66
77#ifdef HAS_CUSTOM_FILE
88#include CUSTOM_FILE_FILE
9- #else
9+ #else /* HAS_CUSTOM_FILE */
1010typedef struct
1111{
1212 unsigned char slot;
@@ -17,7 +17,7 @@ typedef struct
1717#define stdin ((FILE*)1 )
1818#define stdout ((FILE*)2 )
1919#define stderr ((FILE*)2 )
20- #endif
20+ #endif /* HAS_CUSTOM_FILE */
2121
2222#ifndef EOF
2323#define EOF (-1 )
@@ -36,12 +36,14 @@ typedef struct
3636__BEGIN_DECLS
3737
3838/* weak user-defined functions */
39+
3940int inchar (void );
4041
4142void outchar (char character);
4243
43- FILE *fopen (const char *__restrict filename,
44- const char *__restrict mode);
44+ FILE *fopen (const char *__restrict filename, const char *__restrict mode);
45+
46+ FILE *freopen (const char *__restrict filename, const char *__restrict mode, FILE *__restrict stream);
4547
4648int fclose (FILE *stream);
4749
@@ -53,44 +55,50 @@ int feof(FILE *stream);
5355
5456void clearerr (FILE *stream);
5557
56- int fputs (const char *__restrict str, FILE *__restrict stream);
57-
58- size_t fread (void *ptr, size_t size, size_t count, FILE *__restrict stream);
58+ size_t fread (void *__restrict ptr, size_t size, size_t count, FILE *__restrict stream);
5959
60- size_t fwrite (const void *__restrict ptr, size_t size, size_t count,
61- FILE *__restrict stream);
60+ size_t fwrite (const void *__restrict ptr, size_t size, size_t count, FILE *__restrict stream);
6261
6362long int ftell (FILE *stream) __attribute__((__warn_unused_result__));
6463
6564int fseek (FILE *stream, long int offset, int origin);
6665
66+ void rewind (FILE *stream);
67+
6768int fgetc (FILE *stream);
68- #define getc (...) fgetc(__VA_ARGS__)
69+
70+ char *fgets (char *__restrict str, int num, FILE *__restrict stream);
71+
72+ int ungetc (int ch, FILE *stream);
6973
7074int fputc (int c, FILE *stream);
71- #define putc (...) fputc(__VA_ARGS__)
7275
73- char * fgets ( char *__restrict str, int num , FILE *__restrict stream);
76+ int fputs ( const char *__restrict str, FILE *__restrict stream);
7477
7578int remove (const char *filename);
7679
77- void rewind (FILE *stream );
80+ int rename ( const char *old_filename, const char *new_filename );
7881
7982/* standard impls */
83+
8084int getchar (void );
8185
8286int putchar (int character);
8387
8488int puts (const char *str);
8589
90+ int getc (FILE *stream);
91+
92+ int putc (int c, FILE *stream);
93+
8694int printf (const char *__restrict format, ...)
8795 __attribute__((format(__printf__, 1 , 2 )));
8896
8997int vprintf (const char *__restrict format, va_list va)
9098 __attribute__((format(__printf__, 1 , 0 )));
9199
92100int sprintf (char *__restrict buffer, const char *__restrict format, ...)
93- __attribute__((format (__printf__, 2 , 3 )));
101+ __attribute__((format(__printf__, 2 , 3 )));
94102
95103int vsprintf (char *__restrict buffer, const char *__restrict format, va_list va)
96104 __attribute__((format(__printf__, 2 , 0 )));
@@ -108,7 +116,7 @@ int vfprintf(FILE *__restrict stream, const char *__restrict format, va_list va)
108116 __attribute__((format(__printf__, 2 , 0 )));
109117
110118int asprintf (char **__restrict p_buffer, const char *__restrict format, ...)
111- __attribute__((format (__printf__, 2 , 3 ))) __attribute__((nonnull(1 )));
119+ __attribute__((format(__printf__, 2 , 3 ))) __attribute__((nonnull(1 )));
112120
113121int vasprintf (char **__restrict p_buffer, const char *__restrict format, va_list va)
114122 __attribute__((format(__printf__, 2 , 0 ))) __attribute__((nonnull(1 )));
@@ -119,39 +127,44 @@ __END_DECLS
119127
120128#ifdef __cplusplus
121129namespace std {
122- using ::size_t ;
123- using ::FILE;
124-
125- using ::fopen;
126- using ::fclose;
127- using ::fflush;
128- using ::ferror;
129- using ::feof;
130- using ::clearerr;
131- using ::fputs;
132- using ::fread;
133- using ::fwrite;
134- using ::ftell;
135- using ::fseek;
136- using ::fgetc;
137- using ::fputc;
138- using ::fgets;
139- using ::remove;
140- using ::rewind;
141- using ::getchar;
142- using ::putchar;
143- using ::puts;
144- using ::printf;
145- using ::vprintf;
146- using ::sprintf;
147- using ::vsprintf;
148- using ::snprintf;
149- using ::vsnprintf;
150- using ::fprintf;
151- using ::vfprintf;
152- using ::asprintf;
153- using ::vasprintf;
154- using ::perror;
130+ using ::size_t ;
131+ using ::FILE;
132+
133+ using ::fopen;
134+ using ::freopen;
135+ using ::fclose;
136+ using ::fflush;
137+ using ::ferror;
138+ using ::feof;
139+ using ::clearerr;
140+ using ::fread;
141+ using ::fwrite;
142+ using ::ftell;
143+ using ::fseek;
144+ using ::rewind;
145+ using ::fgetc;
146+ using ::fgets;
147+ using ::ungetc;
148+ using ::fputc;
149+ using ::fputs;
150+ using ::remove;
151+ using ::rename;
152+ using ::getchar;
153+ using ::putchar;
154+ using ::puts;
155+ using ::getc;
156+ using ::putc;
157+ using ::printf;
158+ using ::vprintf;
159+ using ::sprintf;
160+ using ::vsprintf;
161+ using ::snprintf;
162+ using ::vsnprintf;
163+ using ::fprintf;
164+ using ::vfprintf;
165+ using ::asprintf;
166+ using ::vasprintf;
167+ using ::perror;
155168} /* namespace std */
156169#endif /* __cplusplus */
157170
0 commit comments