1: # include   "../../pipes.h"
   2: # include   "../../ingres.h"
   3: # include   "../../aux.h"
   4: # include   "../../version.h"
   5: # include   "IIglobals.h"
   6: 
   7: /*
   8: **  IIp_err
   9: **
  10: **	This routine processes an IIerror call for printout.This involves doing
  11: **	a lookup in the .../files/error? files, where ? is the thous-
  12: **	ands digit of the error number.  The associated error message
  13: **	then goes through parameter substitution and is printed.
  14: **
  15: **	In the current version, the error message is just printed.
  16: **
  17: **	Requires:
  18: **		IIfopen() [IIgetc.c] - to open the error file for READ
  19: **		IIgetc() [IIgetc.c] - to read characters from error file
  20: **
  21: **	History:
  22: **		9/7/78 -- (marc) modified from eric's utility
  23: **			routine, for inclusion in equel.
  24: **
  25: */
  26: 
  27: IIp_err(err_num, argc, argv)
  28: int     err_num;
  29: int     argc;
  30: char        **argv;
  31: {
  32:     register char       *p;
  33:     char            buf[512];
  34:     int         i;
  35:     struct iob      iob;
  36:     register char       c;
  37:     char            *IIerrfilen();
  38: 
  39:     /* IIfopen the appropriate error file */
  40:     p = buf;
  41:     IIerrfilen(err_num / 1000, p);
  42: 
  43: #	ifdef xETR2
  44:     if (IIdebug > 1)
  45:         printf("IIp_err : with IIerrfilen ret \"%s\"\n", p);
  46: #	endif
  47: 
  48:     if (IIfopen(p, &iob) < 0)
  49:         return (0);
  50: 
  51:     /* read in the code and check for correct */
  52:     for (;;)
  53:     {
  54:         p = buf;
  55:         while ((c = IIgetc(&iob)) != '\t')
  56:         {
  57:             if (c <= 0)
  58:             {
  59:                 if (IIclose(&iob) < 0)
  60:                     IIsyserr("IIp_err: bad close 1");
  61:                 return (0);
  62:             }
  63:             *p++ = c;
  64:         }
  65:         *p = 0;
  66:         if (IIatoi(buf, &i))
  67:             IIsyserr("IIp_err: bad error file %d\n%s",
  68:                 err_num, buf);
  69:         if (i != err_num)
  70:         {
  71:             while ((c = IIgetc(&iob)) != ERRDELIM)
  72:                 if (c <= 0)
  73:                     IIsyserr("IIp_err: format err %d", err_num);
  74:             IIgetc(&iob);   /* throw out the newline */
  75:             continue;
  76:         }
  77: 
  78:         /* got the correct line, print it doing parameter substitution */
  79:         printf("%d: ", err_num);
  80:         for (;;)
  81:         {
  82:             c = IIgetc(&iob);
  83:             if (c <= 0 || c == ERRDELIM)
  84:             {
  85:                 printf("\n");
  86:                  if (IIclose(&iob) < 0)
  87:                     IIsyserr("IIp_err: bad close 2");
  88:                 return (1);
  89:             }
  90:             if (c == '%')
  91:             {
  92:                 c = IIgetc(&iob);
  93:                 for (p = argv[c - '0']; c = *p; p++)
  94:                 {
  95:                     if (c < 040 || c >= 0177)
  96:                         printf("\\%o", c);
  97:                     else
  98:                         putchar(c);
  99:                 }
 100:                 continue;
 101:             }
 102:             putchar(c);
 103:         }
 104:     }
 105: }
 106: 
 107: /*
 108: ** IIerrfilen -- Returns the pathname where the error file can be found
 109: **	into "buf".
 110: **
 111: **	It is assumed that the error number cannot be more than 999.
 112: **	Returned is concat of : IIPathname, "/files/error", VERSION (w/o mod),
 113: **	"_num".
 114: */
 115: 
 116: char *IIerrfilen(num, buf)
 117: int num;
 118: char    *buf;
 119: {
 120:     register char   *cp;
 121:     char        ver[12];
 122:     char        *IIconcatv();
 123: 
 124:     IIconcatv(ver, VERSION, 0);
 125: 
 126:     /* make sure any mod number is removed */
 127:     for (cp = ver; *cp; cp++)
 128:         if (*cp == '/')
 129:             break;
 130: 
 131:     /* now insert the "_X" */
 132:     *cp++ = '_';
 133:     *cp = '\0';
 134:     IIconcatv(ver, ver, IIitos(num), 0);
 135: 
 136: 
 137:     return (IIconcatv(buf, IIPathname, "/files/error", ver, 0));
 138: }

Defined functions

IIerrfilen defined in line 116; used 2 times
IIp_err defined in line 27; used 1 times
Last modified: 1995-02-11
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2470
Valid CSS Valid XHTML 1.0 Strict