|
|
1.1 root 1: /* (-lgl
2: * COHERENT Version 4.0.2
3: * Copyright (c) 1982, 1993 by Mark Williams Company.
4: * All rights reserved. May not be copied without permission.
5: -lgl) */
6: /*
7: * stdio.h
8: * COHERENT Standard Input/Output library header.
9: * ANSI C Standard, Section 4.9.
10: */
11:
12: #ifndef __STDIO_H__
13: #define __STDIO_H__
14:
15: #include <common/feature.h>
16: #include <common/ccompat.h>
17: #include <common/__off.h>
18: #include <common/__valist.h>
19: #include <common/_size.h>
20: #include <common/_null.h>
21: #include <common/whence.h>
22:
23: /* Macros. */
24: #define BUFSIZ 512 /* default buffer size */
25: #define EOF (-1) /* end of file */
26: #define _EOFCHAR 26 /* ASCII EOF character */
27: #define FILENAME_MAX 64 /* max filename length */
28: #define FOPEN_MAX _NFILE /* max # of open files */
29: #define _NFILE 60 /* number of FILEs */
30: #define _NSTDFILE 3 /* number of predefined FILEs */
31: #define L_tmpnam 64 /* tmpnam length */
32: #define P_tmpdir "/tmp" /* default temporary directory */
33: #define TMP_MAX 91 /* number of tmpnams */
34:
35: /* Types. */
36: typedef long fpos_t; /* file position type */
37:
38: /*
39: * The order the first 5 FILE members corresponds to the order in iBCS2,
40: * to allow a degree of binary compatability.
41: */
42: typedef struct FILE {
43: int _cc; /* character count */
44: unsigned char *_cp; /* current character */
45: struct _FILE2 *_f2p; /* more info */
46: char _ff1; /* flags */
47: char _fd; /* file descriptor */
48: char _ff2; /* more flags; see below */
49: char _mode; /* mode */
50: } FILE;
51: /* These additional members are not in struct FILE for compatability reasons. */
52: typedef struct _FILE2 {
53: int (*_gt)(); /* getc function */
54: int (*_pt)(); /* putc function */
55: unsigned char *_bp; /* start of buffer */
56: unsigned char *_dp; /* start of data */
57: unsigned char *_ep; /* end of buffer */
58: char *_nm; /* temp file name */
59: int _uc; /* ungot char */
60: } _FILE2;
61:
62: /* iBCS2 compatability. */
63: #define _cnt _cc
64: #define _ptr _cp
65: #define _base _f2p
66: #define _flag _ff1
67: #define _file _fd
68:
69: /*
70: * Standard FILEs. Technically, these definitions violate the user name-space,
71: * but these names are required for iBCS2.
72: */
73: extern FILE _iob[_NSTDFILE];
74: extern FILE *_fp[_NFILE];
75: #define stdin (&_iob[0])
76: #define stdout (&_iob[1])
77: #define stderr (&_iob[2])
78:
79: /* _IO[FLN]BF are used for setvbuf() type args. */
80: #define _IOFBF 0x00 /* fully buffered */
81: #define _IONBF 0x04 /* unbuffered */
82: #define _IOLBF 0x40 /* line buffered */
83:
84: /* Flags in _ff1, cf. iBCS2. */
85: #define _FEOF 0x10 /* end of file */
86: #define _FERR 0x20 /* error */
87:
88: /* Non-iBCS2 flags in _ff1. */
89: #define _FRONLY 0x01 /* read only */
90: #define _FWONLY 0x02 /* write only */
91: #define _FRW 0x80 /* read and write */
92:
93: /* Flags in _ff2, not in iBCS2. */
94: #define _FINUSE 0x01 /* in use */
95: #define _FAPPND 0x02 /* append */
96: #define _FASCII 0x04 /* ASCII */
97: #define _FDONTC 0x08 /* do not close */
98: #define _FFREEB 0x10 /* free buffer when closed */
99: #define _FUNGOT 0x80 /* ungotten char present */
100:
101: /* Mode field values. */
102: #define _MODE_FBUF 0x01 /* fully buffered */
103: #define _MODE_LBUF 0x02 /* line buffered */
104: #define _MODE_NBUF 0x04 /* unbuffered */
105: #define _MODE_STR 0x08 /* string */
106: #define _MODE_UNINIT 0x10 /* uninitialized */
107:
108: /* External declarations for non-conforming implementations. */
109: /* Standard functions. */
110:
111: __EXTERN_C_BEGIN__
112:
113: int remove __PROTO ((__CONST__ char * _filename));
114: int rename __PROTO ((__CONST__ char * _old,
115: __CONST__ char * _new));
116: FILE * tmpfile __PROTO ((void));
117: char * tmpnam __PROTO ((char * _s));
118: int fclose __PROTO ((FILE * _stream));
119: int fflush __PROTO ((FILE * _stream));
120: FILE * fopen __PROTO ((__CONST__ char * _filename,
121: __CONST__ char * _mode));
122: FILE * freopen __PROTO ((__CONST__ char * _filename,
123: __CONST__ char * _mode,
124: FILE * _stream));
125: void setbuf __PROTO ((FILE * _stream, char * _buf));
126: int setvbuf __PROTO ((FILE * _stream, char * _buf,
127: int _mode, size_t _size));
128: int fprintf __PROTO ((FILE * _stream,
129: __CONST__ char * _format, ...));
130: int fscanf __PROTO ((FILE * _stream,
131: __CONST__ char * _format, ...));
132: int printf __PROTO ((__CONST__ char * _format, ...));
133: int scanf __PROTO ((__CONST__ char * _format, ...));
134: int sprintf __PROTO ((char * _s,
135: __CONST__ char * _format, ...));
136: int sscanf __PROTO ((__CONST__ char * _s,
137: __CONST__ char * _format, ...));
138: int vfprintf __PROTO ((FILE * _stream,
139: __CONST__ char * _format,
140: __va_list arg));
141: int vprintf __PROTO ((__CONST__ char * _format,
142: __va_list arg));
143: int vsprintf __PROTO ((char * _s,
144: __CONST__ char * _format,
145: __va_list arg));
146: int fgetc __PROTO ((FILE * _stream));
147: char * fgets __PROTO ((char * _s, int _n, FILE * _stream));
148: int fputc __PROTO ((int _c, FILE * _stream));
149: int fputs __PROTO ((__CONST__ char * _s,
150: FILE * _stream));
151: int getc __PROTO ((FILE * stream));
152: int getchar __PROTO ((void));
153: char * gets __PROTO ((char * _s));
154: int putc __PROTO ((int _c, FILE * _stream));
155: int putchar __PROTO ((int _c));
156: int puts __PROTO ((__CONST__ char * _s));
157: int ungetc __PROTO ((int _c, FILE * _stream));
158: size_t fread __PROTO ((__VOID__ * _ptr, size_t _size,
159: size_t _nmemb, FILE * _stream));
160: size_t fwrite __PROTO ((__CONST__ __VOID__ * _ptr,
161: size_t _size, size_t _nmemb,
162: FILE * _stream));
163: int fgetpos __PROTO ((FILE * _stream, fpos_t * _pos));
164: int fseek __PROTO ((FILE * _stream, __off_t _offset,
165: int whence));
166: int fsetpos __PROTO ((FILE * _stream,
167: __CONST__ fpos_t * pos));
168: __off_t ftell __PROTO ((FILE * _stream));
169: void rewind __PROTO ((FILE * _stream));
170: void clearerr __PROTO ((void));
171: int feof __PROTO ((FILE * _stream));
172: int ferror __PROTO ((FILE * _stream));
173: void perror __PROTO ((__CONST__ char * _s));
174:
175: #if ! _STDC_SOURCE
176:
177: FILE * fdopen __PROTO ((int _fildes,
178: __CONST__ char * _type));
179: int fileno __PROTO ((FILE * _stream));
180:
181: #if ! _POSIX_SOURCE
182:
183: FILE * popen __PROTO ((__CONST__ char * _command,
184: __CONST__ char * _how));
185:
186: #endif /* ! _POSIX_SOURCE */
187: #endif /* ! _STDC_SOURCE */
188:
189: __EXTERN_C_END__
190:
191: #if 0
192: /* Internal functions. */
193: extern void _dassign();
194: extern int _dscan ();
195: extern char * _dtefg ();
196: extern void _dtoa ();
197: extern int _fgetb ();
198: extern int _fgetc ();
199: extern int _fgete ();
200: extern int _fgetstr();
201: extern int _fginit ();
202: extern int _filbuf ();
203: extern void _finish ();
204: extern int _flsbuf ();
205: extern FILE * _fopen ();
206: extern int _fpinit ();
207: extern int _fpseek ();
208: extern int _fputa ();
209: extern int _fputb ();
210: extern int _fputc ();
211: extern int _fpute ();
212: extern int _fputt ();
213: extern int _scanf ();
214: extern FILE * _stropen();
215:
216: #endif /* not permitted in <stdio.h> */
217:
218: /* Macros covering standard functions. */
219: #define clearerr(fp) ((fp)->_ff1 &= ~(_FERR|_FEOF))
220: #define feof(fp) ((fp)->_ff1 & _FEOF)
221: #define ferror(fp) ((fp)->_ff1 & _FERR)
222: #define getc(fp) (--(fp)->_cc<0 ? ++(fp)->_cc,(*(fp)->_f2p->_gt)((fp)) \
223: : *(fp)->_cp++)
224: #define getchar() getc(stdin)
225: #define putc(c,fp) (--(fp)->_cc<0 ? ++(fp)->_cc,(*(fp)->_f2p->_pt)((c),(fp)) \
226: : (*(fp)->_cp++=(c)))
227: #define putchar(c) putc((c), stdout)
228:
229: /* Other macros, non-ANSI. */
230: #define fileno(fp) ((fp)->_fd)
231:
232: #endif /* ! defined (__STDIO_H__) */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.