#include "debug.h" int global_debug_level; /* set my command-line args parser */ /* * @fn debug_ Routine to print debug messages. * * This function should not be called directly, but should be accessed * through one of the debugging macros defined above. This way, if * VERBOSE is set to 0, this function will never be called. * * Messages are printed to stdout and stdout flushed. * * @param format Specifies formatting of * arguments. printf() syntax. * @param ... Optional arguments to be printed. * * @return void */ void debug_(int level, char *filename, char *function_name, int line_no, const char *format, ...) { if (level <= global_debug_level) { va_list list; va_start(list, format); fprintf(stdout, "%s(), line %d: ", function_name, line_no); vfprintf(stdout, format, list); va_end(list); fflush(stdout); } }