| 1 |
#ifndef ELIOP_H |
| 2 |
#define ELIOP_H |
| 3 |
|
| 4 |
#ifdef WIN32 |
| 5 |
#include <io.h> |
| 6 |
#ifndef __MINGW32__ |
| 7 |
|
| 8 |
#endif |
| 9 |
#define F_OK 00 |
| 10 |
#endif |
| 11 |
|
| 12 |
#include <errno.h> |
| 13 |
|
| 14 |
#if HAVE_STDLIB_H |
| 15 |
#include <stdlib.h> |
| 16 |
#endif |
| 17 |
#if HAVE_STRING_H |
| 18 |
#include <string.h> |
| 19 |
#endif |
| 20 |
|
| 21 |
#include <sys/types.h> |
| 22 |
#include <sys/stat.h> |
| 23 |
#include "typesf2c.h" |
| 24 |
|
| 25 |
#define PRINT_AND_ABORT(msg, val) GA_Error(msg, (int)val) |
| 26 |
#ifndef GLOBAL_H |
| 27 |
extern void GA_Error(char*, int); |
| 28 |
#endif |
| 29 |
|
| 30 |
#if defined(__FreeBSD__) && !defined(GLIBC) |
| 31 |
# include <sys/param.h> |
| 32 |
# include <sys/mount.h> |
| 33 |
# define STATVFS statfs |
| 34 |
# define NO_F_FRSIZE |
| 35 |
#elif defined(WIN32) |
| 36 |
# define STATVFS _stat |
| 37 |
# define S_ISDIR(mode) ((mode&S_IFMT) == S_IFDIR) |
| 38 |
# define S_ISREG(mode) ((mode&S_IFMT) == S_IFREG) |
| 39 |
#elif defined(LINUX) || defined(CYGWIN) || defined(__GLIBC__) |
| 40 |
# include <sys/vfs.h> |
| 41 |
# define STATVFS statfs |
| 42 |
# define NO_F_FRSIZE |
| 43 |
#else |
| 44 |
# include <sys/statvfs.h> |
| 45 |
# define STATVFS statvfs |
| 46 |
#endif |
| 47 |
|
| 48 |
#ifdef WIN32 |
| 49 |
#include <windows.h> |
| 50 |
#else |
| 51 |
#include <unistd.h> |
| 52 |
#endif |
| 53 |
|
| 54 |
#include <fcntl.h> |
| 55 |
|
| 56 |
#if defined(FFIO) |
| 57 |
# include <ffio.h> |
| 58 |
# include <sys/fstyp.h> |
| 59 |
# include <sys/fsid.h> |
| 60 |
#endif |
| 61 |
|
| 62 |
|
| 63 |
#include "elio.h" |
| 64 |
#include "pablo.h" |
| 65 |
|
| 66 |
extern int _elio_Errors_Fatal; |
| 67 |
extern void elio_init(void); |
| 68 |
extern int elio_pending_error; |
| 69 |
|
| 70 |
|
| 71 |
#if !defined(PRINT_AND_ABORT) |
| 72 |
# define PRINT_AND_ABORT(msg, val){\ |
| 73 |
fprintf(stderr, "ELIO fatal error: %s %ld\n", msg, val);\ |
| 74 |
fprintf(stdout, "ELIO fatal error: %s %ld\n", msg, val);\ |
| 75 |
fflush(stdout);\ |
| 76 |
exit(val);\ |
| 77 |
} |
| 78 |
#endif |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
#define ELIO_ERROR_NULL(code, val){\ |
| 90 |
PABLO_end(pablo_code);\ |
| 91 |
if(! _elio_Errors_Fatal){\ |
| 92 |
elio_pending_error= code;\ |
| 93 |
return NULL;\ |
| 94 |
}\ |
| 95 |
if( _elio_Errors_Fatal)\ |
| 96 |
PRINT_AND_ABORT(errtable[code-OFFSET], val);\ |
| 97 |
} |
| 98 |
|
| 99 |
#define ELIO_ERROR(code, val) { \ |
| 100 |
PABLO_end(pablo_code);\ |
| 101 |
if(! _elio_Errors_Fatal) return(code);\ |
| 102 |
else PRINT_AND_ABORT(errtable[code-OFFSET], val);\ |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
#define ERRLEN 26 |
| 109 |
#define OFFSET (-2000) |
| 110 |
#define SEEKFAIL (OFFSET + 0) |
| 111 |
#define WRITFAIL (OFFSET + 1) |
| 112 |
#define AWRITFAIL (OFFSET + 2) |
| 113 |
#define READFAIL (OFFSET + 3) |
| 114 |
#define AREADFAIL (OFFSET + 4) |
| 115 |
#define SUSPFAIL (OFFSET + 5) |
| 116 |
#define HANDFAIL (OFFSET + 6) |
| 117 |
#define MODEFAIL (OFFSET + 7) |
| 118 |
#define DIRFAIL (OFFSET + 8) |
| 119 |
#define STATFAIL (OFFSET + 9) |
| 120 |
#define OPENFAIL (OFFSET + 10) |
| 121 |
#define ALOCFAIL (OFFSET + 11) |
| 122 |
#define UNSUPFAIL (OFFSET + 12) |
| 123 |
#define DELFAIL (OFFSET + 13) |
| 124 |
#define CLOSFAIL (OFFSET + 14) |
| 125 |
#define INTRFAIL (OFFSET + 15) |
| 126 |
#define RETUFAIL (OFFSET + 16) |
| 127 |
#define LONGFAIL (OFFSET + 17) |
| 128 |
#define FTYPFAIL (OFFSET + 18) |
| 129 |
#define CONVFAIL (OFFSET + 19) |
| 130 |
#define TYPEFAIL (OFFSET + 20) |
| 131 |
#define PROBFAIL (OFFSET + 21) |
| 132 |
#define TRUNFAIL (OFFSET + 22) |
| 133 |
#define EOFFAIL (OFFSET + 23) |
| 134 |
#define FSYNCFAIL (OFFSET + 24) |
| 135 |
#define UNKNFAIL (OFFSET + 25) |
| 136 |
|
| 137 |
extern char *errtable[ERRLEN]; |
| 138 |
|
| 139 |
#define ELIO_FILENAME_MAX 1024 |
| 140 |
#define SDIRS_INIT_SIZE 1024 |
| 141 |
|
| 142 |
#endif |