diff options
| author | erdgeist <> | 2007-04-19 19:54:07 +0000 |
|---|---|---|
| committer | erdgeist <> | 2007-04-19 19:54:07 +0000 |
| commit | cf193c66d988637d9ddfb0acee82608a04f96402 (patch) | |
| tree | 05d007e28ce0526ff150e67eecba782ea57e832d /mystdlib.h | |
Kickoff
Diffstat (limited to 'mystdlib.h')
| -rw-r--r-- | mystdlib.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/mystdlib.h b/mystdlib.h new file mode 100644 index 0000000..2e9499f --- /dev/null +++ b/mystdlib.h | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | #include <sys/types.h> | ||
| 2 | #include <stdio.h> | ||
| 3 | |||
| 4 | typedef struct { int fh; unsigned char *addr; size_t size; } *MAP; | ||
| 5 | |||
| 6 | /* Mapps a file into memory | ||
| 7 | returns pointer to the mapping struct, | ||
| 8 | containing the file's size, the mapped | ||
| 9 | address and its file handle. | ||
| 10 | |||
| 11 | If readonly is true, the file will be | ||
| 12 | opened and mapped read only. File is | ||
| 13 | opened and mapped writable, if false. | ||
| 14 | |||
| 15 | Returns NULL if memory could not be | ||
| 16 | allocated, file could not be opened or | ||
| 17 | mapped. Gives out an diagnostic message | ||
| 18 | on stderr | ||
| 19 | */ | ||
| 20 | MAP map_file( char *filename, int readonly ); | ||
| 21 | |||
| 22 | /* Unmapps a file from memory. NULL pointer | ||
| 23 | checks are being done, so this is safe | ||
| 24 | to be called from cleanup without knowing | ||
| 25 | whether there actually is a map. | ||
| 26 | */ | ||
| 27 | void unmap_file ( MAP *pMap ); | ||
| 28 | |||
| 29 | /* Gets file size of open file | ||
| 30 | returns != 0 in case of error */ | ||
| 31 | inline int getfilesize( int fd, unsigned long *size ); | ||
| 32 | |||
