-/* $OpenBSD: smtpd.h,v 1.614 2018/12/28 11:40:29 eric Exp $ */
+/* $OpenBSD: smtpd.h,v 1.615 2018/12/28 15:09:28 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
int table_open(struct table *);
int table_update(struct table *);
void table_close(struct table *);
+void table_dump(struct table *);
int table_check_use(struct table *, uint32_t, uint32_t);
int table_check_type(struct table *, uint32_t);
int table_check_service(struct table *, uint32_t);
-/* $OpenBSD: table.c,v 1.46 2018/12/28 13:47:54 eric Exp $ */
+/* $OpenBSD: table.c,v 1.47 2018/12/28 15:09:28 eric Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
log_warnx("warn: failed to add \"%s\" in table \"%s\"", key, t->t_name);
}
+void
+table_dump(struct table *t)
+{
+ const char *type;
+ char buf[LINE_MAX];
+
+ switch(t->t_type) {
+ case T_NONE:
+ type = "NONE";
+ break;
+ case T_DYNAMIC:
+ type = "DYNAMIC";
+ break;
+ case T_LIST:
+ type = "LIST";
+ break;
+ case T_HASH:
+ type = "HASH";
+ break;
+ default:
+ type = "???";
+ break;
+ }
+
+ if (t->t_config[0])
+ snprintf(buf, sizeof(buf), " config=\"%s\"", t->t_config);
+ else
+ buf[0] = '\0';
+
+ log_debug("TABLE \"%s\" backend=%s type=%s%s", t->t_name,
+ t->t_backend->name, type, buf);
+
+ if (t->t_backend->dump)
+ t->t_backend->dump(t);
+}
+
int
table_check_type(struct table *t, uint32_t mask)
{
{
struct table *t;
void *iter;
- const char *sep;
- char buf[1024];
iter = NULL;
- while (dict_iter(conf->sc_tables_dict, &iter, NULL, (void **)&t)) {
- sep = "";
- buf[0] = '\0';
- if (t->t_type & T_DYNAMIC) {
- (void)strlcat(buf, "DYNAMIC", sizeof(buf));
- sep = ",";
- }
- if (t->t_type & T_LIST) {
- (void)strlcat(buf, sep, sizeof(buf));
- (void)strlcat(buf, "LIST", sizeof(buf));
- sep = ",";
- }
- if (t->t_type & T_HASH) {
- (void)strlcat(buf, sep, sizeof(buf));
- (void)strlcat(buf, "HASH", sizeof(buf));
- sep = ",";
- }
- log_debug("TABLE \"%s\" type=%s config=\"%s\"",
- t->t_name, buf, t->t_config);
- if (t->t_backend->dump)
- t->t_backend->dump(t);
- }
+ while (dict_iter(conf->sc_tables_dict, &iter, NULL, (void **)&t))
+ table_dump(t);
}
void