1: # include   "../ingres.h"
   2: # include   "../aux.h"
   3: # include   "../pipes.h"
   4: # include   "../tree.h"
   5: # include   "../symbol.h"
   6: # include   "qrymod.h"
   7: 
   8: 
   9: /*
  10: **  WRITETREE.C -- query tree output routines
  11: **
  12: **	These routines write out a query tree in internal format.
  13: **
  14: **	Defines:
  15: **		writetree
  16: **		writeqry
  17: **		writesym
  18: **
  19: **	Required By:
  20: **		qrymod.c
  21: **
  22: **	Trace Flags:
  23: **		70
  24: **
  25: **	History:
  26: **		2/14/79 -- version 6.2/0 release.
  27: */
  28: 
  29: extern struct pipfrmt   Pipe, Outpipe;
  30: /*
  31: **  WRITETREE -- write a query tree
  32: **
  33: **	A query tree is written to the down pipe.  The parameter is
  34: **	the root of the tree to be written.
  35: **
  36: **	Parameters:
  37: **		q1 -- the root of the tree to write.
  38: **		wrfn -- the function to call to do physical
  39: **			writes.
  40: **
  41: **	Returns:
  42: **		none
  43: **
  44: **	Side Effects:
  45: **		none
  46: **
  47: **	Requires:
  48: **		nodepr -- for debugging node print.
  49: **
  50: **	Called By:
  51: **		writeqry
  52: */
  53: 
  54: writetree(q1, wrfn)
  55: QTREE   *q1;
  56: int (*wrfn)();
  57: {
  58:     register QTREE  *q;
  59:     register int    l;
  60:     register char   t;
  61: 
  62:     q = q1;
  63: 
  64:     /* write the subtrees */
  65:     if (q->left != NULL)
  66:         writetree(q->left, wrfn);
  67:     if (q->right != NULL)
  68:         writetree(q->right, wrfn);
  69: 
  70:     /* write this node */
  71:     t = q->sym.type;
  72:     if (t == AND || t == ROOT || t == AGHEAD)
  73:         q->sym.len = 0;
  74:     l = q->sym.len & I1MASK;
  75:     (*wrfn)(&(q->sym), l + 2);
  76: #	ifdef xQTR1
  77:     if (tTf(70, 5))
  78:         nodepr(q, TRUE);
  79: #	endif
  80: }
  81: /*
  82: **  WRITEQRY -- write a whole query
  83: **
  84: **	An entire query is written, including range table, and so
  85: **	forth.
  86: **
  87: **	Parameters:
  88: **		root -- the root of the tree to write.
  89: **		wrfn -- the function to do the physical write.
  90: **
  91: **	Returns:
  92: **		none
  93: **
  94: **	Side Effects:
  95: **		none.
  96: **
  97: **	Requires:
  98: **		Rangev -- the range table.
  99: **		Resultvar -- The result variable number.
 100: **		writesym() -- to write symbols out.
 101: **
 102: **	Called By:
 103: **		User.
 104: */
 105: 
 106: writeqry(root, wrfn)
 107: QTREE   *root;
 108: int (*wrfn)();
 109: {
 110:     register int        i;
 111:     struct srcid        sid;
 112: 
 113:     /* write the query mode */
 114:     if (Qmode >= 0)
 115:         writesym(QMODE, 2, &Qmode, wrfn);
 116: 
 117:     /* write the range table */
 118:     for (i = 0; i < MAXVAR + 1; i++)
 119:     {
 120:         if (Rangev[i].rused)
 121:         {
 122:             sid.type = SOURCEID;
 123:             sid.len = sizeof sid - 2;
 124:             pmove(Rangev[i].relid, sid.srcname, MAXNAME, ' ');
 125:             sid.srcvar = i;
 126:             sid.srcstat = Rangev[i].rstat;
 127:             bmove(Rangev[i].rowner, sid.srcown, 2);
 128:             (*wrfn)(&sid, sizeof sid);
 129:         }
 130:     }
 131: 
 132:     /* write a possible result variable */
 133:     if (Resultvar >= 0)
 134:         writesym(RESULTVAR, 2, &Resultvar, wrfn);
 135: 
 136:     /* write the tree */
 137:     writetree(root, wrfn);
 138: }
 139: /*
 140: **  WRITESYM -- write a symbol block
 141: **
 142: **	A single symbol entry of the is written.
 143: **	a 'value' of zero will not be written.
 144: */
 145: 
 146: writesym(typ, len, value, wrfn)
 147: int typ;
 148: int len;
 149: char    *value;
 150: int (*wrfn)();
 151: {
 152:     struct symbol   sym;
 153:     register char   *v;
 154:     register int    l;
 155: 
 156:     sym.type = typ & I1MASK;
 157:     sym.len = l = len & I1MASK;
 158:     (*wrfn)(&sym, 2);
 159:     v = value;
 160:     if (v != 0)
 161:         (*wrfn)(v, l);
 162: }

Defined functions

writesym defined in line 146; used 2 times
writetree defined in line 54; used 3 times
Last modified: 1995-02-19
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2556
Valid CSS Valid XHTML 1.0 Strict