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