summaryrefslogtreecommitdiff
path: root/dirent
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1991-01-30 10:25:34 +0000
committerRoland McGrath <roland@gnu.org>1991-01-30 10:25:34 +0000
commitc2547ce6a46f905a7f876f3e2c35e6e9e9b36527 (patch)
tree2b619afb1196c20c60ea0272412e589ad8a9039d /dirent
parent1c078555037a905f1e9bb29951e5e16420d66992 (diff)
Initial revision
Diffstat (limited to 'dirent')
-rw-r--r--dirent/Makefile27
-rw-r--r--dirent/list.c63
2 files changed, 90 insertions, 0 deletions
diff --git a/dirent/Makefile b/dirent/Makefile
new file mode 100644
index 0000000000..41d3b36530
--- /dev/null
+++ b/dirent/Makefile
@@ -0,0 +1,27 @@
+# Copyright (C) 1991 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 1, or (at your option)
+# any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with the GNU C Library; see the file COPYING. If not, write to
+# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#
+# Sub-makefile for dirent portion of the library.
+#
+subdir := dirent
+
+routines := opendir closedir readdir rewinddir seekdir telldir
+
+tests := list
+
+include ../Rules
diff --git a/dirent/list.c b/dirent/list.c
new file mode 100644
index 0000000000..11e81d0f70
--- /dev/null
+++ b/dirent/list.c
@@ -0,0 +1,63 @@
+/* Copyright (C) 1991 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 1, or (at your option)
+any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with the GNU C Library; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <dirent.h>
+
+
+void
+DEFUN(test, (name), CONST char *name)
+{
+ DIR *dirp;
+ struct dirent *entp;
+
+ puts(name);
+
+ dirp = opendir(name);
+ if (dirp == NULL)
+ {
+ perror("opendir");
+ return;
+ }
+
+ while ((entp = readdir(dirp)) != NULL)
+ printf("%s\tfile number %lu\n",
+ entp->d_name, (unsigned long int) entp->d_fileno);
+
+ if (closedir(dirp) < 0)
+ perror("closedir");
+}
+
+int
+DEFUN(main, (argc, argv), int argc AND char **argv)
+{
+ --argc;
+ ++argv;
+
+ if (argc == 0)
+ test(".");
+ else
+ while (argc-- > 0)
+ test(*argv++);
+
+ exit(0);
+ return(0);
+}