URI:
       stdio.h - scc - simple c99 compiler
  HTML git clone git://git.simple-cc.org/scc
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
       stdio.h (3957B)
       ---
            1 #ifndef _STDIO_H
            2 #define _STDIO_H
            3 
            4 #define _NEED_NULL
            5 #define _NEED_SIZET
            6 #include <sys/stdio.h>
            7 #include <arch/cdefs.h>
            8 #include <bits/wchar.h>
            9 
           10 #ifndef FOPEN_MAX
           11 #define FOPEN_MAX 12
           12 #endif
           13 
           14 #define EOF     -1
           15 #define SEEK_SET 0
           16 #define SEEK_CUR 1
           17 #define SEEK_END 2
           18 
           19 /**
           20  * enum _file_flags - internal FILE macros used by stdio
           21  * @_IOWRITE: write only stream
           22  * @_IOREAD: read only stream
           23  * @_IORW: read and write stream
           24  * @_IOEOF: mark of end of file in the stream
           25  * @_IOERR: mark of error in the stream
           26  * @_IOSTRG: string stream
           27  * @_IOTXT: text stream
           28  * @_IOFBF: full buffered stream
           29  * @_IOLBF: line buffered stream
           30  * @_IONBF: non buffered stream
           31  * @_IOALLOC: stream with a dynamic allocated buffer
           32  */
           33 enum _file_flags {
           34         _IOWRITE = (1 << 0),
           35         _IOREAD =  (1 << 1),
           36         _IORW =    (1 << 2),
           37         _IOEOF =   (1 << 3),
           38         _IOERR =   (1 << 4),
           39         _IOSTRG =  (1 << 5),
           40         _IOTXT =   (1 << 6),
           41         _IOFBF =   (1 << 7),
           42         _IOLBF =   (1 << 8),
           43         _IONBF =   (1 << 9),
           44         _IOALLOC = (1 <<10),
           45 };
           46 
           47 /**
           48  * struct FILE - opaque structure containing information about a file
           49  * @fd: file descriptor
           50  * @buf: pointer to i/o buffer
           51  * @rp: read pointer
           52  * @wp: write pointer
           53  * @lp: write pointer used when line-buffering
           54  * @len: actual length of buffer
           55  * @flags: file open mode
           56  * @unbuf: tiny buffer for unbuffered i/o
           57  */
           58 typedef struct _FILE {
           59         int fd;
           60         unsigned char *buf;
           61         unsigned char *rp;
           62         unsigned char *wp;
           63         unsigned char *lp;
           64         size_t len;
           65         unsigned short flags;
           66         unsigned char unbuf[1];
           67         __mbstate_t mbs;
           68 } FILE;
           69 
           70 extern FILE __iob[FOPEN_MAX];
           71 
           72 #define        stdin  (&__iob[0])
           73 #define        stdout (&__iob[1])
           74 #define        stderr (&__iob[2])
           75 
           76 int remove(const char *);
           77 int rename(const char *, const char *);
           78 FILE *tmpfile(void);
           79 char *tmpnam(char *);
           80 int fclose(FILE *);
           81 int fflush(FILE *);
           82 FILE *fopen(const char *restrict, const char *restrict);
           83 FILE *freopen(const char *restrict, const char *restrict,
           84                      FILE *restrict);
           85 void setbuf(FILE *restrict, char *restrict);
           86 int setvbuf(FILE *restrict, char *restrict, int, size_t);
           87 int fprintf(FILE *restrict, const char *restrict, ...);
           88 int fscanf(FILE *restrict, const char *restrict, ...);
           89 int printf(const char *restrict, ...);
           90 int scanf(const char *restrict, ...);
           91 int snprintf(char *restrict, size_t, const char *restrict, ...);
           92 int sprintf(char *restrict, const char *restrict, ...);
           93 int sscanf(const char *restrict, const char *restrict, ...);
           94 
           95 int vfprintf(FILE *restrict, const char *restrict, __va_list);
           96 int vfscanf(FILE *restrict, const char *restrict, __va_list);
           97 int vprintf(const char *restrict, __va_list);
           98 int vscanf(const char *restrict, __va_list);
           99 int vsnprintf(char *restrict, size_t, const char *restrict, __va_list);
          100 int vsprintf(char *restrict, const char *restrict, __va_list);
          101 int vsscanf(const char *restrict, const char *restrict, __va_list);
          102 
          103 int fgetc(FILE *);
          104 char *fgets(char *restrict, int, FILE *restrict);
          105 int fputc(int, FILE *);
          106 int fputs(const char *restrict, FILE *restrict);
          107 int getc(FILE *);
          108 int getchar(void);
          109 char *gets(char *);
          110 int putc(int, FILE *);
          111 int putchar(int);
          112 int puts(const char *);
          113 int ungetc(int, FILE *);
          114 size_t fread(void *restrict, size_t, size_t, FILE *restrict);
          115 size_t fwrite(const void *restrict, size_t, size_t, FILE *restrict);
          116 int fseek(FILE *, long int, int);
          117 long int ftell(FILE *);
          118 void rewind(FILE *);
          119 void clearerr(FILE *);
          120 int feof(FILE *);
          121 int ferror(FILE *);
          122 void perror(const char *);
          123 
          124 int __getc(FILE *);
          125 int __putc(int, FILE *);
          126 
          127 #define getc(fp)            ((fp)->rp >= (fp)->wp ? __getc(fp) : *(fp)->rp++)
          128 #define putc(c, fp)         ((fp)->wp >= (fp)->rp ? __putc(c,fp) : (*(fp)->wp++ = c))
          129 #define ferror(fp)          ((fp)->flags & _IOERR)
          130 #define feof(fp)            ((fp)->flags & _IOEOF)
          131 #define clearerr(fp)        (void) ((fp)->flags &= ~(_IOERR|_IOEOF))
          132 #define getchar()           getc(stdin)
          133 #define putchar(c)          putc((c), stdout)
          134 #define setbuf(fp, b)       (void) setvbuf(fp, b, b ? _IOFBF:_IONBF, BUFSIZ)
          135 
          136 #endif