📄 utildebug.c,v
字号:
head 1.1;access;symbols;locks; strict;comment @ * @;1.1date 2002.07.02.19.30.41; author rbraud; state Exp;branches;next ;desc@@1.1log@Initial revision@text@#include <stdio.h>#include <errno.h>#include <stdarg.h>#include <string.h>#include <stdlib.h>#include "utilDebug.h"/* extern char *sys_errlist[]; *//***************************************************************************/FILE *utilDebugFile = NULL;/* FILE *utilDebugFile = stderr; */int utilDebugLevel = UTIL_CRITICAL;/***************************************************************************//* InfoMessage is a printf-like funtion that prints a debugging message if the current debugging level is less-than priorityLabel*//***************************************************************************/void UTIL_InfoMessage(int priorityLabel,char *string,...){ va_list args; if (priorityLabel >= utilDebugLevel) { va_start(args,string); vfprintf(utilDebugFile,string,args); va_end(args); }}/***************************************************************************//* UTIL_SetDebugFile() redirects all further debugging output to the file fp *//***************************************************************************/int UTIL_SetDebugFile(FILE *fp){ if ((utilDebugFile != NULL) && (utilDebugFile != stderr) && (utilDebugFile != stdout)) UTIL_AssertTrue(fclose(utilDebugFile) == 0, "Unable to close current debug file", UTIL_ABORT,0); utilDebugFile = fp; return 0;}/***************************************************************************//* UTIL_SetDebugLevel() sets the current debugging level to newLevel*//***************************************************************************/int UTIL_SetDebugLevel(int newLevel){ UTIL_InfoMessage(UTIL_CRITICAL,"Changing debug level to %d\n",newLevel); utilDebugLevel = newLevel; return 0;}intUTIL_ParseArguments(char **argv,int *argc){ int i,j; for (i=0;i<*argc;i++) if (strncasecmp(argv[i],"-util",4) == 0) { if (strcasecmp(argv[i],"-utilDebugFile") == 0) { FILE *x; UTIL_AssertTrue(i != *argc, "no file listed with utilDebugFile",UTIL_ABORT,0); UTIL_InfoMessage(UTIL_INFORMATION, "Openning debug file %s\n",argv[i+1]); x = fopen(argv[i+1],"w"); UTIL_AssertTrue(x != NULL, "Unable to open file for writing",UTIL_ABORT,0); UTIL_SetDebugFile(x); *argc -= 2; for (j=i;j<*argc;j++) { UTIL_InfoMessage(UTIL_INFORMATION,"Removing argument %s",argv[j]); argv[j] = argv[j+2]; } } /* end of utilDebugFile argument test */ if (strcasecmp(argv[i],"-utilDebugLevel") == 0) { UTIL_AssertTrue(i != *argc, "no level listed with utilDebugLevel",UTIL_ABORT,0); UTIL_InfoMessage(UTIL_INFORMATION, "Setting debug level to %d\n",atoi(argv[i+1])); UTIL_SetDebugLevel(atoi(argv[i+1])); *argc -= 2; for (j=i;j<*argc;j++) { UTIL_InfoMessage(UTIL_INFORMATION,"Removing argument %s",argv[j]); argv[j] = argv[j+2]; } } /* end of utilDebugLevel argument test */ } /* end of test for util* argument */ return 0;}@
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -