1: # include   "monitor.h"
   2: # include   <trace.h>
   3: # include   <resp.h>
   4: # include   <sccs.h>
   5: 
   6: SCCSID(@(#)trapquery.c	8.1	12/31/84)
   7: 
   8: 
   9: 
  10: 
  11: /*
  12: **  TRAPQUERY -- trap queries which succeeded.
  13: **
  14: **	This module traps the current query into the file
  15: **	specified by Trapfile.  It will open Trapfile if
  16: **	it is not already open.
  17: **
  18: **	Parameters:
  19: **		retcode -- the return code of the query.
  20: **		name -- the name of the file in which to dump the
  21: **			query buffer.
  22: **
  23: **	Returns:
  24: **		none.
  25: **
  26: **	Side Effects:
  27: **		Outputs the query buffer to Trapfile.
  28: **
  29: **	Called By:
  30: **		go.
  31: **
  32: **	Files:
  33: **		Trapfile -- the descriptor of the file in which to
  34: **			trap the query.
  35: **		Qbname -- the name of the query buffer.
  36: **
  37: **	Trace Flags:
  38: **		none
  39: **
  40: **	Bugs:
  41: **		If 'name' (that is, the {querytrap} macro) changes
  42: **			during a run, the output file does not change.
  43: */
  44: 
  45: FILE    *Trapfile;
  46: 
  47: trapquery(resp, name)
  48: struct resp *resp;
  49: char        *name;
  50: {
  51:     register FILE   *iop;
  52:     static int  first;
  53:     register char   *sp, c;
  54:     int     timevec[2];
  55:     extern      fgetc();
  56:     extern char *ctime();
  57: 
  58:     if (first < 0)
  59:         return;
  60:     if (Trapfile == NULL)
  61:     {
  62:         if ((Trapfile = fopen(name, "a")) == NULL)
  63:         {
  64:             printf("can't trap query in %s\n", name);
  65:             first = -1;
  66:             return;
  67:         }
  68:     }
  69:     if (first == 0)
  70:     {
  71:         time(timevec);
  72:         sp = ctime(timevec);
  73:         while (*sp)
  74:             putc(*sp++, Trapfile);
  75:         first++;
  76:     }
  77: 
  78:     if ((iop = fopen(Qbname, "r")) == NULL)
  79:         syserr("go: open 1");
  80:     macinit(fgetc, iop, 1);
  81: 
  82:     while ((c = macgetch()) > 0)
  83:         putc(c, Trapfile);
  84: 
  85:     if (resp->resp_resp == 0)
  86:     {
  87:         sp = (char *) locv(resp->resp_tups);
  88:         while (*sp)
  89:             putc(*sp++, Trapfile);
  90:         putc('\n', Trapfile);
  91:     }
  92: 
  93:     fclose(iop);
  94: }

Defined functions

trapquery defined in line 47; used 1 times
Last modified: 1986-04-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 868
Valid CSS Valid XHTML 1.0 Strict