home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / linux / backup / star-1.3.1.tar.gz / star-1.3.1.tar / star-1.3.1 / include / dirdefs.h < prev    next >
C/C++ Source or Header  |  2001-02-17  |  3KB  |  133 lines

  1. /* @(#)dirdefs.h    1.11 01/02/17 Copyright 1987, 1998 J. Schilling */
  2. /*
  3.  *    Copyright (c) 1987, 1998 J. Schilling
  4.  */
  5. /*
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2, or (at your option)
  9.  * any later version.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program; see the file COPYING.  If not, write to
  18.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  */
  20.  
  21. #ifndef    _DIRDEFS_H
  22. #define    _DIRDEFS_H
  23.  
  24. #ifndef _MCONFIG_H
  25. #include <mconfig.h>
  26. #endif
  27.  
  28. #ifdef    __cplusplus
  29. extern "C" {
  30. #endif
  31.  
  32. #ifdef JOS
  33. #    include <sys/stypes.h>
  34. #    include <sys/filedesc.h>
  35. #    define    NEED_READDIR
  36. #    define    DIRSIZE    30
  37.     typedef struct dirent {
  38.         char    name[DIRSIZE];
  39.         short    ino;
  40.     } dirent;
  41.  
  42. #else    /* !JOS */
  43.  
  44. #    ifndef    _INCL_SYS_TYPES_H
  45. #    include <sys/types.h>
  46. #    define    _INCL_SYS_TYPES_H
  47. #    endif
  48. #    include <sys/stat.h>
  49. #    ifdef    HAVE_SYS_PARAM_H
  50. #        include    <sys/param.h>
  51. #    endif
  52.  
  53. #    ifdef    HAVE_DIRENT_H        /* This a POSIX compliant system */
  54. #        include <dirent.h>
  55. #        define    DIR_NAMELEN(dirent)    strlen((dirent)->d_name)
  56. #        define    _FOUND_DIR_
  57. #    else                /* This is a Pre POSIX system     */
  58.  
  59. #    define     dirent    direct
  60. #    define    DIR_NAMELEN(dirent)    (dirent)->d_namlen
  61.  
  62. #    if    defined(HAVE_SYS_DIR_H)
  63. #        include <sys/dir.h>
  64. #        define    _FOUND_DIR_
  65. #    endif
  66.  
  67. #    if    defined(HAVE_NDIR_H) && !defined(_FOUND_DIR_)
  68. #        include <ndir.h>
  69. #        define    _FOUND_DIR_
  70. #    endif
  71.  
  72. #    if    defined(HAVE_SYS_NDIR_H) && !defined(_FOUND_DIR_)
  73. #        include <sys/ndir.h>
  74. #        define    _FOUND_DIR_
  75. #    endif
  76. #    endif    /* HAVE_DIRENT_H */
  77.  
  78. #    if    defined(_FOUND_DIR_)
  79. /*
  80.  * Don't use defaults here to allow recognition of problems.
  81.  */
  82. #    ifdef    MAXNAMELEN
  83. #        define    DIRSIZE        MAXNAMELEN    /* From sys/param.h  */
  84. #    else
  85. #    ifdef    MAXNAMLEN
  86. #        define    DIRSIZE        MAXNAMLEN    /* From dirent.h     */
  87. #    else
  88. #        define    DIRSIZE        DIRSIZ        /* From sys/dir.h    */
  89. #    endif
  90. #    endif
  91. #    else    /* !_FOUND_DIR_ */
  92.  
  93. #        define    NEED_DIRENT
  94. #        define    NEED_READDIR
  95.  
  96. #    endif    /* _FOUND_DIR_ */
  97.  
  98.  
  99. #ifdef    NEED_DIRENT
  100.  
  101. typedef struct dirent {
  102.     short    ino;
  103.     char    name[DIRSIZE];
  104. } dirent;
  105.  
  106. #endif    /* NEED_DIRENT */
  107.  
  108. #endif    /* !JOS */
  109.  
  110. #ifdef    NEED_READDIR
  111.     typedef struct __dirdesc {
  112.         FILE    *dd_fd;
  113.     } DIR;
  114.  
  115.     struct _direct {
  116.         unsigned long    d_ino;
  117.         unsigned short    d_reclen;
  118.         unsigned short    d_namlen;
  119.         char        d_name[DIRSIZE +1];
  120.     };
  121.  
  122. extern    DIR        *opendir();
  123. extern            closedir();
  124. extern    struct direct    *readdir();
  125.  
  126. #endif    /* NEED_READDIR */
  127.  
  128. #ifdef    __cplusplus
  129. }
  130. #endif
  131.  
  132. #endif    /* _DIRDEFS_H */
  133.