mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 09:41:54 +00:00
Displaced bird_name to log.c where it rightfully belongs
This commit is contained in:
parent
bb183c9d0c
commit
e70207b281
@ -201,6 +201,9 @@ void log_rl(struct tbf *rl, const char *msg, ...);
|
||||
void die(const char *msg, ...) NORET;
|
||||
void bug(const char *msg, ...) NORET;
|
||||
|
||||
void set_daemon_name(char *path, char *def);
|
||||
|
||||
|
||||
#define L_DEBUG "\001" /* Debugging messages */
|
||||
#define L_TRACE "\002" /* Protocol tracing */
|
||||
#define L_INFO "\003" /* Informational messages */
|
||||
|
@ -36,6 +36,7 @@ static pool *log_pool;
|
||||
|
||||
static struct rfile *dbg_rf;
|
||||
static char *current_syslog_name = NULL; /* NULL -> syslog closed */
|
||||
const char *bird_name = NULL;
|
||||
|
||||
_Atomic uint max_thread_id = 1;
|
||||
_Thread_local uint this_thread_id;
|
||||
@ -826,6 +827,7 @@ resolve_fail:
|
||||
void
|
||||
log_init_debug(char *f)
|
||||
{
|
||||
ASSERT_DIE(bird_name);
|
||||
clock_gettime(CLOCK_MONOTONIC, &dbg_time_start);
|
||||
|
||||
if (dbg_rf && dbg_rf != &rf_stderr)
|
||||
@ -842,3 +844,26 @@ log_init_debug(char *f)
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Setting BIRD name
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void set_daemon_name(char *path, char *def)
|
||||
{
|
||||
bird_name = get_bird_name(path, def);
|
||||
}
|
||||
|
@ -709,7 +709,6 @@ signal_init(void)
|
||||
|
||||
static char *opt_list = "bc:dD:ps:P:u:g:flRh";
|
||||
int parse_and_exit;
|
||||
char *bird_name;
|
||||
static char *use_user;
|
||||
static char *use_group;
|
||||
static int run_in_foreground = 0;
|
||||
@ -754,20 +753,6 @@ display_version(void)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
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 inline uid_t
|
||||
get_uid(const char *s)
|
||||
{
|
||||
@ -821,7 +806,8 @@ parse_args(int argc, char **argv)
|
||||
int socket_changed = 0;
|
||||
int c;
|
||||
|
||||
bird_name = get_bird_name(argv[0], "bird");
|
||||
set_daemon_name(argv[0], "bird");
|
||||
|
||||
if (argc == 2)
|
||||
{
|
||||
if (!strcmp(argv[1], "--version"))
|
||||
|
@ -24,7 +24,7 @@ struct config;
|
||||
|
||||
/* main.c */
|
||||
|
||||
extern char *bird_name;
|
||||
extern const char *bird_name;
|
||||
extern int parse_and_exit;
|
||||
void async_config(void);
|
||||
void async_dump(void);
|
||||
|
@ -76,6 +76,8 @@ bt_init(int argc, char *argv[])
|
||||
bt_test_id = NULL;
|
||||
is_terminal = isatty(fileno(stdout));
|
||||
|
||||
set_daemon_name(argv[0], "birdtest");
|
||||
|
||||
while ((c = getopt(argc, argv, "lcdftv")) >= 0)
|
||||
switch (c)
|
||||
{
|
||||
@ -539,7 +541,6 @@ bt_is_char(byte c)
|
||||
*/
|
||||
|
||||
int parse_and_exit;
|
||||
char *bird_name;
|
||||
void async_config(void) {}
|
||||
void async_dump(void) {}
|
||||
void async_shutdown(void) {}
|
||||
|
Loading…
Reference in New Issue
Block a user