]> git.ipfire.org Git - thirdparty/postfix.git/commitdiff
snapshot-20010125
authorWietse Venema <wietse@porcupine.org>
Thu, 25 Jan 2001 05:00:00 +0000 (00:00 -0500)
committerViktor Dukhovni <viktor@dukhovni.org>
Tue, 5 Feb 2013 06:27:05 +0000 (06:27 +0000)
35 files changed:
postfix/HISTORY
postfix/PCRE_README
postfix/src/global/mail_params.h
postfix/src/global/mkmap_open.c
postfix/src/util/Makefile.in
postfix/src/util/dict.c
postfix/src/util/dict.h
postfix/src/util/dict_alloc.c [new file with mode: 0644]
postfix/src/util/dict_db.c
postfix/src/util/dict_db.h
postfix/src/util/dict_dbm.c
postfix/src/util/dict_dbm.h
postfix/src/util/dict_env.c
postfix/src/util/dict_env.h
postfix/src/util/dict_ht.c
postfix/src/util/dict_ht.h
postfix/src/util/dict_ldap.c
postfix/src/util/dict_ldap.h
postfix/src/util/dict_mysql.c
postfix/src/util/dict_mysql.h
postfix/src/util/dict_ni.c
postfix/src/util/dict_ni.h
postfix/src/util/dict_nis.c
postfix/src/util/dict_nis.h
postfix/src/util/dict_nisplus.c
postfix/src/util/dict_nisplus.h
postfix/src/util/dict_open.c
postfix/src/util/dict_pcre.c
postfix/src/util/dict_pcre.h
postfix/src/util/dict_regexp.c
postfix/src/util/dict_regexp.h
postfix/src/util/dict_tcp.c
postfix/src/util/dict_tcp.h
postfix/src/util/dict_unix.c
postfix/src/util/dict_unix.h

index b254bea66ed170247915dc288b9ebe70293025b2..a6157c4709f74726d1a9599c078fc7548ccc1f1a 100644 (file)
@@ -4747,3 +4747,15 @@ Apologies for any names omitted.
 
        Workaround: Lotus Domino 5.0.4 violates RFC 2554 and replies
        to EHLO with AUTH=LOGIN. File: smtp/smtp_proto.c.
+
+20010125
+
+       Code cleanup: wrote creator/destructor for dictionary
+       objects that provides default methods that trap all attempts
+       to perform an unimplemented operation. Based on an ansatz
+       by Laurent Wacrenier (teaser.fr).  Files: util/dict*.[hc].
+
+       Code cleanup: INSTALL.sh does not ask questions when stdin
+       is not connected to a tty. To automate a customized install,
+       the script imports environment variables for install_root
+       etc.
index d3b4fc9fa0a0ad295d219510dc1a6bcc46489252..6f97edcfa599f618d1858c3bc97d9fc3d26f8bb0 100644 (file)
@@ -19,8 +19,8 @@ from:
 You will need to add -DHAS_PCRE and a -I for the PCRE header to CCARGS,
 and add the path to the PCRE library to AUXLIBS, for example:
 
-   make -f Makefile.init makefiles 'CCARGS=-DHAS_PCRE -I../../pcre-2.08' \
-      'AUXLIBS=../../pcre-2.08/libpcre.a'
+   make -f Makefile.init makefiles 'CCARGS=-DHAS_PCRE -I../../../pcre-2.08' \
+      'AUXLIBS=../../../pcre-2.08/libpcre.a'
 
 [note: pcre versions before 2.06 are no longer compatible -- Wietse]
 
index ba4fa86f2661bd4f9500f76ab4205597e7422552..aa93a0f22627f63d9eb7c920e1b25b6253dbbf95 100644 (file)
@@ -1130,33 +1130,6 @@ extern char *var_import_environ;
 #define DEF_EXPORT_ENVIRON             "TZ"
 extern char *var_export_environ;
 
- /*
-  * Tunables for the "virtual" local delivery agent
-  */
-#define VAR_VIRT_MAILBOX_MAPS  "virtual_mailbox_maps"
-#define DEF_VIRT_MAILBOX_MAPS  ""
-extern char *var_mailbox_maps;
-
-#define VAR_VIRT_UID_MAPS      "virtual_uid_maps"
-#define DEF_VIRT_UID_MAPS      ""
-extern char *var_uid_maps;
-
-#define VAR_VIRT_GID_MAPS      "virtual_gid_maps"
-#define DEF_VIRT_GID_MAPS      ""
-extern char *var_gid_maps;
-
-#define VAR_VIRT_USEDOTLOCK    "virtual_usedotlock"
-#define DEF_VIRT_USEDOTLOCK    0
-extern bool var_virt_usedotlock;
-
-#define VAR_VIRT_MINUID                "virtual_minimum_uid"
-#define DEF_VIRT_MINUID                100
-extern int var_virt_minimum_uid;
-
-#define VAR_VIRT_MAILBOX_BASE  "virtual_mailbox_base"
-#define DEF_VIRT_MAILBOX_BASE  ""
-extern char *var_virt_mailbox_base;
-
 /* LICENSE
 /* .ad
 /* .fi
index ad7a903cb4352562af47b4ca81bc5cd8443866df..593f7631739befeacda6d7033214cb71a0672c8f 100644 (file)
@@ -60,6 +60,8 @@
 
 #include <msg.h>
 #include <dict.h>
+#include <dict_db.h>
+#include <dict_dbm.h>
 #include <sigdelay.h>
 #include <mymalloc.h>
 #include <myflock.h>
@@ -79,11 +81,11 @@ typedef struct {
 
 MKMAP_OPEN_INFO mkmap_types[] = {
 #ifdef HAS_DBM
-    "dbm", mkmap_dbm_open,
+    DICT_TYPE_DBM, mkmap_dbm_open,
 #endif
 #ifdef HAS_DB
-    "hash", mkmap_hash_open,
-    "btree", mkmap_btree_open,
+    DICT_TYPE_HASH, mkmap_hash_open,
+    DICT_TYPE_BTREE, mkmap_btree_open,
 #endif
     0,
 };
index 8d8c53b631f2a079db714a09441bfde349092b57..62fd42a6b339b8c02f87ff8c9d9cb26658946072 100644 (file)
@@ -22,7 +22,7 @@ SRCS  = argv.c argv_split.c attr.c basename.c binhash.c chroot_uid.c \
        stream_connect.c stream_trigger.c dict_regexp.c mac_expand.c \
        clean_env.c watchdog.c spawn_command.c duplex_pipe.c sane_rename.c \
        sane_link.c unescape.c timed_read.c timed_write.c dict_tcp.c \
-       hex_quote.c 
+       hex_quote.c dict_alloc.c
 OBJS   = argv.o argv_split.o attr.o basename.o binhash.o chroot_uid.o \
        close_on_exec.o concatenate.o dict.o dict_db.o dict_dbm.o \
        dict_env.o dict_ht.o dict_ldap.o dict_mysql.o dict_ni.o dict_nis.o \
@@ -46,7 +46,7 @@ OBJS  = argv.o argv_split.o attr.o basename.o binhash.o chroot_uid.o \
        stream_connect.o stream_trigger.o dict_regexp.o mac_expand.o \
        clean_env.o watchdog.o spawn_command.o duplex_pipe.o sane_rename.o \
        sane_link.o unescape.o timed_read.o timed_write.o dict_tcp.o \
-       hex_quote.o 
+       hex_quote.o dict_alloc.o
 HDRS   = argv.h attr.h binhash.h chroot_uid.h connect.h dict.h dict_db.h \
        dict_dbm.h dict_env.h dict_ht.h dict_ldap.h dict_mysql.h \
        dict_ni.h dict_nis.h dict_nisplus.h dir_forest.h events.h \
@@ -368,6 +368,14 @@ dict.o: mac_parse.h
 dict.o: dict.h
 dict.o: argv.h
 dict.o: dict_ht.h
+dict_alloc.o: dict_alloc.c
+dict_alloc.o: sys_defs.h
+dict_alloc.o: msg.h
+dict_alloc.o: mymalloc.h
+dict_alloc.o: dict.h
+dict_alloc.o: vstream.h
+dict_alloc.o: vbuf.h
+dict_alloc.o: argv.h
 dict_db.o: dict_db.c
 dict_db.o: sys_defs.h
 dict_db.o: msg.h
index 6467441ab5fb9c62b6bbdef302c7aeed66aa35e7..2a02ce958a41357aecc4a3ab7577f938b184e4a3 100644 (file)
@@ -277,7 +277,7 @@ void    dict_update(const char *dict_name, const char *member, const char *value
     if ((node = dict_node(dict_name)) == 0) {
        if (dict_unknown_allowed == 0)
            msg_fatal("%s: unknown dictionary: %s", myname, dict_name);
-       dict = dict_ht_open(htable_create(0), myfree);
+       dict = dict_ht_open(dict_name, htable_create(0), myfree);
        dict_register(dict_name, dict);
     } else
        dict = node->dict;
@@ -321,7 +321,7 @@ int     dict_delete(const char *dict_name, const char *member)
     if ((node = dict_node(dict_name)) == 0) {
        if (dict_unknown_allowed == 0)
            msg_fatal("%s: unknown dictionary: %s", myname, dict_name);
-       dict = dict_ht_open(htable_create(0), myfree);
+       dict = dict_ht_open(dict_name, htable_create(0), myfree);
        dict_register(dict_name, dict);
     } else
        dict = node->dict;
@@ -345,7 +345,7 @@ int     dict_sequence(const char *dict_name, const int func,
     if ((node = dict_node(dict_name)) == 0) {
        if (dict_unknown_allowed == 0)
            msg_fatal("%s: unknown dictionary: %s", myname, dict_name);
-       dict = dict_ht_open(htable_create(0), myfree);
+       dict = dict_ht_open(dict_name, htable_create(0), myfree);
        dict_register(dict_name, dict);
     } else
        dict = node->dict;
index c5d2b9162bdceee14671d7364a1ef634406f3c5b..c9fb8e9815d0a1996f12b0b57d39c9db52451e59 100644 (file)
@@ -27,6 +27,8 @@
   * structure with private members to maintain internal state.
   */
 typedef struct DICT {
+    char   *type;                      /* for diagnostics */
+    char   *name;                      /* for diagnostics */
     int     flags;                     /* see below */
     const char *(*lookup) (struct DICT *, const char *);
     void    (*update) (struct DICT *, const char *, const char *);
@@ -37,6 +39,9 @@ typedef struct DICT {
     time_t  mtime;                     /* mod time at open */
 } DICT;
 
+extern DICT *dict_alloc(const char *, const char *, int);
+extern void dict_free(DICT *);
+
 #define DICT_FLAG_DUP_WARN     (1<<0)  /* if file, warn about dups */
 #define DICT_FLAG_DUP_IGNORE   (1<<1)  /* if file, ignore dups */
 #define DICT_FLAG_TRY0NULL     (1<<2)  /* do not append 0 to key/value */
diff --git a/postfix/src/util/dict_alloc.c b/postfix/src/util/dict_alloc.c
new file mode 100644 (file)
index 0000000..005e47a
--- /dev/null
@@ -0,0 +1,131 @@
+/*++
+/* NAME
+/*     dict_alloc 3
+/* SUMMARY
+/*     dictionary memory manager
+/* SYNOPSIS
+/*     #include <dict.h>
+/*
+/*     DICT    *dict_alloc(dict_type, dict_name, size)
+/*     const char *dict_type;
+/*     const char *dict_name;
+/*     int     size;
+/*
+/*     void    dict_free(dict)
+/*     DICT    *ptr;
+/* DESCRIPTION
+/*     dict_alloc() allocates memory for a dictionary structure of
+/*     \fIsize\fR bytes, initializes all properties to default settings,
+/*     and installs default methods that do not support any operation.
+/*     The caller is supposed to override the default methods with
+/*     ones that it supports.
+/*     The purpose of the default methods is to trap an attempt to
+/*     invoke an unsupported method.
+/*
+/*     dict_free() releases memory and cleans up after dict_alloc().
+/*     It is up to the caller to dispose of any memory that was allocated
+/*     by the caller.
+/*
+/*     Arguments:
+/* .IP dict_type
+/*     The official name for this type of dictionary, as used by
+/*     dict_open(3) etc. This is stored under the \fBtype\fR
+/*     member.
+/* .IP dict_name
+/*     Dictionary name. This is stored as the \fBname\fR member.
+/* .IP size
+/*     The size in bytes of the dictionary subclass structure instance.
+/* SEE ALSO
+/*     dict(3)
+/* DIAGNOSTICS
+/*     Fatal errors: the process invokes a default method.
+/* LICENSE
+/* .ad
+/* .fi
+/*     The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/*     Wietse Venema
+/*     IBM T.J. Watson Research
+/*     P.O. Box 704
+/*     Yorktown Heights, NY 10598, USA
+/*--*/
+
+/* System libraries. */
+
+#include "sys_defs.h"
+
+/* Utility library. */
+
+#include "msg.h"
+#include "mymalloc.h"
+#include "dict.h"
+
+/* dict_default_lookup - trap unimplemented operation */
+
+static const char *dict_default_lookup(DICT *dict, const char *unused_key)
+{
+    msg_fatal("%s table %s: lookup operation is not supported",
+             dict->type, dict->name);
+}
+
+/* dict_default_update - trap unimplemented operation */
+
+static void dict_default_update(DICT *dict, const char *unused_key,
+                                       const char *unused_value)
+{
+    msg_fatal("%s table %s: update operation is not supported",
+             dict->type, dict->name);
+}
+
+/* dict_default_delete - trap unimplemented operation */
+
+static int dict_default_delete(DICT *dict, const char *unused_key)
+{
+    msg_fatal("%s table %s: delete operation is not supported",
+             dict->type, dict->name);
+}
+
+/* dict_default_sequence - trap unimplemented operation */
+
+static int dict_default_sequence(DICT *dict, int function,
+                        const char **unused_key, const char **unused_value)
+{
+    msg_fatal("%s table %s: sequence operation is not supported",
+             dict->type, dict->name);
+}
+
+/* dict_default_close - trap unimplemented operation */
+
+static void dict_default_close(DICT *dict)
+{
+    msg_fatal("%s table %s: close operation is not supported",
+              dict->type, dict->name);
+}
+
+/* dict_alloc - allocate dictionary object, initialize super-class */
+
+DICT   *dict_alloc(const char *dict_type, const char *dict_name, int size)
+{
+    DICT   *dict = (DICT *) mymalloc(size);
+
+    dict->type = mystrdup(dict_type);
+    dict->name = mystrdup(dict_name);
+    dict->flags = DICT_FLAG_FIXED;
+    dict->lookup = dict_default_lookup;
+    dict->update = dict_default_update;
+    dict->delete = dict_default_delete;
+    dict->sequence = dict_default_sequence;
+    dict->close = dict_default_close;
+    dict->fd = -1;
+    dict->mtime = 0;
+    return dict;
+}
+
+/* dict_free - super-class destructor */
+
+void    dict_free(DICT *dict)
+{
+    myfree(dict->type);
+    myfree(dict->name);
+    myfree((char *) dict);
+}
index c75fb077892ae14cc3a62c103c642fae456bc7f9..a887b4be2a8a2557dfc0e8a980ce3e7c2295282b 100644 (file)
 typedef struct {
     DICT    dict;                      /* generic members */
     DB     *db;                                /* open db file */
-    char   *path;                      /* pathname */
 } DICT_DB;
 
 #define DICT_DB_CACHE_SIZE     (1024 * 1024)
@@ -160,7 +159,7 @@ static const char *dict_db_lookup(DICT *dict, const char *name)
      */
     if ((dict->flags & DICT_FLAG_LOCK)
        && myflock(dict->fd, INTERNAL_LOCK, MYFLOCK_OP_SHARED) < 0)
-       msg_fatal("%s: lock dictionary: %m", dict_db->path);
+       msg_fatal("%s: lock dictionary: %m", dict_db->dict.name);
 
     /*
      * See if this DB file was written with one null byte appended to key and
@@ -170,7 +169,7 @@ static const char *dict_db_lookup(DICT *dict, const char *name)
        db_key.data = (void *) name;
        db_key.size = strlen(name) + 1;
        if ((status = DICT_DB_GET(db, &db_key, &db_value, 0)) < 0)
-           msg_fatal("error reading %s: %m", dict_db->path);
+           msg_fatal("error reading %s: %m", dict_db->dict.name);
        if (status == 0) {
            dict->flags &= ~DICT_FLAG_TRY0NULL;
            result = db_value.data;
@@ -185,7 +184,7 @@ static const char *dict_db_lookup(DICT *dict, const char *name)
        db_key.data = (void *) name;
        db_key.size = strlen(name);
        if ((status = DICT_DB_GET(db, &db_key, &db_value, 0)) < 0)
-           msg_fatal("error reading %s: %m", dict_db->path);
+           msg_fatal("error reading %s: %m", dict_db->dict.name);
        if (status == 0) {
            if (buf == 0)
                buf = vstring_alloc(10);
@@ -200,7 +199,7 @@ static const char *dict_db_lookup(DICT *dict, const char *name)
      */
     if ((dict->flags & DICT_FLAG_LOCK)
        && myflock(dict->fd, INTERNAL_LOCK, MYFLOCK_OP_NONE) < 0)
-       msg_fatal("%s: unlock dictionary: %m", dict_db->path);
+       msg_fatal("%s: unlock dictionary: %m", dict_db->dict.name);
 
     return (result);
 }
@@ -248,32 +247,32 @@ static void dict_db_update(DICT *dict, const char *name, const char *value)
      */
     if ((dict->flags & DICT_FLAG_LOCK)
        && myflock(dict->fd, INTERNAL_LOCK, MYFLOCK_OP_EXCLUSIVE) < 0)
-       msg_fatal("%s: lock dictionary: %m", dict_db->path);
+       msg_fatal("%s: lock dictionary: %m", dict_db->dict.name);
 
     /*
      * Do the update.
      */
     if ((status = DICT_DB_PUT(db, &db_key, &db_value,
             (dict->flags & DICT_FLAG_DUP_REPLACE) ? 0 : DONT_CLOBBER)) < 0)
-       msg_fatal("error writing %s: %m", dict_db->path);
+       msg_fatal("error writing %s: %m", dict_db->dict.name);
     if (status) {
        if (dict->flags & DICT_FLAG_DUP_IGNORE)
             /* void */ ;
        else if (dict->flags & DICT_FLAG_DUP_WARN)
-           msg_warn("%s: duplicate entry: \"%s\"", dict_db->path, name);
+           msg_warn("%s: duplicate entry: \"%s\"", dict_db->dict.name, name);
        else
-           msg_fatal("%s: duplicate entry: \"%s\"", dict_db->path, name);
+           msg_fatal("%s: duplicate entry: \"%s\"", dict_db->dict.name, name);
     }
     if (dict->flags & DICT_FLAG_SYNC_UPDATE)
        if (DICT_DB_SYNC(db, 0) < 0)
-           msg_fatal("%s: flush dictionary: %m", dict_db->path);
+           msg_fatal("%s: flush dictionary: %m", dict_db->dict.name);
 
     /*
      * Release the exclusive lock.
      */
     if ((dict->flags & DICT_FLAG_LOCK)
        && myflock(dict->fd, INTERNAL_LOCK, MYFLOCK_OP_NONE) < 0)
-       msg_fatal("%s: unlock dictionary: %m", dict_db->path);
+       msg_fatal("%s: unlock dictionary: %m", dict_db->dict.name);
 }
 
 /* delete one entry from the dictionary */
@@ -291,7 +290,7 @@ static int dict_db_delete(DICT *dict, const char *name)
      */
     if ((dict->flags & DICT_FLAG_LOCK)
        && myflock(dict->fd, INTERNAL_LOCK, MYFLOCK_OP_EXCLUSIVE) < 0)
-       msg_fatal("%s: lock dictionary: %m", dict_db->path);
+       msg_fatal("%s: lock dictionary: %m", dict_db->dict.name);
 
     /*
      * See if this DB file was written with one null byte appended to key and
@@ -301,7 +300,7 @@ static int dict_db_delete(DICT *dict, const char *name)
        db_key.data = (void *) name;
        db_key.size = strlen(name) + 1;
        if ((status = DICT_DB_DEL(db, &db_key, flags)) < 0)
-           msg_fatal("error deleting from %s: %m", dict_db->path);
+           msg_fatal("error deleting from %s: %m", dict_db->dict.name);
        if (status == 0)
            dict->flags &= ~DICT_FLAG_TRY0NULL;
     }
@@ -314,20 +313,20 @@ static int dict_db_delete(DICT *dict, const char *name)
        db_key.data = (void *) name;
        db_key.size = strlen(name);
        if ((status = DICT_DB_DEL(db, &db_key, flags)) < 0)
-           msg_fatal("error deleting from %s: %m", dict_db->path);
+           msg_fatal("error deleting from %s: %m", dict_db->dict.name);
        if (status == 0)
            dict->flags &= ~DICT_FLAG_TRY1NULL;
     }
     if (dict->flags & DICT_FLAG_SYNC_UPDATE)
        if (DICT_DB_SYNC(db, 0) < 0)
-           msg_fatal("%s: flush dictionary: %m", dict_db->path);
+           msg_fatal("%s: flush dictionary: %m", dict_db->dict.name);
 
     /*
      * Release the exclusive lock.
      */
     if ((dict->flags & DICT_FLAG_LOCK)
        && myflock(dict->fd, INTERNAL_LOCK, MYFLOCK_OP_NONE) < 0)
-       msg_fatal("%s: unlock dictionary: %m", dict_db->path);
+       msg_fatal("%s: unlock dictionary: %m", dict_db->dict.name);
 
     return status;
 }
@@ -369,17 +368,17 @@ static int dict_db_sequence(DICT *dict, const int function,
      */
     if ((dict->flags & DICT_FLAG_LOCK)
        && myflock(dict->fd, INTERNAL_LOCK, MYFLOCK_OP_EXCLUSIVE) < 0)
-       msg_fatal("%s: lock dictionary: %m", dict_db->path);
+       msg_fatal("%s: lock dictionary: %m", dict_db->dict.name);
 
     if ((status = db->seq(db, &db_key, &db_value, db_function)) < 0)
-       msg_fatal("error seeking %s: %m", dict_db->path);
+       msg_fatal("error seeking %s: %m", dict_db->dict.name);
 
     /*
      * Release the exclusive lock.
      */
     if ((dict->flags & DICT_FLAG_LOCK)
        && myflock(dict->fd, INTERNAL_LOCK, MYFLOCK_OP_NONE) < 0)
-       msg_fatal("%s: unlock dictionary: %m", dict_db->path);
+       msg_fatal("%s: unlock dictionary: %m", dict_db->dict.name);
 
     if (status == 0) {
 
@@ -415,17 +414,16 @@ static void dict_db_close(DICT *dict)
     DICT_DB *dict_db = (DICT_DB *) dict;
 
     if (DICT_DB_SYNC(dict_db->db, 0) < 0)
-       msg_fatal("flush database %s: %m", dict_db->path);
+       msg_fatal("flush database %s: %m", dict_db->dict.name);
     if (DICT_DB_CLOSE(dict_db->db) < 0)
-       msg_fatal("close database %s: %m", dict_db->path);
-    myfree(dict_db->path);
-    myfree((char *) dict_db);
+       msg_fatal("close database %s: %m", dict_db->dict.name);
+    dict_free(dict);
 }
 
 /* dict_db_open - open data base */
 
-static DICT *dict_db_open(const char *path, int open_flags, int type,
-                                 void *tweak, int dict_flags)
+static DICT *dict_db_open(const char *class, const char *path, int open_flags,
+                                 int type, void *tweak, int dict_flags)
 {
     DICT_DB *dict_db;
     struct stat st;
@@ -509,7 +507,7 @@ static DICT *dict_db_open(const char *path, int open_flags, int type,
        if (close(lock_fd) < 0)
            msg_fatal("close database %s: %m", db_path);
     }
-    dict_db = (DICT_DB *) mymalloc(sizeof(*dict_db));
+    dict_db = (DICT_DB *) dict_alloc(class, db_path, sizeof(*dict_db));
     dict_db->dict.lookup = dict_db_lookup;
     dict_db->dict.update = dict_db_update;
     dict_db->dict.delete = dict_db_delete;
@@ -524,7 +522,7 @@ static DICT *dict_db_open(const char *path, int open_flags, int type,
     if ((dict_flags & (DICT_FLAG_TRY1NULL | DICT_FLAG_TRY0NULL)) == 0)
        dict_db->dict.flags |= (DICT_FLAG_TRY1NULL | DICT_FLAG_TRY0NULL);
     dict_db->db = db;
-    dict_db->path = db_path;
+    myfree(db_path);
     return (&dict_db->dict);
 }
 
@@ -551,7 +549,8 @@ DICT   *dict_hash_open(const char *path, int open_flags, int dict_flags)
 
     tweak = 0;
 #endif
-    return (dict_db_open(path, open_flags, DB_HASH, (void *) &tweak, dict_flags));
+    return (dict_db_open(DICT_TYPE_HASH, path, open_flags, DB_HASH,
+                        (void *) &tweak, dict_flags));
 }
 
 /* dict_btree_open - create association with data base */
@@ -576,7 +575,8 @@ DICT   *dict_btree_open(const char *path, int open_flags, int dict_flags)
     tweak = 0;
 #endif
 
-    return (dict_db_open(path, open_flags, DB_BTREE, (void *) &tweak, dict_flags));
+    return (dict_db_open(DICT_TYPE_BTREE, path, open_flags, DB_BTREE,
+                        (void *) &tweak, dict_flags));
 }
 
 #endif
index 43d7e35ab57b50cd56a48e4cd8477b33d73d7faf..f42984ffcb8d19f3803e40e33ad7f1b2135f84fe 100644 (file)
@@ -19,6 +19,9 @@
  /*
   * External interface.
   */
+#define DICT_TYPE_HASH "hash"
+#define DICT_TYPE_BTREE        "btree"
+
 extern DICT *dict_hash_open(const char *, int, int);
 extern DICT *dict_btree_open(const char *, int, int);
 
index c870f32a9bbb96266eedcbd64484c1050351a774..332c38f77d5129a4756e0b44423259dcf778abc3 100644 (file)
@@ -66,7 +66,6 @@
 typedef struct {
     DICT    dict;                      /* generic members */
     DBM    *dbm;                       /* open database */
-    char   *path;                      /* pathname */
 } DICT_DBM;
 
 /* dict_dbm_lookup - find database entry */
@@ -86,7 +85,7 @@ static const char *dict_dbm_lookup(DICT *dict, const char *name)
      */
     if ((dict->flags & DICT_FLAG_LOCK)
        && myflock(dict->fd, INTERNAL_LOCK, MYFLOCK_OP_SHARED) < 0)
-       msg_fatal("%s: lock dictionary: %m", dict_dbm->path);
+       msg_fatal("%s: lock dictionary: %m", dict_dbm->dict.name);
 
     /*
      * See if this DBM file was written with one null byte appended to key
@@ -124,7 +123,7 @@ static const char *dict_dbm_lookup(DICT *dict, const char *name)
      */
     if ((dict->flags & DICT_FLAG_LOCK)
        && myflock(dict->fd, INTERNAL_LOCK, MYFLOCK_OP_NONE) < 0)
-       msg_fatal("%s: unlock dictionary: %m", dict_dbm->path);
+       msg_fatal("%s: unlock dictionary: %m", dict_dbm->dict.name);
 
     return (result);
 }
@@ -169,21 +168,21 @@ static void dict_dbm_update(DICT *dict, const char *name, const char *value)
      */
     if ((dict->flags & DICT_FLAG_LOCK)
        && myflock(dict->fd, INTERNAL_LOCK, MYFLOCK_OP_EXCLUSIVE) < 0)
-       msg_fatal("%s: lock dictionary: %m", dict_dbm->path);
+       msg_fatal("%s: lock dictionary: %m", dict_dbm->dict.name);
 
     /*
      * Do the update.
      */
     if ((status = dbm_store(dict_dbm->dbm, dbm_key, dbm_value,
      (dict->flags & DICT_FLAG_DUP_REPLACE) ? DBM_REPLACE : DBM_INSERT)) < 0)
-       msg_fatal("error writing DBM database %s: %m", dict_dbm->path);
+       msg_fatal("error writing DBM database %s: %m", dict_dbm->dict.name);
     if (status) {
        if (dict->flags & DICT_FLAG_DUP_IGNORE)
             /* void */ ;
        else if (dict->flags & DICT_FLAG_DUP_WARN)
-           msg_warn("%s: duplicate entry: \"%s\"", dict_dbm->path, name);
+           msg_warn("%s: duplicate entry: \"%s\"", dict_dbm->dict.name, name);
        else
-           msg_fatal("%s: duplicate entry: \"%s\"", dict_dbm->path, name);
+           msg_fatal("%s: duplicate entry: \"%s\"", dict_dbm->dict.name, name);
     }
 
     /*
@@ -191,7 +190,7 @@ static void dict_dbm_update(DICT *dict, const char *name, const char *value)
      */
     if ((dict->flags & DICT_FLAG_LOCK)
        && myflock(dict->fd, INTERNAL_LOCK, MYFLOCK_OP_NONE) < 0)
-       msg_fatal("%s: unlock dictionary: %m", dict_dbm->path);
+       msg_fatal("%s: unlock dictionary: %m", dict_dbm->dict.name);
 }
 
 /* dict_dbm_delete - delete one entry from the dictionary */
@@ -208,7 +207,7 @@ static int dict_dbm_delete(DICT *dict, const char *name)
      */
     if ((dict->flags & DICT_FLAG_LOCK)
        && myflock(dict->fd, INTERNAL_LOCK, MYFLOCK_OP_EXCLUSIVE) < 0)
-       msg_fatal("%s: lock dictionary: %m", dict_dbm->path);
+       msg_fatal("%s: lock dictionary: %m", dict_dbm->dict.name);
 
     /*
      * See if this DBM file was written with one null byte appended to key
@@ -220,7 +219,7 @@ static int dict_dbm_delete(DICT *dict, const char *name)
        dbm_clearerr(dict_dbm->dbm);
        if ((status = dbm_delete(dict_dbm->dbm, dbm_key)) < 0) {
            if (dbm_error(dict_dbm->dbm) != 0)  /* fatal error */
-               msg_fatal("error deleting from %s: %m", dict_dbm->path);
+               msg_fatal("error deleting from %s: %m", dict_dbm->dict.name);
            status = 1;                         /* not found */
        } else {
            dict->flags &= ~DICT_FLAG_TRY0NULL; /* found */
@@ -237,7 +236,7 @@ static int dict_dbm_delete(DICT *dict, const char *name)
        dbm_clearerr(dict_dbm->dbm);
        if ((status = dbm_delete(dict_dbm->dbm, dbm_key)) < 0) {
            if (dbm_error(dict_dbm->dbm) != 0)  /* fatal error */
-               msg_fatal("error deleting from %s: %m", dict_dbm->path);
+               msg_fatal("error deleting from %s: %m", dict_dbm->dict.name);
            status = 1;                         /* not found */
        } else {
            dict->flags &= ~DICT_FLAG_TRY1NULL; /* found */
@@ -249,7 +248,7 @@ static int dict_dbm_delete(DICT *dict, const char *name)
      */
     if ((dict->flags & DICT_FLAG_LOCK)
        && myflock(dict->fd, INTERNAL_LOCK, MYFLOCK_OP_NONE) < 0)
-       msg_fatal("%s: unlock dictionary: %m", dict_dbm->path);
+       msg_fatal("%s: unlock dictionary: %m", dict_dbm->dict.name);
 
     return (status);
 }
@@ -272,7 +271,7 @@ static int dict_dbm_sequence(DICT *dict, const int function,
      */
     if ((dict->flags & DICT_FLAG_LOCK)
        && myflock(dict->fd, INTERNAL_LOCK, MYFLOCK_OP_EXCLUSIVE) < 0)
-       msg_fatal("%s: lock dictionary: %m", dict_dbm->path);
+       msg_fatal("%s: lock dictionary: %m", dict_dbm->dict.name);
 
     /*
      * Determine and execute the seek function. It returns the key.
@@ -293,7 +292,7 @@ static int dict_dbm_sequence(DICT *dict, const int function,
      */
     if ((dict->flags & DICT_FLAG_LOCK)
        && myflock(dict->fd, INTERNAL_LOCK, MYFLOCK_OP_NONE) < 0)
-       msg_fatal("%s: unlock dictionary: %m", dict_dbm->path);
+       msg_fatal("%s: unlock dictionary: %m", dict_dbm->dict.name);
 
     if (dbm_key.dptr != 0 && dbm_key.dsize > 0) {
 
@@ -336,7 +335,7 @@ static int dict_dbm_sequence(DICT *dict, const int function,
             * condition.
             */
            if (dbm_error(dict_dbm->dbm))
-               msg_fatal("error seeking %s: %m", dict_dbm->path);
+               msg_fatal("error seeking %s: %m", dict_dbm->dict.name);
            return (1);                         /* no error: eof/not found
                                                 * (should not happen!) */
        }
@@ -346,7 +345,7 @@ static int dict_dbm_sequence(DICT *dict, const int function,
         * Determine if we have hit the last record or an error condition.
         */
        if (dbm_error(dict_dbm->dbm))
-           msg_fatal("error seeking %s: %m", dict_dbm->path);
+           msg_fatal("error seeking %s: %m", dict_dbm->dict.name);
        return (1);                             /* no error: eof/not found */
     }
     return (0);
@@ -359,8 +358,7 @@ static void dict_dbm_close(DICT *dict)
     DICT_DBM *dict_dbm = (DICT_DBM *) dict;
 
     dbm_close(dict_dbm->dbm);
-    myfree(dict_dbm->path);
-    myfree((char *) dict_dbm);
+    dict_free(dict);
 }
 
 /* dict_dbm_open - open DBM data base */
@@ -394,7 +392,7 @@ DICT   *dict_dbm_open(const char *path, int open_flags, int dict_flags)
            msg_fatal("close database %s: %m", dbm_path);
        myfree(dbm_path);
     }
-    dict_dbm = (DICT_DBM *) mymalloc(sizeof(*dict_dbm));
+    dict_dbm = (DICT_DBM *) dict_alloc(DICT_TYPE_DBM, path, sizeof(*dict_dbm));
     dict_dbm->dict.lookup = dict_dbm_lookup;
     dict_dbm->dict.update = dict_dbm_update;
     dict_dbm->dict.delete = dict_dbm_delete;
@@ -410,7 +408,6 @@ DICT   *dict_dbm_open(const char *path, int open_flags, int dict_flags)
     if ((dict_flags & (DICT_FLAG_TRY0NULL | DICT_FLAG_TRY1NULL)) == 0)
        dict_dbm->dict.flags |= (DICT_FLAG_TRY0NULL | DICT_FLAG_TRY1NULL);
     dict_dbm->dbm = dbm;
-    dict_dbm->path = mystrdup(path);
 
     return (&dict_dbm->dict);
 }
index e15e8fb7239546ba7b6ca2b76ab1d93fa948b212..0e2a3347e5a191f72774f924f3235957957de697 100644 (file)
@@ -19,6 +19,8 @@
  /*
   * External interface.
   */
+#define DICT_TYPE_DBM  "dbm"
+
 extern DICT *dict_dbm_open(const char *, int, int);
 
 /* LICENSE
index 1f906c7d75c9b2470c79ba3ea4dce92b8a34c12d..34c0e8447275fd5c933a45ad4f4fc1af57cdd181 100644 (file)
@@ -66,20 +66,19 @@ static const char *dict_env_lookup(DICT *unused_dict, const char *name)
 
 static void dict_env_close(DICT *dict)
 {
-    myfree((char *) dict);
+    dict_free(dict);
 }
 
 /* dict_env_open - make association with environment array */
 
-DICT   *dict_env_open(const char *unused_name, int unused_flags, int dict_flags)
+DICT   *dict_env_open(const char *name, int unused_flags, int dict_flags)
 {
     DICT   *dict;
 
-    dict = (DICT *) mymalloc(sizeof(*dict));
+    dict = dict_alloc(DICT_TYPE_ENVIRON, name, sizeof(*dict));
     dict->lookup = dict_env_lookup;
     dict->update = dict_env_update;
     dict->close = dict_env_close;
     dict->flags = dict_flags | DICT_FLAG_FIXED;
-    dict->fd = -1;
     return (dict);
 }
index f49e10551ad4420713e7063aa3401725149eac24..9abfa4fa1ac178e194c403c3b3d3699e82d8efc9 100644 (file)
@@ -19,6 +19,8 @@
  /*
   * External interface.
   */
+#define DICT_TYPE_ENVIRON      "environ"
+
 extern DICT *dict_env_open(const char *, int, int);
 
 /* LICENSE
index a3f51e6f3182902f681204620f9add06c0cb9efc..38625daadc4bac29b077d9f00b45b9ad3964d0ef 100644 (file)
@@ -6,7 +6,8 @@
 /* SYNOPSIS
 /*     #include <dict_ht.h>
 /*
-/*     DICT    *dict_ht_open(table, remove)
+/*     DICT    *dict_ht_open(name, table, remove)
+/*     const char *name;
 /*     HTABLE  *table;
 /*     void    (*remove)(char *value)
 /* DESCRIPTION
@@ -82,20 +83,19 @@ static void dict_ht_close(DICT *dict)
 
     if (dict_ht->remove)
        htable_free(dict_ht->table, dict_ht->remove);
-    myfree((char *) dict);
+    dict_free(dict);
 }
 
 /* dict_ht_open - create association with hash table */
 
-DICT   *dict_ht_open(HTABLE *table, void (*remove) (char *))
+DICT   *dict_ht_open(const char *name, HTABLE *table, void (*remove) (char *))
 {
     DICT_HT *dict_ht;
 
-    dict_ht = (DICT_HT *) mymalloc(sizeof(*dict_ht));
+    dict_ht = (DICT_HT *) dict_alloc(DICT_TYPE_HT, name, sizeof(*dict_ht));
     dict_ht->dict.lookup = dict_ht_lookup;
     dict_ht->dict.update = dict_ht_update;
     dict_ht->dict.close = dict_ht_close;
-    dict_ht->dict.fd = -1;
     dict_ht->table = table;
     dict_ht->remove = remove;
     return (&dict_ht->dict);
index 4f408bc97f73fca03e4d6629ea1ee8ed73829bc8..c0b49654e12bb9ab3583db94652704431cd9a4a4 100644 (file)
@@ -20,7 +20,9 @@
  /*
   * External interface.
   */
-extern DICT *dict_ht_open(HTABLE *, void (*) (char *));
+#define DICT_TYPE_HT   "internal"
+
+extern DICT *dict_ht_open(const char *, HTABLE *, void (*) (char *));
 
 /* LICENSE
 /* .ad
index 0ebdd377b410c5b7cd2d5e7711f53f3f91b79bc3..2692c6d4fbb73812328c52b1b3a39519a9c469e6 100644 (file)
@@ -582,14 +582,6 @@ static const char *dict_ldap_lookup(DICT *dict, const char *name)
     return (VSTRING_LEN(result) > 0 && !dict_errno ? vstring_str(result) : 0);
 }
 
-/* dict_ldap_update - add or update database entry */
-
-static void dict_ldap_update(DICT *dict, const char *unused_name,
-                                    const char *unused_value)
-{
-    msg_fatal("dict_ldap_update: Operation not implemented");
-}
-
 /* dict_ldap_close - disassociate from data base */
 
 static void dict_ldap_close(DICT *dict)
@@ -608,7 +600,7 @@ static void dict_ldap_close(DICT *dict)
     argv_free(dict_ldap->result_attributes);
     myfree(dict_ldap->bind_dn);
     myfree(dict_ldap->bind_pw);
-    myfree((char *) dict_ldap);
+    dict_free(dict);
 }
 
 /* dict_ldap_open - create association with data base */
@@ -622,11 +614,10 @@ DICT   *dict_ldap_open(const char *ldapsource, int dummy, int dict_flags)
     char   *scope;
     char   *attr;
 
-    dict_ldap = (DICT_LDAP *) mymalloc(sizeof(*dict_ldap));
+    dict_ldap = (DICT_LDAP *) dict_alloc(DICT_TYPE_LDAP, ldapsource,
+                                        sizeof(*dict_ldap));
     dict_ldap->dict.lookup = dict_ldap_lookup;
-    dict_ldap->dict.update = dict_ldap_update;
     dict_ldap->dict.close = dict_ldap_close;
-    dict_ldap->dict.fd = -1;
     dict_ldap->dict.flags = dict_flags | DICT_FLAG_FIXED;
 
     if (msg_verbose)
index 818835df02cb3986fcbd82966bfeb5bb127463e6..902896351c6135771f7bbb0ffc607d11f90954de 100644 (file)
@@ -19,6 +19,8 @@
  /*
   * External interface.
   */
+#define DICT_TYPE_LDAP "ldap"
+
 extern DICT *dict_ldap_open(const char *, int, int);
 
 /* AUTHOR(S)
index c4e5b5e15d7026a215c1fda600221885e7dc786f..91498b416dbbfe1425bc27340c044d3b584f9bc9 100644 (file)
@@ -73,6 +73,7 @@
 #include <stdlib.h>
 #include <syslog.h>
 #include <time.h>
+#include <mysql.h>
 
 /* Utility library. */
 #include "dict.h"
@@ -84,9 +85,6 @@
 #include "split_at.h"
 #include "find_inet.h"
 
-/* external declarations */
-extern int dict_errno;
-
 /* need some structs to help organize things */
 typedef struct {
     MYSQL  *db;
@@ -120,6 +118,11 @@ typedef struct {
     MYSQL_NAME *name;
 } DICT_MYSQL;
 
+#define STATACTIVE 0
+#define STATFAIL 1
+#define STATUNTRIED 2
+#define RETRY_CONN_INTV 60             /* 1 minute */
+
 /* internal function declarations */
 static PLMYSQL *plmysql_init(char *hostnames[], int);
 static MYSQL_RES *plmysql_query(PLMYSQL *, const char *, char *, char *, char *);
@@ -127,9 +130,6 @@ static void plmysql_dealloc(PLMYSQL *);
 static void plmysql_down_host(HOST *);
 static void plmysql_connect_single(HOST *, char *, char *, char *);
 static int plmysql_ready_reconn(HOST *);
-static void dict_mysql_update(DICT *, const char *, const char *);
-static void dict_mysql_delete(DICT *, const char *);
-static void dict_mysql_sequence(DICT *, const int, const char **, const char **);
 static const char *dict_mysql_lookup(DICT *, const char *);
 DICT   *dict_mysql_open(const char *, int, int);
 static void dict_mysql_close(DICT *);
@@ -349,14 +349,10 @@ DICT   *dict_mysql_open(const char *name, int unused_flags, int unused_dict_flag
     DICT_MYSQL *dict_mysql;
     int     connections;
 
-    dict_mysql = (DICT_MYSQL *) mymalloc(sizeof(DICT_MYSQL));
+    dict_mysql = (DICT_MYSQL *) dict_alloc(DICT_TYPE_MYSQL, name,
+                                          sizeof(DICT_MYSQL));
     dict_mysql->dict.lookup = dict_mysql_lookup;
-    dict_mysql->dict.update = dict_mysql_update;
-    dict_mysql->dict.delete = dict_mysql_delete;
-    dict_mysql->dict.sequence = dict_mysql_sequence;
     dict_mysql->dict.close = dict_mysql_close;
-    dict_mysql->dict.fd = -1;                  /* there's no file descriptor
-                                                * for locking */
     dict_mysql->name = mysqlname_parse(name);
     dict_mysql->pldb = plmysql_init(dict_mysql->name->hostnames,
                                    dict_mysql->name->len_hosts);
@@ -530,6 +526,7 @@ static void dict_mysql_close(DICT *dict)
     }
     myfree((char *) dict_mysql->name->hostnames);
     myfree((char *) dict_mysql->name);
+    dict_free(dict);
 }
 
 /* plmysql_dealloc - free memory associated with PLMYSQL close databases */
@@ -546,27 +543,4 @@ static void plmysql_dealloc(PLMYSQL *PLDB)
     myfree((char *) (PLDB));
 }
 
-
-/**********************************************************************
- * public interface dict_mysql_update - add or update table entry
- *
- *********************************************************************/
-static void dict_mysql_update(DICT *dict, const char *unused_name, const char *unused_value)
-{
-    DICT_MYSQL *dict_mysql = (DICT_MYSQL *) dict;
-
-    msg_fatal("dict_mysql_update: attempt to update mysql database");
-}
-
-static void dict_mysql_delete(DICT *unused_dict, const char *unused_name)
-{
-    msg_fatal("dict_mysql_delete: attempt to delete mysql database entry");
-}
-
-static void dict_mysql_sequence(DICT *unused_dict, const int unused_function,
-                        const char **unused_key, const char **unused_value)
-{
-    msg_fatal("dict_mysql_sequence: attempt to iterate over mysql database");
-}
-
 #endif
index fdb9395d32376dd5959fa4def432f761eec10c96..7fe559bd53cec2fad3d315f8a2f5ec226030068b 100644 (file)
@@ -1,14 +1,40 @@
-#ifdef HAS_MYSQL
+#ifndef _DICT_MYSQL_H_INCLUDED_
+#define _DICT_MYSQL_H_INCLUDED_
 
-#include <time.h>
-#include "mysql.h"
+/*++
+/* NAME
+/*     dict_mysql 3h
+/* SUMMARY
+/*     dictionary manager interface to mysql databases
+/* SYNOPSIS
+/*     #include <dict_mysql.h>
+/* DESCRIPTION
+/* .nf
 
-#define STATACTIVE 0
-#define STATFAIL 1
-#define STATUNTRIED 2
-#define RETRY_CONN_INTV 60             /* 1 minute */
+ /*
+  * Utility library.
+  */
+#include <dict.h>
 
-extern DICT *dict_mysql_open(const char *name, int unused_flags, int dict_flags);
+ /*
+  * External interface.
+  */
+#define DICT_TYPE_MYSQL        "mysql"
 
+extern DICT *dict_mysql_open(const char *, int, int);
+
+/* LICENSE
+/* .ad
+/* .fi
+/*     The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/*     Scott Cotton
+/*     IC Group, Inc.
+/*     scott@icgroup.com
+/*
+/*     Joshua Marcus
+/*     IC Group, Inc.
+/*     josh@icgroup.com
+/*--*/
 
 #endif
index 6f1b6e0ea90b628aebc08aadff08fa619da39e1c..acee1c50ecef4c251dd4585777e5a632ee1db8b1 100644 (file)
@@ -151,43 +151,28 @@ static const char *dict_ni_lookup(DICT *dict, const char *key)
 {
     DICT_NI *d = (DICT_NI *) dict;
 
-    return dict_ni_do_lookup(d->path, NETINFO_PROP_KEY,
+    return dict_ni_do_lookup(d->dict.name, NETINFO_PROP_KEY,
                             key, NETINFO_PROP_VALUE);
 }
 
-/* dict_ni_update - add or update table entry (not!) */
-
-static void dict_ni_update(DICT *dict, const char *unused_name,
-                                  const char *unused_value)
-{
-    DICT_NI *d = (DICT_NI *) dict;
-
-    msg_fatal("dict_ni_update: unimplemented: update NetInfo directory %s",
-             d->path);
-}
-
 /* dict_ni_close - disassociate from NetInfo map */
 
 static void dict_ni_close(DICT *dict)
 {
     DICT_NI *d = (DICT_NI *) dict;
 
-    myfree(d->path);
-    myfree((char *) d);
+    dict_free(dict);
 }
 
 /* dict_ni_open - create association with NetInfo map */
 
 DICT   *dict_ni_open(const char *path, int unused_flags, int dict_flags)
 {
-    DICT_NI *d = (void *) mymalloc(sizeof(*d));
+    DICT_NI *d = (void *) dict_alloc(DICT_TYPE_NETINFO, path, sizeof(*d));
 
     d->dict.lookup = dict_ni_lookup;
-    d->dict.update = dict_ni_update;
     d->dict.close = dict_ni_close;
-    d->dict.fd = -1;
     d->dict.flags = dict_flags | DICT_FLAG_FIXED;
-    d->path = mystrdup(path);
 
     return &d->dict;
 }
index b0221a4b6e2181854a37ca87882d276006a416ff..652b422f135a5d6b1aba23e6c5e2b64b32e2d8a0 100644 (file)
@@ -19,6 +19,8 @@
  /*
   * External interface.
   */
+#define DICT_TYPE_NETINFO      "netinfo"
+
 extern DICT *dict_ni_open(const char *, int, int);
 
 /* AUTHOR(S)
index 36bb99bb34b0caa785187922ea7ee0fc0c451274..fa95efc35ab15743c5036b9c95cf819883ec24ea 100644 (file)
@@ -64,7 +64,6 @@
 
 typedef struct {
     DICT    dict;                      /* generic members */
-    char   *map;                       /* NIS map name */
 } DICT_NIS;
 
  /*
@@ -154,7 +153,7 @@ static const char *dict_nis_lookup(DICT *dict, const char *key)
      * value.
      */
     if (dict->flags & DICT_FLAG_TRY1NULL) {
-       err = yp_match(dict_nis_domain, dict_nis->map,
+       err = yp_match(dict_nis_domain, dict_nis->dict.name,
                       (void *) key, strlen(key) + 1,
                       &result, &result_len);
        if (err == 0) {
@@ -168,7 +167,7 @@ static const char *dict_nis_lookup(DICT *dict, const char *key)
      * value. This should never be the case, but better play safe.
      */
     if (dict->flags & DICT_FLAG_TRY0NULL) {
-       err = yp_match(dict_nis_domain, dict_nis->map,
+       err = yp_match(dict_nis_domain, dict_nis->dict.name,
                       (void *) key, strlen(key),
                       &result, &result_len);
        if (err == 0) {
@@ -187,30 +186,20 @@ static const char *dict_nis_lookup(DICT *dict, const char *key)
      */
     if (err != YPERR_KEY) {
        msg_warn("lookup %s, NIS domain %s, map %s: %s",
-                key, dict_nis_domain, dict_nis->map,
+                key, dict_nis_domain, dict_nis->dict.name,
                 dict_nis_strerror(err));
        dict_errno = DICT_ERR_RETRY;
     }
     return (0);
 }
 
-/* dict_nis_update - add or update table entry */
-
-static void dict_nis_update(DICT *dict, const char *unused_name, const char *unused_value)
-{
-    DICT_NIS *dict_nis = (DICT_NIS *) dict;
-
-    msg_fatal("dict_nis_update: attempt to update NIS map %s", dict_nis->map);
-}
-
 /* dict_nis_close - close NIS map */
 
 static void dict_nis_close(DICT *dict)
 {
     DICT_NIS *dict_nis = (DICT_NIS *) dict;
 
-    myfree(dict_nis->map);
-    myfree((char *) dict_nis);
+    dict_free(dict);
 }
 
 /* dict_nis_open - open NIS map */
@@ -219,12 +208,9 @@ DICT   *dict_nis_open(const char *map, int unused_flags, int dict_flags)
 {
     DICT_NIS *dict_nis;
 
-    dict_nis = (DICT_NIS *) mymalloc(sizeof(*dict_nis));
+    dict_nis = (DICT_NIS *) dict_alloc(DICT_TYPE_NIS, map, sizeof(*dict_nis));
     dict_nis->dict.lookup = dict_nis_lookup;
-    dict_nis->dict.update = dict_nis_update;
     dict_nis->dict.close = dict_nis_close;
-    dict_nis->dict.fd = -1;
-    dict_nis->map = mystrdup(map);
     dict_nis->dict.flags = dict_flags | DICT_FLAG_FIXED;
     if ((dict_flags & (DICT_FLAG_TRY1NULL | DICT_FLAG_TRY0NULL)) == 0)
        dict_nis->dict.flags |= (DICT_FLAG_TRY1NULL | DICT_FLAG_TRY0NULL);
index ff2759b7c5c1e98555bcad94ec8b4c8f80358e0f..97aa7cda94d5f9642cc7815b4d57eab4c9221997 100644 (file)
@@ -19,6 +19,8 @@
  /*
   * External interface.
   */
+#define DICT_TYPE_NIS  "nis"
+
 extern DICT *dict_nis_open(const char *, int, int);
 
 /* LICENSE
index 06c9d2fcd1b292736611694cb604000db50961fa..46b88ce3384d894083e221d57c636ee3191f4695 100644 (file)
 
 typedef struct {
     DICT    dict;                      /* generic members */
-    char   *map;                       /* NISPLUS map name */
 } DICT_NISPLUS;
 
-/* dict_nisplus_lookup - find table entry */
-
-static const char *dict_nisplus_lookup(DICT *unused_dict, const char *unused_name)
-{
-    dict_errno = 0;
-    msg_warn("dict_nisplus_lookup: NISPLUS lookup not implemented");
-    return (0);
-}
-
-/* dict_nisplus_update - add or update table entry */
-
-static void dict_nisplus_update(DICT *dict, const char *unused_name, const char *unused_value)
-{
-    DICT_NISPLUS *dict_nisplus = (DICT_NISPLUS *) dict;
-
-    msg_fatal("dict_nisplus_update: attempt to update NIS+ map %s",
-             dict_nisplus->map);
-}
-
 /* dict_nisplus_close - close NISPLUS map */
 
 static void dict_nisplus_close(DICT *dict)
 {
     DICT_NISPLUS *dict_nisplus = (DICT_NISPLUS *) dict;
 
-    myfree(dict_nisplus->map);
     myfree((char *) dict_nisplus);
 }
 
@@ -82,12 +61,9 @@ DICT   *dict_nisplus_open(const char *map, int unused_flags, int dict_flags)
 {
     DICT_NISPLUS *dict_nisplus;
 
-    dict_nisplus = (DICT_NISPLUS *) mymalloc(sizeof(*dict_nisplus));
-    dict_nisplus->dict.lookup = dict_nisplus_lookup;
-    dict_nisplus->dict.update = dict_nisplus_update;
+    dict_nisplus = (DICT_NISPLUS *) dict_alloc(DICT_TYPE_NISPLUS, map,
+                                              sizeof(*dict_nisplus));
     dict_nisplus->dict.close = dict_nisplus_close;
-    dict_nisplus->dict.fd = -1;
-    dict_nisplus->map = mystrdup(map);
     dict_nisplus->dict.flags = dict_flags | DICT_FLAG_FIXED;
     return (&dict_nisplus->dict);
 }
index f43b3141ba932232ea0af3ef1bb97984f0490c44..1fd31c955047a786ce88d9252306213304981781 100644 (file)
@@ -19,6 +19,8 @@
  /*
   * External interface.
   */
+#define DICT_TYPE_NISPLUS      "nisplus"
+
 extern DICT *dict_nisplus_open(const char *, int, int);
 
 /* LICENSE
index e06c9daa156420668aa16b7507647634ded07c89..2c15ac897ef86d3d554f3ae75a4841fb42d36199 100644 (file)
@@ -179,38 +179,38 @@ typedef struct {
 } DICT_OPEN_INFO;
 
 static DICT_OPEN_INFO dict_open_info[] = {
-    "environ", dict_env_open,
-    "unix", dict_unix_open,
+    DICT_TYPE_ENVIRON, dict_env_open,
+    DICT_TYPE_UNIX, dict_unix_open,
 #if 0
-    "tcp", dict_tcp_open,
+    DICT_TYPE_TCP, dict_tcp_open,
 #endif
 #ifdef HAS_DBM
-    "dbm", dict_dbm_open,
+    DICT_TYPE_DBM, dict_dbm_open,
 #endif
 #ifdef HAS_DB
-    "hash", dict_hash_open,
-    "btree", dict_btree_open,
+    DICT_TYPE_HASH, dict_hash_open,
+    DICT_TYPE_BTREE, dict_btree_open,
 #endif
 #ifdef HAS_NIS
-    "nis", dict_nis_open,
+    DICT_TYPE_NIS, dict_nis_open,
 #endif
 #ifdef HAS_NISPLUS
-    "nisplus", dict_nisplus_open,
+    DICT_TYPE_NISPLUS, dict_nisplus_open,
 #endif
 #ifdef HAS_NETINFO
-    "netinfo", dict_ni_open,
+    DICT_TYPE_NETINFO, dict_ni_open,
 #endif
 #ifdef HAS_LDAP
-    "ldap", dict_ldap_open,
+    DICT_TYPE_LDAP, dict_ldap_open,
 #endif
 #ifdef HAS_MYSQL
-    "mysql", dict_mysql_open,
+    DICT_TYPE_MYSQL, dict_mysql_open,
 #endif
 #ifdef HAS_PCRE
-    "pcre", dict_pcre_open,
+    DICT_TYPE_PCRE, dict_pcre_open,
 #endif
 #ifdef HAS_POSIX_REGEXP
-    "regexp", dict_regexp_open,
+    DICT_TYPE_REGEXP, dict_regexp_open,
 #endif
     0,
 };
index 019f3f449876da461b53180b4aee29457c036f29..8181057396efd709e4ea28e79458a46c25e713da 100644 (file)
@@ -70,25 +70,11 @@ struct dict_pcre_list {
 
 typedef struct {
     DICT    dict;                      /* generic members */
-    char   *map;                       /* map name */
-    int     flags;                     /* unused at the moment */
     struct dict_pcre_list *head;
 } DICT_PCRE;
 
 static  dict_pcre_init = 0;            /* flag need to init pcre library */
 
-/*
- *  dict_pcre_update - not supported
- */
-static void dict_pcre_update(DICT *dict, const char *unused_name,
-                                    const char *unused_value)
-{
-    DICT_PCRE *dict_pcre = (DICT_PCRE *) dict;
-
-    msg_fatal("dict_pcre_update: attempt to update regexp map %s",
-             dict_pcre->map);
-}
-
 /*
  * Context for macro expansion callback.
  */
@@ -153,7 +139,7 @@ static const char *dict_pcre_lookup(DICT *dict, const char *name)
     dict_errno = 0;
 
     if (msg_verbose)
-       msg_info("dict_pcre_lookup: %s: %s", dict_pcre->map, name);
+       msg_info("dict_pcre_lookup: %s: %s", dict_pcre->dict.name, name);
 
     /* Search for a matching expression */
     ctxt.matches = 0;
@@ -168,22 +154,22 @@ static const char *dict_pcre_lookup(DICT *dict, const char *name)
                    /* An error */
                    switch (ctxt.matches) {
                    case 0:
-                       msg_warn("regexp map %s, line %d: too many (...)",
-                                dict_pcre->map, pcre_list->lineno);
+                       msg_warn("pcre map %s, line %d: too many (...)",
+                                dict_pcre->dict.name, pcre_list->lineno);
                        break;
                    case PCRE_ERROR_NULL:
                    case PCRE_ERROR_BADOPTION:
-                       msg_fatal("regexp map %s, line %d: bad args to re_exec",
-                                 dict_pcre->map, pcre_list->lineno);
+                       msg_fatal("pcre map %s, line %d: bad args to re_exec",
+                                 dict_pcre->dict.name, pcre_list->lineno);
                        break;
                    case PCRE_ERROR_BADMAGIC:
                    case PCRE_ERROR_UNKNOWN_NODE:
-                       msg_fatal("regexp map %s, line %d: corrupt compiled regexp",
-                                 dict_pcre->map, pcre_list->lineno);
+                       msg_fatal("pcre map %s, line %d: corrupt compiled regexp",
+                                 dict_pcre->dict.name, pcre_list->lineno);
                        break;
                    default:
-                       msg_fatal("regexp map %s, line %d: unknown re_exec error: %d",
-                          dict_pcre->map, pcre_list->lineno, ctxt.matches);
+                       msg_fatal("pcre map %s, line %d: unknown re_exec error: %d",
+                                 dict_pcre->dict.name, pcre_list->lineno, ctxt.matches);
                        break;
                    }
                    return ((char *) 0);
@@ -200,12 +186,12 @@ static const char *dict_pcre_lookup(DICT *dict, const char *name)
        VSTRING_RESET(buf);
        ctxt.buf = buf;
        ctxt.subject = name;
-       ctxt.dict_name = dict_pcre->map;
+       ctxt.dict_name = dict_pcre->dict.name;
        ctxt.lineno = pcre_list->lineno;
 
        if (mac_parse(pcre_list->replace, dict_pcre_action, (char *) &ctxt) & MAC_PARSE_ERROR)
-           msg_fatal("regexp map %s, line %d: bad replacement syntax",
-                     dict_pcre->map, pcre_list->lineno);
+           msg_fatal("pcre map %s, line %d: bad replacement syntax",
+                     dict_pcre->dict.name, pcre_list->lineno);
 
        VSTRING_TERMINATE(buf);
        return (vstring_str(buf));
@@ -219,17 +205,19 @@ static void dict_pcre_close(DICT *dict)
 {
     DICT_PCRE *dict_pcre = (DICT_PCRE *) dict;
     struct dict_pcre_list *pcre_list;
+    struct dict_pcre_list *next;
 
-    for (pcre_list = dict_pcre->head; pcre_list; pcre_list = pcre_list->next) {
+    for (pcre_list = dict_pcre->head; pcre_list; pcre_list = next) {
+       next = pcre_list->next;
        if (pcre_list->pattern)
            myfree((char *) pcre_list->pattern);
        if (pcre_list->hints)
            myfree((char *) pcre_list->hints);
        if (pcre_list->replace)
            myfree((char *) pcre_list->replace);
+       myfree((char *) pcre_list);
     }
-    myfree(dict_pcre->map);
-    myfree((char *) dict_pcre);
+    dict_free(dict);
 }
 
 /*
@@ -254,12 +242,10 @@ DICT   *dict_pcre_open(const char *map, int unused_flags, int dict_flags)
 
     line_buffer = vstring_alloc(100);
 
-    dict_pcre = (DICT_PCRE *) mymalloc(sizeof(*dict_pcre));
+    dict_pcre = (DICT_PCRE *) dict_alloc(DICT_TYPE_PCRE, map,
+                                        sizeof(*dict_pcre));
     dict_pcre->dict.lookup = dict_pcre_lookup;
-    dict_pcre->dict.update = dict_pcre_update;
     dict_pcre->dict.close = dict_pcre_close;
-    dict_pcre->dict.fd = -1;
-    dict_pcre->map = mystrdup(map);
     dict_pcre->dict.flags = dict_flags | DICT_FLAG_PATTERN;
     dict_pcre->head = NULL;
 
index 253c69e78f57acdfe0ee74d355b52aa4ff427eef..3aa49559b2cae2c5bbc4a0dc972bea24835dd3ce 100644 (file)
@@ -19,6 +19,8 @@
  /*
   * External interface.
   */
+#define DICT_TYPE_PCRE "pcre"
+
 extern DICT *dict_pcre_open(const char *, int, int);
 
 /* LICENSE
index 7f86f083dba34c7f363ce495ea180ab670e2b8ff..795eecd4b28163c4d64c8c0282c5d771b29d9396 100644 (file)
@@ -82,18 +82,6 @@ struct dict_regexp_context {
     const char *subject;               /* str against which we match */
 };
 
-/*
- *  dict_regexp_update - not supported
- */
-static void dict_regexp_update(DICT *dict, const char *unused_name,
-                                      const char *unused_value)
-{
-    DICT_REGEXP *dict_regexp = (DICT_REGEXP *) dict;
-
-    msg_fatal("dict_regexp_update: attempt to update regexp map %s",
-             dict_regexp->map);
-}
-
 /*
  * Macro expansion callback - replace $0-${99} with strings cut from
  * matched string.
@@ -109,7 +97,7 @@ static int dict_regexp_action(int type, VSTRING *buf, char *ptr)
        n = atoi(vstring_str(buf));
        if (n >= dict->nmatch)
            msg_fatal("regexp %s, line %d: replacement index out of range",
-                     dict->map, rule->lineno);
+                     dict->dict.name, rule->lineno);
        if (dict->pmatch[n].rm_so < 0 ||
            dict->pmatch[n].rm_so == dict->pmatch[n].rm_eo) {
            return (MAC_PARSE_UNDEF);           /* empty string or not
@@ -138,7 +126,7 @@ static const char *dict_regexp_lookup(DICT *dict, const char *name)
     dict_errno = 0;
 
     if (msg_verbose)
-       msg_info("dict_regexp_lookup: %s: %s", dict_regexp->map, name);
+       msg_info("dict_regexp_lookup: %s: %s", dict_regexp->dict.name, name);
 
     /* Search for a matching expression */
     for (rule = dict_regexp->head; rule; rule = rule->next) {
@@ -155,7 +143,7 @@ static const char *dict_regexp_lookup(DICT *dict, const char *name)
 
                    (void) regerror(error, rule->expr[1], errbuf, sizeof(errbuf));
                    msg_fatal("regexp map %s, line %d: %s.",
-                             dict_regexp->map, rule->lineno, errbuf);
+                             dict_regexp->dict.name, rule->lineno, errbuf);
                }
            }
 
@@ -174,7 +162,7 @@ static const char *dict_regexp_lookup(DICT *dict, const char *name)
 
            if (mac_parse(rule->replace, dict_regexp_action, (char *) &ctxt) & MAC_PARSE_ERROR)
                msg_fatal("regexp map %s, line %d: bad replacement syntax.",
-                         dict_regexp->map, rule->lineno);
+                         dict_regexp->dict.name, rule->lineno);
 
            VSTRING_TERMINATE(buf);
            return (vstring_str(buf));
@@ -183,7 +171,7 @@ static const char *dict_regexp_lookup(DICT *dict, const char *name)
 
            (void) regerror(error, rule->expr[0], errbuf, sizeof(errbuf));
            msg_fatal("regexp map %s, line %d: %s.",
-                     dict_regexp->map, rule->lineno, errbuf);
+                     dict_regexp->dict.name, rule->lineno, errbuf);
            return ((char *) 0);
        }
     }
@@ -212,8 +200,7 @@ static void dict_regexp_close(DICT *dict)
     }
     if (dict_regexp->pmatch)
        myfree((char *) dict_regexp->pmatch);
-    myfree(dict_regexp->map);
-    myfree((char *) dict_regexp);
+    dict_free(dict);
 }
 
 static regex_t *dict_regexp_get_expr(int lineno, char **bufp, VSTREAM *map_fp)
@@ -358,12 +345,10 @@ DICT   *dict_regexp_open(const char *map, int unused_flags, int dict_flags)
 
     line_buffer = vstring_alloc(100);
 
-    dict_regexp = (DICT_REGEXP *) mymalloc(sizeof(*dict_regexp));
+    dict_regexp = (DICT_REGEXP *) dict_alloc(DICT_TYPE_REGEXP, map, 
+       sizeof(*dict_regexp));
     dict_regexp->dict.lookup = dict_regexp_lookup;
-    dict_regexp->dict.update = dict_regexp_update;
     dict_regexp->dict.close = dict_regexp_close;
-    dict_regexp->dict.fd = -1;
-    dict_regexp->map = mystrdup(map);
     dict_regexp->dict.flags = dict_flags | DICT_FLAG_PATTERN;
     dict_regexp->head = 0;
     dict_regexp->pmatch = 0;
index f487bedf6b2050a4a3fbd61377a194240f6f68e5..2874b2708093b21954880ae0573955f98cecc7e3 100644 (file)
@@ -19,6 +19,8 @@
  /*
   * External interface.
   */
+#define DICT_TYPE_REGEXP       "regexp"
+
 extern DICT *dict_regexp_open(const char *, int, int);
 
 /* AUTHOR(S)
index ccb516292338b609a51813de6af88aaa53ed92d5..f6fc3540d199bb756a15c6ed2b85fd80379b22a2 100644 (file)
@@ -98,7 +98,6 @@
 
 typedef struct {
     DICT    dict;                      /* generic members */
-    char   *map;                       /* server host:port */
     VSTRING *raw_buf;                  /* raw I/O buffer */
     VSTRING *hex_buf;                  /* quoted I/O buffer */
     VSTREAM *fp;                       /* I/O stream */
@@ -119,8 +118,8 @@ static int dict_tcp_connect(DICT_TCP *dict_tcp)
      * Connect to the server. Enforce a time limit on read/write operations
      * so that we do not get stuck.
      */
-    if ((fd = inet_connect(dict_tcp->map, BLOCKING, 0)) < 0) {
-       msg_warn("connect to TCP map %s: %m", dict_tcp->map);
+    if ((fd = inet_connect(dict_tcp->dict.name, BLOCKING, 0)) < 0) {
+       msg_warn("connect to TCP map %s: %m", dict_tcp->dict.name);
        return (-1);
     }
     dict_tcp->fp = vstream_fdopen(fd, O_RDWR);
@@ -181,7 +180,7 @@ static const char *dict_tcp_lookup(DICT *dict, const char *key)
             * Disconnect from the server if it can't talk to us.
             */
            msg_warn("read TCP map reply from %s: unexpected EOF (%m)",
-                    dict_tcp->map);
+                    dict_tcp->dict.name);
            dict_tcp_disconnect(dict_tcp);
        }
 
@@ -206,7 +205,7 @@ static const char *dict_tcp_lookup(DICT *dict, const char *key)
        || !ISDIGIT(start[2]) || !ISSPACE(start[3])
        || !hex_unquote(dict_tcp->raw_buf, start + 4)) {
        msg_warn("read TCP map reply from %s: malformed reply %.100s",
-                dict_tcp->map, printable(STR(dict_tcp->hex_buf), '_'));
+                dict_tcp->dict.name, printable(STR(dict_tcp->hex_buf), '_'));
        dict_tcp_disconnect(dict_tcp);
        RETURN(DICT_ERR_RETRY, 0);
     }
@@ -218,7 +217,7 @@ static const char *dict_tcp_lookup(DICT *dict, const char *key)
     switch (start[0]) {
     default:
        msg_warn("read TCP map reply from %s: bad status code %.100s",
-                dict_tcp->map, printable(STR(dict_tcp->hex_buf), '_'));
+                dict_tcp->dict.name, printable(STR(dict_tcp->hex_buf), '_'));
        dict_tcp_disconnect(dict_tcp);
        RETURN(DICT_ERR_RETRY, 0);
     case '4':
@@ -240,34 +239,6 @@ static const char *dict_tcp_lookup(DICT *dict, const char *key)
     }
 }
 
-/* dict_tcp_update - add or update table entry */
-
-static void dict_tcp_update(DICT *dict, const char *unused_name, const char *unused_value)
-{
-    DICT_TCP *dict_tcp = (DICT_TCP *) dict;
-
-    msg_fatal("dict_tcp_update: attempt to update map %s", dict_tcp->map);
-}
-
-/* dict_tcp_delete - remove table entry */
-
-static int dict_tcp_delete(DICT *dict, const char *unused_name)
-{
-    DICT_TCP *dict_tcp = (DICT_TCP *) dict;
-
-    msg_fatal("dict_tcp_delete: attempt to update map %s", dict_tcp->map);
-}
-
-/* dict_tcp_sequence - iterate over table */
-
-static int dict_tcp_sequence(DICT *dict, int unused_func,
-                       const char **unused_name, const char **unused_value)
-{
-    DICT_TCP *dict_tcp = (DICT_TCP *) dict;
-
-    msg_fatal("dict_tcp_sequence: attempt to iterate map %s", dict_tcp->map);
-}
-
 /* dict_tcp_close - close TCP map */
 
 static void dict_tcp_close(DICT *dict)
@@ -280,8 +251,7 @@ static void dict_tcp_close(DICT *dict)
        vstring_free(dict_tcp->raw_buf);
     if (dict_tcp->hex_buf)
        vstring_free(dict_tcp->hex_buf);
-    myfree(dict_tcp->map);
-    myfree((char *) dict_tcp);
+    dict_free(dict);
 }
 
 /* dict_tcp_open - open TCP map */
@@ -292,16 +262,11 @@ DICT   *dict_tcp_open(const char *map, int unused_flags, int dict_flags)
 
     dict_errno = 0;
 
-    dict_tcp = (DICT_TCP *) mymalloc(sizeof(*dict_tcp));
+    dict_tcp = (DICT_TCP *) dict_alloc(DICT_TYPE_TCP, map, sizeof(*dict_tcp));
     dict_tcp->fp = 0;
     dict_tcp->raw_buf = dict_tcp->hex_buf = 0;
     dict_tcp->dict.lookup = dict_tcp_lookup;
-    dict_tcp->dict.update = dict_tcp_update;
-    dict_tcp->dict.delete = dict_tcp_delete;
-    dict_tcp->dict.sequence = dict_tcp_sequence;
     dict_tcp->dict.close = dict_tcp_close;
-    dict_tcp->dict.fd = -1;
-    dict_tcp->map = mystrdup(map);
     dict_tcp->dict.flags = dict_flags | DICT_FLAG_FIXED;
     return (&dict_tcp->dict);
 }
index 4b31edad6676ecebe4164287fa0b8e4ac3f85248..9814c61ff82ae303cad8155a204a5f86ff624d82 100644 (file)
@@ -19,6 +19,8 @@
  /*
   * External interface.
   */
+#define DICT_TYPE_TCP  "tcp"
+
 extern DICT *dict_tcp_open(const char *, int, int);
 
 /* LICENSE
index 0b261de199df8abf62d923cffd97f133e68ea61c..d750b8d1ece748915aff59b7362f72fb1d85d618 100644 (file)
@@ -57,7 +57,6 @@
 
 typedef struct {
     DICT    dict;                      /* generic members */
-    char   *map;                       /* UNIX map name */
 } DICT_UNIX;
 
 /* dict_unix_getpwnam - find password table entry */
@@ -109,23 +108,13 @@ static const char *dict_unix_getgrnam(DICT *unused_dict, const char *key)
     }
 }
 
-/* dict_unix_update - add or update table entry */
-
-static void dict_unix_update(DICT *dict, const char *unused_name, const char *unused_value)
-{
-    DICT_UNIX *dict_unix = (DICT_UNIX *) dict;
-
-    msg_fatal("dict_unix_update: attempt to update map %s", dict_unix->map);
-}
-
 /* dict_unix_close - close UNIX map */
 
 static void dict_unix_close(DICT *dict)
 {
     DICT_UNIX *dict_unix = (DICT_UNIX *) dict;
 
-    myfree(dict_unix->map);
-    myfree((char *) dict_unix);
+    dict_free(dict);
 }
 
 /* dict_unix_open - open UNIX map */
@@ -146,7 +135,8 @@ DICT   *dict_unix_open(const char *map, int unused_flags, int dict_flags)
 
     dict_errno = 0;
 
-    dict_unix = (DICT_UNIX *) mymalloc(sizeof(*dict_unix));
+    dict_unix = (DICT_UNIX *) dict_alloc(DICT_TYPE_UNIX, map,
+                                        sizeof(*dict_unix));
     for (lp = dict_unix_lookup; /* void */ ; lp++) {
        if (lp->name == 0)
            msg_fatal("dict_unix_open: unknown map name: %s", map);
@@ -154,10 +144,7 @@ DICT   *dict_unix_open(const char *map, int unused_flags, int dict_flags)
            break;
     }
     dict_unix->dict.lookup = lp->lookup;
-    dict_unix->dict.update = dict_unix_update;
     dict_unix->dict.close = dict_unix_close;
-    dict_unix->dict.fd = -1;
-    dict_unix->map = mystrdup(map);
     dict_unix->dict.flags = dict_flags | DICT_FLAG_FIXED;
     return (&dict_unix->dict);
 }
index b82a1ec8fee722ec58e206c67e344f7dfcca4340..b5674b29236bda6ea8627fd526b17c7af0a5adc0 100644 (file)
@@ -19,6 +19,8 @@
  /*
   * External interface.
   */
+#define DICT_TYPE_UNIX "unix"
+
 extern DICT *dict_unix_open(const char *, int, int);
 
 /* LICENSE