source: trunk/sys/dietlibc/include/stdio.h @ 1

Last change on this file since 1 was 1, checked in by alain, 7 years ago

First import

File size: 6.2 KB
Line 
1#ifndef _STDIO_H
2#define _STDIO_H
3
4#include <stdarg.h>
5#include <sys/types.h>
6#include <endian.h>
7
8struct __stdio_file;
9typedef struct __stdio_file FILE;
10
11extern FILE *stdin, *stdout, *stderr;
12
13FILE *fopen (const char *path, const char *mode) ;
14FILE *fdopen (int fildes, const char *mode) ;
15FILE *freopen (const char *path, const char *mode, FILE *stream) ;
16
17int printf(const char *format, ...)  __attribute__((__format__(__printf__,1,2)));
18int fprintf(FILE *stream, const char *format, ...)  __attribute__((__format__(__printf__,2,3)));
19int sprintf(char *str, const char *format, ...)  __attribute__((__format__(__printf__,2,3)));
20int snprintf(char *str, size_t size, const char *format, ...)  __attribute__((__format__(__printf__,3,4)));
21int asprintf(char **ptr, const char* format, ...)  __attribute__((__format__(__printf__,2,3)));
22
23int scanf(const char *format, ...)  __attribute__((__format__(__scanf__,1,2)));
24int fscanf(FILE *stream, const char *format, ...)  __attribute__((__format__(__scanf__,2,3)));
25int sscanf(const char *str, const char *format, ...)  __attribute__((__format__(__scanf__,2,3)));
26
27int vprintf(const char *format, va_list ap)  __attribute__((__format__(__printf__,1,0)));
28int vfprintf(FILE *stream, const char *format, va_list ap)  __attribute__((__format__(__printf__,2,0)));
29int vsprintf(char *str, const char *format, va_list ap)  __attribute__((__format__(__printf__,2,0)));
30int vsnprintf(char *str, size_t size, const char *format, va_list ap)  __attribute__((__format__(__printf__,3,0)));
31
32int fdprintf(int fd, const char *format, ...)  __attribute__((__format__(__printf__,2,3)));
33int vfdprintf(int fd, const char *format, va_list ap)  __attribute__((__format__(__printf__,2,0)));
34
35int vscanf(const char *format, va_list ap)  __attribute__((__format__(__scanf__,1,0)));
36int vsscanf(const char *str, const char *format, va_list ap)  __attribute__((__format__(__scanf__,2,0)));
37int vfscanf(FILE *stream, const char *format, va_list ap)  __attribute__((__format__(__scanf__,2,0)));
38
39int fgetc(FILE *stream) ;
40int fgetc_unlocked(FILE *stream) ;
41char *fgets(char *s, int size, FILE *stream) ;
42char *fgets_unlocked(char *s, int size, FILE *stream) ;
43
44char *gets(char *s) ;
45int ungetc(int c, FILE *stream) ;
46int ungetc_unlocked(int c, FILE *stream) ;
47
48int fputc(int c, FILE *stream) ;
49int fputc_unlocked(int c, FILE *stream) ;
50int fputs(const char *s, FILE *stream) ;
51int fputs_unlocked(const char *s, FILE *stream) ;
52
53int getc(FILE *stream) ;
54int getchar(void) ;
55int putchar(int c) ;
56int putchar_unlocked(int c) ;
57
58#if !defined(__cplusplus)
59#define putc(c,stream) fputc(c,stream)
60#define putchar(c) fputc(c,stdout)
61#define putc_unlocked(c,stream) fputc_unlocked(c,stream)
62#define putchar_unlocked(c) fputc_unlocked(c,stdout)
63#else
64inline int putc(int c, FILE *stream)  { return fputc(c,stream); }
65inline int putc_unlocked(int c, FILE *stream)  { return fputc_unlocked(c,stream); }
66#endif
67
68#if !defined(__cplusplus)
69#define getc(stream) fgetc(stream)
70#define getchar() fgetc(stdin)
71#define getc_unlocked(stream) fgetc_unlocked(stream)
72#define getchar_unlocked() fgetc_unlocked(stdin)
73#else
74inline int getc_unlocked(FILE *stream)  { return fgetc_unlocked(stream); }
75inline int getchar_unlocked(void)  { return fgetc_unlocked(stdin); }
76#endif
77
78int puts(const char *s) ;
79
80int fseek(FILE *stream, long offset, int whence) ;
81int fseek_unlocked(FILE *stream, long offset, int whence) ;
82long ftell(FILE *stream) ;
83long ftell_unlocked(FILE *stream) ;
84int fseeko(FILE *stream, off_t offset, int whence) ;
85int fseeko_unlocked(FILE *stream, off_t offset, int whence) ;
86off_t ftello(FILE *stream) ;
87off_t ftello_unlocked(FILE *stream) ;
88
89#if __WORDSIZE == 32
90
91#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
92#define off_t loff_t
93#define fseeko(foo,bar,baz) fseeko64(foo,bar,baz)
94#define ftello(foo) ftello64(foo)
95#endif
96
97#endif
98
99void rewind(FILE *stream) ;
100int fgetpos(FILE *stream, fpos_t *pos) ;
101int fsetpos(FILE *stream, fpos_t *pos) ;
102
103size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream) ;
104size_t fread_unlocked(void *ptr, size_t size, size_t nmemb, FILE *stream) ;
105
106size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) ;
107size_t fwrite_unlocked(const void *ptr, size_t size, size_t nmemb, FILE *stream) ;
108
109int fflush(FILE *stream) ;
110int fflush_unlocked(FILE *stream) ;
111
112int fclose(FILE *stream) ;
113int fclose_unlocked(FILE *stream) ;
114
115int feof(FILE *stream) ;
116int feof_unlocked(FILE *stream) ;
117int ferror(FILE *stream) ;
118int ferror_unlocked(FILE *stream) ;
119int fileno(FILE *stream) ;
120int fileno_unlocked(FILE *stream) ;
121void clearerr(FILE *stream) ;
122void clearerr_unlocked(FILE *stream) ;
123
124int remove(const char *pathname) ;
125int rename(const char *oldpath, const char *newpath) ;
126
127void perror(const char *s) ;
128
129#define EOF (-1)
130
131#define BUFSIZ 128
132
133#define _IONBF 0
134#define _IOLBF 1
135#define _IOFBF 2
136
137int setvbuf(FILE *stream, char *buf, int mode , size_t size) ;
138int setvbuf_unlocked(FILE *stream, char *buf, int mode , size_t size) ;
139
140#if !defined(__cplusplus)
141#define setbuf(stream,buf) setvbuf(stream,buf,buf?_IOFBF:_IONBF,BUFSIZ)
142#define setbuffer(stream,buf,size) setvbuf(stream,buf,buf?_IOFBF:_IONBF,size)
143#define setlinebuf(stream) setvbuf(stream,0,_IOLBF,BUFSIZ)
144#else
145inline int setbuf(FILE *stream, char *buf) 
146  { return setvbuf(stream,buf,buf?_IOFBF:_IONBF,BUFSIZ); }
147inline int setbuffer(FILE *stream, char *buf, size_t size) 
148  { return setvbuf(stream,buf,buf?_IOFBF:_IONBF,size); }
149inline int setlinebuf(FILE *stream) 
150  { return setvbuf(stream,0,_IOLBF,BUFSIZ); }
151#endif
152
153FILE *popen(const char *command, const char *type) ;
154int pclose(FILE *stream) ;
155
156
157#define L_tmpnam 128
158#define P_tmpdir "/tmp"
159char* tmpnam(char *s) ; /* DO NOT USE!!! Use mkstemp instead! */
160char* tempnam(char* dir,char* _template);       /* dito */
161FILE* tmpfile(void) ;
162FILE* tmpfile_unlocked(void) ;
163
164#define FILENAME_MAX NAME_MAX
165#define FOPEN_MAX 16
166
167#define TMP_MAX 10000
168
169/* this is so bad, we moved it to -lcompat */
170#define L_ctermid 9
171char* ctermid(char* s); /* returns "/dev/tty" */
172
173void flockfile(FILE* f) ;
174void funlockfile(FILE* f) ;
175int ftrylockfile (FILE *__stream) ;
176
177#ifdef _GNU_SOURCE
178int vasprintf(char **strp, const char *fmt, va_list ap);
179ssize_t getline(char **lineptr, size_t *n, FILE *stream);
180ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream);
181#endif
182
183#endif
Note: See TracBrowser for help on using the repository browser.