Penguin
Blame: alphasort(3)
EditPageHistoryDiffInfoLikePages
Annotated edit history of alphasort(3) version 1, including all changes. View license author blame.
Rev Author # Line
1 perry 1 SCANDIR
2 !!!SCANDIR
3 NAME
4 SYNOPSIS
5 DESCRIPTION
6 RETURN VALUE
7 ERRORS
8 CONFORMING TO
9 EXAMPLE
10 SEE ALSO
11 ----
12 !!NAME
13
14
15 scandir, alphasort, versionsort - scan a directory for matching entries
16 !!SYNOPSIS
17
18
19 __#include
20 __''dir''__, struct dirent ***__''namelist''__,
21 int (*__''select''__)(const struct dirent *),
22 int (*__''compar''__)(const void *, const void *));
23 int alphasort(const void *__''a''__, const void *__''b''__);
24 int versionsort(const void *__''a''__, const void *__''b''__);
25 __
26 !!DESCRIPTION
27
28
29 The __scandir()__ function scans the directory
30 ''dir'', calling __select()__ on each directory entry.
31 Entries for which __select()__ returns non-zero are
32 stored in strings allocated via __malloc()__, sorted
33 using __qsort()__ with the comparison function
34 __compar()__, and collected in array ''namelist''
35 which is allocated via __malloc()__.
36
37
38 The __alphasort()__ and __versionsort()__ functions
39 can be used as the comparison function for the
40 __scandir()__ function to sort the directory entries into
41 alphabetical order. Although they parameters point to void,
42 they are in fact pointers to pointers (__struct
43 dirent**__) to two directory entries, ''a'' and
44 ''b'', to compare.
45
46
47 __alphasort()__ will order the files with
48 strcoll(3), while __versionsort()__ will use
49 strverscmp(3).
50 !!RETURN VALUE
51
52
53 The __scandir()__ function returns the number of
54 directory entries selected or -1 if an error
55 occurs.
56
57
58 The __alphasort()__ and __versionsort()__ functions
59 return an integer less than, equal to, or greater than zero
60 if the first argument is considered to be respectively less
61 than, equal to, or greater than the second.
62 !!ERRORS
63
64
65 __ENOMEM__
66
67
68 Insufficient memory to complete the operation.
69 !!CONFORMING TO
70
71
72 BSD 4.3
73 !!EXAMPLE
74
75
76 /* print files in current directory in reverse order */
77 #include
78 !!SEE ALSO
79
80
81 opendir(3), readdir(3), closedir(3),
82 rewinddir(3), telldir(3),
83 seekdir(3)
84 ----
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.