1: # include   "monitor.h"
   2: # include   <ingres.h>
   3: # include   <aux.h>
   4: # include   <sccs.h>
   5: 
   6: SCCSID(@(#)include.c	8.1	12/31/84)
   7: 
   8: 
   9: 
  10: /*
  11: **  INCLUDE FILE
  12: **
  13: **	A file name, which must follow the \i, is read and inserted
  14: **	into the text stream at this location.  It may include all of
  15: **	the standard control functions.  Includes may be nested.
  16: **
  17: **	If the parameter is 0, the file name is taken from the input;
  18: **	otherwise it is taken directly from the parameter.  In this
  19: **	mode, errors are not printed.
  20: **
  21: **	Prompts are turned off during the include.
  22: */
  23: 
  24: include(filename)
  25: char    *filename;
  26: {
  27:     int         savendf;
  28:     FILE            *saveinp;
  29:     register char       *f;
  30:     register FILE       *b;
  31:     extern char     *getfilenm();
  32: 
  33:     f = filename;
  34:     if (f == 0)
  35:         f = getfilenm();
  36:     if (sequal(f, "-"))
  37:     {
  38:         /* read keyboard */
  39:         b = stdin;
  40:     }
  41:     else if (*f == 0)
  42:     {
  43:         /* back up one level (EOF on next read) */
  44:         GiveEof = TRUE;
  45:         return;
  46:     }
  47:     else
  48:     {
  49:         /* read file */
  50:         if ((b = fopen(f, "r")) == NULL)
  51:         {
  52:             if (filename == 0)
  53:                 printf("Cannot open \"%s\"\n", f);
  54:             return;
  55:         }
  56:     }
  57: 
  58:     /* check for too deep */
  59:     if (Idepth >= 5)
  60:     {
  61:         printf("Include nested too deep\n");
  62:         if (b)
  63:             fclose(b);
  64:         return;
  65:     }
  66:     Idepth++;
  67: 
  68:     /* get input from alternate file */
  69:     savendf = Nodayfile;
  70:     if (b == stdin)
  71:     {
  72:         Nodayfile = Userdflag;
  73:         prompt("<<input>>");
  74:     }
  75:     else
  76:         Nodayfile = -1;
  77:     saveinp = Input;
  78:     Input = b;
  79:     monitor(TRUE);
  80: 
  81:     /* done -- restore old file */
  82:     Input = saveinp;
  83:     Nodayfile = savendf;
  84:     Idepth--;
  85: }

Defined functions

Last modified: 1986-04-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 561
Valid CSS Valid XHTML 1.0 Strict