summaryrefslogtreecommitdiffstats
path: root/sysdep/unix/main.c
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2010-04-07 11:00:36 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2010-04-07 15:34:45 +0200
commit44d4ab7a960cf143c43d1645f2985cc9d74e3077 (patch)
tree6fb7e65191951bce4d92c7b93d3a76dcf1fd9b6d /sysdep/unix/main.c
parentb8113a5e92cb19a0910041d5708f4eafeb713b54 (diff)
downloadbird-44d4ab7a960cf143c43d1645f2985cc9d74e3077.tar
bird-44d4ab7a960cf143c43d1645f2985cc9d74e3077.zip
Configurable syslog name.
Also fixes a bug in syslog initialization.
Diffstat (limited to 'sysdep/unix/main.c')
-rw-r--r--sysdep/unix/main.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/sysdep/unix/main.c b/sysdep/unix/main.c
index e0e0d63..732c916 100644
--- a/sysdep/unix/main.c
+++ b/sysdep/unix/main.c
@@ -83,7 +83,7 @@ sysdep_preconfig(struct config *c)
int
sysdep_commit(struct config *new, struct config *old UNUSED)
{
- log_switch(debug_flag, &new->logfiles);
+ log_switch(debug_flag, &new->logfiles, new->syslog_name);
return 0;
}
@@ -378,21 +378,36 @@ signal_init(void)
*/
static char *opt_list = "c:dD:ps:";
+static int parse_and_exit;
+char *bird_name;
static void
usage(void)
{
- fprintf(stderr, "Usage: bird [-c <config-file>] [-d] [-D <debug-file>] [-p] [-s <control-socket>]\n");
+ fprintf(stderr, "Usage: %s [-c <config-file>] [-d] [-D <debug-file>] [-p] [-s <control-socket>]\n", bird_name);
exit(1);
}
-int parse_and_exit;
+static inline char *
+get_bird_name(char *s, char *def)
+{
+ char *t;
+ if (!s)
+ return def;
+ t = strrchr(s, '/');
+ if (!t)
+ return s;
+ if (!t[1])
+ return def;
+ return t+1;
+}
static void
parse_args(int argc, char **argv)
{
int c;
+ bird_name = get_bird_name(argv[0], "bird");
if (argc == 2)
{
if (!strcmp(argv[1], "--version"))
@@ -444,7 +459,7 @@ main(int argc, char **argv)
parse_args(argc, argv);
if (debug_flag == 1)
log_init_debug("");
- log_init(debug_flag, 1);
+ log_switch(debug_flag, NULL, NULL);
if (!parse_and_exit)
test_old_bird(path_control_socket);