Imported Upstream version 1.3.99.3~20130529~SE~b989f69~SYSYNC~3366831
[platform/upstream/syncevolution.git] / src / synthesis / src / sysync_SDK / Sources / SDK_util.c
1 /*
2  *  File:     SDK_util.c
3  *
4  *  Authors:  Beat Forster
5  *
6  *
7  *  SDK utility functions for
8  *   - version handling
9  *   - string alloc/dispose
10  *   - debug/callback
11  *
12  *  written in Std C, can be used in C++ as well
13  *
14  *  Copyright (c) 2004-2011 by Synthesis AG + plan44.ch
15  *
16  */
17
18
19 #include "sync_dbapidef.h"
20 #include "SDK_util.h"
21 #include <string.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24
25 #ifndef __MACH__
26 #include <malloc.h>
27 #endif
28
29 #ifdef ANDROID
30 #include "android/log.h"
31 #endif
32
33 #define MyDB "SDK"                    /* local debug name */
34 #define Old_SDKversionMask 0xffff00ff /* Old mask for version comparison: Omit OS identifier */
35 #define maxmsglen 1024                /* Maximum string length for callback string */
36
37
38
39 /* This StdC module is independent from namespace "sysync" */
40
41 /* Get the plug-in's version/subversion number
42  * The plugin will contain a user defined <buildNumber> 0..255
43  * This version number is defined by Synthesis and should not be changed:
44  * The engine contains also a version number, and makes some comparisons.
45  */
46 CVersion Plugin_Version( short buildNumber )
47 {
48   #define P 256
49   long    v;
50
51   #define SDK_VERSION_MAJOR 1 /* Release: V1.9.1, change this if you need troubles */
52   #define SDK_VERSION_MINOR 9
53   #define SDK_SUBVERSION    1
54
55   /* allowed range for the local build number */
56   if (buildNumber<  0) buildNumber=   0;
57   if (buildNumber>255) buildNumber= 255;
58
59   v= ((SDK_VERSION_MAJOR *P +
60        SDK_VERSION_MINOR)*P +
61        SDK_SUBVERSION   )*P +
62        buildNumber;
63
64   return v;
65 } /* Plugin_Version */
66
67
68
69 /* Check, if <version_feature> is supported in <currentVersion>
70  * NOTE: For the SyncML engine internally everything is supported
71  *       This will be reflected with the fact that for 2.1.1.X
72  *       the engine's version was always much much higher.
73  *       Today the engine's version is equivalent to the SDK version.
74  */
75 bool Feature_Supported  ( CVersion versionFeature, CVersion currentVersion )
76 {
77   CVersion v= currentVersion;
78   if      (v<VP_NewBuildNumber) v= v & Old_SDKversionMask; /* avoid OS identifier comparison */
79   return   v>=versionFeature;
80 } /* FeatureSupported */
81
82
83 /* Check, if <version_feature> is equivalent to <currentVersion>
84  */
85 bool Feature_SupportedEq( CVersion versionFeature, CVersion currentVersion )
86 {
87   CVersion v= currentVersion;
88   if      (v<VP_NewBuildNumber) v= v & Old_SDKversionMask; /* avoid OS identifier comparison */
89   return   v==versionFeature;
90 } /* FeatureSupportedEq */
91
92
93
94 /* Get platform identifier */
95 cAppCharP MyPlatform( void )
96 {
97   cAppCharP p;
98
99   #if defined  MACOSX
100     #if defined IPHONEOS
101       p= "PLATFORM:iPhone"; /* there is ONLY XCode, no need to mention that here */
102     #elif defined __MWERKS__
103       p= "PLATFORM:Mac (CodeWarrior)";
104     #elif defined __GNUC__
105       p= "PLATFORM:Mac (XCode)";
106     #else
107       p= "PLATFORM:Mac";
108     #endif
109
110   #elif defined _WIN32
111     #ifdef __MWERKS__
112       p= "PLATFORM:Windows (CodeWarrior)";
113     #elif defined _MSC_VER
114       p= "PLATFORM:Windows (VisualStudio)";
115     #else
116       p= "PLATFORM:Windows";
117     #endif
118
119   #elif defined  LINUX
120     #ifdef ANDROID
121       p= "PLATFORM:Android";
122     #else
123       p= "PLATFORM:Linux";
124     #endif
125
126 /* elif **** for JAVA defined at the Java code ******** */
127 /*  p= "PLATFORM:Java" */
128
129 /* elif **** for .net defined at the C#   code ******** */
130 /*  p= "PLATFORM:C#"   */
131
132   #else
133     p= "PLATFORM:unknown";
134   #endif
135
136   return p;
137 } /* MyPlatform */
138
139
140
141 /* -------------------- string allocation/deallocation -------- */
142 /* Allocate local memory for a string */
143 appCharP StrAllocN( cAppCharP s, int n, bool fullSize )
144 {
145   char* cp;
146   int   len;
147
148   if (!fullSize) {
149           len= strlen( s );
150     if (n>len) n= len; /* never more than the length of <s> */
151   } /* if */
152
153   cp= (char*)malloc( n+1 );
154   if (cp) {
155     strncpy( cp, s, n ); /* not yet NUL terminated !! */
156     cp[ n ]= '\0';
157   }
158   return   cp;
159 } /* StrAllocN */
160
161
162 /* Allocate local memory for a string */
163 appCharP StrAlloc ( cAppCharP  s ) {
164   return StrAllocN( s, strlen( s ), true );
165 } /* StrAlloc */
166
167
168 /* !Dispose a string which has been allocated with 'StrAlloc' */
169 void StrDispose( void* s ) {
170   if (s!=NULL)   free( s );
171 } /* StrDispose */
172
173
174
175 /* ------------------ field operations ------------------------- */
176 bool Field( cAppCharP item, cAppCharP key, char** field )
177 {
178   char* b;
179   char* e;
180   char* t= (char*)item;
181
182   *field= NULL;
183   while (true) {
184     b= strstr( t,key ); if (!b) break; /* <key> available ? */
185             e= strstr( b,"\r" );
186     if (!e) e= strstr( b,"\n" ); /* get the end of this field */
187
188     if (b==item || *(b-1)=='\r'
189                 || *(b-1)=='\n') {
190       b+= strlen( key )+1;
191
192       if (*(b-1)==':') {                         /* correctly separated ? */
193         if (!e) *field= StrAlloc ( b );             /* either the rest    */
194         else    *field= StrAllocN( b, e-b, false ); /* or till next field */
195         return *field != NULL;
196       } /* if */
197     } /* if */
198
199     if (!e) break;
200
201     t= e+1; /* go to the next field */
202   } /* loop */
203
204   return false;
205 } /* Field */
206
207
208
209 bool SameField( cAppCharP item, cAppCharP key, cAppCharP field )
210 {
211   char* vv;
212   bool  ok= Field( item, key, &vv );   /* get the <key> field */
213   if   (ok) {
214     ok= strcmp( field,vv )==0; /* and compare it with <field> */
215     StrDispose      ( vv );     /* <vv> is no longer used now */
216   } /* if */
217
218   return ok;
219 } /* SameField */
220
221
222
223 /* ------------------ callback system -------------------------------------- */
224 /* Initialize to safe defaults, useable for Std C as well
225  * NOTE: The current = latest available <callbackVersion> will be taken
226  */
227 static bool BadCB( void* aCallbackRef )
228 {
229   DB_Callback cb= aCallbackRef;
230
231   if (cb==NULL) {
232     printf( "bad cb==NULL\n" );    return true;
233   } /* if */
234
235   if (cb->callbackRef!=cb) {
236     printf( "bad callbackRef %08lX <> %08lX\n",
237                (unsigned long)cb->callbackRef,
238                (unsigned long)cb ); return true;
239   } /* if */
240
241   return false; /* false= it's ok */
242 } /* BadCB */
243
244
245 void NBlk( void* aCallbackRef )
246 {
247   int  i;
248   DB_Callback cb= aCallbackRef;
249   if (!CB_OK( cb,2 )) return;
250 /*if     ( BadCB( aCallbackRef )) return;*/
251
252   for (i=0; i<cb->lCount; i++) printf( "  " );
253 } /* NBlk */
254
255
256
257 static void BeginBlk( void* aCallbackRef, cAppCharP aTag,
258                                           cAppCharP aDesc,
259                                           cAppCharP aAttrText )
260 {
261   DB_Callback cb= aCallbackRef;
262   if     ( BadCB( aCallbackRef )) return;
263
264   NBlk( cb ); printf( "<%s> %s %s\n", aTag, aDesc, aAttrText );
265         cb->lCount++;
266 } /* BeginBlk */
267
268
269
270 static void EndBlk( void* aCallbackRef, cAppCharP aTag )
271 {
272   DB_Callback cb= aCallbackRef;
273   if (!CB_OK( cb,2 )) return;
274 /*if     ( BadCB( aCallbackRef )) return;*/
275
276         cb->lCount--;
277   NBlk( cb ); printf( "</%s>\n", aTag );
278 } /* EndBlk */
279
280
281
282 static void EndThread( void* aCallbackRef )
283 {
284   DB_Callback cb= aCallbackRef;
285   if (!CB_OK( cb,2 )) return;
286 /*if     ( BadCB( aCallbackRef )) return;*/
287
288   NBlk( cb ); printf( "=EndThread=\n" );
289 } /* EndThread */
290
291
292
293 /* -------------------------------------------------------------------- */
294 void InitCallback( void* aCB, uInt16 aVersion, void* aRoutine, void* aExoticRoutine )
295 {
296   DB_Callback cb= aCB;
297   if        (!cb) return;
298
299   cb->callbackVersion= aVersion;
300   cb->callbackRef    = cb;                 /* the callback pointer is the cb itself here */
301
302   if (CB_OK( cb,1 )) {
303     cb->debugFlags   = 0;                  /* debug disable so far */
304     cb->DB_DebugPuts = aRoutine;
305     if                (aRoutine) {
306       if        (aExoticRoutine) cb->debugFlags= DBG_PLUGIN_ALL;
307       else                       cb->debugFlags= DBG_PLUGIN_INT + DBG_PLUGIN_DB;
308     } /* if */
309
310     cb->cContext= 0;                       /* contexts */
311     cb->mContext= 0;
312     cb->sContext= 0;
313   } /* if */
314
315   if (CB_OK( cb,2 )) {
316     cb->DB_DebugBlock    = BeginBlk;       /* level 2 */
317     cb->DB_DebugEndBlock = EndBlk;
318     cb->DB_DebugEndThread= EndThread;
319     cb->lCount           = 0;
320   } /* if */
321
322   if (CB_OK( cb,3 ))
323     cb->DB_DebugExotic  = aExoticRoutine;  /* level 3 */
324
325   if (CB_OK( cb,4 ))
326     cb->allow_DLL_legacy= 0; /* false */   /* level 4 */
327
328   if (CB_OK( cb,5 ))
329     cb->allow_DLL       = 0; /* false */   /* level 5 */
330
331   if (CB_OK( cb,6 )) {
332     cb->reserved1= 0;                      /* level 6 */
333     cb->reserved2= 0;
334     cb->reserved3= 0;
335     cb->reserved4= 0;
336   } /* if */
337
338   if (CB_OK( cb,7 )) {
339     cb->thisCB  = cb;                      /* level 7 */
340     cb->logCount=  0;
341   } /* if */
342
343   if (CB_OK( cb,8 )) {
344     cb->thisBase            = NULL;        /* level 8 */
345     cb->jRef                = NULL;
346     cb->gContext            = 0;
347
348     cb->ui.SetStringMode    = NULL;
349     cb->ui.InitEngineXML    = NULL;
350     cb->ui.InitEngineFile   = NULL;
351     cb->ui.InitEngineCB     = NULL;
352
353     cb->ui.OpenSession      = NULL;
354     cb->ui.OpenSessionKey   = NULL;
355     cb->ui.SessionStep      = NULL;
356     cb->ui.GetSyncMLBuffer  = NULL;
357     cb->ui.RetSyncMLBuffer  = NULL;
358     cb->ui.ReadSyncMLBuffer = NULL;
359     cb->ui.WriteSyncMLBuffer= NULL;
360     cb->ui.CloseSession     = NULL;
361
362     cb->ui.OpenKeyByPath    = NULL;
363     cb->ui.OpenSubkey       = NULL;
364     cb->ui.DeleteSubkey     = NULL;
365     cb->ui.GetKeyID         = NULL;
366     cb->ui.SetTextMode      = NULL;
367     cb->ui.SetTimeMode      = NULL;
368     cb->ui.CloseKey         = NULL;
369
370     cb->ui.GetValue         = NULL;
371     cb->ui.GetValueByID     = NULL;
372     cb->ui.GetValueID       = NULL;
373     cb->ui.SetValue         = NULL;
374     cb->ui.SetValueByID     = NULL;
375   } /* if */
376
377   if (CB_OK( cb,9 )) {
378     cb->SDK_Interface_size= sizeof(SDK_Interface_Struct); /* level 9 */
379
380     cb->dt.StartDataRead    = NULL; /* tunnel callback functions, for internal use only */
381     cb->dt.ReadNextItem     = NULL;
382     cb->dt.ReadItem         = NULL;
383     cb->dt.EndDataRead      = NULL;
384
385     cb->dt.StartDataWrite   = NULL;
386     cb->dt.InsertItem       = NULL;
387     cb->dt.UpdateItem       = NULL;
388     cb->dt.MoveItem         = NULL;
389     cb->dt.DeleteItem       = NULL;
390     cb->dt.EndDataWrite     = NULL;
391   } /* if */
392
393   if (CB_OK( cb,11 )) {
394     cb->dt.DisposeObj       = NULL;
395
396     cb->dt.ReadNextItemAsKey= NULL;
397     cb->dt.ReadItemAsKey    = NULL;
398     cb->dt.InsertItemAsKey  = NULL;
399     cb->dt.UpdateItemAsKey  = NULL;
400   } /* if */
401 } /* InitCallback */
402
403
404
405 /* Initialize to safe defaults and "CB_PurePrintf", usable for Std C as well */
406 /* Normal debug output */
407 void InitCallback_Pure  ( void* aCB, uInt16 aVersion ) {
408      InitCallback             ( aCB,        aVersion, CB_PurePrintf, NULL );
409 } /* InitCallback_Pure */
410
411
412 /* Initialize to safe defaults and "CB_PurePrintf", usable for Std C as well */
413 /* Normal and exotic debug output */
414 void InitCallback_Exotic( void* aCB, uInt16 aVersion ) {
415      InitCallback             ( aCB,        aVersion, CB_PurePrintf, CB_PurePrintf );
416 } /* InitCallback_Exotic */
417
418
419
420 /* The <aRoutine> for 'InitCallback', when a simple "printf" is
421  * requested for the callback.
422  *
423  * Routine must be defined as
424  *   typedef void (*DB_DebugPuts_Func)( void *aCallbackRef, cAppCharP aText );
425  */
426 void CB_PurePrintf( void* aCB, cAppCharP aText )
427 {
428   DB_Callback cb= aCB;
429   if (!CB_OK( cb,2 )) return;
430 /*if ( BadCB( aCB ))  return;*/
431
432   NBlk( cb ); printf( "%s\n", aText );
433 } /* CB_PurePrintf */
434
435
436
437 /* Get the size of the SDK_Interface_Struct to be copied */
438 TSyError SDK_Size( void* aCB, uInt32 *sSize )
439 {
440   TSyError    err= LOCERR_OK;
441   DB_Callback cb = aCB;
442
443   do {
444     /* try to get the SDK_Interface_Struct <sSize> of the calling engine */
445     if (cb->callbackVersion< SDK_Interface_Struct_V8)  { err= LOCERR_TOOOLD; break; }
446     if (cb->callbackVersion==SDK_Interface_Struct_V8) *sSize=     SDK_Interface_Struct_V8_Size;
447     else                                              *sSize= cb->SDK_Interface_size;
448
449     /* but it must neither be smaller than version 8 size nor larger than the own size */
450     if (*sSize<       SDK_Interface_Struct_V8_Size)    { err= LOCERR_TOOOLD; break; }
451     if (*sSize>sizeof(SDK_Interface_Struct))          *sSize= sizeof(SDK_Interface_Struct);
452   } while (false);
453
454 /*printf( "sizeof=%d sSize=%d err=%d\n", sizeof(SDK_Interface_Struct), *sSize, err );*/
455   return err;
456 } /* SDK_Size */
457
458
459
460 /* ---------- debug output ----------------------------------- */
461 /* prints directly to the screen */
462 static void ConsolePuts( cAppCharP msg )
463 {
464   #ifdef ANDROID
465     __android_log_write( ANDROID_LOG_DEBUG, "ConsolePuts", msg );
466   #else
467     printf( "%s\n", msg );
468   #endif
469 } /* ConsolePuts */
470
471
472 #if !defined(SYSYNC_ENGINE) && !defined(UIAPI_LINKED)
473   /* the Synthesis SyncML engine has its own implementation */
474   /* => use this code in SDK only */
475   void ConsoleVPrintf( cAppCharP format, va_list args )
476   {
477     #ifdef SYDEBUG
478       char         msg[ maxmsglen ];
479                    msg[ 0 ]= '\0';               /* start with an empty <msg> */
480       vsnprintf  ( msg, maxmsglen,format,args ); /* assemble the message string */
481       ConsolePuts( msg );                        /* write the string */
482     #endif
483   } /* ConsoleVPrintf */
484
485   void ConsolePrintf( cAppCharP text, ... )
486   {
487     va_list              args;
488     va_start           ( args,text );
489     ConsoleVPrintf( text,args );
490     va_end             ( args );
491   } /* ConsolePrintf */
492 #endif
493
494
495 /* Get the callback version of <aCB> */
496 uInt16 CB_Version( void* aCB )
497 {
498   DB_Callback    cb= aCB;
499   if (cb) return cb->callbackVersion;
500   else    return 0;
501 } /* CB_Version */
502
503
504 /* Check, if <aCB> structure is at least <minVersion> */
505 bool CB_OK( void* aCB, uInt16 minVersion ) { return CB_Version( aCB )>=minVersion; }
506
507 /* Check, if <aCB> structure supports UI callback (cbVersion>=6) */
508 /* static bool CB_UI( void* aCB ) { return CB_OK( aCB,6 ); } */
509
510 /* Check, if <aCB> structure supports <gContext>  (cbVersion>=8) and <gContext> <> 0 */
511 bool CB_gContext ( void* aCB )
512 {
513   DB_Callback cb= aCB;
514   return CB_OK  ( aCB,8 ) && cb->gContext!=0;
515 } /* CB_gContext */
516
517
518 /* Check, if <aCB> structure supports CA_SubSytem (cbVersion>=10) */
519 bool CB_SubSystem( void* aCB ) { return CB_OK( aCB,10 ); }
520
521
522 /* Check, if <aCB> structure is at least <minVersion> and DBG_PLUGIN_DB is set */
523 bool DB_OK( void* aCB, uInt16 minVersion )
524 {
525   DB_Callback cb= aCB;                 /* at least one flag must be set */
526   return   CB_OK( aCB,minVersion ) && (DBG_PLUGIN_DB & cb->debugFlags)!=DBG_PLUGIN_NONE;
527 } /* DB_OK */
528
529
530 /* Check, if <aCB> structure is at least <minVersion> and one of <debugFlags> is set */
531 bool Callback_OK( void* aCB, uInt16 minVersion, uInt16 debugFlags )
532 {
533   DB_Callback cb= aCB; /* at least one flag must be set */
534   return   CB_OK( aCB,minVersion ) && (debugFlags & cb->debugFlags)!=DBG_PLUGIN_NONE;
535 } /* Callback_OK */
536
537
538
539 /* Normal callback output of <text> */
540 void CallbackPuts( void* aCB, cAppCharP text )
541 {
542   DB_Callback   cb= aCB;
543   if (!Callback_OK( aCB, 1,DBG_PLUGIN_ALL )) return;
544
545   if (cb->DB_DebugPuts)
546       cb->DB_DebugPuts( cb->callbackRef, text );
547 } /* CallbackPuts */
548
549
550
551 /* Exotic callback output of <text> */
552 static void CallbackExotic( void* aCB, cAppCharP text )
553 {
554   DB_Callback   cb= aCB;
555   if (!Callback_OK( aCB, 3,DBG_PLUGIN_ALL )) { CallbackPuts( aCB,text ); return; }
556
557   if (cb->DB_DebugExotic)
558       cb->DB_DebugExotic( cb->callbackRef, text );
559 } /* CallbackExotic */
560
561
562
563 static void CallbackVPrintf( DB_Callback aCB, cAppCharP format, va_list args, uInt16 outputMode )
564 {
565   #ifdef SYDEBUG
566     #ifdef __GNUC__
567       int isMax;
568     #endif
569
570     char               message[ maxmsglen ];
571     char* ptr= (char*)&message;
572
573     #ifdef __GNUC__
574     // need a copy for vasprintf() call
575     va_list copy;
576     va_copy(copy, args);
577     #endif
578
579                message[ 0 ]= '\0';                /* start with an empty <msg> */
580     vsnprintf( message, maxmsglen, format,args ); /* assemble the message string */
581
582     #ifdef __GNUC__
583           isMax= strlen(message)==maxmsglen-1;
584       if (isMax && vasprintf( &ptr, format, copy ) != -1) {};
585       va_end(copy);
586     #endif
587
588     switch (outputMode) {
589       case OutputNorm        : CallbackPuts  ( aCB, ptr ); break;
590    /* case OutputExoticBefore: */
591    /* case OutputExoticAfter : */
592       case OutputExotic      : CallbackExotic( aCB, ptr ); break;
593       case OutputConsole     :
594       case OutputExoticBefore:
595       case OutputExoticAfter :
596       case OutputBefore      :
597       case OutputAfter       : NBlk   ( (void*)aCB );
598                                ConsolePuts        ( ptr ); break;
599     } /* switch */
600
601     #ifdef __GNUC__
602       if (isMax) free( ptr );
603     #endif
604   #endif
605 } /* CallbackVPrintf */
606
607
608
609 void DEBUG_( void* aCB, cAppCharP text, ... )
610 {
611   #ifdef SYDEBUG
612     va_list args;
613
614     if (Callback_OK( aCB, 1,DBG_PLUGIN_ALL )) {
615       va_start                 ( args,text );
616       CallbackVPrintf( aCB, text,args, false );
617       va_end                   ( args );
618     } /* if (gDebug) */
619   #endif
620 } /* DEBUG_ */
621
622
623
624 #ifdef SYDEBUG
625 void DoDEBUG( void* aCB, uInt16 outputMode, bool withIntro,
626                     cAppCharP ident,
627                     cAppCharP routine, va_list args,
628                     cAppCharP text )
629 {
630   cAppCharP dbIntro= "";
631   cAppCharP id     = "";
632   cAppCharP isX    = "";
633   cAppCharP p      = "";
634   char*     s;
635   int       size;
636
637   if (*routine!='\0') {
638     if (withIntro) {                      dbIntro= "##### ";
639       if (outputMode==OutputBefore ||
640           outputMode==OutputExoticBefore) dbIntro= ">>>>> ";
641       if (outputMode==OutputAfter  ||
642           outputMode==OutputExoticAfter)  dbIntro= "<<<<< ";
643     } /* if */
644
645     id= ident;
646
647     #if   defined SDK_LIB
648       isX=       ": ";
649     #elif defined SDK_DLL
650       isX= " (DLL): ";
651     #else
652       isX= " (LNK): ";
653     #endif
654
655     if (*text!='\0') p= ": ";
656   } /* if */
657
658   size= strlen(dbIntro) + strlen(id)      +
659         strlen(isX)     + strlen(routine) +
660         strlen(p)       + strlen(text)    + 1;
661
662   s= (char*)malloc( size );
663   if (s) {
664     sprintf( s, "%s%s%s%s%s%s", dbIntro,id,isX,routine,p,text );
665     CallbackVPrintf( aCB, s,args, outputMode );
666     free   ( s );
667   }
668 } /* DoDEBUG */
669 #endif
670
671
672
673 /* ------------------------------------------------------------------------------------- */
674 void DEBUG_Call( void* aCB, uInt16 debugFlags,
675                          cAppCharP ident,
676                          cAppCharP routine,
677                          cAppCharP text, ... )
678 {
679   #ifdef SYDEBUG
680     va_list args;
681
682     if (Callback_OK( aCB, 1,debugFlags )) {
683       va_start                               ( args,text );
684       DoDEBUG( aCB, false,true, ident,routine, args,text );
685       va_end                                 ( args );
686     } /* if */
687   #endif
688 } /* DEBUG_Call */
689
690
691
692 void DEBUG_INT( void* aCB, cAppCharP ident,
693                            cAppCharP routine,
694                            cAppCharP text, ... )
695 {
696   #ifdef SYDEBUG
697     va_list args;
698     if (Callback_OK( aCB, 1,DBG_PLUGIN_INT )) {
699       va_start                               ( args,text );
700       DoDEBUG( aCB, false,true, ident,routine, args,text );
701       va_end                                 ( args );
702     } /* if */
703   #endif
704 } /* DEBUG_INT */
705
706
707
708 void DEBUG_DB( void* aCB, cAppCharP ident,
709                           cAppCharP routine,
710                           cAppCharP text, ... )
711 {
712   #ifdef SYDEBUG
713     va_list args;
714     if (Callback_OK( aCB, 1,DBG_PLUGIN_DB )) {
715       va_start                               ( args,text );
716       DoDEBUG( aCB, false,true, ident,routine, args,text );
717       va_end                                 ( args );
718     } /* if */
719   #endif
720 } /* DEBUG_DB */
721
722
723
724 /* ------------------------------------------------------------------------------------- */
725 void DEBUG_Exotic_INT( void* aCB, cAppCharP ident,
726                                   cAppCharP routine,
727                                   cAppCharP text, ... )
728 {
729   #ifdef SYDEBUG
730     va_list args;
731     if (Callback_OK( aCB, 1,DBG_PLUGIN_INT  ) &&
732         Callback_OK( aCB, 1,DBG_PLUGIN_EXOT )) {
733       va_start                              ( args,text );
734       DoDEBUG( aCB, true,true, ident,routine, args,text );
735       va_end                                ( args );
736     } /* if */
737   #endif
738 } /* DEBUG_Exotic_INT */
739
740
741
742 void DEBUG_Exotic_DB( void* aCB, cAppCharP ident,
743                                  cAppCharP routine,
744                                  cAppCharP text, ... )
745 {
746   #ifdef SYDEBUG
747     va_list args;
748     if (Callback_OK( aCB, 1,DBG_PLUGIN_EXOT )) {
749       va_start                              ( args,text );
750       DoDEBUG( aCB, true,true, ident,routine, args,text );
751       va_end                                ( args );
752     } /* if */
753   #endif
754 } /* DEBUG_Exotic_DB */
755
756
757
758 void DEBUG_Exotic_DBW( void* aCB, cAppCharP ident,
759                                   cAppCharP routine,
760                                   cAppCharP text, ... )
761 {
762   #ifdef SYDEBUG
763     va_list args;
764     if (Callback_OK( aCB, 1,DBG_PLUGIN_EXOT )) {
765       va_start                              ( args,text );
766       DoDEBUG( aCB, true,false,ident,routine, args,text );
767       va_end                                ( args );
768     } /* if */
769   #endif
770 } /* DEBUG_Exotic_DBW */
771
772
773
774 /* ------------------------------------------------------------------------------------- */
775 /* Start of sub block */
776 void DEBUG_Block( void* aCB, cAppCharP aTag,
777                              cAppCharP aDesc,
778                              cAppCharP aAttrText )
779 {
780   /* callbackVersion >= 2 support for blocks */
781   #ifdef SYDEBUG
782     DB_Callback cb=  aCB;
783     if (Callback_OK( aCB, 2,DBG_PLUGIN_ALL ) &&
784         cb->DB_DebugBlock)
785         cb->DB_DebugBlock( cb->callbackRef, aTag,aDesc,aAttrText );
786     else /* old */
787       DEBUG_DB( aCB, MyDB, aTag, "%s (%s) BEGIN", aAttrText,aDesc );
788   #endif
789 } /* DEBUG_Block */
790
791
792
793 /* End of sub block */
794 void DEBUG_EndBlock( void* aCB, cAppCharP aTag )
795 {
796   #ifdef SYDEBUG
797     DB_Callback cb=  aCB;
798     if (Callback_OK( aCB, 2,DBG_PLUGIN_ALL ) &&
799         cb->DB_DebugEndBlock)
800         cb->DB_DebugEndBlock( cb->callbackRef, aTag );
801     else /* old */
802       DEBUG_DB( aCB, MyDB, aTag, "END" );
803   #endif
804 } /* DEBUG_EndBlock */
805
806
807
808 void DEBUG_EndThread( void* aCB )
809 {
810   #ifdef SYDEBUG
811     DB_Callback cb=  aCB;
812     if (Callback_OK( aCB, 2,DBG_PLUGIN_ALL ) &&
813         cb->DB_DebugEndThread)
814         cb->DB_DebugEndThread( cb->callbackRef );
815     else /* old */
816       DEBUG_DB( aCB, MyDB, "THREAD", "END" );
817   #endif
818 } /* DEBUG_EndThread */
819
820
821 /* eof */