]> pd.if.org Git - pdclib/blob - internals/_PDCLIB_glue.h
Porting current working set from CVS.
[pdclib] / internals / _PDCLIB_glue.h
1 /* $Id$ */
2
3 /* Release $Name$ */
4
5 /* OS glue functions declaration <_PDCLIB_glue.h>
6
7    This file is part of the Public Domain C Library (PDCLib).
8    Permission is granted to use, modify, and / or redistribute at will.
9 */
10
11 #ifndef _PDCLIB_INT_H
12 #define _PDCLIB_INT_H _PDCLIB_INT_H
13 #include <_PDCLIB_int.h>
14 #endif
15
16 /* -------------------------------------------------------------------------- */
17 /* OS "glue", part 2                                                          */
18 /* These are the functions you will have to touch, as they are where PDCLib   */
19 /* interfaces with the operating system.                                      */
20 /* They operate on data types partially defined by _PDCLIB_config.h.          */
21 /* -------------------------------------------------------------------------- */
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 /* A system call that opens a file identified by name in a given mode, and
36    returns a file descriptor uniquely identifying that file.
37 */
38 _PDCLIB_fd_t _PDCLIB_open( char const * const filename, int mode );
39
40 /* A system call that writes n characters to a file identified by given file
41    descriptor. Return the number of characters written.
42 */
43 _PDCLIB_size_t _PDCLIB_write( _PDCLIB_fd_t fd, char const * buffer, _PDCLIB_size_t n );
44
45 /* A system call that reads n characters into a buffer, from a file identified
46    by given file descriptor. Return the number of characters read.
47 */
48 _PDCLIB_size_t _PDCLIB_read( _PDCLIB_fd_t fd, char * buffer, _PDCLIB_size_t n );
49
50 /* A system call that closes a file identified by given file descriptor. */
51 void _PDCLIB_close( _PDCLIB_fd_t fd );
52
53 /* A system call that removes a file identified by name. Return zero on success,
54    non-zero otherwise.
55 */
56 int _PDCLIB_remove( const char * filename );
57
58 /* A system call that renames a file from given old name to given new name.
59    Return zero on success, non-zero otherwise. In case of failure, the file
60    must still be accessible by old name.
61 */
62 int _PDCLIB_rename( const char * old, const char * new );