1: # include   "ctlmod.h"
   2: # include   <ingres.h>
   3: # include   <aux.h>
   4: # include   <tree.h>
   5: # include   <sccs.h>
   6: 
   7: SCCSID(@(#)initp.c	8.1	12/31/84)
   8: 
   9: /*
  10: **  INITP -- initialize parameters for call
  11: **
  12: **	Saves the current context if one is in effect, and
  13: **	initializes the new context.  Further 'setp' calls
  14: **	will set parameters, and 'call' will call the desired
  15: **	function.
  16: **
  17: **	'Initp' is also used by the error routine, except
  18: **	that the 'call' is simulated internally in 'error'
  19: **
  20: **	Parameters:
  21: **		none
  22: **
  23: **	Returns:
  24: **		nothing
  25: **
  26: **	Side Effects:
  27: **		Saves the context 'Ctx' if active.
  28: **		Initializes 'Ctx'.
  29: **
  30: **	Trace Flags:
  31: **		4.0 - 4.3
  32: */
  33: 
  34: initp()
  35: {
  36:     register ctx_t  *pctx;
  37:     register int    sz;
  38:     extern char *need();
  39: 
  40: # ifdef xCTR1
  41:     if (tTf(4, 0))
  42:         lprintf("initp: new %d mark %d\n", Ctx.ctx_new, markbuf(Qbuf));
  43: # endif
  44: 
  45:     if (!Ctx.ctx_new)
  46:     {
  47:         /*
  48: 		** Save the context.
  49: 		**	Mark the current point in Qbuf.
  50: 		**	Allocate space from Qbuf and save the context.
  51: 		**	Only save as much of the pv as is used.
  52: 		**	Leave 'pctx' as a pointer to the save area.
  53: 		*/
  54: 
  55:         Ctx.ctx_cmark = markbuf(Qbuf);
  56:         sz = Ctx.ctx_pc * sizeof Ctx.ctx_pv[0]
  57:              + ((char *) Ctx.ctx_pv - (char *) &Ctx);
  58:         pctx = (ctx_t *) need(Qbuf, sz);
  59:         bmove((char *) &Ctx, (char *) pctx, sz);
  60: 
  61:         /*
  62: 		**  Initialize new context.
  63: 		**	The current context describes the attributes of
  64: 		**		the next context (e.g., ctx_size).
  65: 		**	ctx_pmark marks the base of the parameters in
  66: 		**		Qbuf.
  67: 		**	ctx_qt points to the saved query tree header (if
  68: 		**		one exists).
  69: 		*/
  70: 
  71:         Ctx.ctx_link = pctx;
  72:         Ctx.ctx_size = sz;
  73:         Ctx.ctx_pmark = markbuf(Qbuf);
  74:         Ctx.ctx_qt = NULL;
  75:         Ctx.ctx_resp = Cm.cm_myproc;
  76: 
  77:         /*
  78: 		**  If the QT hdr is in use by the
  79: 		**  context we just saved, arrange to have it saved
  80: 		**  later (if anyone every tries to use it).
  81: 		*/
  82: 
  83:         if (Qt.qt_active > 0 && Qt.qt_ctx == NULL)
  84:         {
  85:             Qt.qt_ctx = (char *) pctx;
  86:         }
  87:     }
  88:     Ctx.ctx_pc = 0;
  89:     Ctx.ctx_init = Ctx.ctx_new = TRUE;
  90:     Ctx.ctx_errfn = NULL;
  91:     Ctx.ctx_fn = NULL;
  92:     Ctx.ctx_glob = NULL;
  93: 
  94: # ifdef xCTR2
  95:     if (tTf(4, 2))
  96:         lprintf("initp: cmark %d pmark %d link %x\n",
  97:             Ctx.ctx_cmark, Ctx.ctx_pmark, Ctx.ctx_link);
  98: # endif
  99: }

Defined functions

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