| [aad342c] | 1 | /* The header stdio.h defines several macros, and declares three types and many
|
|---|
| 2 | * functions for performing input and output.
|
|---|
| 3 | */
|
|---|
| 4 | #ifndef _STDIO_
|
|---|
| 5 | #define _STDIO_
|
|---|
| 6 |
|
|---|
| 7 | #include<civl-stdio.cvh>
|
|---|
| 8 |
|
|---|
| 9 | /* Needed from stdarg.h: */
|
|---|
| 10 |
|
|---|
| 11 | #include <stdarg.h>
|
|---|
| 12 | #pragma CIVL ACSL
|
|---|
| 13 | /* Types */
|
|---|
| 14 |
|
|---|
| 15 | typedef unsigned long int size_t;
|
|---|
| 16 |
|
|---|
| 17 | typedef int fpos_t;
|
|---|
| 18 |
|
|---|
| 19 | /* Macros */
|
|---|
| 20 |
|
|---|
| 21 | #ifndef NULL
|
|---|
| 22 | #define NULL ((void*)0)
|
|---|
| 23 | #endif
|
|---|
| 24 | #define _IOFBF 1
|
|---|
| 25 | #define _IOLBF 2
|
|---|
| 26 | #define _IONBF 3
|
|---|
| 27 | #define BUFSIZ 100
|
|---|
| 28 | #define EOF (-100)
|
|---|
| 29 | #define FOPEN_MAX 100
|
|---|
| 30 | #define FILENAME_MAX 500
|
|---|
| 31 | #define L_tmpnam 500
|
|---|
| 32 | #define SEEK_CUR 1
|
|---|
| 33 | #define SEEK_END 2
|
|---|
| 34 | #define SEEK_SET 3
|
|---|
| 35 | #define TMP_MAX 100
|
|---|
| 36 | //#define stdin (FILE*)0
|
|---|
| 37 | //#define stdout (FILE*)1
|
|---|
| 38 | //#define stderr (FILE*)2
|
|---|
| 39 |
|
|---|
| 40 | /* external variables */
|
|---|
| 41 |
|
|---|
| 42 | extern FILE * stdout;
|
|---|
| 43 | extern FILE * stdin;
|
|---|
| 44 | extern FILE * stderr;
|
|---|
| 45 |
|
|---|
| 46 | /* Functions */
|
|---|
| 47 |
|
|---|
| 48 | int remove(const char *filename);
|
|---|
| 49 | int rename(const char *old, const char *new);
|
|---|
| 50 | FILE *tmpfile(void);
|
|---|
| 51 | char *tmpnam(char *s);
|
|---|
| 52 | /*@ depends_on \access(stream);
|
|---|
| 53 | @ executes_when \true;
|
|---|
| 54 | @*/
|
|---|
| 55 | $system int fclose(FILE *stream);
|
|---|
| 56 | /*@ depends_on \access(stream);
|
|---|
| 57 | @ executes_when \true;
|
|---|
| 58 | @*/
|
|---|
| 59 | $system int fflush(FILE *stream);
|
|---|
| 60 | FILE *fopen(const char * restrict filename,
|
|---|
| 61 | const char * restrict mode);
|
|---|
| 62 | FILE *freopen(const char * restrict filename,
|
|---|
| 63 | const char * restrict mode,
|
|---|
| 64 | FILE * restrict stream);
|
|---|
| 65 | void setbuf(FILE * restrict stream,
|
|---|
| 66 | char * restrict buf);
|
|---|
| 67 | int setvbuf(FILE * restrict stream,
|
|---|
| 68 | char * restrict buf,
|
|---|
| 69 | int mode, size_t size);
|
|---|
| 70 | /*@ depends_on \access(stream, format);
|
|---|
| 71 | @ executes_when \true;
|
|---|
| 72 | @*/
|
|---|
| 73 | $system int fprintf(FILE * restrict stream,
|
|---|
| 74 | const char * restrict format, ...);
|
|---|
| 75 | /*@ depends_on \access(stream, format);
|
|---|
| 76 | @ executes_when \true;
|
|---|
| 77 | @*/
|
|---|
| 78 | $system int fscanf(FILE * restrict stream,
|
|---|
| 79 | const char * restrict format, ...);
|
|---|
| 80 | /*@ depends_on \access(format);
|
|---|
| 81 | @ executes_when \true;
|
|---|
| 82 | @*/
|
|---|
| 83 | $system int printf(const char * restrict format, ...);
|
|---|
| 84 | /*@ depends_on \access(format);
|
|---|
| 85 | @ executes_when \true;
|
|---|
| 86 | @*/
|
|---|
| 87 | $system int scanf(const char * restrict format, ...);
|
|---|
| 88 | int snprintf(char * restrict s, size_t n,
|
|---|
| 89 | const char * restrict format, ...);
|
|---|
| 90 | $system int sprintf(char * restrict s,
|
|---|
| 91 | const char * restrict format, ...);
|
|---|
| 92 | /*@ depends_on \access(s, format);
|
|---|
| 93 | @ executes_when \true;
|
|---|
| 94 | @*/
|
|---|
| 95 | $system int sscanf(const char * restrict s,
|
|---|
| 96 | const char * restrict format, ...);
|
|---|
| 97 | int vfprintf(FILE * restrict stream,
|
|---|
| 98 | const char * restrict format, va_list arg);
|
|---|
| 99 | int vfscanf(FILE * restrict stream,
|
|---|
| 100 | const char * restrict format, va_list arg);
|
|---|
| 101 | int vprintf(const char * restrict format, va_list arg);
|
|---|
| 102 | int vscanf(const char * restrict format, va_list arg);
|
|---|
| 103 | int vsnprintf(char * restrict s, size_t n,
|
|---|
| 104 | const char * restrict format, va_list arg);
|
|---|
| 105 | int vsprintf(char * restrict s,
|
|---|
| 106 | const char * restrict format, va_list arg);
|
|---|
| 107 | int vsscanf(const char * restrict s,
|
|---|
| 108 | const char * restrict format, va_list arg);
|
|---|
| 109 | int fgetc(FILE *stream);
|
|---|
| 110 | $system char *fgets(char * restrict s, int n,
|
|---|
| 111 | FILE * restrict stream);
|
|---|
| 112 | int fputc(int c, FILE *stream);
|
|---|
| 113 | int fputs(const char * restrict s,
|
|---|
| 114 | FILE * restrict stream);
|
|---|
| 115 | int getc(FILE *stream);
|
|---|
| 116 | int getchar(void);
|
|---|
| 117 | int putc(int c, FILE *stream);
|
|---|
| 118 | int putchar(int c);
|
|---|
| 119 | int puts(const char *s);
|
|---|
| 120 | int ungetc(int c, FILE *stream);
|
|---|
| 121 | size_t fread(void * restrict ptr,
|
|---|
| 122 | size_t size, size_t nmemb,
|
|---|
| 123 | FILE * restrict stream);
|
|---|
| 124 | size_t fwrite(const void * restrict ptr,
|
|---|
| 125 | size_t size, size_t nmemb,
|
|---|
| 126 | FILE * restrict stream);
|
|---|
| 127 | int fgetpos(FILE * restrict stream,
|
|---|
| 128 | fpos_t * restrict pos);
|
|---|
| 129 | int fseek(FILE *stream, long int offset, int whence);
|
|---|
| 130 | int fsetpos(FILE *stream, const fpos_t *pos);
|
|---|
| 131 | long int ftell(FILE *stream);
|
|---|
| 132 | void rewind(FILE *stream);
|
|---|
| 133 | void clearerr(FILE *stream);
|
|---|
| 134 | int feof(FILE *stream);
|
|---|
| 135 | int ferror(FILE *stream);
|
|---|
| 136 | void perror(const char *s);
|
|---|
| 137 |
|
|---|
| 138 | /* Optional Extensions */
|
|---|
| 139 |
|
|---|
| 140 | #define __STDC_WANT_LIB_EXT1__ 1
|
|---|
| 141 | #define L_tmpnam_s 100
|
|---|
| 142 | #define TMP_MAX_S 100
|
|---|
| 143 | typedef int errno_t;
|
|---|
| 144 | typedef size_t rsize_t;
|
|---|
| 145 | errno_t tmpfile_s(FILE * restrict * restrict streamptr);
|
|---|
| 146 | errno_t tmpnam_s(char *s, rsize_t maxsize);
|
|---|
| 147 | errno_t fopen_s(FILE * restrict * restrict streamptr,
|
|---|
| 148 | const char * restrict filename,
|
|---|
| 149 | const char * restrict mode);
|
|---|
| 150 | errno_t freopen_s(FILE * restrict * restrict newstreamptr,
|
|---|
| 151 | const char * restrict filename,
|
|---|
| 152 | const char * restrict mode,
|
|---|
| 153 | FILE * restrict stream);
|
|---|
| 154 | int fprintf_s(FILE * restrict stream,
|
|---|
| 155 | const char * restrict format, ...);
|
|---|
| 156 | int fscanf_s(FILE * restrict stream,
|
|---|
| 157 | const char * restrict format, ...);
|
|---|
| 158 | int printf_s(const char * restrict format, ...);
|
|---|
| 159 | int scanf_s(const char * restrict format, ...);
|
|---|
| 160 | int snprintf_s(char * restrict s, rsize_t n,
|
|---|
| 161 | const char * restrict format, ...);
|
|---|
| 162 | int sprintf_s(char * restrict s, rsize_t n,
|
|---|
| 163 | const char * restrict format, ...);
|
|---|
| 164 | int sscanf_s(const char * restrict s,
|
|---|
| 165 | const char * restrict format, ...);
|
|---|
| 166 | int vfprintf_s(FILE * restrict stream,
|
|---|
| 167 | const char * restrict format,
|
|---|
| 168 | va_list arg);
|
|---|
| 169 | int vfscanf_s(FILE * restrict stream,
|
|---|
| 170 | const char * restrict format,
|
|---|
| 171 | va_list arg);
|
|---|
| 172 | int vprintf_s(const char * restrict format,
|
|---|
| 173 | va_list arg);
|
|---|
| 174 | int vscanf_s(const char * restrict format,
|
|---|
| 175 | va_list arg);
|
|---|
| 176 | int vsnprintf_s(char * restrict s, rsize_t n,
|
|---|
| 177 | const char * restrict format,
|
|---|
| 178 | va_list arg);
|
|---|
| 179 | int vsprintf_s(char * restrict s, rsize_t n,
|
|---|
| 180 | const char * restrict format,
|
|---|
| 181 | va_list arg);
|
|---|
| 182 | int vsscanf_s(const char * restrict s,
|
|---|
| 183 | const char * restrict format,
|
|---|
| 184 | va_list arg);
|
|---|
| 185 | char *gets_s(char *s, rsize_t n);
|
|---|
| 186 |
|
|---|
| 187 | #endif
|
|---|