aboutsummaryrefslogtreecommitdiff
path: root/src/lib/include/stdio.h
blob: 5bb3b71ebaaf5164c73a4149a95db60fe984a0ce (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#pragma once

#include <stdarg.h>

#include <proto/fs.h>

#include <kogata/printf.h>

#include <kogata/syscall.h>

void setup_libc_stdio();

#define BUFSIZ 256


struct file_t {
	fd_t fd;
	stat_t st;
	int file_mode;

	size_t pos;

	int buf_mode;
	char *out_buf;
	size_t out_buf_size, out_buf_used;
	bool out_buf_owned;

	int ungetc_char;
};
typedef struct file_t FILE;


int fgetc(FILE *stream);
char *fgets(char *s, int size, FILE *stream);
int getc(FILE *stream);
int getchar(void);
int ungetc(int c, FILE *stream);

int fputc(int c, FILE *stream);
int fputs(const char *s, FILE *stream);
int putc(int c, FILE *stream);
int putchar(int c);
int puts(const char *s);

FILE *fopen(const char *path, const char *mode);
FILE *freopen(const char *path, const char *mode, FILE *stream);

void clearerr(FILE *stream);
int feof(FILE *stream);
int ferror(FILE *stream);
int fileno(FILE *stream);


size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);

int fflush(FILE* f);
int fclose(FILE* f);

#define EOF ((int)-1)

extern FILE *stdin, *stdout, *stderr;

void setbuf(FILE *stream, char *buf);
void setbuffer(FILE *stream, char *buf, size_t size);
void setlinebuf(FILE *stream);
int setvbuf(FILE *stream, char *buf, int mode, size_t size);

#define _IOFBF 1
#define _IOLBF 2
#define _IONBF 4

typedef size_t fpos_t;	//TODO

int fseek(FILE *stream, long offset, int whence);
long ftell(FILE *stream);
void rewind(FILE *stream);
int fgetpos(FILE *stream, fpos_t *pos);
int fsetpos(FILE *stream, const fpos_t *pos);

#define SEEK_SET 1
#define SEEK_CUR 2
#define SEEK_END 4

#define L_tmpnam 128
FILE *tmpfile(void);
char *tmpnam(char *s);

int rename(const char *old, const char *new);
int remove(const char *pathname);

int printf(const char *format, ...);
int fprintf(FILE *stream, const char *format, ...);
int vfprintf(FILE *stream, const char *format, va_list ap);



/* vim: set ts=4 sw=4 tw=0 noet :*/