00001 #ifndef PORTABILITY_GROUP
00002 #define PORTABILITY_GROUP
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "array.h"
00019
00021
00027
00028 class char_star_array;
00029
00030
00031
00032 #ifdef __UNIX__
00033 #include <unistd.h>
00034 #endif
00035 #ifndef NO_XWINDOWS
00036 #ifdef __XWINDOWS__
00037 #include <Intrinsic.h>
00038 #include <StringDefs.h>
00039 #include <Xm/Xm.h>
00040 #include <Xlib.h>
00041 #endif
00042 #endif
00043 #ifdef __WIN32__
00044 #ifndef STRICT
00045 #define STRICT
00046 #endif
00047
00048 #ifndef _AFXDLL
00049
00050
00051 #include <windows.h>
00052 #else
00053 #include <afx.h>
00054 #include <afxwin.h>
00055 #endif
00056
00057 #undef FD_SETSIZE
00058 #define FD_SETSIZE 1000
00059
00060 #include <winsock2.h>
00061 #endif
00062
00063
00064 struct timeval;
00065 class version;
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 #ifdef __UNIX__
00076
00077
00078
00079 typedef void *application_instance;
00080
00081
00082 #ifndef LONGINT_SIZE
00083 #if defined(__alpha) || (defined(__HOS_AIX__) && defined(_LP64)) \
00084 || defined(__sparcv9) || defined(__LP64__)
00085 #define LONGINT_SIZE 8
00086 #else
00087 #define LONGINT_SIZE 4
00088 #endif
00089 #endif
00090 #if (LONGINT_SIZE == 4)
00091
00092 typedef unsigned long DWORD;
00093 #else
00094 typedef unsigned int DWORD;
00095 #endif
00096
00097 typedef void *HANDLE;
00098
00099
00100 typedef void *ATOM;
00101 typedef void *BITMAPINFO;
00102 typedef void *HBITMAP;
00103 typedef void *HDC;
00104 typedef void *RGBQUAD;
00105 #define LoadBitmap(a, b) (a)
00106 #define __stdcall
00107 #define afx_msg
00108
00109
00110 #ifndef NO_XWINDOWS // protects regions with similar names.
00111 #ifdef __XWINDOWS__
00112 typedef Widget window_handle;
00114
00115 typedef Colormap window_colormap;
00117
00118 typedef XColor window_color;
00120
00121 typedef XmString window_string;
00123
00124
00125 const int MAXIMUM_COLOR_INTENSITY = 65535;
00126
00127 #else
00128
00129 typedef void *window_handle;
00130 #endif
00131 #endif
00132 #endif
00133
00134 #ifdef __WIN32__
00135 typedef HINSTANCE application_instance;
00136
00137
00138 typedef HWND window_handle;
00139
00140 #endif
00141
00142
00143
00144 namespace portable {
00145
00146
00147
00148 version get_OS_version();
00150
00153 u_int process_id();
00155
00156 istring current_directory();
00158
00159 istring application_name();
00161
00162 istring module_name(const void *module_handle = NIL);
00164
00166 u_int system_uptime();
00168
00169 double rolling_uptime();
00171
00172 void sleep_ms(u_int msec);
00174
00178 istring env_string(const istring &variable_name);
00180
00185 bool set_environ(const istring &variable_name, const istring &value);
00187
00190 u_int system_error();
00192
00193 istring system_error_text(u_int error_to_show);
00195
00197 istring null_device();
00199
00202 char_star_array break_line(istring &app, const istring ¶meters);
00204
00208 enum process_launch_flags {
00209 HIDE_APP_WINDOW = 0x1,
00211 AWAIT_APP_EXIT = 0x2,
00213 RETURN_IMMEDIATELY = 0x4,
00215 AWAIT_VIA_POLLING = 0x8,
00217 SHELL_EXECUTE = 0x10
00219 };
00220
00221 u_int launch_process(const istring &app_name, const istring &command_line,
00222 int flag, u_int &child_id);
00224
00234 timeval fill_timeval_ms(int milliseconds);
00236
00240
00241 extern application_instance _i_handle;
00243 #define DEFINE_INSTANCE_HANDLE application_instance portable::_i_handle = 0
00245
00247 #define SET_INSTANCE_HANDLE(value) portable::_i_handle = value
00249
00250 #define GET_INSTANCE_HANDLE() portable::_i_handle
00252
00254
00255
00256 #ifdef __UNIX__
00257 istring get_cmdline_from_proc();
00259
00260 char *itoa(int to_convert, char *buffer, int radix);
00262
00268 #define RGB(r, g, b) (b + (g << 8) + (r << 16))
00270 #endif
00271
00272
00273 #ifdef __WIN32__
00274
00275 bool event_poll(MSG &message);
00277
00282
00283 bool is_address_valid(const void *address, int size_expected,
00284 bool writable = false);
00286
00290 #define BROADCAST_HANDLE HWND_BROADCAST
00291
00292 bool has_win95_style_shell();
00294
00298 enum known_operating_systems { WIN_95, WIN_NT, WIN_2K, WIN_XP, UNKNOWN_OS };
00299 known_operating_systems determine_OS();
00301
00303 istring rc_string(u_int id, application_instance instance);
00305
00308 istring rc_string(u_int id);
00310
00313 void show_wait_cursor();
00315 void show_normal_cursor();
00317
00318 #endif // win32.
00319
00320 }
00321
00323 class char_star_array : public array<char *>
00324 {
00325 public:
00326 inline char_star_array() : array<char *>(0, NIL, SIMPLE_COPY | EXPONE
00327 | FLUSH_INVISIBLE) {}
00328 inline ~char_star_array() {
00329
00330 for (int i = 0; i < length(); i++) {
00331 delete [] (use(i));
00332 }
00333 }
00334 };
00335
00336 #endif // outer guard.
00337