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

Defined functions

Last modified: 1995-02-12
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2593
Valid CSS Valid XHTML 1.0 Strict