CringeDB/System Abstraction/cdb_sustem.h
2022-08-30 13:22:09 +02:00

46 lines
2.2 KiB
C

//TODO finland up
//#include <stddef.h>
// TODO should propably be placed in a global header
#define sus_Bool char
#define sus_True 1
#define sus_False 0
#define SUS_FILE_TEMP ((1UL << 0) | SUS_FILE_NEW) //A temporary file gets automatically deleted, once it is no longer needed; a temp file also has to be a new file
#define SUS_FILE_NEW (1UL << 1)
#define SUS_FILE_NOTHING 0UL
//Naming: firstly the package, then the topic, lastly the operation
#include <stddef.h>
//Operating System independent implementation
typedef struct sus_File_impl * sus_File;
// File IO API
//sus_File sus_file_OpenInMem(char * fileName, unsigned long parameter);
sus_File sus_fileOpenInMem(char * fileName, unsigned long parameter); // Map a file into the memroy of the current process
//void * sus_fileOpenNewinMem(char * fileName); //prevent user errors
//void * sus_fileOpenTempFileinMem(char * fileName);
void * sus_fileFileToMemroy(sus_File file); //retrieves the memroy Pointer of where the file was mapped in memroy
sus_Bool sus_fileExists(char * fileName); //check if a file exists in the specified path with the specified name
void sus_fileClose(sus_File file); //Closes the file mapping and all the system specific stuff for that mapping
void sus_fileFlush(sus_File file); //Flushes the filemapping; synchronize the written data in the filemapping to the actual file on disk (without blocking for better performance)
void * sus_fileResize(sus_File file, signed long appendBytes); //if appendBytes is negative, the file shrinks. This prevents me from definining a new function for retreving the file Size
void sus_fileDelete(char * fileName);
void sus_fileRename(char * fileName, char * newFileName);
// Memory API
void * sus_heapAlloc(size_t bytes); // returns NULL, if there is no memroy left or an error occured
void * sus_heapResize(void * memroy, size_t newBytes); // returns NULL, if there is no memroy left or an error occured
void sus_heapFree(void * memroy); // what should this function do, if an error occurse..
// Networking API -- coming soon, cuz idk
//Threads
typedef __attribute__ ((sysv_abi)) int (*sus_threadProc)(void * arg);
sus_Bool sus_threadNew(sus_threadProc proc, void * arg);
void sus_threadSleep(unsigned long seconds);