diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2017-02-11 16:12:37 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2017-02-11 16:12:37 +0000 |
commit | 0ffc504c30989ed9a78f4c6bd62872e8b2505a22 (patch) | |
tree | f8d1e287d327ef94e1ed4008ab00f817e53d0ae7 /sbin | |
parent | 98000604daadd5e202795ad1fc2ee42690796663 (diff) |
Move parse_warning() into parse.c to prepare to replace errwarn.c
with standard daemon log.[ch].
ok mpi@
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/dhclient/dhcpd.h | 4 | ||||
-rw-r--r-- | sbin/dhclient/errwarn.c | 49 | ||||
-rw-r--r-- | sbin/dhclient/parse.c | 50 |
3 files changed, 53 insertions, 50 deletions
diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h index 56baeb6c8da..f63d8830017 100644 --- a/sbin/dhclient/dhcpd.h +++ b/sbin/dhclient/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.158 2016/09/02 15:44:26 mpi Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.159 2017/02/11 16:12:36 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@openbsd.org> @@ -200,7 +200,6 @@ void note(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); #ifdef DEBUG void debug(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); #endif -void parse_warn(char *); /* conflex.c */ extern int lexline, lexchar; @@ -220,6 +219,7 @@ void parse_lease_time(FILE *, time_t *); int parse_decimal(FILE *, unsigned char *, char); int parse_hex(FILE *, unsigned char *); time_t parse_date(FILE *); +void parse_warn(char *); /* bpf.c */ void if_register_send(struct interface_info *); diff --git a/sbin/dhclient/errwarn.c b/sbin/dhclient/errwarn.c index 093d26e2c73..18b5f846c69 100644 --- a/sbin/dhclient/errwarn.c +++ b/sbin/dhclient/errwarn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: errwarn.c,v 1.23 2016/02/06 19:30:52 krw Exp $ */ +/* $OpenBSD: errwarn.c,v 1.24 2017/02/11 16:12:36 krw Exp $ */ /* Errors and warnings. */ @@ -61,7 +61,7 @@ #include "dhcp.h" #include "dhcpd.h" -static char mbuf[1024]; +char mbuf[1024]; int warnings_occurred; @@ -158,48 +158,3 @@ debug(char *fmt, ...) } } #endif - -void -parse_warn(char *msg) -{ - static char spaces[81]; - struct iovec iov[6]; - size_t iovcnt; - int i; - - snprintf(mbuf, sizeof(mbuf), "%s line %d: %s", tlname, lexline, msg); - -#ifndef DEBUG - syslog(LOG_ERR, "%s", mbuf); - syslog(LOG_ERR, "%s", token_line); - if (lexchar < 81) - syslog(LOG_ERR, "%*c", lexchar, '^'); -#endif - - if (log_perror) { - iov[0].iov_base = mbuf; - iov[0].iov_len = strlen(mbuf); - iov[1].iov_base = "\n"; - iov[1].iov_len = 1; - iov[2].iov_base = token_line; - iov[2].iov_len = strlen(token_line); - iov[3].iov_base = "\n"; - iov[3].iov_len = 1; - iovcnt = 4; - if (lexchar < 81) { - for (i = 0; i < lexchar; i++) { - if (token_line[i] == '\t') - spaces[i] = '\t'; - else - spaces[i] = ' '; - } - iov[4].iov_base = spaces; - iov[4].iov_len = lexchar - 1; - iov[5].iov_base = "^\n"; - iov[5].iov_len = 2; - iovcnt += 2; - } - writev(STDERR_FILENO, iov, iovcnt); - } - warnings_occurred = 1; -} diff --git a/sbin/dhclient/parse.c b/sbin/dhclient/parse.c index 8fed24971f3..d71242596e9 100644 --- a/sbin/dhclient/parse.c +++ b/sbin/dhclient/parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.c,v 1.40 2016/02/06 19:30:52 krw Exp $ */ +/* $OpenBSD: parse.c,v 1.41 2017/02/11 16:12:36 krw Exp $ */ /* Common parser code for dhcpd and dhclient. */ @@ -55,6 +55,8 @@ #include <stdlib.h> #include <stdint.h> #include <string.h> +#include <syslog.h> +#include <unistd.h> #include "dhcp.h" #include "dhcpd.h" @@ -410,3 +412,49 @@ parse_date(FILE *cfile) return (guess); } + +void +parse_warn(char *msg) +{ + static char spaces[81]; + extern char mbuf[1024]; + struct iovec iov[6]; + size_t iovcnt; + int i; + + snprintf(mbuf, sizeof(mbuf), "%s line %d: %s", tlname, lexline, msg); + +#ifndef DEBUG + syslog(LOG_ERR, "%s", mbuf); + syslog(LOG_ERR, "%s", token_line); + if (lexchar < 81) + syslog(LOG_ERR, "%*c", lexchar, '^'); +#endif + + if (log_perror) { + iov[0].iov_base = mbuf; + iov[0].iov_len = strlen(mbuf); + iov[1].iov_base = "\n"; + iov[1].iov_len = 1; + iov[2].iov_base = token_line; + iov[2].iov_len = strlen(token_line); + iov[3].iov_base = "\n"; + iov[3].iov_len = 1; + iovcnt = 4; + if (lexchar < 81) { + for (i = 0; i < lexchar; i++) { + if (token_line[i] == '\t') + spaces[i] = '\t'; + else + spaces[i] = ' '; + } + iov[4].iov_base = spaces; + iov[4].iov_len = lexchar - 1; + iov[5].iov_base = "^\n"; + iov[5].iov_len = 2; + iovcnt += 2; + } + writev(STDERR_FILENO, iov, iovcnt); + } + warnings_occurred = 1; +} |