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

Defined functions

trapquery defined in line 50; used 1 times
Last modified: 1995-02-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2818
Valid CSS Valid XHTML 1.0 Strict