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