aboutsummaryrefslogtreecommitdiff
path: root/src/wydawca.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/wydawca.c')
-rw-r--r--src/wydawca.c112
1 files changed, 56 insertions, 56 deletions
diff --git a/src/wydawca.c b/src/wydawca.c
index ce78fc1..cc6c8f0 100644
--- a/src/wydawca.c
+++ b/src/wydawca.c
@@ -32,6 +32,16 @@ char *tar_command_name = "tar";
int archive_signatures = 1; /* Archive sig files by default */
int lint_mode = 0;
int preprocess_only = 0;
+int cron_option = 0;
+int foreground_option = -1;
+int single_process_option = -1;
+
+int daemon_mode = 0;
+int foreground;
+int single_process;
+time_t wakeup_interval;
+
+struct gconf_sockaddr listen_sockaddr;
unsigned wydawca_stat[MAX_STAT];
@@ -106,46 +116,20 @@ logmsg (int prio, char *fmt, ...)
}
-
-enum {
- SYSLOG_OPTION = 256,
- CONFIG_HELP_OPTION,
- DUMP_GRAMMAR_TRACE_OPTION,
- DUMP_LEX_TRACE_OPTION
-};
-
-struct option options[] = {
- { "config-file", required_argument, NULL, 'c' },
- { "config-help", no_argument, NULL, CONFIG_HELP_OPTION },
- { "dump-grammar-trace", no_argument, NULL, DUMP_GRAMMAR_TRACE_OPTION },
- { "dump-lex-trace", no_argument, NULL, DUMP_LEX_TRACE_OPTION },
- { "debug", no_argument, NULL, 'd' },
- { "stderr", no_argument, NULL, 'e' },
- { "syslog", no_argument, NULL, SYSLOG_OPTION },
- { "cron", no_argument, NULL, SYSLOG_OPTION },
- { "help", no_argument, NULL, 'h' },
- { "version", no_argument, NULL, 'v' },
- { "dry-run", no_argument, NULL, 'n' },
- { "lint", no_argument, NULL, 't' },
- { "include-directory", optional_argument, NULL, 'I' },
- { NULL }
-};
-
-
static char *stat_name[MAX_STAT] = {
- "errors",
- "warnings",
- "bad signatures",
- "access violation attempts",
- "complete triplets",
- "incomplete triplets",
- "bad triplets",
- "expired triplets",
- "triplet successes",
- "files uploaded",
- "files archived",
- "symlinks created",
- "symlinks removed",
+ N_("errors"),
+ N_("warnings"),
+ N_("bad signatures"),
+ N_("access violation attempts"),
+ N_("complete triplets"),
+ N_("incomplete triplets"),
+ N_("bad triplets"),
+ N_("expired triplets"),
+ N_("triplet successes"),
+ N_("files uploaded"),
+ N_("files archived"),
+ N_("symlinks created"),
+ N_("symlinks removed"),
};
static char *stat_kwname[MAX_STAT] = {
@@ -212,7 +196,7 @@ logstats ()
{
for (i = 0; i < MAX_STAT; i++)
if (print_stats & STAT_MASK (i))
- logmsg (LOG_INFO, "%s: %u", stat_name[i], wydawca_stat[i]);
+ logmsg (LOG_INFO, "%s: %u", gettext (stat_name[i]), wydawca_stat[i]);
}
mail_stats ();
@@ -244,7 +228,7 @@ gconf_print_diag (gconf_locus_t *locus, int err, int errcode, const char *msg)
static int uidc;
-static char *uidv;
+static uid_t *uidv;
static int
collect_uids (int argc, char **argv)
@@ -272,18 +256,6 @@ collect_uids (int argc, char **argv)
}
}
-int
-match_uid_p (uid_t uid)
-{
- int i;
- if (!uidv)
- return 1;
- for (i = 0; i < uidc; i++)
- if (uidv[i] == uid)
- return 1;
- return 0;
-}
-
int
wydawca_uid (uid_t uid)
@@ -308,6 +280,21 @@ wydawca_uid (uid_t uid)
}
+void
+wydawca_daemon ()
+{
+ check_pidfile ();
+
+ if (!foreground && daemon (0, 0))
+ {
+ logmsg (LOG_ERR, "%s", strerror (errno));
+ exit (1);
+ }
+
+ wydawca_listener ();
+}
+
+
#include "cmdline.h"
int
@@ -333,8 +320,15 @@ main (int argc, char **argv)
if (lint_mode)
exit (0);
+ if (cron_option)
+ daemon_mode = 0;
+ if (foreground_option >= 0)
+ foreground = foreground_option;
+ if (single_process_option >= 0)
+ single_process = single_process_option;
+
if (log_to_stderr == -1)
- log_to_stderr = isatty (0);
+ log_to_stderr = (!daemon_mode || foreground) && isatty (0);
gconf_log_to_stderr = log_to_stderr;
if (!log_to_stderr)
@@ -346,10 +340,16 @@ main (int argc, char **argv)
mail_init ();
logmsg (LOG_NOTICE, _("wydawca (%s) started"), PACKAGE_STRING);
- scan_directories ();
- logmsg (LOG_NOTICE, _("wydawca (%s) finished"), PACKAGE_STRING);
+ if (!daemon_mode)
+ {
+ scan_directories (uidc, uidv);
logstats ();
+ }
+ else
+ wydawca_daemon ();
+
+ logmsg (LOG_NOTICE, _("wydawca (%s) finished"), PACKAGE_STRING);
mail_finish ();

Return to:

Send suggestions and report system problems to the System administrator.