Typedef debugflags_t replaces (unsigned int)

This commit is contained in:
Andrew Bettison 2012-10-10 13:21:20 +10:30
parent 3678522872
commit 04d50e0057
3 changed files with 10 additions and 7 deletions

6
conf.c
View File

@ -296,15 +296,15 @@ int64_t confValueGetInt64Range(const char *var, int64_t defaultValue, int64_t ra
void confSetDebugFlags()
{
if (config_buffer || read_config() != -1) {
unsigned int setmask = 0;
unsigned int clearmask = 0;
debugflags_t setmask = 0;
debugflags_t clearmask = 0;
int setall = 0;
int clearall = 0;
unsigned int i;
for (i = 0; i != confc; ++i) {
char *var = confvar[i];
if (strncasecmp(var, "debug.", 6) == 0) {
unsigned int mask = debugFlagMask(var + 6);
debugflags_t mask = debugFlagMask(var + 6);
if (mask == 0)
WARNF("Unsupported debug option '%s'", var);
else {

5
log.c
View File

@ -39,7 +39,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "strbuf.h"
#include "strbuf_helpers.h"
unsigned int debug = 0;
debugflags_t debug = 0;
static FILE *logfile = NULL;
static int flag_show_pid = -1;
@ -290,7 +290,8 @@ int logDump(int level, struct __sourceloc where, char *name, const unsigned char
return 0;
}
unsigned int debugFlagMask(const char *flagname) {
debugflags_t debugFlagMask(const char *flagname)
{
if (!strcasecmp(flagname,"all")) return DEBUG_ALL;
else if (!strcasecmp(flagname,"interfaces")) return DEBUG_OVERLAYINTERFACES;
else if (!strcasecmp(flagname,"rx")) return DEBUG_PACKETRX;

6
log.h
View File

@ -23,7 +23,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <stdarg.h>
#include "strbuf_helpers.h"
extern unsigned int debug;
typedef unsigned int debugflags_t;
extern debugflags_t debug;
#define DEBUG_ALL (~0)
#define DEBUG_PACKETRX (1 << 0)
@ -76,7 +78,7 @@ void logArgv(int level, struct __sourceloc where, const char *label, int argc, c
void logString(int level, struct __sourceloc where, const char *str);
void logMessage(int level, struct __sourceloc where, const char *fmt, ...);
void vlogMessage(int level, struct __sourceloc where, const char *fmt, va_list);
unsigned int debugFlagMask(const char *flagname);
debugflags_t debugFlagMask(const char *flagname);
int logDump(int level, struct __sourceloc where, char *name, const unsigned char *addr, size_t len);
char *toprint(char *dstStr, ssize_t dstBufSiz, const char *srcBuf, size_t srcBytes, const char quotes[2]);
char *toprint_str(char *dstStr, ssize_t dstBufSiz, const char *srcStr, const char quotes[2]);