# 2.11BSD#431 - /usr/src/usr.lib/libI77/err.c

##### Functions

    fatal             X
    ffputc            X
    flush_            X
    prnt_ext          X
    prnt_fmt          X
    prnt_int          X

##### Variables

    cblank            X
    cplus             X
    cursor            X
    elist             X
    endflag           X
    errflag           X
    external          X
    fmtbuf            X
    fmtptr            X
    formatted         X
    icend             X
    icptr             X
    ioiflg_           X
    l_first           X
    lcount            X
    leof              X
    lfname            X
    line_len          X
    lquit             X
    lunit             X
    radix             X
    reading           X
    reclen            X
    recnum            X
    recpos            X
    scale             X
    sequential        X
    signit            X
    tab               X

       1: /*
       2:  * Copyright (c) 1980 Regents of the University of California.
       3:  * All rights reserved.  The Berkeley software License Agreement
       4:  * specifies the terms and conditions for redistribution.
       5:  *
       6:  *	@(#)err.c	5.2.1	1996/3/22
       7:  */
       8:
       9: /*
      10:  * fatal(): i/o error routine
      11:  * flush_(): flush file buffer
      12:  */
      13:
      14: #include <sys/types.h>
      15: #include <sys/stat.h>
      16: #include <signal.h>
      17: #include "fio.h"
      18:
      19: /*
      20:  * global definitions
      21:  */
      22:
      23: unit units[MXUNIT]; /*unit table*/
      24: flag reading;       /*1 if reading,		0 if writing*/
      25: flag external;      /*1 if external io,	0 if internal */
      26: flag sequential;    /*1 if sequential io,	0 if direct*/
      27: flag formatted;     /*1 if formatted io,	0 if unformatted,
      28: 				-1 if list directed, -2 if namelist */
      29: char *fmtbuf, *icptr, *icend, *fmtptr;
      30: int (*doed)(),(*doned)();
      31: int (*doend)(),(*donewrec)(),(*dorevert)(),(*dotab)();
      32: int (*lioproc)();
      33: int (*getn)(),(*putn)(),(*ungetn)();    /*for formatted io*/
      34: FILE *cf;       /*current file structure*/
      35: unit *curunit;      /*current unit structure*/
      36: int lunit;      /*current logical unit*/
      37: char *lfname;       /*current filename*/
      38: int recpos;     /*place in current record*/
      39: ftnint recnum;      /* current record number */
      40: int reclen;     /* current record length */
      41: int cursor,scale;
      42: int radix;
      43: ioflag signit,tab,cplus,cblank,elist,errflag,endflag,lquit,l_first;
      44: flag leof;
      45: int lcount,line_len;
      46: struct ioiflg ioiflg_;  /* initialization flags */
      47:
      48: /*error messages*/
      49:
      50: extern char *f_errlist[];
      51: extern int f_nerr;
      52:
      53: fatal(n,s) char *s;
      54: {
      55:     ftnint lu;
      56:
      57:     for (lu=1; lu < MXUNIT; lu++)
      58:         flush_(&lu);
      59:     if(n<0)
      60:         fprintf(stderr,"%s: [%d] end of file\n",s,n);
      61:     else if(n>=F_ER && n<F_MAXERR)
      62:         fprintf(stderr,"%s: [%d] %s\n",s,n,f_errlist[n-F_ER]);
      63:     else
      64:         fprintf(stderr,"%s: [%d] %s\n",s,n,strerror(n));
      65:     if(external)
      66:     {
      67:         if(!lfname) switch (lunit)
      68:         {   case STDERR: lfname = "stderr";
      69:                     break;
      70:             case STDIN:  lfname = "stdin";
      71:                     break;
      72:             case STDOUT: lfname = "stdout";
      73:                     break;
      74:             default:     lfname = "";
      75:         }
      76:         fprintf(stderr,"logical unit %d, named '%s'\n",lunit,lfname);
      77:     }
      78:     if (elist)
      79:     {   fprintf(stderr,"lately: %s %s %s %s I/O\n",
      80:             reading?"reading":"writing",
      81:             sequential?"sequential":"direct",
      82:             formatted>0?"formatted":(formatted==0?"unformatted":
      83:                 (formatted==LISTDIRECTED?"list":"namelist")),
      84:             external?"external":"internal");
      85:         if (formatted)
      86:         {   if(fmtbuf) prnt_fmt(n);
      87:             if (external)
      88:             {   if(reading && curunit->useek)
      89:                     prnt_ext();  /* print external data */
      90:             }
      91:             else prnt_int();    /* print internal array */
      92:         }
      93:     }
      94:     f77_abort(1, n);
      95: }
      96:
      97: LOCAL
      98: prnt_ext()
      99: {   int ch;
     100:     int i=1;
     101:     long loc;
     102:     fprintf (stderr, "part of last data: ");
     103:     loc = ftell(curunit->ufd);
     104:     if(loc)
     105:     {   if(loc==1L) rewind(curunit->ufd);
     106:         else for(;i<12 && last_char(curunit->ufd)!='\n';i++);
     107:         while(i--) ffputc(fgetc(curunit->ufd),stderr);
     108:     }
     109:     fputc('|',stderr);
     110:     for(i=0;i<5 && (ch=fgetc(curunit->ufd))!=EOF;i++) ffputc(ch,stderr);
     111:     fputc('\n',stderr);
     112: }
     113:
     114: LOCAL
     115: prnt_int()
     116: {   char *ep;
     117:     fprintf (stderr,"part of last string: ");
     118:     ep = icptr - (recpos<12?recpos:12);
     119:     while (ep<icptr) ffputc(*ep++,stderr);
     120:     fputc('|',stderr);
     121:     while (ep<(icptr+5) && ep<icend) ffputc(*ep++,stderr);
     122:     fputc('\n',stderr);
     123: }
     124:
     125: LOCAL
     126: prnt_fmt(n) int n;
     127: {   int i; char *ep;
     128:     fprintf(stderr, "format: ");
     129:     if(n==F_ERFMT)
     130:     {   i = fmtptr - fmtbuf;
     131:         ep = fmtptr - (i<25?i:25);
     132:         if(ep != fmtbuf) fprintf(stderr, "... ");
     133:         i = i + 5;
     134:     }
     135:     else
     136:     {   ep = fmtbuf;
     137:         i = 25;
     138:         fmtptr = fmtbuf - 1;
     139:     }
     140:     while(i && *ep)
     141:     {   ffputc((*ep==GLITCH)?'"':*ep,stderr);
     142:         if(ep==fmtptr) fputc('|',stderr);
     143:         ep++; i--;
     144:     }
     145:     if(*ep) fprintf(stderr, " ...");
     146:     fputc('\n',stderr);
     147: }
     148:
     149: LOCAL
     150: ffputc(c, f)
     151: int c;
     152: FILE    *f;
     153: {
     154:     c &= 0177;
     155:     if (c < ' ' || c == 0177)
     156:     {
     157:         fputc('^', f);
     158:         c ^= 0100;
     159:     }
     160:     fputc(c, f);
     161: }
     162:
     163: ftnint
     164: flush_(u) ftnint *u;
     165: {
     166:     FILE *F;
     167:
     168:     if(not_legal(*u))
     169:         return(F_ERUNIT);
     170:     F = units[*u].ufd;
     171:     if(F)
     172:         return(fflush(F));
     173:     else
     174:         return(F_ERNOPEN);
     175: }

#### Defined functions

fatal defined in line 53; used 8 times

- in /usr/src/usr.lib/libI77/dofio.c line 18
- in /usr/src/usr.lib/libI77/fio.h line 16
- in /usr/src/usr.lib/libI77/fmt.c line 331-335(2), 376
- in /usr/src/usr.lib/libI77/lwrite.c line 99
- in /usr/src/usr.lib/libI77/rsnmle.c line 178, 198

ffputc defined in line 149; used 5 times

- in line 107-110(2), 119-121(2), 141

flush_ defined in line 163; used 3 times

- in line 58
- in /usr/src/usr.lib/libU77/fork_.c line 30
- in /usr/src/usr.lib/libU77/system_.c line 37

prnt_ext defined in line 97; used 1 times

- in line 89

prnt_fmt defined in line 125; used 1 times

- in line 86

prnt_int defined in line 114; used 1 times

- in line 91

#### Defined variables

cblank defined in line 43; never used
cplus defined in line 43; never used
cursor defined in line 41; used 27 times

- in /usr/src/usr.lib/libI77/rdfe.c line 82
- in /usr/src/usr.lib/libI77/rdfmt.c line 22, 73-86(6), 98-100(3)
- in /usr/src/usr.lib/libI77/rsfe.c line 47
- in /usr/src/usr.lib/libI77/wdfe.c line 60
- in /usr/src/usr.lib/libI77/wrtfmt.c line 23, 61-74(6), 91-93(3), 131, 146
- in /usr/src/usr.lib/libI77/wsfe.c line 45, 56

elist defined in line 43; used 1 times

- in line 78

endflag defined in line 43; never used
errflag defined in line 43; never used
external defined in line 25; used 3 times

- in line 65, 84-87(2)

fmtbuf defined in line 29; used 20 times

- in line 86, 130-138(4)
- in /usr/src/usr.lib/libI77/fmt.c line 54-60(3), 66-67(2)
- in /usr/src/usr.lib/libI77/lread.c line 54
- in /usr/src/usr.lib/libI77/lwrite.c line 24
- in /usr/src/usr.lib/libI77/rfi.c line 55
- in /usr/src/usr.lib/libI77/rsfe.c line 70
- in /usr/src/usr.lib/libI77/rsli.c line 31
- in /usr/src/usr.lib/libI77/rsnmle.c line 70
- in /usr/src/usr.lib/libI77/wfi.c line 56
- in /usr/src/usr.lib/libI77/wsfe.c line 86
- in /usr/src/usr.lib/libI77/wsli.c line 28
- in /usr/src/usr.lib/libI77/wsnmle.c line 32

fmtptr defined in line 29; used 17 times

- in line 130-131(2), 138-142(2)
- in /usr/src/usr.lib/libI77/fmt.c line 77, 106, 124, 146, 174, 182, 199, 211, 316, 322, 330-334(2), 375

formatted defined in line 27; used 4 times

- in line 82-85(4)

icend defined in line 29; used 1 times

- in line 121

icptr defined in line 29; used 3 times

- in line 118-121(3)

ioiflg_ defined in line 46; never used
l_first defined in line 43; never used
lcount defined in line 45; used 22 times

- in /usr/src/usr.lib/libI77/lread.c line 62, 101, 169(2), 178-184(4), 201, 207, 228, 236
- in /usr/src/usr.lib/libI77/rsli.c line 25
- in /usr/src/usr.lib/libI77/rsnmle.c line 305-309(2), 398-401(3), 412, 418, 438, 445

leof defined in line 44; never used
lfname defined in line 37; used 14 times

- in line 67-76(6)
- in /usr/src/usr.lib/libI77/inquire.c line 24, 53
- in /usr/src/usr.lib/libI77/open.c line 37, 75
- in /usr/src/usr.lib/libI77/rewind.c line 21, 29
- in /usr/src/usr.lib/libI77/sue.c line 54, 65

line_len defined in line 45; used 4 times

- in /usr/src/usr.lib/libI77/lio.h line 56
- in /usr/src/usr.lib/libI77/lwrite.c line 28
- in /usr/src/usr.lib/libI77/wsli.c line 23
- in /usr/src/usr.lib/libI77/wsnmle.c line 35

lquit defined in line 43; never used
lunit defined in line 36; used 21 times

- in line 67, 76
- in /usr/src/usr.lib/libI77/inquire.c line 25, 46-52(3), 59
- in /usr/src/usr.lib/libI77/open.c line 41-43(3), 55, 86, 139, 167
- in /usr/src/usr.lib/libI77/rewind.c line 24-27(3)
- in /usr/src/usr.lib/libI77/sue.c line 58-61(4)

radix defined in line 42; used 7 times

- in /usr/src/usr.lib/libI77/fmtlib.c line 28
- in /usr/src/usr.lib/libI77/rdfmt.c line 118-121(2), 128-133(4)

reading defined in line 24; used 2 times

- in line 80, 88

reclen defined in line 40; used 18 times

- in /usr/src/usr.lib/libI77/rdfe.c line 82
- in /usr/src/usr.lib/libI77/rsfe.c line 47
- in /usr/src/usr.lib/libI77/sue.c line 27, 42, 74-77(2), 84
- in /usr/src/usr.lib/libI77/wdfe.c line 54-60(4)
- in /usr/src/usr.lib/libI77/wsfe.c line 45, 56, 72(2), 79(2)
- in /usr/src/usr.lib/libI77/wsli.c line 29

recnum defined in line 39; never used
recpos defined in line 38; used 39 times

- in line 118(2)
- in /usr/src/usr.lib/libI77/lwrite.c line 38-39(2)
- in /usr/src/usr.lib/libI77/rdfe.c line 47, 82
- in /usr/src/usr.lib/libI77/rdfmt.c line 78-80(2), 86(2)
- in /usr/src/usr.lib/libI77/rsfe.c line 45-47(2), 56
- in /usr/src/usr.lib/libI77/sue.c line 26, 84
- in /usr/src/usr.lib/libI77/wdfe.c line 46, 54-60(5)
- in /usr/src/usr.lib/libI77/wrtfmt.c line 61-63(2), 69(2)
- in /usr/src/usr.lib/libI77/wsfe.c line 45-46(2), 56, 64, 72(2), 79(2)
- in /usr/src/usr.lib/libI77/wsli.c line 29
- in /usr/src/usr.lib/libI77/wsnmle.c line 41, 83-88(4)

scale defined in line 41; used 29 times

- in /usr/src/usr.lib/libI77/lwrite.c line 155, 161-162(2), 175, 181-182(2)
- in /usr/src/usr.lib/libI77/rdfmt.c line 273-274(2)
- in /usr/src/usr.lib/libI77/wrtfmt.c line 194-203(5), 209-224(8), 230, 259-264(3), 277-280(4)

sequential defined in line 26; used 1 times

- in line 81

signit defined in line 43; never used
tab defined in line 43; never used

Last modified: 1996-03-23 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1203 |