1 /******************************************************************************
2  * Copyright (c) 2004, 2008 IBM Corporation
3  * All rights reserved.
4  * This program and the accompanying materials
5  * are made available under the terms of the BSD License
6  * which accompanies this distribution, and is available at
7  * http://www.opensource.org/licenses/bsd-license.php
8  *
9  * Contributors:
10  *     IBM Corporation - initial implementation
11  *****************************************************************************/
12 
13 #ifndef _STDIO_H
14 #define _STDIO_H
15 
16 #include <stdarg.h>
17 #include "stddef.h"
18 
19 #define EOF (-1)
20 
21 #define _IONBF 0
22 #define _IOLBF 1
23 #define _IOFBF 2
24 #define BUFSIZ 80
25 
26 typedef struct {
27 	int fd;
28 	int mode;
29 	int pos;
30 	char *buf;
31 	int bufsiz;
32 } FILE;
33 
34 extern FILE stdin_data;
35 extern FILE stdout_data;
36 extern FILE stderr_data;
37 
38 #define stdin (&stdin_data)
39 #define stdout (&stdout_data)
40 #define stderr (&stderr_data)
41 
42 int fileno(FILE *stream);
43 
44 int _printf(const char *format, ...) __attribute__((format (printf, 1, 2)));
45 
46 #ifndef pr_fmt
47 #define pr_fmt(fmt) fmt
48 #endif
49 
50 #define printf(f, ...) do { _printf(pr_fmt(f), ##__VA_ARGS__); } while(0)
51 
52 int fprintf(FILE *stream, const char *format, ...) __attribute__((format (printf, 2, 3)));
53 int snprintf(char *str, size_t size, const char *format, ...)  __attribute__((format (printf, 3, 4)));
54 int vfprintf(FILE *stream, const char *format, va_list);
55 int vsnprintf(char *str, size_t size, const char *format, va_list);
56 void setbuf(FILE *stream, char *buf);
57 int setvbuf(FILE *stream, char *buf, int mode , size_t size);
58 
59 int fputc(int ch, FILE *stream);
60 #define putc(ch, stream)	fputc(ch, stream)
61 int putchar(int ch);
62 int puts(const char *str);
63 int fputs(const char *str, FILE *stream);
64 
65 int scanf(const char *format, ...)  __attribute__((format (scanf, 1, 2)));
66 int fscanf(FILE *stream, const char *format, ...) __attribute__((format (scanf, 2, 3)));
67 int vfscanf(FILE *stream, const char *format, va_list);
68 int vsscanf(const char *str, const char *format, va_list);
69 int getc(FILE *stream);
70 int getchar(void);
71 
72 #endif
73