diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2017-12-14 08:57:37 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2017-12-14 08:57:37 +0000 |
commit | b37b09244c6fd9299bf5bea445ae61bc160f23df (patch) | |
tree | a1c0663258ad9d3971a613e87710270160cff645 | |
parent | 0bffd217508d1f101b6282032ace72200faeef51 (diff) |
Replace usage of fparselen(3) by a getline(3)
This allow to remove the dependency on libutil
Notes
Notes:
svn path=/head/; revision=326844
-rw-r--r-- | usr.sbin/mailwrapper/Makefile | 2 | ||||
-rw-r--r-- | usr.sbin/mailwrapper/Makefile.depend | 3 | ||||
-rw-r--r-- | usr.sbin/mailwrapper/mailwrapper.c | 18 |
3 files changed, 13 insertions, 10 deletions
diff --git a/usr.sbin/mailwrapper/Makefile b/usr.sbin/mailwrapper/Makefile index 799d7e43fb71..98222ae22cfc 100644 --- a/usr.sbin/mailwrapper/Makefile +++ b/usr.sbin/mailwrapper/Makefile @@ -5,8 +5,6 @@ .if ${MK_MAILWRAPPER} != "no" PROG= mailwrapper MAN= mailwrapper.8 - -LIBADD= util .endif .if ${MK_MAILWRAPPER} != "no" || ${MK_SENDMAIL} != "no" diff --git a/usr.sbin/mailwrapper/Makefile.depend b/usr.sbin/mailwrapper/Makefile.depend index 991757ecadc0..5c0ddbe76ee3 100644 --- a/usr.sbin/mailwrapper/Makefile.depend +++ b/usr.sbin/mailwrapper/Makefile.depend @@ -7,8 +7,7 @@ DIRDEPS = \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ - lib/libcompiler_rt \ - lib/libutil \ + lib/libcompiler_rt .include <dirdeps.mk> diff --git a/usr.sbin/mailwrapper/mailwrapper.c b/usr.sbin/mailwrapper/mailwrapper.c index 1ad4053a843e..9b57c458b165 100644 --- a/usr.sbin/mailwrapper/mailwrapper.c +++ b/usr.sbin/mailwrapper/mailwrapper.c @@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$"); #include <string.h> #include <unistd.h> #include <stdlib.h> -#include <libutil.h> #include <sysexits.h> #include <syslog.h> @@ -89,14 +88,17 @@ int main(int argc, char *argv[], char *envp[]) { FILE *config; - char *line, *cp, *from, *to, *ap; + char *line, *cp, *from, *to, *ap, *walk; const char *progname; char localmailerconf[MAXPATHLEN]; const char *mailerconf; - size_t len, lineno = 0; + size_t linecap = 0, lineno = 0; + ssize_t linelen; int i; struct arglist al; + line = NULL; + /* change __progname to mailwrapper so we get sensible error messages */ progname = getprogname(); setprogname("mailwrapper"); @@ -123,12 +125,16 @@ main(int argc, char *argv[], char *envp[]) } for (;;) { - if ((line = fparseln(config, &len, &lineno, NULL, 0)) == NULL) { - if (feof(config)) + if ((linelen = getline(&line, &linecap, config)) <= 0) { + if (feof(config)) { errx(EX_CONFIG, "no mapping in %s", mailerconf); + } err(EX_CONFIG, "cannot parse line %lu", (u_long)lineno); } - + lineno++; + walk = line; + /* strip comments */ + strsep(&walk, "#"); #define WS " \t\n" cp = line; |