io.h

Go to the documentation of this file.
00001 // Copyright 2006 Benedikt Böhm <hollow@gentoo.org>
00002 //
00003 // This program is free software; you can redistribute it and/or modify
00004 // it under the terms of the GNU General Public License as published by
00005 // the Free Software Foundation; either version 2 of the License, or
00006 // (at your option) any later version.
00007 //
00008 // This program is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 // GNU General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the
00015 // Free Software Foundation, Inc.,
00016 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 
00018 /*!
00019  * @defgroup io Input/Output wrappers
00020  *
00021  * The io family of functions provide convenient wrappers around read(2).
00022  *
00023  * The io_read_eol() function reads bytes until the end of the line, that is 
00024  * until one of the characters \\r or \\n is found, and stores them in the
00025  * string pointed to by line.
00026  *
00027  * The io_read_eof() function reads bytes until the end of the file is reached
00028  * and stores them in the string pointed to by file.
00029  *
00030  * The io_read_len() function reads an exact number of bytes from the file and
00031  * stores them in the string pointed to by str.
00032  *
00033  * @{
00034  */
00035 
00036 #ifndef _LUCID_IO_H
00037 #define _LUCID_IO_H
00038 
00039 /*! bytes read at a time */
00040 #define CHUNKSIZE 128
00041 
00042 /*!
00043  * @brief read a line of input
00044  *
00045  * @param[in]  fd   file descriptor to read from
00046  * @param[out] line pointer to a string
00047  *
00048  * @return bytes on success, -1 on error with errno set
00049  *
00050  * @note The caller should free obtained memory for line using free(3)
00051  *
00052  * @see malloc(3)
00053  * @see free(3)
00054  * @see read(2)
00055  */
00056 int io_read_eol(int fd, char **line);
00057 
00058 /*!
00059  * @brief read until end of file
00060  *
00061  * @param[in]  fd   file descriptor to read from
00062  * @param[out] file pointer to a string
00063  *
00064  * @return bytes on success, -1 on error with errno set
00065  *
00066  * @note The caller should free obtained memory for file using free(3)
00067  *
00068  * @see malloc(3)
00069  * @see free(3)
00070  * @see read(2)
00071  */
00072 int io_read_eof(int fd, char **file);
00073 
00074 /*!
00075  * @brief read exact number of bytes
00076  *
00077  * @param[in]  fd  file descriptor to read from
00078  * @param[out] str pointer to a string
00079  * @param[in]  len bytes to be read
00080  *
00081  * @return bytes read on success, -1 on error with errno set
00082  *
00083  * @note The caller should free obtained memory for str using free(3)
00084  *
00085  * @see malloc(3)
00086  * @see free(3)
00087  * @see read(2)
00088  */
00089 int io_read_len(int fd, char **str, size_t len);
00090 
00091 #endif
00092 
00093 /*! @} io */

Generated on Sun Dec 3 17:45:53 2006 for lucid by  doxygen 1.5.1