summaryrefslogtreecommitdiffabout
path: root/src/main.c
authorSergey Poznyakoff <gray@gnu.org.ua>2007-12-12 12:22:30 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2007-12-12 12:22:30 (GMT)
commit60fbc52f285b19ccbc9723cdae135cbb22acfe98 (patch) (side-by-side diff)
treea5dc6c946b27627d5c3eb3906512f4728c6ea3b9 /src/main.c
parent080cc8f1c899f91f143694f3a3399a159239496b (diff)
downloadmailfromd-60fbc52f285b19ccbc9723cdae135cbb22acfe98.tar.gz
mailfromd-60fbc52f285b19ccbc9723cdae135cbb22acfe98.tar.bz2
Reflect recent changes to Mailutils.
git-svn-id: file:///svnroot/mailfromd/trunk@1534 7a8a7f39-df28-0410-adc6-e0d955640f24
Diffstat (limited to 'src/main.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/main.c129
1 files changed, 64 insertions, 65 deletions
diff --git a/src/main.c b/src/main.c
index 3798ca3..f09f34e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -37,10 +37,6 @@
#include <mailutils/mailutils.h>
#if MAILUTILS_VERSION_NUMBER < 1290
# include <mailutils/argp.h>
-typedef struct {
- char *file;
- int line;
-} mu_cfg_locus_t;
#else
# include <mailutils/libargp.h>
#endif
@@ -242,16 +238,17 @@ log_status(sfsistat status, SMFICTX *ctx)
}
static void
-mf_error_on_locus(mu_cfg_locus_t *locus, const char *fmt, ...)
+mf_error_on_locus(mu_debug_t err, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
- if (locus) {
- char *newfmt = NULL;
- asprintf(&newfmt, "%s:%d: %s", locus->file, locus->line, fmt);
- mu_verror(newfmt, ap);
+#if MAILUTILS_VERSION_NUMBER >= 1290
+ if (err) {
+ mu_debug_vprintf(err, 0, fmt, ap);
+ mu_debug_printf(err, 0, "\n");
} else
+#endif
mu_verror(fmt, ap);
va_end(ap);
}
@@ -270,7 +267,7 @@ compare_string(const void *item, const void *value)
/* Read domains from sendmail-style domain file NAME and store them in
DOMAIN_LIST */
int
-read_domain_file(mu_cfg_locus_t *locus, char *name)
+read_domain_file(mu_debug_t err, char *name)
{
FILE *fp;
char buf[256];
@@ -278,7 +275,7 @@ read_domain_file(mu_cfg_locus_t *locus, char *name)
fp = fopen(name, "r");
if (!fp) {
- mf_error_on_locus(locus, _("Cannot open file `%s': %s"),
+ mf_error_on_locus(err, _("Cannot open file `%s': %s"),
name, mu_strerror(errno));
return 1;
}
@@ -384,14 +381,14 @@ gid_comp(const void *item, const void *data)
}
static int
-mf_option_group(mu_cfg_locus_t *locus, char *arg)
+mf_option_group(mu_debug_t err, char *arg)
{
struct group *group = getgrnam(arg);
if (group) {
if (!retain_groups) {
int rc = mu_list_create(&retain_groups);
if (rc) {
- mf_error_on_locus(locus,
+ mf_error_on_locus(err,
_("Cannot create list: %s"),
mu_strerror(rc));
return 1;
@@ -400,21 +397,21 @@ mf_option_group(mu_cfg_locus_t *locus, char *arg)
}
mu_list_append(retain_groups, (void*)group->gr_gid);
} else {
- mf_error_on_locus(locus, _("Unknown group: %s"), arg);
+ mf_error_on_locus(err, _("Unknown group: %s"), arg);
return 1;
}
return 0;
}
static int
-mf_option_mailfrom(mu_cfg_locus_t *locus, char *arg)
+mf_option_mailfrom(mu_debug_t err, char *arg)
{
int rc;
mu_address_t addr;
rc = mu_address_create(&addr, arg);
if (rc) {
- mf_error_on_locus(locus, _("Cannot create address `%s': %s"),
+ mf_error_on_locus(err, _("Cannot create address `%s': %s"),
arg, mu_strerror(rc));
return 1;
}
@@ -424,21 +421,21 @@ mf_option_mailfrom(mu_cfg_locus_t *locus, char *arg)
}
static int
-mf_option_state_directory(mu_cfg_locus_t *locus, char *arg)
+mf_option_state_directory(mu_debug_t err, char *arg)
{
struct stat st;
if (stat(arg, &st)) {
- mf_error_on_locus(locus, _("Cannot stat file `%s': %s"),
+ mf_error_on_locus(err, _("Cannot stat file `%s': %s"),
arg,
mu_strerror(errno));
return 1;
}
if (!S_ISDIR(st.st_mode)) {
- mf_error_on_locus(locus, _("`%s' is not a directory"), arg);
+ mf_error_on_locus(err, _("`%s' is not a directory"), arg);
return 1;
}
if (arg[0] != '/') {
- mf_error_on_locus(locus,
+ mf_error_on_locus(err,
_("State directory `%s' is not an absolute file name"),
arg);
return 1;
@@ -448,13 +445,13 @@ mf_option_state_directory(mu_cfg_locus_t *locus, char *arg)
}
static int
-mf_option_source_ip(mu_cfg_locus_t *locus, char *arg, unsigned long *pval)
+mf_option_source_ip(mu_debug_t err, char *arg, unsigned long *pval)
{
unsigned long address = inet_addr(arg);
if (address == INADDR_NONE) {
struct hostent *phe = gethostbyname(arg);
if (!phe) {
- mf_error_on_locus(locus, _("Cannot resolve `%s'"),
+ mf_error_on_locus(err, _("Cannot resolve `%s'"),
arg);
return 1;
}
@@ -1458,11 +1455,11 @@ static struct argp argp = {
/* Mailutils-2.0 configuration */
#if MAILUTILS_VERSION_NUMBER >= 1290
int
-cb_timeout(time_t *pinterval, mu_cfg_locus_t *locus, void *data, char *arg)
+cb_timeout(time_t *pinterval, mu_debug_t err, void *data, char *arg)
{
const char *endp;
if (parse_time_interval(arg, pinterval, &endp)) {
- mf_error_on_locus(locus,
+ mf_error_on_locus(err,
_("unrecognized time format (near `%s')"),
endp);
return 1;
@@ -1471,14 +1468,14 @@ cb_timeout(time_t *pinterval, mu_cfg_locus_t *locus, void *data, char *arg)
}
int
-cb_milter_timeout(mu_cfg_locus_t *locus, void *data, char *arg)
+cb_milter_timeout(mu_debug_t err, void *data, char *arg)
{
time_t interval;
- if (cb_timeout(&interval, locus, data, arg))
+ if (cb_timeout(&interval, err, data, arg))
return 1;
if (smfi_settimeout(interval) == MI_FAILURE) {
- mf_error_on_locus(locus,
+ mf_error_on_locus(err,
_("%s:%d: Invalid milter timeout: %lu"),
(unsigned long) interval);
exit(EX_USAGE);
@@ -1488,52 +1485,52 @@ cb_milter_timeout(mu_cfg_locus_t *locus, void *data, char *arg)
}
int
-cb_io_timeout(mu_cfg_locus_t *locus, void *data, char *arg)
+cb_io_timeout(mu_debug_t err, void *data, char *arg)
{
- if (cb_timeout(&io_timeout, locus, data, arg))
+ if (cb_timeout(&io_timeout, err, data, arg))
return 1;
return 0;
}
int
-cb_connect_timeout(mu_cfg_locus_t *locus, void *data, char *arg)
+cb_connect_timeout(mu_debug_t err, void *data, char *arg)
{
- if (cb_timeout(&connect_timeout, locus, data, arg))
+ if (cb_timeout(&connect_timeout, err, data, arg))
return 1;
return 0;
}
int
-cb_initial_response_timeout(mu_cfg_locus_t *locus, void *data, char *arg)
+cb_initial_response_timeout(mu_debug_t err, void *data, char *arg)
{
- if (cb_timeout(&response_timeout, locus, data, arg))
+ if (cb_timeout(&response_timeout, err, data, arg))
return 1;
return 0;
}
int
-cb_lock_retry_timeout(mu_cfg_locus_t *locus, void *data, char *arg)
+cb_lock_retry_timeout(mu_debug_t err, void *data, char *arg)
{
- if (cb_timeout(&lock_retry_timeout_option, locus, data, arg))
+ if (cb_timeout(&lock_retry_timeout_option, err, data, arg))
return 1;
return 0;
}
int
-cb_set_variable(mu_cfg_locus_t *locus, void *data, char *arg)
+cb_set_variable(mu_debug_t err, void *data, char *arg)
{
char *p, *value;
char *tmp = NULL;
for (p = arg; !(*p == ' ' || *p == '\t'); p++)
if (!*p) {
- mf_error_on_locus(locus, _("missing value"));
+ mf_error_on_locus(err, _("missing value"));
return 1;
}
for (; *p == ' ' || *p == '\t'; p++)
if (!*p) {
- mf_error_on_locus(locus, _("missing value"));
+ mf_error_on_locus(err, _("missing value"));
return 1;
}
@@ -1551,20 +1548,20 @@ cb_set_variable(mu_cfg_locus_t *locus, void *data, char *arg)
}
int
-cb_ehlo_domain(mu_cfg_locus_t *locus, void *data, char *arg)
+cb_ehlo_domain(mu_debug_t err, void *data, char *arg)
{
defer_initialize_variable("ehlo_domain", arg);
return 0;
}
int
-cb_mail_from_address(mu_cfg_locus_t *locus, void *data, char *arg)
+cb_mail_from_address(mu_debug_t err, void *data, char *arg)
{
- return mf_option_mailfrom(locus, arg);
+ return mf_option_mailfrom(err, arg);
}
int
-cb_debug(mu_cfg_locus_t *locus, void *data, char *arg)
+cb_debug(mu_debug_t err, void *data, char *arg)
{
debug_parse_spec(arg);
return 0;
@@ -1572,31 +1569,31 @@ cb_debug(mu_cfg_locus_t *locus, void *data, char *arg)
/* See also option_group. */
int
-cb_group(mu_cfg_locus_t *locus, void *data, char *arg)
+cb_group(mu_debug_t err, void *data, char *arg)
{
- return mf_option_group(locus, arg);
+ return mf_option_group(err, arg);
}
int
-cb_state_directory(mu_cfg_locus_t *locus, void *data, char *arg)
+cb_state_directory(mu_debug_t err, void *data, char *arg)
{
- return mf_option_state_directory(locus, arg);
+ return mf_option_state_directory(err, arg);
}
int
-cb_relay_file(mu_cfg_locus_t *locus, void *data, char *arg)
+cb_relay_file(mu_debug_t err, void *data, char *arg)
{
- return read_domain_file(locus, arg);
+ return read_domain_file(err, arg);
}
int
-cb_source_ip(mu_cfg_locus_t *locus, void *data, char *arg)
+cb_source_ip(mu_debug_t err, void *data, char *arg)
{
- return mf_option_source_ip(locus, arg, &source_address);
+ return mf_option_source_ip(err, arg, &source_address);
}
int
-cb_include_path(mu_cfg_locus_t *locus, void *data, char *arg)
+cb_include_path(mu_debug_t err, void *data, char *arg)
{
char *p, *sp;
@@ -1607,28 +1604,30 @@ cb_include_path(mu_cfg_locus_t *locus, void *data, char *arg)
/* Keep alphabetical ordering of statements */
struct mu_cfg_param mf_cfg_param[] = {
- { "connect-timeout", mu_cfg_callback, NULL, cb_connect_timeout },
- { "debug", mu_cfg_callback, NULL, cb_debug },
- { "ehlo-domain", mu_cfg_callback, NULL, cb_ehlo_domain },
- { "group", mu_cfg_callback, NULL, cb_group },
- { "include-path", mu_cfg_callback, NULL, cb_include_path },
- { "initial-response-timeout", mu_cfg_callback, NULL,
+ { "connect-timeout", mu_cfg_callback, NULL, 0, cb_connect_timeout },
+ { "debug", mu_cfg_callback, NULL, 0, cb_debug },
+ { "ehlo-domain", mu_cfg_callback, NULL, 0, cb_ehlo_domain },
+ { "group", mu_cfg_callback, NULL, 0, cb_group },
+ { "include-path", mu_cfg_callback, NULL, 0, cb_include_path },
+ { "initial-response-timeout", mu_cfg_callback, NULL, 0,
cb_initial_response_timeout },
- { "io-timeout", mu_cfg_callback, NULL, cb_io_timeout },
+ { "io-timeout", mu_cfg_callback, NULL, 0, cb_io_timeout },
{ "lock-retry-count", mu_cfg_size, &lock_retry_count_option },
- { "lock-retry-timeout", mu_cfg_callback, NULL,
+ { "lock-retry-timeout", mu_cfg_callback, NULL, 0,
cb_lock_retry_timeout },
- { "mail-from-address", mu_cfg_callback, NULL, cb_mail_from_address },
- { "milter-timeout", mu_cfg_callback, NULL, cb_milter_timeout },
+ { "mail-from-address", mu_cfg_callback, NULL, 0,
+ cb_mail_from_address },
+ { "milter-timeout", mu_cfg_callback, NULL, 0,
+ cb_milter_timeout },
{ "pidfile", mu_cfg_string, &pidfile },
- { "relay-file", mu_cfg_callback, NULL, cb_relay_file },
- { "setvar", mu_cfg_callback, NULL, cb_set_variable },
+ { "relay-file", mu_cfg_callback, NULL, 0, cb_relay_file },
+ { "setvar", mu_cfg_callback, NULL, 0, cb_set_variable },
{ "script-file", mu_cfg_string, &script_file },
{ "source-info", mu_cfg_bool, &source_info_option },
/* FIXME: Could have used mu_cfg_ipv4 here, but... */
- { "source-ip", mu_cfg_callback, NULL, cb_source_ip },
+ { "source-ip", mu_cfg_callback, NULL, 0, cb_source_ip },
{ "stack-trace", mu_cfg_bool, &stack_trace_option },
- { "state-directory", mu_cfg_callback, NULL, cb_state_directory },
+ { "state-directory", mu_cfg_callback, NULL, 0, cb_state_directory },
{ "user", mu_cfg_string, &user },
{ NULL }
};

Return to:

Send suggestions and report system problems to the System administrator.