diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2009-11-08 23:15:04 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2009-11-08 23:15:04 +0000 |
commit | 9f9db797cbd47e8f4634e4d2aa46f0e8bce2caeb (patch) | |
tree | 4f454fd86486ee62721a38a17f334c0b3c301325 /usr.sbin/smtpd | |
parent | cb89fc166cda202180868bdf62a4da204ddf2db0 (diff) |
move expansion code to new expand.c to clearly separate it from aliases
Diffstat (limited to 'usr.sbin/smtpd')
-rw-r--r-- | usr.sbin/smtpd/aliases.c | 43 | ||||
-rw-r--r-- | usr.sbin/smtpd/expand.c | 75 | ||||
-rw-r--r-- | usr.sbin/smtpd/makemap/Makefile | 4 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd/Makefile | 10 |
4 files changed, 83 insertions, 49 deletions
diff --git a/usr.sbin/smtpd/aliases.c b/usr.sbin/smtpd/aliases.c index c23871a0f87..325a23f4e6d 100644 --- a/usr.sbin/smtpd/aliases.c +++ b/usr.sbin/smtpd/aliases.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aliases.c,v 1.27 2009/11/08 23:08:56 gilles Exp $ */ +/* $OpenBSD: aliases.c,v 1.28 2009/11/08 23:15:03 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -488,44 +488,3 @@ alias_is_include(struct alias *alias, char *line, size_t len) alias->type = EXPAND_INCLUDE; return 1; } - -struct expand_node * -expandtree_lookup(struct expandtree *expandtree, struct expand_node *node) -{ - struct expand_node key; - - key = *node; - return RB_FIND(expandtree, expandtree, &key); -} - -void -expandtree_insert(struct expandtree *expandtree, struct expand_node *node) -{ - node->id = generate_uid(); - RB_INSERT(expandtree, expandtree, node); -} - -void -expandtree_remove(struct expandtree *expandtree, struct expand_node *node) -{ - struct expand_node *p; - - p = expandtree_lookup(expandtree, node); - if (p == NULL) - fatalx("expandtree_remove: node doesn't exist."); - RB_REMOVE(expandtree, expandtree, node); -} - -int -expand_cmp(struct expand_node *e1, struct expand_node *e2) -{ - if (e1->id < e2->id) - return -1; - - if (e1->id > e2->id) - return 1; - - return 0; -} - -RB_GENERATE(expandtree, expand_node, entry, expand_cmp); diff --git a/usr.sbin/smtpd/expand.c b/usr.sbin/smtpd/expand.c new file mode 100644 index 00000000000..de71498e503 --- /dev/null +++ b/usr.sbin/smtpd/expand.c @@ -0,0 +1,75 @@ +/* $OpenBSD: expand.c,v 1.1 2009/11/08 23:15:03 gilles Exp $ */ + +/* + * Copyright (c) 2009 Gilles Chehade <gilles@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 <sys/types.h> +#include <sys/queue.h> +#include <sys/tree.h> +#include <sys/param.h> +#include <sys/socket.h> + +#include <ctype.h> +#include <errno.h> +#include <event.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <util.h> + +#include "smtpd.h" + +struct expand_node * +expandtree_lookup(struct expandtree *expandtree, struct expand_node *node) +{ + struct expand_node key; + + key = *node; + return RB_FIND(expandtree, expandtree, &key); +} + +void +expandtree_insert(struct expandtree *expandtree, struct expand_node *node) +{ + node->id = generate_uid(); + RB_INSERT(expandtree, expandtree, node); +} + +void +expandtree_remove(struct expandtree *expandtree, struct expand_node *node) +{ + struct expand_node *p; + + p = expandtree_lookup(expandtree, node); + if (p == NULL) + fatalx("expandtree_remove: node doesn't exist."); + RB_REMOVE(expandtree, expandtree, node); +} + +int +expand_cmp(struct expand_node *e1, struct expand_node *e2) +{ + if (e1->id < e2->id) + return -1; + + if (e1->id > e2->id) + return 1; + + return 0; +} + +RB_GENERATE(expandtree, expand_node, entry, expand_cmp); diff --git a/usr.sbin/smtpd/makemap/Makefile b/usr.sbin/smtpd/makemap/Makefile index b1fb315a7fa..7b68c2fa840 100644 --- a/usr.sbin/smtpd/makemap/Makefile +++ b/usr.sbin/smtpd/makemap/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.7 2009/03/23 15:14:54 deraadt Exp $ +# $OpenBSD: Makefile,v 1.8 2009/11/08 23:15:03 gilles Exp $ .PATH: ${.CURDIR}/.. @@ -16,7 +16,7 @@ CFLAGS+= -Wmissing-declarations CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual CFLAGS+= -Wsign-compare -Wbounded -SRCS= parse.y makemap.c aliases.c map.c log.c util.c +SRCS= parse.y makemap.c aliases.c expand.c map.c log.c util.c DPADD+= ${LIBUTIL} LDADD+= -lutil .include <bsd.prog.mk> diff --git a/usr.sbin/smtpd/smtpd/Makefile b/usr.sbin/smtpd/smtpd/Makefile index 9a4b0fe1390..6cf4056bc28 100644 --- a/usr.sbin/smtpd/smtpd/Makefile +++ b/usr.sbin/smtpd/smtpd/Makefile @@ -1,11 +1,11 @@ -# $OpenBSD: Makefile,v 1.13 2009/09/04 11:49:23 jacekm Exp $ +# $OpenBSD: Makefile,v 1.14 2009/11/08 23:15:03 gilles Exp $ PROG= smtpd SRCS= aliases.c authenticate.c bounce.c buffer.c client.c \ - config.c control.c dns.c forward.c imsg.c lka.c log.c \ - map.c mda.c mfa.c mta.c parse.y queue.c queue_shared.c \ - ruleset.c runner.c smtp.c smtp_session.c smtpd.c ssl.c \ - ssl_privsep.c util.c + config.c control.c dns.c expand.c forward.c imsg.c \ + lka.c log.c map.c mda.c mfa.c mta.c parse.y queue.c \ + queue_shared.c ruleset.c runner.c smtp.c smtp_session.c \ + smtpd.c ssl.c ssl_privsep.c util.c MAN= smtpd.8 smtpd.conf.5 BINDIR= /usr/sbin |