# studio.h

Go to the documentation of this file.

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