root/trunk/internals/_PDCLIB_glue.h
| Revision 416, 2.8 kB (checked in by solar, 4 months ago) | |
|---|---|
| |
| Line | |
|---|---|
| 1 | /* $Id$ */ |
| 2 | |
| 3 | /* OS glue functions declaration <_PDCLIB_glue.h> |
| 4 | |
| 5 | This file is part of the Public Domain C Library (PDCLib). |
| 6 | Permission is granted to use, modify, and / or redistribute at will. |
| 7 | */ |
| 8 | |
| 9 | #ifndef _PDCLIB_INT_H |
| 10 | #define _PDCLIB_INT_H _PDCLIB_INT_H |
| 11 | #include <_PDCLIB_int.h> |
| 12 | #endif |
| 13 | |
| 14 | /* -------------------------------------------------------------------------- */ |
| 15 | /* OS "glue", part 2 */ |
| 16 | /* These are the functions you will have to touch, as they are where PDCLib */ |
| 17 | /* interfaces with the operating system. */ |
| 18 | /* They operate on data types partially defined by _PDCLIB_config.h. */ |
| 19 | /* -------------------------------------------------------------------------- */ |
| 20 | |
| 21 | /* stdlib.h */ |
| 22 | |
| 23 | /* A system call that terminates the calling process, returning a given status |
| 24 | to the environment. |
| 25 | */ |
| 26 | void _PDCLIB_Exit( int status ) _PDCLIB_NORETURN; |
| 27 | |
| 28 | /* A system call that adds n pages of memory to the process heap (if n is |
| 29 | positive), or releases n pages from the process heap (if n is negative). |
| 30 | Return a (void *) pointing to the *former* end-of-heap if successful, NULL |
| 31 | otherwise. |
| 32 | */ |
| 33 | void * _PDCLIB_allocpages( int n ); |
| 34 | |
| 35 | |
| 36 | /* stdio.h */ |
| 37 | |
| 38 | /* A system call that opens a file identified by name in a given mode. Return |
| 39 | a file descriptor uniquely identifying that file. |
| 40 | (The mode is the return value of the _PDCLIB_filemode() function.) |
| 41 | */ |
| 42 | _PDCLIB_fd_t _PDCLIB_open( char const * const filename, unsigned int mode ); |
| 43 | |
| 44 | /* A system call that writes a stream's buffer. |
| 45 | Returns 0 on success, EOF on write error. |
| 46 | Sets stream error flags and errno appropriately on error. |
| 47 | */ |
| 48 | int _PDCLIB_flushbuffer( struct _PDCLIB_file_t * stream ); |
| 49 | |
| 50 | /* A system call that fills a stream's buffer. |
| 51 | Returns 0 on success, EOF on read error / EOF. |
| 52 | Sets stream EOF / error flags and errno appropriately on error. |
| 53 | */ |
| 54 | int _PDCLIB_fillbuffer( struct _PDCLIB_file_t * stream ); |
| 55 | |
| 56 | /* A system call that repositions within a file. Returns new offset on success, |
| 57 | -1 / errno on error. |
| 58 | */ |
| 59 | _PDCLIB_int64_t _PDCLIB_seek( struct _PDCLIB_file_t * stream, _PDCLIB_int64_t offset, int whence ); |
| 60 | |
| 61 | /* A system call that closes a file identified by given file descriptor. Return |
| 62 | zero on success, non-zero otherwise. |
| 63 | */ |
| 64 | int _PDCLIB_close( _PDCLIB_fd_t fd ); |
| 65 | |
| 66 | /* A system call that removes a file identified by name. Return zero on success, |
| 67 | non-zero otherwise. |
| 68 | */ |
| 69 | int _PDCLIB_remove( const char * filename ); |
| 70 | |
| 71 | /* A system call that renames a file from given old name to given new name. |
| 72 | Return zero on success, non-zero otherwise. In case of failure, the file |
| 73 | must still be accessible by old name. Any handling of open files etc. is |
| 74 | done by standard rename() already. |
| 75 | */ |
| 76 | int _PDCLIB_rename( const char * old, const char * new ); |
| 77 |
Note: See TracBrowser for help on using the browser.
