]> pd.if.org Git - pdclib.old/blob - internals/_PDCLIB_glue.h
flushbuffer: make EOL conversion code more robust against I/O errors
[pdclib.old] / internals / _PDCLIB_glue.h
1 #ifndef __PDCLIB_GLUE_H
2 #define __PDCLIB_GLUE_H __PDCLIB_GLUE_H
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 #include <_PDCLIB_int.h>
10 #include <_PDCLIB_io.h>
11 #include <stdbool.h>
12 #include <stddef.h>
13 _PDCLIB_BEGIN_EXTERN_C
14
15 /* -------------------------------------------------------------------------- */
16 /* OS "glue", part 2                                                          */
17 /* These are the functions you will have to touch, as they are where PDCLib   */
18 /* interfaces with the operating system.                                      */
19 /* They operate on data types partially defined by _PDCLIB_config.h.          */
20 /* -------------------------------------------------------------------------- */
21
22 /* stdlib.h */
23
24 /* A system call that terminates the calling process, returning a given status
25    to the environment.
26 */
27 _PDCLIB_noreturn void _PDCLIB_Exit( int status );
28
29 /* A system call which allocates n pages of memory and returns a pointer to 
30    them. On failure, returns NULL
31 */
32 void * _PDCLIB_allocpages( size_t n );
33
34 /* A system call which frees the n pages of memory pointed to by p */
35 void _PDCLIB_freepages( void * p, size_t n );
36
37 #ifdef _PDCLIB_HAVE_REALLOCPAGES
38 /* A system call which attempts to reallocate the group of \p on pages starting
39    at \p p, resizing the chunk to be \p nn pages long. If \p mayMove is true, 
40    then then the group of pages may move; otherwise, if the group cannot be 
41    resized in its current position, failure must be reported.
42
43    On failure, returns NULL; on success, returns the address of the group of 
44    pages (if mayMove == false, then this must be equal to \p p)
45 */
46 void * _PDCLIB_reallocpages( void* p, size_t on, size_t nn, bool mayMove);
47 #endif
48
49 /* stdio.h */
50
51 /* Open the file with the given name and mode. Return the file descriptor in 
52  * *fd and a pointer to the operations structure in **ops on success.
53  *
54  * Return true on success and false on failure.
55  */
56 bool _PDCLIB_open( 
57    _PDCLIB_fd_t* fd, const _PDCLIB_fileops_t** ops,
58    char const * filename, unsigned int mode );
59
60 /* A system call that removes a file identified by name. Return zero on success,
61    non-zero otherwise.
62 */
63 int _PDCLIB_remove( const char * filename );
64
65 /* A system call that renames a file from given old name to given new name.
66    Return zero on success, non-zero otherwise. In case of failure, the file
67    must still be accessible by old name. Any handling of open files etc. is
68    done by standard rename() already.
69 */
70 int _PDCLIB_rename( const char * old, const char * newn);
71
72 _PDCLIB_END_EXTERN_C
73 #endif