dirent.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* Generic dirent.h */
  2. /* $OpenLDAP$ */
  3. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  4. *
  5. * Copyright 1998-2022 The OpenLDAP Foundation.
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted only as authorized by the OpenLDAP
  10. * Public License.
  11. *
  12. * A copy of this license is available in file LICENSE in the
  13. * top-level directory of the distribution or, alternatively, at
  14. * <http://www.OpenLDAP.org/license.html>.
  15. */
  16. #ifndef _AC_DIRENT_H
  17. #define _AC_DIRENT_H
  18. #ifdef HAVE_DIRENT_H
  19. # include <dirent.h>
  20. # define NAMLEN(dirent) strlen((dirent)->d_name)
  21. #elif defined(_MSC_VER)
  22. #include <windows.h>
  23. #ifndef MAX_PATH
  24. #define MAX_PATH 260
  25. #endif
  26. struct dirent {
  27. char *d_name;
  28. };
  29. typedef struct DIR {
  30. HANDLE dir;
  31. struct dirent data;
  32. int first;
  33. char buf[MAX_PATH+1];
  34. } DIR;
  35. DIR *opendir(const char *name);
  36. struct dirent *readdir(DIR *dir);
  37. int closedir(DIR *dir);
  38. #else
  39. # define dirent direct
  40. # define NAMLEN(dirent) (dirent)->d_namlen
  41. # ifdef HAVE_SYS_NDIR_H
  42. # include <sys/ndir.h>
  43. # endif
  44. # ifdef HAVE_SYS_DIR_H
  45. # include <sys/dir.h>
  46. # endif
  47. # ifdef HAVE_NDIR_H
  48. # include <ndir.h>
  49. # endif
  50. #endif
  51. #endif /* _AC_DIRENT_H */