aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilles Chehade <gilles@poolp.org>2018-11-07 09:28:50 +0100
committerGilles Chehade <gilles@poolp.org>2018-11-07 09:28:50 +0100
commitd3f4e57e51172c27b81308adb66654b04a4116ac (patch)
tree6bf59aceb6adb04a0568539d7642cfc071ae3892
parentMerge pull request #53 from jirutka/fix-compat (diff)
downloadOpenSMTPD-extras-d3f4e57e51172c27b81308adb66654b04a4116ac.tar.xz
OpenSMTPD-extras-d3f4e57e51172c27b81308adb66654b04a4116ac.zip
remove filters and tools
-rw-r--r--configure.ac9
-rw-r--r--extras/Makefile.am2
-rw-r--r--extras/filters/Makefile.am19
-rw-r--r--extras/filters/README0
-rw-r--r--extras/filters/filter-monkey/Makefile.am17
-rw-r--r--extras/filters/filter-monkey/filter-monkey.8.in71
-rw-r--r--extras/filters/filter-monkey/filter-monkey.conf26
-rw-r--r--extras/filters/filter-monkey/filter-monkey.conf.5.in99
-rw-r--r--extras/filters/filter-monkey/filter_monkey.c318
-rw-r--r--extras/filters/filter-stub/Makefile.am9
-rw-r--r--extras/filters/filter-stub/filter-stub.859
-rw-r--r--extras/filters/filter-stub/filter_stub.c185
-rw-r--r--extras/filters/filter-trace/Makefile.am9
-rw-r--r--extras/filters/filter-trace/filter-trace.861
-rw-r--r--extras/filters/filter-trace/filter_trace.c168
-rw-r--r--extras/filters/filter-void/Makefile.am9
-rw-r--r--extras/filters/filter-void/filter-void.857
-rw-r--r--extras/filters/filter-void/filter_void.c59
-rw-r--r--extras/filters/filter_api.3298
-rw-r--r--extras/tools/Makefile.am5
-rw-r--r--extras/tools/tool-stats/Makefile.am9
-rw-r--r--extras/tools/tool-stats/tool-stats.855
-rw-r--r--extras/tools/tool-stats/tool_stats.c457
23 files changed, 0 insertions, 2001 deletions
diff --git a/configure.ac b/configure.ac
index ea33729..cb0873b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1556,12 +1556,6 @@ AC_CONFIG_FILES([Makefile
extras/Makefile
- extras/filters/Makefile
- extras/filters/filter-monkey/Makefile
- extras/filters/filter-stub/Makefile
- extras/filters/filter-trace/Makefile
- extras/filters/filter-void/Makefile
-
extras/queues/Makefile
extras/queues/queue-null/Makefile
extras/queues/queue-python/Makefile
@@ -1583,9 +1577,6 @@ AC_CONFIG_FILES([Makefile
extras/tables/table-socketmap/Makefile
extras/tables/table-sqlite/Makefile
extras/tables/table-stub/Makefile
-
- extras/tools/Makefile
- extras/tools/tool-stats/Makefile
])
#l4761
diff --git a/extras/Makefile.am b/extras/Makefile.am
index 1289a7b..e7caa46 100644
--- a/extras/Makefile.am
+++ b/extras/Makefile.am
@@ -1,5 +1,3 @@
-SUBDIRS = filters
SUBDIRS+= queues
SUBDIRS+= schedulers
SUBDIRS+= tables
-SUBDIRS+= tools
diff --git a/extras/filters/Makefile.am b/extras/filters/Makefile.am
deleted file mode 100644
index eb670bb..0000000
--- a/extras/filters/Makefile.am
+++ /dev/null
@@ -1,19 +0,0 @@
-SUBDIRS =
-
-if HAVE_FILTER_MONKEY
-SUBDIRS += filter-monkey
-endif
-
-if HAVE_FILTER_STUB
-SUBDIRS += filter-stub
-endif
-
-if HAVE_FILTER_TRACE
-SUBDIRS += filter-trace
-endif
-
-if HAVE_FILTER_VOID
-SUBDIRS += filter-void
-endif
-
-man_MANS = filter_api.3
diff --git a/extras/filters/README b/extras/filters/README
deleted file mode 100644
index e69de29..0000000
--- a/extras/filters/README
+++ /dev/null
diff --git a/extras/filters/filter-monkey/Makefile.am b/extras/filters/filter-monkey/Makefile.am
deleted file mode 100644
index 76b13ef..0000000
--- a/extras/filters/filter-monkey/Makefile.am
+++ /dev/null
@@ -1,17 +0,0 @@
-include $(top_srcdir)/mk/paths.mk
-include $(top_srcdir)/mk/filter.mk
-
-pkglibexec_PROGRAMS = filter-monkey
-
-filter_monkey_SOURCES = $(SRCS)
-filter_monkey_SOURCES += filter_monkey.c
-
-man_MANS = filter-monkey.8 filter-monkey.conf.5
-
-filter-monkey.8: filter-monkey.8.in
- $(SED) -e 's|[@]SYSCONFDIR@|$(sysconfdir)|g' < filter-monkey.8.in > "$@"
-filter-monkey.conf.5: filter-monkey.conf.5.in
- $(SED) -e 's|[@]SYSCONFDIR@|$(sysconfdir)|g' < filter-monkey.conf.5.in > "$@"
-
-clean-local:
- rm -f filter-monkey.8 filter-monkey.conf.5
diff --git a/extras/filters/filter-monkey/filter-monkey.8.in b/extras/filters/filter-monkey/filter-monkey.8.in
deleted file mode 100644
index b404213..0000000
--- a/extras/filters/filter-monkey/filter-monkey.8.in
+++ /dev/null
@@ -1,71 +0,0 @@
-.\"
-.\" 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
-.\" copyright notice and this permission notice appear in all copies.
-.\"
-.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-.\" 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 16 2016 $
-.Dt FILTER-MONKEY 8
-.Os
-.Sh NAME
-.Nm filter-monkey
-.Nd smtpd filter to arbitrary reject mails
-.Sh SYNOPSIS
-.Nm
-.Op Fl dv
-.Op Ar file
-.Sh DESCRIPTION
-.Nm
-is a filter for
-.Xr smtpd 8
-which can be used to arbitrary filter mails.
-Mails are randomly delayed or rejected.
-.Pp
-The options are as follows:
-.Bl -tag -width "-d"
-.It Fl d
-Debug mode, if this option is specified,
-.Nm
-will run in the foreground and log to
-.Em stderr .
-.It Fl v
-Produce more verbose output.
-.El
-.Pp
-.Nm
-runs by default in a chroot.
-.Pp
-The debug and verbose options given with the
-.Xr smtpd 8
-invocation are intially passed to
-.Nm .
-.Pp
-Depending on the configuration lines, mails are randomly delayed or rejected
-with an optionally given SMTP reply.
-.Sh FILES
-.Bl -tag -width "@SYSCONFDIR@/filter-monkey.conf" -compact
-.It Pa @SYSCONFDIR@/filter-monkey.conf
-Default
-.Nm
-configuration file.
-.El
-.Sh SEE ALSO
-.Xr filter_api 3 ,
-.Xr filter-monkey.conf 5 ,
-.Xr smtpd.conf 5 ,
-.Xr smtpd 8
-.Sh HISTORY
-The first version of
-.Nm
-was written in 2013.
-.Sh AUTHORS
-.An Eric Faurot Aq Mt eric@openbsd.org
diff --git a/extras/filters/filter-monkey/filter-monkey.conf b/extras/filters/filter-monkey/filter-monkey.conf
deleted file mode 100644
index 30a7975..0000000
--- a/extras/filters/filter-monkey/filter-monkey.conf
+++ /dev/null
@@ -1,26 +0,0 @@
-# opensmtpd-extras filter-monkey configuration
-
-# add random delay on connect and end of message
-#delay 0:500 on connect
-#delay 0:1000 on eom
-
-# reject connect with a 10% probability
-#reject 10% on connect
-
-# reject helo with low probability and status
-#reject 2% on helo 451 Not welcome
-
-# reject and close on helo
-#close 3% on helo 500 I'm on vacation.
-
-# random reject of mail command
-#reject 30% on mail 451 Maybe next time?
-
-# random reject of recipients
-#reject 30% on rcpt 451 Try harder!
-
-# fifty-fifty reject data
-#reject 50% on data 451 Don't despair!
-
-# reject end of message
-#reject 100% on eom 500 Actually, no.
diff --git a/extras/filters/filter-monkey/filter-monkey.conf.5.in b/extras/filters/filter-monkey/filter-monkey.conf.5.in
deleted file mode 100644
index 1784ce5..0000000
--- a/extras/filters/filter-monkey/filter-monkey.conf.5.in
+++ /dev/null
@@ -1,99 +0,0 @@
-.\"
-.\" 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
-.\" copyright notice and this permission notice appear in all copies.
-.\"
-.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-.\"
-.Dd $Mdocdate: April 14 2016 $
-.Dt FILTER-MONKEY.CONF 5
-.Os
-.Sh NAME
-.Nm filter-monkey.conf
-.Nd filter-monkey configuration file
-.Sh DESCRIPTION
-.Nm
-is the configuration file for
-.Xr filter-monkey 8 .
-.Pp
-The file consists of rules that, when matched, cause
-.Xr filter-monkey 8
-to delay or reject mails.
-.Pp
-Comments can be put anywhere in the file using a hash mark
-.Pq Sq # ,
-and extend to the end of the current line.
-Emtpy lines and lines starting with
-.Sq #
-are ignored, as well as leading whitespaces.
-.Pp
-The syntax of
-.Nm
-is described below.
-.Bl -tag -width Ds
-.It Xo
-.Ic delay
-.Pf < Ar min Ns > Ns Ic : Ns Pf < Ar max Ns > Ic on
-.Pf < Ar command Ns >
-.Xc
-Add a random delay (between
-.Ar min
-and
-.Ar max
-milliseconds before sending the response for the given
-.Ar command .
-.It Xo
-.Ic reject
-.Pf < Ar n Ns > Ns Ic % on
-.Pf < Ar command Ns >
-.Op Pf < Ar code Ns > < Ns Ar status Ns >
-.Xc
-Reject the given
-.Ar command
-with a probability of
-.Ar n
-percent.
-A response
-.Ar code
-and status line may be specified.
-Multiple reject rules can be registered for the same command, but the total
-probability must not exceed 100%.
-.It Xo
-.Ic close
-.Pf < Ar n Ns > Ns Ic % on
-.Pf < Ar command Ns >
-.Op Pf < Ar code Ns > < Ns Ar status Ns >
-.Xc
-Same as
-.Ic reject ,
-but forces the SMTP engine to close the session after sending the status line.
-.El
-.Sh EXAMPLES
-The default filter-monkey.conf file which ships with OpenSMTPD-extras contains
-commented examples.
-.Sh FILES
-.Bl -tag -width "@SYSCONFDIR@/filter-monkey.conf" -compact
-.It Pa @SYSCONFDIR@/filter-monkey.conf
-Default
-.Nm
-configuration file.
-.El
-.Sh SEE ALSO
-.Xr filter_api 3 ,
-.Xr smtpd.conf 5 ,
-.Xr filter-monkey 8 ,
-.Xr smtpd 8
-.Sh HISTORY
-The first version of
-.Nm
-was written in 2013.
-.Sh AUTHORS
-.An Eric Faurot Aq Mt eric@openbsd.org
diff --git a/extras/filters/filter-monkey/filter_monkey.c b/extras/filters/filter-monkey/filter_monkey.c
deleted file mode 100644
index e58a8d5..0000000
--- a/extras/filters/filter-monkey/filter_monkey.c
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * 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
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include "includes.h"
-
-#include <sys/types.h>
-
-#include <ctype.h>
-#include <inttypes.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <smtpd-api.h>
-
-#define MONKEY_CONF SMTPD_CONFDIR "/filter-monkey.conf"
-
-struct rule {
- uint32_t limit;
- enum filter_status status;
- int code;
- char *response;
- TAILQ_ENTRY(rule) entry;
-};
-
-TAILQ_HEAD(tq_rules, rule);
-
-struct ruleset {
- uint32_t delay_min;
- uint32_t delay_max;
- struct tq_rules rules;
-};
-
-struct dict rulesets;
-
-static int
-monkey(uint64_t id, const char *cmd)
-{
- uint32_t p;
- struct rule *rule;
- struct ruleset *ruleset;
-
- ruleset = dict_xget(&rulesets, cmd);
-
- p = arc4random_uniform(100);
-
- TAILQ_FOREACH(rule, &ruleset->rules, entry)
- if (p >= rule->limit)
- break;
-
- switch (rule->status) {
- case FILTER_OK:
- log_info("info: session %016"PRIx64": ACCEPT cmd=%s", id, cmd);
- return filter_api_accept(id);
- case FILTER_FAIL:
- case FILTER_CLOSE:
- if (rule->code == 0) {
- log_info("info: session %016"PRIx64": REJECT cmd=%s", id, cmd);
- return filter_api_reject(id, rule->status);
- }
- log_info("info: session %016"PRIx64": REJECT cmd=%s, code=%i, response=%s",
- id, cmd, rule->code, rule->response);
- return filter_api_reject_code(id, rule->status, rule->code, rule->response);
-
- default:
- fatalx("invalid status");
- }
-
- return 0;
-}
-
-static void
-monkey_timer(uint64_t id, void *p)
-{
- (void)monkey(id, (const char *)p);
-}
-
-static int
-monkey_defer(uint64_t id, const char *cmd)
-{
- struct ruleset *ruleset;
- uint32_t delay;
-
- ruleset = dict_xget(&rulesets, cmd);
- if (ruleset->delay_max == 0)
- return monkey(id, cmd);
-
- delay = arc4random_uniform(ruleset->delay_max - ruleset->delay_min);
- delay += ruleset->delay_min;
-
- filter_api_timer(id, delay, monkey_timer, (void *)cmd);
- return 0;
-}
-
-static int
-on_connect(uint64_t id, struct filter_connect *conn)
-{
- return monkey_defer(id, "connect");
-}
-
-static int
-on_helo(uint64_t id, const char *helo)
-{
- return monkey_defer(id, "helo");
-}
-
-static int
-on_mail(uint64_t id, struct mailaddr *mail)
-{
- return monkey_defer(id, "mail");
-}
-
-static int
-on_rcpt(uint64_t id, struct mailaddr *rcpt)
-{
- return monkey_defer(id, "rcpt");
-}
-
-static int
-on_data(uint64_t id)
-{
- return monkey_defer(id, "data");
-}
-
-static int
-on_msg_end(uint64_t id, size_t size)
-{
- return monkey_defer(id, "eom");
-}
-
-static void
-add_rule(const char *cmd, uint32_t proba, int status, int code, const char *msg)
-{
- struct rule *rule;
- struct ruleset *ruleset;
- uint32_t limit;
-
- log_debug("info: adding rule cmd=%s, proba=%i, status=%i, code=%i, msg=\"%s\"",
- cmd, proba, status, code, msg);
-
- ruleset = dict_xget(&rulesets, cmd);
-
- rule = TAILQ_LAST(&ruleset->rules, tq_rules);
- limit = rule ? rule->limit : 100;
-
- if (proba > limit)
- fatalx("invalid limit");
-
- rule = xcalloc(1, sizeof(*rule), "read_config: rule");
- rule->limit = limit - proba;
- rule->status = status;
- rule->code = code;
- if (msg)
- rule->response = xstrdup(msg, "add_rule");
- TAILQ_INSERT_TAIL(&ruleset->rules, rule, entry);
-}
-
-static void
-read_config(const char *path)
-{
- static char *entries[] = { "connect", "helo", "mail", "rcpt", "data", "eom", NULL };
- struct rule *rule;
- struct ruleset *ruleset;
- FILE *fp;
- char **s, *line = NULL, *start, action[17], cmd[17];
- ssize_t len;
- size_t linelen = 0;
- int n, lineno = 0, proba, status = 0, code, offset;
- uint32_t delay_min, delay_max;
-
- log_debug("info: config file is %s", path);
-
- dict_init(&rulesets);
-
- for (s = entries; *s; s++) {
- ruleset = xcalloc(1, sizeof(*ruleset), "read_config: ruleset");
- TAILQ_INIT(&ruleset->rules);
- dict_xset(&rulesets, *s, ruleset);
- }
-
- if ((fp = fopen(path, "r")) == NULL)
- fatal("fopen");
-
- while ((len = getline(&line, &linelen, fp)) != -1) {
- lineno += 1;
- if (len)
- len--;
- for (start = line + len; start >= line && isspace((int)(*start)); start--)
- *start = '\0';
-
- for (start = line; *start && isspace((int)(*start)); start++)
- ;
-
- if (*start == '\0')
- continue;
- if (*start == '#')
- continue;
-
- if (!strncmp(start, "delay", strlen("delay"))) {
- n = sscanf(start, "delay %u:%u on %16s", &delay_min, &delay_max, cmd);
- if (n < 3)
- fatalx("line %i: parse error: %i", lineno, n);
-
- if (delay_min > delay_max)
- fatalx("line %i: invalid delays", lineno);
-
- for (s = entries; *s; s++)
- if (!strcmp(*s, cmd))
- break;
- if (*s == NULL)
- fatalx("line %i: invalid command", lineno);
-
- ruleset = dict_xget(&rulesets, cmd);
- ruleset->delay_min = delay_min;
- ruleset->delay_max = delay_max;
- continue;
- }
-
- n = sscanf(start, "%16s %i%% on %16s %i %n", action, &proba, cmd, &code, &offset);
- if (n < 3)
- fatalx("line %i: parse error: %i", lineno, n);
-
- if (!strcmp(action, "reject"))
- status = FILTER_FAIL;
- else if (!strcmp(action, "close"))
- status = FILTER_CLOSE;
- else
- fatalx("line %i: invalid action", lineno);
-
- if (proba < 0 || proba > 100)
- fatalx("line %i: invalid probability", lineno);
-
- for (s = entries; *s; s++)
- if (!strcmp(*s, cmd))
- break;
- if (*s == NULL)
- fatalx("line %i: invalid command", lineno);
-
- if (n == 3)
- add_rule(cmd, proba, status, 0, NULL);
- else {
- if (code < 400 || code >= 600)
- fatalx("line %i: invalid code", lineno);
- add_rule(cmd, proba, status, code, start + offset);
- }
- }
-
- if (ferror(fp))
- fatal("ferror");
- free(line);
- fclose(fp);
-
- for (s = entries; *s; s++) {
- ruleset = dict_xget(&rulesets, *s);
- rule = xcalloc(1, sizeof(*rule), "read_config: rule");
- rule->limit = 0;
- rule->status = FILTER_OK;
- TAILQ_INSERT_TAIL(&ruleset->rules, rule, entry);
- }
-}
-
-int
-main(int argc, char **argv)
-{
- int ch, d = 0, v = 0;
-
- log_init(1);
-
- while ((ch = getopt(argc, argv, "dv")) != -1) {
- switch (ch) {
- case 'd':
- d = 1;
- break;
- case 'v':
- v |= TRACE_DEBUG;
- break;
- default:
- fatalx("bad option");
- /* NOTREACHED */
- }
- }
- argc -= optind;
- argv += optind;
- if (argc > 1)
- fatalx("bogus argument(s)");
-
- log_init(d);
- log_verbose(v);
-
- log_debug("debug: starting...");
- read_config((argc == 1) ? argv[0] : MONKEY_CONF);
-
- filter_api_on_connect(on_connect);
- filter_api_on_helo(on_helo);
- filter_api_on_mail(on_mail);
- filter_api_on_rcpt(on_rcpt);
- filter_api_on_data(on_data);
- filter_api_on_msg_end(on_msg_end);
- filter_api_loop();
-
- log_debug("debug: exiting");
-
- return 1;
-}
diff --git a/extras/filters/filter-stub/Makefile.am b/extras/filters/filter-stub/Makefile.am
deleted file mode 100644
index f7bb43b..0000000
--- a/extras/filters/filter-stub/Makefile.am
+++ /dev/null
@@ -1,9 +0,0 @@
-include $(top_srcdir)/mk/paths.mk
-include $(top_srcdir)/mk/filter.mk
-
-pkglibexec_PROGRAMS = filter-stub
-
-filter_stub_SOURCES = $(SRCS)
-filter_stub_SOURCES += filter_stub.c
-
-man_MANS = filter-stub.8
diff --git a/extras/filters/filter-stub/filter-stub.8 b/extras/filters/filter-stub/filter-stub.8
deleted file mode 100644
index 09e8bdb..0000000
--- a/extras/filters/filter-stub/filter-stub.8
+++ /dev/null
@@ -1,59 +0,0 @@
-.\"
-.\" 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
-.\" copyright notice and this permission notice appear in all copies.
-.\"
-.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-.\" 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 16 2016 $
-.Dt FILTER-STUB 8
-.Os
-.Sh NAME
-.Nm filter-stub
-.Nd smtpd filter stub
-.Sh SYNOPSIS
-.Nm
-.Op Fl dv
-.Sh DESCRIPTION
-.Nm
-is a stub filter for
-.Xr smtpd 8
-which accepts all mails.
-The purpose of this filter is to provide a code template for other filters.
-.Pp
-The options are as follows:
-.Bl -tag -width "-d"
-.It Fl d
-Debug mode, if this option is specified,
-.Nm
-will run in the foreground and log to
-.Em stderr .
-.It Fl v
-Produce more verbose output.
-.El
-.Pp
-.Nm
-runs by default in a chroot.
-.Pp
-The debug and verbose options given with the
-.Xr smtpd 8
-invocation are intially passed to
-.Nm .
-.Sh SEE ALSO
-.Xr filter_api 3 ,
-.Xr smtpd.conf 5 ,
-.Xr smtpd 8
-.Sh HISTORY
-The first version of
-.Nm
-was written in 2013.
-.Sh AUTHORS
-.An Eric Faurot Aq Mt eric@openbsd.org
diff --git a/extras/filters/filter-stub/filter_stub.c b/extras/filters/filter-stub/filter_stub.c
deleted file mode 100644
index 48de540..0000000
--- a/extras/filters/filter-stub/filter_stub.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright (c) 2013 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
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include "includes.h"
-
-#include <sys/types.h>
-
-#include <inttypes.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include <smtpd-api.h>
-
-static void *
-session_alloc(uint64_t id)
-{
- return (void *)-1;
-}
-
-static void
-session_free(void *session)
-{
-}
-
-static void *
-transaction_alloc(uint64_t id)
-{
- return (void *)-1;
-}
-
-static void
-transaction_free(void *transaction)
-{
-}
-
-static int
-on_connect(uint64_t id, struct filter_connect *conn)
-{
- log_debug("debug: on_connect");
- return filter_api_accept(id);
-}
-
-static int
-on_helo(uint64_t id, const char *helo)
-{
- log_debug("debug: on_helo");
- return filter_api_accept(id);
-}
-
-static int
-on_mail(uint64_t id, struct mailaddr *mail)
-{
- log_debug("debug: on_mail");
- return filter_api_accept(id);
-}
-
-static int
-on_rcpt(uint64_t id, struct mailaddr *rcpt)
-{
- log_debug("debug: on_rcpt");
- return filter_api_accept(id);
-}
-
-static int
-on_data(uint64_t id)
-{
- log_debug("debug: on_data");
- return filter_api_accept(id);
-}
-
-static void
-on_msg_start(uint64_t id)
-{
- log_debug("debug: on_msg_start");
-}
-
-static int
-on_msg_end(uint64_t id, size_t size)
-{
- log_debug("debug: on_msg_end");
- return filter_api_accept(id);
-}
-
-static void
-on_msg_line(uint64_t id, const char *line)
-{
- log_debug("debug: on_msg_line");
- filter_api_writeln(id, line);
-}
-
-static void
-on_reset(uint64_t id)
-{
- log_debug("debug: on_reset");
-}
-
-static void
-on_tx_begin(uint64_t id)
-{
- log_debug("debug: on_tx_begin");
-}
-
-static void
-on_tx_commit(uint64_t id)
-{
- log_debug("debug: on_tx_commit");
-}
-
-static void
-on_tx_rollback(uint64_t id)
-{
- log_debug("debug: on_tx_rollback");
-}
-
-static void
-on_disconnect(uint64_t id)
-{
- log_debug("debug: on_disconnect");
-}
-
-int
-main(int argc, char **argv)
-{
- int ch, d = 0, v = 0;
-
- log_init(1);
-
- while ((ch = getopt(argc, argv, "dv")) != -1) {
- switch (ch) {
- case 'd':
- d = 1;
- break;
- case 'v':
- v |= TRACE_DEBUG;
- break;
- default:
- fatalx("bad option");
- /* NOTREACHED */
- }
- }
- argc -= optind;
- argv += optind;
-
- log_init(d);
- log_verbose(v);
-
- log_debug("debug: starting...");
-
- filter_api_session_allocator(session_alloc);
- filter_api_session_destructor(session_free);
- filter_api_transaction_allocator(transaction_alloc);
- filter_api_transaction_destructor(transaction_free);
-
- filter_api_on_connect(on_connect);
- filter_api_on_helo(on_helo);
- filter_api_on_mail(on_mail);
- filter_api_on_rcpt(on_rcpt);
- filter_api_on_data(on_data);
- filter_api_on_reset(on_reset);
- filter_api_on_msg_start(on_msg_start);
- filter_api_on_msg_end(on_msg_end);
- filter_api_on_msg_line(on_msg_line);
- filter_api_on_tx_begin(on_tx_begin);
- filter_api_on_tx_commit(on_tx_commit);
- filter_api_on_tx_rollback(on_tx_rollback);
- filter_api_on_disconnect(on_disconnect);
-
- filter_api_loop();
- log_debug("debug: exiting");
-
- return 1;
-}
diff --git a/extras/filters/filter-trace/Makefile.am b/extras/filters/filter-trace/Makefile.am
deleted file mode 100644
index abccaec..0000000
--- a/extras/filters/filter-trace/Makefile.am
+++ /dev/null
@@ -1,9 +0,0 @@
-include $(top_srcdir)/mk/paths.mk
-include $(top_srcdir)/mk/filter.mk
-
-pkglibexec_PROGRAMS = filter-trace
-
-filter_trace_SOURCES = $(SRCS)
-filter_trace_SOURCES += filter_trace.c
-
-man_MANS = filter-trace.8
diff --git a/extras/filters/filter-trace/filter-trace.8 b/extras/filters/filter-trace/filter-trace.8
deleted file mode 100644
index db272e3..0000000
--- a/extras/filters/filter-trace/filter-trace.8
+++ /dev/null
@@ -1,61 +0,0 @@
-.\"
-.\" 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
-.\" copyright notice and this permission notice appear in all copies.
-.\"
-.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-.\" 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 16 2016 $
-.Dt FILTER-TRACE 8
-.Os
-.Sh NAME
-.Nm filter-trace
-.Nd smtpd filter for tracing
-.Sh SYNOPSIS
-.Nm
-.Op Fl dlv
-.Sh DESCRIPTION
-.Nm
-is a trace filter for
-.Xr smtpd 8
-which accepts all mails.
-The purpose of this filter is to trace SMTP sessions and provide its output.
-.Pp
-The options are as follows:
-.Bl -tag -width "-d"
-.It Fl d
-Debug mode, if this option is specified,
-.Nm
-will run in the foreground and log to
-.Em stderr .
-.It Fl l
-Ignore data content lines.
-.It Fl v
-Produce more verbose output.
-.El
-.Pp
-.Nm
-runs by default in a chroot.
-.Pp
-The debug and verbose options given with the
-.Xr smtpd 8
-invocation are intially passed to
-.Nm .
-.Sh SEE ALSO
-.Xr filter_api 3 ,
-.Xr smtpd.conf 5 ,
-.Xr smtpd 8
-.Sh HISTORY
-The first version of
-.Nm
-was written in 2013.
-.Sh AUTHORS
-.An Eric Faurot Aq Mt eric@openbsd.org
diff --git a/extras/filters/filter-trace/filter_trace.c b/extras/filters/filter-trace/filter_trace.c
deleted file mode 100644
index b09305e..0000000
--- a/extras/filters/filter-trace/filter_trace.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (c) 2013 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
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include "includes.h"
-
-#include <sys/types.h>
-
-#include <inttypes.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include <smtpd-api.h>
-
-static int
-on_connect(uint64_t id, struct filter_connect *conn)
-{
-
- log_info("info: session %016"PRIx64": on_connect: hostname=%s",
- id, conn->hostname);
- return filter_api_accept(id);
-}
-
-static int
-on_helo(uint64_t id, const char *helo)
-{
- log_info("info: session %016"PRIx64": on_helo: helo=%s", id, helo);
- return filter_api_accept(id);
-}
-
-static int
-on_mail(uint64_t id, struct mailaddr *mail)
-{
- log_info("info: session %016"PRIx64": on_mail: from=%s@%s",
- id, mail->user, mail->domain);
- return filter_api_accept(id);
-}
-
-static int
-on_rcpt(uint64_t id, struct mailaddr *rcpt)
-{
- log_info("info: session %016"PRIx64": on_rcpt: to=%s@%s",
- id, rcpt->user, rcpt->domain);
- return filter_api_accept(id);
-}
-
-static int
-on_data(uint64_t id)
-{
- log_info("info: session %016"PRIx64": on_data", id);
- return filter_api_accept(id);
-}
-
-static void
-on_msg_start(uint64_t id)
-{
- log_info("info: session %016"PRIx64": on_msg_start", id);
-}
-
-static int
-on_msg_end(uint64_t id, size_t size)
-{
- log_info("info: session %016"PRIx64": on_msg_end: size=%zu", id, size);
- return filter_api_accept(id);
-}
-
-static void
-on_msg_line(uint64_t id, const char *line)
-{
- log_info("info: session %016"PRIx64": on_msg_line: line=\"%s\"", id, line);
- filter_api_writeln(id, line);
-}
-
-static void
-on_reset(uint64_t id)
-{
- log_info("info: session %016"PRIx64": on_reset", id);
-}
-
-static void
-on_disconnect(uint64_t id)
-{
- log_info("info: session %016"PRIx64": on_disconnect", id);
-}
-
-static void
-on_tx_begin(uint64_t id)
-{
- log_info("info: session %016"PRIx64": on_tx_begin", id);
-}
-
-static void
-on_tx_commit(uint64_t id)
-{
- log_info("info: session %016"PRIx64": on_tx_commit", id);
-}
-
-static void
-on_tx_rollback(uint64_t id)
-{
- log_info("info: session %016"PRIx64": on_tx_rollback", id);
-}
-
-int
-main(int argc, char **argv)
-{
- int ch, d = 0, l = 1, v = 0;
-
- log_init(1);
-
- while ((ch = getopt(argc, argv, "dlv")) != -1) {
- switch (ch) {
- case 'd':
- d = 1;
- break;
- case 'l':
- l = 0;
- break;
- case 'v':
- v |= TRACE_DEBUG;
- break;
- default:
- fatalx("bad option");
- /* NOTREACHED */
- }
- }
- argc -= optind;
- argv += optind;
-
- log_init(d);
- log_verbose(v);
-
- log_debug("debug: starting...");
-
- filter_api_on_connect(on_connect);
- filter_api_on_helo(on_helo);
- filter_api_on_mail(on_mail);
- filter_api_on_rcpt(on_rcpt);
- filter_api_on_data(on_data);
- if (l)
- filter_api_on_msg_line(on_msg_line);
- filter_api_on_msg_start(on_msg_start);
- filter_api_on_msg_end(on_msg_end);
-
- filter_api_on_reset(on_reset);
- filter_api_on_disconnect(on_disconnect);
- filter_api_on_tx_begin(on_tx_begin);
- filter_api_on_tx_commit(on_tx_commit);
- filter_api_on_tx_rollback(on_tx_rollback);
-
- filter_api_loop();
-
- log_debug("debug: exiting");
-
- return 1;
-}
diff --git a/extras/filters/filter-void/Makefile.am b/extras/filters/filter-void/Makefile.am
deleted file mode 100644
index e0f15d4..0000000
--- a/extras/filters/filter-void/Makefile.am
+++ /dev/null
@@ -1,9 +0,0 @@
-include $(top_srcdir)/mk/paths.mk
-include $(top_srcdir)/mk/filter.mk
-
-pkglibexec_PROGRAMS = filter-void
-
-filter_void_SOURCES = $(SRCS)
-filter_void_SOURCES += filter_void.c
-
-man_MANS = filter-void.8
diff --git a/extras/filters/filter-void/filter-void.8 b/extras/filters/filter-void/filter-void.8
deleted file mode 100644
index 52e4351..0000000
--- a/extras/filters/filter-void/filter-void.8
+++ /dev/null
@@ -1,57 +0,0 @@
-.\"
-.\" 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
-.\" copyright notice and this permission notice appear in all copies.
-.\"
-.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-.\" 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 16 2016 $
-.Dt FILTER-VOID 8
-.Os
-.Sh NAME
-.Nm filter-void
-.Nd smtpd filter that does nothing
-.Sh SYNOPSIS
-.Nm
-.Op Fl dv
-.Sh DESCRIPTION
-.Nm
-is a void filter for
-.Xr smtpd 8
-which accepts all mails, without doing anything.
-.Pp
-The options are as follows:
-.Bl -tag -width "-d"
-.It Fl d
-Debug mode, if this option is specified,
-.Nm
-will run in the foreground and log to
-.Em stderr .
-.It Fl v
-Produce more verbose output.
-.El
-.Nm
-runs by default in a chroot.
-.Pp
-The debug and verbose options given with the
-.Xr smtpd 8
-invocation are intially passed to
-.Nm .
-.Sh SEE ALSO
-.Xr filter_api 3 ,
-.Xr smtpd.conf 5 ,
-.Xr smtpd 8
-.Sh HISTORY
-The first version of
-.Nm
-was written in 2013.
-.Sh AUTHORS
-.An Eric Faurot Aq Mt eric@openbsd.org
diff --git a/extras/filters/filter-void/filter_void.c b/extras/filters/filter-void/filter_void.c
deleted file mode 100644
index 1bcef7e..0000000
--- a/extras/filters/filter-void/filter_void.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2013 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
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include "includes.h"
-
-#include <sys/types.h>
-
-#include <inttypes.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include <smtpd-api.h>
-
-int
-main(int argc, char **argv)
-{
- int ch, d = 0, v = 0;
-
- log_init(1);
-
- while ((ch = getopt(argc, argv, "dv")) != -1) {
- switch (ch) {
- case 'd':
- d = 1;
- break;
- case 'v':
- v |= TRACE_DEBUG;
- break;
- default:
- fatalx("bad option");
- /* NOTREACHED */
- }
- }
- argc -= optind;
- argv += optind;
-
- log_init(d);
- log_verbose(v);
-
- log_debug("debug: starting...");
-
- filter_api_loop();
- log_debug("debug: exiting");
-
- return 1;
-}
diff --git a/extras/filters/filter_api.3 b/extras/filters/filter_api.3
deleted file mode 100644
index 035bb03..0000000
--- a/extras/filters/filter_api.3
+++ /dev/null
@@ -1,298 +0,0 @@
-.\"
-.\" 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
-.\" copyright notice and this permission notice appear in all copies.
-.\"
-.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-.\" 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 23 2016 $
-.Dt FILTER_API 3
-.Os
-.Sh NAME
-.Nm filter_api_loop ,
-.Nm filter_api_accept ,
-.Nm filter_api_reject ,
-.Nm filter_api_reject_code ,
-.Nm filter_api_writeln ,
-.Nm filter_api_on_connect ,
-.Nm filter_api_on_helo ,
-.Nm filter_api_on_mail ,
-.Nm filter_api_on_rcpt ,
-.Nm filter_api_on_data ,
-.Nm filter_api_on_dataline ,
-.Nm filter_api_on_eom ,
-.Nm filter_api_on_reset ,
-.Nm filter_api_on_disconnect ,
-.Nm filter_api_on_commit ,
-.Nm filter_api_on_rollback ,
-.Nm filter_api_setugid ,
-.Nm filter_api_set_chroot ,
-.Nm filter_api_no_chroot ,
-.Nm filter_api_timer ,
-.Nm filter_api_sockaddr_to_text ,
-.Nm filter_api_mailaddr_to_text
-.Nd filter API for smtpd
-.Sh SYNOPSIS
-.In smtpd-defines.h
-.In smtpd-api.h
-.Ft void
-.Fn filter_api_loop "void"
-.Ft int
-.Fn filter_api_accept "uint64_t id"
-.Ft int
-.Fn filter_api_reject "uint64_t id" "enum filter_status status"
-.Ft int
-.Fn filter_api_reject_code "uint64_t id" "enum filter_status status" \
- "uint32_t code" "const char *line"
-.Ft void
-.Fn filter_api_writeln "uint64_t id" "const char * line"
-.Ft void
-.Fn filter_api_on_connect "int(*cb)(uint64_t, struct filter_connect *)"
-.Ft void
-.Fn filter_api_on_helo "int(*cb)(uint64_t, const char *)"
-.Ft void
-.Fn filter_api_on_mail "int(*cb)(uint64_t, struct mailaddr *)"
-.Ft void
-.Fn filter_api_on_rcpt "int(*cb)(uint64_t, struct mailaddr *)"
-.Ft void
-.Fn filter_api_on_data "int(*cb)(uint64_t)"
-.Ft void
-.Fn filter_api_on_dataline "void(*cb)(uint64_t, const char *)"
-.Ft void
-.Fn filter_api_on_eom "int(*cb)(uint64_t, size_t)"
-.Ft void
-.Fn filter_api_on_reset "void(*cb)(uint64_t)"
-.Ft void
-.Fn filter_api_on_disconnect "void(*cb)(uint64_t)"
-.Ft void
-.Fn filter_api_on_commit "void(*cb)(uint64_t)"
-.Ft void
-.Fn filter_api_on_rollback "void(*cb)(uint64_t)"
-.Ft void
-.Fn filter_api_setugid "uid_t uid" "gid_t gid"
-.Ft void
-.Fn filter_api_set_chroot "const char *rootpath"
-.Ft void
-.Fn filter_api_no_chroot "void"
-.Ft void *
-.Fn filter_api_timer "uint64_t id" "uint32_t tmo" \
- "void (*cb)(uint64_t, void *)" "void *arg"
-.Ft const char *
-.Fn filter_api_sockaddr_to_text "const struct sockaddr *sa"
-.Ft const char *
-.Fn filter_api_mailaddr_to_text "const struct mailaddr *maddr"
-.Sh DESCRIPTION
-.Nm filter_api
-is an interface intended to provide filter capabilities for the
-.Xr smtpd 8
-daemon.
-.Nm filter_api
-is used in standalone filter programs, which set up callback functions to hook
-into the SMTP dialog.
-For example, each SMTP command can be intercepted with callback functions.
-.Pp
-The function
-.Fn filter_api_loop
-is used to enter the filter loop, waiting for callback functions to be called.
-.Pp
-The function
-.Fn filter_api_accept
-can be called to accept the current message with the given
-.Fa id
-from within a callback function.
-.Pp
-The functions
-.Fn filter_api_reject
-and
-.Fn filter_api_reject_code
-can be called to reject the current message with the given
-.Fa id
-from within a callback function.
-Both expect the
-.Fa status
-to be specified, which should be one of the following values:
-.Bl -tag -width -Ds
-.It Dv FILTER_FAIL
-The filter failed and the message should not be accepted.
-.It Dv FILTER_CLOSE
-The filter is done and the message should not be accepted.
-.El
-.Pp
-Moreover, with the function
-.Fn filter_api_reject_code
-a
-.Fa code
-and
-.Fa line
-can be specified, to reject the current message with a custom SMTP reply code
-and error message.
-.Pp
-The function
-.Fn filter_api_writeln
-is intended to write (received) SMTP DATA command lines (back) from within a
-callback function.
-This might be used by a filter to add or modifiy DATA lines.
-.Sh CALLBACK FUNCTIONS
-The function
-.Fn filter_api_on_connect
-is called on new SMTP connections.
-The callback can be used to accept or reject messages based on the given
-connection information.
-Moreover, this might be used to set up a filter session state.
-.Pp
-The function
-.Fn filter_api_on_helo
-is called on SMTP HELO command.
-The callback can be used to accept or reject messages based on the given HELO
-string.
-.Pp
-The function
-.Fn filter_api_on_mail
-is called on SMTP MAIL FROM command.
-The callback can be used to accept or reject messages based on the given MAIL
-FROM address.
-.Pp
-The function
-.Fn filter_api_on_rcpt
-is called on SMTP RCPT TO command.
-The callback can be used to accept or reject messages based on the given RCPT
-TO address.
-.Pp
-The function
-.Fn filter_api_on_data
-is called on SMTP DATA command.
-The callback might be used to set up message state data structures for
-filtering the upcoming DATA lines.
-.Pp
-The function
-.Fn filter_api_on_dataline
-is called on each SMTP DATA line.
-The callback can be used to accept or reject messaged based on the (header or
-body) content of the current message.
-.Pp
-The function
-.Fn filter_api_on_eom
-is called on the end (of DATA command) of the current message.
-The callback might be used to finalize the decision of accepting or rejecting
-the message.
-.Pp
-The function
-.Fn filter_api_on_reset
-is called whenever the RSET command has been issued in a session.
-The callback implictly calls the
-.Fn filter_api_on_rollback
-callback.
-.Pp
-The function
-.Fn filter_api_on_disconnect
-is called on closed SMTP connections.
-The callback might be used to clean up earlier setup filter session state data
-structures.
-Moreover, the callback implictly calls the
-.Fn filter_api_on_rollback
-callback.
-.Pp
-The function
-.Fn filter_api_on_commit
-is called on commit of the current message.
-The callback might be used to clean up earlier setup message state data
-structures.
-.Pp
-The function
-.Fn filter_api_on_rollback
-is called on rollback of the SMTP session, after the SMTP RSET and before
-disconnect.
-The callback might be used to clean up earlier setup message state data
-structures and to rollback the current filter message state.
-.Sh HELPER FUNCTIONS
-The function
-.Fn filter_api_setugid
-can be called using
-.Fa uid
-and
-.Fa gid
-to set the running user and group of the filter.
-.Pp
-The function
-.Fn filter_api_set_chroot
-can be called using
-.Fa rootpath
-to set the chroot path of the filter.
-.Pp
-The function
-.Fn filter_api_no_chroot
-can be called to disable chroot for the filter.
-.Pp
-The function
-.Fn filter_api_timer
-can be called to set up a timeout
-.Fa tmo
-in milliseconds, after which
-.Fa cb
-is called with the given argument
-.Fa arg .
-.Pp
-The function
-.Fn filter_api_sockaddr_to_text
-can be called to convert a socket address
-.Fa sa
-to a string.
-.Pp
-The function
-.Fn filter_api_mailaddr_to_text
-can be called to convert a mail address
-.Fa maddr
-to a string.
-.Sh RETURN VALUES
-The functions
-.Fn filter_api_accept ,
-.Fn filter_api_reject ,
-and
-.Fn filter_api_reject_code ,
-return 1, intended to be used in a return statement of a callback function.
-.Pp
-The function
-.Fn filter_api_get_udata
-returns a pointer to the user data set for the current message.
-.Pp
-The functions
-.Fn filter_api_sockaddr_to_text
-and
-.Fn filter_api_mailaddr_to_text
-return a pointer to a static buffer containing the string representation.
-The buffer remains valid until the next call to the conversion functions.
-In case of error, the function
-.Fn filter_api_sockaddr_to_text
-returns the static string
-.Dq Li (unknown)
-and the function
-.Fn filter_api_mailaddr_to_text
-returns NULL.
-.Sh EXAMPLES
-.Xr filter-stub 8 ,
-which ships with the OpenSMTPD-extras package,
-is intended to provide an example code template.
-.Sh ERRORS
-The function
-.Fn filter_api_sockaddr_to_text
-may fail for any of the errors specified for the routine
-.Xr getnameinfo 3
-and listed in
-.Xr gai_strerror 3 .
-.Sh SEE ALSO
-.Xr smtpd.conf 5 ,
-.Xr filter-stub 8 ,
-.Xr smtpd 8
-.\" .Sh HISTORY
-.\" The
-.\" .Nm filter_api
-.\" first appeared in
-.\" .Ox 5.9 .
diff --git a/extras/tools/Makefile.am b/extras/tools/Makefile.am
deleted file mode 100644
index 89df9f6..0000000
--- a/extras/tools/Makefile.am
+++ /dev/null
@@ -1,5 +0,0 @@
-SUBDIRS =
-
-if HAVE_TOOL_STATS
-SUBDIRS += tool-stats
-endif
diff --git a/extras/tools/tool-stats/Makefile.am b/extras/tools/tool-stats/Makefile.am
deleted file mode 100644
index 3363ca1..0000000
--- a/extras/tools/tool-stats/Makefile.am
+++ /dev/null
@@ -1,9 +0,0 @@
-include $(top_srcdir)/mk/paths.mk
-include $(top_srcdir)/mk/tool.mk
-
-bin_PROGRAMS = tool-stats
-
-tool_stats_SOURCES = $(SRCS)
-tool_stats_SOURCES += tool_stats.c
-
-man_MANS = tool-stats.8
diff --git a/extras/tools/tool-stats/tool-stats.8 b/extras/tools/tool-stats/tool-stats.8
deleted file mode 100644
index 2985392..0000000
--- a/extras/tools/tool-stats/tool-stats.8
+++ /dev/null
@@ -1,55 +0,0 @@
-.\"
-.\" 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
-.\" copyright notice and this permission notice appear in all copies.
-.\"
-.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-.\"
-.Dd $Mdocdate: January 06 2016 $
-.Dt TOOL-STATS 8
-.Os
-.Sh NAME
-.Nm tool-stats
-.Nd smtpd tool for log statistics
-.Sh SYNOPSIS
-.Nm
-.Op Ar log ...
-.Sh DESCRIPTION
-.Nm
-is a tool which can be used to display
-statistics from
-.Xr smtpd 8
-.Ar log
-files.
-The
-.Ar log
-files are read line by line and the analyzed statistic results are written to
-the standard output.
-.Pp
-.Nm
-does not have any options.
-.Pp
-Statistics are shown for
-.Xr smtpd 8 ,
-as well as for filters.
-.Sh SEE ALSO
-.Xr filter_api 3 ,
-.Xr smtpd 8
-.Sh HISTORY
-The first version of
-.Nm
-was written in 2015.
-.Sh AUTHORS
-.An Joerg Jung Aq Mt jung@openbsd.org
-.Sh CAVEATS
-Filter statistics are only provided, if the filter process name choosen in
-.Xr smtpd.conf 5
-starts with and matches the filter binary name.
diff --git a/extras/tools/tool-stats/tool_stats.c b/extras/tools/tool-stats/tool_stats.c
deleted file mode 100644
index 96d62de..0000000
--- a/extras/tools/tool-stats/tool_stats.c
+++ /dev/null
@@ -1,457 +0,0 @@
-/*
- * 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
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <err.h>
-#include <limits.h>
-#include <sys/types.h>
-#include <ctype.h>
-#include <time.h>
-#include <unistd.h>
-
-#include <smtpd-api.h>
-
-#define STATS_YR "2016"
-#define STATS_TOP 5
-
-struct stats {
- struct { time_t first, last, time; } ts;
- struct { size_t smtp, mta, mda, reject, size; } total;
- struct { struct { size_t connect, helo, mail, rcpt, dataline; } regex;
- size_t dnsbl, spam, virus; } filter;
- struct { struct dict id, result, error, from, to, host, relay; } top;
-};
-
-static char *
-stats_tok(char **l, size_t no, const char *e)
-{
- char *t;
-
- if (!(t = strsep(l, " ")) || !strlen(t) || (e && strcmp(t, e))) {
- e ? warnx("token %s failed line %lu", e, no) :
- warnx("token failed line %lu", no);
- return NULL;
- }
- return t;
-}
-
-static char *
-stats_kv(char **l, size_t no, const char *e)
-{
- char *k, *v;
-
- if (!(k = strsep(l, "=")) || !strlen(k) || strcmp(k, e)) {
- warnx("key %s failed line %lu", e, no);
- return NULL;
- }
- if (!(v = strsep(l, " ")) || !strlen(v)) {
- warnx("value failed line %lu", no);
- return NULL;
- }
- return v;
-}
-
-static void
-stats_init(struct stats *s)
-{
- s->ts.first = s->ts.last = -1;
- dict_init(&s->top.id);
- dict_init(&s->top.result);
- dict_init(&s->top.error);
- dict_init(&s->top.from);
- dict_init(&s->top.to);
- dict_init(&s->top.host);
- dict_init(&s->top.relay);
-}
-
-static void
-stats_smtp(struct stats *s, char *l, size_t no, const char *id)
-{
- const char *e;
- char *v;
- size_t *p, n;
-
- if (strncmp(l, "event", 5))
- return;
- if (!(v = stats_kv(&l, no, "event"))) {
- warnx("event failed line %lu", no);
- return;
- }
- if (!strcmp(v, "connected")) {
- if (!(l = strstr(l, "host=")) || !(v = stats_kv(&l, no, "host"))) {
- warnx("result failed line %lu", no);
- return;
- }
- dict_xset(&s->top.id, id, xstrdup(v, "smtp"));
- } else if (!strcmp(v, "message")) { /* todo: parse and count errors and failures? */
- if (!(l = strstr(l, "from=")) || !(v = stats_kv(&l, no, "from"))) {
- warnx("from failed line %lu", no);
- return;
- }
- if (!(p = dict_get(&s->top.from, v)))
- dict_xset(&s->top.from, v, (p = xcalloc(1, sizeof(size_t), "smtp")));
- (*p)++;
- if (!(v = stats_kv(&l, no, "to"))) {
- warnx("to failed line %lu", no);
- return;
- }
- if (!(p = dict_get(&s->top.to, v)))
- dict_xset(&s->top.to, v, (p = xcalloc(1, sizeof(size_t), "smtp")));
- (*p)++;
- if (!(v = stats_kv(&l, no, "size"))) {
- warnx("size failed line %lu", no);
- return;
- }
- n = strtonum(v, 0, UINT_MAX, &e); /* todo: SIZE_MAX here? */
- if (e) {
- warnx("size value is %s: %s line %lu", e, v, no);
- return;
- }
- s->total.size += n;
- if (!(v = dict_get(&s->top.id, id))) {
- warnx("session failed line %lu", no);
- return;
- }
- if (!(p = dict_get(&s->top.host, v)))
- dict_xset(&s->top.host, v, (p = xcalloc(1, sizeof(size_t), "smtp")));
- (*p)++;
- s->total.smtp++;
- } else if (!strcmp(v, "closed"))
- free(dict_pop(&s->top.host, id));
-}
-
-static void
-stats_mta(struct stats *s, char *l, size_t no)
-{
- const char *v, *r;
- size_t *p;
-
- if (strncmp(l, "event", 5))
- return;
- if (!(v = stats_kv(&l, no, "event"))) {
- warnx("event failed line %lu", no);
- return;
- }
- if (strcmp(v, "delivery"))
- return;
- if (!(l = strstr(l, "relay=")) || !(r = stats_kv(&l, no, "relay"))) {
- warnx("relay failed line %lu", no);
- return;
- }
- if (!(l = strstr(l, "result=")) || !(v = stats_kv(&l, no, "result"))) {
- warnx("result failed line %lu", no);
- return;
- }
- if (!(p = dict_get(&s->top.result, v)))
- dict_xset(&s->top.result, v, (p = xcalloc(1, sizeof(size_t), "mda")));
- (*p)++;
- if (!strcmp(v, "Ok")) {
- if (!(p = dict_get(&s->top.relay, r)))
- dict_xset(&s->top.relay, r, (p = xcalloc(1, sizeof(size_t), "mta")));
- (*p)++;
- s->total.mta++;
- return;
- }
- if (!(v = stats_kv(&l, no, "stat"))) {
- warnx("stat failed line %lu", no);
- return;
- }
- if (!(p = dict_get(&s->top.error, v)))
- dict_xset(&s->top.error, v, (p = xcalloc(1, sizeof(size_t), "mda")));
- (*p)++;
-}
-
-static void
-stats_mda(struct stats *s, char *l, size_t no)
-{
- const char *v;
- size_t *p;
-
- if (strncmp(l, "event", 5))
- return;
- if (!(v = stats_kv(&l, no, "event"))) {
- warnx("event failed line %lu", no);
- return;
- }
- if (strcmp(v, "delivery"))
- return;
- if (!(l = strstr(l, "result=")) || !(v = stats_kv(&l, no, "result"))) {
- warnx("result failed line %lu", no);
- return;
- }
- if (!(p = dict_get(&s->top.result, v)))
- dict_xset(&s->top.result, v, (p = xcalloc(1, sizeof(size_t), "mda")));
- (*p)++;
- if (!strcmp(v, "Ok")) {
- s->total.mda++;
- return;
- }
- if (!(v = stats_kv(&l, no, "stat"))) {
- warnx("stat failed line %lu", no);
- return;
- }
- if (!(p = dict_get(&s->top.error, v)))
- dict_xset(&s->top.error, v, (p = xcalloc(1, sizeof(size_t), "mda")));
- (*p)++;
-}
-
-static void
-stats_smtpd(struct stats *s, char *l, size_t no)
-{
- const char *id;
- const char *t;
-
- if (!(id = stats_tok(&l, no, NULL)))
- return;
- if (!(t = stats_tok(&l, no, NULL)))
- return;
- if (!strcmp(t, "smtp"))
- stats_smtp(s, l, no, id);
- else if (!strcmp(t, "mta"))
- stats_mta(s, l, no);
- else if (!strcmp(t, "mda"))
- stats_mda(s, l, no);
-}
-
-static void
-stats_filter(struct stats *s, char *l, size_t no, const char *p)
-{
- if (!strncmp(p, "filter-clamav", 13)) {
- if (strstr(l, "REJECT virus"))
- s->filter.virus++;
- } else if (!strncmp(p, "filter-dnsbl", 12)) {
- if (strstr(l, "REJECT address"))
- s->filter.dnsbl++;
- } else if (!strncmp(p, "filter-regex", 12)) {
- if (strstr(l, "REJECT connect"))
- s->filter.regex.connect++;
- else if (strstr(l, "REJECT helo"))
- s->filter.regex.helo++;
- else if (strstr(l, "REJECT mail"))
- s->filter.regex.mail++;
- else if (strstr(l, "REJECT rcpt"))
- s->filter.regex.rcpt++;
- else if (strstr(l, "REJECT dataline"))
- s->filter.regex.dataline++;
- } else if (!strncmp(p, "filter-rspamd", 13)) {
- /* todo */
- } else if (!strncmp(p, "filter-spamassassin", 19)) {
- if (strstr(l, "ACCEPT spam") || strstr(l, "REJECT spam"))
- s->filter.spam++;
- }
-}
-
-static void
-stats_line(struct stats *s, char *l, size_t no)
-{
- struct tm t = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL};
- time_t ts;
- const char *p;
-
- if (!(l = strptime(l, "%b %d %T ", &t))) {
- warn("strptime failed line %lu", no);
- return;
- }
- if ((ts = mktime(&t)) == -1) {
- warn("mktime failed line %lu", no);
- return;
- }
- if (s->ts.first == -1 || ts < s->ts.first)
- s->ts.first = ts;
- if (s->ts.last == -1 || ts > s->ts.last)
- s->ts.last = ts;
-
- /* skip host, no support for multiple hosts */
- if (!stats_tok(&l, no, NULL) || !(p = stats_tok(&l, no, NULL)))
- return;
- if (!strncmp(p, "smtpd[", 6))
- stats_smtpd(s, l, no);
- else if (!strncmp(p, "filter-", 7))
- stats_filter(s, l, no, p);
-}
-
-static void
-stats_read(struct stats *ls, FILE *f)
-{
- char *l = NULL;
- size_t sz = 0, no = 0;
- ssize_t len;
-
- while ((len = getline(&l, &sz, f)) != -1) {
- if (l[len - 1] == '\n')
- l[len - 1] = '\0';
- stats_line(ls, l, ++no);
- }
- free(l);
- if (ferror(f))
- err(1, "getline");
-}
-
-static void
-stats_bar(int l, int m)
-{
- int i;
-
- for (i = 0; i < m; i++)
- printf("%s", i < l ? "▇" : " ");
-}
-
-static unsigned long
-stats_round(double d)
-{
- if (d < 0 || d > ULONG_MAX - 0.5)
- errx(1, "ulong overflow");
- return (unsigned long)(d + 0.5); /* half round up */
-}
-
-static void
-stats_top(struct dict *d, const char *s)
-{
- const char *k, *max_k;
- size_t *v, max_v, t = 0, n;
- double p;
- void *i;
-
- if (!dict_root(d, &k, (void **)&v))
- return;
- printf("\n%s\n\n", s);
- for (n = 0; n < STATS_TOP; n++) { /* this can be optimized */
- i = NULL, max_k = NULL, max_v = 0;
- while (dict_iter(d, &i, &k, (void **)&v)) {
- if (!max_k || *v > max_v )
- max_k = k, max_v = *v;
- if (!n)
- t += *v;
- }
- if (max_k) {
- p = (max_v / (double)t) * 100;
- stats_bar((int)stats_round(p / 10), 10);
- printf(" %5.1f%% %4lu %.52s%s\n",
- p, max_v, max_k, (strlen(max_k) > 52) ? "..." : "");
- dict_xpop(d, max_k);
- }
- }
-}
-
-#define STATS_KILO (1024)
-#define STATS_MEGA (1024 * 1024)
-#define STATS_GIGA (1024 * 1024 * 1024)
-
-static void
-stats_byte(double b)
-{
- if (b > STATS_GIGA)
- printf("%.2f gbytes", b / STATS_GIGA);
- else if (b > STATS_MEGA)
- printf("%.2f mbytes", b / STATS_MEGA);
- else if (b > STATS_KILO)
- printf("%.2f kbytes", b / STATS_KILO);
- else
- printf("%.2f bytes", b);
-}
-
-static void
-stats_print(struct stats *s)
-{
- char first[20], last[20];
-
- strftime(first, 20, "%a %b %d %H:%M:%S", localtime(&s->ts.first));
- strftime(last, 20, "%a %b %d %H:%M:%S", localtime(&s->ts.last));
- s->ts.time = s->ts.last - s->ts.first;
- s->total.reject = s->filter.dnsbl + s->filter.spam + s->filter.virus +
- s->filter.regex.connect + s->filter.regex.helo +
- s->filter.regex.mail + s->filter.regex.rcpt +
- s->filter.regex.dataline;
- puts("tool-stats - smtpd log statistics (c) "STATS_YR" Joerg Jung\n");
- printf("%s - %s\n\n", first, last);
- printf("%-11s smtp: %lu mta: %lu mda: %lu reject: %lu\n", "Messages:",
- s->total.smtp, s->total.mta, s->total.mda, s->total.reject);
- printf("%-11s %.2f mails/hour ", "Throughput:",
- s->total.smtp ? s->total.smtp / (s->ts.time / (double)3600) : 0);
- stats_byte(s->total.size ? s->total.size / (s->ts.time / (double)3600) : 0);
- puts("/hour\n\nFilters\n");
- printf("%-11s %lu\n", " DNSBL:", s->filter.dnsbl);
- printf("%-11s connect: %lu helo: %lu mail: %lu rcpt: %lu dataline: %lu\n",
- " Regex:", s->filter.regex.connect, s->filter.regex.helo,
- s->filter.regex.mail, s->filter.regex.rcpt, s->filter.regex.dataline);
- printf("%-11s %lu\n", " Spam:", s->filter.spam);
- printf("%-11s %lu\n", " Virus:", s->filter.virus);
- stats_top(&s->top.result, "Results");
- stats_top(&s->top.error, "Errors");
- stats_top(&s->top.from, "Sender");
- stats_top(&s->top.to, "Recipients");
- stats_top(&s->top.host, "Hosts");
- stats_top(&s->top.relay, "Relays");
-}
-
-static void
-stats_clear(struct stats *s)
-{
- size_t *v;
-
- while (dict_poproot(&s->top.id, (void **)&v))
- free(v);
- while (dict_poproot(&s->top.result, (void **)&v))
- free(v);
- while (dict_poproot(&s->top.error, (void **)&v))
- free(v);
- while (dict_poproot(&s->top.from, (void **)&v))
- free(v);
- while (dict_poproot(&s->top.to, (void **)&v))
- free(v);
- while (dict_poproot(&s->top.host, (void **)&v))
- free(v);
- while (dict_poproot(&s->top.relay, (void **)&v))
- free(v);
- free(s);
-}
-
-int
-main(int argc, char **argv)
-{
- int ch;
- FILE *f;
- struct stats *s;
-
- while ((ch = getopt(argc, argv, "")) != -1) {
- switch (ch) {
- default:
- errx(1, "bad option");
- /* NOTREACHED */
- }
- }
- argc -= optind;
- argv += optind;
-
- s = xcalloc(1, sizeof(struct stats), "main");
- stats_init(s);
-
- if (argc) {
- for (; *argv; ++argv) {
- if (!(f = fopen(*argv, "r")))
- err(1, "fopen");
- stats_read(s, f);
- fclose(f);
- }
- } else
- stats_read(s, stdin);
-
- stats_print(s);
- stats_clear(s);
- return 0;
-}