00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FXEXDEFS_H
00023 #define FXEXDEFS_H
00024
00025
00026 #ifndef FXDEFS_H
00027 #include <fox/fxdefs.h>
00028
00029
00030
00031
00032 using namespace FX;
00033 #endif
00034
00035
00036
00037 #if defined(WIN32) && defined(_MSC_VER)
00038 #pragma warning (disable : 4231)
00039 #endif
00040
00041
00042
00043 #ifndef CALLBACK
00044 #define CALLBACK
00045 #endif
00046
00047
00048
00049
00050
00051
00052
00053 namespace FXEX {
00054
00055
00056 #ifdef WIN32
00057 #ifdef FOXDLL
00058 #ifndef FOXDLL_EXPORTS
00059 #define FXEXTERN extern
00060 #endif
00061 #endif
00062 #endif
00063
00064 #ifndef FXEXTERN
00065 #define FXEXTERN
00066 #endif
00067
00068
00069
00070 #define COMPRESS_MAX 9
00071 #define COMPRESS_NORMAL 6
00072 #define COMPRESS_FAST 1
00073 #define COMPRESS_NONE 0
00074
00075
00076
00077 #ifndef WIN32
00078 # define INFINITE (-1)
00079 #endif
00080
00081
00082
00083 #ifdef WIN32
00084 #define FXNEWLINE "\r\n"
00085 #endif
00086 #ifdef MAC
00087 #define FXNEWLINE "\r"
00088 #endif
00089 #ifndef FXNEWLINE
00090 #define FXNEWLINE "\n"
00091 #endif
00092
00093
00094
00095 #define MKUSHORT(l,h) ((((FX::FXuchar)(l))&0xff) | (((FX::FXuchar)(h))<<8))
00096
00097
00098 #ifdef FX_LONG
00099 # define MKULONG(l,h) ((((FX::FXuint)(l))&0xffffffff) | (((FX::FXuint)(h))<<32))
00100 #else
00101 # if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
00102 # error "You wanted 64bit file sizes (actually 63), but I couldn't make it so..."
00103 # endif
00104 #endif
00105
00106
00107
00108
00109
00110
00111 #define FXDeclare(Class) \
00112 FXDECLARE(Class)
00113 #define FXDeclareAbstract(Class) \
00114 FXDECLARE_ABSTRACT(Class)
00115 #define FXDefMap(Class) \
00116 FXDEFMAP(Class) Class##Map[]
00117 #define FXImplementAbstract(Class,Parent) \
00118 FXIMPLEMENT_ABSTRACT(Class,Parent,Class##Map,ARRAYNUMBER(Class##Map))
00119 #define FXImplement(Class,Parent) \
00120 FXIMPLEMENT(Class,Parent,Class##Map,ARRAYNUMBER(Class##Map))
00121 #define FXFuncDecl(Func) \
00122 long on##Func (FXObject*,FXSelector,void*)
00123 #define FXFuncImpl(Class,Func,tgt,sel,ptr) \
00124 long Class::on##Func (FXOject *tgt,FXSelector sel, void *ptr)
00125 #define FXMapTypes(Class,FromType,ToType,Func) \
00126 FXMAPTYPES(SEL_##FromType,SEL_##ToType,Class::on##Func)
00127 #define FXMapType(Class,SelType,Func) \
00128 FXMAPTYPE(SEL_##SelType,Class::on##Func)
00129 #define FXMapFuncs(Class,SelType,FromId,ToId,Func) \
00130 FXMAPFUNCS(SEL_##SelType,Class::ID_##FromId,Class::ID_##ToId,Class::on#Func)
00131 #define FXMapFunc(Class,SelType,Id,Func) \
00132 FXMAPFUNC(SEL_##SelType,Class::ID_##Id,Class::on##Func)
00133
00134
00135
00136 #define FXSEND(tgt,sel,msg,ptr) \
00137 (tgt->handle(this,FXSEL(sel,msg),ptr)
00138 #define FXROUTE(src,tgt,sel,msg,ptr) \
00139 (tgt->handle(src,FXSEL(sel,msg),ptr)
00140
00141
00142
00143 #ifndef NDEBUG
00144 # define FXCTOR() fxtrace (100,"%s::%s %p\n",getClassName(),getClassName(),this)
00145 # define FXMETHOD(methodname) fxtrace (100,"%s::%s %p\n",getClassName(),#methodname,this)
00146 # define FXDTOR() fxtrace (100,"%s::~%s %p\n",getClassName(),getClassName(),this)
00147 #else
00148 # define FXCTOR()
00149 # define FXMETHOD(methodname)
00150 # define FXDTOR()
00151 #endif
00152
00153
00154
00155 enum {
00156 SEL_DATA=FX::SEL_LAST,
00157 SEL_THREAD,
00158 SEL_WAITABLE_WAIT,
00159 SEL_WAITABLE_ACTIVATE,
00160 SEL_INTERLOCK,
00161 SEL_BARRIER_LOCK,
00162 SEL_BARRIER_UNLOCK,
00163 SEL_INPUT,
00164 SEL_OUTPUT,
00165 SEL_ERROR,
00166 SEL_IO,
00167 SEL_IO_CONNECT,
00168 SEL_EVENT,
00169 SEL_BEGIN,
00170 SEL_END,
00171 SEL_TAG,
00172 SEL_CONTENT,
00173 SEL_REGISTRY,
00174 SEL_LASTEX
00175 };
00176
00177
00178
00179 typedef FXint FXIOStatus;
00180 enum {
00181 FXIOStatusUnknown=-2,
00182 FXIOStatusError=-1,
00183 FXIOStatusOk=0,
00184 FXIOStatusOK=0,
00185 FXIOStatusLast
00186 };
00187 #ifndef INVALID_HANDLE
00188 # ifdef WIN32
00189 # define INVALID_HANDLE INVALID_HANDLE_VALUE
00190 # else
00191 # define INVALID_HANDLE -1
00192 # endif
00193 #endif
00194
00195 #ifndef VALID_RESULT
00196 # define VALID_RESULT 0
00197 #endif
00198
00199
00200
00201 typedef FXint FXIOState;
00202 enum {
00203 FXIOStateUnknown=-1,
00204 FXIOStateNone=-1,
00205 FXIOStateOk=0,
00206 FXIOStateOK=0,
00207 FXIOStateUnconnected,
00208 FXIOStateConnected,
00209 FXIOStateOpen=FXIOStateConnected,
00210 FXIOStateListener,
00211 FXIOStateAccepted,
00212 FXIOStateDuplicated,
00213 FXIOStateLast
00214 };
00215
00216
00217
00218
00219
00220
00221 enum FXSocketType {
00222 FXSocketTypeNone=0,
00223 FXSocketTypeStream,
00224 FXSocketTypeTCP=FXSocketTypeStream,
00225 FXSocketTypeDatagram,
00226 FXSocketTypeUDP=FXSocketTypeDatagram,
00227 };
00228
00229
00230 enum FXSocketFamily {
00231 FXSocketFamilyNone=0,
00232 FXSocketFamilyLocal,
00233 FXSocketFamilyInet,
00234 FXSocketFamilyInet6,
00235 FXSocketFamilyAutomatic,
00236
00237 FXSocketFamilyUnix=FXSocketFamilyLocal
00238 };
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260 enum FXFilePermission {
00261 FILEPERM_NONE = 0,
00262 FILEPERM_USER_READ = 0x00000001,
00263 FILEPERM_USER_WRITE = 0x00000002,
00264 FILEPERM_USER_EXEC = 0X00000004,
00265 FILEPERM_GROUP_READ = 0x00000010,
00266 FILEPERM_GROUP_WRITE = 0x00000020,
00267 FILEPERM_GROUP_EXEC = 0x00000040,
00268 FILEPERM_OTHER_READ = 0x00000100,
00269 FILEPERM_OTHER_WRITE = 0x00000200,
00270 FILEPERM_OTHER_EXEC = 0x00000400,
00271 FILEPERM_READ = 0x00000111,
00272 FILEPERM_WRITE = 0x00000222,
00273 FILEPERM_EXEC = 0x00000444,
00274 FILEPERM_ALL = 0x00000777,
00275 FILEPERM_SET_UID = 0x00001000,
00276 FILEPERM_SET_GID = 0x00002000,
00277 FILEPERM_STICKY = 0x00004000,
00278 FILEPERM_SECURE_IO = FILEPERM_USER_READ|FILEPERM_USER_WRITE,
00279 FILEPERM_DEFAULT_IO = FILEPERM_READ|FILEPERM_USER_WRITE|FILEPERM_GROUP_WRITE,
00280 FILEPERM_DEFAULT_EXEC = FILEPERM_READ|FILEPERM_USER_WRITE|FILEPERM_GROUP_WRITE|FILEPERM_EXEC,
00281 };
00282
00283
00284
00285 #ifndef WIN32
00286 typedef void* FXThreadHandle;
00287 typedef void* FXThreadMutex;
00288 typedef void* FXThreadCondition;
00289 typedef void* FXThreadSemaphore;
00290 typedef FXInputHandle* FXThreadEventHandle;
00291 #else
00292 typedef HANDLE FXThreadHandle;
00293 typedef HANDLE FXThreadMutex;
00294 typedef HANDLE FXThreadCondition;
00295 typedef HANDLE FXThreadSemaphore;
00296 typedef FXInputHandle FXThreadEventHandle;
00297 #endif
00298
00299
00300
00301 #ifndef WIN32
00302 typedef void* FXDLLHandle;
00303 #else
00304 typedef HMODULE FXDLLHandle;
00305 #endif
00306
00307
00308
00309
00310
00311
00312 namespace FXUtils {
00313
00314
00315
00316
00317 extern FXAPI const FXuchar fxexversion[3];
00318
00319
00320
00321
00322
00323 #ifdef WIN32
00324 static void get_time_now(unsigned long* abs_sec, unsigned long* abs_nsec);
00325 static DWORD get_timeout(unsigned long secs, unsigned long nsecs,DWORD default_to);
00326 #else
00327 void convert_timeval(struct timeval *tv,FXuint ms);
00328 void convert_timespec(struct timespec *ts,FXuint ms);
00329 #endif
00330
00331 };
00332 };
00333
00334 #endif // FXEXDEFS_H
00335