1: # include   "monitor.h"
   2: # include   <ingres.h>
   3: # include   <aux.h>
   4: # include   <sccs.h>
   5: 
   6: SCCSID(@(#)eval.c	8.1	12/31/84)
   7: 
   8: 
   9: 
  10: /*
  11: **  DO MACRO EVALUATION OF QUERY BUFFER
  12: **
  13: **	The logical query buffer is read and passed through the macro
  14: **	processor.  The main purpose of this is to evaluate {define}'s.
  15: **	If the 'pr' flag is set, the result is printed on the terminal,
  16: **	and so becomes a post-evaluation version of print.
  17: **
  18: **	Uses trace flag 12
  19: */
  20: 
  21: eval(pr)
  22: int pr;
  23: {
  24:     register FILE   *tfile;
  25:     register char   c;
  26:     extern int  fgetc();
  27:     char        tfilename[40];
  28: 
  29:     Autoclear = 0;
  30:     clrline(1);
  31: 
  32:     /* open temp file and reopen query buffer for reading */
  33:     if (!pr)
  34:     {
  35:         concat("/tmp/INGTQ", Fileset, tfilename);
  36:         if ((tfile = fopen(tfilename, "w")) == NULL)
  37:             syserr("eval: open(%s)", tfilename);
  38:     }
  39:     if (freopen(Qbname, "r", Qryiop) == NULL)
  40:         syserr("eval: freopen 1");
  41: 
  42:     /* COPY FILE */
  43:     macinit(fgetc, Qryiop, 1);
  44:     while ((c = macgetch()) > 0)
  45:     {
  46:         if (pr)
  47:             putchar(c);
  48:         else
  49:             if (putc(c, tfile) == EOF)
  50:                 syserr("eval: putc");
  51:     }
  52: 
  53:     if (!pr)
  54:     {
  55:         /* link temp file back to query buffer */
  56:         fclose(tfile);
  57:         unlink(Qbname);
  58:         if (link(tfilename, Qbname))
  59:             syserr("eval: link");
  60:         unlink(tfilename);
  61:     }
  62: 
  63:     /* reopen query buffer (now evaluated) */
  64:     if (freopen(Qbname, "a", Qryiop) == NULL)
  65:         syserr("eval: freopen 2");
  66: 
  67:     cgprompt();
  68: }

Defined functions

eval defined in line 6; used 2 times
Last modified: 1986-04-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 578
Valid CSS Valid XHTML 1.0 Strict