1: #include "../h/rt.h"
   2: 
   3: /*
   4:  * read(f) - read line on file f.
   5:  */
   6: Xread(nargs, arg1, arg0)
   7: int nargs;
   8: struct descrip arg1, arg0;
   9:    {
  10:    register int slen;
  11:    int status;
  12:    char sbuf[MAXREADSTRING];
  13:    FILE *f;
  14:    extern char *alcstr();
  15: 
  16:    /*
  17:     * Default f to &input.
  18:     */
  19:    deffile(&arg1, &input);
  20:    /*
  21:     * Get a pointer to the file and be sure that it's open for reading.
  22:     */
  23:    f = BLKLOC(arg1)->file.fd;
  24:    status = BLKLOC(arg1)->file.status;
  25:    if ((status & FS_READ) == 0)
  26:       runerr(212, &arg1);
  27: 
  28:    /*
  29:     * Use getstr to read a line from the file, failing if getstr
  30:     *  encounters end of file.
  31:     */
  32:    if ((slen = getstr(sbuf,MAXREADSTRING,f)) < 0)
  33:       fail();
  34:    /*
  35:     * Allocate the string read and make arg0 a descriptor for it.
  36:     */
  37:    sneed(slen);
  38:    STRLEN(arg0) = slen;
  39:    STRLOC(arg0) = alcstr(sbuf,slen);
  40:    }
  41: 
  42: Procblock(read,1)

Defined functions

Xread defined in line 6; never used
Last modified: 1984-11-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 583
Valid CSS Valid XHTML 1.0 Strict