]> git.ipfire.org Git - thirdparty/glibc.git/blame - dirent/list.c
Update.
[thirdparty/glibc.git] / dirent / list.c
CommitLineData
c84142e8
UD
1/* Copyright (C) 1991, 1993, 1997 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
28f540f4 3
c84142e8
UD
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
28f540f4 8
c84142e8
UD
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
28f540f4 13
c84142e8
UD
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
28f540f4 18
28f540f4
RM
19#include <errno.h>
20#include <stddef.h>
21#include <stdio.h>
22#include <stdlib.h>
23#include <dirent.h>
24
25
26void
c84142e8 27test (const char *name)
28f540f4
RM
28{
29 DIR *dirp;
30 struct dirent *entp;
31
c84142e8 32 puts (name);
28f540f4 33
c84142e8 34 dirp = opendir (name);
28f540f4
RM
35 if (dirp == NULL)
36 {
c84142e8 37 perror ("opendir");
28f540f4
RM
38 return;
39 }
40
41 errno = 0;
c84142e8
UD
42 while ((entp = readdir (dirp)) != NULL)
43 printf ("%s\tfile number %lu\n",
44 entp->d_name, (unsigned long int) entp->d_fileno);
28f540f4
RM
45
46 if (errno)
47 perror ("readdir");
48
c84142e8
UD
49 if (closedir (dirp) < 0)
50 perror ("closedir");
28f540f4
RM
51}
52
53int
c84142e8 54main (int argc, char **argv)
28f540f4
RM
55{
56 --argc;
57 ++argv;
58
59 if (argc == 0)
c84142e8 60 test (".");
28f540f4
RM
61 else
62 while (argc-- > 0)
c84142e8 63 test (*argv++);
28f540f4 64
c84142e8
UD
65 exit (0);
66 return 0;
28f540f4 67}