]> pd.if.org Git - pdclib/blob - internals/_PDCLIB_glue.h
Intermediate work, checked in for safekeeping as I pick up working on this again.
[pdclib] / internals / _PDCLIB_glue.h
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 /* Some operate on data types defined by _PDCLIB_config.h.                    */
19 /* -------------------------------------------------------------------------- */
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 /* A system call that opens a file identified by name in a given mode. Return 
34    a file descriptor uniquely identifying that file.
35    (The mode is the return value of the _PDCLIB_filemode() function.)
36 */
37 _PDCLIB_fd_t _PDCLIB_open( char const * const filename, unsigned int mode );
38
39 /* A system call that writes up to n characters to a file identified by given
40    file descriptor. Return the number of characters actually written, or -1
41    if an error occured. Note that the number of characters may well be lower
42    than n without an error having occured.
43 */
44 int _PDCLIB_write( struct _PDCLIB_file_t * stream, char const * buffer, int n );
45
46 /* A system call that reads n characters into a buffer, from a file identified
47    by given file descriptor. Return the number of characters read.
48 */
49 _PDCLIB_size_t _PDCLIB_read( _PDCLIB_fd_t fd, char * buffer, _PDCLIB_size_t n );
50
51 /* A system call that closes a file identified by given file descriptor. Return
52    zero on success, non-zero otherwise.
53 */
54 int _PDCLIB_close( _PDCLIB_fd_t fd );
55
56 /* A system call that removes a file identified by name. Return zero on success,
57    non-zero otherwise.
58 */
59 int _PDCLIB_remove( const char * filename );
60
61 /* A system call that renames a file from given old name to given new name.
62    Return zero on success, non-zero otherwise. In case of failure, the file
63    must still be accessible by old name.
64 */
65 int _PDCLIB_rename( const char * old, const char * new );
66
67 /* A system call that returns one if the given file descriptor refers to an
68    interactive device, and zero otherwise.
69  */
70 int _PDCLIB_interactive_stream( _PDCLIB_fd_t fd );
71