Annotation of 43BSD/ingres/source/libq/IIp_err.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.