sl@0: /* STDIO.H sl@0: * sl@0: * Portions Copyright (c) 1990-1999 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: */ sl@0: sl@0: /** @file sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: sl@0: /* sl@0: * Copyright (c) 1990 The Regents of the University of California. sl@0: * All rights reserved. sl@0: * sl@0: * Redistribution and use in source and binary forms are permitted sl@0: * provided that the above copyright notice and this paragraph are sl@0: * duplicated in all such forms and that any documentation, sl@0: * advertising materials, and other materials related to such sl@0: * distribution and use acknowledge that the software was developed sl@0: * by the University of California, Berkeley. The name of the sl@0: * University may not be used to endorse or promote products derived sl@0: * from this software without specific prior written permission. sl@0: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR sl@0: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED sl@0: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. sl@0: * sl@0: * @(#)stdio.h 5.3 (Berkeley) 3/15/86 sl@0: */ sl@0: sl@0: /* sl@0: * NB: to fit things in six character monocase externals, the sl@0: * stdio code uses the prefix `__s' for stdio objects, typically sl@0: * followed by a three-character attempt at a mnemonic. sl@0: */ sl@0: sl@0: #ifndef _STDIO_H_ sl@0: #define _STDIO_H_ sl@0: sl@0: #ifdef __cplusplus sl@0: extern "C" { sl@0: #endif sl@0: sl@0: #include "_ansi.h" sl@0: sl@0: #define _FSTDIO /* ``function stdio'' */ sl@0: sl@0: #define __need_size_t sl@0: #include <stddef.h> sl@0: sl@0: #include <stdarg_e.h> /* defines __e32_va_list */ sl@0: sl@0: #include <sys/stdio_t.h> /* Definition of _fpos_t and struct __sFILE */ sl@0: sl@0: typedef _fpos_t fpos_t; sl@0: typedef struct __sFILE FILE; sl@0: sl@0: #define __SLBF 0x0001 /* line buffered */ sl@0: #define __SNBF 0x0002 /* unbuffered */ sl@0: #define __SRD 0x0004 /* OK to read */ sl@0: #define __SWR 0x0008 /* OK to write */ sl@0: /* RD and WR are never simultaneously asserted */ sl@0: #define __SRW 0x0010 /* open for reading & writing */ sl@0: #define __SEOF 0x0020 /* found EOF */ sl@0: #define __SERR 0x0040 /* found error */ sl@0: #define __SMBF 0x0080 /* _buf is from malloc */ sl@0: #define __SAPP 0x0100 /* fdopen()ed in append mode - so must write to end */ sl@0: #define __SSTR 0x0200 /* this is an sprintf/snprintf string */ sl@0: #define __SOPT 0x0400 /* do fseek() optimisation */ sl@0: #define __SNPT 0x0800 /* do not do fseek() optimisation */ sl@0: #define __SOFF 0x1000 /* set iff _offset is in fact correct */ sl@0: #define __SMOD 0x2000 /* true => fgetline modified _p text */ sl@0: sl@0: /** sl@0: The following three definitions are for ANSI C, which took them sl@0: from System V, which stupidly took internal interface macros and sl@0: made them official arguments to setvbuf(), without renaming them. sl@0: Hence, these ugly _IOxxx names are *supposed* to appear in user code. sl@0: sl@0: Although these happen to match their counterparts above, the sl@0: implementation does not rely on that (so these could be renumbered). sl@0: */ sl@0: #define _IOFBF 0 /* setvbuf should set fully buffered */ sl@0: #define _IOLBF 1 /* setvbuf should set line buffered */ sl@0: #define _IONBF 2 /* setvbuf should set unbuffered */ sl@0: sl@0: #ifndef NULL sl@0: #define NULL 0L sl@0: #endif sl@0: sl@0: #define BUFSIZ 1024 sl@0: #define EOF (-1) sl@0: sl@0: #define FOPEN_MAX 20 /* must be <= OPEN_MAX <sys/syslimits.h> */ sl@0: #define FILENAME_MAX 256 /* must be <= PATH_MAX <sys/syslimits.h> */ sl@0: #define P_tmpdir "/System/temp/" sl@0: #define WIDEP_tmpdir L"/System/temp/" sl@0: #define L_tmpnam 34 /* ?:/System/temp/t%x.%x */ sl@0: sl@0: #ifndef SEEK_SET sl@0: #define SEEK_SET 0 /* set file offset to offset */ sl@0: #endif sl@0: #ifndef SEEK_CUR sl@0: #define SEEK_CUR 1 /* set file offset to current plus offset */ sl@0: #endif sl@0: #ifndef SEEK_END sl@0: #define SEEK_END 2 /* set file offset to EOF plus offset */ sl@0: #endif sl@0: sl@0: #define TMP_MAX 26 sl@0: sl@0: /** sl@0: Function interface to the "constants" stdin, stdout and stderr. sl@0: These functions guarantee to return a fixed value, so that it sl@0: will be possible to use expressions such as sl@0: if (fp != stdout) sl@0: fclose(fp); sl@0: sl@0: with complete confidence. Unfortunately it will rule out initialising sl@0: global variables with stdin/stdout/stderr, as in the common idiom: sl@0: sl@0: static FILE *log = stderr; sl@0: sl@0: This isn't currently possible with EPOC32. sl@0: */ sl@0: IMPORT_C FILE *__stdin (void); sl@0: IMPORT_C FILE *__stdout (void); sl@0: IMPORT_C FILE *__stderr (void); sl@0: sl@0: #define stdin (__stdin()) sl@0: #define stdout (__stdout()) sl@0: #define stderr (__stderr()) sl@0: sl@0: /** sl@0: Functions defined in ANSI C standard. sl@0: */ sl@0: IMPORT_C FILE * tmpfile (void); sl@0: IMPORT_C char * tmpnam (char *); sl@0: IMPORT_C wchar_t * wtmpnam (wchar_t *); sl@0: IMPORT_C int fclose (FILE *); sl@0: IMPORT_C int fflush (FILE *); sl@0: IMPORT_C FILE * freopen (const char *, const char *, FILE *); sl@0: IMPORT_C FILE * wfreopen (const wchar_t *, const wchar_t *, FILE *); sl@0: IMPORT_C void setbuf (FILE *, char *); sl@0: IMPORT_C int setvbuf (FILE *, char *, int, size_t); sl@0: IMPORT_C int fprintf (FILE *, const char *, ...); sl@0: IMPORT_C int fscanf (FILE *, const char *, ...); sl@0: IMPORT_C int printf (const char *, ...); sl@0: IMPORT_C int scanf (const char *, ...); sl@0: IMPORT_C int sscanf (const char *, const char *, ...); sl@0: IMPORT_C int vfprintf (FILE *, const char *, __e32_va_list); sl@0: IMPORT_C int vprintf (const char *, __e32_va_list); sl@0: IMPORT_C int vsprintf (char *, const char *, __e32_va_list); sl@0: IMPORT_C int fgetc (FILE *); sl@0: IMPORT_C char * fgets (char *, int, FILE *); sl@0: IMPORT_C int fputc (int, FILE *); sl@0: IMPORT_C int fputs (const char *, FILE *); sl@0: IMPORT_C int getc (FILE *); sl@0: IMPORT_C int getchar (void); sl@0: IMPORT_C char * gets (char *); sl@0: IMPORT_C int putc (int, FILE *); sl@0: IMPORT_C int putchar (int); sl@0: IMPORT_C int puts (const char *); sl@0: IMPORT_C int ungetc (int, FILE *); sl@0: IMPORT_C size_t fread (void*, size_t _size, size_t _n, FILE *); sl@0: IMPORT_C size_t fwrite (const void* , size_t _size, size_t _n, FILE *); sl@0: IMPORT_C int fgetpos (FILE *, fpos_t *); sl@0: IMPORT_C int fseek (FILE *, long, int); sl@0: IMPORT_C int fsetpos (FILE *, const fpos_t *); sl@0: IMPORT_C long ftell (FILE *); sl@0: IMPORT_C void rewind (FILE *); sl@0: IMPORT_C void clearerr (FILE *); sl@0: IMPORT_C int feof (FILE *); sl@0: IMPORT_C int ferror (FILE *); sl@0: IMPORT_C void perror (const char *); sl@0: #ifndef _REENT_ONLY sl@0: IMPORT_C FILE * fopen (const char *_name, const char *_type); sl@0: IMPORT_C FILE * wfopen (const wchar_t *_name, const wchar_t *_type); sl@0: IMPORT_C int sprintf (char *, const char *, ...); sl@0: #endif sl@0: sl@0: /** sl@0: Routines in POSIX 1003.1. sl@0: */ sl@0: IMPORT_C int fileno (FILE *); sl@0: sl@0: #ifndef _REENT_ONLY sl@0: IMPORT_C FILE * fdopen (int, const char *); sl@0: IMPORT_C FILE * wfdopen (int, const wchar_t *); sl@0: #endif sl@0: sl@0: /** sl@0: The name _cleanup is rather well-known... sl@0: */ sl@0: IMPORT_C void _cleanup (void); sl@0: sl@0: /** sl@0: EPOC32 support for multiple processes sl@0: */ sl@0: IMPORT_C int popen3 (const char *cmd, const char *mode, char** envp, int fids[3]); sl@0: IMPORT_C int wpopen3 (const wchar_t *cmd, const wchar_t *mode, wchar_t** envp, int fids[3]); sl@0: sl@0: #ifndef _STRICT_ANSI sl@0: int getw (FILE *); sl@0: int putw (int, FILE *); sl@0: void setbuffer (FILE *, char *, int); sl@0: int setlinebuf (FILE *); sl@0: sl@0: /** sl@0: Stdio function-access interface. sl@0: */ sl@0: FILE *funopen (const void* _cookie, sl@0: int (*readfn) (void* _cookie, char *_buf, int _n), sl@0: int (*writefn)(void* _cookie, const char *_buf, int _n), sl@0: fpos_t (*seekfn) (void* _cookie, fpos_t _off, int _whence), sl@0: int (*closefn)(void* _cookie)); sl@0: sl@0: #define fropen(cookie, fn) funopen(cookie, fn, (int (*)())0, (fpos_t (*)())0, (int (*)())0) sl@0: #define fwopen(cookie, fn) funopen(cookie, (int (*)())0, fn, (fpos_t (*)())0, (int (*)())0) sl@0: #define getchar() getc(stdin) sl@0: #define putchar(x) putc(x, stdout) sl@0: #define L_cuserid 9 /* posix says it goes in stdio.h :( */ sl@0: sl@0: #endif /* _STRICT_ANSI */ sl@0: sl@0: #ifdef __cplusplus sl@0: } sl@0: #endif sl@0: #endif /* _STDIO_H_ */