dirent.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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 THE COPYRIGHT HOLDERS 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 THE
  23. * COPYRIGHT OWNER 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$
  72. * Revision 1.3 2008/08/11 06:59:58 haraldkipp
  73. * BSD types replaced by stdint types (feature request #1282721).
  74. *
  75. * Revision 1.2 2006/01/05 16:45:20 haraldkipp
  76. * Dynamic NUTFILE allocation for detached block device.
  77. *
  78. * Revision 1.1 2005/02/05 20:37:17 haraldkipp
  79. * Peanut added
  80. *
  81. *
  82. * \endverbatim
  83. */
  84. #include <stdint.h>
  85. #include <sys/file.h>
  86. /*!
  87. * \addtogroup xgFS
  88. */
  89. /*@{*/
  90. /*!
  91. * \name File System Directory Configuration
  92. *
  93. * The Nut/OS Configurator may be used to override the default values.
  94. */
  95. /*@{*/
  96. /*!
  97. * \brief UDP port of DHCP server.
  98. *
  99. * \showinitializer
  100. */
  101. #ifndef MAXNAMLEN
  102. #define MAXNAMLEN 255
  103. #endif
  104. /*@}*/
  105. /*!
  106. * \brief Directory entry structure.
  107. *
  108. * This structure is returned by readdir(). It is not optimal
  109. * for Nut/OS, but compatible to *nix systems.
  110. */
  111. struct dirent {
  112. uint32_t d_fileno; /*!< \brief File number, unused. */
  113. uint16_t d_reclen; /*!< \brief Record length, unused. */
  114. uint8_t d_type; /*!< \brief File type, 0=regular, 1=directory. */
  115. uint8_t d_namlen; /*!< \brief Length of string in d_name. */
  116. char d_name[MAXNAMLEN + 1]; /*!< \brief Name of this entry. */
  117. };
  118. /*!
  119. * \brief Internally used directory information structure.
  120. *
  121. * Applications should ignore its contents.
  122. */
  123. typedef struct _dirdesc {
  124. NUTFILE *dd_fd; /*!< \brief File descriptor associated with directory */
  125. char *dd_buf; /*!< \brief Data buffer */
  126. size_t dd_len; /*!< \brief Size of data buffer */
  127. } DIR;
  128. /*@}*/
  129. extern DIR *opendir(const char *);
  130. extern struct dirent *readdir(DIR *);
  131. extern int closedir(DIR *);
  132. #endif