00001 // debug.cc 00002 // Debugging routines. Allows users to control whether to 00003 // print DEBUG statements, based on a command line argument. 00004 // 00005 // Copyright (c) 1992-1996 The Regents of the University of California. 00006 // All rights reserved. See copyright.h for copyright notice and limitation 00007 // of liability and disclaimer of warranty provisions. 00008 00009 #include "copyright.h" 00010 #include "utility.h" 00011 #include "debug.h" 00012 #include "string.h" 00013 00014 //---------------------------------------------------------------------- 00015 // Debug::Debug 00016 // Initialize so that only DEBUG messages with a flag in flagList 00017 // will be printed. 00018 // 00019 // If the flag is "+", we enable all DEBUG messages. 00020 // 00021 // "flagList" is a string of characters for whose DEBUG messages are 00022 // to be enabled. 00023 //---------------------------------------------------------------------- 00024 00025 Debug::Debug(char *flagList) 00026 { 00027 enableFlags = flagList; 00028 } 00029 00030 00031 //---------------------------------------------------------------------- 00032 // Debug::IsEnabled 00033 // Return TRUE if DEBUG messages with "flag" are to be printed. 00034 //---------------------------------------------------------------------- 00035 00036 bool 00037 Debug::IsEnabled(char flag) 00038 { 00039 if (enableFlags != NULL) { 00040 return ((strchr(enableFlags, flag) != 0) 00041 || (strchr(enableFlags, '+') != 0)); 00042 } else { 00043 return FALSE; 00044 } 00045 }