Doxygen Source Code Documentation
err.c File Reference
#include "stdlib.h"#include "sys/types.h"#include "sys/stat.h"#include "f2c.h"#include "fio.h"#include "fmt.h"#include "rawio.h"Go to the source code of this file.
Defines | |
| #define | MAXERR (sizeof(F_err)/sizeof(char *)+100) |
Functions | |
| int(*)(*) | f__donewrec (void) |
| f__canseek (FILE *f) | |
| void | f__fatal (int n, char *s) |
| VOID | f_init (Void) |
| f__nowreading (unit *x) | |
| f__nowwriting (unit *x) | |
| int | err__fl (int f, int m, char *s) |
Variables | |
| unit | f__units [MXUNIT] |
| flag | f__init |
| cilist * | f__elist |
| icilist * | f__svic |
| flag | f__reading |
| flag | f__cplus |
| flag | f__cblank |
| char * | f__fmtbuf |
| flag | f__external |
| int(* | f__getn )(void) |
| int(*)(*) | 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 |
| unit * | f__curunit |
| int | f__recpos |
| int | f__cursor |
| int | f__hiwater |
| int | f__scale |
| char * | f__icptr |
| char * | F_err [] |
Define Documentation
|
|
Definition at line 81 of file err.c. Referenced by f__fatal(). |
Function Documentation
|
||||||||||||||||
|
Definition at line 270 of file err.c. References f__fatal().
00272 {
00273 if (!f)
00274 f__fatal(m, s);
00275 if (f__doend)
00276 (*f__doend)();
00277 return errno = m;
00278 }
|
|
|
Definition at line 86 of file err.c. References isatty(), and S_ISDIR. Referenced by f_init(), and f_open().
00088 {
00089 #ifdef NON_UNIX_STDIO
00090 return !isatty(fileno(f));
00091 #else
00092 struct stat x;
00093
00094 if (fstat(fileno(f),&x) < 0)
00095 return(0);
00096 #ifdef S_IFMT
00097 switch(x.st_mode & S_IFMT) {
00098 case S_IFDIR:
00099 case S_IFREG:
00100 if(x.st_nlink > 0) /* !pipe */
00101 return(1);
00102 else
00103 return(0);
00104 case S_IFCHR:
00105 if(isatty(fileno(f)))
00106 return(0);
00107 return(1);
00108 #ifdef S_IFBLK
00109 case S_IFBLK:
00110 return(1);
00111 #endif
00112 }
00113 #else
00114 #ifdef S_ISDIR
00115 /* POSIX version */
00116 if (S_ISREG(x.st_mode) || S_ISDIR(x.st_mode)) {
00117 if(x.st_nlink > 0) /* !pipe */
00118 return(1);
00119 else
00120 return(0);
00121 }
00122 if (S_ISCHR(x.st_mode)) {
00123 if(isatty(fileno(f)))
00124 return(0);
00125 return(1);
00126 }
00127 if (S_ISBLK(x.st_mode))
00128 return(1);
00129 #else
00130 Help! How does fstat work on this system?
00131 #endif
00132 #endif
00133 return(0); /* who knows what it is? */
00134 #endif
00135 }
|
|
|
|
|
||||||||||||
|
Definition at line 141 of file err.c. References f__external, f__fmtbuf, f__formatted, f__reading, f__sequential, F_err, MAXERR, sig_die(), and unit::ufnm. Referenced by ap_end(), err__fl(), l_write(), and unit_chk().
00143 {
00144 if(n<100 && n>=0) perror(s); /*SYSDEP*/
00145 else if(n >= (int)MAXERR || n < -1)
00146 { fprintf(stderr,"%s: illegal error number %d\n",s,n);
00147 }
00148 else if(n == -1) fprintf(stderr,"%s: end of file\n",s);
00149 else
00150 fprintf(stderr,"%s: %s\n",s,F_err[n-100]);
00151 if (f__curunit) {
00152 fprintf(stderr,"apparent state: unit %d ",f__curunit-f__units);
00153 fprintf(stderr, f__curunit->ufnm ? "named %s\n" : "(unnamed)\n",
00154 f__curunit->ufnm);
00155 }
00156 else
00157 fprintf(stderr,"apparent state: internal I/O\n");
00158 if (f__fmtbuf)
00159 fprintf(stderr,"last format: %s\n",f__fmtbuf);
00160 fprintf(stderr,"lately %s %s %s %s",f__reading?"reading":"writing",
00161 f__sequential?"sequential":"direct",f__formatted?"formatted":"unformatted",
00162 f__external?"external":"internal");
00163 sig_die(" IO", 1);
00164 }
|
|
|
Definition at line 195 of file err.c. References unit::ufd, unit::ufmt, unit::ufnm, and unit::uwrt.
00197 {
00198 long loc;
00199 int ufmt;
00200 extern char *f__r_mode[];
00201
00202 if (!x->ufnm)
00203 goto cantread;
00204 ufmt = x->ufmt;
00205 loc=ftell(x->ufd);
00206 if(freopen(x->ufnm,f__r_mode[ufmt],x->ufd) == NULL) {
00207 cantread:
00208 errno = 126;
00209 return(1);
00210 }
00211 x->uwrt=0;
00212 (void) fseek(x->ufd,loc,SEEK_SET);
00213 return(0);
00214 }
|
|
|
Definition at line 218 of file err.c. References close(), f__cf, fdopen(), O_WRONLY, unit::ufd, unit::ufmt, unit::ufnm, and unit::uwrt. Referenced by s_wdfe(), s_wdue(), s_wsfe(), s_wsle(), s_wsne(), and s_wsue().
00220 {
00221 long loc;
00222 int ufmt;
00223 extern char *f__w_mode[];
00224 #ifndef NON_UNIX_STDIO
00225 int k;
00226 #endif
00227
00228 if (!x->ufnm)
00229 goto cantwrite;
00230 ufmt = x->ufmt;
00231 #ifdef NON_UNIX_STDIO
00232 ufmt |= 2;
00233 #endif
00234 if (x->uwrt == 3) { /* just did write, rewind */
00235 #ifdef NON_UNIX_STDIO
00236 if (!(f__cf = x->ufd =
00237 freopen(x->ufnm,f__w_mode[ufmt],x->ufd)))
00238 #else
00239 if (close(creat(x->ufnm,0666)))
00240 #endif
00241 goto cantwrite;
00242 }
00243 else {
00244 loc=ftell(x->ufd);
00245 #ifdef NON_UNIX_STDIO
00246 if (!(f__cf = x->ufd =
00247 freopen(x->ufnm, f__w_mode[ufmt], x->ufd)))
00248 #else
00249 if (fclose(x->ufd) < 0
00250 || (k = x->uwrt == 2 ? creat(x->ufnm,0666)
00251 : open(x->ufnm,O_WRONLY)) < 0
00252 || (f__cf = x->ufd = fdopen(k,f__w_mode[ufmt])) == NULL)
00253 #endif
00254 {
00255 x->ufd = NULL;
00256 cantwrite:
00257 errno = 127;
00258 return(1);
00259 }
00260 (void) fseek(x->ufd,loc,SEEK_SET);
00261 }
00262 x->uwrt = 1;
00263 return(0);
00264 }
|
|
|
Definition at line 167 of file err.c. References f__canseek(), f__init, malloc, p, unit::ufd, unit::ufmt, unit::useek, and unit::uwrt.
00168 { unit *p;
00169
00170 f__init=1;
00171 p= &f__units[0];
00172 p->ufd=stderr;
00173 p->useek=f__canseek(stderr);
00174 #ifdef NON_UNIX_STDIO
00175 setbuf(stderr, (char *)malloc(BUFSIZ));
00176 #else
00177 stderr->_flag &= ~_IONBF;
00178 #endif
00179 p->ufmt=1;
00180 p->uwrt=1;
00181 p = &f__units[5];
00182 p->ufd=stdin;
00183 p->useek=f__canseek(stdin);
00184 p->ufmt=1;
00185 p->uwrt=0;
00186 p= &f__units[6];
00187 p->ufd=stdout;
00188 p->useek=f__canseek(stdout);
00189 p->ufmt=1;
00190 p->uwrt=1;
00191 }
|
Variable Documentation
|
|
|
|
|
Definition at line 41 of file err.c. Referenced by f__nowwriting(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 29 of file err.c. Referenced by f__fatal(). |
|
|
Definition at line 28 of file err.c. Referenced by e_rsfe(), e_wsfe(), and f__fatal(). |
|
|
Definition at line 40 of file err.c. Referenced by f__fatal(). |
|
|
|
|
|
Definition at line 44 of file err.c. Referenced by s_wsfe(), x_putc(), x_wSL(), xw_end(), and xw_rev(). |
|
|
Definition at line 45 of file err.c. Referenced by mv_cur(). |
|
|
Definition at line 23 of file err.c. Referenced by f_init(). |
|
|
|
|
|
Definition at line 26 of file err.c. Referenced by f__fatal(). |
|
|
Definition at line 43 of file err.c. Referenced by c_lir(), i_getc(), and i_ungetc(). |
|
|
|
|
|
Definition at line 39 of file err.c. Referenced by f__fatal(). |
|
|
|
|
|
|
|
|
Definition at line 48 of file err.c. Referenced by f__fatal(). |