kviewshell
DjVuGlobal.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #ifndef _DJVUGLOBAL_H
00058 #define _DJVUGLOBAL_H
00059 #ifdef HAVE_CONFIG_H
00060 # include "config.h"
00061 #endif
00062 #if NEED_GNUG_PRAGMAS
00063 # pragma interface
00064 #endif
00065
00066 #if defined(UNDER_CE)
00067 # ifndef __WCEALT_H__
00068 inline void * operator new(size_t, void * ptr) { return ptr; }
00069 # endif
00070 #elif defined(HAVE_STDINCLUDES)
00071 # include <new>
00072 #else
00073 # include <new.h>
00074 #endif
00075
00076 #ifdef WIN32
00077 # ifdef DLL_EXPORT
00078 # define DJVUAPI __declspec(dllexport)
00079 # else
00080 # ifdef LIBDJVU_DLL_IMPORT
00081 # define DJVUAPI __declspec(dllimport)
00082 # endif
00083 # endif
00084 #endif
00085 #ifndef DJVUAPI
00086 # define DJVUAPI
00087 #endif
00088
00089
00108
00109
00119
00120
00121 #ifdef NEED_DJVU_MEMORY
00122
00123 # include "DjVu.h"
00124
00125
00126 typedef void djvu_delete_callback(void *);
00127 typedef void *djvu_new_callback(size_t);
00128
00129
00130 int djvu_memoryObject_callback ( djvu_delete_callback*, djvu_new_callback*);
00131 int djvu_memoryArray_callback ( djvu_delete_callback*, djvu_new_callback*);
00132
00133
00134
00135
00136 # ifndef STATIC_INLINE
00137 # ifdef __GNUC__
00138 # define STATIC_INLINE extern inline
00139 # else
00140 # define STATIC_INLINE static inline
00141 # endif
00142 # endif
00143
00144
00145
00146 # if defined( __GNUC__ ) && ( __GNUC__*1000 + __GNUC_MINOR__ >= 2091 )
00147 # ifndef new_throw_spec
00148 # define new_throw_spec throw(std::bad_alloc)
00149 # endif
00150 # ifndef delete_throw_spec
00151 # define delete_throw_spec throw()
00152 # endif
00153 # endif
00154
00155 # ifndef new_throw_spec
00156 # define new_throw_spec
00157 # endif
00158 # ifndef delete_throw_spec
00159 # define delete_throw_spec
00160 # endif
00161
00162 # ifdef UNIX
00163 extern djvu_new_callback *_djvu_new_ptr;
00164 extern djvu_new_callback *_djvu_newArray_ptr;
00165 extern djvu_delete_callback *_djvu_delete_ptr;
00166 extern djvu_delete_callback *_djvu_deleteArray_ptr;
00167
00168 # ifndef NEED_DJVU_MEMORY_IMPLEMENTATION
00169 void *operator new (size_t) new_throw_spec;
00170 void *operator new[] (size_t) new_throw_spec;
00171 void operator delete (void *) delete_throw_spec;
00172 void operator delete[] (void *) delete_throw_spec;
00173
00174 STATIC_INLINE void *
00175 operator new(size_t sz) new_throw_spec
00176 { return (*_djvu_new_ptr)(sz); }
00177 STATIC_INLINE void
00178 operator delete(void *addr) delete_throw_spec
00179 { return (*_djvu_delete_ptr)(addr); }
00180 STATIC_INLINE void *
00181 operator new [] (size_t sz) new_throw_spec
00182 { return (*_djvu_newArray_ptr)(sz); }
00183 STATIC_INLINE void
00184 operator delete [] (void *addr) delete_throw_spec
00185 { return (*_djvu_deleteArray_ptr)(addr); }
00186 # endif
00187
00188 # else
00189
00190 # ifndef NEED_DJVU_MEMORY_IMPLEMENTATION
00191 STATIC_INLINE void *
00192 operator new(size_t sz) new_throw_spec
00193 { return _djvu_new(sz); }
00194 inline_as_macro void
00195 operator delete(void *addr) delete_throw_spec
00196 { return _djvu_delete(addr); }
00197 inline_as_macro void *
00198 operator new [] (size_t sz) new_throw_spec
00199 { return _djvu_new(sz); }
00200 inline_as_macro void
00201 operator delete [] (void *addr) delete_throw_spec
00202 { _djvu_deleteArray(addr); }
00203 # endif
00204
00205 # endif
00206
00207 #else
00208
00209 # define _djvu_free(ptr) free((ptr))
00210 # define _djvu_malloc(siz) malloc((siz))
00211 # define _djvu_realloc(ptr,siz) realloc((ptr),(siz))
00212 # define _djvu_calloc(siz,items) calloc((siz),(items))
00213
00214 #endif
00215
00249
00250 #ifndef HAS_DJVU_PROGRESS_CALLBACKS
00251 # define HAS_DJVU_PROGRESS_CALLBACKS
00252
00253 # ifdef NEED_DJVU_PROGRESS
00254 # include "DjVu.h"
00255
00256 extern djvu_progress_callback *_djvu_progress_ptr;
00257
00258 # define DJVU_PROGRESS_TASK(name,task,nsteps) DjVuProgressTask task_##name(task,nsteps)
00259 # define DJVU_PROGRESS_RUN(name,tostep) { task_##name.run(tostep); }
00260
00261 class DjVuProgressTask
00262 {
00263 public:
00264 class Data;
00265 ~DjVuProgressTask();
00266 DjVuProgressTask(const char *task,int nsteps);
00267 void run(int tostep);
00268 const char *task;
00269 static djvu_progress_callback *set_callback(djvu_progress_callback *ptr=0);
00270 private:
00271 DjVuProgressTask *parent;
00272 int nsteps;
00273 int runtostep;
00274 unsigned long startdate;
00275
00276 void *gdata;
00277 Data *data;
00278
00279 void signal(unsigned long curdate, unsigned long estdate);
00280 };
00281
00282 # else // ! NEED_DJVU_PROGRESS
00283
00284 # define DJVU_PROGRESS_TASK(name,task,nsteps)
00285 # define DJVU_PROGRESS_RUN(name,step)
00286
00287 # endif // ! NEED_DJVU_PROGRESS
00288 #endif // HAS_DJVU_PROGRESS_CALLBACKS
00289
00290
00291
00298 #ifdef __cplusplus
00299 # define DJVUEXTERNCAPI(x) extern "C" DJVUAPI x;
00300 #else
00301 # define DJVUEXTERNCAPI(x) extern DJVUAPI x
00302 #endif
00303
00305 DJVUEXTERNCAPI(void DjVuPrintErrorUTF8(const char *fmt, ...))
00306
00307
00308 DJVUEXTERNCAPI(void DjVuPrintErrorNative(const char *fmt, ...))
00309
00311 DJVUEXTERNCAPI(void DjVuPrintMessageUTF8(const char *fmt, ...))
00312
00314 DJVUEXTERNCAPI(void DjVuPrintMessageNative(const char *fmt, ...))
00315
00318 DJVUEXTERNCAPI(void DjVuFormatErrorUTF8(const char *fmt, ...))
00319
00322 DJVUEXTERNCAPI(void DjVuFormatErrorNative(const char *fmt, ...))
00323
00325 DJVUEXTERNCAPI(void DjVuWriteError( const char *message ))
00326
00328 DJVUEXTERNCAPI(void DjVuWriteMessage( const char *message ))
00329
00336 DJVUEXTERNCAPI(void DjVuMessageLookUpUTF8(
00337 char *msg_buffer, const unsigned int buffer_size,
00338 const char *message ))
00339 DJVUEXTERNCAPI(void DjVuMessageLookUpNative(
00340 char *msg_buffer, const unsigned int buffer_size,
00341 const char *message ))
00342
00346 DJVUEXTERNCAPI(const char *djvu_programname(const char *programname))
00347
00348
00357
00358
00359 #ifdef NEED_DJVU_NAMES
00360
00361
00362
00363
00364
00365 #endif // NEED_DJVU_NAMES
00366
00368
00369 #if defined(macintosh)
00370 # define EMPTY_LOOP continue
00371 #else
00372 # define EMPTY_LOOP
00373 #endif
00374
00375
00376
00377
00378
00379
00380 #ifndef HAS_CTRL_C_IN_ERR_MSG
00381 # define HAS_CTRL_C_IN_ERR_MSG 1
00382 #endif
00383 #ifndef ERR_MSG
00384 # if HAS_CTRL_C_IN_ERR_MSG
00385
00386
00387
00388
00389
00390 # define ERR_MSG(x) "\003" x
00391 # else
00392 # define ERR_MSG(x) x
00393 # endif
00394 #endif
00395
00396 #endif
00397
00398