1 #ifndef  ELIOP_H
2 #define  ELIOP_H
3 
4 #ifdef WIN32
5 #include <io.h>
6 #ifndef __MINGW32__
7 /* #include "winutil.h" */
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(SP) || defined(SP1))
31 #define PIOFS 1
32 #endif
33 
34 
35 #if (defined(CRAY) && !defined(__crayx1))
36 #        include <sys/statfs.h>
37 #        define  STATVFS statfs
38 #elif defined(__FreeBSD__) && !defined(GLIBC)
39 #        include <sys/param.h>
40 #        include <sys/mount.h>
41 #        define  STATVFS statfs
42 #        define NO_F_FRSIZE
43 #elif defined(WIN32)
44 #        define  STATVFS _stat
45 #        define  S_ISDIR(mode) ((mode&S_IFMT) == S_IFDIR)
46 #        define  S_ISREG(mode) ((mode&S_IFMT) == S_IFREG)
47 #elif defined(LINUX)  ||  defined(CYGWIN) || defined(BGQ) || defined(__GLIBC__)
48 #        include <sys/vfs.h>
49 #        define  STATVFS statfs
50 #        define NO_F_FRSIZE
51 #else
52 #        include <sys/statvfs.h>
53 #        define  STATVFS statvfs
54 #endif
55 
56 #ifdef WIN32
57 #include <windows.h>
58 #else
59 #include <unistd.h>
60 #endif
61 
62 #include <fcntl.h>
63 
64 #if (defined(CRAY) && defined(FFIO))
65 #        include <ffio.h>
66 #        include <sys/fstyp.h>
67 #        include <sys/fsid.h>
68 #endif
69 
70 
71 #include "elio.h"
72 #include "pablo.h"
73 
74 extern int                   _elio_Errors_Fatal;
75 extern void                  elio_init(void);
76 extern int                   elio_pending_error;
77 
78 
79 #if !defined(PRINT_AND_ABORT)
80 #   if defined(SUN)
81       extern int fprintf();
82       extern void fflush();
83 #   endif
84 #   define PRINT_AND_ABORT(msg, val){\
85      fprintf(stderr, "ELIO fatal error: %s %ld\n", msg,  val);\
86      fprintf(stdout, "ELIO fatal error: %s %ld\n", msg,  val);\
87      fflush(stdout);\
88      exit(val);\
89    }
90 #endif
91 
92 /**************************** Error Macro ******************************/
93 /* ELIO defines error macro called in case of error
94  * the macro can also use user-provided error routine PRINT_AND_ABORT
95  * defined as macro to do some cleanup in the application before
96  * aborting
97  * The requirement is that PRINT_AND_ABORT is defined before
98  * including ELIO header file - this file
99  */
100 
101 #define ELIO_ERROR_NULL(code, val){\
102  PABLO_end(pablo_code);\
103  if(! _elio_Errors_Fatal){\
104      elio_pending_error= code;\
105      return NULL;\
106  }\
107  if( _elio_Errors_Fatal)\
108      PRINT_AND_ABORT(errtable[code-OFFSET], val);\
109 }
110 
111 #define ELIO_ERROR(code, val) { \
112  PABLO_end(pablo_code);\
113  if(! _elio_Errors_Fatal) return(code);\
114  else PRINT_AND_ABORT(errtable[code-OFFSET], val);\
115 }
116 
117 
118 /* error codes and messages */
119 
120 #define ERRLEN 26
121 #define OFFSET    (-2000)
122 #define SEEKFAIL  (OFFSET + 0)
123 #define WRITFAIL  (OFFSET + 1)
124 #define AWRITFAIL (OFFSET + 2)
125 #define READFAIL  (OFFSET + 3)
126 #define AREADFAIL (OFFSET + 4)
127 #define SUSPFAIL  (OFFSET + 5)
128 #define HANDFAIL  (OFFSET + 6)
129 #define MODEFAIL  (OFFSET + 7)
130 #define DIRFAIL   (OFFSET + 8)
131 #define STATFAIL  (OFFSET + 9)
132 #define OPENFAIL  (OFFSET + 10)
133 #define ALOCFAIL  (OFFSET + 11)
134 #define UNSUPFAIL (OFFSET + 12)
135 #define DELFAIL   (OFFSET + 13)
136 #define CLOSFAIL  (OFFSET + 14)
137 #define INTRFAIL  (OFFSET + 15)
138 #define RETUFAIL  (OFFSET + 16)
139 #define LONGFAIL  (OFFSET + 17)
140 #define FTYPFAIL  (OFFSET + 18)
141 #define CONVFAIL  (OFFSET + 19)
142 #define TYPEFAIL  (OFFSET + 20)
143 #define PROBFAIL  (OFFSET + 21)
144 #define TRUNFAIL  (OFFSET + 22)
145 #define EOFFAIL   (OFFSET + 23)
146 #define FSYNCFAIL (OFFSET + 24)
147 #define UNKNFAIL  (OFFSET + 25)
148 
149 extern  char *errtable[ERRLEN];
150 
151 #define ELIO_FILENAME_MAX 1024
152 #define SDIRS_INIT_SIZE 1024
153 
154 #endif
155