ciabatta/inc/_os.h

41 lines
905 B
C
Raw Normal View History

#pragma once
2022-06-14 22:46:14 +00:00
#include <stddef.h>
#if defined(_WIN32)
#define _os_win
#endif
#if defined(__linux__) && !defined(__ANDROID__)
#define _os_linux
#endif
#if !(defined(_os_win) \
|| defined(_os_linux))
#error "Unsupported OS"
#endif
2022-06-07 02:57:57 +00:00
// OS-dependent IO Functions
2022-06-08 03:31:06 +00:00
// TODO: see if we need this or will it be easier for linux to just pass
// the mode string.
typedef struct _OS_ModeFlags {
int base_mode;
int binary;
int update;
int exclusive;
} _OS_ModeFlags;
2022-06-07 02:57:57 +00:00
typedef struct FILE FILE;
2022-06-08 03:31:06 +00:00
int _os_del_file(char const *filename);
int _os_mov_file(char const *old, char const *new);
char *_os_tmpname(char *buffer);
FILE *_os_fopen(char const *restrict name, _OS_ModeFlags flags);
int _os_fclose(FILE *file);
void _os_file_write(void* ctx, size_t n, const char str[]);
2022-06-16 05:15:45 +00:00
void _os_file_write_char(void* ctx, char ch);
2022-06-08 03:31:06 +00:00
void _os_init_eh();
_Noreturn void _os_exit(int code);