io.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #ifndef _IO_H_
  2. #define _IO_H_
  3. /*
  4. * Copyright (C) 2001-2004 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. * $Log: io.h,v $
  36. * Revision 1.7 2007/05/02 11:30:33 haraldkipp
  37. * Mapped _write_P to _write for non Harvard architectures.
  38. *
  39. * Revision 1.6 2006/10/08 16:48:09 haraldkipp
  40. * Documentation fixed
  41. *
  42. * Revision 1.5 2005/08/05 11:18:00 olereinhardt
  43. * Added support for _seek, _tell, fseek, ftell functions
  44. *
  45. * Revision 1.4 2005/08/02 17:46:47 haraldkipp
  46. * Major API documentation update.
  47. *
  48. * Revision 1.3 2004/07/30 19:10:42 drsung
  49. * First proposal to define some global ioctl commands.
  50. *
  51. */
  52. #include <sys/types.h>
  53. /*!
  54. * \addtogroup xgCrtLowio
  55. */
  56. /*@{*/
  57. /*
  58. * Some global definitions for ioctl commands.
  59. */
  60. #define IOCTL_GETSTATUS 0x0001
  61. #define IOCTL_SETSTATUS 0x0002
  62. #define IOCTL_SETBUFFERMODE 0x0003
  63. #define IOCTL_GETBUFFERMODE 0x0004
  64. #define IOCTL_GETOUTBUFSIZE 0x0005
  65. #define IOCTL_SETOUTBUFSIZE 0x0006
  66. #define IOCTL_GETINBUFSIZE 0x0007
  67. #define IOCTL_SETINBUFSIZE 0x0008
  68. /*! \brief Flush the output buffer.
  69. *
  70. * Currently not provided by any known device.
  71. */
  72. #define IOCTL_FLUSHOUTBUF 0x0009
  73. /*! \brief Return the number of bytes currently available in the input buffer.
  74. */
  75. #define IOCTL_GETFILESIZE 0x000A
  76. /*! \brief Return the number of bytes currently available in the input buffer.
  77. */
  78. #define IOCTL_GETOUTBUFCOUNT 0x000B
  79. /*! \brief Return the number of bytes currently available in the output buffer.
  80. */
  81. #define IOCTL_GETINBUFCOUNT 0x000C
  82. /*@}*/
  83. extern int _close(int fd);
  84. extern int _open(CONST char *name, int mode);
  85. extern int _read(int fd, void *buffer, size_t count);
  86. extern int _write(int fd, CONST void *buffer, size_t count);
  87. #ifdef __HARVARD_ARCH__
  88. extern int _write_P(int fd, PGM_P buffer, size_t count);
  89. #else
  90. #define _write_P(fd, buffer, count) _write(fd, buffer, count)
  91. #endif
  92. extern int _seek(int fd, long offset, int origin);
  93. extern long _tell(int fd);
  94. extern int _ioctl(int fd, int cmd, void *buffer);
  95. extern long _filelength(int fd);
  96. #endif