qio - quick I/O part of InterNetNews library


SYNOPSIS

       #include "qio.h"

       QIOSTATE *
       QIOopen(name)
           char             *name;

       QIOSTATE *
       QIOfdopen(fd)
           int              fd;

       void
       QIOclose(qp)
           QIOSTATE         *qp;

       char *
       QIOread(qp)
           QIOSTATE         *qp;

       int
       QIOlength(qp)
           QIOSTATE         *qp;

       int
       QIOtoolong(qp)
           QIOSTATE         *qp;

       int
       QIOerror(qp)
           QIOSTATE         *qp;

       int
       QIOtell(qp)
           QIOSTATE         *qp;

       int
       QIOrewind(qp)
           QIOSTATE         *qp;

       int
       QIOfileno(qp)
           QIOSTATE         *qp;


DESCRIPTION

       The  routines  described  in  this manual page are part of
       libinn(3).  They are used to provide quick read access  to
       files.   All  routines  are  not available for token.  The
       letters ``QIO'' stand for Quick I/O.

       QIOopen opens the file name for reading.  If <HAVE_ST_BLK­
       SIZE  in  include/config.h>  is defined, QIOopen will call

       <HAVE_ST_BLKSIZE  in  include/config.h> is not defined) it
       will use QIO_BUFFER.  It  returns  NULL  on  error,  or  a
       pointer  to a handle to be used in other calls.  QIOfdopen
       performs the same function except that  fd  refers  to  an
       already-open descriptor.

       QIOclose  closes  the open file and releases any resources
       used by it.

       QIOread returns a pointer to the next line  in  the  file.
       The  trailing  newline will be replaced with a \0.  If EOF
       is reached, an error occurs, or if the line is longer than
       the buffer, QIOread returns NULL.

       After  a successful call to QIOread, QIOlength will return
       the length of the current line.

       The functions QIOtoolong and QIOerror can be called  after
       QIOread  returns  NULL to determine if there was an error,
       or if the line was too long.  If QIOtoolong  returns  non-
       zero, then the current line did not fit in the buffer, and
       the next call to QIOread will try read  the  rest  of  the
       line.   Long  lines  can  only  be discarded.  If QIOerror
       returns non-zero, then a serious I/O error occurred.

       QIOtell returns the lseek(2) offset at which the next line
       will start.

       QIOrewind  sets  the read pointer back to the beginning of
       the file.

       QIOfileno returns the descriptor of the open file.

       QIOlength, QIOtoolong, QIOerror,  QIOtell,  and  QIOfileno
       are implemented as macro's defined in the header file.


EXAMPLE

              QIOSTATE             *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\n", offset, p);
              if (QIOerror(h)) {
                  perror("Read error");
                  exit(1);
              }
              QIOclose(h);


HISTORY

       Written  by  Rich  $alz <rsalz@uunet.uu.net> for InterNet­
       News.  This is revision 1.6.2.1, dated 2000/08/17.


Man(1) output converted with man2html