studio.h

Go to the documentation of this file.
00001 /*
00002   Copyright 1999-2010 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(__cplusplus) || defined(c_plusplus)
00048 #  undef inline
00049 # endif
00050 # if defined(_magickcore_restrict) && !defined(restrict)
00051 #  define restrict  _wizardstoolkit_restrict
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 # if defined(_MT) && defined(_DLL) && !defined(_WIZARDDLL_) && !defined(_LIB)
00061 #  define _WIZARDDLL_
00062 # endif
00063 # if defined(_WIZARDDLL_)
00064 #  if defined(_VISUALC_)
00065 #   pragma warning( disable: 4273 )  /* Disable the dll linkage warnings */
00066 #  endif
00067 #  if !defined(_WIZARDLIB_)
00068 #   define WizardExport  __declspec(dllimport)
00069 #   if defined(_VISUALC_)
00070 #    pragma message( "Wizard lib DLL import interface" )
00071 #   endif
00072 #  else
00073 #   define WizardExport  __declspec(dllexport)
00074 #   if defined(_VISUALC_)
00075 #    pragma message( "Wizard lib DLL export interface" )
00076 #   endif
00077 #  endif
00078 # else
00079 #  define WizardExport
00080 #  if defined(_VISUALC_)
00081 #   pragma message( "Wizard lib static interface" )
00082 #  endif
00083 # endif
00084 
00085 # if defined(_DLL) && !defined(_LIB)
00086 #  define ModuleExport  __declspec(dllexport)
00087 #  if defined(_VISUALC_)
00088 #   pragma message( "Wizard module DLL export interface" )
00089 #  endif
00090 # else
00091 #  define ModuleExport
00092 #  if defined(_VISUALC_)
00093 #   pragma message( "Wizard module static interface" )
00094 #  endif
00095 
00096 # endif
00097 # define WizardGlobal __declspec(thread)
00098 # if defined(_VISUALC_)
00099 #  pragma warning(disable : 4018)
00100 #  pragma warning(disable : 4068)
00101 #  pragma warning(disable : 4244)
00102 #  pragma warning(disable : 4142)
00103 #  pragma warning(disable : 4800)
00104 #  pragma warning(disable : 4786)
00105 #  pragma warning(disable : 4996)
00106 # endif
00107 #else
00108 # define WizardExport
00109 # define ModuleExport
00110 # define WizardGlobal
00111 #endif
00112 #define WizardSignature  0xabacadabUL
00113 #if !defined(MaxTextExtent)
00114 # define MaxTextExtent  4096
00115 #endif
00116 
00117 #include <stdarg.h>
00118 #include <stdio.h>
00119 #if defined(WIZARDSTOOLKIT_HAVE_SYS_STAT_H)
00120 # include <sys/stat.h>
00121 #endif
00122 #if defined(WIZARDSTOOLKIT_STDC_HEADERS)
00123 # include <stdlib.h>
00124 # include <stddef.h>
00125 #else
00126 # if defined(WIZARDSTOOLKIT_HAVE_STDLIB_H)
00127 #  include <stdlib.h>
00128 # endif
00129 #endif
00130 #if defined(WIZARDSTOOLKIT_HAVE_STRING_H)
00131 # if !defined(STDC_HEADERS) && defined(WIZARDSTOOLKIT_HAVE_MEMORY_H)
00132 #  include <memory.h>
00133 # endif
00134 # include <string.h>
00135 #endif
00136 #if defined(WIZARDSTOOLKIT_HAVE_STRINGS_H)
00137 # include <strings.h>
00138 #endif
00139 #if defined(WIZARDSTOOLKIT_HAVE_INTTYPES_H)
00140 # include <inttypes.h>
00141 #endif
00142 #if defined(WIZARDSTOOLKIT_HAVE_STDINT_H)
00143 # include <stdint.h>
00144 #endif
00145 #if defined(WIZARDSTOOLKIT_HAVE_UNISTD_H)
00146 # include <unistd.h>
00147 #endif
00148 #if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT) && defined(_DEBUG)
00149 #define _CRTDBG_MAP_ALLOC
00150 #endif
00151 #if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT)
00152 # include <direct.h>
00153 # if !defined(WIZARDSTOOLKIT_HAVE_STRERROR)
00154 #  define HAVE_STRERROR
00155 # endif
00156 #endif
00157 
00158 #if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT) && defined(_DEBUG)
00159 #define _CRTDBG_MAP_ALLOC
00160 #endif
00161 #if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT)
00162 # include <direct.h>
00163 # if !defined(WIZARDSTOOLKIT_HAVE_STRERROR)
00164 #  define HAVE_STRERROR
00165 # endif
00166 #endif
00167 
00168 #include <ctype.h>
00169 #include <locale.h>
00170 #include <errno.h>
00171 #include <fcntl.h>
00172 #include <math.h>
00173 #include <time.h>
00174 #include <limits.h>
00175 #include <signal.h>
00176 #include <assert.h>
00177 
00178 #if defined(WIZARDSTOOLKIT_HAVE_PTHREAD)
00179 #  include <pthread.h>
00180 #elif defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT)
00181 #  define WIZARDSTOOLKIT_HAVE_WINTHREADS  1
00182 #include <windows.h>
00183 #endif
00184 #if defined(WIZARDSTOOLKIT_HAVE_SYS_SYSLIMITS_H)
00185 #  include <sys/syslimits.h>
00186 #endif
00187 #if defined(WIZARDSTOOLKIT_HAVE_ARM_LIMITS_H)
00188 #  include <arm/limits.h>
00189 #endif
00190 #if defined(_OPENMP) && (_OPENMP >= 200203)
00191 #  include <omp.h>
00192 #  define WIZARDSTOOLKIT_HAVE_OPENMP 1
00193 #endif
00194 
00195 #if defined(WIZARDSTOOLKIT_HAVE_PREAD) && defined(WIZARDSTOOLKIT_HAVE_DECL_PREAD) && !WIZARDSTOOLKIT_HAVE_DECL_PREAD
00196 ssize_t pread(int,void *,size_t,off_t);
00197 #endif
00198 
00199 #if defined(WIZARDSTOOLKIT_HAVE_PWRITE) && defined(WIZARDSTOOLKIT_HAVE_DECL_PWRITE) && !WIZARDSTOOLKIT_HAVE_DECL_PWRITE
00200 ssize_t pwrite(int,const void *,size_t,off_t);
00201 #endif
00202 
00203 #if defined(WIZARDSTOOLKIT_HAVE_STRLCPY) && defined(WIZARDSTOOLKIT_HAVE_DECL_STRLCPY) && !WIZARDSTOOLKIT_HAVE_DECL_STRLCPY
00204 extern size_t strlcpy(char *,const char *,size_t);
00205 #endif
00206 
00207 #if defined(WIZARDSTOOLKIT_HAVE_VSNPRINTF) && defined(WIZARDSTOOLKIT_HAVE_DECL_VSNPRINTF) && !WIZARDSTOOLKIT_HAVE_DECL_VSNPRINTF
00208 extern int vsnprintf(char *,size_t,const char *,va_list);
00209 #endif
00210 
00211 #if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT) || defined(WIZARDSTOOLKIT_POSIX_SUPPORT)
00212 # include <sys/types.h>
00213 # include <sys/stat.h>
00214 # if defined(WIZARDSTOOLKIT_HAVE_FTIME)
00215 # include <sys/timeb.h>
00216 # endif
00217 # if defined(WIZARDSTOOLKIT_POSIX_SUPPORT)
00218 #  if defined(WIZARDSTOOLKIT_HAVE_SYS_NDIR_H) || defined(WIZARDSTOOLKIT_HAVE_SYS_DIR_H) || defined(WIZARDSTOOLKIT_HAVE_NDIR_H)
00219 #   define dirent direct
00220 #   define NAMLEN(dirent) (dirent)->d_namlen
00221 #   if defined(WIZARDSTOOLKIT_HAVE_SYS_NDIR_H)
00222 #    include <sys/ndir.h>
00223 #   endif
00224 #   if defined(WIZARDSTOOLKIT_HAVE_SYS_DIR_H)
00225 #    include <sys/dir.h>
00226 #   endif
00227 #   if defined(WIZARDSTOOLKIT_HAVE_NDIR_H)
00228 #    include <ndir.h>
00229 #   endif
00230 #  else
00231 #   include <dirent.h>
00232 #   define NAMLEN(dirent) strlen((dirent)->d_name)
00233 #  endif
00234 #  include <pwd.h>
00235 # endif
00236 # if !defined(S_ISDIR)
00237 #  define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
00238 # endif
00239 # if !defined(S_ISREG)
00240 #  define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
00241 # endif
00242 # include "wizard/wizard-type.h"
00243 # if !defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT)
00244 #  include <sys/time.h>
00245 #if defined(WIZARDSTOOLKIT_HAVE_SYS_TIMES_H)
00246 #  include <sys/times.h>
00247 #endif
00248 #if defined(WIZARDSTOOLKIT_HAVE_SYS_RESOURCE_H)
00249 #  include <sys/resource.h>
00250 #endif
00251 # endif
00252 #else
00253 # include <types.h>
00254 # include <stat.h>
00255 # if defined(macintosh)
00256 #  include <SIOUX.h>
00257 #  include <console.h>
00258 #  include <unix.h>
00259 # endif
00260 # include "wizard/wizard-type.h"
00261 #endif
00262 
00263 #if defined(WIZARDSTOOLKIT_HAVE___ATTRIBUTE__)
00264 #  define wizard_aligned(x)  __attribute__((aligned(x)))
00265 #  define wizard_attribute  __attribute__
00266 #  define wizard_unused(x)  wizard_unused_ ## x __attribute__((unused))
00267 #else
00268 #  define wizard_attribute(x)  /* nothing */
00269 #  define wizard_unused(x) x
00270 #endif
00271 
00272 #if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT)
00273 # include "wizard/nt-base.h"
00274 #endif
00275 #if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT) || defined(__CYGWIN__)
00276 #endif
00277 #if defined(macintosh)
00278 # include "mac.h"
00279 #endif
00280 #if defined(vms)
00281 # include "vms.h"
00282 #endif
00283 
00284 #undef HAVE_CONFIG_H
00285 #undef index
00286 #undef pipe
00287 
00288 #include <wizard/string_.h>
00289 
00290 /*
00291   Review these platform specific definitions.
00292 */
00293 #if defined(WIZARDSTOOLKIT_POSIX_SUPPORT)
00294 # define DirectorySeparator  "/"
00295 # define DirectoryListSeparator  ':'
00296 # define Exit  _exit
00297 # define IsBasenameSeparator(c)  ((c) == '/' ? WizardTrue : WizardFalse)
00298 # define PreferencesDefaults  "~/."
00299 # define ProcessPendingEvents(text)
00300 # define ReadCommandlLine(argc,argv)
00301 # define SetNotifyHandlers
00302 #else
00303 
00304 # if defined(vms)
00305 #  define ApplicationDefaults  "decw$system_defaults:"
00306 #  define DirectorySeparator  ""
00307 #  define DirectoryListSeparator  ';'
00308 #  define Exit  exit
00309 #  define IsBasenameSeparator(c) \
00310   (((c) == ']') || ((c) == ':') || ((c) == '/') ? WizardTrue : WizardFalse)
00311 #  define WizardLibPath  "sys$login:"
00312 #  define WizardModulesPath  "sys$login:"
00313 #  define WizardSignaturerePath  "sys$login:"
00314 #  define PreferencesDefaults  "decw$user_defaults:"
00315 #  define ProcessPendingEvents(text)
00316 #  define ReadCommandlLine(argc,argv)
00317 #  define SetNotifyHandlers
00318 # endif
00319 
00320 # if defined(macintosh)
00321 #  define ApplicationDefaults  "/usr/lib/X11/app-defaults/"
00322 #  define DirectorySeparator  ":"
00323 #  define DirectoryListSeparator  ';'
00324 #  define IsBasenameSeparator(c)  ((c) == ':' ? WizardTrue : WizardFalse)
00325 #  define WizardLibPath  ""
00326 #  define WizardModulesPath  ""
00327 #  define WizardSignaturerePath  ""
00328 #  define PreferencesDefaults  "~/."
00329 #  define ReadCommandlLine(argc,argv)  argc=ccommand(argv); puts(WizardVersion);
00330 #  define SetNotifyHandlers \
00331     SetErrorHandler(MACErrorHandler); \
00332     SetWarningHandler(MACWarningHandler)
00333 # endif
00334 
00335 # if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT)
00336 #  define DirectorySeparator  "\\"
00337 #  define DirectoryListSeparator  ';'
00338 #  define IsBasenameSeparator(c) \
00339   (((c) == '/') || ((c) == '\\') ? WizardTrue : WizardFalse)
00340 #  define ProcessPendingEvents(text)
00341 #if !defined(PreferencesDefaults)
00342 #  define PreferencesDefaults  "~\\."
00343 #endif /* PreferencesDefaults */
00344 #  define ReadCommandlLine(argc,argv)
00345 #  define SetNotifyHandlers \
00346     SetErrorHandler(NTErrorHandler); \
00347     SetWarningHandler(NTWarningHandler)
00348 #  undef sleep
00349 #  define sleep(seconds)  Sleep(seconds*1000)
00350 #  if !defined(WIZARDSTOOLKIT_HAVE_TIFFCONF_H)
00351 #    define HAVE_TIFFCONF_H
00352 #  endif
00353 # endif
00354 
00355 #endif
00356 
00357 /*
00358   Define declarations.
00359 */
00360 #define AbsoluteValue(x)  ((x) < 0 ? -(x) : (x))
00361 #define WizardEpoch  1000000000L
00362 #define Max(x,y)  (((x) > (y)) ? (x) : (y))
00363 #define Min(x,y)  (((x) < (y)) ? (x) : (y))
00364 #define Swap(x,y) ((x)^=(y), (y)^=(x), (x)^=(y))
00365 
00366 /*
00367   Define system symbols if not already defined.
00368 */
00369 #if !defined(STDIN_FILENO)
00370 #define STDIN_FILENO  0x00
00371 #endif
00372 
00373 #if !defined(STDOUT_FILENO)
00374 #define STDOUT_FILENO  0x01
00375 #endif
00376 
00377 #if !defined(STDERR_FILENO)
00378 #define STDERR_FILENO  0x02
00379 #endif
00380 
00381 #if !defined(O_BINARY)
00382 #define O_BINARY  0x00
00383 #endif
00384 
00385 #if defined(S_IRUSR) && defined(S_IWUSR)
00386 # define S_MODE (S_IRUSR | S_IWUSR)
00387 #elif defined (WIZARDSTOOLKIT_WINDOWS_SUPPORT)
00388 # define S_MODE (_S_IREAD | _S_IWRITE)
00389 #else
00390 # define S_MODE  0600
00391 #endif
00392 
00393 #if !defined(PATH_MAX)
00394 #define PATH_MAX  4096
00395 #endif
00396 
00397 /*
00398   I/O defines.
00399 */
00400 #if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT) && !defined(Windows95) && defined(_VISUALC_)
00401 #define WizardSeek(file,offset,whence)  _lseeki64(file,offset,whence)
00402 #else
00403 #define WizardSeek(file,offset,whence)  lseek(file,offset,whence)
00404 #endif
00405 
00406 extern unsigned char
00407   _wizard_info[1];
00408 
00409 #if defined(__cplusplus) || defined(c_plusplus)
00410 }
00411 #endif
00412 
00413 #endif
Generated by  doxygen 1.6.2-20100208