1: #include "../h/rt.h"
   2: 
   3: /*
   4:  * close(f) - close file f.
   5:  */
   6: 
   7: Xclose(nargs, arg1, arg0)
   8: int nargs;
   9: struct descrip arg1, arg0;
  10:    {
  11:    register int i;
  12: 
  13:    /*
  14:     * f must be a file.
  15:     */
  16:    DeRef(arg1)
  17:    if (QUAL(arg1) || TYPE(arg1) != T_FILE)
  18:       runerr(105, &arg1);
  19: 
  20:    /*
  21:     * If f has a buffer associated with it, "free" it.
  22:     */
  23:    for (i = 0; i < numbufs; i++) {
  24:       if (bufused[i] == BLKLOC(arg1)->file.fd) {
  25:          bufused[i] = NULL;
  26:          break;
  27:          }
  28:       }
  29: 
  30:    /*
  31:     * Close f, using fclose or pclose as appropriate.
  32:     */
  33:    if (BLKLOC(arg1)->file.status & FS_PIPE)
  34:       pclose(BLKLOC(arg1)->file.fd);
  35:    else
  36:       fclose(BLKLOC(arg1)->file.fd);
  37:    BLKLOC(arg1)->file.status = 0;
  38: 
  39:    /*
  40:     * Return the closed file.
  41:     */
  42:    arg0 = arg1;
  43:    }
  44: 
  45: Procblock(close,1)

Defined functions

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