io.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright (C) 2001-2004 by egnite Software GmbH. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. Neither the name of the copyright holders nor the names of
  14. * contributors may be used to endorse or promote products derived
  15. * from this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  20. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  21. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  22. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  23. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  24. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  25. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  26. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  27. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. * SUCH DAMAGE.
  29. *
  30. * For additional information see http://www.ethernut.de/
  31. */
  32. /*
  33. * $Log$
  34. * Revision 1.7 2007/05/02 11:30:33 haraldkipp
  35. * Mapped _write_P to _write for non Harvard architectures.
  36. *
  37. * Revision 1.6 2006/10/08 16:48:09 haraldkipp
  38. * Documentation fixed
  39. *
  40. * Revision 1.5 2005/08/05 11:18:00 olereinhardt
  41. * Added support for _seek, _tell, fseek, ftell functions
  42. *
  43. * Revision 1.4 2005/08/02 17:46:47 haraldkipp
  44. * Major API documentation update.
  45. *
  46. * Revision 1.3 2004/07/30 19:10:42 drsung
  47. * First proposal to define some global ioctl commands.
  48. *
  49. */
  50. #ifndef _NUT_IO_H_
  51. #define _NUT_IO_H_
  52. #include <cfg/crt.h>
  53. #include <sys/types.h>
  54. /*!
  55. * \addtogroup xgCrtLowio
  56. */
  57. /*@{*/
  58. #ifndef FOPEN_MAX
  59. #define FOPEN_MAX 8 /*!< \brief Default maximum number of open streams.
  60. \showinitializer */
  61. #endif
  62. /*
  63. * Some global definitions for ioctl commands.
  64. */
  65. #define IOCTL_GETSTATUS 0x0001
  66. #define IOCTL_SETSTATUS 0x0002
  67. #define IOCTL_SETBUFFERMODE 0x0003
  68. #define IOCTL_GETBUFFERMODE 0x0004
  69. #define IOCTL_GETOUTBUFSIZE 0x0005
  70. #define IOCTL_SETOUTBUFSIZE 0x0006
  71. #define IOCTL_GETINBUFSIZE 0x0007
  72. #define IOCTL_SETINBUFSIZE 0x0008
  73. /*! \brief Flush the output buffer.
  74. *
  75. * Currently not provided by any known device.
  76. */
  77. #define IOCTL_FLUSHOUTBUF 0x0009
  78. /*! \brief Return the number of bytes currently available in the input buffer.
  79. */
  80. #define IOCTL_GETFILESIZE 0x000A
  81. /*! \brief Return the number of bytes currently available in the input buffer.
  82. */
  83. #define IOCTL_GETOUTBUFCOUNT 0x000B
  84. /*! \brief Return the number of bytes currently available in the output buffer.
  85. */
  86. #define IOCTL_GETINBUFCOUNT 0x000C
  87. /*@}*/
  88. extern int _close(int fd);
  89. extern int _open(const char *name, int mode);
  90. extern int _read(int fd, void *buffer, size_t count);
  91. extern int _write(int fd, const void *buffer, size_t count);
  92. #ifdef __HARVARD_ARCH__
  93. extern int _write_P(int fd, PGM_P buffer, size_t count);
  94. #else
  95. #define _write_P(fd, buffer, count) _write(fd, buffer, count)
  96. #endif
  97. extern int _seek(int fd, long offset, int origin);
  98. extern long _tell(int fd);
  99. extern int _ioctl(int fd, int cmd, void *buffer);
  100. extern long _filelength(int fd);
  101. #endif