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