1: # include   <stdio.h>
   2: 
   3: # include   "../ingres.h"
   4: # include   "../aux.h"
   5: 
   6: # define    ERRDELIM    '~'
   7: 
   8: /*
   9: **  PROCESS ERROR MESSAGE (Standalone override)
  10: **
  11: **	This routine replaces the "error" routine for use in
  12: **	standalone routines such as creatdb and printr.  Its usage
  13: **	is identical to that of normal "error".
  14: **
  15: **	This routine is assumed to be called by process five; hence,
  16: **	all error messages it produces have a 5000 offset.
  17: **
  18: */
  19: 
  20: error(number, argvect)
  21: int number;
  22: char    *argvect;
  23: {
  24:     FILE        *iop;
  25:     char        **pv;
  26:     int     i;
  27:     register char   *p;
  28:     register int    err;
  29:     char        buf[10];
  30:     register char   c;
  31:     char        *errfilen();
  32: 
  33:     pv = &argvect;
  34:     err = number;
  35:     if ((iop = fopen(errfilen(5), "r")) == NULL)
  36:         syserr("error: open");
  37: 
  38:     /* read in the code and check for correct */
  39:     for (;;)
  40:     {
  41:         p = buf;
  42:         while ((c = getc(iop)) != '\t')
  43:         {
  44:             if (c <= 0)
  45:             {
  46:                 /* no code exists, print the first parm */
  47:                 printf("%d: %s\n\n", err, pv[0]);
  48:                 fclose(iop);
  49:                 return (err);
  50:             }
  51:             *p++ = c;
  52:         }
  53:         *p = 0;
  54:         if (atoi(buf, &i))
  55:             syserr("proc_error: bad error file %d\n%s", err, buf);
  56:         if (i != err)
  57:         {
  58:             while ((c = getc(iop)) != ERRDELIM)
  59:                 if (c <= 0)
  60:                     syserr("proc_error: format err %d", err);
  61:             getc(iop);  /* throw out the newline */
  62:             continue;
  63:         }
  64: 
  65:         /* got the correct line, print it doing parameter substitution */
  66:         printf("%d: ", err);
  67:         c = '\n';
  68:         for (;;)
  69:         {
  70:             c = getc(iop);
  71:             if (c == EOF || c == ERRDELIM)
  72:             {
  73:                 printf("\n");
  74:                 fclose(iop);
  75:                 return (err);
  76:             }
  77:             if (c == '%')
  78:             {
  79:                 c = getc(iop);
  80:                 for (p = pv[c - '0']; c = *p; p++)
  81:                 {
  82:                     putchar(c);
  83:                 }
  84:                 continue;
  85:             }
  86:             putchar(c);
  87:         }
  88:     }
  89: }

Defined functions

error defined in line 20; never used

Defined macros

ERRDELIM defined in line 6; used 2 times
Last modified: 1995-02-04
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2879
Valid CSS Valid XHTML 1.0 Strict