Pristine Ack-5.5
[Ack-5.5.git] / lang / cem / libcc.ansi / headers / stdio.h
1 /*
2  * stdio.h - input/output definitions
3  *
4  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
5  * See the copyright notice in the ACK home directory, in the file "Copyright".
6  */
7 /* $Id: stdio.h,v 1.11 1994/06/24 11:41:21 ceriel Exp $ */
8
9 #if     !defined(_STDIO_H)
10 #define _STDIO_H
11
12 /*
13  * Focus point of all stdio activity.
14  */
15 typedef struct __iobuf {
16         int             _count;
17         int             _fd;
18         int             _flags;
19         int             _bufsiz;
20         unsigned char   *_buf;
21         unsigned char   *_ptr;
22 } FILE;
23
24 #define _IOFBF          0x000
25 #define _IOREAD         0x001
26 #define _IOWRITE        0x002
27 #define _IONBF          0x004
28 #define _IOMYBUF        0x008
29 #define _IOEOF          0x010
30 #define _IOERR          0x020
31 #define _IOLBF          0x040
32 #define _IOREADING      0x080
33 #define _IOWRITING      0x100
34 #define _IOAPPEND       0x200
35
36 /* The following definitions are also in <unistd.h>. They should not
37  * conflict.
38  */
39 #define SEEK_SET        0
40 #define SEEK_CUR        1
41 #define SEEK_END        2
42
43 #define stdin           (&__stdin)
44 #define stdout          (&__stdout)
45 #define stderr          (&__stderr)
46
47 #define BUFSIZ          1024
48 #define NULL            ((void *)0)
49 #define EOF             (-1)
50
51 #define FOPEN_MAX       20
52
53 #if     defined(__BSD4_2)
54 #define FILENAME_MAX    255
55 #else
56 #define FILENAME_MAX    14
57 #endif  /* __BSD4_2 */
58 #define TMP_MAX         999
59 #define L_tmpnam        (sizeof("/tmp/") + 15)
60
61 typedef long int        fpos_t;
62
63 #if     !defined(_SIZE_T)
64 #define _SIZE_T
65 typedef unsigned int    size_t;         /* type returned by sizeof */
66 #endif  /* _SIZE_T */
67
68 extern FILE     *__iotab[FOPEN_MAX];
69 extern FILE     __stdin, __stdout, __stderr;
70
71 int     remove(const char *_filename);
72 int     rename(const char *_old, const char *_new);
73 FILE    *tmpfile(void);
74 char    *tmpnam(char *_s);
75 int     fclose(FILE *_stream);
76 int     fflush(FILE *_stream);
77 FILE    *fopen(const char *_filename, const char *_mode);
78 FILE    *freopen(const char *_filename, const char *_mode, FILE *_stream);
79 void    setbuf(FILE *_stream, char *_buf);
80 int     setvbuf(FILE *_stream, char *_buf, int _mode, size_t _size);
81 int     fprintf(FILE *_stream, const char *_format, ...);
82 int     fscanf(FILE *_stream, const char *_format, ...);
83 int     printf(const char *_format, ...);
84 int     scanf(const char *_format, ...);
85 int     sprintf(char *_s, const char *_format, ...);
86 int     sscanf(const char *_s, const char *_format, ...);
87 int     vfprintf(FILE *_stream, const char *_format, char *_arg);
88 int     vprintf(const char *_format, char *_arg);
89 int     vsprintf(char *_s, const char *_format, char *_arg);
90 int     fgetc(FILE *_stream);
91 char    *fgets(char *_s, int _n, FILE *_stream);
92 int     fputc(int _c, FILE *_stream);
93 int     fputs(const char *_s, FILE *_stream);
94 int     getc(FILE *_stream);
95 int     getchar(void);
96 char    *gets(char *_s);
97 int     putc(int _c, FILE *_stream);
98 int     putchar(int _c);
99 int     puts(const char *_s);
100 int     ungetc(int _c, FILE *_stream);
101 size_t  fread(void *_ptr, size_t _size, size_t _nmemb, FILE *_stream);
102 size_t  fwrite(const void *_ptr, size_t _size, size_t _nmemb, FILE *_stream);
103 int     fgetpos(FILE *_stream, fpos_t *_pos);
104 int     fseek(FILE *_stream, long _offset, int _whence);
105 int     fsetpos(FILE *_stream, fpos_t *_pos);
106 long    ftell(FILE *_stream);
107 void    rewind(FILE *_stream);
108 void    clearerr(FILE *_stream);
109 int     feof(FILE *_stream);
110 int     ferror(FILE *_stream);
111 void    perror(const char *_s);
112
113 int __fillbuf(FILE *_stream);
114 int __flushbuf(int _c, FILE *_stream);
115
116
117 #define getchar()       getc(stdin)
118 #define putchar(c)      putc(c,stdout)
119 #define getc(p)         (--(p)->_count >= 0 ? (int) (*(p)->_ptr++) : \
120                                 __fillbuf(p))
121 #define putc(c, p)      (--(p)->_count >= 0 ? \
122                          (int) (*(p)->_ptr++ = (c)) : \
123                          __flushbuf((c),(p)))
124
125 #define feof(p)         (((p)->_flags & _IOEOF) != 0)
126 #define ferror(p)       (((p)->_flags & _IOERR) != 0)
127 #define clearerr(p)     ((p)->_flags &= ~(_IOERR|_IOEOF))
128
129 #if     defined(__BSD4_2) || defined(__USG) || defined(_POSIX_SOURCE)
130 int fileno(FILE *_stream);
131 FILE *fdopen(int fildes, const char *type);
132 #define fileno(stream)          ((stream)->_fd)
133 #endif  /* __BSD4_2 || __USG || _POSIX_SOURCE */
134
135 #endif  /* _STDIO_H */