00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __UT_MBSDUtil_h__
00023 #define __UT_MBSDUtil_h__
00024
00025 #include "UT_API.h"
00026
00027
00028
00029 #if defined(MBSD)
00030
00031 #include <sched.h>
00032 #include <signal.h>
00033 #include <fcntl.h>
00034 #include <time.h>
00035 #include <math.h>
00036 #include <errno.h>
00037 #include <sys/types.h>
00038 #include <sys/socket.h>
00039 #include <sys/time.h>
00040 #include <SYS/SYS_Types.h>
00041
00042
00043
00044
00045 #define PR_SADDR 1
00046 #define MP_NPROCS 0
00047 #ifndef SO_REUSEPORT
00048 #define SO_REUSEPORT SO_REUSEADDR
00049 #endif
00050 #ifndef SIGCLD
00051 #define SIGCLD SIGCHLD
00052 #endif
00053
00054
00055 #define CONF_INITUSERS 1
00056
00057 #define FNONBLK FNONBLOCK
00058
00059 #define ffloor(x) floorf(x)
00060 #define fceil(x) ceilf(x)
00061 #define fatan2(a,b) atan2(a,b)
00062 #define fcos(x) cosf(x)
00063 #define fsin(x) sinf(x)
00064 #define sigset(a,b) signal(a,b)
00065 #define sighold(a)
00066 #define sigrelse(a)
00067 #define sigignore(a)
00068 #define oserror() errno
00069
00070 #ifndef CLK_TCK
00071 #define CLK_TCK CLOCKS_PER_SEC
00072 #endif
00073
00074 #define sginap(a) UTnap(a*10)
00075
00076
00077 class UT_WorkArgs;
00078 class UT_ExtensionList;
00079
00080
00081
00082
00083 UT_API long UTnap(long ms);
00084
00085 UT_API void cftime (char *dest, char *fmt, time_t *now);
00086
00087 UT_API pid_t sproc (void (*)(void *), unsigned int flags = 0, void *args = 0);
00088
00089 UT_API int sysmp (int val, ...);
00090
00091 UT_API int msgctl (int msgid, int cmd);
00092 UT_API int usconfig (int flag, int data);
00093
00094 UT_API int fp_class_f (fpreal32 f);
00095
00096 UT_API extern void UTclearHostnameCache();
00097 UT_API extern int UTgethostname(char *host, int len);
00098
00099 UT_API void MBSDregisterThread();
00100
00101 UT_API int MBSDLaunchApp(UT_WorkArgs& args);
00102
00103 UT_API void MBSDLoadURL(const char* url);
00104
00105 UT_API void MBSDAddImageAndMovieExtensions(UT_ExtensionList & extension_list);
00106
00107
00108
00109 class UT_API UT_ObjCRef
00110 {
00111 public:
00112 inline UT_ObjCRef() : myObjectPointer(NULL) {}
00113 inline UT_ObjCRef(void * pointer) : myObjectPointer(NULL) { setPointer(pointer); }
00114 inline UT_ObjCRef(long int) : myObjectPointer(NULL) {}
00115 inline UT_ObjCRef(int) : myObjectPointer(NULL) {}
00116 inline UT_ObjCRef(const UT_ObjCRef & other) : myObjectPointer(NULL) { setPointer(other.myObjectPointer); }
00117
00118 inline ~UT_ObjCRef() { setPointer(NULL); }
00119
00120 #ifdef __OBJC__
00121 inline UT_ObjCRef(id object) : myObjectPointer(NULL) { setPointer((void*)object); }
00122
00123 inline operator id() { return (id)myObjectPointer; }
00124 inline UT_ObjCRef & operator=(id object) { setPointer((void*)object); return *this; }
00125 #else
00126 inline operator void * () { return myObjectPointer; }
00127 inline operator long () { return (long)myObjectPointer; }
00128 #endif
00129
00130 inline bool operator!() const { return myObjectPointer==NULL; }
00131 inline bool operator>(int value) const { return (long)myObjectPointer > (long)value; }
00132 inline bool operator==(int value) const { return (long)myObjectPointer == (long)value; }
00133 inline bool operator!=(int value) const { return (long)myObjectPointer != (long)value; }
00134 inline bool operator==(void*ptr) const { return myObjectPointer == ptr; }
00135 inline bool operator!=(const UT_ObjCRef & other) const
00136 {
00137 return myObjectPointer != other.myObjectPointer;
00138 }
00139 inline bool operator==(const UT_ObjCRef & other) const
00140 {
00141 return myObjectPointer == other.myObjectPointer;
00142 }
00143
00144 private:
00145
00146 void setPointer(void * pointer);
00147
00148 void * myObjectPointer;
00149 };
00150
00151 #ifdef __OBJC__
00152
00153 #import <Foundation/Foundation.h>
00154
00155 class UT_String;
00156
00157 NSString * MBSDconvertString(const UT_String & ut_string);
00158 UT_String MBSDconvertString(NSString * string);
00159
00160 NSString * UTstackTraceForException(NSException * exception);
00161
00162 #endif
00163
00164 #endif // MBSD
00165
00166 #endif // __UT_MBSDUtil_h__