From c2011c5def9154c9a48f5e7e17d48d840aad675d Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Thu, 29 Apr 2004 19:42:16 +0000 Subject: Start --- src/mystdlib.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/mystdlib.h (limited to 'src/mystdlib.h') diff --git a/src/mystdlib.h b/src/mystdlib.h new file mode 100644 index 0000000..2e9499f --- /dev/null +++ b/src/mystdlib.h @@ -0,0 +1,32 @@ +#include +#include + +typedef struct { int fh; unsigned char *addr; size_t size; } *MAP; + +/* Mapps a file into memory + returns pointer to the mapping struct, + containing the file's size, the mapped + address and its file handle. + + If readonly is true, the file will be + opened and mapped read only. File is + opened and mapped writable, if false. + + Returns NULL if memory could not be + allocated, file could not be opened or + mapped. Gives out an diagnostic message + on stderr +*/ +MAP map_file( char *filename, int readonly ); + +/* Unmapps a file from memory. NULL pointer + checks are being done, so this is safe + to be called from cleanup without knowing + whether there actually is a map. +*/ +void unmap_file ( MAP *pMap ); + +/* Gets file size of open file + returns != 0 in case of error */ +inline int getfilesize( int fd, unsigned long *size ); + -- cgit v1.2.3