make rewinddir a function, closedir returns int; POSIX 1003.1
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Sat, 26 May 1990 08:56:07 +0000 (00:56 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Sat, 26 May 1990 08:56:07 +0000 (00:56 -0800)
SCCS-vsn: include/dirent.h 5.9

usr/src/include/dirent.h

index 420613f..bf58e9b 100644 (file)
@@ -1,51 +1,45 @@
-/*
+/*-
  * Copyright (c) 1989 The Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1989 The Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * %sccs.include.redist.c%
  *
  *
- *     @(#)dirent.h    5.8 (Berkeley) %G%
+ *     @(#)dirent.h    5.9 (Berkeley) %G%
  */
 
 #ifndef _DIRENT_
 #define _DIRENT_
 
 /*
  */
 
 #ifndef _DIRENT_
 #define _DIRENT_
 
 /*
- * A directory entry has a struct direct at the front of it,
- * containing its inode number, the length of the entry, and the
- * length of the name contained in the entry.  These are followed
- * by the name padded to a 4 byte boundary with null bytes.  All
- * names are guaranteed null terminated.  The maximum length of a
- * name in a directory is MAXNAMLEN.
+ * A directory entry has a struct direct at the front of it, containing its
+ * inode number, the length of the entry, and the length of the name
+ * contained in the entry.  These are followed by the name padded to a 4
+ * byte boundary with null bytes.  All names are guaranteed null terminated.
+ * The maximum length of a name in a directory is MAXNAMLEN.
  */
  */
-#define        MAXNAMLEN       255
 
 
-struct dirent {
+struct dirent {
        u_long  d_fileno;               /* file number of entry */
        u_short d_reclen;               /* length of this record */
        u_short d_namlen;               /* length of string in d_name */
        u_long  d_fileno;               /* file number of entry */
        u_short d_reclen;               /* length of this record */
        u_short d_namlen;               /* length of string in d_name */
+#ifdef _POSIX_SOURCE
+       char    d_name[255 + 1];        /* name must be no longer than this */
+#else
+#define        MAXNAMLEN       255
        char    d_name[MAXNAMLEN + 1];  /* name must be no longer than this */
        char    d_name[MAXNAMLEN + 1];  /* name must be no longer than this */
+#endif
 };
 };
-#define d_ino d_fileno         /* backward compatibility */
 
 
-/*
- * Definitions for library routines operating on directories.
- */
+#ifdef _POSIX_SOURCE
+typedef void * DIR;
+#else
+
+#define        d_ino           d_fileno        /* backward compatibility */
+
+/* definitions for library routines operating on directories. */
 #define        DIRBLKSIZ       1024
 
 #define        DIRBLKSIZ       1024
 
-/*
- * This structure describes an open directory.
- */
+/* structure describing an open directory. */
 typedef struct _dirdesc {
        int     dd_fd;          /* file descriptor associated with directory */
        long    dd_loc;         /* offset in current buffer */
 typedef struct _dirdesc {
        int     dd_fd;          /* file descriptor associated with directory */
        long    dd_loc;         /* offset in current buffer */
@@ -55,33 +49,36 @@ typedef struct _dirdesc {
        long    dd_seek;        /* magic cookie returned by getdirentries */
 } DIR;
 
        long    dd_seek;        /* magic cookie returned by getdirentries */
 } DIR;
 
-#define dirfd(dirp)    ((dirp)->dd_fd)
+#define        dirfd(dirp)     ((dirp)->dd_fd)
 
 #ifndef NULL
 
 #ifndef NULL
-#define NULL 0
+#define        NULL    0
 #endif
 
 #endif
 
-extern long _rewinddir;
-#define rewinddir(dirp) \
-       _seekdir((dirp), _rewinddir), \
-       _rewinddir = telldir(dirp)
+#endif /* _POSIX_SOURCE */
 
 #ifdef __STDC__
 extern DIR *opendir(const char *);
 extern struct dirent *readdir(DIR *);
 
 #ifdef __STDC__
 extern DIR *opendir(const char *);
 extern struct dirent *readdir(DIR *);
+extern void rewindir(DIR *);
+extern int closedir(DIR *);
+#ifndef _POSIX_SOURCE
 extern long telldir(const DIR *);
 extern void seekdir(DIR *, long);
 extern long telldir(const DIR *);
 extern void seekdir(DIR *, long);
-extern void closedir(DIR *);
 extern int scandir(const char *, struct direct *(*[]),
     int (* )(struct direct *), int (* )(char *, char *));
 extern int alphasort(const struct direct **, const struct direct **);
 extern int scandir(const char *, struct direct *(*[]),
     int (* )(struct direct *), int (* )(char *, char *));
 extern int alphasort(const struct direct **, const struct direct **);
+#endif
 #else
 extern DIR *opendir();
 extern struct dirent *readdir();
 #else
 extern DIR *opendir();
 extern struct dirent *readdir();
+extern void rewinddir();
+extern int closedir();
+#ifndef _POSIX_SOURCE
 extern long telldir();
 extern void seekdir();
 extern long telldir();
 extern void seekdir();
-extern void closedir();
 extern int scandir();
 extern int alphasort();
 #endif
 extern int scandir();
 extern int alphasort();
 #endif
+#endif
 #endif /* _DIRENT_ */
 #endif /* _DIRENT_ */