Commit aac8beae aac8beae014b6345bc3682c6d0f5b544b2a84956 by Sergey Poznyakoff

Use mu_c_type_t throughout the code. Get rid of mu_cfg_param_data_type.

* include/mailutils/cfg.h (mu_cfg_param_data_type): Remove.
(mu_cfg_param_type): New enum.
(mu_cfg_param) <type>: Change type to int.
(mu_cfg_cidr): Remove.
(mu_cfg_parse_boolean): Remove.  All uses updated.
* include/mailutils/util.h (mu_c_void): New constant.
(mu_c_type_str): New extern/
* libmailutils/string/str_to_c.c (mu_c_type_str): New global.
* libmailutils/cfg/format.c (mu_cfg_data_type_string): Rename
to mu_c_type_string; change argument type.
All uses updated.
* libmailutils/cfg/parser.y: Use mu_str_to_c for value
conversion.

* libmailutils/tests/.gitignore: Update.
* libmailutils/tests/Makefile.am: Add strtoc.at; build strtoc
* libmailutils/tests/strtoc.at: New file.
* libmailutils/tests/strtoc.c: New file.
* libmailutils/tests/testsuite.at: Include strtoc.at

* comsat/comsat.c: Use mu_c_type_t types.
* dotlock/dotlock.c: Likewise.
* imap4d/imap4d.c: Likewise.
* lib/manlock.c: Likewise.
* lib/tcpwrap.c: Likewise.
* libmailutils/server/msrv.c: Likewise.
* libmu_argp/muinit.c: Likewise.
* libmu_cfg/common.c: Likewise.
* libmu_cfg/gsasl.c: Likewise.
* libmu_cfg/ldap.c: Likewise.
* libmu_cfg/pam.c: Likewise.
* libmu_cfg/radius.c: Likewise.
* libmu_cfg/sieve.c: Likewise.
* libmu_cfg/sql.c: Likewise.
* libmu_cfg/tls.c: Likewise.
* libmu_cfg/virtdomain.c: Likewise.
* maidag/maidag.c: Likewise.
* mimeview/mimeview.c: Likewise.
* movemail/movemail.c: Likewise.
* pop3d/pop3d.c: Likewise.
* readmsg/readmsg.c: Likewise.
* sieve/sieve.c: Likewise.
1 parent 87ef8884
......@@ -128,7 +128,7 @@ biffrc_error_ctl (mu_config_value_t *val, int flag)
if (mu_cfg_assert_value_type (val, MU_CFG_STRING))
return 1;
if (mu_cfg_parse_boolean (val->v.string, &res))
if (mu_str_to_c (val->v.string, mu_c_bool, &res, NULL))
mu_diag_output (MU_LOG_ERROR, _("not a boolean"));
else if (res)
biffrc_errors |= flag;
......@@ -150,9 +150,9 @@ cb_biffrc_errors_to_err (void *data, mu_config_value_t *val)
}
struct mu_cfg_param comsat_cfg_param[] = {
{ "allow-biffrc", mu_cfg_bool, &allow_biffrc, 0, NULL,
{ "allow-biffrc", mu_c_bool, &allow_biffrc, 0, NULL,
N_("Read .biffrc file from the user home directory.") },
{ "require-tty", mu_cfg_bool, &require_tty, 0, NULL,
{ "require-tty", mu_c_bool, &require_tty, 0, NULL,
N_("Notify only if the user is logged on one of the ttys.") },
{ "biffrc-errors-to-tty", mu_cfg_callback, NULL, 0, cb_biffrc_errors_to_tty,
N_("Send biffrc errors to user's tty."),
......@@ -160,17 +160,17 @@ struct mu_cfg_param comsat_cfg_param[] = {
{ "biffrc-errors-to-err", mu_cfg_callback, NULL, 0, cb_biffrc_errors_to_err,
N_("Send biffrc errors to Mailutils error output."),
N_("arg: bool") },
{ "max-lines", mu_cfg_int, &maxlines, 0, NULL,
{ "max-lines", mu_c_int, &maxlines, 0, NULL,
N_("Maximum number of message body lines to be output.") },
{ "max-requests", mu_cfg_uint, &maxrequests, 0, NULL,
{ "max-requests", mu_c_uint, &maxrequests, 0, NULL,
N_("Maximum number of incoming requests per request control interval.") },
{ "request-control-interval", mu_cfg_time, &request_control_interval,
{ "request-control-interval", mu_c_time, &request_control_interval,
0, NULL,
N_("Set control interval.") },
{ "overflow-control-interval", mu_cfg_time, &overflow_control_interval,
{ "overflow-control-interval", mu_c_time, &overflow_control_interval,
0, NULL,
N_("Set overflow control interval.") },
{ "overflow-delay-time", mu_cfg_time, &overflow_delay_time,
{ "overflow-delay-time", mu_c_time, &overflow_delay_time,
0, NULL,
N_("Time to sleep after the first overflow occurs.") },
{ ".server", mu_cfg_section, NULL, 0, NULL,
......
......@@ -122,11 +122,11 @@ parse_opt (int key, char *arg, struct argp_state *state)
struct mu_cfg_param dotlock_cfg_param[] = {
{ "force", mu_cfg_time, &force, 0, NULL,
{ "force", mu_c_time, &force, 0, NULL,
N_("Forcibly break an existing lock older than the specified time.") },
{ "retry", mu_cfg_int, &retries, 0, NULL,
{ "retry", mu_c_int, &retries, 0, NULL,
N_("Number of times to retry acquiring the lock.") },
{ "debug", mu_cfg_bool, &debug, 0, NULL,
{ "debug", mu_c_bool, &debug, 0, NULL,
N_("Print details of failure reasons to stderr.") },
{ NULL }
};
......
......@@ -321,7 +321,7 @@ cb_tls_required (void *data, mu_config_value_t *val)
if (mu_cfg_assert_value_type (val, MU_CFG_STRING))
return 1;
if (mu_cfg_parse_boolean (val->v.string, &bv))
if (mu_str_to_c (val->v.string, mu_c_bool, &bv, NULL))
mu_error (_("Not a boolean value"));
else if (bv)
{
......@@ -384,28 +384,28 @@ static struct mu_cfg_param imap4d_srv_param[] = {
};
static struct mu_cfg_param imap4d_cfg_param[] = {
{ "allow-users", MU_CFG_LIST_OF(mu_cfg_string), &auth_allow_user_list,
{ "allow-users", MU_CFG_LIST_OF(mu_c_string), &auth_allow_user_list,
0, NULL,
N_("Allow access to users from this list.") },
{ "deny-users", MU_CFG_LIST_OF(mu_cfg_string), &auth_deny_user_list,
{ "deny-users", MU_CFG_LIST_OF(mu_c_string), &auth_deny_user_list,
0, NULL,
N_("Deny access to users from this list.") },
{ "allow-groups", MU_CFG_LIST_OF(mu_cfg_string), &auth_allow_group_list,
{ "allow-groups", MU_CFG_LIST_OF(mu_c_string), &auth_allow_group_list,
0, NULL,
N_("Allow access if the user group is in this list.") },
{ "deny-groups", MU_CFG_LIST_OF(mu_cfg_string), &auth_deny_group_list,
{ "deny-groups", MU_CFG_LIST_OF(mu_c_string), &auth_deny_group_list,
0, NULL,
N_("Deny access if the user group is in this list.") },
{ "homedir", mu_cfg_string, &modify_homedir, 0, NULL,
{ "homedir", mu_c_string, &modify_homedir, 0, NULL,
N_("Modify home directory.") },
{ "personal-namespace", MU_CFG_LIST_OF(mu_cfg_string), &namespace[NS_PRIVATE],
{ "personal-namespace", MU_CFG_LIST_OF(mu_c_string), &namespace[NS_PRIVATE],
0, NULL,
N_("Set personal namespace.") },
{ "other-namespace", MU_CFG_LIST_OF(mu_cfg_string), &namespace[NS_OTHER],
{ "other-namespace", MU_CFG_LIST_OF(mu_c_string), &namespace[NS_OTHER],
0, NULL,
N_("Set other users' namespace.") },
{ "shared-namespace", MU_CFG_LIST_OF(mu_cfg_string), &namespace[NS_SHARED],
{ "shared-namespace", MU_CFG_LIST_OF(mu_c_string), &namespace[NS_SHARED],
0, NULL,
N_("Set shared namespace.") },
{ "other-mailbox-mode", mu_cfg_callback, &mailbox_mode[NS_OTHER], 0,
......@@ -414,9 +414,9 @@ static struct mu_cfg_param imap4d_cfg_param[] = {
{ "shared-mailbox-mode", mu_cfg_callback, &mailbox_mode[NS_SHARED], 0,
cb_mailbox_mode,
N_("File mode for mailboxes in shared namespace.") },
{ "login-disabled", mu_cfg_bool, &login_disabled, 0, NULL,
{ "login-disabled", mu_c_bool, &login_disabled, 0, NULL,
N_("Disable LOGIN command.") },
{ "create-home-dir", mu_cfg_bool, &create_home_dir, 0, NULL,
{ "create-home-dir", mu_c_bool, &create_home_dir, 0, NULL,
N_("If true, create non-existing user home directories.") },
{ "home-dir-mode", mu_cfg_callback, NULL, 0, cb_mode,
N_("File mode for creating user home directories (octal)."),
......@@ -437,19 +437,19 @@ static struct mu_cfg_param imap4d_cfg_param[] = {
" ident[://:<port: string-or-number>]\n"
" stdio"),
N_("mode") },
{ "preauth-only", mu_cfg_bool, &preauth_only, 0, NULL,
{ "preauth-only", mu_c_bool, &preauth_only, 0, NULL,
N_("Use only preauth mode. If unable to setup it, disconnect "
"immediately.") },
{ "ident-keyfile", mu_cfg_string, &ident_keyfile, 0, NULL,
{ "ident-keyfile", mu_c_string, &ident_keyfile, 0, NULL,
N_("Name of DES keyfile for decoding encrypted ident responses.") },
{ "ident-encrypt-only", mu_cfg_bool, &ident_encrypt_only, 0, NULL,
{ "ident-encrypt-only", mu_c_bool, &ident_encrypt_only, 0, NULL,
N_("Use only encrypted ident responses.") },
{ "id-fields", MU_CFG_LIST_OF(mu_cfg_string), &imap4d_id_list, 0, NULL,
{ "id-fields", MU_CFG_LIST_OF(mu_c_string), &imap4d_id_list, 0, NULL,
N_("List of fields to return in response to ID command.") },
{ "mandatory-locking", mu_cfg_section },
{ ".server", mu_cfg_section, NULL, 0, NULL,
N_("Server configuration.") },
{ "transcript", mu_cfg_bool, &imap4d_transcript, 0, NULL,
{ "transcript", mu_c_bool, &imap4d_transcript, 0, NULL,
N_("Set global transcript mode.") },
TCP_WRAPPERS_CONFIG
{ NULL }
......
......@@ -22,6 +22,7 @@
#include <mailutils/list.h>
#include <mailutils/debug.h>
#include <mailutils/opool.h>
#include <mailutils/util.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
......@@ -113,27 +114,6 @@ void mu_cfg_destroy_tree (mu_cfg_tree_t **tree);
int mu_cfg_preorder (mu_list_t nodelist, struct mu_cfg_iter_closure *);
/* Table-driven parsing */
enum mu_cfg_param_data_type
{
mu_cfg_string,
mu_cfg_short,
mu_cfg_ushort,
mu_cfg_int,
mu_cfg_uint,
mu_cfg_long,
mu_cfg_ulong,
mu_cfg_size,
mu_cfg_off,
mu_cfg_time,
mu_cfg_bool,
mu_cfg_ipv4,
mu_cfg_cidr,
mu_cfg_host,
mu_cfg_callback,
mu_cfg_section
};
#define MU_CFG_LIST_MASK 0x8000
#define MU_CFG_LIST_OF(t) ((t) | MU_CFG_LIST_MASK)
#define MU_CFG_TYPE(t) ((t) & ~MU_CFG_LIST_MASK)
......@@ -141,10 +121,16 @@ enum mu_cfg_param_data_type
typedef int (*mu_cfg_callback_t) (void *, mu_config_value_t *);
enum mu_cfg_param_type
{
mu_cfg_section = mu_c_void + 1,
mu_cfg_callback
};
struct mu_cfg_param
{
const char *ident;
enum mu_cfg_param_data_type type;
int type; /* One of enum mu_c_type or mu_cfg_param_type values */
void *data;
size_t offset;
mu_cfg_callback_t callback;
......@@ -197,14 +183,6 @@ struct mu_cfg_cont
} v;
};
typedef struct mu_cfg_cidr mu_cfg_cidr_t;
struct mu_cfg_cidr
{
struct in_addr addr;
unsigned long mask;
};
#define MU_CFG_PATH_DELIM '.'
#define MU_CFG_PATH_DELIM_STR "."
......@@ -271,8 +249,6 @@ int mu_parse_config (const char *file, const char *progname,
struct mu_cfg_param *progparam, int flags,
void *target_ptr) MU_CFG_DEPRECATED;
int mu_cfg_parse_boolean (const char *str, int *res);
extern int mu_cfg_parser_verbose;
extern size_t mu_cfg_error_count;
......
......@@ -173,10 +173,11 @@ enum mu_c_type
mu_c_host,
mu_c_incr, /* C int value, incremented each time mu_str_to_c is
invoked */
mu_c_void /* No type. Keep it the last */
};
typedef enum mu_c_type mu_c_type_t;
extern char const *mu_c_type_str[];
int mu_str_to_c (char const *string, mu_c_type_t type, void *tgt,
char **errmsg);
......
......@@ -185,9 +185,9 @@ manlock_open_mailbox (mu_mailbox_t *pmbox, const char *mailbox_name, int def,
struct mu_cfg_param manlock_param[] = {
{ "enable", mu_cfg_bool, &manlock_mandatory_locking, 0, NULL,
{ "enable", mu_c_bool, &manlock_mandatory_locking, 0, NULL,
N_("Enable mandatory locking.") },
{ "lock-directory", mu_cfg_string, &manlock_lock_dir, 0, NULL,
{ "lock-directory", mu_c_string, &manlock_lock_dir, 0, NULL,
N_("Set directory for mandatory lock files.") },
{ NULL }
};
......
......@@ -53,17 +53,17 @@ mu_tcpwrapper_access (int fd)
}
struct mu_cfg_param tcpwrapper_param[] = {
{ "enable", mu_cfg_bool, &mu_tcp_wrapper_enable, 0, NULL,
{ "enable", mu_c_bool, &mu_tcp_wrapper_enable, 0, NULL,
N_("Enable TCP wrapper access control. Default is \"yes\".") },
{ "daemon", mu_cfg_string, &mu_tcp_wrapper_daemon, 0, NULL,
{ "daemon", mu_c_string, &mu_tcp_wrapper_daemon, 0, NULL,
N_("Set daemon name for TCP wrapper lookups. Default is program name."),
N_("name") },
{ "allow-table", mu_cfg_string, &hosts_allow_table,
{ "allow-table", mu_c_string, &hosts_allow_table,
0, NULL,
N_("Use file for positive client address access control "
"(default: /etc/hosts.allow)."),
N_("file") },
{ "deny-table", mu_cfg_string, &hosts_deny_table,
{ "deny-table", mu_c_string, &hosts_deny_table,
0, NULL,
N_("Use file for negative client address access control "
"(default: /etc/hosts.deny)."),
......
......@@ -263,35 +263,38 @@ mu_cfg_format_node (mu_stream_t stream, const mu_cfg_node_t *node, int flags)
const char *
mu_cfg_data_type_string (enum mu_cfg_param_data_type type)
mu_c_type_string (int type)
{
switch (type)
{
case mu_cfg_string:
case mu_c_string:
return N_("string");
case mu_cfg_short:
case mu_cfg_ushort:
case mu_cfg_int:
case mu_cfg_uint:
case mu_cfg_long:
case mu_cfg_ulong:
case mu_cfg_size:
case mu_cfg_off:
case mu_c_short:
case mu_c_ushort:
case mu_c_int:
case mu_c_uint:
case mu_c_long:
case mu_c_ulong:
case mu_c_size:
case mu_c_off:
case mu_c_incr:
return N_("number");
case mu_cfg_time:
case mu_c_time:
return N_("time");
case mu_cfg_bool:
case mu_c_bool:
return N_("boolean");
case mu_cfg_ipv4:
case mu_c_ipv4:
return N_("ipv4");
case mu_cfg_cidr:
case mu_c_cidr:
return N_("cidr");
case mu_cfg_host:
case mu_c_host:
return N_("host");
case mu_cfg_callback:
return N_("string");
case mu_cfg_section:
return N_("section");
case mu_cfg_callback:
return N_("callback");
default:
break;
}
return N_("unknown");
}
......@@ -361,13 +364,13 @@ format_param (mu_stream_t stream, struct mu_cfg_param *param, int level)
param->ident,
gettext (param->argname ?
param->argname : N_("arg")),
gettext (mu_cfg_data_type_string (MU_CFG_TYPE (param->type))));
gettext (mu_c_type_string (MU_CFG_TYPE (param->type))));
else
mu_stream_printf (stream, "%s <%s: %s>;\n",
param->ident,
gettext (param->argname ?
param->argname : N_("arg")),
gettext (mu_cfg_data_type_string (param->type)));
gettext (mu_c_type_string (param->type)));
}
static void format_container (mu_stream_t stream, struct mu_cfg_cont *cont,
......
......@@ -890,24 +890,24 @@ _cb_port (void *data, mu_config_value_t *val)
}
static struct mu_cfg_param dot_server_cfg_param[] = {
{ "max-children", mu_cfg_size,
{ "max-children", mu_c_size,
NULL, mu_offsetof (struct _mu_m_server,max_children), NULL,
N_("Maximum number of children processes to run simultaneously.") },
{ "mode", mu_cfg_callback,
NULL, mu_offsetof (struct _mu_m_server,mode), _cb_daemon_mode,
N_("Set daemon mode (either inetd (or interactive) or daemon)."),
N_("mode") },
{ "foreground", mu_cfg_bool,
{ "foreground", mu_c_bool,
NULL, mu_offsetof (struct _mu_m_server, foreground), NULL,
N_("Run in foreground.") },
{ "pidfile", mu_cfg_string,
{ "pidfile", mu_c_string,
NULL, mu_offsetof (struct _mu_m_server,pidfile), NULL,
N_("Store PID of the master process in this file."),
N_("file") },
{ "port", mu_cfg_callback,
NULL, mu_offsetof (struct _mu_m_server, hints), _cb_port,
N_("Default port number.") },
{ "timeout", mu_cfg_time,
{ "timeout", mu_c_time,
NULL, mu_offsetof (struct _mu_m_server,timeout), NULL,
N_("Set idle timeout.") },
{ "server", mu_cfg_section, NULL, 0, NULL,
......@@ -918,13 +918,13 @@ static struct mu_cfg_param dot_server_cfg_param[] = {
};
static struct mu_cfg_param server_cfg_param[] = {
{ "single-process", mu_cfg_bool,
{ "single-process", mu_c_bool,
NULL, mu_offsetof (struct mu_srv_config, single_process), NULL,
N_("Do not spawn sub-process to handle requests in this server.") },
{ "transcript", mu_cfg_bool,
{ "transcript", mu_c_bool,
NULL, mu_offsetof (struct mu_srv_config, transcript), NULL,
N_("Log the session transcript.") },
{ "timeout", mu_cfg_time,
{ "timeout", mu_c_time,
NULL, mu_offsetof (struct mu_srv_config, timeout), NULL,
N_("Set idle timeout.") },
{ "acl", mu_cfg_section,
......
......@@ -179,7 +179,8 @@ to_time_t (void *tgt, char const *string, char **errmsg)
if (rc)
{
mu_asprintf (errmsg, _("invalid time specification near %s"), string);
if (errmsg)
mu_asprintf (errmsg, _("invalid time specification near %s"), string);
return EINVAL;
}
......@@ -262,10 +263,30 @@ static str_to_c_t str_to_c[] = {
[mu_c_incr] = to_incr
};
char const *mu_c_type_str[] = {
[mu_c_string] = "mu_c_string",
[mu_c_short] = "mu_c_short",
[mu_c_ushort] = "mu_c_ushort",
[mu_c_int] = "mu_c_int",
[mu_c_uint] = "mu_c_uint",
[mu_c_long] = "mu_c_long",
[mu_c_ulong] = "mu_c_ulong",
[mu_c_size] = "mu_c_size",
[mu_c_off] = "mu_c_off",
[mu_c_time] = "mu_c_time",
[mu_c_bool] = "mu_c_bool",
[mu_c_ipv4] = "mu_c_ipv4",
[mu_c_cidr] = "mu_c_cidr",
[mu_c_host] = "mu_c_host",
[mu_c_incr] = "mu_c_incr",
[mu_c_void] = "mu_c_void"
};
int
mu_str_to_c (char const *string, enum mu_c_type type, void *tgt, char **errmsg)
{
*errmsg = NULL;
if (errmsg)
*errmsg = NULL;
if ((size_t)type >= sizeof (str_to_c) / sizeof (str_to_c[0]))
return EINVAL;
if (!str_to_c[type])
......
......@@ -26,6 +26,7 @@ scantime
strftime
strin
strout
strtoc
tempfile
url-comp
url-parse
......
......@@ -62,6 +62,7 @@ noinst_PROGRAMS = \
strftime\
strin\
strout\
strtoc\
tempfile\
url-comp\
url-parse\
......@@ -109,6 +110,7 @@ TESTSUITE_AT = \
strerr.at\
strin.at\
strout.at\
strtoc.at\
testsuite.at\
url.at\
url-comp.at\
......
# This file is part of GNU Mailutils. -*- Autotest -*-
# Copyright (C) 2016 Free Software Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at
# your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
AT_SETUP([mu_str_to_c])
AT_CHECK([strtoc])
AT_CLEANUP
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2016 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GNU Mailutils is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
#include <mailutils/mailutils.h>
union value
{
char *v_string;
signed short v_short;
unsigned short v_ushort;
int v_int;
unsigned v_uint;
long v_long;
unsigned long v_ulong;
size_t v_size;
time_t v_time;
struct mu_cidr v_cidr;
};
struct value_handler
{
void (*format) (union value *, FILE *);
int (*compare) (union value *, union value *);
};
static void
v_string_format (union value *val, FILE *fp)
{
char *p;
fputc ('"', fp);
for (p = val->v_string; *p; p++)
{
if (*p == '\\' || *p == '"')
fputc ('\\', fp);
fputc (*p, fp);
}
fputc ('"', fp);
}
static int
v_string_compare (union value *a, union value *b)
{
return strcmp (a->v_string, b->v_string);
}
static void
v_short_format (union value *val, FILE *fp)
{
fprintf (fp, "%hd", val->v_short);
}
static int
v_short_compare (union value *a, union value *b)
{
return a->v_short != b->v_short;
}
static void
v_ushort_format (union value *val, FILE *fp)
{
fprintf (fp, "%hu", val->v_short);
}
static int
v_ushort_compare (union value *a, union value *b)
{
return a->v_ushort != b->v_ushort;
}
static void
v_int_format (union value *val, FILE *fp)
{
fprintf (fp, "%d", val->v_int);
}
static int
v_int_compare (union value *a, union value *b)
{
return a->v_int != b->v_int;
}
static void
v_uint_format (union value *val, FILE *fp)
{
fprintf (fp, "%u", val->v_uint);
}
static int
v_uint_compare (union value *a, union value *b)
{
return a->v_uint != b->v_uint;
}
static void
v_long_format (union value *val, FILE *fp)
{
fprintf (fp, "%ld", val->v_long);
}
static int
v_long_compare (union value *a, union value *b)
{
return a->v_long != b->v_long;
}
static void
v_ulong_format (union value *val, FILE *fp)
{
fprintf (fp, "%lu", val->v_long);
}
static int
v_ulong_compare (union value *a, union value *b)
{
return a->v_ulong != b->v_ulong;
}
static void
v_size_format (union value *val, FILE *fp)
{
size_t v = val->v_size;
char buf[80];
size_t buflen = 80;
char *p = buf + buflen;
*--p = 0;
do
{
int n = v % 10;
*--p = n + '0';
v /= 10;
}
while (v && p > buf);
if (v)
fputs ("[overflow]", fp);
else
fputs (p, fp);
}
static int
v_size_compare (union value *a, union value *b)
{
return a->v_size != b->v_size;
}
static void
v_cidr_format (union value *val, FILE *fp)
{
char *buf;
mu_cidr_format (&val->v_cidr, 0, &buf);
fprintf (fp, "%s", buf);
free (buf);
}
static int
v_cidr_compare (union value *a, union value *b)
{
if (a->v_cidr.family != b->v_cidr.family)
return 1;
if (a->v_cidr.len != b->v_cidr.len)
return 1;
if (memcmp (a->v_cidr.address, b->v_cidr.address, a->v_cidr.len))
return 1;
if (memcmp (a->v_cidr.netmask, b->v_cidr.netmask, a->v_cidr.len))
return 1;
return 0;
}
struct value_handler value_handler[] = {
[mu_c_string] = { v_string_format, v_string_compare },
[mu_c_short] = { v_short_format, v_short_compare },
[mu_c_ushort] = { v_ushort_format, v_ushort_compare },
[mu_c_int] = { v_int_format, v_int_compare },
[mu_c_uint] = { v_uint_format, v_uint_compare },
[mu_c_long] = { v_long_format, v_long_compare },
[mu_c_ulong] = { v_ulong_format, v_ulong_compare },
[mu_c_size] = { v_size_format, v_size_compare },
#if 0
mu_c_time,
#endif
[mu_c_bool] = { v_int_format, v_int_compare },
[mu_c_cidr] = { v_cidr_format, v_cidr_compare },
[mu_c_incr] = { v_int_format, v_int_compare },
};
int
valcmp (mu_c_type_t type, union value *a, union value *b)
{
if ((size_t)type < sizeof (value_handler) / sizeof (value_handler[0])
&& value_handler[type].compare)
return value_handler[type].compare (a, b);
else
{
fprintf (stderr, "unsupported value type: %d\n", type);
abort ();
}
}
void
valprint (FILE *fp, mu_c_type_t type, union value *val)
{
if ((size_t)type < sizeof (value_handler) / sizeof (value_handler[0])
&& value_handler[type].format)
value_handler[type].format (val, fp);
else
{
fprintf (stderr, "unsupported value type: %d\n", type);
abort ();
}
}
struct testdata
{
mu_c_type_t type;
char const *input;
int err;
union value val;
};
struct testdata tests[] = {
{ mu_c_string, "now is the time", 0, { .v_string = "now is the time" } },
{ mu_c_short, "115", 0, { .v_short = 115 } },
{ mu_c_short, "-400", 0, { .v_short = -400 } },
{ mu_c_short, "1a", EINVAL, },
{ mu_c_ushort, "110", 0, { .v_ushort = 110 } },
{ mu_c_ushort, "-110", ERANGE },
{ mu_c_int, "10568", 0, { .v_int = 10568 } },
{ mu_c_int, "-10568", 0, { .v_int = -10568 } },
{ mu_c_uint, "10568", 0, { .v_uint = 10568 } },
{ mu_c_long, "10568", 0, { .v_long = 10568 } },
{ mu_c_long, "-10568", 0, { .v_long = -10568 } },
{ mu_c_ulong, "10568", 0, { .v_ulong = 10568 } },
{ mu_c_bool, "true", 0, { .v_int = 1 } },
{ mu_c_bool, "false", 0, { .v_int = 0 } },
{ mu_c_cidr, "127.0.0.0/8", 0, { .v_cidr = {
.family = 2,
.len = 4,
.address = { 127, 0, 0, 0 },
.netmask = { 255 } } } },
{ mu_c_cidr, "fe80::4a5b:39ff:fe09:97f0/64", 0, { .v_cidr = {
.family = 10,
.len = 16,
.address = { 0xfe, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x4a, 0x5b, 0x39, 0xff, 0xfe, 0x9, 0x97, 0xf0 },
.netmask = { 255, 255, 255, 255, 255, 255, 255, 255,
0, 0, 0, 0, 0, 0, 0, 0 } } } },
{ mu_c_incr, NULL, 0, { .v_int = 1 } },
{ mu_c_void }
};
void
print_test_id (int i, FILE *fp)
{
fprintf (fp, "%d: %s:%s: ", i, mu_c_type_str[tests[i].type],
tests[i].input ? tests[i].input : "NULL");
}
void
usage (int code, FILE *fp, char const *argv0)
{
fprintf (fp, "usage: %s [-v]", argv0);
exit (code);
}
int
main (int argc, char **argv)
{
union value val;
char *errmsg;
int i;
unsigned failures = 0;
int verbose = 0;
for (i = 1; i < argc; i++) {
if (strcmp (argv[i], "-v") == 0)
verbose = 1;
else if (strcmp (argv[i], "-h") == 0)
usage (0, stdout, argv[0]);
else
usage (1, stderr, argv[0]);
}
if (i != argc)
usage (1, stderr, argv[0]);
for (i = 0; tests[i].type != mu_c_void; i++)
{
int rc;
memset (&val, 0, sizeof (val));
rc = mu_str_to_c (tests[i].input, tests[i].type, &val, &errmsg);
if (rc)
{
if (tests[i].err == rc)
{
if (verbose)
{
print_test_id (i, stdout);
fprintf (stdout, "XFAIL\n");
}
}
else
{
print_test_id (i, stderr);
fprintf (stderr, "FAIL: error %s", mu_strerror (rc));
if (errmsg)
fprintf (stderr, ": %s", errmsg);
fputc ('\n', stderr);
free (errmsg);
++failures;
}
}
else if (valcmp (tests[i].type, &tests[i].val, &val))
{
fprintf (stderr, "%d: FAIL: %s value differ: ",
i, mu_c_type_str[tests[i].type]);
fprintf (stderr, "expected: ");
valprint (stderr, tests[i].type, &tests[i].val);
fprintf (stderr, ", but got: ");
valprint (stderr, tests[i].type, &val);
fputc ('\n', stderr);
++failures;
}
else if (verbose)
{
print_test_id (i, stdout);
fprintf (stdout, "OK\n");
}
}
exit (!!failures);
}
......@@ -53,6 +53,9 @@ AT_CLEANUP
AT_INIT
AT_BANNER([Conversions])
m4_include([strtoc.at])
AT_BANNER([Standard streams])
m4_include([strin.at])
m4_include([strout.at])
......
......@@ -138,7 +138,7 @@ mu_app_init (struct argp *myargp, const char **capa,
mu_stream_t stream;
struct mu_cfg_cont *cont;
static struct mu_cfg_param dummy_include_param[] = {
{ "include", mu_cfg_string, NULL, 0, NULL,
{ "include", mu_c_string, NULL, 0, NULL,
N_("Include contents of the given file. If a directory is given, "
"include contents of the file <file>/<program>, where "
"<program> is the name of the program. This latter form is "
......
......@@ -49,14 +49,14 @@ _cb_folder (void *data, mu_config_value_t *val)
}
static struct mu_cfg_param mu_mailbox_param[] = {
{ "mail-spool", mu_cfg_string, &mailbox_settings.mail_spool, 0, NULL,
{ "mail-spool", mu_c_string, &mailbox_settings.mail_spool, 0, NULL,
N_("Use specified URL as a mailspool directory."),
N_("url") },
{ "mailbox-pattern", mu_cfg_string, &mailbox_settings.mailbox_pattern,
{ "mailbox-pattern", mu_c_string, &mailbox_settings.mailbox_pattern,
0, NULL,
N_("Create mailbox URL using <pattern>."),
N_("pattern") },
{ "mailbox-type", mu_cfg_string, &mailbox_settings.mailbox_type, 0, NULL,
{ "mailbox-type", mu_c_string, &mailbox_settings.mailbox_type, 0, NULL,
N_("Default mailbox type."), N_("protocol") },
{ "folder", mu_cfg_callback, NULL, 0, _cb_folder,
N_("Default user mail folder"),
......@@ -73,17 +73,17 @@ DCL_CFG_CAPA (mailbox);
static struct mu_cfg_param mu_locking_param[] = {
/* FIXME: Flags are superfluous. */
{ "flags", mu_cfg_string, &locking_settings.lock_flags, 0, NULL,
{ "flags", mu_c_string, &locking_settings.lock_flags, 0, NULL,
N_("Default locker flags (E=external, R=retry, T=time, P=pid).") },
{ "retry-timeout", mu_cfg_ulong, &locking_settings.lock_retry_timeout,
{ "retry-timeout", mu_c_ulong, &locking_settings.lock_retry_timeout,
0, NULL,
N_("Set timeout for acquiring the lock.") },
{ "retry-count", mu_cfg_ulong, &locking_settings.lock_retry_count, 0, NULL,
{ "retry-count", mu_c_ulong, &locking_settings.lock_retry_count, 0, NULL,
N_("Set the maximum number of times to retry acquiring the lock.") },
{ "expire-timeout", mu_cfg_ulong, &locking_settings.lock_expire_timeout,
{ "expire-timeout", mu_c_ulong, &locking_settings.lock_expire_timeout,
0, NULL,
N_("Expire locks older than this amount of time.") },
{ "external-locker", mu_cfg_string, &locking_settings.external_locker,
{ "external-locker", mu_c_string, &locking_settings.external_locker,
0, NULL,
N_("Use external locker program."),
N_("prog") },
......@@ -98,11 +98,11 @@ DCL_CFG_CAPA (locking);
/* ************************************************************************* */
static struct mu_cfg_param mu_address_param[] = {
{ "email-addr", mu_cfg_string, &address_settings.address, 0, NULL,
{ "email-addr", mu_c_string, &address_settings.address, 0, NULL,
N_("Set the current user email address (default is "
"loginname@defaultdomain)."),
N_("email") },
{ "email-domain", mu_cfg_string, &address_settings.domain, 0, NULL,
{ "email-domain", mu_c_string, &address_settings.domain, 0, NULL,
N_("Set e-mail domain for unqualified user names (default is this host)"),
N_("domain") },
{ NULL }
......@@ -116,7 +116,7 @@ DCL_CFG_CAPA (address);
/* ************************************************************************* */
static struct mu_cfg_param mu_mailer_param[] = {
{ "url", mu_cfg_string, &mailer_settings.mailer, 0, NULL,
{ "url", mu_c_string, &mailer_settings.mailer, 0, NULL,
N_("Use this URL as the default mailer"),
N_("url") },
{ NULL }
......@@ -160,9 +160,9 @@ cb_severity (void *data, mu_config_value_t *val)
}
static struct mu_cfg_param mu_logging_param[] = {
{ "syslog", mu_cfg_bool, &mu_log_syslog, 0, NULL,
{ "syslog", mu_c_bool, &mu_log_syslog, 0, NULL,
N_("Send diagnostics to syslog.") },
{ "print-severity", mu_cfg_bool, &mu_log_print_severity, 0, NULL,
{ "print-severity", mu_c_bool, &mu_log_print_severity, 0, NULL,
N_("Print message severity levels.") },
{ "severity", mu_cfg_callback, NULL, 0, cb_severity,
N_("Output only messages with a severity equal to or greater than "
......@@ -171,9 +171,9 @@ static struct mu_cfg_param mu_logging_param[] = {
N_("Set syslog facility. Arg is one of the following: user, daemon, "
"auth, authpriv, mail, cron, local0 through local7 (case-insensitive), "
"or a facility number.") },
{ "session-id", mu_cfg_bool, &mu_log_session_id, 0, NULL,
{ "session-id", mu_c_bool, &mu_log_session_id, 0, NULL,
N_("Log session ID") },
{ "tag", mu_cfg_string, &mu_log_tag, 0, NULL,
{ "tag", mu_c_string, &mu_log_tag, 0, NULL,
N_("Tag syslog messages with this string.") },
{ NULL }
};
......@@ -204,7 +204,7 @@ static struct mu_cfg_param mu_debug_param[] = {
N_("Set Mailutils debugging level. Argument is a colon-separated list "
"of debugging specifications in the form:\n"
" <object: string>[[:]=<level: number>].") },
{ "line-info", mu_cfg_bool, &debug_settings.line_info, 0, NULL,
{ "line-info", mu_c_bool, &debug_settings.line_info, 0, NULL,
N_("Prefix debug messages with Mailutils source locations.") },
{ NULL }
};
......
......@@ -26,21 +26,21 @@
static struct mu_gsasl_module_data gsasl_settings;
static struct mu_cfg_param mu_gsasl_param[] = {
{ "enable", mu_cfg_bool, &gsasl_settings.enable, 0, NULL,
{ "enable", mu_c_bool, &gsasl_settings.enable, 0, NULL,
N_("Enable GSASL (default)") },
{ "cram-passwd", mu_cfg_string, &gsasl_settings.cram_md5_pwd, 0, NULL,
{ "cram-passwd", mu_c_string, &gsasl_settings.cram_md5_pwd, 0, NULL,
N_("Name of GSASL password file."),
N_("file") },
{ "service", mu_cfg_string, &gsasl_settings.service, 0, NULL,
{ "service", mu_c_string, &gsasl_settings.service, 0, NULL,
N_("SASL service name."),
N_("name") },
{ "realm", mu_cfg_string, &gsasl_settings.realm, 0, NULL,
{ "realm", mu_c_string, &gsasl_settings.realm, 0, NULL,
N_("SASL realm name."),
N_("name") },
{ "hostname", mu_cfg_string, &gsasl_settings.hostname, 0, NULL,
{ "hostname", mu_c_string, &gsasl_settings.hostname, 0, NULL,
N_("SASL host name."),
N_("name") },
{ "anonymous-user", mu_cfg_string, &gsasl_settings.anon_user, 0, NULL,
{ "anonymous-user", mu_c_string, &gsasl_settings.anon_user, 0, NULL,
N_("Anonymous user name."),
N_("name") },
......
......@@ -43,22 +43,22 @@ cb_field_map (void *data, mu_config_value_t *val)
}
static struct mu_cfg_param mu_ldap_param[] = {
{ "enable", mu_cfg_bool, &ldap_settings.enable, 0, NULL,
{ "enable", mu_c_bool, &ldap_settings.enable, 0, NULL,
N_("Enable LDAP lookups.") },
{ "url", mu_cfg_string, &ldap_settings.url, 0, NULL,
{ "url", mu_c_string, &ldap_settings.url, 0, NULL,
N_("Set URL of the LDAP server."),
N_("url") },
{ "base", mu_cfg_string, &ldap_settings.base, 0, NULL,
{ "base", mu_c_string, &ldap_settings.base, 0, NULL,
N_("Base DN for LDAP lookups."),
N_("dn") },
{ "binddn", mu_cfg_string, &ldap_settings.binddn, 0, NULL,
{ "binddn", mu_c_string, &ldap_settings.binddn, 0, NULL,
N_("DN for accessing LDAP database."),
N_("dn") },
{ "passwd", mu_cfg_string, &ldap_settings.passwd, 0, NULL,
{ "passwd", mu_c_string, &ldap_settings.passwd, 0, NULL,
N_("Password for use with binddn.") },
{ "tls", mu_cfg_bool, &ldap_settings.tls, 0, NULL,
{ "tls", mu_c_bool, &ldap_settings.tls, 0, NULL,
N_("Use TLS encryption.") },
{ "debug", mu_cfg_int, &ldap_settings.debug, 0, NULL,
{ "debug", mu_c_int, &ldap_settings.debug, 0, NULL,
N_("Set LDAP debugging level.") },
{ "field-map", mu_cfg_callback, NULL, 0, cb_field_map,
N_("Set a field-map for parsing LDAP replies. The map is a "
......@@ -69,10 +69,10 @@ static struct mu_cfg_param mu_ldap_param[] = {
"gecos, dir, shell, mailbox, quota, and <attr> is the name of "
"the corresponding LDAP attribute."),
N_("map") },
{ "getpwnam", mu_cfg_string, &ldap_settings.getpwnam_filter, 0, NULL,
{ "getpwnam", mu_c_string, &ldap_settings.getpwnam_filter, 0, NULL,
N_("LDAP filter to use for getpwnam requests."),
N_("filter") },
{ "getpwuid", mu_cfg_string, &ldap_settings.getpwuid_filter, 0, NULL,
{ "getpwuid", mu_c_string, &ldap_settings.getpwuid_filter, 0, NULL,
N_("LDAP filter to use for getpwuid requests."),
N_("filter") },
{ NULL }
......
......@@ -25,7 +25,7 @@
static char *pam_settings;
static struct mu_cfg_param mu_pam_param[] = {
{ "service", mu_cfg_string, &pam_settings, 0, NULL,
{ "service", mu_c_string, &pam_settings, 0, NULL,
N_("Set PAM service name."),
N_("name") },
{ NULL }
......
......@@ -26,16 +26,16 @@
static struct mu_radius_module_data radius_settings;
static struct mu_cfg_param mu_radius_param[] = {
{ "auth", mu_cfg_string, &radius_settings.auth_request, 0, NULL,
{ "auth", mu_c_string, &radius_settings.auth_request, 0, NULL,
N_("Radius request for authorization."),
N_("request") },
{ "getpwnam", mu_cfg_string, &radius_settings.getpwnam_request, 0, NULL,
{ "getpwnam", mu_c_string, &radius_settings.getpwnam_request, 0, NULL,
N_("Radius request for getpwnam."),
N_("request") },
{ "getpwuid", mu_cfg_string, &radius_settings.getpwuid_request, 0, NULL,
{ "getpwuid", mu_c_string, &radius_settings.getpwuid_request, 0, NULL,
N_("Radius request for getpwuid."),
N_("request") },
{ "directory", mu_cfg_string, &radius_settings.config_dir, 0, NULL,
{ "directory", mu_c_string, &radius_settings.config_dir, 0, NULL,
N_("Set radius configuration directory.") },
{ NULL }
};
......
......@@ -32,7 +32,7 @@ cb_clear_library_path (void *data, mu_config_value_t *val)
if (mu_cfg_assert_value_type (val, MU_CFG_STRING))
return 1;
if (mu_cfg_parse_boolean (val->v.string, &flag))
if (mu_str_to_c (val->v.string, mu_c_bool, &flag, NULL))
{
mu_error (_("not a boolean"));
return 1;
......@@ -49,7 +49,7 @@ cb_clear_include_path (void *data, mu_config_value_t *val)
if (mu_cfg_assert_value_type (val, MU_CFG_STRING))
return 1;
if (mu_cfg_parse_boolean (val->v.string, &flag))
if (mu_str_to_c (val->v.string, mu_c_bool, &flag, NULL))
{
mu_error (_("not a boolean"));
return 1;
......
......@@ -57,31 +57,31 @@ cb_field_map (void *data, mu_config_value_t *val)
}
static struct mu_cfg_param mu_sql_param[] = {
{ "interface", mu_cfg_string, &sql_settings.interface, 0, NULL,
{ "interface", mu_c_string, &sql_settings.interface, 0, NULL,
N_("Set SQL interface to use (one of: mysql, odbc, or postgres).") },
{ "getpwnam", mu_cfg_string, &sql_settings.getpwnam_query, 0, NULL,
{ "getpwnam", mu_c_string, &sql_settings.getpwnam_query, 0, NULL,
N_("SQL query to use for getpwnam requests."),
N_("query") },
{ "getpwuid", mu_cfg_string, &sql_settings.getpwuid_query, 0, NULL,
{ "getpwuid", mu_c_string, &sql_settings.getpwuid_query, 0, NULL,
N_("SQL query to use for getpwuid requests."),
N_("query") },
{ "getpass", mu_cfg_string, &sql_settings.getpass_query, 0, NULL,
{ "getpass", mu_c_string, &sql_settings.getpass_query, 0, NULL,
N_("SQL query returning the user's password."),
N_("query") },
{ "host", mu_cfg_string, &sql_settings.host, 0, NULL,
{ "host", mu_c_string, &sql_settings.host, 0, NULL,
N_("SQL server host name.") },
{ "user", mu_cfg_string, &sql_settings.user, 0, NULL,
{ "user", mu_c_string, &sql_settings.user, 0, NULL,
N_("SQL user name.") },
{ "passwd", mu_cfg_string, &sql_settings.passwd, 0, NULL,
{ "passwd", mu_c_string, &sql_settings.passwd, 0, NULL,
N_("Password for the SQL user.") },
{ "port", mu_cfg_int, &sql_settings.port, 0, NULL,
{ "port", mu_c_int, &sql_settings.port, 0, NULL,
N_("SQL server port.") },
{ "db", mu_cfg_string, &sql_settings.db, 0, NULL,
{ "db", mu_c_string, &sql_settings.db, 0, NULL,
N_("Database name.") },
{ "password-type", mu_cfg_callback, NULL, 0, cb_password_type,
N_("Type of password returned by getpass query (one of: plain, hash, "
"scrambled).") },
{ "positional", mu_cfg_bool, &sql_settings.positional, 0, NULL,
{ "positional", mu_c_bool, &sql_settings.positional, 0, NULL,
N_("Use positional (v1.0 compatible) field interface.") },
{ "field-map", mu_cfg_callback, NULL, 0, cb_field_map,
N_("Set a field-map for parsing SQL replies. The map is a "
......
......@@ -77,18 +77,18 @@ cb_safety_checks (void *data, mu_config_value_t *arg)
}
static struct mu_cfg_param mu_tls_param[] = {
{ "enable", mu_cfg_bool, &tls_settings.enable, 0, NULL,
{ "enable", mu_c_bool, &tls_settings.enable, 0, NULL,
N_("Enable TLS encryption.") },
{ "ssl-cert", mu_cfg_string, &tls_settings.ssl_cert, 0, NULL,
{ "ssl-cert", mu_c_string, &tls_settings.ssl_cert, 0, NULL,
N_("Specify SSL certificate file."),
N_("file") },
{ "ssl-key", mu_cfg_string, &tls_settings.ssl_key, 0, NULL,
{ "ssl-key", mu_c_string, &tls_settings.ssl_key, 0, NULL,
N_("Specify SSL certificate key file."),
N_("file") },
{ "ssl-cafile", mu_cfg_string, &tls_settings.ssl_cafile, 0, NULL,
{ "ssl-cafile", mu_c_string, &tls_settings.ssl_cafile, 0, NULL,
N_("Specify trusted CAs file."),
N_("file") },
{ "ssl-priorities", mu_cfg_string, &tls_settings.priorities, 0, NULL,
{ "ssl-priorities", mu_c_string, &tls_settings.priorities, 0, NULL,
N_("Set the priorities to use on the ciphers, key exchange methods, "
"macs and compression methods."),
NULL },
......
......@@ -25,7 +25,7 @@
static struct mu_gocs_virtual virtdomain_settings;
static struct mu_cfg_param mu_virtdomain_param[] = {
{ "passwd-dir", mu_cfg_string, &virtdomain_settings, 0, NULL,
{ "passwd-dir", mu_c_string, &virtdomain_settings, 0, NULL,
N_("Name of the directory where virtual domain password files are "
"located."),
N_("dir") },
......
......@@ -284,7 +284,7 @@ cb_stderr (void *data, mu_config_value_t *val)
if (mu_cfg_assert_value_type (val, MU_CFG_STRING))
return 1;
if (mu_cfg_parse_boolean (val->v.string, &res))
if (mu_str_to_c (val->v.string, mu_c_bool, &res, NULL))
mu_error (_("not a boolean"));
else
mu_log_syslog = !res;
......@@ -415,24 +415,24 @@ struct mu_cfg_param maidag_cfg_param[] = {
{ "delivery-mode", mu_cfg_callback, NULL, 0, cb_delivery_mode,
N_("Set delivery mode"),
N_("mode: {mda | url | lmtp}") },
{ "exit-multiple-delivery-success", mu_cfg_bool, &multiple_delivery, 0, NULL,
{ "exit-multiple-delivery-success", mu_c_bool, &multiple_delivery, 0, NULL,
N_("In case of multiple delivery, exit with code 0 if at least one "
"delivery succeeded.") },
{ "exit-quota-tempfail", mu_cfg_bool, &ex_quota_tempfail, 0, NULL,
{ "exit-quota-tempfail", mu_c_bool, &ex_quota_tempfail, 0, NULL,
N_("Indicate temporary failure if the recipient is over his mail quota.")
},
#ifdef ENABLE_DBM
{ "quota-db", mu_cfg_string, &quotadbname, 0, NULL,
{ "quota-db", mu_c_string, &quotadbname, 0, NULL,
N_("Name of DBM quota database file."),
N_("file") },
#endif
#ifdef USE_SQL
{ "quota-query", mu_cfg_string, &quota_query, 0, NULL,
{ "quota-query", mu_c_string, &quota_query, 0, NULL,
N_("SQL query to retrieve mailbox quota. This is deprecated, use "
"sql { ... } instead."),
N_("query") },
#endif
{ "message-id-header", mu_cfg_string, &message_id_header, 0, NULL,
{ "message-id-header", mu_c_string, &message_id_header, 0, NULL,
N_("When logging Sieve actions, identify messages by the value of "
"this header."),
N_("name") },
......@@ -445,12 +445,12 @@ struct mu_cfg_param maidag_cfg_param[] = {
" l - sieve action logs\n") },
{ "stderr", mu_cfg_callback, NULL, 0, cb_stderr,
N_("Log to stderr instead of syslog.") },
{ "forward-file", mu_cfg_string, &forward_file, 0, NULL,
{ "forward-file", mu_c_string, &forward_file, 0, NULL,
N_("Process forward file.") },
{ "forward-file-checks", mu_cfg_callback, NULL, 0, cb_forward_file_checks,
N_("Configure safety checks for the forward file."),
N_("arg: list") },
{ "domain", mu_cfg_string, &default_domain, 0, NULL,
{ "domain", mu_c_string, &default_domain, 0, NULL,
N_("Default email domain") },
/* LMTP support */
{ "group", mu_cfg_callback, &lmtp_groups, 0, cb_group,
......@@ -463,7 +463,7 @@ struct mu_cfg_param maidag_cfg_param[] = {
" file://<socket-file-name>\n"
"or socket://<socket-file-name>"),
N_("url") },
{ "reuse-address", mu_cfg_bool, &reuse_lmtp_address, 0, NULL,
{ "reuse-address", mu_c_bool, &reuse_lmtp_address, 0, NULL,
N_("Reuse existing address (LMTP mode). Default is \"yes\".") },
{ "filter", mu_cfg_section, NULL, 0, NULL,
N_("Add a message filter") },
......
......@@ -164,10 +164,10 @@ struct mu_cfg_param mimeview_cfg_param[] = {
{ "debug", mu_cfg_callback, NULL, 0, cb_debug,
N_("Set debug verbosity level."),
N_("flags") },
{ "mimetypes", mu_cfg_string, &mimetypes_config, 0, NULL,
{ "mimetypes", mu_c_string, &mimetypes_config, 0, NULL,
N_("Use this mime.types file."),
N_("file") },
{ "metamail", mu_cfg_string, &metamail, 0, NULL,
{ "metamail", mu_c_string, &metamail, 0, NULL,
N_("Use this program to display files."),
N_("prog") },
{ NULL }
......
......@@ -371,17 +371,17 @@ cb_onerror (void *data, mu_config_value_t *val)
}
struct mu_cfg_param movemail_cfg_param[] = {
{ "preserve", mu_cfg_bool, &preserve_mail, 0, NULL,
{ "preserve", mu_c_bool, &preserve_mail, 0, NULL,
N_("Do not remove messages from the source mailbox.") },
{ "reverse", mu_cfg_bool, &reverse_order, 0, NULL,
{ "reverse", mu_c_bool, &reverse_order, 0, NULL,
N_("Reverse message sorting order.") },
{ "emacs", mu_cfg_bool, &emacs_mode, 0, NULL,
{ "emacs", mu_c_bool, &emacs_mode, 0, NULL,
N_("Output information used by Emacs rmail interface.") },
{ "uidl", mu_cfg_bool, &uidl_option, 0, NULL,
{ "uidl", mu_c_bool, &uidl_option, 0, NULL,
N_("Use UIDLs to avoid downloading the same message twice.") },
{ "verbose", mu_cfg_int, &verbose_option, 0, NULL,
{ "verbose", mu_c_int, &verbose_option, 0, NULL,
N_("Set verbosity level.") },
{ "program-id", mu_cfg_string, &program_id_option, 0, NULL,
{ "program-id", mu_c_string, &program_id_option, 0, NULL,
N_("Set program identifier string (default: program name)") },
{ "mailbox-ownership", mu_cfg_callback, NULL, 0,
cb_mailbox_ownership,
......@@ -392,10 +392,10 @@ struct mu_cfg_param movemail_cfg_param[] = {
" set-id=UID[:GID] set supplied UID and GID\n"
" set-name=USER make destination mailbox owned by USER"),
N_("methods: list") },
{ "max-messages", mu_cfg_size, &max_messages_option, 0, NULL,
{ "max-messages", mu_c_size, &max_messages_option, 0, NULL,
N_("Copy at most <count> messages."),
N_("count") },
{ "ignore-errors", mu_cfg_bool, &ignore_errors, 0, NULL,
{ "ignore-errors", mu_c_bool, &ignore_errors, 0, NULL,
N_("Continue after an error.") },
{ "onerror", mu_cfg_callback, NULL, 0, cb_onerror,
N_("What to do after an error. Argument is a comma-separated list of:\n"
......
......@@ -182,7 +182,7 @@ cb_tls_required (void *data, mu_config_value_t *val)
if (mu_cfg_assert_value_type (val, MU_CFG_STRING))
return 1;
if (mu_cfg_parse_boolean (val->v.string, &bv))
if (mu_str_to_c (val->v.string, mu_c_bool, &bv, NULL))
mu_error (_("Not a boolean value"));
else if (bv)
{
......@@ -210,16 +210,16 @@ static struct mu_cfg_param pop3d_srv_param[] = {
};
static struct mu_cfg_param pop3d_cfg_param[] = {
{ "undelete", mu_cfg_bool, &undelete_on_startup, 0, NULL,
{ "undelete", mu_c_bool, &undelete_on_startup, 0, NULL,
N_("On startup, clear deletion marks from all the messages.") },
{ "expire", mu_cfg_uint, &expire, 0, NULL,
{ "expire", mu_c_uint, &expire, 0, NULL,
N_("Automatically expire read messages after the given number of days."),
N_("days") },
{ "delete-expired", mu_cfg_bool, &expire_on_exit, 0, NULL,
{ "delete-expired", mu_c_bool, &expire_on_exit, 0, NULL,
N_("Delete expired messages upon closing the mailbox.") },
{ "scan-lines", mu_cfg_bool, &pop3d_xlines, 0, NULL,
{ "scan-lines", mu_c_bool, &pop3d_xlines, 0, NULL,
N_("Output the number of lines in the message in its scan listing.") },
{ "apop-database-file", mu_cfg_string, &apop_database_name, 0, NULL,
{ "apop-database-file", mu_c_string, &apop_database_name, 0, NULL,
N_("set APOP database file name or URL") },
{ "apop-database-owner", mu_cfg_callback, NULL, 0, cb_apop_database_owner,
N_("Name or UID of the APOP database owner") },
......@@ -247,9 +247,9 @@ static struct mu_cfg_param pop3d_cfg_param[] = {
"Deprecated, use \"tls required\" instead.") },
#endif
#ifdef ENABLE_LOGIN_DELAY
{ "login-delay", mu_cfg_time, &login_delay, 0, NULL,
{ "login-delay", mu_c_time, &login_delay, 0, NULL,
N_("Set the minimal allowed delay between two successive logins.") },
{ "stat-file", mu_cfg_string, &login_stat_file, 0, NULL,
{ "stat-file", mu_c_string, &login_stat_file, 0, NULL,
N_("Set the name of login statistics file (for login-delay).") },
#endif
{ "bulletin-source", mu_cfg_callback, NULL, 0, cb_bulletin_source,
......@@ -260,12 +260,12 @@ static struct mu_cfg_param pop3d_cfg_param[] = {
N_("Set the bulletin database file name."),
N_("file") },
#endif
{ "output-buffer-size", mu_cfg_size, &pop3d_output_bufsize, 0, NULL,
{ "output-buffer-size", mu_c_size, &pop3d_output_bufsize, 0, NULL,
N_("Size of the output buffer.") },
{ "mandatory-locking", mu_cfg_section },
{ ".server", mu_cfg_section, NULL, 0, NULL,
N_("Server configuration.") },
{ "transcript", mu_cfg_bool, &pop3d_transcript, 0, NULL,
{ "transcript", mu_c_bool, &pop3d_transcript, 0, NULL,
N_("Set global transcript mode.") },
TCP_WRAPPERS_CONFIG
{ NULL }
......
......@@ -126,21 +126,21 @@ readmsg_parse_opt (int key, char *arg, struct argp_state *astate)
struct mu_cfg_param readmsg_cfg_param[] = {
{ "debug", mu_cfg_int, &dbug, 0, NULL,
{ "debug", mu_c_int, &dbug, 0, NULL,
N_("Set debug verbosity level.") },
{ "header", mu_cfg_bool, &all_header, 0, NULL,
{ "header", mu_c_bool, &all_header, 0, NULL,
N_("Display entire headers.") },
{ "weedlist", mu_cfg_string, &weedlist, 0, NULL,
{ "weedlist", mu_c_string, &weedlist, 0, NULL,
N_("Display only headers from this list. Argument is a list of header "
"names separated by whitespace or commas."),
N_("list") },
{ "folder", mu_cfg_string, &mailbox_name, 0, NULL,
{ "folder", mu_c_string, &mailbox_name, 0, NULL,
N_("Read messages from this folder.") },
{ "no-header", mu_cfg_bool, &no_header, 0, NULL,
{ "no-header", mu_c_bool, &no_header, 0, NULL,
N_("Exclude all headers.") },
{ "form-feeds", mu_cfg_bool, &form_feed, 0, NULL,
{ "form-feeds", mu_c_bool, &form_feed, 0, NULL,
N_("Output formfeed character between messages.") },
{ "show-all-match", mu_cfg_bool, &show_all, 0, NULL,
{ "show-all-match", mu_c_bool, &show_all, 0, NULL,
N_("Print all messages matching pattern, not only the first.") },
{ NULL }
};
......
......@@ -281,12 +281,12 @@ cb_email (void *data, mu_config_value_t *val)
}
static struct mu_cfg_param sieve_cfg_param[] = {
{ "keep-going", mu_cfg_bool, &keep_going, 0, NULL,
{ "keep-going", mu_c_bool, &keep_going, 0, NULL,
N_("Do not abort if execution fails on a message.") },
{ "mbox-url", mu_cfg_string, &mbox_url, 0, NULL,
{ "mbox-url", mu_c_string, &mbox_url, 0, NULL,
N_("Mailbox to sieve (defaults to user's mail spool)."),
N_("url") },
{ "ticket", mu_cfg_string, &mu_ticket_file, 0, NULL,
{ "ticket", mu_c_string, &mu_ticket_file, 0, NULL,
N_("Ticket file for user authentication."),
N_("ticket") },
{ "debug", mu_cfg_callback, NULL, 0, cb_debug,
......@@ -297,9 +297,9 @@ static struct mu_cfg_param sieve_cfg_param[] = {
" P - network protocols (sieve.prot)\n"
" t - sieve trace (MU_SIEVE_DEBUG_TRACE)\n"
" i - sieve instructions trace (MU_SIEVE_DEBUG_INSTR).") },
{ "verbose", mu_cfg_bool, &verbose, 0, NULL,
{ "verbose", mu_c_bool, &verbose, 0, NULL,
N_("Log all executed actions.") },
{ "line-info", mu_cfg_bool, &sieve_print_locus, 0, NULL,
{ "line-info", mu_c_bool, &sieve_print_locus, 0, NULL,
N_("Print source locations along with action logs (default).") },
{ "email", mu_cfg_callback, NULL, 0, cb_email,
N_("Set user email address.") },
......