1: # include   "ctlmod.h"
   2: # include   <signal.h>
   3: # include   <sccs.h>
   4: 
   5: SCCSID(@(#)cm_cleanup.c	8.1	12/31/84)
   6: 
   7: /*
   8: **  CM_CLEANUP -- cleanup after interrupt or error.
   9: **
  10: **	This routine does things like call the interrupt cleanup
  11: **	function, reset the input, etc.
  12: **
  13: **	Parameters:
  14: **		typ -- the type of cleanup:
  15: **			1 -- fatal error (from error [error.c]).
  16: **			2 -- keyboard interrupt.
  17: **
  18: **	Returns:
  19: **		never (uses non-local jump to ctlmod/main.c).
  20: **
  21: **	Side Effects:
  22: **		Proc_name & Cm.cm_input are reset.
  23: **
  24: **	Trace Flags:
  25: **		0
  26: */
  27: 
  28: cm_cleanup(typ)
  29: int typ;
  30: {
  31:     register int        i;
  32:     register struct fn_def  *f;
  33:     extern char     *Proc_name;
  34:     extern jmp_buf      CmReset;
  35:     extern          rubcatch();
  36:     register ctx_t      *ctx;
  37: 
  38: # ifdef xCTR2
  39:     if (tTf(0, 13))
  40:         printf("cm_cleanup: %d\n", typ);
  41: # endif
  42: 
  43:     /*
  44: 	**  Call all interrupt cleanup functions for active
  45: 	**	modules.
  46: 	*/
  47: 
  48:     for (i = 0; i < NumFunc; i++)
  49:     {
  50:         f = FuncVect[i];
  51:         if (f->fn_active > 0)
  52:         {
  53:             Ctx.ctx_name = Proc_name = f->fn_name;
  54:             (*f->fn_cleanup)(typ);
  55:         }
  56:     }
  57: 
  58:     /* clean up memory */
  59:     for (ctx = &Ctx; ctx != NULL; ctx = ctx->ctx_link)
  60:     {
  61:         if (ctx->ctx_qt != NULL)
  62:             free(ctx->ctx_qt);
  63:         if (ctx->ctx_glob != NULL)
  64:         {
  65:             bmove(ctx->ctx_glob, ctx->ctx_fn->fn_gptr, ctx->ctx_fn->fn_gsize);
  66:             free(ctx->ctx_glob);
  67:         }
  68:     }
  69: 
  70:     /* return to top of loop */
  71:     longjmp(CmReset, typ);
  72: }

Defined functions

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