diff options
author | whitespace / reindent <invalid@invalid.invalid> | 2017-07-17 14:03:14 +0200 |
---|---|---|
committer | whitespace / reindent <invalid@invalid.invalid> | 2017-07-17 14:04:07 +0200 |
commit | d62a17aedeb0eebdba98238874bb13d62c48dbf9 (patch) | |
tree | 3b319b1d61c8b85b4d1f06adf8b844bb8a9b5107 /lib/libfrr.c | |
parent | *: add indent control files (diff) | |
download | frr-d62a17aedeb0eebdba98238874bb13d62c48dbf9.tar.xz frr-d62a17aedeb0eebdba98238874bb13d62c48dbf9.zip |
*: reindentreindent-master-after
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'`
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/libfrr.c')
-rw-r--r-- | lib/libfrr.c | 146 |
1 files changed, 65 insertions, 81 deletions
diff --git a/lib/libfrr.c b/lib/libfrr.c index 8d816437c..022296b3f 100644 --- a/lib/libfrr.c +++ b/lib/libfrr.c @@ -30,7 +30,7 @@ #include "log_int.h" #include "module.h" -DEFINE_HOOK(frr_late_init, (struct thread_master *tm), (tm)) +DEFINE_HOOK(frr_late_init, (struct thread_master * tm), (tm)) const char frr_sysconfdir[] = SYSCONFDIR; const char frr_vtydir[] = DAEMON_VTY_DIR; @@ -69,14 +69,13 @@ static void opt_extend(const struct optspec *os) #define OPTION_MODULEDIR 1002 static const struct option lo_always[] = { - { "help", no_argument, NULL, 'h' }, - { "version", no_argument, NULL, 'v' }, - { "daemon", no_argument, NULL, 'd' }, - { "module", no_argument, NULL, 'M' }, - { "vty_socket", required_argument, NULL, OPTION_VTYSOCK }, - { "moduledir", required_argument, NULL, OPTION_MODULEDIR }, - { NULL } -}; + {"help", no_argument, NULL, 'h'}, + {"version", no_argument, NULL, 'v'}, + {"daemon", no_argument, NULL, 'd'}, + {"module", no_argument, NULL, 'M'}, + {"vty_socket", required_argument, NULL, OPTION_VTYSOCK}, + {"moduledir", required_argument, NULL, OPTION_MODULEDIR}, + {NULL}}; static const struct optspec os_always = { "hvdM:", " -h, --help Display this help and exit\n" @@ -85,60 +84,47 @@ static const struct optspec os_always = { " -M, --module Load specified module\n" " --vty_socket Override vty socket path\n" " --moduledir Override modules directory\n", - lo_always -}; + lo_always}; static const struct option lo_cfg_pid_dry[] = { - { "pid_file", required_argument, NULL, 'i' }, - { "config_file", required_argument, NULL, 'f' }, - { "dryrun", no_argument, NULL, 'C' }, - { NULL } -}; + {"pid_file", required_argument, NULL, 'i'}, + {"config_file", required_argument, NULL, 'f'}, + {"dryrun", no_argument, NULL, 'C'}, + {NULL}}; static const struct optspec os_cfg_pid_dry = { "f:i:C", " -f, --config_file Set configuration file name\n" " -i, --pid_file Set process identifier file name\n" " -C, --dryrun Check configuration for validity and exit\n", - lo_cfg_pid_dry -}; + lo_cfg_pid_dry}; static const struct option lo_zclient[] = { - { "socket", required_argument, NULL, 'z' }, - { NULL } -}; + {"socket", required_argument, NULL, 'z'}, + {NULL}}; static const struct optspec os_zclient = { - "z:", - " -z, --socket Set path of zebra socket\n", - lo_zclient -}; + "z:", " -z, --socket Set path of zebra socket\n", lo_zclient}; static const struct option lo_vty[] = { - { "vty_addr", required_argument, NULL, 'A'}, - { "vty_port", required_argument, NULL, 'P'}, - { NULL } -}; + {"vty_addr", required_argument, NULL, 'A'}, + {"vty_port", required_argument, NULL, 'P'}, + {NULL}}; static const struct optspec os_vty = { "A:P:", " -A, --vty_addr Set vty's bind address\n" " -P, --vty_port Set vty's port number\n", - lo_vty -}; + lo_vty}; -static const struct option lo_user[] = { - { "user", required_argument, NULL, 'u'}, - { "group", required_argument, NULL, 'g'}, - { NULL } -}; -static const struct optspec os_user = { - "u:g:", - " -u, --user User to run as\n" - " -g, --group Group to run as\n", - lo_user -}; +static const struct option lo_user[] = {{"user", required_argument, NULL, 'u'}, + {"group", required_argument, NULL, 'g'}, + {NULL}}; +static const struct optspec os_user = {"u:g:", + " -u, --user User to run as\n" + " -g, --group Group to run as\n", + lo_user}; static struct frr_daemon_info *di = NULL; @@ -164,18 +150,18 @@ void frr_preinit(struct frr_daemon_info *daemon, int argc, char **argv) opt_extend(&os_vty); snprintf(config_default, sizeof(config_default), "%s/%s.conf", - frr_sysconfdir, di->name); + frr_sysconfdir, di->name); snprintf(pidfile_default, sizeof(pidfile_default), "%s/%s.pid", - frr_vtydir, di->name); + frr_vtydir, di->name); strlcpy(frr_protoname, di->logname, sizeof(frr_protoname)); strlcpy(frr_protonameinst, di->logname, sizeof(frr_protonameinst)); } void frr_opt_add(const char *optstr, const struct option *longopts, - const char *helpstr) + const char *helpstr) { - const struct optspec main_opts = { optstr, helpstr, longopts }; + const struct optspec main_opts = {optstr, helpstr, longopts}; opt_extend(&main_opts); } @@ -190,11 +176,8 @@ void frr_help_exit(int status) di->printhelp(target); else fprintf(target, "Usage: %s [OPTION...]\n\n%s%s%s\n\n%s", - di->progname, - di->proghelp, - di->copyright ? "\n\n" : "", - di->copyright ? di->copyright : "", - comb_helpstr); + di->progname, di->proghelp, di->copyright ? "\n\n" : "", + di->copyright ? di->copyright : "", comb_helpstr); fprintf(target, "\nReport bugs to %s\n", FRR_BUG_ADDRESS); exit(status); } @@ -256,7 +239,8 @@ static int frr_opt(int opt) if (di->flags & FRR_NO_TCPVTY) return 1; if (vty_addr_set) { - fprintf(stderr, "-A option specified more than once!\n"); + fprintf(stderr, + "-A option specified more than once!\n"); errors++; break; } @@ -267,22 +251,25 @@ static int frr_opt(int opt) if (di->flags & FRR_NO_TCPVTY) return 1; if (vty_port_set) { - fprintf(stderr, "-P option specified more than once!\n"); + fprintf(stderr, + "-P option specified more than once!\n"); errors++; break; } vty_port_set = 1; di->vty_port = strtoul(optarg, &err, 0); if (*err || !*optarg) { - fprintf(stderr, "invalid port number \"%s\" for -P option\n", - optarg); + fprintf(stderr, + "invalid port number \"%s\" for -P option\n", + optarg); errors++; break; } break; case OPTION_VTYSOCK: if (di->vty_sock_path) { - fprintf(stderr, "--vty_socket option specified more than once!\n"); + fprintf(stderr, + "--vty_socket option specified more than once!\n"); errors++; break; } @@ -290,7 +277,8 @@ static int frr_opt(int opt) break; case OPTION_MODULEDIR: if (di->module_path) { - fprintf(stderr, "----moduledir option specified more than once!\n"); + fprintf(stderr, + "----moduledir option specified more than once!\n"); errors++; break; } @@ -312,7 +300,7 @@ static int frr_opt(int opt) return 0; } -int frr_getopt(int argc, char * const argv[], int *longindex) +int frr_getopt(int argc, char *const argv[], int *longindex) { int opt; int lidx; @@ -344,13 +332,13 @@ struct thread_master *frr_init(void) srandom(time(NULL)); if (di->instance) - snprintf(frr_protonameinst, sizeof(frr_protonameinst), - "%s[%u]", di->logname, di->instance); + snprintf(frr_protonameinst, sizeof(frr_protonameinst), "%s[%u]", + di->logname, di->instance); - openzlog (di->progname, di->logname, di->instance, - LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON); + openzlog(di->progname, di->logname, di->instance, + LOG_CONS | LOG_NDELAY | LOG_PID, LOG_DAEMON); #if defined(HAVE_CUMULUS) - zlog_set_level (ZLOG_DEST_SYSLOG, zlog_default->default_lvl); + zlog_set_level(ZLOG_DEST_SYSLOG, zlog_default->default_lvl); #endif frrmod_init(di->module); @@ -384,10 +372,11 @@ void frr_config_fork(void) hook_call(frr_late_init, master); if (di->instance) { - snprintf(config_default, sizeof(config_default), "%s/%s-%d.conf", - frr_sysconfdir, di->name, di->instance); - snprintf(pidfile_default, sizeof(pidfile_default), "%s/%s-%d.pid", - frr_vtydir, di->name, di->instance); + snprintf(config_default, sizeof(config_default), + "%s/%s-%d.conf", frr_sysconfdir, di->name, + di->instance); + snprintf(pidfile_default, sizeof(pidfile_default), + "%s/%s-%d.pid", frr_vtydir, di->name, di->instance); } vty_read_config(di->config_file, config_default); @@ -397,19 +386,19 @@ void frr_config_fork(void) exit(0); /* Daemonize. */ - if (di->daemon_mode && daemon (0, 0) < 0) { + if (di->daemon_mode && daemon(0, 0) < 0) { zlog_err("Zebra daemon failed: %s", strerror(errno)); exit(1); } if (!di->pid_file) di->pid_file = pidfile_default; - pid_output (di->pid_file); + pid_output(di->pid_file); } void frr_vty_serv(void) { - /* allow explicit override of vty_path in the future + /* allow explicit override of vty_path in the future * (not currently set anywhere) */ if (!di->vty_path) { const char *dir; @@ -417,11 +406,10 @@ void frr_vty_serv(void) if (di->instance) snprintf(vtypath_default, sizeof(vtypath_default), - "%s/%s-%d.vty", - dir, di->name, di->instance); + "%s/%s-%d.vty", dir, di->name, di->instance); else snprintf(vtypath_default, sizeof(vtypath_default), - "%s/%s.vty", dir, di->name); + "%s/%s.vty", dir, di->name); di->vty_path = vtypath_default; } @@ -437,14 +425,10 @@ void frr_run(struct thread_master *master) if (di->instance) snprintf(instanceinfo, sizeof(instanceinfo), "instance %u ", - di->instance); - - zlog_notice("%s %s starting: %svty@%d%s", - di->name, - FRR_VERSION, - instanceinfo, - di->vty_port, - di->startinfo); + di->instance); + + zlog_notice("%s %s starting: %svty@%d%s", di->name, FRR_VERSION, + instanceinfo, di->vty_port, di->startinfo); struct thread thread; while (thread_fetch(master, &thread)) |