Jabber WindowGram Client (JWGC)

Introduction Screenshots Installation Downloads
Documentation Browse Source Resources Project Site

Stable Version
-none-

Latest Version
beta5



Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

JDebug.c

Go to the documentation of this file.
00001 #include <sysdep.h>
00002 #include "include/libjwgc.h"
00003 
00004 /* $Id: JDebug.c,v 1.9 2004/03/08 04:30:37 jadestorm Exp $ */
00005 
00006 int debug_enabled[dNumZones];
00007 char *debug_zones[dNumZones];
00008 
00009 void 
00010 dinit()
00011 {
00012 #ifndef NODEBUG
00013         dZone i;
00014 
00015         for (i = 0; i < dNumZones; i++) {
00016                 debug_enabled[i] = 0;
00017         }
00018 
00019         debug_zones[dJWG] = "jwg";
00020         debug_zones[dParser] = "parser";
00021         debug_zones[dJAB] = "jab";
00022         debug_zones[dOutput] = "output";
00023         debug_zones[dEval] = "eval";
00024         debug_zones[dPoll] = "poll";
00025         debug_zones[dExecution] = "execution";
00026         debug_zones[dVars] = "vars";
00027         debug_zones[dMatch] = "match";
00028         debug_zones[dXML] = "xml";
00029         debug_zones[dGPG] = "gpg";
00030 #endif /* NODEBUG */
00031 }
00032 
00033 void 
00034 dflagon(dZone zone)
00035 {
00036 #ifndef NODEBUG
00037         debug_enabled[zone] = 1;
00038 #endif /* NODEBUG */
00039 }
00040 
00041 void 
00042 dflagoff(dZone zone)
00043 {
00044 #ifndef NODEBUG
00045         debug_enabled[zone] = 0;
00046 #endif /* NODEBUG */
00047 }
00048 
00049 void 
00050 dprintf(dZone zone, const char *msgfmt, ...)
00051 {
00052 #ifndef NODEBUG
00053         va_list ap;
00054 
00055         if (!debug_enabled[zone]) {
00056                 return;
00057         }
00058 
00059         va_start(ap, msgfmt);
00060         printf("[%s] ", dzoneitos(zone));
00061         vprintf(msgfmt, ap);
00062         va_end(ap);
00063 #endif /* NODEBUG */
00064 }
00065 
00066 void
00067 dprinttypes()
00068 {
00069 #ifndef NODEBUG
00070         dZone i;
00071 
00072         fprintf(stderr, "\
00073 Debugging usage:\n\
00074   <flags> can contain any number of the following flags, separated by commas.\n\
00075   If you wish to use 'all' to enable all flags, and then disable a couple,\n\
00076   you can prepend the flag with a - (Ex: all,-poll,-eval).  The available\n\
00077   flags are as follows:\n\
00078 \n\
00079 ");
00080         for (i = 0; i < dNumZones; i++) {
00081                 printf("     %s\n", debug_zones[i]);
00082         }
00083 
00084         exit(1);
00085 #endif /* NODEBUG */
00086 }
00087 
00088 char *
00089 dzoneitos(dZone zone)
00090 {
00091 #ifndef NODEBUG
00092         return debug_zones[zone];
00093 #endif /* NODEBUG */
00094 }
00095 
00096 dZone 
00097 dzonestoi(char *zone)
00098 {
00099 #ifndef NODEBUG
00100         dZone i;
00101 
00102         for (i = 0; i < dNumZones; i++) {
00103                 if (!strcmp(zone, debug_zones[i])) {
00104                         return i;
00105                 }
00106         }
00107 
00108         return -1;
00109 #endif /* NODEBUG */
00110 }
00111 
00112 void
00113 dparseflags(char *flags)
00114 {
00115 #ifndef NODEBUG
00116         char *ptr;
00117         int retval;
00118         dZone i;
00119 
00120         if (!flags) { return; }
00121 
00122         ptr = strtok(flags, ",");
00123         while (ptr != NULL) {
00124                 if (!strcmp(ptr, "-all")) {
00125                         for (i = 0; i < dNumZones; i++) {
00126                                 debug_enabled[i] = 0;
00127                         }
00128                 }
00129                 else if (!strcmp(ptr, "all")) {
00130                         for (i = 0; i < dNumZones; i++) {
00131                                 debug_enabled[i] = 1;
00132                         }
00133                 }
00134                 else {
00135                         if (*ptr == '-') {
00136                                 retval = dzonestoi(++ptr);
00137                                 if (retval != -1) {
00138                                         dflagoff(retval);
00139                                 }
00140                         }
00141                         else {
00142                                 retval = dzonestoi(ptr);
00143                                 if (retval != -1) {
00144                                         dflagon(retval);
00145                                 }
00146                         }
00147                 }
00148                 
00149                 ptr = strtok(NULL, ",");
00150         }
00151 #endif /* NODEBUG */
00152 }


Last updated at Tue Dec 18 21:07:42 PST 2007. This site and project hosted by...SourceForge.net Logo
Source Perspective by Fisheye