summaryrefslogtreecommitdiffabout
path: root/src/main.c
authorSergey Poznyakoff <gray@gnu.org.ua>2007-05-13 15:21:02 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2007-05-13 15:21:02 (GMT)
commit113cb4b143f63e18f2cbab9f0abec0ef453fbbd8 (patch) (side-by-side diff)
tree8d8ccc1d6196e5570953033cbed3189a8111196a /src/main.c
parent06aae065b5b5ccf3ae1e4350f97d0ed0a2658501 (diff)
downloadmailfromd-113cb4b143f63e18f2cbab9f0abec0ef453fbbd8.tar.gz
mailfromd-113cb4b143f63e18f2cbab9f0abec0ef453fbbd8.tar.bz2
Mailfromd goes international
git-svn-id: file:///svnroot/mailfromd/trunk@1428 7a8a7f39-df28-0410-adc6-e0d955640f24
Diffstat (limited to 'src/main.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/main.c106
1 files changed, 57 insertions, 49 deletions
diff --git a/src/main.c b/src/main.c
index 86d3038..4572bda 100644
--- a/src/main.c
+++ b/src/main.c
@@ -246,7 +246,7 @@ read_domain_file(char *name)
fp = fopen(name, "r");
if (!fp) {
- mu_error("Cannot open file `%s': %s",
+ mu_error(_("Cannot open file `%s': %s"),
name, mu_strerror(errno));
return;
}
@@ -381,7 +381,7 @@ option_mailfrom(char *opt, void **pval, char *newval)
rc = mu_address_create(&addr, newval);
if (rc) {
- mu_error("Cannot create address `%s': %s",
+ mu_error(_("Cannot create address `%s': %s"),
newval, mu_strerror(rc));
return 1;
}
@@ -401,7 +401,7 @@ set_mailfrom(void *value)
rc = mu_address_create(&addr, value);
if (rc) {
- mu_error("Cannot create address `%s': %s",
+ mu_error(_("Cannot create address `%s': %s"),
value, mu_strerror(rc));
return;
}
@@ -464,7 +464,7 @@ set_milter_timeout(void *value)
time_t to = *(time_t*) value;
free(value);
if (smfi_settimeout(to) == MI_FAILURE) {
- mu_error("Invalid milter timeout: %lu", (unsigned long) to);
+ mu_error(_("Invalid milter timeout: %lu"), (unsigned long) to);
exit(EX_USAGE);
}
}
@@ -607,7 +607,7 @@ option_time(char *opt, void **pval, char *newval)
time_t interval;
const char *endp;
if (parse_time_interval(newval, &interval, &endp)) {
- mu_error("%s: unrecognized time format (near `%s')",
+ mu_error(_("%s: unrecognized time format (near `%s')"),
opt, endp);
return 1;
}
@@ -621,7 +621,7 @@ static int
option_pidfile(char *opt, void **pval, char *newval)
{
if (newval[0] != '/') {
- mu_error("Invalid pidfile name: must be absolute");
+ mu_error(_("Invalid pidfile name: must be absolute"));
return 1;
}
return option_string(opt, pval, newval);
@@ -643,7 +643,7 @@ option_source(char *opt, void **pval, char *newval)
if (address == INADDR_NONE) {
struct hostent *phe = gethostbyname (newval);
if (!phe) {
- mu_error("Cannot resolve `%s'", newval);
+ mu_error(_("Cannot resolve `%s'"), newval);
return 1;
}
address = *(((unsigned long **) phe->h_addr_list)[0]);
@@ -672,7 +672,7 @@ option_group(char *opt, void **pval, char *newval)
if (!retain_groups) {
int rc = mu_list_create(&retain_groups);
if (rc) {
- mu_error("Cannot create list: %s",
+ mu_error(_("Cannot create list: %s"),
mu_strerror(rc));
return 1;
}
@@ -680,7 +680,7 @@ option_group(char *opt, void **pval, char *newval)
}
mu_list_append(retain_groups, (void*)group->gr_gid);
} else {
- mu_error("Unknown group: %s", newval);
+ mu_error(_("Unknown group: %s"), newval);
return 1;
}
return 0;
@@ -697,17 +697,17 @@ option_state_directory(char *opt, void **pval, char *newval)
{
struct stat st;
if (stat(newval, &st)) {
- mu_error("cannot stat file `%s': %s",
+ mu_error(_("Cannot stat file `%s': %s"),
newval,
mu_strerror(errno));
return 1;
}
if (!S_ISDIR(st.st_mode)) {
- mu_error("`%s' is not a directory", newval);
+ mu_error(_("`%s' is not a directory"), newval);
return 1;
}
if (newval[0] != '/') {
- mu_error("state directory `%s' is not an absolute file name",
+ mu_error(_("State directory `%s' is not an absolute file name"),
newval);
return 1;
}
@@ -790,7 +790,7 @@ process_options()
/* Command line parsing */
const char *program_version = "mailfromd (" PACKAGE_STRING ")";
-static char doc[] = N_("mailfromd -- MAIL FROM milter checker");
+static char doc[] = N_("mailfromd -- a general purpose milter daemon");
static char args_doc[] = "[var=value...][SCRIPT]";
enum mailfromd_option {
@@ -839,12 +839,12 @@ static struct argp_option options[] = {
{ "delete", OPTION_DELETE, NULL, 0,
N_("Delete given entries from the database"), GRP+1 },
{ "list", OPTION_LIST, NULL, 0,
- N_("List cache (default) or rates database"), GRP+1 },
+ N_("List given database (default cache)"), GRP+1 },
{ "expire", OPTION_EXPIRE, NULL, 0,
- N_("Delete expired entries from the cache"), GRP+1 },
+ N_("Delete expired entries from the database"), GRP+1 },
{ "compact", OPTION_COMPACT, NULL, 0,
N_("Compact the database"), GRP+1 },
- { "test", 't', N_("state"), OPTION_ARG_OPTIONAL,
+ { "test", 't', N_("HANDLER"), OPTION_ARG_OPTIONAL,
N_("Run in test mode"), GRP+1 },
{ "lint", OPTION_LINT, NULL, 0,
N_("Check syntax and exit"), GRP+1 },
@@ -875,14 +875,14 @@ static struct argp_option options[] = {
{ "ignore-failed-reads", OPTION_IGNORE_FAILED_READS, NULL, 0,
N_("Ignore failed reads while compacting the database"), GRP+1 },
{ "predict", OPTION_PREDICT_NEXT, N_("RATE"), 0,
- N_("Predict when the user will be able to "
- "send next message (use with --list --format=rate)"), GRP+1 },
+ N_("Predict when the user will be able to send next message"),
+ GRP+1 },
{ "lock-retry-count", OPTION_LOCK_RETRY_COUNT, N_("NUMBER"), 0,
N_("Set maximum number of attempts to acquire the lock"), GRP+1 },
{ "lock-retry-timeout", OPTION_LOCK_RETRY_TIMEOUT, N_("TIME"), 0,
N_("Set timeout for acquiring the lockfile"), GRP+1 },
{ "expire-interval", 'e', N_("NUMBER"), 0,
- N_("Set cache expiration interval to NUMBER seconds"), GRP+1 },
+ N_("Set database expiration interval to NUMBER seconds"), GRP+1 },
{ "all", OPTION_ALL, NULL, 0,
N_("With --compact or --expire: apply the operation to all "
"available databases"), GRP+1 },
@@ -898,7 +898,7 @@ static struct argp_option options[] = {
{ "config-file", OPTION_CONFIG_FILE, N_("FILE"), OPTION_HIDDEN,
N_("Read configuration from FILE"), GRP+1 },
{ "include", 'I', N_("DIR"), 0,
- N_("Add the directory dir to the list of directories to be "
+ N_("Add the directory DIR to the list of directories to be "
"searched for header files"), GRP+1 },
{ "port", 'p', N_("STRING"), 0,
N_("Set communication socket"), GRP+1 },
@@ -925,18 +925,18 @@ static struct argp_option options[] = {
N_("Set code optimization level"), GRP+1 },
{ "variable", 'v', N_("VAR=VALUE"), 0,
N_("Assign VALUE to VAR"), GRP+1 },
+ { "relayed-domain-file", OPTION_DOMAIN_FILE, N_("FILE"), 0,
+ N_("Read relayed domains from FILE"), GRP+1 },
#undef GRP
#undef GRP
#define GRP 30
{ NULL, 0, NULL, 0,
N_("Timeout control"), GRP },
- { "milter-timeout", OPTION_MILTER_TIMEOUT, N_("NUMBER"), 0,
+ { "milter-timeout", OPTION_MILTER_TIMEOUT, N_("TIME"), 0,
N_("Set MTA connection timeout"), GRP+1 },
- { "timeout", OPTION_TIMEOUT, N_("NUMBER"), 0,
- N_("Set I/O operation timeout (seconds)"), GRP+1 },
- { "relayed-domain-file", OPTION_DOMAIN_FILE, N_("FILE"), 0,
- N_("Read relayed domains from FILE"), GRP+1 },
+ { "timeout", OPTION_TIMEOUT, N_("TIME"), 0,
+ N_("Set I/O operation timeout"), GRP+1 },
#undef GRP
#define GRP 40
@@ -1000,11 +1000,11 @@ validate_options()
{
if (all_option &&
!(mode == MAILFROMD_COMPACT || mode == MAILFROMD_EXPIRE)) {
- mu_error("--all is meaningful only with --expire or --compact option");
+ mu_error(_("--all is meaningful only with --expire or --compact option"));
return 1;
}
if (all_option && format_option)
- mu_error("--format is incompatible with --all");
+ mu_error(_("--format is incompatible with --all"));
return 0;
}
@@ -1044,6 +1044,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
break;
case OPTION_CONFIG_FILE:
+ /*DEPRECATION*/
mu_error("Warning: --config-file is obsolete; give the filter script name as an argument");
script_file = arg;
break;
@@ -1328,7 +1329,7 @@ switch_to_privs(uid_t uid, gid_t gid)
mu_iterator_t itr;
if (uid == 0) {
- mu_error("Refusing to run as root");
+ mu_error(_("Refusing to run as root"));
return 1;
}
@@ -1347,7 +1348,7 @@ switch_to_privs(uid_t uid, gid_t gid)
/* Reset group permissions */
if (geteuid() == 0 && setgroups(j, emptygidset)) {
- mu_error("setgroups(1, %lu) failed: %s",
+ mu_error(_("setgroups(1, %lu) failed: %s"),
(unsigned long) emptygidset[0],
mu_strerror(errno));
rc = 1;
@@ -1359,16 +1360,16 @@ switch_to_privs(uid_t uid, gid_t gid)
#if defined(HAVE_SETEGID)
if ((rc = setegid(gid)) < 0)
- mu_error("setegid(%lu) failed: %s",
+ mu_error(_("setegid(%lu) failed: %s"),
(unsigned long) gid, mu_strerror(errno));
#elif defined(HAVE_SETREGID)
if ((rc = setregid(gid, gid)) < 0)
- mu_error("setregid(%lu,%lu) failed: %s",
+ mu_error(_("setregid(%lu,%lu) failed: %s"),
(unsigned long) gid, (unsigned long) gid,
mu_strerror(errno));
#elif defined(HAVE_SETRESGID)
if ((rc = setresgid(gid, gid, gid)) < 0)
- mu_error("setresgid(%lu,%lu,%lu) failed: %s",
+ mu_error(_("setresgid(%lu,%lu,%lu) failed: %s"),
(unsigned long) gid,
(unsigned long) gid,
(unsigned long) gid,
@@ -1377,10 +1378,10 @@ switch_to_privs(uid_t uid, gid_t gid)
if (rc == 0 && gid != 0) {
if ((rc = setgid(gid)) < 0 && getegid() != gid)
- mu_error("setgid(%lu) failed: %s",
+ mu_error(_("setgid(%lu) failed: %s"),
(unsigned long) gid, mu_strerror(errno));
if (rc == 0 && getegid() != gid) {
- mu_error("Cannot set effective gid to %lu",
+ mu_error(_("Cannot set effective gid to %lu"),
(unsigned long) gid);
rc = 1;
}
@@ -1398,13 +1399,13 @@ switch_to_privs(uid_t uid, gid_t gid)
#if defined(HAVE_SETREUID)
if (geteuid() != uid) {
if (setreuid(uid, -1) < 0) {
- mu_error("setreuid(%lu,-1) failed",
+ mu_error(_("setreuid(%lu,-1) failed"),
(unsigned long) uid,
mu_strerror(errno));
rc = 1;
}
if (setuid(uid) < 0) {
- mu_error("second setuid(%lu) failed",
+ mu_error(_("second setuid(%lu) failed"),
(unsigned long) uid,
mu_strerror(errno));
rc = 1;
@@ -1412,7 +1413,7 @@ switch_to_privs(uid_t uid, gid_t gid)
} else
#endif
{
- mu_error("setuid(%lu) failed",
+ mu_error(_("setuid(%lu) failed"),
(unsigned long) uid,
mu_strerror(errno));
rc = 1;
@@ -1421,10 +1422,10 @@ switch_to_privs(uid_t uid, gid_t gid)
euid = geteuid();
if (uid != 0 && setuid(0) == 0) {
- mu_error("seteuid(0) succeeded when it should not");
+ mu_error(_("seteuid(0) succeeded when it should not"));
rc = 1;
} else if (uid != euid && setuid(euid) == 0) {
- mu_error("Cannot drop non-root setuid privileges");
+ mu_error(_("Cannot drop non-root setuid privileges"));
rc = 1;
}
@@ -1438,12 +1439,12 @@ priv_setup()
{
if (getuid() == 0) {
if (!user) {
- mu_error("When running as root, --user option is mandatory.");
+ mu_error(_("When running as root, --user option is mandatory."));
exit(EX_USAGE);
} else {
struct passwd *pw = getpwnam(user);
if (!pw) {
- mu_error("No such user: %s", user);
+ mu_error(_("No such user: %s"), user);
exit(EX_SOFTWARE);
}
if (pw && switch_to_privs(pw->pw_uid, pw->pw_gid))
@@ -1456,7 +1457,7 @@ void
assert_db_format()
{
if (!format_option) {
- mu_error("Operation is not applicable");
+ mu_error(_("Operation is not applicable"));
exit(EX_USAGE);
}
}
@@ -1469,7 +1470,7 @@ get_db_name()
return file_option;
if (format_option->dbname)
return format_option->dbname;
- mu_error("Database file name is not given");
+ mu_error(_("Database file name is not given"));
exit(EX_USAGE);
}
@@ -1571,7 +1572,7 @@ mailfromd_list(int argc, char **argv)
if (!format_option->print_item) {
/* Should not happen */
- mu_error("List is not applicable to this DB format");
+ mu_error(_("List is not applicable to this DB format"));
exit(EX_USAGE);
}
@@ -1605,7 +1606,7 @@ mailfromd_expire()
db_format_enumerate(db_proc_enumerator, db_expire);
else {
if (!format_option->expire) {
- mu_error("Expire is not applicable to this DB format");
+ mu_error(_("Expire is not applicable to this DB format"));
exit(EX_USAGE);
}
exit(db_expire(get_db_name(), format_option->expire) != 0);
@@ -1620,7 +1621,7 @@ mailfromd_compact()
db_format_enumerate(db_proc_enumerator, db_compact);
else {
if (!format_option->expire) {
- mu_error("Compact is not applicable to this DB format");
+ mu_error(_("Compact is not applicable to this DB format"));
exit(EX_USAGE);
}
exit(db_compact(get_db_name(), format_option->expire) != 0);
@@ -1711,6 +1712,13 @@ main(int argc, char **argv)
{
int index;
+#ifdef ENABLE_NLS
+ mu_init_nls();
+ setlocale (LC_ALL, "");
+ bindtextdomain (PACKAGE, LOCALEDIR);
+ textdomain (PACKAGE);
+#endif
+
MU_AUTH_REGISTER_ALL_MODULES();
mu_register_all_mailer_formats();
if (!program_invocation_short_name)
@@ -1743,9 +1751,9 @@ main(int argc, char **argv)
if (n == -1)
n = i;
else {
- mu_error("Script file "
+ mu_error(_("Script file "
"specified twice "
- "(%s and %s)",
+ "(%s and %s)"),
argv[n], argv[i]);
exit(EX_USAGE);
}
@@ -1799,7 +1807,7 @@ main(int argc, char **argv)
case MAILFROMD_DAEMON:
if (argc > 0) {
- mu_error("Too many arguments");
+ mu_error(_("Too many arguments"));
exit(EX_USAGE);
}
mailfromd_daemon();

Return to:

Send suggestions and report system problems to the System administrator.