source: branches/minix3-book/include/stdio.h@ 20

Last change on this file since 20 was 4, checked in by Mattia Monga, 14 years ago

Importazione sorgenti libro

File size: 5.1 KB
RevLine 
[4]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/* $Header: /cvsup/minix/src/include/stdio.h,v 1.2 2005/09/01 13:07:08 beng Exp $ */
8
9#ifndef _STDIO_H
10#define _STDIO_H
11
12#ifndef _ANSI_H
13#include <ansi.h>
14#endif
15
16/*
17 * Focus point of all stdio activity.
18 */
19typedef struct __iobuf {
20 int _count;
21 int _fd;
22 int _flags;
23 int _bufsiz;
24 unsigned char *_buf;
25 unsigned char *_ptr;
26} FILE;
27
28#define _IOFBF 0x000
29#define _IOREAD 0x001
30#define _IOWRITE 0x002
31#define _IONBF 0x004
32#define _IOMYBUF 0x008
33#define _IOEOF 0x010
34#define _IOERR 0x020
35#define _IOLBF 0x040
36#define _IOREADING 0x080
37#define _IOWRITING 0x100
38#define _IOAPPEND 0x200
39#define _IOFIFO 0x400
40
41/* The following definitions are also in <unistd.h>. They should not
42 * conflict.
43 */
44#define SEEK_SET 0
45#define SEEK_CUR 1
46#define SEEK_END 2
47
48#define stdin (&__stdin)
49#define stdout (&__stdout)
50#define stderr (&__stderr)
51
52#define BUFSIZ 1024
53#define NULL ((void *)0)
54#define EOF (-1)
55
56#define FOPEN_MAX 20
57
58#include <sys/dir.h>
59#define FILENAME_MAX DIRSIZ
60
61#define TMP_MAX 999
62#define L_tmpnam (sizeof("/tmp/") + FILENAME_MAX)
63#define __STDIO_VA_LIST__ void *
64
65typedef long int fpos_t;
66
67#ifndef _SIZE_T
68#define _SIZE_T
69typedef unsigned int size_t; /* type returned by sizeof */
70#endif /* _SIZE_T */
71
72extern FILE *__iotab[FOPEN_MAX];
73extern FILE __stdin, __stdout, __stderr;
74
75_PROTOTYPE( int remove, (const char *_filename) );
76_PROTOTYPE( int rename, (const char *_old, const char *_new) );
77_PROTOTYPE( FILE *tmpfile, (void) );
78_PROTOTYPE( char *tmpnam, (char *_s) );
79_PROTOTYPE( int fclose, (FILE *_stream) );
80_PROTOTYPE( int fflush, (FILE *_stream) );
81_PROTOTYPE( FILE *fopen, (const char *_filename, const char *_mode) );
82_PROTOTYPE( FILE *freopen,
83 (const char *_filename, const char *_mode, FILE *_stream) );
84_PROTOTYPE( void setbuf, (FILE *_stream, char *_buf) );
85_PROTOTYPE( int setvbuf,
86 (FILE *_stream, char *_buf, int _mode, size_t _size) );
87_PROTOTYPE( int fprintf, (FILE *_stream, const char *_format, ...) );
88_PROTOTYPE( int printf, (const char *_format, ...) );
89_PROTOTYPE( int sprintf, (char *_s, const char *_format, ...) );
90_PROTOTYPE( int vfprintf,
91 (FILE *_stream, const char *_format, char *_arg) );
92_PROTOTYPE( int vprintf, (const char *_format, char *_arg) );
93_PROTOTYPE( int vsprintf, (char *_s, const char *_format, char *_arg) );
94_PROTOTYPE( int fscanf, (FILE *_stream, const char *_format, ...) );
95_PROTOTYPE( int scanf, (const char *_format, ...) );
96_PROTOTYPE( int sscanf, (const char *_s, const char *_format, ...) );
97#define vfscanf _doscan
98_PROTOTYPE( int vfscanf, (FILE *_stream, const char *_format, char *_arg));
99_PROTOTYPE( int vscanf, (const char *_format, char *_arg) );
100_PROTOTYPE( int vsscanf, (const char *_s, const char *_format, char *_arg));
101_PROTOTYPE( int fgetc, (FILE *_stream) );
102_PROTOTYPE( char *fgets, (char *_s, int _n, FILE *_stream) );
103_PROTOTYPE( int fputc, (int _c, FILE *_stream) );
104_PROTOTYPE( int fputs, (const char *_s, FILE *_stream) );
105_PROTOTYPE( int getc, (FILE *_stream) );
106_PROTOTYPE( int getchar, (void) );
107_PROTOTYPE( char *gets, (char *_s) );
108_PROTOTYPE( int putc, (int _c, FILE *_stream) );
109_PROTOTYPE( int putchar, (int _c) );
110_PROTOTYPE( int puts, (const char *_s) );
111_PROTOTYPE( int ungetc, (int _c, FILE *_stream) );
112_PROTOTYPE( size_t fread,
113 (void *_ptr, size_t _size, size_t _nmemb, FILE *_stream) );
114_PROTOTYPE( size_t fwrite,
115 (const void *_ptr, size_t _size, size_t _nmemb, FILE *_stream) );
116_PROTOTYPE( int fgetpos, (FILE *_stream, fpos_t *_pos) );
117_PROTOTYPE( int fseek, (FILE *_stream, long _offset, int _whence) );
118_PROTOTYPE( int fsetpos, (FILE *_stream, fpos_t *_pos) );
119_PROTOTYPE( long ftell, (FILE *_stream) );
120_PROTOTYPE( void rewind, (FILE *_stream) );
121_PROTOTYPE( void clearerr, (FILE *_stream) );
122_PROTOTYPE( int feof, (FILE *_stream) );
123_PROTOTYPE( int ferror, (FILE *_stream) );
124_PROTOTYPE( void perror, (const char *_s) );
125_PROTOTYPE( int __fillbuf, (FILE *_stream) );
126_PROTOTYPE( int __flushbuf, (int _c, FILE *_stream) );
127
128#define getchar() getc(stdin)
129#define putchar(c) putc(c,stdout)
130#define getc(p) (--(p)->_count >= 0 ? (int) (*(p)->_ptr++) : \
131 __fillbuf(p))
132#define putc(c, p) (--(p)->_count >= 0 ? \
133 (int) (*(p)->_ptr++ = (c)) : \
134 __flushbuf((c),(p)))
135
136#define feof(p) (((p)->_flags & _IOEOF) != 0)
137#define ferror(p) (((p)->_flags & _IOERR) != 0)
138#define clearerr(p) ((p)->_flags &= ~(_IOERR|_IOEOF))
139
140#ifdef _POSIX_SOURCE
141_PROTOTYPE( int fileno, (FILE *_stream) );
142_PROTOTYPE (FILE *fdopen, (int _fildes, const char *_types) );
143#define fileno(stream) ((stream)->_fd)
144#define L_ctermid 255 /* required by POSIX */
145#define L_cuserid 255 /* required by POSIX */
146#endif
147
148#ifdef _MINIX
149_PROTOTYPE(FILE *popen, (const char *_command, const char *_type));
150_PROTOTYPE(int pclose, (FILE *_stream));
151_PROTOTYPE(int snprintf, (char *_s, size_t _n, const char *_format, ...));
152_PROTOTYPE(int vsnprintf, (char *_s, size_t _n, const char *_format,
153 char *_arg) );
154#endif
155
156#endif /* _STDIO_H */
Note: See TracBrowser for help on using the repository browser.