Imported tab->space correction by redhat
[infodrom/manpages-de] / man3 / scandir.3
1 .\" Copyright (c) 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one
11 .\" 
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\" 
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" References consulted:
24 .\"     Linux libc source code
25 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
26 .\"     386BSD man pages
27 .\" Modified Sat Jul 24 18:26:16 1993 by Rik Faith <faith@cs.unc.edu>
28 .\" Modified 18 Mar 1996 by Martin Schulze <joey@infodrom.north.de>:
29 .\"   Corrected arguments to compar-routine
30 .\" Translated into german 02 June 1996 by Markus Kaufmann
31 .\"                                        <markus.kaufmann@gmx.de>
32 .\"
33 .TH SCANDIR 3  "2. Juni 1996" "GNU" "Linux Bibliotheksfunktionen"
34 .SH BEZEICHNUNG
35 scandir, alphasort \- durchsucht ein Verzeichnis nach passenden Einträgen
36 .SH ÜBERSICHT
37 .nf
38 .B #include <dirent.h>
39 .sp
40 .BI "int scandir(const char *" dir ", struct dirent ***" namelist ,
41 .RS
42 .BI "int (*" select ")(const struct dirent *),"
43 .BI "int (*" compar ")(const struct dirent *, const struct dirent *));
44 .RE
45 .sp
46 .BI "int alphasort(const struct dirent *" a ", const struct dirent *" b );
47 .fi
48 .SH BESCHREIBUNG
49 Die 
50 .BR scandir() \-Funktion
51 durchsucht das Verzeichnis
52 .I dir
53 und ruft für jeden Verzeichniseintrag
54 .B select()
55 auf.
56 Die Einträge, bei denen 
57 .B select()
58 einen Wert ungleich 0 zurückliefert werden in Strings gespeichert. Der
59 Speicher wird dabei mit
60 .B malloc()
61 reserviert. Danach werden die Strings mit
62 .B sort()
63 sortiert wobei die Vergleichsroutine
64 .B compar()
65 benutzt wird. Am Schluss werden die Strings im Array
66 .I namelist
67 gespeichert, dessen Speicher ebenfalls mit 
68 .B malloc()
69 reserviert wird.
70 .PP
71 Die
72 .BR alphasort() \-Funktion
73 kann als Vergleichsroutine für die 
74 .BR scandir() \-Funktion
75 benutzt werden um die Verzeichniseinträge alphabetisch zu sortieren.
76 Die Parameter sind die beiden Verzeichniseinträge
77 .I a 
78 und 
79 .I b
80 die verglichen werden sollen.
81 .SH "RÜCKGABEWERT"
82 Die 
83 .BR scandir() \-Funktion
84 liefert die Anzahl gelesener Verzeichniseinträge oder \-1 im Fehlerfall
85 zurück.
86 .PP
87 Die 
88 .BR alphasort() -Funktion 
89 liefert eine Zahl kleiner 0 zurück wenn das erste
90 Argument im Alphabet vor dem zweiten Argument kommt, genau 0 wenn beide
91 gleich sind und eine Zahl größer 0 wenn das erste Argument im Alphabet nach
92 dem zweiten Argument kommt.
93 .SH "FEHLER"
94 .TP
95 .B ENOMEM
96 Zu wenig Speicher um den Vorgang zu beenden.
97 .SH "KONFORM ZU"
98 BSD 4.3
99 .SH SIEHE AUCH
100 .BR opendir (3),
101 .BR readdir (3), 
102 .BR closedir (3), 
103 .BR rewinddir (3),
104 .BR telldir (3),
105 .BR seekdir (3).
106