©2004 by Marc J. Rochkind. All rights reserved. Portions marked "Open Source" may be copied under license.

 

Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

c2/bufio.h

Go to the documentation of this file.
00001 /*
00002     Functions for User Buffering
00003     AUP2, Sec. 2.12.2
00004 
00005     Copyright 2003 by Marc J. Rochkind. All rights reserved.
00006     May be copied only for purposes and under conditions described
00007     on the Web page www.basepath.com/aup/copyright.htm.
00008 
00009     The Example Files are provided "as is," without any warranty;
00010     without even the implied warranty of merchantability or fitness
00011     for a particular purpose. The author and his publisher are not
00012     responsible for any damages, direct or incidental, resulting
00013     from the use or non-use of these Example Files.
00014 
00015     The Example Files may contain defects, and some contain deliberate
00016     coding mistakes that were included for educational reasons.
00017     You are responsible for determining if and how the Example Files
00018     are to be used.
00019 */
00020 #ifndef _BUFIO_H_
00021 #define _BUFIO_H_
00022 
00023 /*[bufio-h]*/
00024 typedef struct {
00025     int fd;                     /* file descriptor */
00026     char dir;                   /* direction: r or w */
00027     ssize_t total;              /* total chars in buf */
00028     ssize_t next;               /* next char in buf */
00029     unsigned char buf[BUFSIZ];  /* buffer */
00030     bool fdopen;                /* opened with Bfdopen? [not in book] */
00031     /* Following members not in book. */
00032     struct timeval timeout;     /* optional timeout (causes select to be used) */
00033 } BUFIO;
00034 /*[]*/
00035 
00036 BUFIO *Bopen(const char *path, const char *dir);
00037 BUFIO *Bfdopen(int fd, const char *dir);
00038 int Bgetc(BUFIO *b);
00039 bool Bputc(BUFIO *b, int c);
00040 bool Bclose(BUFIO *b);
00041 
00042 /*
00043     Rest of functions not in book.
00044 */
00045 bool Bgets(BUFIO *b, char *s, size_t smax);
00046 void Bsettimeout(BUFIO *b, struct timeval *timeout);
00047 #endif /* _BUFIO_H_ */

Generated on Fri Apr 23 10:56:54 2004 for AUP2 Example Source by doxygen 1.3.1