Search
lxdream.org :: lxdream/test/include/stdio.h
lxdream 0.9.1
released Jun 29
Download Now
filename test/include/stdio.h
changeset 185:6755a04c447f
author nkeynes
date Sat Aug 05 00:18:21 2006 +0000 (17 years ago)
permissions -rw-r--r--
last change Add error lines to tests with incomplete polys
Split clip tests to separate data file
Add tests for cmd bit 23 ("use list size field")
view annotate diff log raw
     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  */
    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  */
    26 #ifndef _STDIO_H_
    27 #ifdef __cplusplus
    28 extern "C" {
    29 #endif
    30 #define	_STDIO_H_
    32 #include "_ansi.h"
    34 #define	_FSTDIO			/* ``function stdio'' */
    36 #define __need_size_t
    37 #include <stddef.h>
    39 #define __need___va_list
    40 #include <stdarg.h>
    42 /*
    43  * <sys/reent.h> defines __sFILE, _fpos_t.
    44  * They must be defined there because struct _reent needs them (and we don't
    45  * want reent.h to include this file.
    46  */
    48 #include <sys/reent.h>
    50 typedef _fpos_t fpos_t;
    52 typedef struct __sFILE FILE;
    54 #define	__SLBF	0x0001		/* line buffered */
    55 #define	__SNBF	0x0002		/* unbuffered */
    56 #define	__SRD	0x0004		/* OK to read */
    57 #define	__SWR	0x0008		/* OK to write */
    58 	/* RD and WR are never simultaneously asserted */
    59 #define	__SRW	0x0010		/* open for reading & writing */
    60 #define	__SEOF	0x0020		/* found EOF */
    61 #define	__SERR	0x0040		/* found error */
    62 #define	__SMBF	0x0080		/* _buf is from malloc */
    63 #define	__SAPP	0x0100		/* fdopen()ed in append mode - so must  write to end */
    64 #define	__SSTR	0x0200		/* this is an sprintf/snprintf string */
    65 #define	__SOPT	0x0400		/* do fseek() optimisation */
    66 #define	__SNPT	0x0800		/* do not do fseek() optimisation */
    67 #define	__SOFF	0x1000		/* set iff _offset is in fact correct */
    68 #define	__SMOD	0x2000		/* true => fgetline modified _p text */
    70 /*
    71  * The following three definitions are for ANSI C, which took them
    72  * from System V, which stupidly took internal interface macros and
    73  * made them official arguments to setvbuf(), without renaming them.
    74  * Hence, these ugly _IOxxx names are *supposed* to appear in user code.
    75  *
    76  * Although these happen to match their counterparts above, the
    77  * implementation does not rely on that (so these could be renumbered).
    78  */
    79 #define	_IOFBF	0		/* setvbuf should set fully buffered */
    80 #define	_IOLBF	1		/* setvbuf should set line buffered */
    81 #define	_IONBF	2		/* setvbuf should set unbuffered */
    83 #ifndef NULL
    84 #define	NULL	0
    85 #endif
    87 #define	BUFSIZ	1024
    88 #define	EOF	(-1)
    90 #define	FOPEN_MAX	20	/* must be <= OPEN_MAX <sys/syslimits.h> */
    91 #define	FILENAME_MAX	1024	/* must be <= PATH_MAX <sys/syslimits.h> */
    92 #define	L_tmpnam	1024	/* XXX must be == PATH_MAX */
    93 #ifndef __STRICT_ANSI__
    94 #define P_tmpdir        "/tmp"
    95 #endif
    97 #ifndef SEEK_SET
    98 #define	SEEK_SET	0	/* set file offset to offset */
    99 #endif
   100 #ifndef SEEK_CUR
   101 #define	SEEK_CUR	1	/* set file offset to current plus offset */
   102 #endif
   103 #ifndef SEEK_END
   104 #define	SEEK_END	2	/* set file offset to EOF plus offset */
   105 #endif
   107 #define	TMP_MAX		26
   109 #define	stdin	(_impure_ptr->_stdin)
   110 #define	stdout	(_impure_ptr->_stdout)
   111 #define	stderr	(_impure_ptr->_stderr)
   113 #define _stdin_r(x)	((x)->_stdin)
   114 #define _stdout_r(x)	((x)->_stdout)
   115 #define _stderr_r(x)	((x)->_stderr)
   117 /*
   118  * Functions defined in ANSI C standard.
   119  */
   121 #ifdef __GNUC__
   122 #define __VALIST __gnuc_va_list
   123 #else
   124 #define __VALIST char*
   125 #endif
   127 #ifndef _REENT_ONLY
   128 int	_EXFUN(remove, (const char *));
   129 int	_EXFUN(rename, (const char *, const char *));
   130 #endif
   131 char *	_EXFUN(tempnam, (const char *, const char *));
   132 FILE *	_EXFUN(tmpfile, (void));
   133 char *	_EXFUN(tmpnam, (char *));
   134 int	_EXFUN(fclose, (FILE *));
   135 int	_EXFUN(fflush, (FILE *));
   136 FILE *	_EXFUN(freopen, (const char *, const char *, FILE *));
   137 void	_EXFUN(setbuf, (FILE *, char *));
   138 int	_EXFUN(setvbuf, (FILE *, char *, int, size_t));
   139 int	_EXFUN(fprintf, (FILE *, const char *, ...));
   140 int	_EXFUN(fscanf, (FILE *, const char *, ...));
   141 int	_EXFUN(printf, (const char *, ...));
   142 int	_EXFUN(scanf, (const char *, ...));
   143 int	_EXFUN(sscanf, (const char *, const char *, ...));
   144 int	_EXFUN(vfprintf, (FILE *, const char *, __VALIST));
   145 int	_EXFUN(vprintf, (const char *, __VALIST));
   146 int	_EXFUN(vsprintf, (char *, const char *, __VALIST));
   147 int	_EXFUN(vsnprintf, (char *, size_t, const char *, __VALIST));
   148 int	_EXFUN(fgetc, (FILE *));
   149 char *  _EXFUN(fgets, (char *, int, FILE *));
   150 int	_EXFUN(fputc, (int, FILE *));
   151 int	_EXFUN(fputs, (const char *, FILE *));
   152 int	_EXFUN(getc, (FILE *));
   153 int	_EXFUN(getchar, (void));
   154 char *  _EXFUN(gets, (char *));
   155 int	_EXFUN(putc, (int, FILE *));
   156 int	_EXFUN(putchar, (int));
   157 int	_EXFUN(puts, (const char *));
   158 int	_EXFUN(ungetc, (int, FILE *));
   159 size_t	_EXFUN(fread, (_PTR, size_t _size, size_t _n, FILE *));
   160 size_t	_EXFUN(fwrite, (const _PTR , size_t _size, size_t _n, FILE *));
   161 int	_EXFUN(fgetpos, (FILE *, fpos_t *));
   162 int	_EXFUN(fseek, (FILE *, long, int));
   163 int	_EXFUN(fsetpos, (FILE *, const fpos_t *));
   164 long	_EXFUN(ftell, ( FILE *));
   165 void	_EXFUN(rewind, (FILE *));
   166 void	_EXFUN(clearerr, (FILE *));
   167 int	_EXFUN(feof, (FILE *));
   168 int	_EXFUN(ferror, (FILE *));
   169 void    _EXFUN(perror, (const char *));
   170 #ifndef _REENT_ONLY
   171 FILE *	_EXFUN(fopen, (const char *_name, const char *_type));
   172 int	_EXFUN(sprintf, (char *, const char *, ...));
   173 int	_EXFUN(snprintf, (char *, size_t, const char *, ...));
   174 #endif
   175 #ifndef __STRICT_ANSI__
   176 int	_EXFUN(vfiprintf, (FILE *, const char *, __VALIST));
   177 int	_EXFUN(iprintf, (const char *, ...));
   178 int	_EXFUN(fiprintf, (FILE *, const char *, ...));
   179 int	_EXFUN(siprintf, (char *, const char *, ...));
   180 #endif
   182 /*
   183  * Routines in POSIX 1003.1.
   184  */
   186 #ifndef __STRICT_ANSI__
   187 #ifndef _REENT_ONLY
   188 FILE *	_EXFUN(fdopen, (int, const char *));
   189 #endif
   190 int	_EXFUN(fileno, (FILE *));
   191 int	_EXFUN(getw, (FILE *));
   192 int	_EXFUN(pclose, (FILE *));
   193 FILE *  _EXFUN(popen, (const char *, const char *));
   194 int	_EXFUN(putw, (int, FILE *));
   195 void    _EXFUN(setbuffer, (FILE *, char *, int));
   196 int	_EXFUN(setlinebuf, (FILE *));
   197 #endif
   199 /*
   200  * Recursive versions of the above.
   201  */
   203 FILE *	_EXFUN(_fdopen_r, (struct _reent *, int, const char *));
   204 FILE *	_EXFUN(_fopen_r, (struct _reent *, const char *, const char *));
   205 int	_EXFUN(_getchar_r, (struct _reent *));
   206 char *	_EXFUN(_gets_r, (struct _reent *, char *));
   207 int	_EXFUN(_iprintf_r, (struct _reent *, const char *, ...));
   208 int	_EXFUN(_mkstemp_r, (struct _reent *, char *));
   209 char *	_EXFUN(_mktemp_r, (struct _reent *, char *));
   210 void	_EXFUN(_perror_r, (struct _reent *, const char *));
   211 int	_EXFUN(_printf_r, (struct _reent *, const char *, ...));
   212 int	_EXFUN(_putchar_r, (struct _reent *, int));
   213 int	_EXFUN(_puts_r, (struct _reent *, const char *));
   214 int	_EXFUN(_remove_r, (struct _reent *, const char *));
   215 int	_EXFUN(_rename_r, (struct _reent *,
   216 			   const char *_old, const char *_new));
   217 int	_EXFUN(_scanf_r, (struct _reent *, const char *, ...));
   218 int	_EXFUN(_sprintf_r, (struct _reent *, char *, const char *, ...));
   219 int	_EXFUN(_snprintf_r, (struct _reent *, char *, size_t, const char *, ...));
   220 char *	_EXFUN(_tempnam_r, (struct _reent *, const char *, const char *));
   221 FILE *	_EXFUN(_tmpfile_r, (struct _reent *));
   222 char *	_EXFUN(_tmpnam_r, (struct _reent *, char *));
   223 int	_EXFUN(_vfprintf_r, (struct _reent *, FILE *, const char *, __VALIST));
   224 int	_EXFUN(_vprintf_r, (struct _reent *, const char *, __VALIST));
   225 int	_EXFUN(_vsprintf_r, (struct _reent *, char *, const char *, __VALIST));
   226 int	_EXFUN(_vsnprintf_r, (struct _reent *, char *, size_t, const char *, __VALIST));
   228 /*
   229  * Routines internal to the implementation.
   230  */
   232 int	_EXFUN(__srget, (FILE *));
   233 int	_EXFUN(__swbuf, (int, FILE *));
   235 /*
   236  * Stdio function-access interface.
   237  */
   239 #ifndef __STRICT_ANSI__
   240 FILE	*_EXFUN(funopen,(const _PTR _cookie,
   241 		int (*readfn)(_PTR _cookie, char *_buf, int _n),
   242 		int (*writefn)(_PTR _cookie, const char *_buf, int _n),
   243 		fpos_t (*seekfn)(_PTR _cookie, fpos_t _off, int _whence),
   244 		int (*closefn)(_PTR _cookie)));
   246 #define	fropen(cookie, fn) funopen(cookie, fn, (int (*)())0, (fpos_t (*)())0, (int (*)())0)
   247 #define	fwopen(cookie, fn) funopen(cookie, (int (*)())0, fn, (fpos_t (*)())0, (int (*)())0)
   248 #endif
   250 /*
   251  * The __sfoo macros are here so that we can 
   252  * define function versions in the C library.
   253  */
   254 #define	__sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++))
   255 #ifdef _never /* __GNUC__ */
   256 /* If this inline is actually used, then systems using coff debugging
   257    info get hopelessly confused.  21sept93 rich@cygnus.com.  */
   258 static __inline int __sputc(int _c, FILE *_p) {
   259 	if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
   260 		return (*_p->_p++ = _c);
   261 	else
   262 		return (__swbuf(_c, _p));
   263 }
   264 #else
   265 /*
   266  * This has been tuned to generate reasonable code on the vax using pcc
   267  */
   268 #define	__sputc(c, p) \
   269 	(--(p)->_w < 0 ? \
   270 		(p)->_w >= (p)->_lbfsize ? \
   271 			(*(p)->_p = (c)), *(p)->_p != '\n' ? \
   272 				(int)*(p)->_p++ : \
   273 				__swbuf('\n', p) : \
   274 			__swbuf((int)(c), p) : \
   275 		(*(p)->_p = (c), (int)*(p)->_p++))
   276 #endif
   278 #define	__sfeof(p)	(((p)->_flags & __SEOF) != 0)
   279 #define	__sferror(p)	(((p)->_flags & __SERR) != 0)
   280 #define	__sclearerr(p)	((void)((p)->_flags &= ~(__SERR|__SEOF)))
   281 #define	__sfileno(p)	((p)->_file)
   283 #define	feof(p)		__sfeof(p)
   284 #define	ferror(p)	__sferror(p)
   285 #define	clearerr(p)	__sclearerr(p)
   287 #if 0 /*ndef __STRICT_ANSI__ - FIXME: must initialize stdio first, use fn */
   288 #define	fileno(p)	__sfileno(p)
   289 #endif
   291 #ifndef lint
   292 #define	getc(fp)	__sgetc(fp)
   293 #define putc(x, fp)	__sputc(x, fp)
   294 #endif /* lint */
   296 #define	getchar()	getc(stdin)
   297 #define	putchar(x)	putc(x, stdout)
   299 #ifndef __STRICT_ANSI__
   300 /* fast always-buffered version, true iff error */
   301 #define	fast_putc(x,p) (--(p)->_w < 0 ? \
   302 	__swbuf((int)(x), p) == EOF : (*(p)->_p = (x), (p)->_p++, 0))
   304 #define	L_cuserid	9		/* posix says it goes in stdio.h :( */
   305 #ifdef __CYGWIN32__
   306 #define L_ctermid       16
   307 #endif
   308 #endif
   310 #ifdef __cplusplus
   311 }
   312 #endif
   313 #endif /* _STDIO_H_ */
.