static int load_authorities(vici_conn_t *conn) { command_format_options_t format = COMMAND_FORMAT_NONE; settings_t *cfg; char *arg, *file = NULL; int ret; while (TRUE) { switch (command_getopt(&arg)) { case 'h': return command_usage(NULL); case 'P': format |= COMMAND_FORMAT_PRETTY; /* fall through to raw */ case 'r': format |= COMMAND_FORMAT_RAW; continue; case 'f': file = arg; continue; case EOF: break; default: return command_usage("invalid --load-authorities option"); } break; } cfg = load_swanctl_conf(file); if (!cfg) { return EINVAL; } ret = load_authorities_cfg(conn, format, cfg); cfg->destroy(cfg); return ret; }
static int load_authorities(vici_conn_t *conn) { command_format_options_t format = COMMAND_FORMAT_NONE; settings_t *cfg; char *arg; int ret; while (TRUE) { switch (command_getopt(&arg)) { case 'h': return command_usage(NULL); case 'P': format |= COMMAND_FORMAT_PRETTY; /* fall through to raw */ case 'r': format |= COMMAND_FORMAT_RAW; continue; case EOF: break; default: return command_usage("invalid --load-authorities option"); } break; } cfg = settings_create(SWANCTL_CONF); if (!cfg) { fprintf(stderr, "parsing '%s' failed\n", SWANCTL_CONF); return EINVAL; } ret = load_authorities_cfg(conn, format, cfg); cfg->destroy(cfg); return ret; }
static int load_all(vici_conn_t *conn) { bool clear = FALSE, noprompt = FALSE; command_format_options_t format = COMMAND_FORMAT_NONE; settings_t *cfg; char *arg, *file = SWANCTL_CONF; int ret = 0; while (TRUE) { switch (command_getopt(&arg)) { case 'h': return command_usage(NULL); case 'c': clear = TRUE; continue; case 'n': noprompt = TRUE; continue; case 'P': format |= COMMAND_FORMAT_PRETTY; /* fall through to raw */ case 'r': format |= COMMAND_FORMAT_RAW; continue; case 'f': file = arg; continue; case EOF: break; default: return command_usage("invalid --load-all option"); } break; } cfg = settings_create(file); if (!cfg) { fprintf(stderr, "parsing '%s' failed\n", file); return EINVAL; } if (ret == 0) { ret = load_creds_cfg(conn, format, cfg, clear, noprompt); } if (ret == 0) { ret = load_authorities_cfg(conn, format, cfg); } if (ret == 0) { ret = load_pools_cfg(conn, format, cfg); } if (ret == 0) { ret = load_conns_cfg(conn, format, cfg); } cfg->destroy(cfg); return ret; }