diff options
author | 2016-04-17 20:01:49 +0200 | |
---|---|---|
committer | 2016-04-17 20:01:49 +0200 | |
commit | 75ce8e40a0506db82b9592ea79159c78e49aa83c (patch) | |
tree | f38e4b84b36dd026f25af1cfba6dad9136292c07 | |
parent | document new whitelist option (diff) | |
download | OpenSMTPD-extras-75ce8e40a0506db82b9592ea79159c78e49aa83c.tar.xz OpenSMTPD-extras-75ce8e40a0506db82b9592ea79159c78e49aa83c.zip |
spring cleanup:
- add iobuf_xinit() and strip() from smtpd to util.c and use them in
filters, e.g. remove stats_skip() and regex_skip()
- remove rather useless $OpenBSD: $ keyword from extras/ but keep it in
api and compat layer for easier diffs
- remove some (trailing) whitespaces and superfluous commas in licenses
54 files changed, 105 insertions, 202 deletions
diff --git a/api/smtpd-api.h b/api/smtpd-api.h index 0a54a2a..7d5ea4d 100644 --- a/api/smtpd-api.h +++ b/api/smtpd-api.h @@ -519,9 +519,12 @@ int tree_iterfrom(struct tree *, void **, uint64_t, uint64_t *, void **); void tree_merge(struct tree *, struct tree *); /* util.c */ +struct iobuf; /* forward declaration */ void *xmalloc(size_t, const char *); void *xcalloc(size_t, size_t, const char *); char *xstrdup(const char *, const char *); +void iobuf_xinit(struct iobuf *, size_t, size_t, const char *); +char *strip(char *); int base64_encode(unsigned char const *, size_t, char *, size_t); int base64_decode(char const *, unsigned char *, size_t); @@ -21,11 +21,13 @@ #include <netinet/in.h> -#include <pwd.h> #include <base64.h> +#include <ctype.h> +#include <pwd.h> #include <stdlib.h> #include <string.h> +#include "iobuf.h" #include "log.h" void * @@ -67,6 +69,32 @@ xstrdup(const char *str, const char *where) return (r); } +void +iobuf_xinit(struct iobuf *io, size_t size, size_t max, const char *where) +{ + if (iobuf_init(io, size, max) == -1) { + log_warnx("%s: iobuf_init(%p, %zu, %zu)", where, io, size, max); + fatalx("exiting"); + } +} + +char * +strip(char *s) +{ + size_t l; + + while (isspace((unsigned char)*s)) + s++; + + for (l = strlen(s); l; l--) { + if (!isspace((unsigned char)s[l-1])) + break; + s[l-1] = '\0'; + } + + return (s); +} + int base64_encode(unsigned char const *src, size_t srclen, char *dest, size_t destsize) diff --git a/configure.ac b/configure.ac index 0e31b9f..c699b22 100644 --- a/configure.ac +++ b/configure.ac @@ -244,6 +244,7 @@ AC_ARG_WITH([Werror], AC_CHECK_HEADERS([ \ arpa/inet.h \ + ctype.h \ dirent.h \ fcntl.h \ grp.h \ diff --git a/extras/wip/filters/filter-clamav/filter-clamav.8 b/extras/wip/filters/filter-clamav/filter-clamav.8 index 59ffd23..3a79e23 100644 --- a/extras/wip/filters/filter-clamav/filter-clamav.8 +++ b/extras/wip/filters/filter-clamav/filter-clamav.8 @@ -1,6 +1,5 @@ -.\" $OpenBSD: $ .\" -.\" Copyright (c) 2015, Joerg Jung <jung@openbsd.org> +.\" Copyright (c) 2015 Joerg Jung <jung@openbsd.org> .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above diff --git a/extras/wip/filters/filter-clamav/filter_clamav.c b/extras/wip/filters/filter-clamav/filter_clamav.c index 089c3c4..907bd27 100644 --- a/extras/wip/filters/filter-clamav/filter_clamav.c +++ b/extras/wip/filters/filter-clamav/filter_clamav.c @@ -1,7 +1,5 @@ -/* $OpenBSD$ */ - /* - * Copyright (c) 2015 Joerg Jung <jung@openbsd.org> + * Copyright (c) 2015, 2016 Joerg Jung <jung@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -40,15 +38,11 @@ struct clamav { struct iobuf iobuf; }; -static int +static void clamav_init(struct clamav *cl) { cl->fd = cl->r = -1; - if (iobuf_init(&cl->iobuf, LINE_MAX, LINE_MAX) == -1) { - log_warnx("warn: init: iobuf_init"); - return -1; - } - return 0; + iobuf_xinit(&cl->iobuf, LINE_MAX, LINE_MAX, "init"); } static int @@ -195,11 +189,7 @@ clamav_on_data(uint64_t id) { struct clamav *cl; - cl = xcalloc(1, sizeof(struct clamav), "on_data"); - if (clamav_init(cl) == -1) { - clamav_clear(cl); - return filter_api_accept(id); - } + clamav_init((cl = xcalloc(1, sizeof(struct clamav), "on_data"))); if (clamav_open(cl) == -1) { clamav_clear(cl); return filter_api_accept(id); @@ -271,7 +261,7 @@ clamav_on_rollback(uint64_t id) int main(int argc, char **argv) { - int ch, d = 0, v = 0; + int ch, d = 0, v = 0; log_init(1); diff --git a/extras/wip/filters/filter-dkim-signer/filter-dkim-signer.8 b/extras/wip/filters/filter-dkim-signer/filter-dkim-signer.8 index a5a1f74..20ac80f 100644 --- a/extras/wip/filters/filter-dkim-signer/filter-dkim-signer.8 +++ b/extras/wip/filters/filter-dkim-signer/filter-dkim-signer.8 @@ -1,7 +1,6 @@ -.\" $OpenBSD: $ .\" -.\" Copyright (c) 2015, Bernard Spil <brnrd@FreeBSD.org> -.\" Copyright (c) 2015, Joerg Jung <jung@openbsd.org> +.\" Copyright (c) 2015 Bernard Spil <brnrd@FreeBSD.org> +.\" Copyright (c) 2015 Joerg Jung <jung@openbsd.org> .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above diff --git a/extras/wip/filters/filter-dkim-signer/filter_dkim_signer.c b/extras/wip/filters/filter-dkim-signer/filter_dkim_signer.c index ad2029f..d0bb911 100644 --- a/extras/wip/filters/filter-dkim-signer/filter_dkim_signer.c +++ b/extras/wip/filters/filter-dkim-signer/filter_dkim_signer.c @@ -137,7 +137,7 @@ on_dataline(uint64_t id, const char *line) { struct signer *s; struct entry *n; - + s = filter_api_get_udata(id); n = xmalloc(sizeof *n, "dkim_signer: on_dataline"); n->line = xstrdup(line, "dkim_signer: on_dataline"); @@ -154,7 +154,7 @@ on_dataline(uint64_t id, const char *line) return; /* skip unwanted headers */ } else { s->nlines += 1; - /* + /* * treat trailing two or more emptylines at end of * message as a single emptyline */ @@ -181,7 +181,7 @@ on_eom(uint64_t id, size_t size) struct entry *n; char *dkim_header, *dkim_sig, *rsa_sig; int dkim_sig_len, rsa_sig_len; - + s = filter_api_get_udata(id); /* empty body should be treated as a single CRLF */ if (s->nlines == 0) @@ -191,7 +191,7 @@ on_eom(uint64_t id, size_t size) if (base64_encode(s->body_hash, sizeof(s->body_hash), s->b64_body_hash, sizeof(s->b64_body_hash)) == -1) { log_warnx("warn: on_eom: __b64_ntop failed"); - return filter_api_reject(id, FILTER_FAIL); + return filter_api_reject(id, FILTER_FAIL); } /* trim trailing colon in the hdrs_list */ @@ -267,10 +267,10 @@ on_disconnect(uint64_t id) int main(int argc, char **argv) { - int ch, d = 0, v = 0; - const char *p = NULL; - FILE *fp; - static char hostname[SMTPD_MAXHOSTNAMELEN]; + int ch, d = 0, v = 0; + const char *p = NULL; + FILE *fp; + static char hostname[SMTPD_MAXHOSTNAMELEN]; log_init(1); @@ -339,5 +339,6 @@ main(int argc, char **argv) filter_api_loop(); log_debug("debug: exiting"); + return 1; } diff --git a/extras/wip/filters/filter-dnsbl/filter-dnsbl.8 b/extras/wip/filters/filter-dnsbl/filter-dnsbl.8 index aa2926d..40360c3 100644 --- a/extras/wip/filters/filter-dnsbl/filter-dnsbl.8 +++ b/extras/wip/filters/filter-dnsbl/filter-dnsbl.8 @@ -1,6 +1,5 @@ -.\" $OpenBSD: $ .\" -.\" Copyright (c) 2015, 2016, Joerg Jung <jung@openbsd.org> +.\" Copyright (c) 2015, 2016 Joerg Jung <jung@openbsd.org> .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above diff --git a/extras/wip/filters/filter-dnsbl/filter_dnsbl.c b/extras/wip/filters/filter-dnsbl/filter_dnsbl.c index 0f1b541..b7a6d4e 100644 --- a/extras/wip/filters/filter-dnsbl/filter_dnsbl.c +++ b/extras/wip/filters/filter-dnsbl/filter_dnsbl.c @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> * Copyright (c) 2016 Joerg Jung <jung@openbsd.org> @@ -130,8 +128,8 @@ dnsbl_on_connect(uint64_t id, struct filter_connect *conn) int main(int argc, char **argv) { - int ch, d = 0, v = 0; - const char *h = NULL, *w = NULL; + int ch, d = 0, v = 0; + char *h = NULL, *w = NULL; log_init(1); @@ -158,16 +156,10 @@ main(int argc, char **argv) argc -= optind; argv += optind; - if (h) { - while (isspace((unsigned char)*h)) - h++; - dnsbl_host = h; - } - if (w) { - while (isspace((unsigned char)*w)) - w++; - dnswl_host = w; - } + if (h) + dnsbl_host = strip(h); + if (w) + dnswl_host = strip(w); log_init(d); log_verbose(v); diff --git a/extras/wip/filters/filter-lua/filter_lua.c b/extras/wip/filters/filter-lua/filter_lua.c index 16c065d..e4eea67 100644 --- a/extras/wip/filters/filter-lua/filter_lua.c +++ b/extras/wip/filters/filter-lua/filter_lua.c @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> * Copyright (c) 2014 Emmanuel Vadot <manu@bocal.org> @@ -331,8 +329,8 @@ on_disconnect(uint64_t id) int main(int argc, char **argv) { - int ch, d = 0, v = 0; - char *path; + int ch, d = 0, v = 0; + char *path; log_init(1); diff --git a/extras/wip/filters/filter-monkey/filter-monkey.8 b/extras/wip/filters/filter-monkey/filter-monkey.8 index 3c782f4..faef032 100644 --- a/extras/wip/filters/filter-monkey/filter-monkey.8 +++ b/extras/wip/filters/filter-monkey/filter-monkey.8 @@ -1,6 +1,5 @@ -.\" $OpenBSD: $ .\" -.\" Copyright (c) 2015, Joerg Jung <jung@openbsd.org> +.\" Copyright (c) 2015 Joerg Jung <jung@openbsd.org> .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above diff --git a/extras/wip/filters/filter-monkey/filter-monkey.conf.5 b/extras/wip/filters/filter-monkey/filter-monkey.conf.5 index d79e0d5..7fbf019 100644 --- a/extras/wip/filters/filter-monkey/filter-monkey.conf.5 +++ b/extras/wip/filters/filter-monkey/filter-monkey.conf.5 @@ -1,6 +1,5 @@ -.\" $OpenBSD: $ .\" -.\" Copyright (c) 2016, Joerg Jung <jung@openbsd.org> +.\" Copyright (c) 2016 Joerg Jung <jung@openbsd.org> .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above @@ -14,7 +13,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: May 15 2015 $ +.Dd $Mdocdate: April 14 2016 $ .Dt FILTER-MONKEY.CONF 5 .Os .Sh NAME diff --git a/extras/wip/filters/filter-monkey/filter_monkey.c b/extras/wip/filters/filter-monkey/filter_monkey.c index bfa65db..aad9a43 100644 --- a/extras/wip/filters/filter-monkey/filter_monkey.c +++ b/extras/wip/filters/filter-monkey/filter_monkey.c @@ -1,7 +1,5 @@ -/* $OpenBSD$ */ - /* - * Copyright (c) 2013,2016 Eric Faurot <eric@openbsd.org> + * Copyright (c) 2013, 2016 Eric Faurot <eric@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -297,7 +295,7 @@ read_config(const char *path) int main(int argc, char **argv) { - int ch, d = 0, v = 0; + int ch, d = 0, v = 0; log_init(1); diff --git a/extras/wip/filters/filter-pause/filter-pause.8 b/extras/wip/filters/filter-pause/filter-pause.8 index 855fc13..ce251f3 100644 --- a/extras/wip/filters/filter-pause/filter-pause.8 +++ b/extras/wip/filters/filter-pause/filter-pause.8 @@ -1,6 +1,5 @@ -.\" $OpenBSD: $ .\" -.\" Copyright (c) 2015, Joerg Jung <jung@openbsd.org> +.\" Copyright (c) 2015 Joerg Jung <jung@openbsd.org> .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above diff --git a/extras/wip/filters/filter-pause/filter_pause.c b/extras/wip/filters/filter-pause/filter_pause.c index 66c83da..4affe45 100644 --- a/extras/wip/filters/filter-pause/filter_pause.c +++ b/extras/wip/filters/filter-pause/filter_pause.c @@ -1,7 +1,5 @@ -/* $OpenBSD$ */ - /* - * Copyright (c) 2015 Joerg Jung <jung@openbsd.org> + * Copyright (c) 2015, 2016 Joerg Jung <jung@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -15,7 +13,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - + #include <sys/types.h> #include <inttypes.h> @@ -44,7 +42,7 @@ pause_on_connect(uint64_t id, struct filter_connect *conn) int main(int argc, char **argv) { - int ch, d = 0, v = 0; + int ch, d = 0, v = 0; const char *errstr, *s = NULL; log_init(1); diff --git a/extras/wip/filters/filter-perl/filter_perl.c b/extras/wip/filters/filter-perl/filter_perl.c index 4591886..d26f2f9 100644 --- a/extras/wip/filters/filter-perl/filter_perl.c +++ b/extras/wip/filters/filter-perl/filter_perl.c @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2014 Gilles Chehade <gilles@poolp.org> * @@ -17,7 +15,7 @@ */ #include "includes.h" - + #include <sys/types.h> #include <sys/socket.h> @@ -150,7 +148,7 @@ on_connect(uint64_t id, struct filter_connect *conn) filter_api_sockaddr_to_text((struct sockaddr *)&conn->local)); (void)snprintf(remote, sizeof remote, "%s", filter_api_sockaddr_to_text((struct sockaddr *)&conn->remote)); - + call_sub_sv((SV *)pl_on_connect, "%i%s%s%s", id, local, remote, conn->hostname); } @@ -220,8 +218,8 @@ on_dataline(uint64_t id, const char *line) int main(int argc, char **argv) { - int ch, d = 0, v = 0; - char *fake_argv[3] = { "-e", NULL, NULL }; + int ch, d = 0, v = 0; + char *fake_argv[3] = { "-e", NULL, NULL }; log_init(1); diff --git a/extras/wip/filters/filter-python/filter_python.c b/extras/wip/filters/filter-python/filter_python.c index 9e0ac45..44b9611 100644 --- a/extras/wip/filters/filter-python/filter_python.c +++ b/extras/wip/filters/filter-python/filter_python.c @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2014 Gilles Chehade <gilles@poolp.org> * @@ -17,7 +15,7 @@ */ #include "includes.h" - + #include <sys/types.h> #include <sys/socket.h> @@ -404,9 +402,9 @@ loadfile(const char * path) int main(int argc, char **argv) { - int ch, d = 0, v = 0; - char *path, *buf; - PyObject *self, *code, *module; + int ch, d = 0, v = 0; + char *path, *buf; + PyObject *self, *code, *module; log_init(1); diff --git a/extras/wip/filters/filter-regex/filter-regex.8 b/extras/wip/filters/filter-regex/filter-regex.8 index 9009dd7..0d6c80c 100644 --- a/extras/wip/filters/filter-regex/filter-regex.8 +++ b/extras/wip/filters/filter-regex/filter-regex.8 @@ -1,4 +1,3 @@ -.\" $OpenBSD: $ .\" .\" Copyright (c) 2015, 2016 Joerg Jung <jung@openbsd.org> .\" diff --git a/extras/wip/filters/filter-regex/filter-regex.conf.5 b/extras/wip/filters/filter-regex/filter-regex.conf.5 index dbe4fe8..a2e44c2 100644 --- a/extras/wip/filters/filter-regex/filter-regex.conf.5 +++ b/extras/wip/filters/filter-regex/filter-regex.conf.5 @@ -1,6 +1,5 @@ -.\" $OpenBSD: $ .\" -.\" Copyright (c) 2015, Joerg Jung <jung@openbsd.org> +.\" Copyright (c) 2015 Joerg Jung <jung@openbsd.org> .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above diff --git a/extras/wip/filters/filter-regex/filter_regex.c b/extras/wip/filters/filter-regex/filter_regex.c index bfe5563..95567cf 100644 --- a/extras/wip/filters/filter-regex/filter_regex.c +++ b/extras/wip/filters/filter-regex/filter_regex.c @@ -1,7 +1,5 @@ -/* $OpenBSD$ */ - /* - * Copyright (c) 2015 Armin Wolfermann <armin@wolfermann.org> + * Copyright (c) 2015, Armin Wolfermann <armin@wolfermann.org> * Copyright (c) 2015, 2016 Joerg Jung <jung@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any @@ -55,13 +53,6 @@ static struct { const char *s; struct regex_q *rq; } regex_s[] = { { "dataline", ®ex_dataline }, { NULL, NULL } }; static size_t regex_limit; -static char * -regex_skip(char *s) { - while (isspace((unsigned char)*s)) - s++; - return s; -} - static int regex_parse(char *l, size_t no) { @@ -70,7 +61,7 @@ regex_parse(char *l, size_t no) char *k, buf[BUFSIZ]; int i, r; - l = regex_skip(l); + l = strip(l); if ((k = strsep(&l, " \t")) == NULL || strlen(k) == 0 || *k == '#') return 0; /* skip empty or commented line */ for (i = 0; regex_s[i].s != NULL && rq == NULL; i++) @@ -80,14 +71,14 @@ regex_parse(char *l, size_t no) log_warnx("warn: parse: unknown keyword %s line %lu", k, no); return -1; } - if (strlen((l = regex_skip(l))) == 0 || *l == '#') { + if (strlen((l = strip(l))) == 0 || *l == '#') { log_warnx("warn: parse: missing value line %lu", no); return -1; } re = xcalloc(1, sizeof(struct regex), "parse"); re->s = xstrdup(l, "parse"); if ((re->n = (l[0] == '!' && isspace((unsigned char)l[1])))) - l = regex_skip(++l); + l = strip(++l); if ((r = regcomp(&re->p, l, REG_EXTENDED|REG_NOSUB)) != 0) { regerror(r, &re->p, buf, sizeof(buf)); log_warnx("warn: parse: regcomp %s line %lu", buf, no); @@ -264,7 +255,7 @@ regex_on_rollback(uint64_t id) int main(int argc, char **argv) { - int ch, d = 0, v = 0; + int ch, d = 0, v = 0; const char *errstr, *l = NULL; log_init(1); diff --git a/extras/wip/filters/filter-spamassassin/filter-spamassassin.8 b/extras/wip/filters/filter-spamassassin/filter-spamassassin.8 index 57abcb5..acda793 100644 --- a/extras/wip/filters/filter-spamassassin/filter-spamassassin.8 +++ b/extras/wip/filters/filter-spamassassin/filter-spamassassin.8 @@ -1,4 +1,3 @@ -.\" $OpenBSD: $ .\" .\" Copyright (c) 2015, 2016 Joerg Jung <jung@openbsd.org> .\" diff --git a/extras/wip/filters/filter-spamassassin/filter_spamassassin.c b/extras/wip/filters/filter-spamassassin/filter_spamassassin.c index 0cc40e5..1d2f595 100644 --- a/extras/wip/filters/filter-spamassassin/filter_spamassassin.c +++ b/extras/wip/filters/filter-spamassassin/filter_spamassassin.c @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2015, 2016 Joerg Jung <jung@openbsd.org> * @@ -44,15 +42,11 @@ struct spamassassin { static size_t spamassassin_limit; static enum { SPAMASSASSIN_ACCEPT, SPAMASSASSIN_REJECT } spamassassin_strategy; -static int +static void spamassassin_init(struct spamassassin *sa) { sa->fd = sa->r = -1; - if (iobuf_init(&sa->iobuf, LINE_MAX, LINE_MAX) == -1) { - log_warnx("warn: init: iobuf_init"); - return -1; - } - return 0; + iobuf_xinit(&sa->iobuf, LINE_MAX, LINE_MAX, "init"); } static int @@ -241,11 +235,7 @@ spamassassin_on_data(uint64_t id) { struct spamassassin *sa; - sa = xcalloc(1, sizeof(struct spamassassin), "on_data"); - if (spamassassin_init(sa) == -1) { - spamassassin_clear(sa); - return filter_api_accept(id); - } + spamassassin_init((sa = xcalloc(1, sizeof(struct spamassassin), "on_data"))); if (spamassassin_open(sa) == -1) { spamassassin_clear(sa); return filter_api_accept(id); @@ -333,8 +323,9 @@ spamassassin_on_rollback(uint64_t id) int main(int argc, char **argv) { - int ch, d = 0, v = 0; - const char *errstr, *l = NULL, *s = NULL; + int ch, d = 0, v = 0; + const char *errstr, *l = NULL; + char *s = NULL; log_init(1); @@ -367,8 +358,7 @@ main(int argc, char **argv) fatalx("limit option is %s: %s", errstr, l); } if (s) { - while (isspace((unsigned char)*s)) - s++; + s = strip(s); if (strncmp(s, "accept", 6) == 0) spamassassin_strategy = SPAMASSASSIN_ACCEPT; else if (strncmp(s, "reject", 6) == 0) diff --git a/extras/wip/filters/filter-stub/filter-stub.8 b/extras/wip/filters/filter-stub/filter-stub.8 index c96a0f4..0d25437 100644 --- a/extras/wip/filters/filter-stub/filter-stub.8 +++ b/extras/wip/filters/filter-stub/filter-stub.8 @@ -1,6 +1,5 @@ -.\" $OpenBSD: $ .\" -.\" Copyright (c) 2015, Joerg Jung <jung@openbsd.org> +.\" Copyright (c) 2015 Joerg Jung <jung@openbsd.org> .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above diff --git a/extras/wip/filters/filter-stub/filter_stub.c b/extras/wip/filters/filter-stub/filter_stub.c index 25620c8..39e3cc6 100644 --- a/extras/wip/filters/filter-stub/filter_stub.c +++ b/extras/wip/filters/filter-stub/filter_stub.c @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> * @@ -104,7 +102,7 @@ on_disconnect(uint64_t id) int main(int argc, char **argv) { - int ch, d = 0, v = 0; + int ch, d = 0, v = 0; log_init(1); diff --git a/extras/wip/filters/filter-trace/filter-trace.8 b/extras/wip/filters/filter-trace/filter-trace.8 index a36f9f6..2169eb6 100644 --- a/extras/wip/filters/filter-trace/filter-trace.8 +++ b/extras/wip/filters/filter-trace/filter-trace.8 @@ -1,6 +1,5 @@ -.\" $OpenBSD: $ .\" -.\" Copyright (c) 2015-2016, Joerg Jung <jung@openbsd.org> +.\" Copyright (c) 2015, 2016 Joerg Jung <jung@openbsd.org> .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above diff --git a/extras/wip/filters/filter-trace/filter_trace.c b/extras/wip/filters/filter-trace/filter_trace.c index 3edd970..4456e69 100644 --- a/extras/wip/filters/filter-trace/filter_trace.c +++ b/extras/wip/filters/filter-trace/filter_trace.c @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> * @@ -108,7 +106,7 @@ on_rollback(uint64_t id) int main(int argc, char **argv) { - int ch, d = 0, l = 1, v = 0; + int ch, d = 0, l = 1, v = 0; log_init(1); diff --git a/extras/wip/filters/filter-void/filter-void.8 b/extras/wip/filters/filter-void/filter-void.8 index 09d6564..8999130 100644 --- a/extras/wip/filters/filter-void/filter-void.8 +++ b/extras/wip/filters/filter-void/filter-void.8 @@ -1,6 +1,5 @@ -.\" $OpenBSD: $ .\" -.\" Copyright (c) 2015, Joerg Jung <jung@openbsd.org> +.\" Copyright (c) 2015 Joerg Jung <jung@openbsd.org> .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above diff --git a/extras/wip/filters/filter-void/filter_void.c b/extras/wip/filters/filter-void/filter_void.c index 6677f95..990154f 100644 --- a/extras/wip/filters/filter-void/filter_void.c +++ b/extras/wip/filters/filter-void/filter_void.c @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> * @@ -17,7 +15,7 @@ */ #include "includes.h" - + #include <sys/types.h> #include <inttypes.h> @@ -31,7 +29,7 @@ int main(int argc, char **argv) { - int ch, d = 0, v = 0; + int ch, d = 0, v = 0; log_init(1); diff --git a/extras/wip/filters/filter_api.3 b/extras/wip/filters/filter_api.3 index 5cda4b8..f8b9c86 100644 --- a/extras/wip/filters/filter_api.3 +++ b/extras/wip/filters/filter_api.3 @@ -1,6 +1,5 @@ -.\" $OpenBSD: filter_api.3,v 1.3 2015/12/14 08:24:33 jmc Exp $ .\" -.\" Copyright (c) 2015, Joerg Jung <jung@openbsd.org> +.\" Copyright (c) 2015 Joerg Jung <jung@openbsd.org> .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above diff --git a/extras/wip/queues/queue-null/queue_null.c b/extras/wip/queues/queue-null/queue_null.c index 6e5a65d..d6ef3f0 100644 --- a/extras/wip/queues/queue-null/queue_null.c +++ b/extras/wip/queues/queue-null/queue_null.c @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> * diff --git a/extras/wip/queues/queue-python/queue_python.c b/extras/wip/queues/queue-python/queue_python.c index 264df62..a8ddba5 100644 --- a/extras/wip/queues/queue-python/queue_python.c +++ b/extras/wip/queues/queue-python/queue_python.c @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2014 Gilles Chehade <gilles@poolp.org> * diff --git a/extras/wip/queues/queue-ram/queue_ram.c b/extras/wip/queues/queue-ram/queue_ram.c index 0e9abdb..c928676 100644 --- a/extras/wip/queues/queue-ram/queue_ram.c +++ b/extras/wip/queues/queue-ram/queue_ram.c @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> * diff --git a/extras/wip/queues/queue-stub/queue_stub.c b/extras/wip/queues/queue-stub/queue_stub.c index 8ebb5bd..a0a6201 100644 --- a/extras/wip/queues/queue-stub/queue_stub.c +++ b/extras/wip/queues/queue-stub/queue_stub.c @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> * diff --git a/extras/wip/schedulers/scheduler-python/scheduler_python.c b/extras/wip/schedulers/scheduler-python/scheduler_python.c index 9328aab..7383dcf 100644 --- a/extras/wip/schedulers/scheduler-python/scheduler_python.c +++ b/extras/wip/schedulers/scheduler-python/scheduler_python.c @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2014 Eric Faurot <eric@openbsd.org> * diff --git a/extras/wip/schedulers/scheduler-ram/scheduler_ram.c b/extras/wip/schedulers/scheduler-ram/scheduler_ram.c index 0cd6244..5d502d7 100644 --- a/extras/wip/schedulers/scheduler-ram/scheduler_ram.c +++ b/extras/wip/schedulers/scheduler-ram/scheduler_ram.c @@ -1,5 +1,3 @@ -/* $OpenBSD: scheduler_ramqueue.c,v 1.38 2014/04/19 13:51:24 gilles Exp $ */ - /* * Copyright (c) 2012 Gilles Chehade <gilles@poolp.org> * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> diff --git a/extras/wip/schedulers/scheduler-stub/scheduler_stub.c b/extras/wip/schedulers/scheduler-stub/scheduler_stub.c index 967f6c3..e72affa 100644 --- a/extras/wip/schedulers/scheduler-stub/scheduler_stub.c +++ b/extras/wip/schedulers/scheduler-stub/scheduler_stub.c @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> * diff --git a/extras/wip/tables/table-ldap/aldap.c b/extras/wip/tables/table-ldap/aldap.c index 2703d42..d54a90c 100644 --- a/extras/wip/tables/table-ldap/aldap.c +++ b/extras/wip/tables/table-ldap/aldap.c @@ -1,5 +1,3 @@ -/* $OpenBSD: aldap.c,v 1.7 2014/04/19 14:37:45 gilles Exp $ */ - /* * Copyright (c) 2008 Alexander Schrijver <aschrijver@openbsd.org> * Copyright (c) 2006, 2007 Marc Balmer <mbalmer@openbsd.org> diff --git a/extras/wip/tables/table-ldap/aldap.h b/extras/wip/tables/table-ldap/aldap.h index 8925c2b..7cfd637 100644 --- a/extras/wip/tables/table-ldap/aldap.h +++ b/extras/wip/tables/table-ldap/aldap.h @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2008 Alexander Schrijver <aschrijver@openbsd.org> * Copyright (c) 2006, 2007 Marc Balmer <mbalmer@openbsd.org> diff --git a/extras/wip/tables/table-ldap/ber.c b/extras/wip/tables/table-ldap/ber.c index 68a4331..0f92bb2 100644 --- a/extras/wip/tables/table-ldap/ber.c +++ b/extras/wip/tables/table-ldap/ber.c @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2007 Reyk Floeter <reyk@vantronix.net> * Copyright (c) 2006, 2007 Claudio Jeker <claudio@openbsd.org> diff --git a/extras/wip/tables/table-ldap/ber.h b/extras/wip/tables/table-ldap/ber.h index f2eef14..d656508 100644 --- a/extras/wip/tables/table-ldap/ber.h +++ b/extras/wip/tables/table-ldap/ber.h @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2007 Reyk Floeter <reyk@vantronix.net> * Copyright (c) 2006, 2007 Claudio Jeker <claudio@openbsd.org> diff --git a/extras/wip/tables/table-ldap/table_ldap.c b/extras/wip/tables/table-ldap/table_ldap.c index e0ae4a9..72de844 100644 --- a/extras/wip/tables/table-ldap/table_ldap.c +++ b/extras/wip/tables/table-ldap/table_ldap.c @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> * @@ -308,9 +306,7 @@ ldap_config(void) if (buf[flen - 1] == '\n') buf[flen - 1] = '\0'; - key = buf; - while (isspace((unsigned char)*key)) - ++key; + key = strip(buf); if (*key == '\0' || *key == '#') continue; value = key; diff --git a/extras/wip/tables/table-mysql/table_mysql.c b/extras/wip/tables/table-mysql/table_mysql.c index 7039ff5..cf55979 100644 --- a/extras/wip/tables/table-mysql/table_mysql.c +++ b/extras/wip/tables/table-mysql/table_mysql.c @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> * @@ -205,9 +203,7 @@ config_load(const char *path) if (buf[flen - 1] == '\n') buf[flen - 1] = '\0'; - key = buf; - while (isspace((unsigned char)*key)) - ++key; + key = strip(buf); if (*key == '\0' || *key == '#') continue; value = key; diff --git a/extras/wip/tables/table-passwd/table-passwd.5 b/extras/wip/tables/table-passwd/table-passwd.5 index 3a8b973..c2dc1dd 100644 --- a/extras/wip/tables/table-passwd/table-passwd.5 +++ b/extras/wip/tables/table-passwd/table-passwd.5 @@ -1,4 +1,3 @@ -.\" $OpenBSD: table_passwd.5,v 1.2 2014/02/04 17:47:02 jmc Exp $ .\" .\" Copyright (c) 2014 Gilles Chehade <gilles@poolp.org> .\" Copyright (c) 2016 Joerg Jung <jung@openbsd.org> diff --git a/extras/wip/tables/table-passwd/table_passwd.c b/extras/wip/tables/table-passwd/table_passwd.c index ea37dd4..eba27cb 100644 --- a/extras/wip/tables/table-passwd/table_passwd.c +++ b/extras/wip/tables/table-passwd/table_passwd.c @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2013 Gilles Chehade <gilles@poolp.org> * Copyright (c) 2016 Joerg Jung <jung@openbsd.org> diff --git a/extras/wip/tables/table-postgres/table_postgres.c b/extras/wip/tables/table-postgres/table_postgres.c index 26be0d4..816c527 100644 --- a/extras/wip/tables/table-postgres/table_postgres.c +++ b/extras/wip/tables/table-postgres/table_postgres.c @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> * @@ -181,9 +179,7 @@ config_load(const char *path) if (buf[flen - 1] == '\n') buf[flen - 1] = '\0'; - key = buf; - while (isspace((unsigned char)*key)) - ++key; + key = strip(buf); if (*key == '\0' || *key == '#') continue; value = key; diff --git a/extras/wip/tables/table-python/table_python.c b/extras/wip/tables/table-python/table_python.c index e23bf1f..a9f0fd3 100644 --- a/extras/wip/tables/table-python/table_python.c +++ b/extras/wip/tables/table-python/table_python.c @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2014 Eric Faurot <eric@openbsd.org> * diff --git a/extras/wip/tables/table-redis/table_redis.c b/extras/wip/tables/table-redis/table_redis.c index 228e4ad..fd83968 100644 --- a/extras/wip/tables/table-redis/table_redis.c +++ b/extras/wip/tables/table-redis/table_redis.c @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> * Copyright (c) 2014 Michael Neumann <mneumann@ntecs.de> @@ -141,9 +139,7 @@ config_load(const char *path) if (buf[flen - 1] == '\n') buf[flen - 1] = '\0'; - key = buf; - while (isspace((unsigned char)*key)) - ++key; + key = strip(buf); if (*key == '\0' || *key == '#') continue; value = key; diff --git a/extras/wip/tables/table-socketmap/table-socketmap.5 b/extras/wip/tables/table-socketmap/table-socketmap.5 index a5c2991..1e1acc3 100644 --- a/extras/wip/tables/table-socketmap/table-socketmap.5 +++ b/extras/wip/tables/table-socketmap/table-socketmap.5 @@ -1,4 +1,3 @@ -.\" $OpenBSD: table_passwd.5,v 1.2 2014/02/04 17:47:02 jmc Exp $ .\" .\" Copyright (c) 2014 Gilles Chehade <gilles@poolp.org> .\" diff --git a/extras/wip/tables/table-socketmap/table_socketmap.c b/extras/wip/tables/table-socketmap/table_socketmap.c index 8294b37..dbfb709 100644 --- a/extras/wip/tables/table-socketmap/table_socketmap.c +++ b/extras/wip/tables/table-socketmap/table_socketmap.c @@ -1,5 +1,3 @@ -/* $OpenBSD: table_socketmap.c,v 1.3 2014/04/19 14:21:26 gilles Exp $ */ - /* * Copyright (c) 2014 Gilles Chehade <gilles@poolp.org> * diff --git a/extras/wip/tables/table-sqlite/table-sqlite.5 b/extras/wip/tables/table-sqlite/table-sqlite.5 index bedab73..a2d8c21 100644 --- a/extras/wip/tables/table-sqlite/table-sqlite.5 +++ b/extras/wip/tables/table-sqlite/table-sqlite.5 @@ -1,4 +1,3 @@ -.\" $OpenBSD: table_sqlite.5,v 1 2014/06/17 14:44:00 kusuriya $ .\" .\" Copyright (c) 2014 Jason Barbier <kusuriya@serversave.us> .\" diff --git a/extras/wip/tables/table-sqlite/table_sqlite.c b/extras/wip/tables/table-sqlite/table_sqlite.c index a3a023e..e32962a 100644 --- a/extras/wip/tables/table-sqlite/table_sqlite.c +++ b/extras/wip/tables/table-sqlite/table_sqlite.c @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> * @@ -197,9 +195,7 @@ table_sqlite_update(void) if (buf[flen - 1] == '\n') buf[flen - 1] = '\0'; - key = buf; - while (isspace((unsigned char)*key)) - ++key; + key = strip(buf); if (*key == '\0' || *key == '#') continue; value = key; diff --git a/extras/wip/tables/table-stub/table_stub.c b/extras/wip/tables/table-stub/table_stub.c index 06877f1..1907448 100644 --- a/extras/wip/tables/table-stub/table_stub.c +++ b/extras/wip/tables/table-stub/table_stub.c @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> * diff --git a/extras/wip/tools/tool-stats/tool-stats.8 b/extras/wip/tools/tool-stats/tool-stats.8 index ce584f1..2985392 100644 --- a/extras/wip/tools/tool-stats/tool-stats.8 +++ b/extras/wip/tools/tool-stats/tool-stats.8 @@ -1,6 +1,5 @@ -.\" $OpenBSD: $ .\" -.\" Copyright (c) 2016, Joerg Jung <jung@openbsd.org> +.\" Copyright (c) 2016 Joerg Jung <jung@openbsd.org> .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above diff --git a/extras/wip/tools/tool-stats/tool_stats.c b/extras/wip/tools/tool-stats/tool_stats.c index 35ec80c..060c0a6 100644 --- a/extras/wip/tools/tool-stats/tool_stats.c +++ b/extras/wip/tools/tool-stats/tool_stats.c @@ -1,5 +1,3 @@ -/* $OpenBSD$ */ - /* * Copyright (c) 2016 Joerg Jung <jung@openbsd.org> * @@ -49,14 +47,6 @@ stats_round(double d) { } static char * -stats_skip(char *l) -{ - while (isspace((unsigned char)*l)) - l++; - return l; -} - -static char * stats_tok(char **l, size_t no, const char *e) { char *t; @@ -128,14 +118,14 @@ stats_in(struct stats *s, char *l, size_t no) dict_xset(&s->top.from, v, (p = xcalloc(1, sizeof(size_t), "in"))); (*p)++; - l = stats_skip(l); + l = strip(l); if (!(v = stats_kv(&l, no, "to"))) return; if (!(p = dict_get(&s->top.to, v))) dict_xset(&s->top.to, v, (p = xcalloc(1, sizeof(size_t), "in"))); (*p)++; - l = stats_skip(l); + l = strip(l); if (!(v = stats_kv(&l, no, "size"))) return; n = strtonum(v, 0, UINT_MAX, &e); /* todo: SIZE_MAX here? */ |