Advertisement
NaZaRa

stdio.h - Standart input/output

Jan 16th, 2013
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.38 KB | None | 0 0
  1. /*
  2. * Copyright (c) 1990 The Regents of the University of California.
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms are permitted
  6. * provided that the above copyright notice and this paragraph are
  7. * duplicated in all such forms and that any documentation,
  8. * advertising materials, and other materials related to such
  9. * distribution and use acknowledge that the software was developed
  10. * by the University of California, Berkeley.  The name of the
  11. * University may not be used to endorse or promote products derived
  12. * from this software without specific prior written permission.
  13. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  14. * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  15. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  16. *
  17. *      @(#)stdio.h     5.3 (Berkeley) 3/15/86
  18. */
  19.  
  20. /*
  21. * NB: to fit things in six character monocase externals, the
  22. * stdio code uses the prefix `__s' for stdio objects, typically
  23. * followed by a three-character attempt at a mnemonic.
  24. */
  25.  
  26. #ifndef _STDIO_H_
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. #define _STDIO_H_
  31. #define _FSTDIO                 /* ``function stdio'' */
  32. #define __need_size_t
  33. #include <stddef.h>
  34. #define __need___va_list
  35. #include <stdarg.h>
  36. /*
  37. * <sys/reent.h> defines __sFILE, _fpos_t.
  38. * They must be defined there because struct _reent needs them (and we don't
  39. * want reent.h to include this file.
  40. */
  41.  
  42. struct __sFile
  43. {
  44. int unused;
  45. };
  46.  
  47. typedef struct __sFILE FILE;
  48.  
  49. #define __SLBF  0x0001          /* line buffered */
  50. #define __SNBF  0x0002          /* unbuffered */
  51. #define __SRD   0x0004          /* OK to read */
  52. #define __SWR   0x0008          /* OK to write */
  53. /* RD and WR are never simultaneously asserted */
  54. #define __SRW   0x0010          /* open for reading & writing */
  55. #define __SEOF  0x0020          /* found EOF */
  56. #define __SERR  0x0040          /* found error */
  57. #define __SMBF  0x0080          /* _buf is from malloc */
  58. #define __SAPP  0x0100          /* fdopen()ed in append mode - so must  write to end */
  59. #define __SSTR  0x0200          /* this is an sprintf/snprintf string */
  60. #define __SOPT  0x0400          /* do fseek() optimisation */
  61. #define __SNPT  0x0800          /* do not do fseek() optimisation */
  62. #define __SOFF  0x1000          /* set iff _offset is in fact correct */
  63. #define __SMOD  0x2000          /* true => fgetline modified _p text */
  64. #if defined(__CYGWIN__) || defined(__CYGWIN__)
  65. #define __SCLE        0x4000          /* convert line endings CR/LF <-> NL */
  66. #endif
  67.  
  68. /*
  69. * The following three definitions are for ANSI C, which took them
  70. * from System V, which stupidly took internal interface macros and
  71. * made them official arguments to setvbuf(), without renaming them.
  72. * Hence, these ugly _IOxxx names are *supposed* to appear in user code.
  73. *
  74. * Although these happen to match their counterparts above, the
  75. * implementation does not rely on that (so these could be renumbered).
  76. */
  77. #define _IOFBF  0               /* setvbuf should set fully buffered */
  78. #define _IOLBF  1               /* setvbuf should set line buffered */
  79. #define _IONBF  2               /* setvbuf should set unbuffered */
  80.  
  81. #ifndef NULL
  82. #define NULL    0
  83. #endif
  84.  
  85. #define BUFSIZ  1024
  86.  #define EOF     (-1)
  87.  
  88. #define FOPEN_MAX       20      /* must be <= OPEN_MAX <sys/syslimits.h> */
  89. #define FILENAME_MAX    1024    /* must be <= PATH_MAX <sys/syslimits.h> */
  90. #define L_tmpnam        1024    /* XXX must be == PATH_MAX */
  91. #ifndef __STRICT_ANSI__
  92. #define P_tmpdir        "/tmp"
  93. #endif
  94.  
  95. #ifndef SEEK_SET
  96. #define SEEK_SET        0       /* set file offset to offset */
  97. #endif
  98. #ifndef SEEK_CUR
  99. #define SEEK_CUR        1       /* set file offset to current plus offset */
  100. #endif
  101. #ifndef SEEK_END
  102. #define SEEK_END        2       /* set file offset to EOF plus offset */
  103. #endif
  104.  
  105. #define TMP_MAX         26
  106.  
  107. #define stdin   (_impure_ptr->_stdin)
  108. #define stdout  (_impure_ptr->_stdout)
  109. #define stderr  (_impure_ptr->_stderr)
  110.  
  111. #define _stdin_r(x)     ((x)->_stdin)
  112. #define _stdout_r(x)    ((x)->_stdout)
  113. #define _stderr_r(x)    ((x)->_stderr)
  114.  
  115. /*
  116. * Functions defined in ANSI C standard.
  117. */
  118.  
  119. #ifdef __GNUC__
  120. #define __VALIST __gnuc_va_list
  121. #else
  122. #define __VALIST char*
  123. #endif
  124.  
  125. #ifndef _EXFUN
  126. # define _EXFUN(N,P) N P
  127. #endif
  128. 00132
  129. int     _EXFUN(printf, (const char *, ...));
  130. int     _EXFUN(scanf, (const char *, ...));
  131. int     _EXFUN(sscanf, (const char *, const char *, ...));
  132. int     _EXFUN(vfprintf, (FILE *, const char *, __VALIST));
  133. int     _EXFUN(vprintf, (const char *, __VALIST));
  134. int     _EXFUN(vsprintf, (char *, const char *, __VALIST));
  135. int     _EXFUN(vsnprintf, (char *, size_t, const char *, __VALIST));
  136. int     _EXFUN(fgetc, (FILE *));
  137. char *  _EXFUN(fgets, (char *, int, FILE *));
  138. int     _EXFUN(fputc, (int, FILE *));
  139. int     _EXFUN(fputs, (const char *, FILE *));
  140. int     _EXFUN(getc, (FILE *));
  141. int     _EXFUN(getchar, (void));
  142. char *  _EXFUN(gets, (char *));
  143. int     _EXFUN(putc, (int, FILE *));
  144. int     _EXFUN(putchar, (int));
  145. int     _EXFUN(puts, (const char *));
  146. int     _EXFUN(ungetc, (int, FILE *));
  147. size_t  _EXFUN(fread, (void *, size_t _size, size_t _n, FILE *));
  148. size_t  _EXFUN(fwrite, (const void *, size_t _size, size_t _n, FILE *));
  149.  
  150. int     _EXFUN(sprintf, (char *, const char *, ...));
  151. int     _EXFUN(snprintf, (char *, size_t, const char *, ...));
  152.  
  153. #ifdef __cplusplus
  154. }
  155. #endif
  156. #endif /* _STDIO_H_ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement