From fdea30302612626d87f72de97aa7f1d30bf42a16 Mon Sep 17 00:00:00 2001 From: Gilles Chehade Date: Thu, 15 Nov 2012 14:37:22 +0100 Subject: table->m_* -> table->t_* --- smtpd/config.c | 6 ++-- smtpd/lka.c | 10 +++---- smtpd/makemap.c | 2 +- smtpd/parse.y | 46 ++++++++++++++--------------- smtpd/ruleset.c | 12 ++++---- smtpd/smtpd.c | 6 ++-- smtpd/smtpd.h | 18 ++++++------ smtpd/table.c | 82 ++++++++++++++++++++++++++-------------------------- smtpd/table_db.c | 2 +- smtpd/table_static.c | 20 ++++++------- 10 files changed, 102 insertions(+), 102 deletions(-) diff --git a/smtpd/config.c b/smtpd/config.c index 5f6db911..a6659ed1 100644 --- a/smtpd/config.c +++ b/smtpd/config.c @@ -73,9 +73,9 @@ purge_config(uint8_t what) } if (what & PURGE_TABLES) { while ((m = TAILQ_FIRST(env->sc_tables)) != NULL) { - TAILQ_REMOVE(env->sc_tables, m, m_entry); - while ((me = TAILQ_FIRST(&m->m_contents))) { - TAILQ_REMOVE(&m->m_contents, me, me_entry); + TAILQ_REMOVE(env->sc_tables, m, t_entry); + while ((me = TAILQ_FIRST(&m->t_contents))) { + TAILQ_REMOVE(&m->t_contents, me, me_entry); free(me); } free(m); diff --git a/smtpd/lka.c b/smtpd/lka.c index 8337347f..0a8aafe5 100644 --- a/smtpd/lka.c +++ b/smtpd/lka.c @@ -113,7 +113,7 @@ lka_imsg(struct imsgev *iev, struct imsg *imsg) -1, secret, sizeof *secret); return; } - table_credentials = table_lookup(table->m_id, secret->host, + table_credentials = table_lookup(table->t_id, secret->host, K_CREDENTIALS); log_debug("debug: lka: %s credentials lookup (%d)", secret->host, table_credentials != NULL); @@ -151,15 +151,15 @@ lka_imsg(struct imsgev *iev, struct imsg *imsg) case IMSG_CONF_TABLE: table = xmemdup(imsg->data, sizeof *table, "lka:table"); - TAILQ_INIT(&table->m_contents); - TAILQ_INSERT_TAIL(env->sc_tables_reload, table, m_entry); + TAILQ_INIT(&table->t_contents); + TAILQ_INSERT_TAIL(env->sc_tables_reload, table, t_entry); tmp = env->sc_tables; env->sc_tables = env->sc_tables_reload; mp = table_open(table); if (mp == NULL) - errx(1, "lka: could not open table \"%s\"", table->m_name); + errx(1, "lka: could not open table \"%s\"", table->t_name); table_close(table, mp); env->sc_tables = tmp; @@ -178,7 +178,7 @@ lka_imsg(struct imsgev *iev, struct imsg *imsg) case IMSG_CONF_TABLE_CONTENT: table = TAILQ_LAST(env->sc_tables_reload, tablelist); mapel = xmemdup(imsg->data, sizeof *mapel, "lka:mapel"); - TAILQ_INSERT_TAIL(&table->m_contents, mapel, me_entry); + TAILQ_INSERT_TAIL(&table->t_contents, mapel, me_entry); return; case IMSG_CONF_END: diff --git a/smtpd/makemap.c b/smtpd/makemap.c index 59d28d0d..d9c113e2 100644 --- a/smtpd/makemap.c +++ b/smtpd/makemap.c @@ -433,7 +433,7 @@ conf_aliases(char *cfgpath) if (table == NULL) return (PATH_ALIASES); - path = xstrdup(table->m_config, "conf_aliases"); + path = xstrdup(table->t_config, "conf_aliases"); p = strstr(path, ".db"); if (p == NULL || strcmp(p, ".db") != 0) { return (path); diff --git a/smtpd/parse.y b/smtpd/parse.y index 66d79427..b3d9b883 100644 --- a/smtpd/parse.y +++ b/smtpd/parse.y @@ -271,9 +271,9 @@ credentials : AUTH tables { /* AUTH only accepts T_DYNAMIC and T_HASH */ m = table_find($2); - if (!(m->m_type & (T_DYNAMIC|T_HASH))) { + if (!(m->t_type & (T_DYNAMIC|T_HASH))) { yyerror("table \"%s\" can't be used as AUTH parameter", - m->m_name); + m->t_name); YYERROR; } $$ = $2; @@ -439,7 +439,7 @@ table : TABLE STRING STRING { YYERROR; } table = table_create(backend, $2, config); - table->m_backend->config(table, config); + table->t_backend->config(table, config); free($2); free($3); } @@ -452,7 +452,7 @@ table : TABLE STRING STRING { ; keyval : STRING ARROW STRING { - table->m_type = T_HASH; + table->t_type = T_HASH; table_add(table, $1, $3); free($1); free($3); @@ -464,7 +464,7 @@ keyval_list : keyval ; stringel : STRING { - table->m_type = T_LIST; + table->t_type = T_LIST; table_add(table, $1, NULL); free($1); } @@ -482,14 +482,14 @@ tablenew : STRING { struct table *m; m = table_create("static", NULL, NULL); - m->m_type = T_LIST; + m->t_type = T_LIST; table_add(m, $1, NULL); - $$ = m->m_id; + $$ = m->t_id; } | '{' { table = table_create("static", NULL, NULL); } tableval_list '}' { - $$ = table->m_id; + $$ = table->t_id; } ; @@ -502,7 +502,7 @@ tableref : '<' STRING '>' { YYERROR; } free($2); - $$ = m->m_id; + $$ = m->t_id; } ; @@ -515,12 +515,12 @@ alias : ALIAS tables { /* ALIAS only accepts T_DYNAMIC and T_HASH */ m = table_find($2); - if (!(m->m_type & (T_DYNAMIC|T_HASH))) { + if (!(m->t_type & (T_DYNAMIC|T_HASH))) { yyerror("table \"%s\" can't be used as ALIAS parameter", - m->m_name); + m->t_name); YYERROR; } - $$ = m->m_id; + $$ = m->t_id; } | /* empty */ { $$ = 0; } ; @@ -531,9 +531,9 @@ condition : DOMAIN tables alias { /* DOMAIN only accepts T_DYNAMIC and T_LIST */ m = table_find($2); - if (!(m->m_type & (T_DYNAMIC|T_LIST))) { + if (!(m->t_type & (T_DYNAMIC|T_LIST))) { yyerror("table \"%s\" can't be used as DOMAIN parameter", - m->m_name); + m->t_name); YYERROR; } @@ -550,9 +550,9 @@ condition : DOMAIN tables alias { /* VIRTUAL only accepts T_DYNAMIC and T_LIST */ m = table_find($2); - if (!(m->m_type & (T_DYNAMIC|T_HASH))) { + if (!(m->t_type & (T_DYNAMIC|T_HASH))) { yyerror("table \"%s\" can't be used as VIRTUAL parameter", - m->m_name); + m->t_name); YYERROR; } @@ -579,7 +579,7 @@ condition : DOMAIN tables alias { c = xcalloc(1, sizeof *c, "parse condition: LOCAL"); c->c_type = COND_DOM; - c->c_table = m->m_id; + c->c_table = m->t_id; $$ = c; } @@ -741,7 +741,7 @@ action : DELIVER TO MAILDIR { YYERROR; } m = table_find($5); - strlcpy(rule->r_value.relayhost.authtable, m->m_name, + strlcpy(rule->r_value.relayhost.authtable, m->t_name, sizeof(rule->r_value.relayhost.authtable)); } @@ -767,22 +767,22 @@ from : FROM tables { /* FROM only accepts T_DYNAMIC and T_LIST */ m = table_find($2); - if (!(m->m_type & (T_DYNAMIC|T_LIST))) { + if (!(m->t_type & (T_DYNAMIC|T_LIST))) { yyerror("table \"%s\" can't be used as FROM parameter", - m->m_name); + m->t_name); YYERROR; } $$ = $2; } | FROM ANY { - $$ = table_findbyname("")->m_id; + $$ = table_findbyname("")->t_id; } | FROM LOCAL { - $$ = table_findbyname("")->m_id; + $$ = table_findbyname("")->t_id; } | /* empty */ { - $$ = table_findbyname("")->m_id; + $$ = table_findbyname("")->t_id; } ; diff --git a/smtpd/ruleset.c b/smtpd/ruleset.c index e7f4fc37..23f99245 100644 --- a/smtpd/ruleset.c +++ b/smtpd/ruleset.c @@ -76,13 +76,13 @@ ruleset_match(const struct envelope *evp) if (table == NULL) fatal("failed to lookup table."); - if (! strcmp(table->m_src, "static")) { - TAILQ_FOREACH(me, &table->m_contents, me_entry) { + if (! strcmp(table->t_src, "static")) { + TAILQ_FOREACH(me, &table->t_contents, me_entry) { if (hostname_match(maddr->domain, me->me_key)) return r; } } - else if (table_lookup(table->m_id, maddr->domain, + else if (table_lookup(table->t_id, maddr->domain, K_VIRTUAL) != NULL) { return (r); } else if (errno) { @@ -139,8 +139,8 @@ ruleset_check_source(struct table *table, const struct sockaddr_storage *ss) return 1; } - if (! strcmp(table->m_src, "static")) { - TAILQ_FOREACH(me, &table->m_contents, me_entry) { + if (! strcmp(table->t_src, "static")) { + TAILQ_FOREACH(me, &table->t_contents, me_entry) { if (ss->ss_family == AF_LOCAL) { if (!strcmp(me->me_key, "local")) return 1; @@ -151,7 +151,7 @@ ruleset_check_source(struct table *table, const struct sockaddr_storage *ss) } } else { - if (table_compare(table->m_id, ss_to_text(ss), K_NETADDR, + if (table_compare(table->t_id, ss_to_text(ss), K_NETADDR, ruleset_cmp_source)) return (1); if (errno) diff --git a/smtpd/smtpd.c b/smtpd/smtpd.c index 64a01e70..ca4e84a5 100644 --- a/smtpd/smtpd.c +++ b/smtpd/smtpd.c @@ -357,10 +357,10 @@ parent_send_config_ruleset(int proc) } } else { - TAILQ_FOREACH(m, env->sc_tables, m_entry) { + TAILQ_FOREACH(m, env->sc_tables, t_entry) { imsg_compose_event(env->sc_ievs[proc], IMSG_CONF_TABLE, 0, 0, -1, m, sizeof(*m)); - TAILQ_FOREACH(mapel, &m->m_contents, me_entry) { + TAILQ_FOREACH(mapel, &m->t_contents, me_entry) { imsg_compose_event(env->sc_ievs[proc], IMSG_CONF_TABLE_CONTENT, 0, 0, -1, mapel, sizeof(*mapel)); } @@ -370,7 +370,7 @@ parent_send_config_ruleset(int proc) imsg_compose_event(env->sc_ievs[proc], IMSG_CONF_RULE, 0, 0, -1, r, sizeof(*r)); imsg_compose_event(env->sc_ievs[proc], IMSG_CONF_RULE_SOURCE, - 0, 0, -1, &r->r_sources->m_name, sizeof(r->r_sources->m_name)); + 0, 0, -1, &r->r_sources->t_name, sizeof(r->r_sources->t_name)); } } diff --git a/smtpd/smtpd.h b/smtpd/smtpd.h index f127c293..df617d78 100644 --- a/smtpd/smtpd.h +++ b/smtpd/smtpd.h @@ -279,15 +279,15 @@ struct mapel { }; struct table { - TAILQ_ENTRY(table) m_entry; - char m_name[MAX_LINE_SIZE]; - objid_t m_id; - enum table_type m_type; - char m_src[MAX_TABLE_BACKEND_SIZE]; - char m_config[MAXPATHLEN]; - TAILQ_HEAD(mapel_list, mapel) m_contents; - void *m_handle; - struct table_backend *m_backend; + TAILQ_ENTRY(table) t_entry; + char t_name[MAX_LINE_SIZE]; + objid_t t_id; + enum table_type t_type; + char t_src[MAX_TABLE_BACKEND_SIZE]; + char t_config[MAXPATHLEN]; + TAILQ_HEAD(mapel_list, mapel) t_contents; + void *t_handle; + struct table_backend *t_backend; }; diff --git a/smtpd/table.c b/smtpd/table.c index 7b6393fe..b5b5fcfb 100644 --- a/smtpd/table.c +++ b/smtpd/table.c @@ -56,8 +56,8 @@ table_findbyname(const char *name) { struct table *m; - TAILQ_FOREACH(m, env->sc_tables, m_entry) { - if (strcmp(m->m_name, name) == 0) + TAILQ_FOREACH(m, env->sc_tables, t_entry) { + if (strcmp(m->t_name, name) == 0) break; } return (m); @@ -68,8 +68,8 @@ table_find(objid_t id) { struct table *m; - TAILQ_FOREACH(m, env->sc_tables, m_entry) { - if (m->m_id == id) + TAILQ_FOREACH(m, env->sc_tables, t_entry) { + if (m->t_id == id) break; } return (m); @@ -89,10 +89,10 @@ table_lookup(objid_t id, const char *key, enum table_kind kind) return NULL; } - backend = table_backend_lookup(table->m_src); + backend = table_backend_lookup(table->t_src); hdl = backend->open(table); if (hdl == NULL) { - log_warn("warn: table_lookup: can't open %s", table->m_config); + log_warn("warn: table_lookup: can't open %s", table->t_config); if (errno == 0) errno = ENOTSUP; return NULL; @@ -120,10 +120,10 @@ table_compare(objid_t id, const char *key, enum table_kind kind, return 0; } - backend = table_backend_lookup(table->m_src); + backend = table_backend_lookup(table->t_src); hdl = backend->open(table); if (hdl == NULL) { - log_warn("warn: table_compare: can't open %s", table->m_config); + log_warn("warn: table_compare: can't open %s", table->t_config); if (errno == 0) errno = ENOTSUP; return 0; @@ -150,34 +150,34 @@ table_create(const char *backend, const char *name, const char *config) errx(1, "table_create: backend \"%s\" does not exist", backend); m = xcalloc(1, sizeof(*m), "table_create"); - m->m_backend = mb; + m->t_backend = mb; - if (strlcpy(m->m_src, backend, sizeof m->m_src) >= sizeof m->m_src) - errx(1, "table_create: table backend \"%s\" too large", m->m_src); + if (strlcpy(m->t_src, backend, sizeof m->t_src) >= sizeof m->t_src) + errx(1, "table_create: table backend \"%s\" too large", m->t_src); if (config && *config) { - if (strlcpy(m->m_config, config, sizeof m->m_config) - >= sizeof m->m_config) - errx(1, "table_create: table config \"%s\" too large", m->m_config); + if (strlcpy(m->t_config, config, sizeof m->t_config) + >= sizeof m->t_config) + errx(1, "table_create: table config \"%s\" too large", m->t_config); } - if (strcmp(m->m_src, "static") != 0) - m->m_type = T_DYNAMIC; + if (strcmp(m->t_src, "static") != 0) + m->t_type = T_DYNAMIC; - m->m_id = ++last_table_id; - if (m->m_id == INT_MAX) + m->t_id = ++last_table_id; + if (m->t_id == INT_MAX) errx(1, "table_create: too many tables defined"); if (name == NULL) - snprintf(m->m_name, sizeof(m->m_name), "", m->m_id); + snprintf(m->t_name, sizeof(m->t_name), "", m->t_id); else { - n = strlcpy(m->m_name, name, sizeof(m->m_name)); - if (n >= sizeof(m->m_name)) + n = strlcpy(m->t_name, name, sizeof(m->t_name)); + if (n >= sizeof(m->t_name)) errx(1, "table_create: table name too long"); } - TAILQ_INIT(&m->m_contents); - TAILQ_INSERT_TAIL(env->sc_tables, m, m_entry); + TAILQ_INIT(&m->t_contents); + TAILQ_INSERT_TAIL(env->sc_tables, m, t_entry); return (m); } @@ -187,15 +187,15 @@ table_destroy(struct table *m) { struct mapel *me; - if (strcmp(m->m_src, "static") != 0) + if (strcmp(m->t_src, "static") != 0) errx(1, "table_add: cannot delete all from table"); - while ((me = TAILQ_FIRST(&m->m_contents))) { - TAILQ_REMOVE(&m->m_contents, me, me_entry); + while ((me = TAILQ_FIRST(&m->t_contents))) { + TAILQ_REMOVE(&m->t_contents, me, me_entry); free(me); } - TAILQ_REMOVE(env->sc_tables, m, m_entry); + TAILQ_REMOVE(env->sc_tables, m, t_entry); free(m); } @@ -205,7 +205,7 @@ table_add(struct table *m, const char *key, const char *val) struct mapel *me; size_t n; - if (strcmp(m->m_src, "static") != 0) + if (strcmp(m->t_src, "static") != 0) errx(1, "table_add: cannot add to table"); me = xcalloc(1, sizeof(*me), "table_add"); @@ -220,7 +220,7 @@ table_add(struct table *m, const char *key, const char *val) errx(1, "table_add: value too long"); } - TAILQ_INSERT_TAIL(&m->m_contents, me, me_entry); + TAILQ_INSERT_TAIL(&m->t_contents, me, me_entry); } void @@ -228,16 +228,16 @@ table_delete(struct table *m, const char *key) { struct mapel *me; - if (strcmp(m->m_src, "static") != 0) + if (strcmp(m->t_src, "static") != 0) errx(1, "map_add: cannot delete from map"); - TAILQ_FOREACH(me, &m->m_contents, me_entry) { + TAILQ_FOREACH(me, &m->t_contents, me_entry) { if (strcmp(me->me_key, key) == 0) break; } if (me == NULL) return; - TAILQ_REMOVE(&m->m_contents, me, me_entry); + TAILQ_REMOVE(&m->t_contents, me, me_entry); free(me); } @@ -246,7 +246,7 @@ table_open(struct table *m) { struct table_backend *backend = NULL; - backend = table_backend_lookup(m->m_src); + backend = table_backend_lookup(m->t_src); if (backend == NULL) return NULL; return backend->open(m); @@ -257,7 +257,7 @@ table_close(struct table *m, void *hdl) { struct table_backend *backend = NULL; - backend = table_backend_lookup(m->m_src); + backend = table_backend_lookup(m->t_src); backend->close(hdl); } @@ -267,8 +267,8 @@ table_update(struct table *m) { struct table_backend *backend = NULL; - backend = table_backend_lookup(m->m_src); - backend->update(m, m->m_config[0] ? m->m_config : NULL); + backend = table_backend_lookup(m->t_src); + backend->update(m, m->t_config[0] ? m->t_config : NULL); } int @@ -281,7 +281,7 @@ table_config_parser(struct table *m, const char *config) char *valp; size_t ret = 0; - if (strcmp("static", m->m_src) != 0) { + if (strcmp("static", m->t_src) != 0) { log_warn("table_config_parser: configuration table must be static"); return 0; } @@ -316,12 +316,12 @@ table_config_parser(struct table *m, const char *config) } /**/ - if (m->m_type == 0) - m->m_type = (valp == keyp) ? T_LIST : T_HASH; + if (m->t_type == 0) + m->t_type = (valp == keyp) ? T_LIST : T_HASH; - if ((valp == keyp || valp == NULL) && m->m_type == T_LIST) + if ((valp == keyp || valp == NULL) && m->t_type == T_LIST) table_add(m, keyp, NULL); - else if ((valp != keyp && valp != NULL) && m->m_type == T_HASH) + else if ((valp != keyp && valp != NULL) && m->t_type == T_HASH) table_add(m, keyp, valp); else goto end; diff --git a/smtpd/table_db.c b/smtpd/table_db.c index 862ddd85..44e50b0c 100644 --- a/smtpd/table_db.c +++ b/smtpd/table_db.c @@ -77,7 +77,7 @@ table_db_update(struct table *table, const char *config) static void * table_db_open(struct table *table) { - return dbopen(table->m_config, O_RDONLY, 0600, DB_HASH, NULL); + return dbopen(table->t_config, O_RDONLY, 0600, DB_HASH, NULL); } static void diff --git a/smtpd/table_static.c b/smtpd/table_static.c index 8b8713c9..f840110f 100644 --- a/smtpd/table_static.c +++ b/smtpd/table_static.c @@ -78,19 +78,19 @@ table_static_update(struct table *table, const char *config) if (config == NULL) goto ok; - m = table_create(table->m_src, NULL, config); - if (! m->m_backend->config(m, config)) + m = table_create(table->t_src, NULL, config); + if (! m->t_backend->config(m, config)) goto err; /* update successful, swap table names */ - strlcpy(name, table->m_name, sizeof name); - strlcpy(table->m_name, m->m_name, sizeof table->m_name); - strlcpy(m->m_name, name, sizeof m->m_name); + strlcpy(name, table->t_name, sizeof name); + strlcpy(table->t_name, m->t_name, sizeof table->t_name); + strlcpy(m->t_name, name, sizeof m->t_name); /* swap, table id */ - table->m_id = table->m_id ^ m->m_id; - m->m_id = table->m_id ^ m->m_id; - table->m_id = table->m_id ^ m->m_id; + table->t_id = table->t_id ^ m->t_id; + m->t_id = table->t_id ^ m->t_id; + table->t_id = table->t_id ^ m->t_id; /* destroy former table */ table_destroy(table); @@ -127,7 +127,7 @@ table_static_lookup(void *hdl, const char *key, enum table_kind kind) size_t len; line = NULL; - TAILQ_FOREACH(me, &m->m_contents, me_entry) { + TAILQ_FOREACH(me, &m->t_contents, me_entry) { if (strcmp(key, me->me_key) == 0) { if (me->me_val == NULL) return NULL; @@ -175,7 +175,7 @@ table_static_compare(void *hdl, const char *key, enum table_kind kind, struct mapel *me = NULL; int ret = 0; - TAILQ_FOREACH(me, &m->m_contents, me_entry) { + TAILQ_FOREACH(me, &m->t_contents, me_entry) { if (! func(key, me->me_key)) continue; ret = 1; -- cgit v1.2.3-59-g8ed1b