| 1 |
sysadm |
1.1 |
/*
|
| 2 |
|
|
* Copyright (C) 2001 Dizzy (dizzy@roedu.net)
|
| 3 |
|
|
*
|
| 4 |
|
|
* This program is free software; you can redistribute it and/or
|
| 5 |
|
|
* modify it under the terms of the GNU General Public License
|
| 6 |
|
|
* as published by the Free Software Foundation; either version 2
|
| 7 |
|
|
* of the License, or (at your option) any later version.
|
| 8 |
|
|
*
|
| 9 |
|
|
* This program 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
|
| 12 |
|
|
* GNU General Public License for more details.
|
| 13 |
|
|
*
|
| 14 |
|
|
* You should have received a copy of the GNU General Public License
|
| 15 |
|
|
* along with this program; if not, write to the Free Software
|
| 16 |
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
| 17 |
|
|
*/
|
| 18 |
|
|
#ifndef INCLUDED_PDIR_TYPES
|
| 19 |
|
|
#define INCLUDED_PDIR_TYPES
|
| 20 |
|
|
|
| 21 |
|
|
#ifdef PDIR_INTERNAL_ACCESS
|
| 22 |
|
|
|
| 23 |
|
|
#ifdef JUST_NEED_TYPES
|
| 24 |
|
|
# ifdef HAVE_DIRENT_H
|
| 25 |
|
|
# include <dirent.h>
|
| 26 |
|
|
# else
|
| 27 |
|
|
# ifdef HAVE_SYS_NDIR_H
|
| 28 |
|
|
# include <sys/ndir.h>
|
| 29 |
|
|
# endif
|
| 30 |
|
|
# if HAVE_SYS_DIR_H
|
| 31 |
|
|
# include <sys/dir.h>
|
| 32 |
|
|
# endif
|
| 33 |
|
|
# if HAVE_NDIR_H
|
| 34 |
|
|
# include <ndir.h>
|
| 35 |
|
|
# endif
|
| 36 |
|
|
# define dirent direct
|
| 37 |
|
|
# endif
|
| 38 |
|
|
# ifdef WIN32
|
| 39 |
|
|
# include <io.h> /* for _findfirst(), _findnext(), etc */
|
| 40 |
|
|
# endif
|
| 41 |
|
|
#else
|
| 42 |
|
|
# define JUST_NEED_TYPES
|
| 43 |
|
|
# ifdef HAVE_DIRENT_H
|
| 44 |
|
|
# include <dirent.h>
|
| 45 |
|
|
# else
|
| 46 |
|
|
# ifdef HAVE_SYS_NDIR_H
|
| 47 |
|
|
# include <sys/ndir.h>
|
| 48 |
|
|
# endif
|
| 49 |
|
|
# if HAVE_SYS_DIR_H
|
| 50 |
|
|
# include <sys/dir.h>
|
| 51 |
|
|
# endif
|
| 52 |
|
|
# if HAVE_NDIR_H
|
| 53 |
|
|
# include <ndir.h>
|
| 54 |
|
|
# endif
|
| 55 |
|
|
# define dirent direct
|
| 56 |
|
|
# endif
|
| 57 |
|
|
# ifdef WIN32
|
| 58 |
|
|
# include <io.h> /* for _findfirst(), _findnext(), etc */
|
| 59 |
|
|
# endif
|
| 60 |
|
|
# undef JUST_NEED_TYPES
|
| 61 |
|
|
#endif
|
| 62 |
|
|
|
| 63 |
|
|
#endif
|
| 64 |
|
|
|
| 65 |
|
|
typedef struct pdir_struct
|
| 66 |
|
|
#ifdef PDIR_INTERNAL_ACCESS
|
| 67 |
|
|
{
|
| 68 |
|
|
char const * path;
|
| 69 |
|
|
char const * lastret;
|
| 70 |
|
|
#ifdef WIN32
|
| 71 |
|
|
long lFindHandle;
|
| 72 |
|
|
struct _finddata_t fileinfo;
|
| 73 |
|
|
int status; /* -1 == failure, 0 == freshly opened, 1 == opened and read, 2 == eof */
|
| 74 |
|
|
#else /* POSIX */
|
| 75 |
|
|
DIR * dir;
|
| 76 |
|
|
#endif
|
| 77 |
|
|
}
|
| 78 |
|
|
#endif
|
| 79 |
|
|
t_pdir;
|
| 80 |
|
|
|
| 81 |
|
|
#endif
|
| 82 |
|
|
|
| 83 |
|
|
#ifndef JUST_NEED_TYPES
|
| 84 |
|
|
#ifndef INCLUDED_PDIR_PROTOS
|
| 85 |
|
|
#define INCLUDED_PDIR_PROTOS
|
| 86 |
|
|
|
| 87 |
|
|
extern t_pdir * p_opendir(const char * dirname);
|
| 88 |
|
|
extern int p_rewinddir(t_pdir * pdir);
|
| 89 |
|
|
extern char const * p_readdir(t_pdir * pdir);
|
| 90 |
|
|
extern int p_closedir(t_pdir * pdir);
|
| 91 |
|
|
|
| 92 |
|
|
#endif
|
| 93 |
|
|
|
| 94 |
|
|
#endif
|