]> code.citadel.org Git - citadel.git/blob - libCxClient/src/debug.c
Initial revision
[citadel.git] / libCxClient / src / debug.c
1 /**
2  ** libCxClient - Citadel/UX Extensible Client API
3  ** Copyright (c) 2000, Flaming Sword Productions
4  ** Copyright (c) 2001, The Citadel/UX Consortium
5  ** All Rights Reserved
6  **
7  ** Module: debug.o
8  ** Date: 2000-10-15
9  ** Last Revision: 2000-10-15
10  ** Description: Debug functions.
11  ** CVS: $Id$
12  **/
13 #include        <stdio.h>
14 #include        <stdlib.h>
15 #include        <stdarg.h>
16 #include        <CxClient.h>
17 #include        "autoconf.h"
18
19 #ifdef DEBUG
20 #warning        "Debugging Mode Enabled.  This may not be practical for you..."
21
22 /**
23  ** CxDebug(): Output debugging information.
24  **
25  ** [Expects]
26  **  (#define) DFA: __FILE__, __LINE__, __FUNCTION__.
27  **  (char *) fmt: printf()-style format string.
28  **  ...: Arguments to printf() format.
29  **/
30 void            CxDebug(
31                         const char *file, 
32                         int line, 
33                         const char *function, 
34                         char *fmt, 
35                         ...) {
36 va_list         ap;
37
38         va_start(ap,fmt);
39         fprintf(stderr,"%% [%s:%d] %s(): ", file, line, function);
40         vfprintf(stderr,fmt,ap);
41         fprintf(stderr,"\n");
42         va_end(ap);
43
44 }
45
46 #else
47
48
49 #endif
50
51 /**
52  ** CxMalloc(): Allocate memory.  Annotate allocation in debug log.
53  **/
54 void            *CxMalloc(int szlen) {
55 void            *ret;
56
57         ret = malloc(szlen);
58         if(ret) {
59                 DPF((DFA,"MEM/ALC:\t%d\t@0x%08x",szlen, ret));
60         }
61
62         return(ret);
63 }
64
65 /**
66  ** CxFree(): Free memory.  Annotate deallocation in debug log.
67  **/
68 void            *CxFree(void *obj) {
69         DPF((DFA,"MEM/FRE:\t-1\t@0x%08x",obj));
70         free(obj);
71 }
72