qio.3

来自「早期freebsd实现」· 3 代码 · 共 161 行

3
161 行
字号
.\" $Revision: 1.7 $.TH QIO 3.SH NAMEqio \- quick I/O part of InterNetNews library.SH SYNOPSIS.nf.ta \w'    unsigned long    'u.B#include "qio.h".B "QIOSTATE *".B "QIOopen(name, size)".B "    char	*name;".B "    int	size;".B "QIOSTATE *".B "QIOfdopen(fd, size)".B "    int	fd;".B "    int	size;".B "void".B "QIOclose(qp)".B "    QIOSTATE	*qp;".B "char *".B "QIOread(qp)".B "    QIOSTATE	*qp;".B "int".B "QIOlength(qp)".B "    QIOSTATE	*qp;".B "int".B "QIOtoolong(qp)".B "    QIOSTATE	*qp;".B "int".B "QIOerror(qp)".B "    QIOSTATE	*qp;".B "int".B "QIOtell(qp)".B "    QIOSTATE	*qp;".B "int".B "QIOrewind(qp)".B "    QIOSTATE	*qp;".B "int".B "QIOfileno(qp)".B "    QIOSTATE	*qp;".SH DESCRIPTIONThe routines described in this manual page are part of the InterNetNewslibrary,.IR libinn (3).They are used to provide quick read access to files.The letters ``QIO'' stand for.IR Q uick.IR I/O ..PP.I QIOopenopens the file.I namefor reading.It uses a buffer of.I sizebytes, which must also be larger then the longest expected line.The header file defines the constant QIO_BUFFER as a reasonable default.If.I sizeis zero, then.\" =()<.if '@<HAVE_ST_BLKSIZE>@'DO' \{\>()=.if 'DO'DO' \{\.I QIOopenwill call.IR stat (2)and use the returned block size; if that fails\}it will use QIO_BUFFER.It returns NULL on error, or a pointer to a handle to be used in other calls..I QIOfdopenperforms the same function except that.I fdrefers to an already-open descriptor..PP.I QIOclosecloses the open file and releases any resources used by it..PP.I QIOreadreturns a pointer to the next line in the file.The trailing newline will be replaced with a \e0.If EOF is reached, an error occurs, or if the line is longer than thebuffer,.I QIOreadreturns NULL..PPAfter a successful call to.IR QIOread ,.I QIOlengthwill return the length of the current line..PPThe functions.I QIOtoolongand.I QIOerrorcan be called after.I QIOreadreturns NULL to determine if there was an error, or if the line wastoo long.If.I QIOtoolongreturns non-zero, then the current line did not fit in the buffer, and thenext call to.I QIOreadwill try read the rest of the line.Long lines can only be discarded.If.I QIOerrorreturns non-zero, then a serious I/O error occurred..PP.I QIOtellreturns the.IR lseek (2)offset at which the next line will start..PP.I QIOrewindsets the read pointer back to the beginning of the file..PP.I QIOfilenoreturns the descriptor of the open file..PP.IR QIOlength ,.IR QIOtoolong ,.IR QIOerror ,.IR QIOtell ,and.I QIOfilenoare implemented as macro's defined in the header file..SH EXAMPLE.RS.nfQIOSTATE	*h;long	offset;char	*p;h = QIOopen("/etc/motd", QIO_BUFFER);for (offset = QIOtell(h); (p = QIOread(h)) != NULL; offset = QIOtell(h))    printf("At %ld, %s\en", offset, p);if (QIOerror(h)) {    perror("Read error");    exit(1);}QIOclose(h);.fi.RE.SH HISTORYWritten by Rich $alz <rsalz@uunet.uu.net> for InterNetNews..de R$This is revision \\$3, dated \\$4....R$ $Id: qio.3,v 1.7 1993/01/29 16:43:14 rsalz Exp $

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?