Author: Isomer <Isomer@undernet.org>
[ircu2.10.12-pk.git] / include / fileio.h
1 /*
2  * fileio.h
3  *
4  * $Id$
5  */
6 #ifndef INCLUDED_fileio_h
7 #define INCLUDED_fileio_h
8
9 #ifndef INCLUDED_sys_types_h
10 #include <sys/types.h>          /* size_t */
11 #define INCLUDED_sys_types_h
12 #endif
13
14 struct stat;
15
16 /*
17  * FileBuf is a mirror of the ANSI FILE struct, but it works for any
18  * file descriptor. FileBufs are allocated when a file is opened with
19  * fbopen, and they are freed when the file is closed using fbclose.
20  * (Some OSes limit the range of file descriptors in a FILE*, for
21  * example to fit in "char".)
22  */
23 typedef struct FileBuf FBFILE;
24
25 /*
26  * open a file and return a FBFILE*, see fopen(3)
27  */
28 extern FBFILE *fbopen(const char *filename, const char *mode);
29 /*
30  * associate a file descriptor with a FBFILE*
31  * if a FBFILE* is associated here it MUST be closed using fbclose
32  * see fdopen(3)
33  */
34 extern FBFILE *fdbopen(int fd, const char *mode);
35 /*
36  * close a file opened with fbopen, see fclose(3)
37  */
38 extern void fbclose(FBFILE * fb);
39 /* 
40  * return the next character from the file, EOF on end of file
41  * see fgetc(3)
42  */
43 extern int fbgetc(FBFILE * fb);
44 /*
45  * return next string in a file up to and including the newline character
46  * see fgets(3)
47  */
48 extern char *fbgets(char *buf, size_t len, FBFILE * fb);
49 /*
50  * write a null terminated string to a file, see fputs(3)
51  */
52 extern int fbputs(const char *str, FBFILE * fb);
53 /*
54  * return the status of the file associated with fb, see fstat(3)
55  */
56 extern int fbstat(struct stat *sb, FBFILE * fb);
57
58 #endif /* INCLUDED_fileio_h */