summaryrefslogtreecommitdiffabout
path: root/src/main.c
authorSergey Poznyakoff <gray@gnu.org.ua>2011-11-09 22:21:13 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2011-11-09 22:52:54 (GMT)
commit4926ea635ee23341615c351db3e4949553ca4dfb (patch) (unidiff)
treea1a8c4aede69cf55b5e27fa1dc1630aeeda70329 /src/main.c
parent7e4d54bd39368b36e8451d52975052c00e745f7a (diff)
downloadmailfromd-4926ea635ee23341615c351db3e4949553ca4dfb.tar.gz
mailfromd-4926ea635ee23341615c351db3e4949553ca4dfb.tar.bz2
Switch to libmu_dbm for DBM support.
* configure.ac (DEFAULT_DB_TYPE): New variable. Use mu info to determine which DBM is supported. * lib/Makefile.am (noinst_LIBRARIES): Remove libdbm.a * lib/mf-dbm.c: remove. * lib/mf-dbm.h: remove. * lib/cache.c: Use libmu_dbm functions. * lib/db.c: Likewise. * lib/dbcfg.c: Likewise. * lib/greylist.c: Likewise. * lib/rate.c: Likewise. * lib/tbf_rate.c: Likewise. * src/builtin/db.bi: Likewise. * src/savsrv.c: Likewise. * src/srvcfg.c (srv_cfg_param) <database-type>: New statement. * lib/libmf.h (config_cb_ignore): New proto. * lib/mfdb.h (db_item_printer_t): Change signature. * lib/utils.c (config_cb_ignore): New function. * po/POTFILES.in: Update. * src/Makefile.am (mailfromd_LDADD) (calloutd_LDADD): Remove libdbm.a. * src/calloutd.c: Update. * src/main.c (mf_cfg_param): lock-retry-count and lock-retry-timeout are no-op now. * src/mfdbtool.c: Likewise.
Diffstat (limited to 'src/main.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/main.c52
1 files changed, 37 insertions, 15 deletions
diff --git a/src/main.c b/src/main.c
index c277aa4..ba0c0f5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -37,6 +37,7 @@
37#include <mailutils/server.h> 37#include <mailutils/server.h>
38#include <mailutils/syslog.h> 38#include <mailutils/syslog.h>
39#include <mailutils/libargp.h> 39#include <mailutils/libargp.h>
40#include <mailutils/dbm.h>
40 41
41#include "mailfromd.h" 42#include "mailfromd.h"
42#include "callout.h" 43#include "callout.h"
@@ -44,7 +45,6 @@
44#include "inttostr.h" 45#include "inttostr.h"
45#include "srvcfg.h" 46#include "srvcfg.h"
46#include "filenames.h" 47#include "filenames.h"
47#include "mf-dbm.h"
48#include "builtin.h" 48#include "builtin.h"
49#include "prog.h" 49#include "prog.h"
50 50
@@ -918,11 +918,10 @@ struct mu_cfg_param mf_cfg_param[] = {
918 918
919 { "database", mu_cfg_section, NULL }, 919 { "database", mu_cfg_section, NULL },
920 920
921 { "lock-retry-count", mu_cfg_size, &lock_retry_count_option, 0, NULL, 921 { "lock-retry-count", mu_cfg_callback, 0, 0, config_cb_ignore,
922 N_("Retry acquiring DBM file lock this number of times.") }, 922 N_("Ignored for backward compatibility.") },
923 { "lock-retry-timeout", mu_cfg_callback, &lock_retry_timeout_option, 0, 923 { "lock-retry-timeout", mu_cfg_callback, 0,0, config_cb_ignore,
924 config_cb_time_t, 924 N_("Ignored for backward compatibility."),
925 N_("Set the time span between the two DBM locking attempts."),
926 N_("time") }, 925 N_("time") },
927 926
928 { "max-match-mx", mu_cfg_size, &max_match_mx, 0, NULL, 927 { "max-match-mx", mu_cfg_size, &max_match_mx, 0, NULL,
@@ -1003,6 +1002,37 @@ db_format_enumerator(struct db_format *fmt, void *data)
1003 return 0; 1002 return 0;
1004} 1003}
1005 1004
1005static void
1006list_db_formats(const char *pfx)
1007{
1008 mu_iterator_t itr;
1009 int rc;
1010 const char *defdb = DEFAULT_DB_TYPE;
1011 printf("%s", pfx);
1012
1013 rc = mu_dbm_impl_iterator(&itr);
1014 if (rc) {
1015 printf("%s\n", _("unknown"));
1016 mu_error("%s", mu_strerror(rc));
1017 } else {
1018 int i;
1019 for (mu_iterator_first(itr), i = 0; !mu_iterator_is_done(itr);
1020 mu_iterator_next(itr), i++) {
1021 struct mu_dbm_impl *impl;
1022
1023 mu_iterator_current(itr, (void**)&impl);
1024 if (i)
1025 printf(", ");
1026 else if (!defdb)
1027 defdb = impl->_dbm_name;
1028 printf("%s", impl->_dbm_name);
1029 }
1030 putchar('\n');
1031 mu_iterator_destroy(&itr);
1032 }
1033 printf("default database type: %s\n", defdb);
1034}
1035
1006void 1036void
1007mailfromd_show_defaults() 1037mailfromd_show_defaults()
1008{ 1038{
@@ -1020,14 +1050,7 @@ mailfromd_show_defaults()
1020 printf("default syslog: blocking\n"); 1050 printf("default syslog: blocking\n");
1021#endif 1051#endif
1022#endif 1052#endif
1023 printf("database format: "); 1053 list_db_formats("supported databases: ");
1024#if defined WITH_GDBM
1025 printf("GDBM");
1026#elif defined WITH_BDB
1027 printf("Berkeley DB %d.x", WITH_BDB);
1028#endif
1029 printf("\n");
1030
1031 printf("Optional features: "); 1054 printf("Optional features: ");
1032#if defined WITH_GEOIP 1055#if defined WITH_GEOIP
1033 printf(" GeoIP"); 1056 printf(" GeoIP");
@@ -1193,7 +1216,6 @@ main(int argc, char **argv)
1193 init_symbols(); 1216 init_symbols();
1194 builtin_setup(); 1217 builtin_setup();
1195 mf_runtime_param_finish(); 1218 mf_runtime_param_finish();
1196 libdbm_init();
1197 db_format_setup(); 1219 db_format_setup();
1198 include_path_setup(); 1220 include_path_setup();
1199 pragma_setup(); 1221 pragma_setup();

Return to:

Send suggestions and report system problems to the System administrator.