dirent.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #ifndef _DIRENT_H_
  2. #define _DIRENT_H_
  3. /*
  4. * Copyright (C) 2004-2005 by egnite Software GmbH. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
  23. * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. *
  34. *-
  35. * Parts are
  36. *
  37. * Copyright (c) 1989, 1993
  38. * The Regents of the University of California. All rights reserved.
  39. *
  40. * Redistribution and use in source and binary forms, with or without
  41. * modification, are permitted provided that the following conditions
  42. * are met:
  43. * 1. Redistributions of source code must retain the above copyright
  44. * notice, this list of conditions and the following disclaimer.
  45. * 2. Redistributions in binary form must reproduce the above copyright
  46. * notice, this list of conditions and the following disclaimer in the
  47. * documentation and/or other materials provided with the distribution.
  48. * 3. Neither the name of the University nor the names of its contributors
  49. * may be used to endorse or promote products derived from this software
  50. * without specific prior written permission.
  51. *
  52. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  53. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  54. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  55. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  56. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  57. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  58. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  59. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  60. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  61. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  62. * SUCH DAMAGE.
  63. *
  64. */
  65. /*!
  66. * \file dirent.h
  67. * \brief Filesystem directory structure.
  68. *
  69. * \verbatim
  70. *
  71. * $Log: dirent.h,v $
  72. * Revision 1.2 2006/01/05 16:45:20 haraldkipp
  73. * Dynamic NUTFILE allocation for detached block device.
  74. *
  75. * Revision 1.1 2005/02/05 20:37:17 haraldkipp
  76. * Peanut added
  77. *
  78. *
  79. * \endverbatim
  80. */
  81. #include <sys/file.h>
  82. /*!
  83. * \addtogroup xgFS
  84. */
  85. /*@{*/
  86. /*!
  87. * \name File System Directory Configuration
  88. *
  89. * The Nut/OS Configurator may be used to override the default values.
  90. */
  91. /*@{*/
  92. /*!
  93. * \brief UDP port of DHCP server.
  94. *
  95. * \showinitializer
  96. */
  97. #ifndef MAXNAMLEN
  98. #define MAXNAMLEN 255
  99. #endif
  100. /*@}*/
  101. /*!
  102. * \brief Directory entry structure.
  103. *
  104. * This structure is returned by readdir(). It is not optimal
  105. * for Nut/OS, but compatible to *nix systems.
  106. */
  107. struct dirent {
  108. u_long d_fileno; /*!< \brief File number, unused. */
  109. u_short d_reclen; /*!< \brief Record length, unused. */
  110. u_char d_type; /*!< \brief File type, 0=regular, 1=directory. */
  111. u_char d_namlen; /*!< \brief Length of string in d_name. */
  112. char d_name[MAXNAMLEN + 1]; /*!< \brief Name of this entry. */
  113. };
  114. /*!
  115. * \brief Internally used directory information structure.
  116. *
  117. * Applications should ignore its contents.
  118. */
  119. typedef struct _dirdesc {
  120. NUTFILE *dd_fd; /*!< \brief File descriptor associated with directory */
  121. char *dd_buf; /*!< \brief Data buffer */
  122. size_t dd_len; /*!< \brief Size of data buffer */
  123. } DIR;
  124. /*@}*/
  125. __BEGIN_DECLS
  126. /* */
  127. extern DIR *opendir(CONST char *);
  128. extern struct dirent *readdir(DIR *);
  129. extern int closedir(DIR *);
  130. __END_DECLS
  131. /* */
  132. #endif