Main Page | Modules | Class Hierarchy | Class List | File List | Class Members | Related Pages

types.h

00001 /*
00002  *  libFreiburg - src/LibFreiburg/include/msgque/types.h
00003  *  
00004  *  (C) 2004 - Freiburg - Project - Group
00005  *  ------------------------------------------------------
00006  *  EMail: freiburg AT compiler-factory DOT de
00007  *  ------------------------------------------------------
00008  *  all rights reserved
00009  */
00010 
00011 #ifndef MQ_TYPES_H
00012 #define MQ_TYPES_H
00013 
00014 /* ####################################################################### */
00015 /* ###                                                                 ### */
00016 /* ###                      M S G Q U E - A P I                        ### */
00017 /* ###                                                                 ### */
00018 /* ####################################################################### */
00019 
00025 
00026 #define __STDC_VERSION__ 199901L
00027 
00028 /* Somewhere in the middle of the GCC 2.96 development cycle, we implemented
00029    a mechanism by which the user can annotate likely branch directions and
00030    expect the blocks to be reordered appropriately.  Define __builtin_expect
00031    to nothing for earlier compilers.  */
00032 
00033 #if __GNUC__ == 2 && __GNUC_MINOR__ < 96
00034 #define __builtin_expect(x, expected_value) (x)
00035 #endif
00036 
00038 #define likely(x)       __builtin_expect((x),1)
00039 
00041 #define unlikely(x)     __builtin_expect((x),0)
00042 
00043 #include <limits.h>
00044 #include <float.h>
00045 #include <stdarg.h>
00046 #include <time.h>
00047 
00048 //15 min timeout
00049 #ifndef MQ_TIMEOUT
00050 
00051 #define MQ_TIMEOUT      900
00052 
00053 #define MQ_TIMEOUT5     (MQ_TIMEOUT/5)
00054 
00055 #define MQ_TIMEOUT10    (MQ_TIMEOUT/10  < 1 ? 1 : MQ_TIMEOUT/10)
00056 
00057 #define MQ_TIMEOUT45    (MQ_TIMEOUT/45  < 1 ? 1 : MQ_TIMEOUT/45)
00058 
00059 #define MQ_TIMEOUT180   (MQ_TIMEOUT/180 < 1 ? 1 : MQ_TIMEOUT/180)
00060 #endif
00061 
00062 /*****************************************************************************/
00063 /*                                                                           */
00064 /*                        architecture depending types                       */
00065 /*                                                                           */
00066 /*****************************************************************************/
00067 
00068 #if defined(DARWIN_7_0_POWERPC)
00069 
00070 // system constant __LITTLE_ENDIAN
00071 
00072 #define __LITTLE_ENDIAN  LITTLE_ENDIAN
00073 #define __BIG_ENDIAN     BIG_ENDIAN
00074 #define __PDP_ENDIAN     PDP_ENDIAN
00075 #define __BYTE_ORDER     BYTE_ORDER
00076 
00077 #define MQ_ARCH "DARWIN_7_0_POWERPC"
00078 #define MQ_SOCKLEN int
00079 #define MQ_IS_POSIX
00080 
00081 #elif defined(LINUX_I386)
00082 
00084 #define MQ_ARCH "LINUX_I386"
00085 
00086 #define MQ_SOCKLEN socklen_t
00087 
00088 #define MQ_IS_POSIX
00089 
00090 #elif defined(CYGWIN_NT_5_1_I686)
00091 
00092 // using MinGW compiler (e.g. cygwin: gcc -no-cygwin)
00093 
00094 #define MQ_ARCH "CYGWIN_NT_5_1_I686"
00095 #define MQ_SOCKLEN int
00096 #define MQ_IS_WIN32
00097 
00098 #else
00099 
00100 #error environment not supported
00101 
00102 #endif
00103 
00104 /*****************************************************************************/
00105 /*                                                                           */
00106 /*                          windows conform extern                           */
00107 /*                                                                           */
00108 /*****************************************************************************/
00109 
00110 #ifdef MQ_IS_STATIC
00111 #   define MQ_EXTERN
00112 #else
00113 #   ifdef MQ_IS_WIN32
00114 #       ifdef MQ_BUILD_DLL
00115         // the dll exports
00116 #           define MQ_EXTERN __declspec(dllexport)
00117 #       else
00118         // the exe imports
00119 #           define MQ_EXTERN __declspec(dllimport)
00120 #       endif
00121 #   else
00122 
00123 #       define MQ_EXTERN extern
00124 #   endif
00125 #endif
00126 
00127 /*****************************************************************************/
00128 /*                                                                           */
00129 /*                            types/definition                               */
00130 /*                                                                           */
00131 /*****************************************************************************/
00132 
00134 #define cppxstr(s) cppstr(s)
00135 
00136 #define cppstr(s) #s
00137 
00138 
00139 #if defined(MQ_IS_POSIX)
00140 
00141 #define MQ_FS  "/"
00142 #elif defined(MQ_IS_WIN32)
00143 #define MQ_FS  "\\"
00144 #endif
00145 
00147 #define MQ_SOCK         MQ_INT4
00148 
00150 #define MQ_INT2_MAX     SHRT_MAX
00151 
00152 #define MQ_INT2_MIN     SHRT_MIN
00153 
00155 #define MQ_INT4_MAX     INT_MAX
00156 
00157 #define MQ_INT4_MIN     INT_MIN
00158 
00160 #define MQ_INT8_MAX     LLONG_MAX
00161 
00162 #define MQ_INT8_MIN     LLONG_MIN
00163 
00165 #define MQ_PTR_MAX      (MQ_PTR)0xFFFFFFFF
00166 
00168 #define MQ_FLT4_MAX     FLT_MAX
00169 
00170 #define MQ_FLT4_MIN     FLT_MIN
00171 
00173 #define MQ_FLT8_MAX     DBL_MAX
00174 
00175 #define MQ_FLT8_MIN     DBL_MIN
00176 
00178 #define MQ_NULL_2          0
00179 
00180 #define MQ_NULL_4          0
00181 
00182 #define MQ_NULL_8          0LL
00183 
00184 #define MQ_NULL_F          0.0F
00185 
00186 #define MQ_NULL_D          0.0L
00187 
00188 #define MQ_NULL_P          NULL
00189 
00190 #define MQ_NULL_C          ""
00191 
00193 typedef struct MqReadS *MqReadSP;
00195 typedef struct MqSendS *MqSendSP;
00197 typedef struct MqIoS *MqIoSP;
00199 typedef struct MqTransS *MqTransSP;
00201 typedef struct MqTokenS *MqTokenSP;
00203 typedef struct MqBufferS *MqBufferSP;
00205 typedef struct MqS *MqSP;
00207 typedef struct MqErrorS *MqErrorSP;
00209 typedef struct MqBufferLS *MqBufferLSP;
00211 typedef struct MqStatCtxS *MqStatCtxSP;
00213 typedef struct MqStatS *MqStatSP;
00215 typedef struct ContextS *ContextSP;
00217 typedef union MqOptionU *MqOptionUP;
00218 
00219 /*****************************************************************************/
00220 /*                                                                           */
00221 /*                            enum definitions                               */
00222 /*                                                                           */
00223 /*****************************************************************************/
00224 
00227 typedef enum {
00228   MQ_PARENT                     
00229 } MqOpt;
00230 
00248 typedef enum {
00249   MQ_CLIENT,
00250   MQ_SERVER
00251 } MqE;
00252 
00255 typedef enum {
00256   MQ_SELECT_RECV,               
00257   MQ_SELECT_SEND                
00258 } MqIoSelectE;
00259 
00262 typedef enum {
00263   MQ_WAIT = (1 << 0),           
00264   MQ_FOREVER = (1 << 1)         
00265 } MqWaitOnEventE;
00266 
00273 typedef enum {
00274   _MQ_BIN = 'B',                
00275   _MQ_STR = 'C',                
00276   _MQ_INT2 = '2',               
00277   _MQ_INT4 = '4',               
00278   _MQ_INT8 = '8',               
00279   _MQ_FLT4 = 'F',               
00280   _MQ_FLT8 = 'D',               
00281   _MQ_PTR = 'P',                
00282   _MQ_LST = 'L',                
00283   _MQ_RET = 'R',                
00284   _MQ_STA = 'S'                 
00285 } MqTypeE;
00286 
00293 typedef enum {
00294   MQ_DYNAMIC,                   
00295   MQ_STATIC                     
00296 } MqAllocE;
00297 
00300 typedef enum {
00301   MQ_OK,                        
00302   MQ_ERROR,                     
00303   MQ_WARNING,                   
00304   MQ_CONTINUE                   
00305 } MqErrorE;
00306 
00307 /*****************************************************************************/
00308 /*                                                                           */
00309 /*                            types/LINUX_I386                               */
00310 /*                                                                           */
00311 /*****************************************************************************/
00312 
00313 #ifdef LINUX_I386
00314 
00316 typedef short int MQ_INT2;
00319 typedef int MQ_INT4;
00321 typedef long long int MQ_INT8;
00323 typedef float MQ_FLT4;
00325 typedef double MQ_FLT8;
00327 typedef long double MQ_FLT12;
00328 
00331 typedef MQ_INT4 MQ_SIZE;
00333 typedef unsigned short MQ_UINT2;
00334 
00336 typedef void MQ_PTRT;
00338 typedef char MQ_STRT;
00340 typedef unsigned char MQ_BINT;
00342 typedef unsigned char MQ_LSTT;
00343 
00345 typedef MQ_PTRT *MQ_PTR;
00347 typedef MQ_STRT *MQ_STR;
00349 typedef MQ_BINT *MQ_BIN;
00351 typedef MQ_LSTT *MQ_LST;
00352 
00353 #endif
00354        /* LINUX_I386 */
00355 
00356 /*****************************************************************************/
00357 /*                                                                           */
00358 /*                            types/DARWIN_7_0_POWERPC                       */
00359 /*                                                                           */
00360 /*****************************************************************************/
00361 
00362 #ifdef DARWIN_7_0_POWERPC
00363 
00364 typedef short int MQ_INT2;
00365 typedef int MQ_INT4;
00366 typedef long long int MQ_INT8;
00367 typedef float MQ_FLT4;
00368 typedef double MQ_FLT8;
00369 typedef double MQ_FLT12;        //Darwin does not support long double
00370 typedef void *MQ_PTR;
00371 typedef char *MQ_STR;
00372 typedef unsigned char *MQ_BIN;
00373 typedef unsigned char *MQ_LST;
00374 
00375 typedef int MQ_SIZE;
00376 typedef unsigned short MQ_UINT2;
00377 
00378 typedef void MQ_PTRT;
00379 typedef char MQ_STRT;
00380 typedef unsigned char MQ_BINT;
00381 typedef unsigned char MQ_LSTT;
00382 
00383 #endif
00384        /* DARWIN_7_0_POWERPC */
00385 
00386 /*****************************************************************************/
00387 /*                                                                           */
00388 /*                            types/CYGWIN_NT_5_1_I686                       */
00389 /*                                                                           */
00390 /*****************************************************************************/
00391 
00392 #ifdef CYGWIN_NT_5_1_I686
00393 
00394 typedef short int MQ_INT2;
00395 typedef int MQ_INT4;
00396 typedef long long MQ_INT8;
00397 typedef float MQ_FLT4;
00398 typedef double MQ_FLT8;
00399 typedef long double MQ_FLT12;
00400 typedef void *MQ_PTR;
00401 typedef char *MQ_STR;
00402 typedef unsigned char *MQ_BIN;
00403 typedef unsigned char *MQ_LST;
00404 
00405 typedef int MQ_SIZE;
00406 typedef unsigned short MQ_UINT2;
00407 
00408 typedef void MQ_PTRT;
00409 typedef char MQ_STRT;
00410 typedef unsigned char MQ_BINT;
00411 typedef unsigned char MQ_LSTT;
00412 
00413 #endif
00414        /* CYGWIN_NT_5_1_I686 */
00415 
00418 /* ####################################################################### */
00419 /* ###                                                                 ### */
00420 /* ###                    M S G Q U E - A P I                          ### */
00421 /* ###                                                                 ### */
00422 /* ####################################################################### */
00423 
00445 /*****************************************************************************/
00446 /*                                                                           */
00447 /*                            msgque/definition                              */
00448 /*                                                                           */
00449 /*****************************************************************************/
00450 
00452 typedef MqErrorE (
00453   *ContextCreateF
00454 ) (
00455   MqBufferLSP,
00456   ContextSP *
00457 );
00458 
00460 typedef void (
00461   *ContextDeleteF
00462 ) (
00463   ContextSP *
00464 );
00465 
00467 typedef MqErrorE (
00468   *MqTokenF
00469 ) (
00470   MqSP msgque,
00471   void *data
00472 );
00473 
00475 #define MQ_SAVE_ERROR(msgque) ((msgque)&&(msgque)->error?(msgque)->error:NULL)
00476 
00477 #ifndef MQ_PRIVATE
00478 
00485 typedef struct MqS {
00486 
00487   ContextSP myCtx;              
00488   MqBufferSP const temp;        
00489   MqBufferSP name;              
00490 
00491   const MQ_INT2 debug;          
00492   const MQ_INT2 stat;           
00493   const MQ_INT2 silent;         
00494   const MQ_INT2 binary;         
00495 
00496   MqSendSP const send;          
00497   MqReadSP const read;          
00498   MqIoSP const io;              
00499   MqErrorSP const error;        
00500   MqStatSP statistic;           
00501 
00502 } MqS;
00503 #endif
00504        /* MQ_PRIVATE */
00505 
00506 /*****************************************************************************/
00507 /*                                                                           */
00508 /*                               msgque/init                                 */
00509 /*                                                                           */
00510 /*****************************************************************************/
00511 
00515 MQ_EXTERN MqErrorE MqCreate (
00516   ContextSP context,            
00517   MqBufferLSP argv,             
00518   MqSP *out                     
00519 );
00520 
00524 MQ_EXTERN void MqDelete (
00525   MqSP *msgqueP                 
00526 );
00527 
00528 /*****************************************************************************/
00529 /*                                                                           */
00530 /*                                set/get                                    */
00531 /*                                                                           */
00532 /*****************************************************************************/
00533 
00535 MQ_EXTERN MQ_PTR MqGetOpt (
00536   MqSP const msgque,
00537   MqOpt opt
00538 );
00539 
00541 inline MQ_EXTERN MqTransSP const MqGetTransPtr (
00542   MqSP const msgque
00543 );
00544 
00545 /*****************************************************************************/
00546 /*                                                                           */
00547 /*                                misc                                       */
00548 /*                                                                           */
00549 /*****************************************************************************/
00550 
00552 MQ_EXTERN void MqDataLog (
00553   MqSP msgque,
00554   const char *prefix
00555 );
00556 
00559 MQ_EXTERN inline MqErrorE MqServiceCreate (
00560   MqSP const msgque,
00561   MQ_STR token,
00562   MqTokenF proc,
00563   MQ_PTR data
00564 );
00565 
00568 MQ_EXTERN inline MqErrorE MqServiceDelete (
00569   MqSP const msgque,
00570   MQ_STR token
00571 );
00572 
00575 /* ####################################################################### */
00576 /* ###                                                                 ### */
00577 /* ###                     E V E N T - A P I                           ### */
00578 /* ###                                                                 ### */
00579 /* ####################################################################### */
00580 
00593 
00594 typedef void (
00595   *MqEventF
00596 ) (
00597   ContextSP
00598 );
00599 
00605 typedef void (
00606   *EventCreateF
00607 ) (
00608   ContextSP
00609 );
00610 
00611 struct timeval;
00612 
00618 MQ_EXTERN MqErrorE MqEventCheck (
00619   MqSP const msgque,            
00620   const MqIoSelectE type,       
00621   struct timeval *timeout,      
00622   EventCreateF proc             
00623 );
00624 
00635 MQ_EXTERN MqErrorE MqProcessEvent (
00636   MqSP const msgque,            
00637   const time_t timeout,         
00638   const MqWaitOnEventE wait     
00639 );
00640 
00643 /* ####################################################################### */
00644 /* ###                                                                 ### */
00645 /* ###                     B U F F E R - A P I                         ### */
00646 /* ###                                                                 ### */
00647 /* ####################################################################### */
00648 
00658 /*****************************************************************************/
00659 /*                                                                           */
00660 /*                              buffer_init                                  */
00661 /*                                                                           */
00662 /*****************************************************************************/
00663 
00669 typedef union MqBufferU {
00670   MQ_BINT *B;                   
00671   MQ_STRT *C;                   
00672   MQ_INT2 *I2;                  
00673   MQ_INT4 *I4;                  
00674   MQ_INT8 *I8;                  
00675   MQ_FLT4 *F;                   
00676   MQ_FLT8 *D;                   
00677   MQ_PTR *P;                    
00678   MQ_LSTT *L;                   
00679   MQ_LSTT *R;                   
00680 } MqBufferU;
00681 
00700 typedef struct MqBufferS {
00701   MqErrorSP error;              
00702   MQ_BIN data;                  
00703   MQ_SIZE size;                 
00704   MQ_SIZE cursize;              
00705   MQ_SIZE numItems;             
00706   MqBufferU cur;                
00707 
00708   MqAllocE alloc;               
00709   MqTypeE type;                 
00710 } MqBufferS;
00711 
00713 MQ_EXTERN MqBufferSP MqBufferCreate (
00714   MqErrorSP const error,
00715   const MQ_SIZE size
00716 );
00717 
00719 MQ_EXTERN void MqBufferDelete (
00720   MqBufferSP *bufP
00721 );
00722 
00724 MQ_EXTERN void MqBufferDeleteStatic (
00725   MqBufferSP buf
00726 );
00727 
00729 MQ_EXTERN inline void MqBufferReset (
00730   MqBufferSP buf
00731 );
00732 
00733 /*****************************************************************************/
00734 /*                                                                           */
00735 /*                           buffer_create_type                              */
00736 /*                                                                           */
00737 /*****************************************************************************/
00738 
00740 MQ_EXTERN inline MqBufferSP MqBufferCreateC (
00741   MqErrorSP const error,
00742   const MQ_STR in
00743 );
00744 
00746 MQ_EXTERN inline MqBufferSP MqBufferCreate2 (
00747   MqErrorSP const error,
00748   const MQ_INT2 in
00749 );
00750 
00752 MQ_EXTERN inline MqBufferSP MqBufferCreate4 (
00753   MqErrorSP const error,
00754   const MQ_INT4 in
00755 );
00756 
00758 MQ_EXTERN inline MqBufferSP MqBufferCreate8 (
00759   MqErrorSP const error,
00760   const MQ_INT8 in
00761 );
00762 
00764 MQ_EXTERN inline MqBufferSP MqBufferCreateD (
00765   MqErrorSP const error,
00766   const MQ_FLT8 in
00767 );
00768 
00770 MQ_EXTERN inline MqBufferSP MqBufferCreateP (
00771   MqErrorSP const error,
00772   const MQ_PTR in
00773 );
00774 
00775 /*****************************************************************************/
00776 /*                                                                           */
00777 /*                              buffer_atom                                  */
00778 /*                                                                           */
00779 /*****************************************************************************/
00780 
00782 #define MqBufferInitFromString(str) \
00783     { NULL, (MQ_BIN) str, strlen(str), strlen(str), 0, {.C str}, MQ_STATIC, _MQ_STR}
00784 
00787 MQ_EXTERN void _MqBufferNewSize (
00788   const char *header,
00789   MqBufferSP const buf,
00790   MQ_SIZE newSize
00791 );
00792 
00794 #define MqBufferNewSize(buf, newSize) \
00795     if (unlikely(buf->alloc == MQ_STATIC) || unlikely(newSize > buf->size)) \
00796         _MqBufferNewSize(__func__, buf, newSize)
00797 
00799 #define MqBufferAddSize(buf, addSize) \
00800     if (unlikely(buf->alloc == MQ_STATIC) || unlikely((buf->cursize + addSize) > buf->size)) \
00801         _MqBufferNewSize(__func__, buf, (buf->cursize + addSize))
00802 
00803 /*****************************************************************************/
00804 /*                                                                           */
00805 /*                              buffer_append                                */
00806 /*                                                                           */
00807 /*****************************************************************************/
00808 
00810 MQ_EXTERN MqBufferSP MqBufferCopy (
00811   MqBufferSP const dest,
00812   const MqBufferSP srce
00813 );
00814 
00816 MQ_EXTERN inline MqBufferSP MqBufferDup (
00817   const MqBufferSP srce
00818 );
00819 
00821 MQ_EXTERN MQ_SIZE MqBufferAppendH (
00822   MqBufferSP const buf,
00823   const char character
00824 );
00825 
00827 MQ_EXTERN MQ_SIZE MqBufferAppendB (
00828   MqBufferSP const buf,
00829   const MQ_BIN binary,
00830   MQ_SIZE size
00831 );
00832 
00834 MQ_EXTERN MQ_SIZE MqBufferAppendC (
00835   MqBufferSP const buf,
00836   const MQ_STR string
00837 );
00838 
00840 MQ_EXTERN inline MQ_SIZE MqBufferAppendU (
00841   MqBufferSP const buf,
00842   const MqBufferSP buffer
00843 );
00844 
00846 MQ_EXTERN MQ_SIZE MqBufferAppendVL (
00847   MqBufferSP const buf,
00848   const char *format,
00849   const va_list var_list
00850 );
00851 
00853 MQ_EXTERN MQ_SIZE MqBufferAppendV (
00854   MqBufferSP const buf,
00855   const char *fmt,
00856   ...
00857 );
00858 
00859 /*****************************************************************************/
00860 /*                                                                           */
00861 /*                              buffer_make                                  */
00862 /*                                                                           */
00863 /*****************************************************************************/
00864 
00871 MQ_EXTERN MQ_STR MqBufferGetC (
00872   MqBufferSP const buf
00873 );
00874 
00875 /*****************************************************************************/
00876 /*                                                                           */
00877 /*                              buffer_get                                   */
00878 /*                                                                           */
00879 /*****************************************************************************/
00880 
00882 MQ_EXTERN inline MQ_SIZE MqBufferGetLen (
00883   MqBufferSP const buf
00884 );
00885 
00887 MQ_EXTERN char *const MqBufferGetTypeName (
00888   const MqBufferSP buf
00889 );
00890 
00892 MQ_EXTERN void MqBufferLog (
00893   MqBufferSP const buf,
00894   const char *prefix
00895 );
00896 
00897 /*****************************************************************************/
00898 /*                                                                           */
00899 /*                              buffer_set                                   */
00900 /*                                                                           */
00901 /*****************************************************************************/
00902 
00912 MQ_EXTERN MqBufferSP _MqBufferSet (
00913   MqBufferSP const buf,         
00914   MQ_PTR const in,              
00915   const MQ_SIZE size,           
00916   const MqTypeE type            
00917 );
00918 
00920 MQ_EXTERN MqBufferSP MqBufferSetC (
00921   MqBufferSP const buf,
00922   const MQ_STR string
00923 );
00924 
00926 #define MqBufferSet2(buf,int2) _MqBufferSet(buf,(MQ_PTR const)&int2,sizeof(MQ_INT2),_MQ_INT2)
00927 
00929 #define MqBufferSet4(buf,int4) _MqBufferSet(buf,(MQ_PTR const)&int4,sizeof(MQ_INT4),_MQ_INT4)
00930 
00932 #define MqBufferSet8(buf,int8) _MqBufferSet(buf,(MQ_PTR const)&int8,sizeof(MQ_INT8),_MQ_INT8)
00933 
00935 #define MqBufferSetP(buf,pointer) _MqBufferSet(buf,(MQ_PTR const)&pointer,sizeof(MQ_PTR),_MQ_PTR)
00936 
00938 #define MqBufferSetF(buf,flt4) _MqBufferSet(buf,(MQ_PTR const)&flt4,sizeof(MQ_FLT4),_MQ_FLT4)
00939 
00941 #define MqBufferSetD(buf,flt8) _MqBufferSet(buf,(MQ_PTR const)&flt8,sizeof(MQ_FLT8),_MQ_FLT8)
00942 
00944 MQ_EXTERN MqBufferSP MqBufferSetV (
00945   MqBufferSP const buf,
00946   const char *format,
00947   ...
00948 );
00949 
00950 /*****************************************************************************/
00951 /*                                                                           */
00952 /*                              buffer_push                                  */
00953 /*                                                                           */
00954 /*****************************************************************************/
00955 
00957 MQ_EXTERN MQ_SIZE MqBufferPush (
00958   MqBufferSP buf,
00959   const char *str
00960 );
00961 
00963 MQ_EXTERN MQ_SIZE MqBufferPop (
00964   MqBufferSP buf,
00965   const char *star
00966 );
00967 
00970 /* ####################################################################### */
00971 /* ###                                                                 ### */
00972 /* ###                     E R R O R - A P I                           ### */
00973 /* ###                                                                 ### */
00974 /* ####################################################################### */
00975 
00987 
00988 
00989 MQ_EXTERN void MqPanicVL (
00990   MqErrorSP const error,
00991   const char *prefix,
00992   const MQ_INT4 errnum,
00993   const char *fmt,
00994   va_list ap
00995 ) __attribute__ ((noreturn));
00996 
00999 MQ_EXTERN void MqPanicV (
01000   MqErrorSP const error,
01001   const char *prefix,
01002   const MQ_INT4 errnum,
01003   const char *fmt,
01004   ...
01005 ) __attribute__ ((noreturn));
01006 
01009 #define MqPanicC(error,prefix,errnum,string) MqPanicV(error,prefix,errnum,"%s",string);
01010 
01013 #define MqPanicSYS(error) MqPanicV(error,__func__,-1,"%s","internal ERROR, please contact your local support");
01014 
01016 inline MQ_EXTERN void MqErrorReset (
01017   MqErrorSP const error
01018 );
01019 
01020 /*****************************************************************************/
01021 /*                                                                           */
01022 /*                            error_init_text                                */
01023 /*                                                                           */
01024 /*****************************************************************************/
01025 
01027 MQ_EXTERN MqErrorE MqErrorSGenVL (
01028   MqErrorSP const error,
01029   const char *prefix,
01030   const MqErrorE status,
01031   const MQ_INT4 errnum,
01032   const char *fmt,
01033   va_list ap
01034 );
01035 
01037 MQ_EXTERN MqErrorE MqErrorSGenV (
01038   MqErrorSP const error,
01039   const char *prefix,
01040   const MqErrorE status,
01041   const MQ_INT4 errnum,
01042   const char *fmt,
01043   ...
01044 );
01045 
01047 #define MqErrorC(error,prefix,errnum,str)           MqErrorSGenV(error,prefix,MQ_ERROR  ,errnum,"%s", str);
01048 
01050 #define MqWarningC(error,prefix,str)                MqErrorSGenV(error,prefix,MQ_WARNING,-1,"%s", str);
01051 
01053 #define MqErrorV(error,prefix,errnum,fmt,args...)   MqErrorSGenV(error,prefix,MQ_ERROR,errnum,fmt, args);
01054 
01056 #define MqWarningV(error,prefix,fmt,args...)        MqErrorSGenV(error,prefix,MQ_WARNING,-1,fmt,args);
01057 
01058 /*****************************************************************************/
01059 /*                                                                           */
01060 /*                              error_append                                 */
01061 /*                                                                           */
01062 /*****************************************************************************/
01063 
01065 MQ_EXTERN MqErrorE MqErrorSAppendV (
01066   MqErrorSP const error,
01067   const char *fmt,
01068   ...
01069 );
01070 
01072 #define MqErrorSAppendC(error,str)        MqErrorSAppendV(error,"%s",str);
01073 
01075 #define MQ_ERROR_PROC_FMT "found in procedure \"%s\" at file " cppxstr(__FILE__)
01076 
01077 /*****************************************************************************/
01078 /*                                                                           */
01079 /*                              error_append                                 */
01080 /*                                                                           */
01081 /*****************************************************************************/
01082 
01084 MQ_EXTERN MqErrorE MqErrorSSend (
01085   MqErrorSP const error,
01086   const char *prefix
01087 );
01088 
01089 /*****************************************************************************/
01090 /*                                                                           */
01091 /*                              error_set/get                                */
01092 /*                                                                           */
01093 /*****************************************************************************/
01094 
01096 inline MQ_EXTERN MqErrorE MqErrorGetStatus (
01097   MqErrorSP const error
01098 );
01099 
01101 inline MQ_EXTERN MQ_STR MqErrorGetString (
01102   MqErrorSP const error
01103 );
01104 
01106 inline MQ_EXTERN MQ_INT2 MqErrorGetNum (
01107   MqErrorSP const error
01108 );
01109 
01111 MQ_EXTERN MqBufferSP const MqErrorGetText (
01112   MqErrorSP const error
01113 );
01114 
01116 MQ_EXTERN inline MqSP MqErrorGetMsgque (
01117   MqErrorSP const error
01118 );
01119 
01120 /*****************************************************************************/
01121 /*                                                                           */
01122 /*                              error_is/check                               */
01123 /*                                                                           */
01124 /*****************************************************************************/
01125 
01127 #define MqErrorCheck(PROC) if (unlikely((PROC) == MQ_ERROR)) goto error
01129 #define MqErrorCheck1(PROC) if (unlikely((PROC) == MQ_ERROR)) goto error1
01131 #define MqErrorCheck2(PROC,JUMP) if (unlikely((PROC) == MQ_ERROR)) goto JUMP
01133 #define MqOkCheck(PROC)    if (likely((PROC) == MQ_OK)) goto ok
01134 
01136 #define MqErrorCheckNULL(PROC) if (unlikely((PROC) == NULL)) goto error
01138 #define MqErrorCheckNULL1(PROC) if (unlikely((PROC) == NULL)) goto error1
01139 
01140 /*****************************************************************************/
01141 /*                                                                           */
01142 /*                              error_misc                                   */
01143 /*                                                                           */
01144 /*****************************************************************************/
01145 
01147 MQ_EXTERN void MqErrorLog (
01148   MqErrorSP const error,
01149   const char *prefix
01150 );
01151 
01153 MQ_EXTERN MqErrorE MqErrorCopy (
01154   MqErrorSP out,
01155   MqErrorSP const in
01156 );
01157 
01160 #endif /* MQ_TYPES_H */

Generated on Tue Nov 23 16:13:06 2004 for libFreiburg by  doxygen 1.3.8-20040928