home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Headers / ansi / stdio.h < prev    next >
Text File  |  1991-06-17  |  5KB  |  153 lines

  1. /*
  2.  * Copyright (c) 1980 Regents of the University of California.
  3.  * All rights reserved.  The Berkeley software License Agreement
  4.  * specifies the terms and conditions for redistribution.
  5.  *
  6.  *    @(#)stdio.h    5.3 (Berkeley) 3/15/86
  7.  */
  8.  
  9. #ifndef _STDIO_H
  10. #define _STDIO_H
  11.  
  12. #ifdef __STRICT_BSD__
  13. #ifndef NULL
  14. #define    NULL    0
  15. #endif 
  16. #else
  17. #import <stddef.h> /* get NULL, errno */
  18. #import <stdarg.h> /* get va_list */
  19. #endif
  20.  
  21. #define    BUFSIZ    1024
  22. extern    struct    _iobuf {
  23.     int    _cnt;
  24.     char    *_ptr;        /* should be unsigned char */
  25.     char    *_base;        /* ditto */
  26.     int    _bufsiz;
  27.     short    _flag;
  28. #ifdef    __NeXT__
  29.     unsigned char    _file;    /* should be short */
  30. #else
  31.     char    _file;        /* should be short */
  32. #endif    __NeXT__
  33.     char    _smallbuf;    /* character for unbuf file */
  34. } _iob[];
  35.  
  36. #define    _IOREAD    01
  37. #define    _IOWRT    02
  38. #define    _IONBF    04
  39. #define    _IOMYBUF    010
  40. #define    _IOEOF    020
  41. #define    _IOERR    040
  42. #define    _IOSTRG    0100
  43. #define    _IOLBF    0200
  44. #define    _IORW    0400
  45. #define    FILE    struct _iobuf
  46. #define    EOF    (-1)
  47.  
  48. #define    stdin    (&_iob[0])
  49. #define    stdout    (&_iob[1])
  50. #define    stderr    (&_iob[2])
  51.  
  52. #ifdef __STRICT_BSD__
  53. extern char *bsd_sprintf();
  54. extern char *bsd_vsprintf();
  55. #define sprintf bsd_sprintf
  56. #define vsprintf bsd_vsprintf
  57. extern FILE *fopen();
  58. extern FILE *freopen();
  59. extern long int ftell();
  60. extern char *fgets();
  61. extern char *gets();
  62. #else
  63. typedef long fpos_t;
  64.  
  65. #define _IOFBF    00        /* any value not equal to LBF or NBF */
  66. #define L_tmpnam 14        /* large enough to hold tmpnam result */
  67. #define FOPEN_MAX 256        /* min files guaranteed open simultaneously */
  68. #define FILENAME_MAX 1024    /* max len string that can be opened as file */
  69. #define SEEK_SET 0        /* arguments to fseek function */
  70. #define SEEK_CUR 1
  71. #define SEEK_END 2
  72. #define TMP_MAX 25        /* min unique file names from tmpnam */
  73.  
  74. extern int remove(const char *filename);
  75. extern int rename(const char *old_ng const char *new_name);
  76. extern FILE *tmpfile(void);
  77. extern char *tmpnam(char *s);
  78. extern int fclose(FILE *stream);
  79. extern int fflush(FILE *stream);
  80. extern void setbuf(FILE *stream, char *buf);
  81. extern int setvbuf(FILE *stream, char *buf, int mode, size_t size);
  82. extern int fprintf(FILE *stream, const char *format, ...);
  83. extern int fscanf(FILE *stream, const char *format, ...);
  84. extern int printf(const char *format, ...);
  85. extern int scanf(const char *format, ...);
  86. extern int sprintf(char *s, const char *format, ...);
  87. extern int sscanf(const char *s, const char *format, ...);
  88. extern int vfprintf(FILE *stream, const char *format, va_list arg);
  89. extern int vprintf(const char *format, va_list arg);
  90. extern int vsprintf(char *s, const char *format, va_list arg);
  91. extern int fgetc(FILE *stream);
  92. extern int fputc(int c, FILE *stream);
  93. extern int fputs(const char *s, FILE *stream);
  94. extern int getc(FILE *stream);
  95. extern int _flsbuf();
  96. extern int _filbuf();
  97. extern int getchar(void);
  98. extern int putc(int c, FILE *stream);
  99. extern int putchar(int c);
  100. extern int puts(const char *s);
  101. extern int ungetc(int c, FILE *stream);
  102. extern size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
  103. extern size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
  104. extern int fgetpos(FILE *stream, fpos_t *pos);
  105. extern int fseek(FILE *stream, long int offset, int whence);
  106. extern int fsetpos(FILE *stream, const fpos_t *pos);
  107. extern void rewind(FILE *stream);
  108. extern void clearerr(FILE *stream);
  109. extern int feof(FILE *stream);
  110. extern int ferror(FILE *stream);
  111. extern void perror(const char *s);
  112. extern FILE *fopen(const char *filename, const char *mode);
  113. extern FILE *freopen(const char *filename, const char *mode, FILE *stream);
  114. extern long int ftell(FILE *stream);
  115. extern char *fgets(char *s, int n, FILE *stream);
  116. extern char *gets(char *s);
  117. #endif /* __STRICT_BSD */
  118.  
  119. #ifndef lint
  120. #define    getc(p)        (--(p)->_cnt>=0? (int)(*(unsigned char *)(p)->_ptr++):_filbuf(p))
  121. #endif /* not lint */
  122. #define    getchar()    getc(stdin)
  123. #ifndef lint
  124. #define putc(x, p)    (--(p)->_cnt >= 0 ?\
  125.     (int)(*(unsigned char *)(p)->_ptr++ = (x)) :\
  126.     (((p)->_flag & _IOLBF) && -(p)->_cnt < (p)->_bufsiz ?\
  127.         ((*(p)->_ptr = (x)) != '\n' ?\
  128.             (int)(*(unsigned char *)(p)->_ptr++) :\
  129.             _flsbuf(*(unsigned char *)(p)->_ptr, p)) :\
  130.         _flsbuf((unsigned char)(x), p)))
  131. #endif hot lint */
  132. #define    putchar(x)    putc(x,stdout)
  133. #define    feof(p)        (((p)->_flag&_IOEOF)!=0)
  134. #define    ferror(p)    (((p)->_flag&_IOERR)!=0)
  135. #define    clearerr(p)    ((p)->_flag &= ~(_IOERR|_IOEOF))
  136.  
  137. #ifndef __STRICT_ANSI__
  138. /* BSD compatibility */
  139. extern int fileno(FILE *stream);
  140. #define    fileno(p)    ((p)->_file)
  141.  
  142. #ifdef __STRICT_BSD__
  143. FILE    *fdopen();
  144. FILE    *popen();
  145. extern int pclose();
  146. #else
  147. FILE    *fdopen(int filedes, const char *mode);
  148. FILE    *popen(const char *command, const char *mode);
  149. extern int pclose(FILE *stream);
  150. #endif /* __STRICT_BSD__ */
  151. #endif /* __STRICT_ANSI__ */
  152. #endif /* _STDIO_H */
  153.