Annotation of 43BSDTahoe/man/man3/scandir.3, revision 1.1.1.1

1.1       root        1: .\" Copyright (c) 1983 Regents of the University of California.
                      2: .\" All rights reserved.  The Berkeley software License Agreement
                      3: .\" specifies the terms and conditions for redistribution.
                      4: .\"
                      5: .\"    @(#)scandir.3   6.2 (Berkeley) 9/17/85
                      6: .\"
                      7: .TH SCANDIR 3  "September 17, 1985"
                      8: .UC 5
                      9: .SH NAME
                     10: scandir, alphasort \- scan a directory
                     11: .SH SYNOPSIS
                     12: .nf
                     13: .B #include <sys/types.h>
                     14: .B #include <sys/dir.h>
                     15: .PP
                     16: .B scandir(dirname, namelist, select, compar)
                     17: .B char *dirname;
                     18: .B struct direct *(*namelist[]);
                     19: .B int (*select)();
                     20: .B int (*compar)();
                     21: .PP
                     22: .B alphasort(d1, d2)
                     23: .B struct direct **d1, **d2;
                     24: .fi
                     25: .SH DESCRIPTION
                     26: .I Scandir
                     27: reads the directory
                     28: .I dirname
                     29: and builds an array of pointers to directory
                     30: entries using
                     31: .IR malloc (3).
                     32: It returns the number of entries in the array and a pointer to the
                     33: array through
                     34: .IR namelist .
                     35: .PP
                     36: The
                     37: .I select
                     38: parameter is a pointer to a user supplied subroutine which is called by
                     39: .I scandir
                     40: to select which entries are to be included in the array.
                     41: The select routine is passed a
                     42: pointer to a directory entry and should return a non-zero
                     43: value if the directory entry is to be included in the array.
                     44: If
                     45: .I select
                     46: is null, then all the directory entries will be included.
                     47: .PP
                     48: The
                     49: .I compar
                     50: parameter is a pointer to a user supplied subroutine which is passed to
                     51: .IR qsort (3)
                     52: to sort the completed array. If this pointer is null, the array is not sorted.
                     53: .I Alphasort
                     54: is a routine which can be used for the
                     55: .I compar
                     56: parameter to sort the array alphabetically.
                     57: .PP
                     58: The memory allocated for the array can be deallocated with
                     59: .I free
                     60: (see
                     61: .IR malloc (3))
                     62: by freeing each pointer in the array and the array itself.
                     63: .SH "SEE ALSO"
                     64: directory(3),
                     65: malloc(3),
                     66: qsort(3),
                     67: dir(5)
                     68: .SH DIAGNOSTICS
                     69: Returns \-1 if the directory cannot be opened for reading or if
                     70: .IR malloc (3)
                     71: cannot allocate enough memory to hold all the data structures.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.