mirror of
https://github.com/Tom-on64/kern.git
synced 2026-11-03 18:22:22 +00:00
Wrote a new stdio.h, Implemented fcntl.h
This commit is contained in:
+58
-15
@@ -2,8 +2,27 @@
|
||||
#define _STDIO_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
// Nobody should have to interface with the internals of this structure
|
||||
// End Of File
|
||||
#define EOF (-1)
|
||||
|
||||
// File related macros
|
||||
#define BUFSIZ 512
|
||||
#define FILENAME_MAX 255
|
||||
#define FOPEN_MAX 32
|
||||
|
||||
// Seek positions
|
||||
#define SEEK_CUR 0
|
||||
#define SEEK_END 1
|
||||
#define SEEK_SET 2
|
||||
|
||||
// Standard file pointers
|
||||
#define STDIN_FILENO 0
|
||||
#define STDOUT_FILENO 1
|
||||
#define STDERR_FILENO 2
|
||||
|
||||
/* The ultimate FILE struct */
|
||||
typedef struct _iobuf { // 24B
|
||||
unsigned char* _ptr; // File buffer base
|
||||
unsigned int _size; // Size of buffer
|
||||
@@ -14,28 +33,52 @@ typedef struct _iobuf { // 24B
|
||||
char __reserved[6];
|
||||
} FILE;
|
||||
|
||||
// Standard file pointers
|
||||
extern FILE* stdin;
|
||||
extern FILE* stdout;
|
||||
extern FILE* stderr;
|
||||
|
||||
/* File IO */
|
||||
FILE* fopen(const char* filename, const char* mode);
|
||||
/* File operations */
|
||||
FILE* fopen(const char* path, const char* mode);
|
||||
int fclose(FILE* stream);
|
||||
size_t fread(void* ptr, size_t size, size_t count, FILE* stream);
|
||||
size_t fwrite(const void* ptr, size_t size, size_t count, FILE* stream);
|
||||
int fseek(FILE* stream, long int origin, int offset);
|
||||
long int ftell(FILE* stream);
|
||||
size_t fwrite(void* ptr, size_t size, size_t count, FILE* stream);
|
||||
int fseek(FILE* stream, long offset, int whence);
|
||||
long ftell(FILE* stream);
|
||||
void rewind(FILE* stream);
|
||||
int fflush(FILE* stream);
|
||||
|
||||
/* Terminal IO */
|
||||
/* Character I/O */
|
||||
int getchar(void);
|
||||
int putchar(int c);
|
||||
int getc(FILE* stream);
|
||||
int putc(int c, FILE* stream);
|
||||
int ungetc(int c, FILE* stream);
|
||||
|
||||
/* Line I/O */
|
||||
char* fgets(char* str, int n, FILE* stream);
|
||||
int fputs(const char* str, FILE* stream);
|
||||
int puts(const char* str);
|
||||
|
||||
/* Error handling */
|
||||
void perror(const char* s);
|
||||
int feof(FILE* stream);
|
||||
int ferror(FILE* stream);
|
||||
void clearerr(FILE* stream);
|
||||
|
||||
/* Formatted I/O */
|
||||
int printf(const char* fmt, ...);
|
||||
int sprintf(char* str, const char* fmt, ...);
|
||||
int snprintf(char* str, size_t n, const char* fmt, ...);
|
||||
int vprintf(const char* fmt, va_list va);
|
||||
int fprintf(FILE* stream, const char* fmt, ...);
|
||||
void putc(char c);
|
||||
char getc();
|
||||
void print(const char* str);
|
||||
void clear();
|
||||
void reads(char* str);
|
||||
int vfprintf(FILE* stream, const char* fmt, va_list va);
|
||||
// INFO: (v)sprinf() Has been depricated and removed as it is unsafe (potencial buffer overflow). Please use (v)snprintf()
|
||||
int snprintf(char* str, size_t size, const char* fmt, ...);
|
||||
int vsnprintf(char* str, size_t size, const char* fmt, va_list va);
|
||||
|
||||
int scanf(const char* fmt, ...);
|
||||
int vscanf(const char* fmt, va_list va);
|
||||
int fscanf(FILE* stream, const char* fmt, ...);
|
||||
int vfscanf(FILE* stream, const char* fmt, va_list va);
|
||||
int sscanf(const char* str, const char* fmt, ...);
|
||||
int vsscanf(const char* str, const char* fmt, va_list va);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user