err.c File Reference

#include "sysdep1.h"
#include "f2c.h"
#include "stdlib.h"
#include "fio.h"
#include "fmt.h"

Include dependency graph for err.c:

Go to the source code of this file.

Defines

#define MAXERR   (sizeof(F_err)/sizeof(char *)+100)

Functions

int(*)(*) f__donewrec (void)
int f__canseek (FILE *f)
void f__fatal (int n, char *s)
VOID f_init (Void)
int f__nowreading (unit *x)
int f__nowwriting (unit *x)
int err__fl (int f, int m, char *s)

Variables

unit f__units [MXUNIT]
flag f__init
cilistf__elist
icilistf__svic
flag f__reading
flag f__cplus
flag f__cblank
char * f__fmtbuf
flag f__external
int(*) f__getn (void)
void(*) f__putn (int)
int(* f__doed )(struct syl *, char *, ftnlen)
int(*)(*) f__doned (struct syl *)
int(* f__dorevert )(void)
int(*)(*)(*) f__doend (void)
flag f__sequential
flag f__formatted
FILE * f__cf
unitf__curunit
int f__recpos
OFF_T f__cursor
OFF_T f__hiwater
int f__scale
char * f__icptr
char * F_err []


Define Documentation

#define MAXERR   (sizeof(F_err)/sizeof(char *)+100)

Definition at line 85 of file err.c.

Referenced by f__fatal().


Function Documentation

int err__fl ( int  f,
int  m,
char *  s 
)

Definition at line 278 of file err.c.

References errno, f__doend, and f__fatal().

Referenced by Lfinish().

00280 {
00281         if (!f)
00282                 f__fatal(m, s);
00283         if (f__doend)
00284                 (*f__doend)();
00285         return errno = m;
00286         }

Here is the call graph for this function:

Here is the caller graph for this function:

int f__canseek ( FILE *  f  ) 

Definition at line 91 of file err.c.

References FSTAT, isatty(), STAT_ST, and work.

Referenced by f_init(), and f_open().

00093 {
00094 #ifdef NON_UNIX_STDIO
00095 #ifdef _MSC_VER
00096 #define fileno _fileno
00097 #define isatty _isatty
00098 #endif
00099         return !isatty(fileno(f));
00100 #else
00101         struct STAT_ST x;
00102 
00103         if (FSTAT(fileno(f),&x) < 0)
00104                 return(0);
00105 #ifdef S_IFMT
00106         switch(x.st_mode & S_IFMT) {
00107         case S_IFDIR:
00108         case S_IFREG:
00109                 if(x.st_nlink > 0)      /* !pipe */
00110                         return(1);
00111                 else
00112                         return(0);
00113         case S_IFCHR:
00114                 if(isatty(fileno(f)))
00115                         return(0);
00116                 return(1);
00117 #ifdef S_IFBLK
00118         case S_IFBLK:
00119                 return(1);
00120 #endif
00121         }
00122 #else
00123 #ifdef S_ISDIR
00124         /* POSIX version */
00125         if (S_ISREG(x.st_mode) || S_ISDIR(x.st_mode)) {
00126                 if(x.st_nlink > 0)      /* !pipe */
00127                         return(1);
00128                 else
00129                         return(0);
00130                 }
00131         if (S_ISCHR(x.st_mode)) {
00132                 if(isatty(fileno(f)))
00133                         return(0);
00134                 return(1);
00135                 }
00136         if (S_ISBLK(x.st_mode))
00137                 return(1);
00138 #else
00139         Help! How does fstat work on this system?
00140 #endif
00141 #endif
00142         return(0);      /* who knows what it is? */
00143 #endif
00144 }

Here is the call graph for this function:

Here is the caller graph for this function:

int(*)(*) f__donewrec ( void   ) 

void f__fatal ( int  n,
char *  s 
)

Definition at line 150 of file err.c.

References f__curunit, f__units, MAXERR, sig_die(), and unit::ufnm.

Referenced by err__fl(), f__bufadj(), l_write(), opn_err(), and unit_chk().

00152 {
00153         if(n<100 && n>=0) perror(s); /*SYSDEP*/
00154         else if(n >= (int)MAXERR || n < -1)
00155         {       fprintf(stderr,"%s: illegal error number %d\n",s,n);
00156         }
00157         else if(n == -1) fprintf(stderr,"%s: end of file\n",s);
00158         else
00159                 fprintf(stderr,"%s: %s\n",s,F_err[n-100]);
00160         if (f__curunit) {
00161                 fprintf(stderr,"apparent state: unit %d ",
00162                         (int)(f__curunit-f__units));
00163                 fprintf(stderr, f__curunit->ufnm ? "named %s\n" : "(unnamed)\n",
00164                         f__curunit->ufnm);
00165                 }
00166         else
00167                 fprintf(stderr,"apparent state: internal I/O\n");
00168         if (f__fmtbuf)
00169                 fprintf(stderr,"last format: %s\n",f__fmtbuf);
00170         fprintf(stderr,"lately %s %s %s %s",f__reading?"reading":"writing",
00171                 f__sequential?"sequential":"direct",f__formatted?"formatted":"unformatted",
00172                 f__external?"external":"internal");
00173         sig_die(" IO", 1);
00174 }

Here is the call graph for this function:

Here is the caller graph for this function:

int f__nowreading ( unit x  ) 

Definition at line 202 of file err.c.

References done, errno, f__r_mode, f__w_mode, FREOPEN, FSEEK, FTELL, OFF_T, SEEK_SET, unit::ufd, unit::ufmt, unit::ufnm, unit::url, unit::urw, and unit::uwrt.

Referenced by f_back(), s_rdfe(), s_rdue(), s_rsfe(), s_rsle(), s_rsne(), and s_rsue().

00204 {
00205         OFF_T loc;
00206         int ufmt, urw;
00207         extern char *f__r_mode[], *f__w_mode[];
00208 
00209         if (x->urw & 1)
00210                 goto done;
00211         if (!x->ufnm)
00212                 goto cantread;
00213         ufmt = x->url ? 0 : x->ufmt;
00214         loc = FTELL(x->ufd);
00215         urw = 3;
00216         if (!FREOPEN(x->ufnm, f__w_mode[ufmt|2], x->ufd)) {
00217                 urw = 1;
00218                 if(!FREOPEN(x->ufnm, f__r_mode[ufmt], x->ufd)) {
00219  cantread:
00220                         errno = 126;
00221                         return 1;
00222                         }
00223                 }
00224         FSEEK(x->ufd,loc,SEEK_SET);
00225         x->urw = urw;
00226  done:
00227         x->uwrt = 0;
00228         return 0;
00229 }

Here is the caller graph for this function:

int f__nowwriting ( unit x  ) 

Definition at line 235 of file err.c.

References done, errno, f__w_mode, FREOPEN, FSEEK, FTELL, NULL, OFF_T, SEEK_CUR, SEEK_SET, unit::ufd, unit::ufmt, unit::ufnm, unit::url, unit::urw, and unit::uwrt.

Referenced by s_wdfe(), s_wdue(), s_wsfe(), s_wsle(), s_wsne(), and s_wsue().

00237 {
00238         OFF_T loc;
00239         int ufmt;
00240         extern char *f__w_mode[];
00241 
00242         if (x->urw & 2) {
00243                 if (x->urw & 1)
00244                         FSEEK(x->ufd, (OFF_T)0, SEEK_CUR);
00245                 goto done;
00246                 }
00247         if (!x->ufnm)
00248                 goto cantwrite;
00249         ufmt = x->url ? 0 : x->ufmt;
00250         if (x->uwrt == 3) { /* just did write, rewind */
00251                 if (!(f__cf = x->ufd =
00252                                 FREOPEN(x->ufnm,f__w_mode[ufmt],x->ufd)))
00253                         goto cantwrite;
00254                 x->urw = 2;
00255                 }
00256         else {
00257                 loc=FTELL(x->ufd);
00258                 if (!(f__cf = x->ufd =
00259                         FREOPEN(x->ufnm, f__w_mode[ufmt | 2], x->ufd)))
00260                         {
00261                         x->ufd = NULL;
00262  cantwrite:
00263                         errno = 127;
00264                         return(1);
00265                         }
00266                 x->urw = 3;
00267                 FSEEK(x->ufd,loc,SEEK_SET);
00268                 }
00269  done:
00270         x->uwrt = 1;
00271         return 0;
00272 }

Here is the caller graph for this function:

VOID f_init ( Void   ) 

Definition at line 177 of file err.c.

References f__canseek(), f__units, and p.

Referenced by c_due(), c_le(), f_open(), main(), nl_init(), s_rdfe(), s_rsfe(), s_rsue(), s_wdfe(), s_wsfe(), and s_wsue().

00178 {       unit *p;
00179 
00180         f__init=1;
00181         p= &f__units[0];
00182         p->ufd=stderr;
00183         p->useek=f__canseek(stderr);
00184         p->ufmt=1;
00185         p->uwrt=1;
00186         p = &f__units[5];
00187         p->ufd=stdin;
00188         p->useek=f__canseek(stdin);
00189         p->ufmt=1;
00190         p->uwrt=0;
00191         p= &f__units[6];
00192         p->ufd=stdout;
00193         p->useek=f__canseek(stdout);
00194         p->ufmt=1;
00195         p->uwrt=1;
00196 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

flag f__cblank

Definition at line 26 of file err.c.

Referenced by c_si(), rd_F(), rd_I(), s_rsfe(), and s_wsfe().

FILE* f__cf

Definition at line 42 of file err.c.

Referenced by c_dfe(), c_due(), c_lir(), c_liw(), c_si(), c_sue(), do_ud(), do_us(), e_rdue(), e_rsue(), e_wdue(), e_wsfe(), e_wsle(), e_wsue(), f__putbuf(), getname(), print_ne(), rd_ed(), s_rsfe(), s_rsue(), s_wsfe(), s_wsue(), t_runc(), x_getc(), x_rsne(), xrd_SL(), xw_end(), y_getc(), and y_rsk().

flag f__cplus

Definition at line 26 of file err.c.

Referenced by c_si(), s_rsfe(), s_wsfe(), wrt_E(), wrt_F(), wrt_I(), and wrt_IM().

OFF_T f__cursor

Definition at line 45 of file err.c.

Referenced by c_dfe(), c_lir(), c_liw(), c_si(), fmt_bg(), iw_rev(), mv_cur(), rd_ed(), rd_ned(), s_rsfe(), s_wsfe(), w_ed(), w_ned(), wrt_AP(), wrt_H(), x_wSL(), xrd_SL(), xw_end(), xw_rev(), y_newrec(), z_rnew(), and z_wnew().

unit* f__curunit

Definition at line 43 of file err.c.

Referenced by c_dfe(), c_due(), c_le(), c_lir(), c_liw(), c_sfe(), c_si(), c_sue(), do_ud(), e_rdue(), e_rsle(), f__fatal(), f_back(), f_open(), opn_err(), print_ne(), rd_ed(), s_rdfe(), s_rdue(), s_rsfe(), s_rsle(), s_rsne(), s_rsue(), s_wdfe(), s_wdue(), s_wsfe(), s_wsle(), s_wsne(), s_wsue(), t_getc(), x_endp(), x_getc(), xrd_SL(), y_getc(), y_rev(), and y_rsk().

int(* f__doed)(struct syl *, char *, ftnlen)

Referenced by do_fio(), s_rdfe(), s_rsfe(), s_rsfi(), s_wdfe(), s_wsfe(), and s_wsfi().

int(*)(*)(*) f__doend(void)

Definition at line 38 of file err.c.

Referenced by do_fio(), err__fl(), s_rdfe(), s_rsfe(), s_rsfi(), s_rsle(), s_rsli(), s_rsne(), s_wdfe(), s_wsfe(), and s_wsfi().

int(*)(*) f__doned(struct syl *)

Definition at line 37 of file err.c.

Referenced by do_fio(), s_rdfe(), s_rsfe(), s_rsfi(), s_wdfe(), s_wsfe(), and s_wsfi().

int(* f__dorevert)(void)

Referenced by do_fio(), s_rdfe(), s_rsfe(), s_rsfi(), s_wdfe(), s_wsfe(), and s_wsfi().

cilist* f__elist

Definition at line 23 of file err.c.

Referenced by ap_end(), c_dfe(), c_due(), c_le(), c_lir(), c_liw(), c_si(), c_sue(), do_fio(), do_ud(), do_us(), e_rdue(), e_wdue(), e_wsfe(), e_wsle(), e_wsue(), getname(), l_C(), l_CHAR(), l_L(), l_R(), l_read(), Lfinish(), mv_cur(), print_ne(), rd_ed(), s_rsfe(), s_rsle(), s_wsfe(), x_rsne(), y_err(), and y_getc().

flag f__external

Definition at line 28 of file err.c.

Referenced by c_dfe(), c_due(), c_lir(), c_liw(), c_si(), c_sue(), f_open(), mv_cur(), print_ne(), rd_ed(), s_rsfe(), s_rsle(), s_rsne(), s_wsfe(), s_wsle(), s_wsne(), and x_rsne().

char* f__fmtbuf

Definition at line 27 of file err.c.

Referenced by c_dfe(), c_le(), c_si(), do_fio(), e_rsfi(), e_wsfi(), op_gen(), rd_ed(), rd_ned(), s_rdfe(), s_rsfe(), s_wdfe(), s_wsfe(), w_ed(), and w_ned().

flag f__formatted

Definition at line 41 of file err.c.

Referenced by c_dfe(), c_due(), c_lir(), c_liw(), c_si(), c_sue(), s_rsfe(), s_rsle(), s_wsfe(), s_wsle(), s_wsne(), and x_rsne().

int(*) f__getn(void)

Definition at line 35 of file err.c.

Referenced by rd_ed(), rd_H(), rd_POS(), s_rdfe(), s_rsfe(), and s_rsfi().

OFF_T f__hiwater

Definition at line 45 of file err.c.

Referenced by c_si(), e_wsfi(), f__putbuf(), iw_rev(), mv_cur(), s_wsfe(), x_wSL(), xw_end(), xw_rev(), y_newrec(), y_rev(), z_rnew(), and z_wnew().

char* f__icptr

Definition at line 47 of file err.c.

Referenced by rd_ed().

flag f__init

Definition at line 22 of file err.c.

Referenced by c_due(), c_le(), f_open(), nl_init(), s_rdfe(), s_rsfe(), s_rsue(), s_wdfe(), s_wsfe(), and s_wsue().

void(*) f__putn(int)

Definition at line 36 of file err.c.

Referenced by c_liw(), l_put(), mv_cur(), s_wdfe(), s_wsfe(), s_wsfi(), s_wsle(), s_wsne(), wrt_AP(), wrt_G(), wrt_I(), wrt_IM(), wrt_L(), and wrt_Z().

flag f__reading

Definition at line 25 of file err.c.

Referenced by c_lir(), c_liw(), do_ud(), do_us(), print_ne(), s_rdfe(), s_rdue(), s_rsfe(), s_rsfi(), s_rsle(), s_rsue(), s_wdfe(), s_wdue(), s_wsfe(), s_wsfi(), s_wsle(), s_wsne(), s_wsue(), and x_rsne().

int f__recpos

Definition at line 44 of file err.c.

Referenced by c_dfe(), c_due(), c_le(), c_liw(), c_si(), do_ud(), do_us(), donewrec(), e_rdue(), e_rsue(), e_wsfi(), e_wsle(), f__putbuf(), iw_rev(), lwrt_A(), lwrt_C(), lwrt_F(), lwrt_I(), lwrt_L(), mv_cur(), print_ne(), rd_ed(), rd_ned(), s_rsfe(), s_rsue(), s_wsfe(), w_ned(), x_getc(), x_putc(), x_wSL(), x_wsne(), xrd_SL(), xw_end(), xw_rev(), y_getc(), y_rev(), y_rsk(), z_getc(), z_putc(), z_rnew(), and z_wnew().

int f__scale

Definition at line 46 of file err.c.

Referenced by c_dfe(), c_le(), c_si(), do_fio(), rd_F(), s_rsfe(), s_wsfe(), wrt_E(), wrt_F(), and wrt_G().

flag f__sequential

Definition at line 40 of file err.c.

Referenced by c_dfe(), c_due(), c_si(), c_sue(), do_uio(), s_rsfe(), and s_wsfe().

icilist* f__svic

Definition at line 24 of file err.c.

Referenced by c_lir(), c_liw(), c_si(), e_wsfi(), i_getc(), i_ungetc(), mv_cur(), z_getc(), z_putc(), z_rnew(), and z_wnew().

unit f__units[MXUNIT]

Definition at line 21 of file err.c.

Referenced by c_dfe(), c_due(), c_le(), c_sfe(), c_sue(), f__fatal(), f_back(), f_clos(), f_end(), f_init(), f_inqu(), f_open(), f_rew(), flush_(), t_runc(), and unit_chk().

char* F_err[]

Definition at line 50 of file err.c.


Generated on Sun Mar 4 15:04:26 2007 for Scilab [trunk] by  doxygen 1.5.1