27 |
#include "rcfile.h" |
#include "rcfile.h" |
28 |
|
|
29 |
void |
void |
30 |
mprintf(char *format, ...) |
mprintf(const char *fmt, ...) |
31 |
{ |
{ |
32 |
va_list arglist; |
va_list arglist; |
33 |
char txt[LINEBUFFER+1]; |
char txt[LINEBUFFER+1]; |
35 |
if (options.termlevel == SILENT) |
if (options.termlevel == SILENT) |
36 |
return; |
return; |
37 |
|
|
38 |
va_start(arglist, format); |
va_start(arglist, fmt); |
39 |
vsnprintf(txt, LINEBUFFER, format, arglist); |
vsnprintf(txt, LINEBUFFER, fmt, arglist); |
40 |
va_end(arglist); |
va_end(arglist); |
41 |
|
|
42 |
puts(txt); |
puts(txt); |
|
return; |
|
43 |
} |
} |
44 |
|
|
45 |
void |
void |
46 |
info(int mode, char *format, ...) |
info(int mode, const char *fmt, ...) |
47 |
{ |
{ |
48 |
va_list arglist; |
va_list arglist; |
49 |
char txt[LINEBUFFER+1]; |
char txt[LINEBUFFER+1]; |
51 |
if (mode > options.termlevel) |
if (mode > options.termlevel) |
52 |
return; |
return; |
53 |
|
|
54 |
va_start(arglist, format); |
va_start(arglist, fmt); |
55 |
vsnprintf(txt, LINEBUFFER, format, arglist); |
vsnprintf(txt, LINEBUFFER, fmt, arglist); |
56 |
va_end(arglist); |
va_end(arglist); |
57 |
|
|
58 |
#ifdef HAVE_SYSLOG |
#ifdef HAVE_SYSLOG |
80 |
FILE *fplog; |
FILE *fplog; |
81 |
|
|
82 |
fplog = fopen(logfile, "a"); |
fplog = fopen(logfile, "a"); |
83 |
if (fplog == 0) |
if (fplog == NULL) |
84 |
return; |
return; |
85 |
else { |
else { |
86 |
time_t tp; |
time_t tp; |
95 |
fprintf(fplog, "%s [%d] %s\n", timebuf, (int)getpid(), txt); |
fprintf(fplog, "%s [%d] %s\n", timebuf, (int)getpid(), txt); |
96 |
fclose(fplog); |
fclose(fplog); |
97 |
} |
} |
|
return; |
|
98 |
} |
} |
99 |
|
|
100 |
void |
void |
102 |
{ |
{ |
103 |
va_list ap; |
va_list ap; |
104 |
int n = 0; |
int n = 0; |
105 |
char txt[LINEBUFFER]; |
char txt[LINEBUFFER+1]; |
106 |
|
|
107 |
if (VERBOSE > options.termlevel) |
if (options.termlevel < VERBOSE) |
108 |
return; |
return; |
109 |
|
|
110 |
if (loc) |
if (loc) |
111 |
n = snprintf(txt, sizeof(txt), "%s:%lu: ", |
n = snprintf(txt, sizeof(txt), "%s:%lu: ", |
112 |
loc->file, (unsigned long)loc->line); |
loc->file, (unsigned long)loc->line); |
113 |
va_start(ap, fmt); |
va_start(ap, fmt); |
114 |
vsnprintf(txt + n, sizeof(txt) - n, fmt, ap); |
vsnprintf(txt + n, LINEBUFFER - n, fmt, ap); |
115 |
va_end(ap); |
va_end(ap); |
116 |
info(VERBOSE, "%s", txt); |
info(VERBOSE, "%s", txt); |
117 |
} |
} |