summaryrefslogtreecommitdiff
path: root/src/libc/include/stdio.h
blob: b582e8f48546a9fbb86f06a80832bb9670239175 (plain)
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
#pragma once

#include <bits/file.h>
#include <stdarg.h>
#include <stddef.h>
#include <sys/types.h>

#define EOF (-1)
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2

#define SEEK_SET 1
#define SEEK_CUR 2
#define SEEK_END 3

#define _IONBF 0
#define _IOFBF 1
#define _IOLBF 2

#define BUFSIZ 4096

/* stop fread() from trying to fill the entire buffer before returning
 * i.e. it will call _sys_read() exactly once */
#define FEXT_NOFILL 1

int printf(const char *restrict fmt, ...);
int fprintf(FILE *restrict f, const char *restrict fmt, ...);

int sprintf(char *restrict s, const char *restrict fmt, ...);
int snprintf(char *restrict str, size_t len, const char *restrict fmt, ...);

int vprintf(const char *restrict fmt, va_list ap);
int vsprintf(char *restrict s, const char *restrict fmt, va_list ap);
int vfprintf(FILE *restrict f, const char *restrict fmt, va_list ap);

int _klogf(const char *fmt, ...); // for kernel debugging only


extern FILE *const stdin, *const stdout, *const stderr;

FILE *fopen(const char *path, const char *mode);
FILE *freopen(const char *path, const char *mode, FILE *);
FILE *fdopen(int fd, const char *mode);
FILE *file_clone(const FILE *, const char *mode);
int fileno(FILE *f);
FILE *popen(const char *cmd, const char *mode);
int pclose(FILE *f);
FILE *tmpfile(void);

int fextflags(FILE *, int extflags);
int setvbuf(FILE *restrict f, char *restrict buf, int type, size_t size);
int fclose(FILE *);
int fflush(FILE *f);

size_t fread(void *restrict ptr, size_t size, size_t nitems, FILE *restrict);
size_t fwrite(const void *restrict ptr, size_t size, size_t nitems, FILE *restrict);
int fputs(const char *s, FILE *f);
char *fgets(char *buf, int size, FILE *f);
int fgetc(FILE *f);
int getc(FILE *f);
int fputc(int c, FILE *f);
int putc(int c, FILE *f);
int ungetc(int c, FILE *f);

int fseek(FILE *f, long offset, int whence);
void rewind(FILE *f);
int fseeko(FILE *f, off_t offset, int whence);
long ftell(FILE *f);
off_t ftello(FILE *f);

int feof(FILE *);
int ferror(FILE *);
void clearerr(FILE *f);

void perror(const char *s);
int puts(const char *s);
int getchar(void);
int putchar(int c);

off_t lseek(int fd, off_t off, int whence);

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

#define L_tmpnam (5 + 16 + 1)
char *tmpnam(char *s);

int sscanf(const char *restrict s, const char *restrict format, ...);
int vsscanf(const char* str, const char* format, va_list ap);
int fscanf(FILE* fp, const char* format, ...);
int vfscanf(FILE* fp, const char* format, va_list ap);
int vcbscanf(void* fp, int (*fgetc)(void*), int (*ungetc)(int, void*), const char* restrict format, va_list ap);