Committer : entrope
CVSROOT : /cvsroot/undernet-ircu
Module : ircu2.10
Commit time: 2004-10-05 01:45:34 UTC
Modified files:
include/fileio.h ircd/fileio.c
Log message:
Doxyfy fileio.h and fileio.c.
---------------------- diff included ----------------------
Index: ircu2.10/include/fileio.h
diff -u ircu2.10/include/fileio.h:1.3 ircu2.10/include/fileio.h:1.4
--- ircu2.10/include/fileio.h:1.3 Thu Jul 1 16:46:45 2004
+++ ircu2.10/include/fileio.h Mon Oct 4 18:45:24 2004
@@ -1,7 +1,6 @@
-/*
- * fileio.h
- *
- * $Id: fileio.h,v 1.3 2004/07/01 23:46:45 entrope Exp $
+/** @file fileio.h
+ * @brief ANSI FILE* clone API declarations.
+ * @version $Id: fileio.h,v 1.4 2004/10/05 01:45:24 entrope Exp $
*/
#ifndef INCLUDED_fileio_h
#define INCLUDED_fileio_h
@@ -13,8 +12,7 @@
struct stat;
-/*
- * FileBuf is a mirror of the ANSI FILE struct, but it works for any
+/** A mirror of the ANSI FILE struct, but it works for any
* file descriptor. FileBufs are allocated when a file is opened with
* fbopen, and they are freed when the file is closed using fbclose.
* (Some OSes limit the range of file descriptors in a FILE*, for
@@ -36,7 +34,7 @@
* close a file opened with fbopen, see fclose(3)
*/
extern void fbclose(FBFILE * fb);
-/*
+/*
* return the next character from the file, EOF on end of file
* see fgetc(3)
*/
Index: ircu2.10/ircd/fileio.c
diff -u ircu2.10/ircd/fileio.c:1.4 ircu2.10/ircd/fileio.c:1.5
--- ircu2.10/ircd/fileio.c:1.4 Sat Apr 21 14:49:12 2001
+++ ircu2.10/ircd/fileio.c Mon Oct 4 18:45:24 2004
@@ -18,6 +18,10 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+/** @file
+ * @brief ANSI FILE* clone API implementation.
+ * @version $Id: fileio.c,v 1.5 2004/10/05 01:45:24 entrope Exp $
+ */
#include "config.h"
#include "fileio.h"
@@ -30,17 +34,23 @@
#include <unistd.h> /* read, write, open, close */
#include <string.h>
-#define FB_EOF 0x01
-#define FB_FAIL 0x02
+#define FB_EOF 0x01 /**< File has reached EOF. */
+#define FB_FAIL 0x02 /**< File operation failed. */
+/** Tracks status and buffer for a file on disk. */
struct FileBuf {
- int fd; /* file descriptor */
- char *endp; /* one past the end */
- char *ptr; /* current read pos */
- int flags; /* file state */
- char buf[BUFSIZ]; /* buffer */
+ int fd; /**< file descriptor */
+ char *endp; /**< one past the end */
+ char *ptr; /**< current read pos */
+ int flags; /**< file state */
+ char buf[BUFSIZ]; /**< buffer */
};
+/** Open a new FBFILE.
+ * @param[in] filename Name of file to open.
+ * @param[in] mode fopen()-style mode string.
+ * @return Pointer to newly allocated FBFILE.
+ */
FBFILE* fbopen(const char *filename, const char *mode)
{
int openmode = 0;
@@ -88,6 +98,10 @@
return fb;
}
+/** Open a FBFILE from a file descriptor.
+ * @param[in] fd File descriptor to use.
+ * @param[in] mode fopen()-style mode string (ignored).
+ */
FBFILE* fdbopen(int fd, const char *mode)
{
/*
@@ -103,6 +117,9 @@
return fb;
}
+/** Close a FBFILE.
+ * @param[in] fb File buffer to close.
+ */
void fbclose(FBFILE* fb)
{
assert(fb);
@@ -110,6 +127,10 @@
MyFree(fb);
}
+/** Attempt to fill a file's buffer.
+ * @param[in] fb File to operate on.
+ * @return Number of bytes read into buffer, or a negative number on error.
+ */
static int fbfill(FBFILE * fb)
{
int n;
@@ -129,6 +150,10 @@
return n;
}
+/** Get a single character from a file.
+ * @param[in] fb File to fetch from.
+ * @return Character value read, or EOF on error or end-of-file.
+ */
int fbgetc(FBFILE * fb)
{
assert(fb);
@@ -137,6 +162,12 @@
return EOF;
}
+/** Get a line of input from a file.
+ * @param[out] buf Output buffer to read to.
+ * @param[in] len Maximum number of bytes to write to buffer
+ * (including terminating NUL).
+ * @param[in] fb File to read from.
+ */
char *fbgets(char *buf, size_t len, FBFILE * fb)
{
char *p = buf;
@@ -173,6 +204,11 @@
return buf;
}
+/** Write a string to a file.
+ * @param[in] str String to write to file.
+ * @param[in] fb File to write to.
+ * @return Number of bytes written, or -1 on error.
+ */
int fbputs(const char *str, FBFILE * fb)
{
int n = -1;
@@ -187,6 +223,11 @@
return n;
}
+/** Get file status.
+ * @param[out] sb Receives file status.
+ * @param[in] fb File to get status for.
+ * @return Zero on success, -1 on error.
+ */
int fbstat(struct stat *sb, FBFILE * fb)
{
assert(sb);
----------------------- End of diff -----------------------