Convert fmt_first and fmt_confd into macros.
This commit is contained in:
13
logging.c
13
logging.c
@@ -121,6 +121,9 @@ mysyslog(pri, fmt, va_alist)
|
|||||||
closelog();
|
closelog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define FMT_FIRST "%8s : %s"
|
||||||
|
#define FMT_CONTD "%8s : (command continued) %s";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Log a message to syslog, pre-pending the username and splitting the
|
* Log a message to syslog, pre-pending the username and splitting the
|
||||||
* message into parts if it is longer than MAXSYSLOGLEN.
|
* message into parts if it is longer than MAXSYSLOGLEN.
|
||||||
@@ -133,14 +136,12 @@ do_syslog(pri, msg)
|
|||||||
size_t len, maxlen;
|
size_t len, maxlen;
|
||||||
char *p, *tmp, save;
|
char *p, *tmp, save;
|
||||||
const char *fmt;
|
const char *fmt;
|
||||||
const char *fmt_first = "%8s : %s";
|
|
||||||
const char *fmt_contd = "%8s : (command continued) %s";
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Log the full line, breaking into multiple syslog(3) calls if necessary
|
* Log the full line, breaking into multiple syslog(3) calls if necessary
|
||||||
*/
|
*/
|
||||||
fmt = fmt_first;
|
fmt = FMT_FIRST;
|
||||||
maxlen = MAXSYSLOGLEN - (sizeof(fmt_first) - 6 + strlen(user_name));
|
maxlen = MAXSYSLOGLEN - (sizeof(FMT_FIRST) - 6 + strlen(user_name));
|
||||||
for (p = msg; *p != '\0'; ) {
|
for (p = msg; *p != '\0'; ) {
|
||||||
len = strlen(p);
|
len = strlen(p);
|
||||||
if (len > maxlen) {
|
if (len > maxlen) {
|
||||||
@@ -167,8 +168,8 @@ do_syslog(pri, msg)
|
|||||||
mysyslog(pri, fmt, user_name, p);
|
mysyslog(pri, fmt, user_name, p);
|
||||||
p += len;
|
p += len;
|
||||||
}
|
}
|
||||||
fmt = fmt_contd;
|
fmt = FMT_CONTD;
|
||||||
maxlen = MAXSYSLOGLEN - (sizeof(fmt_contd) - 6 + strlen(user_name));
|
maxlen = MAXSYSLOGLEN - (sizeof(FMT_CONTD) - 6 + strlen(user_name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user