1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
|
/* @(#)dirdefs.h 1.15 04/06/16 Copyright 1987, 1998 J. Schilling */
/*
* Copyright (c) 1987, 1998 J. Schilling
*/
/*
* This program 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 2, or (at your option)
* any later version.
*
* This program 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
* this program; see the file COPYING. If not, write to the Free Software
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _DIRDEFS_H
#define _DIRDEFS_H
#ifndef _MCONFIG_H
#include <mconfig.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifdef JOS
# ifndef _INCL_SYS_STYPES_H
# include <sys/stypes.h>
# define _INCL_SYS_STYPES_H
# endif
# ifndef _INCL_SYS_FILEDESC_H
# include <sys/filedesc.h>
# define _INCL_SYS_FILEDESC_H
# endif
# define NEED_READDIR
# define dirent _direct
# define DIR_NAMELEN(dirent) strlen((dirent)->d_name)
# define DIRSIZE 30
# define FOUND_DIRSIZE
typedef struct _dirent {
char name[DIRSIZE];
short ino;
} dirent;
#else /* !JOS */
# ifndef _INCL_SYS_TYPES_H
# include <sys/types.h>
# define _INCL_SYS_TYPES_H
# endif
# ifndef _INCL_SYS_STAT_H
# include <sys/stat.h>
# define _INCL_SYS_STAT_H
# endif
# ifdef HAVE_LIMITS_H
# ifndef _INCL_LIMITS_H
# include <limits.h>
# define _INCL_LIMITS_H
# endif
# endif
# ifdef HAVE_SYS_PARAM_H
# ifndef _INCL_SYS_PARAM_H
# include <sys/param.h>
# define _INCL_SYS_PARAM_H
# endif
# endif
# ifdef HAVE_DIRENT_H /* This a POSIX compliant system */
# ifndef _INCL_DIRENT_H
# include <dirent.h>
# define _INCL_DIRENT_H
# endif
# define DIR_NAMELEN(dirent) strlen((dirent)->d_name)
# define _FOUND_DIR_
# else /* This is a Pre POSIX system */
# define dirent direct
# define DIR_NAMELEN(dirent) (dirent)->d_namlen
# if defined(HAVE_SYS_DIR_H)
# ifndef _INCL_SYS_DIR_H
# include <sys/dir.h>
# define _INCL_SYS_DIR_H
# endif
# define _FOUND_DIR_
# endif
# if defined(HAVE_NDIR_H) && !defined(_FOUND_DIR_)
# ifndef _INCL_NDIR_H
# include <ndir.h>
# define _INCL_NDIR_H
# endif
# define _FOUND_DIR_
# endif
# if defined(HAVE_SYS_NDIR_H) && !defined(_FOUND_DIR_)
# ifndef _INCL_SYS_NDIR_H
# include <sys/ndir.h>
# define _INCL_SYS_NDIR_H
# endif
# define _FOUND_DIR_
# endif
# endif /* HAVE_DIRENT_H */
# if defined(_FOUND_DIR_)
/*
* Don't use defaults here to allow recognition of problems.
*/
# ifdef MAXNAMELEN
# define DIRSIZE MAXNAMELEN /* From sys/param.h */
# define FOUND_DIRSIZE
# else
# ifdef MAXNAMLEN
# define DIRSIZE MAXNAMLEN /* From dirent.h */
# define FOUND_DIRSIZE
# else
# ifdef DIRSIZ
# define DIRSIZE DIRSIZ /* From sys/dir.h */
# define FOUND_DIRSIZE
# endif
# endif
# endif
# else /* !_FOUND_DIR_ */
# define NEED_DIRENT
# define NEED_READDIR
# define dirent _direct
# define DIR_NAMELEN(dirent) strlen((dirent)->d_name)
# endif /* _FOUND_DIR_ */
#ifdef NEED_DIRENT
#ifndef FOUND_DIRSIZE
#define DIRSIZE 14 /* The old UNIX standard value */
#define FOUND_DIRSIZE
#endif
typedef struct _dirent {
short ino;
char name[DIRSIZE];
} dirent;
#endif /* NEED_DIRENT */
#endif /* !JOS */
#ifdef NEED_READDIR
typedef struct __dirdesc {
FILE *dd_fd;
} DIR;
struct _direct {
unsigned long d_ino;
unsigned short d_reclen;
unsigned short d_namlen;
char d_name[DIRSIZE +1];
};
extern DIR *opendir();
extern closedir();
extern struct dirent *readdir();
#endif /* NEED_READDIR */
#ifdef __cplusplus
}
#endif
#endif /* _DIRDEFS_H */
|