|
WizardsToolkit
1.0.7
|
00001 /* 00002 Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization 00003 dedicated to making software imaging solutions freely available. 00004 00005 You may not use this file except in compliance with the License. 00006 obtain a copy of the License at 00007 00008 http://www.wizards-toolkit.org/script/license.php 00009 00010 Unless required by applicable law or agreed to in writing, software 00011 distributed under the License is distributed on an "AS IS" BASIS, 00012 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 See the License for the specific language governing permissions and 00014 limitations under the License. 00015 00016 Wizard's Toolkit methods. 00017 */ 00018 #ifndef _WIZARDSTOOLKIT_STUDIO_H 00019 #define _WIZARDSTOOLKIT_STUDIO_H 00020 00021 #if defined(__cplusplus) || defined(c_plusplus) 00022 extern "C" { 00023 #endif 00024 00025 #if defined(WIN32) || defined(WIN64) 00026 # define WIZARDSTOOLKIT_WINDOWS_SUPPORT 00027 #else 00028 # define WIZARDSTOOLKIT_POSIX_SUPPORT 00029 #endif 00030 00031 #if !defined(_WIZARDSTOOLKIT_CONFIG_H) 00032 # define _WIZARDSTOOLKIT_CONFIG_H 00033 # if !defined(vms) && !defined(macintosh) 00034 # include "wizard/wizard-config.h" 00035 # else 00036 # include "wizard-config.h" 00037 # endif 00038 #if defined(_WIZARDSTOOLKIT__FILE_OFFSET_BITS) && !defined(_FILE_OFFSET_BITS) 00039 # define _FILE_OFFSET_BITS _WIZARDSTOOLKIT__FILE_OFFSET_BITS 00040 #endif 00041 #if defined(_wizardstoolkit_const) && !defined(const) 00042 # define const _wizardstoolkit_const 00043 #endif 00044 #if defined(_wizardstoolkit_inline) && !defined(inline) 00045 # define inline _wizardstoolkit_inline 00046 #endif 00047 # if defined(_wizardstoolkit_restrict) && !defined(restrict) 00048 # define restrict _wizardstoolkit_restrict 00049 # endif 00050 # if defined(__cplusplus) || defined(c_plusplus) 00051 # undef inline 00052 # endif 00053 #endif 00054 00055 #if !defined(const) 00056 # define STDC 00057 #endif 00058 00059 #if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT) || defined(__CYGWIN__) || defined(__MINGW32__) 00060 # define WizardPrivate 00061 # if defined(_MT) && defined(_DLL) && !defined(_WIZARDDLL_) && !defined(_LIB) 00062 # define _WIZARDDLL_ 00063 # endif 00064 # if defined(_WIZARDDLL_) 00065 # if defined(_VISUALC_) 00066 # pragma warning( disable: 4273 ) /* Disable the dll linkage warnings */ 00067 # endif 00068 # if !defined(_WIZARDLIB_) 00069 # if defined(__GNUC__) 00070 # define WizardExport __attribute__ ((dllimport)) 00071 # else 00072 # define WizardExport __declspec(dllimport) 00073 # endif 00074 # if defined(_VISUALC_) 00075 # pragma message( "Wizard lib DLL import interface" ) 00076 # endif 00077 # else 00078 # if defined(__GNUC__) 00079 # define WizardExport __attribute__ ((dllexport)) 00080 # else 00081 # define WizardExport __declspec(dllexport) 00082 # endif 00083 # if defined(_VISUALC_) 00084 # pragma message( "Wizard lib DLL export interface" ) 00085 # endif 00086 # endif 00087 # else 00088 # define WizardExport 00089 # if defined(_VISUALC_) 00090 # pragma message( "Wizard lib static interface" ) 00091 # endif 00092 # endif 00093 00094 # if defined(_DLL) && !defined(_LIB) 00095 # define ModuleExport __declspec(dllexport) 00096 # if defined(_VISUALC_) 00097 # pragma message( "Wizard module DLL export interface" ) 00098 # endif 00099 # else 00100 # define ModuleExport 00101 # if defined(_VISUALC_) 00102 # pragma message( "Wizard module static interface" ) 00103 # endif 00104 00105 # endif 00106 # define WizardGlobal __declspec(thread) 00107 # if defined(_VISUALC_) 00108 # pragma warning(disable : 4018) 00109 # pragma warning(disable : 4068) 00110 # pragma warning(disable : 4244) 00111 # pragma warning(disable : 4142) 00112 # pragma warning(disable : 4800) 00113 # pragma warning(disable : 4786) 00114 # pragma warning(disable : 4996) 00115 # endif 00116 #else 00117 # if __GNUC__ >= 4 00118 # define WizardExport __attribute__ ((visibility ("default"))) 00119 # define WizardPrivate __attribute__ ((visibility ("hidden"))) 00120 # else 00121 # define WizardExport 00122 # define WizardPrivate 00123 # endif 00124 # define ModuleExport WizardExport 00125 # define WizardGlobal 00126 #endif 00127 #define WizardSignature 0xabacadabUL 00128 #if !defined(MaxTextExtent) 00129 # define MaxTextExtent 4096 00130 #endif 00131 00132 #include <stdarg.h> 00133 #include <stdio.h> 00134 #if defined(WIZARDSTOOLKIT_HAVE_SYS_STAT_H) 00135 # include <sys/stat.h> 00136 #endif 00137 #if defined(WIZARDSTOOLKIT_STDC_HEADERS) 00138 # include <stdlib.h> 00139 # include <stddef.h> 00140 #else 00141 # if defined(WIZARDSTOOLKIT_HAVE_STDLIB_H) 00142 # include <stdlib.h> 00143 # endif 00144 #endif 00145 #if defined(WIZARDSTOOLKIT_HAVE_STRING_H) 00146 # if !defined(STDC_HEADERS) && defined(WIZARDSTOOLKIT_HAVE_MEMORY_H) 00147 # include <memory.h> 00148 # endif 00149 # include <string.h> 00150 #endif 00151 #if defined(WIZARDSTOOLKIT_HAVE_STRINGS_H) 00152 # include <strings.h> 00153 #endif 00154 #if defined(WIZARDSTOOLKIT_HAVE_INTTYPES_H) 00155 # include <inttypes.h> 00156 #endif 00157 #if defined(WIZARDSTOOLKIT_HAVE_STDINT_H) 00158 # include <stdint.h> 00159 #endif 00160 #if defined(WIZARDSTOOLKIT_HAVE_UNISTD_H) 00161 # include <unistd.h> 00162 #endif 00163 #if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT) && defined(_DEBUG) 00164 #define _CRTDBG_MAP_ALLOC 00165 #endif 00166 #if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT) 00167 # include <direct.h> 00168 # if !defined(WIZARDSTOOLKIT_HAVE_STRERROR) 00169 # define HAVE_STRERROR 00170 # endif 00171 #endif 00172 00173 #if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT) && defined(_DEBUG) 00174 #define _CRTDBG_MAP_ALLOC 00175 #endif 00176 #if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT) 00177 # include <direct.h> 00178 # if !defined(WIZARDSTOOLKIT_HAVE_STRERROR) 00179 # define HAVE_STRERROR 00180 # endif 00181 #endif 00182 00183 #include <ctype.h> 00184 #include <locale.h> 00185 #include <errno.h> 00186 #include <fcntl.h> 00187 #include <math.h> 00188 #include <time.h> 00189 #include <limits.h> 00190 #include <signal.h> 00191 #include <assert.h> 00192 00193 #if defined(WIZARDSTOOLKIT_HAVE_XLOCALE_H) 00194 # include <xlocale.h> 00195 #endif 00196 #if defined(WIZARDSTOOLKIT_THREAD_SUPPORT) 00197 # include <pthread.h> 00198 #elif defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT) 00199 # define WIZARDSTOOLKIT_HAVE_WINTHREADS 1 00200 #include <windows.h> 00201 #endif 00202 #if defined(WIZARDSTOOLKIT_HAVE_SYS_SYSLIMITS_H) 00203 # include <sys/syslimits.h> 00204 #endif 00205 #if defined(WIZARDSTOOLKIT_HAVE_ARM_LIMITS_H) 00206 # include <arm/limits.h> 00207 #endif 00208 #if defined(_OPENMP) && (_OPENMP >= 200203) 00209 # include <omp.h> 00210 # define WIZARDSTOOLKIT_HAVE_OPENMP 1 00211 #endif 00212 00213 #if defined(WIZARDSTOOLKIT_HAVE_PREAD) && defined(WIZARDSTOOLKIT_HAVE_DECL_PREAD) && !WIZARDSTOOLKIT_HAVE_DECL_PREAD 00214 ssize_t pread(int,void *,size_t,off_t); 00215 #endif 00216 00217 #if defined(WIZARDSTOOLKIT_HAVE_PWRITE) && defined(WIZARDSTOOLKIT_HAVE_DECL_PWRITE) && !WIZARDSTOOLKIT_HAVE_DECL_PWRITE 00218 ssize_t pwrite(int,const void *,size_t,off_t); 00219 #endif 00220 00221 #if defined(WIZARDSTOOLKIT_HAVE_STRLCPY) && defined(WIZARDSTOOLKIT_HAVE_DECL_STRLCPY) && !WIZARDSTOOLKIT_HAVE_DECL_STRLCPY 00222 extern size_t strlcpy(char *,const char *,size_t); 00223 #endif 00224 00225 #if defined(WIZARDSTOOLKIT_HAVE_VSNPRINTF) && defined(WIZARDSTOOLKIT_HAVE_DECL_VSNPRINTF) && !WIZARDSTOOLKIT_HAVE_DECL_VSNPRINTF 00226 extern int vsnprintf(char *,size_t,const char *,va_list); 00227 #endif 00228 00229 #if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT) || defined(WIZARDSTOOLKIT_POSIX_SUPPORT) 00230 # include <sys/types.h> 00231 # include <sys/stat.h> 00232 # if defined(WIZARDSTOOLKIT_HAVE_FTIME) 00233 # include <sys/timeb.h> 00234 # endif 00235 # if defined(WIZARDSTOOLKIT_POSIX_SUPPORT) 00236 # if defined(WIZARDSTOOLKIT_HAVE_SYS_NDIR_H) || defined(WIZARDSTOOLKIT_HAVE_SYS_DIR_H) || defined(WIZARDSTOOLKIT_HAVE_NDIR_H) 00237 # define dirent direct 00238 # define NAMLEN(dirent) (dirent)->d_namlen 00239 # if defined(WIZARDSTOOLKIT_HAVE_SYS_NDIR_H) 00240 # include <sys/ndir.h> 00241 # endif 00242 # if defined(WIZARDSTOOLKIT_HAVE_SYS_DIR_H) 00243 # include <sys/dir.h> 00244 # endif 00245 # if defined(WIZARDSTOOLKIT_HAVE_NDIR_H) 00246 # include <ndir.h> 00247 # endif 00248 # else 00249 # include <dirent.h> 00250 # define NAMLEN(dirent) strlen((dirent)->d_name) 00251 # endif 00252 # include <pwd.h> 00253 # endif 00254 # if !defined(S_ISDIR) 00255 # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) 00256 # endif 00257 # if !defined(S_ISREG) 00258 # define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) 00259 # endif 00260 # include "wizard/wizard-type.h" 00261 # if !defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT) 00262 # include <sys/time.h> 00263 #if defined(WIZARDSTOOLKIT_HAVE_SYS_TIMES_H) 00264 # include <sys/times.h> 00265 #endif 00266 #if defined(WIZARDSTOOLKIT_HAVE_SYS_RESOURCE_H) 00267 # include <sys/resource.h> 00268 #endif 00269 # endif 00270 #else 00271 # include <types.h> 00272 # include <stat.h> 00273 # if defined(macintosh) 00274 # include <SIOUX.h> 00275 # include <console.h> 00276 # include <unix.h> 00277 # endif 00278 # include "wizard/wizard-type.h" 00279 #endif 00280 00281 #if defined(WIZARDSTOOLKIT_HAVE___ATTRIBUTE__) 00282 # define wizard_aligned(x) __attribute__((aligned(x))) 00283 # define wizard_attribute __attribute__ 00284 # define wizard_unused(x) wizard_unused_ ## x __attribute__((unused)) 00285 #else 00286 # define wizard_attribute(x) /* nothing */ 00287 # define wizard_unused(x) x 00288 #endif 00289 00290 #if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT) 00291 # include "wizard/nt-base.h" 00292 #endif 00293 #if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT) || defined(__CYGWIN__) 00294 #endif 00295 #if defined(macintosh) 00296 # include "mac.h" 00297 #endif 00298 #if defined(vms) 00299 # include "vms.h" 00300 #endif 00301 00302 #undef HAVE_CONFIG_H 00303 #undef index 00304 #undef pipe 00305 00306 #include <wizard/string_.h> 00307 00308 /* 00309 Review these platform specific definitions. 00310 */ 00311 #if defined(WIZARDSTOOLKIT_POSIX_SUPPORT) 00312 # define DirectorySeparator "/" 00313 # define DirectoryListSeparator ':' 00314 # define Exit _exit 00315 # define IsBasenameSeparator(c) ((c) == '/' ? WizardTrue : WizardFalse) 00316 # define PreferencesDefaults "~/." 00317 # define ProcessPendingEvents(text) 00318 # define ReadCommandlLine(argc,argv) 00319 # define SetNotifyHandlers 00320 #else 00321 00322 # if defined(vms) 00323 # define ApplicationDefaults "decw$system_defaults:" 00324 # define DirectorySeparator "" 00325 # define DirectoryListSeparator ';' 00326 # define Exit exit 00327 # define IsBasenameSeparator(c) \ 00328 (((c) == ']') || ((c) == ':') || ((c) == '/') ? WizardTrue : WizardFalse) 00329 # define WizardLibPath "sys$login:" 00330 # define WizardModulesPath "sys$login:" 00331 # define WizardSignaturerePath "sys$login:" 00332 # define PreferencesDefaults "decw$user_defaults:" 00333 # define ProcessPendingEvents(text) 00334 # define ReadCommandlLine(argc,argv) 00335 # define SetNotifyHandlers 00336 # endif 00337 00338 # if defined(macintosh) 00339 # define ApplicationDefaults "/usr/lib/X11/app-defaults/" 00340 # define DirectorySeparator ":" 00341 # define DirectoryListSeparator ';' 00342 # define IsBasenameSeparator(c) ((c) == ':' ? WizardTrue : WizardFalse) 00343 # define WizardLibPath "" 00344 # define WizardModulesPath "" 00345 # define WizardSignaturerePath "" 00346 # define PreferencesDefaults "~/." 00347 # define ReadCommandlLine(argc,argv) argc=ccommand(argv); puts(WizardVersion); 00348 # define SetNotifyHandlers \ 00349 SetErrorHandler(MACErrorHandler); \ 00350 SetWarningHandler(MACWarningHandler) 00351 # endif 00352 00353 # if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT) 00354 # define DirectorySeparator "\\" 00355 # define DirectoryListSeparator ';' 00356 # define IsBasenameSeparator(c) \ 00357 (((c) == '/') || ((c) == '\\') ? WizardTrue : WizardFalse) 00358 # define ProcessPendingEvents(text) 00359 #if !defined(PreferencesDefaults) 00360 # define PreferencesDefaults "~\\." 00361 #endif /* PreferencesDefaults */ 00362 # define ReadCommandlLine(argc,argv) 00363 # define SetNotifyHandlers \ 00364 SetErrorHandler(NTErrorHandler); \ 00365 SetWarningHandler(NTWarningHandler) 00366 # undef sleep 00367 # define sleep(seconds) Sleep(seconds*1000) 00368 # if !defined(WIZARDSTOOLKIT_HAVE_TIFFCONF_H) 00369 # define HAVE_TIFFCONF_H 00370 # endif 00371 # endif 00372 00373 #endif 00374 00375 /* 00376 Define declarations. 00377 */ 00378 #define AbsoluteValue(x) ((x) < 0 ? -(x) : (x)) 00379 #define WizardEpoch 1000000000L 00380 #define Max(x,y) (((x) > (y)) ? (x) : (y)) 00381 #define Min(x,y) (((x) < (y)) ? (x) : (y)) 00382 #define Swap(x,y) ((x)^=(y), (y)^=(x), (x)^=(y)) 00383 00384 /* 00385 Define system symbols if not already defined. 00386 */ 00387 #if !defined(STDIN_FILENO) 00388 #define STDIN_FILENO 0x00 00389 #endif 00390 00391 #if !defined(STDOUT_FILENO) 00392 #define STDOUT_FILENO 0x01 00393 #endif 00394 00395 #if !defined(STDERR_FILENO) 00396 #define STDERR_FILENO 0x02 00397 #endif 00398 00399 #if !defined(O_BINARY) 00400 #define O_BINARY 0x00 00401 #endif 00402 00403 #if defined(S_IRUSR) && defined(S_IWUSR) 00404 # define S_MODE (S_IRUSR | S_IWUSR) 00405 #elif defined (WIZARDSTOOLKIT_WINDOWS_SUPPORT) 00406 # define S_MODE (_S_IREAD | _S_IWRITE) 00407 #else 00408 # define S_MODE 0600 00409 #endif 00410 00411 #if !defined(PATH_MAX) 00412 #define PATH_MAX 4096 00413 #endif 00414 00415 extern unsigned char 00416 _wizard_info[1]; 00417 00418 #if defined(__cplusplus) || defined(c_plusplus) 00419 } 00420 #endif 00421 00422 #endif