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