mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-20 17:33:08 +00:00
Refactor: rename some cli.h structs
Now all symbols defined in cli.h start with or contain "cli_"
This commit is contained in:
parent
f66a894a63
commit
e86a129d49
12
cli.c
12
cli.c
@ -5,7 +5,7 @@
|
||||
#include "serval.h"
|
||||
#include "rhizome.h"
|
||||
|
||||
int cli_usage(const struct command_line_option *commands) {
|
||||
int cli_usage(const struct cli_schema *commands) {
|
||||
printf("Usage:\n");
|
||||
int i,j;
|
||||
for(i=0;commands[i].function;i++) {
|
||||
@ -16,13 +16,13 @@ int cli_usage(const struct command_line_option *commands) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cli_parse(const int argc, const char *const *args, const struct command_line_option *commands, struct parsed_command *parsed)
|
||||
int cli_parse(const int argc, const char *const *args, const struct cli_schema *commands, struct cli_parsed *parsed)
|
||||
{
|
||||
int ambiguous = 0;
|
||||
int matched_cmd = -1;
|
||||
int cmd;
|
||||
for (cmd = 0; commands[cmd].function; ++cmd) {
|
||||
struct parsed_command cmdpa;
|
||||
struct cli_parsed cmdpa;
|
||||
memset(&cmdpa, 0, sizeof cmdpa);
|
||||
cmdpa.command = &commands[cmd];
|
||||
cmdpa.args = args;
|
||||
@ -172,7 +172,7 @@ int cli_parse(const int argc, const char *const *args, const struct command_line
|
||||
return matched_cmd;
|
||||
}
|
||||
|
||||
void _debug_parsed(struct __sourceloc __whence, const struct parsed_command *parsed)
|
||||
void _debug_cli_parsed(struct __sourceloc __whence, const struct cli_parsed *parsed)
|
||||
{
|
||||
DEBUG_argv("command", parsed->argc, parsed->args);
|
||||
strbuf b = strbuf_alloca(1024);
|
||||
@ -186,14 +186,14 @@ void _debug_parsed(struct __sourceloc __whence, const struct parsed_command *par
|
||||
DEBUGF("parsed%s", strbuf_str(b));
|
||||
}
|
||||
|
||||
int cli_invoke(const struct parsed_command *parsed, void *context)
|
||||
int cli_invoke(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
IN();
|
||||
int ret = parsed->command->function(parsed, context);
|
||||
RETURN(ret);
|
||||
}
|
||||
|
||||
int cli_arg(const struct parsed_command *parsed, char *label, const char **dst, int (*validator)(const char *arg), char *defaultvalue)
|
||||
int cli_arg(const struct cli_parsed *parsed, char *label, const char **dst, int (*validator)(const char *arg), char *defaultvalue)
|
||||
{
|
||||
int labellen = strlen(label);
|
||||
if (dst)
|
||||
|
22
cli.h
22
cli.h
@ -24,10 +24,10 @@
|
||||
|
||||
#define COMMAND_LINE_MAX_LABELS (32)
|
||||
|
||||
struct parsed_command;
|
||||
struct cli_parsed;
|
||||
|
||||
struct command_line_option {
|
||||
int (*function)(const struct parsed_command *parsed, void *context);
|
||||
struct cli_schema {
|
||||
int (*function)(const struct cli_parsed *parsed, void *context);
|
||||
const char *words[COMMAND_LINE_MAX_LABELS];
|
||||
unsigned long long flags;
|
||||
#define CLIFLAG_NONOVERLAY (1<<0) /* Uses a legacy IPv4 DNA call instead of overlay mnetwork */
|
||||
@ -36,8 +36,8 @@ struct command_line_option {
|
||||
const char *description; // describe this invocation
|
||||
};
|
||||
|
||||
struct parsed_command {
|
||||
const struct command_line_option *command;
|
||||
struct cli_parsed {
|
||||
const struct cli_schema *command;
|
||||
struct labelv {
|
||||
const char *label;
|
||||
unsigned int len;
|
||||
@ -49,14 +49,14 @@ struct parsed_command {
|
||||
unsigned varargi;
|
||||
};
|
||||
|
||||
void _debug_parsed(struct __sourceloc __whence, const struct parsed_command *parsed);
|
||||
void _debug_cli_parsed(struct __sourceloc __whence, const struct cli_parsed *parsed);
|
||||
|
||||
#define DEBUG_parsed(parsed) _debug_parsed(__WHENCE__, parsed)
|
||||
#define DEBUG_cli_parsed(parsed) _debug_cli_parsed(__WHENCE__, parsed)
|
||||
|
||||
int cli_usage(const struct command_line_option *commands);
|
||||
int cli_parse(const int argc, const char *const *args, const struct command_line_option *commands, struct parsed_command *parsed);
|
||||
int cli_invoke(const struct parsed_command *parsed, void *context);
|
||||
int cli_arg(const struct parsed_command *parsed, char *label, const char **dst, int (*validator)(const char *arg), char *defaultvalue);
|
||||
int cli_usage(const struct cli_schema *commands);
|
||||
int cli_parse(const int argc, const char *const *args, const struct cli_schema *commands, struct cli_parsed *parsed);
|
||||
int cli_invoke(const struct cli_parsed *parsed, void *context);
|
||||
int cli_arg(const struct cli_parsed *parsed, char *label, const char **dst, int (*validator)(const char *arg), char *defaultvalue);
|
||||
|
||||
int cli_lookup_did(const char *text);
|
||||
int cli_absolute_path(const char *arg);
|
||||
|
116
commandline.c
116
commandline.c
@ -44,9 +44,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#include "cli.h"
|
||||
#include "overlay_address.h"
|
||||
|
||||
extern struct command_line_option command_line_options[];
|
||||
extern struct cli_schema command_line_options[];
|
||||
|
||||
int commandline_usage(const struct parsed_command *parsed, void *context)
|
||||
int commandline_usage(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
printf("Serval Mesh version <version>.\n");
|
||||
return cli_usage(command_line_options);
|
||||
@ -224,7 +224,7 @@ int parseCommandLine(const char *argv0, int argc, const char *const *args)
|
||||
fd_clearstats();
|
||||
IN();
|
||||
|
||||
struct parsed_command parsed;
|
||||
struct cli_parsed parsed;
|
||||
int result = cli_parse(argc, args, command_line_options, &parsed);
|
||||
if (result != -1) {
|
||||
// Do not run the command if the configuration does not load ok
|
||||
@ -479,10 +479,10 @@ void cli_flush()
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
int app_echo(const struct parsed_command *parsed, void *context)
|
||||
int app_echo(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
int escapes = !cli_arg(parsed, "-e", NULL, NULL, NULL);
|
||||
int i;
|
||||
for (i = parsed->varargi; i < parsed->argc; ++i) {
|
||||
@ -540,10 +540,10 @@ void lookup_send_request(unsigned char *srcsid, int srcport, unsigned char *dsts
|
||||
}
|
||||
}
|
||||
|
||||
int app_dna_lookup(const struct parsed_command *parsed, void *context)
|
||||
int app_dna_lookup(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
|
||||
/* Create the instance directory if it does not yet exist */
|
||||
if (create_serval_instance_dir() == -1)
|
||||
@ -658,10 +658,10 @@ int app_dna_lookup(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_server_start(const struct parsed_command *parsed, void *context)
|
||||
int app_server_start(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
/* Process optional arguments */
|
||||
int pid=-1;
|
||||
int cpid=-1;
|
||||
@ -832,10 +832,10 @@ int app_server_start(const struct parsed_command *parsed, void *context)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int app_server_stop(const struct parsed_command *parsed, void *context)
|
||||
int app_server_stop(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
int pid, tries, running;
|
||||
const char *instancepath;
|
||||
time_ms_t timeout;
|
||||
@ -894,10 +894,10 @@ int app_server_stop(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_server_status(const struct parsed_command *parsed, void *context)
|
||||
int app_server_status(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
int pid;
|
||||
const char *instancepath;
|
||||
if (cli_arg(parsed, "instance path", &instancepath, cli_absolute_path, NULL) == -1)
|
||||
@ -922,10 +922,10 @@ int app_server_status(const struct parsed_command *parsed, void *context)
|
||||
return pid > 0 ? 0 : 1;
|
||||
}
|
||||
|
||||
int app_mdp_ping(const struct parsed_command *parsed, void *context)
|
||||
int app_mdp_ping(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
const char *sid, *count;
|
||||
if (cli_arg(parsed, "SID|broadcast", &sid, str_is_subscriber_id, "broadcast") == -1)
|
||||
return -1;
|
||||
@ -1070,10 +1070,10 @@ int app_mdp_ping(const struct parsed_command *parsed, void *context)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int app_config_schema(const struct parsed_command *parsed, void *context)
|
||||
int app_config_schema(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
if (create_serval_instance_dir() == -1)
|
||||
return -1;
|
||||
struct cf_om_node *root = NULL;
|
||||
@ -1091,10 +1091,10 @@ int app_config_schema(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_config_set(const struct parsed_command *parsed, void *context)
|
||||
int app_config_set(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
if (create_serval_instance_dir() == -1)
|
||||
return -1;
|
||||
// <kludge>
|
||||
@ -1146,10 +1146,10 @@ int app_config_set(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_config_get(const struct parsed_command *parsed, void *context)
|
||||
int app_config_get(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
const char *var;
|
||||
if (cli_arg(parsed, "variable", &var, is_configvarpattern, NULL) == -1)
|
||||
return -1;
|
||||
@ -1181,10 +1181,10 @@ int app_config_get(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_rhizome_hash_file(const struct parsed_command *parsed, void *context)
|
||||
int app_rhizome_hash_file(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
/* compute hash of file. We do this without a manifest, so it will necessarily
|
||||
return the hash of the file unencrypted. */
|
||||
const char *filepath;
|
||||
@ -1197,10 +1197,10 @@ int app_rhizome_hash_file(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_rhizome_add_file(const struct parsed_command *parsed, void *context)
|
||||
int app_rhizome_add_file(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
const char *filepath, *manifestpath, *authorSidHex, *bskhex;
|
||||
cli_arg(parsed, "filepath", &filepath, NULL, "");
|
||||
if (cli_arg(parsed, "author_sid", &authorSidHex, cli_optional_sid, "") == -1)
|
||||
@ -1321,10 +1321,10 @@ int app_rhizome_add_file(const struct parsed_command *parsed, void *context)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int app_rhizome_import_bundle(const struct parsed_command *parsed, void *context)
|
||||
int app_rhizome_import_bundle(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
const char *filepath, *manifestpath;
|
||||
cli_arg(parsed, "filepath", &filepath, NULL, "");
|
||||
cli_arg(parsed, "manifestpath", &manifestpath, NULL, "");
|
||||
@ -1376,10 +1376,10 @@ cleanup:
|
||||
return status;
|
||||
}
|
||||
|
||||
int app_rhizome_append_manifest(const struct parsed_command *parsed, void *context)
|
||||
int app_rhizome_append_manifest(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
const char *manifestpath, *filepath;
|
||||
if ( cli_arg(parsed, "manifestpath", &manifestpath, NULL, "") == -1
|
||||
|| cli_arg(parsed, "filepath", &filepath, NULL, "") == -1)
|
||||
@ -1403,10 +1403,10 @@ int app_rhizome_append_manifest(const struct parsed_command *parsed, void *conte
|
||||
return ret;
|
||||
}
|
||||
|
||||
int app_rhizome_extract_bundle(const struct parsed_command *parsed, void *context)
|
||||
int app_rhizome_extract_bundle(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
const char *manifestpath, *filepath, *manifestid, *bskhex;
|
||||
if ( cli_arg(parsed, "manifestid", &manifestid, cli_manifestid, "") == -1
|
||||
|| cli_arg(parsed, "manifestpath", &manifestpath, NULL, "") == -1
|
||||
@ -1502,10 +1502,10 @@ int app_rhizome_extract_bundle(const struct parsed_command *parsed, void *contex
|
||||
return ret;
|
||||
}
|
||||
|
||||
int app_rhizome_dump_file(const struct parsed_command *parsed, void *context)
|
||||
int app_rhizome_dump_file(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
const char *fileid, *filepath;
|
||||
if ( cli_arg(parsed, "filepath", &filepath, NULL, "") == -1
|
||||
|| cli_arg(parsed, "fileid", &fileid, cli_fileid, NULL) == -1)
|
||||
@ -1531,10 +1531,10 @@ int app_rhizome_dump_file(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_rhizome_list(const struct parsed_command *parsed, void *context)
|
||||
int app_rhizome_list(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
const char *service, *name, *sender_sid, *recipient_sid, *offset, *limit;
|
||||
cli_arg(parsed, "service", &service, NULL, "");
|
||||
cli_arg(parsed, "name", &name, NULL, "");
|
||||
@ -1552,19 +1552,19 @@ int app_rhizome_list(const struct parsed_command *parsed, void *context)
|
||||
return rhizome_list_manifests(service, name, sender_sid, recipient_sid, atoi(offset), atoi(limit), 0);
|
||||
}
|
||||
|
||||
int app_keyring_create(const struct parsed_command *parsed, void *context)
|
||||
int app_keyring_create(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
if (!keyring_open_instance())
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_keyring_list(const struct parsed_command *parsed, void *context)
|
||||
int app_keyring_list(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
keyring_file *k = keyring_open_instance_cli(parsed);
|
||||
if (!k)
|
||||
return -1;
|
||||
@ -1587,10 +1587,10 @@ int app_keyring_list(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_keyring_add(const struct parsed_command *parsed, void *context)
|
||||
int app_keyring_add(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
const char *pin;
|
||||
cli_arg(parsed, "pin", &pin, NULL, "");
|
||||
keyring_file *k = keyring_open_instance_cli(parsed);
|
||||
@ -1634,10 +1634,10 @@ int app_keyring_add(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_keyring_set_did(const struct parsed_command *parsed, void *context)
|
||||
int app_keyring_set_did(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
const char *sid, *did, *name;
|
||||
cli_arg(parsed, "sid", &sid, str_is_subscriber_id, "");
|
||||
cli_arg(parsed, "did", &did, cli_optional_did, "");
|
||||
@ -1663,10 +1663,10 @@ int app_keyring_set_did(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_id_self(const struct parsed_command *parsed, void *context)
|
||||
int app_id_self(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
/* List my own identities */
|
||||
overlay_mdp_frame a;
|
||||
bzero(&a, sizeof(overlay_mdp_frame));
|
||||
@ -1712,10 +1712,10 @@ int app_id_self(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_count_peers(const struct parsed_command *parsed, void *context)
|
||||
int app_count_peers(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
overlay_mdp_frame a;
|
||||
bzero(&a, sizeof(overlay_mdp_frame));
|
||||
a.packetTypeAndFlags=MDP_GETADDRS;
|
||||
@ -1731,10 +1731,10 @@ int app_count_peers(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_crypt_test(const struct parsed_command *parsed, void *context)
|
||||
int app_crypt_test(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
unsigned char nonce[crypto_box_curve25519xsalsa20poly1305_NONCEBYTES];
|
||||
unsigned char k[crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES];
|
||||
|
||||
@ -1895,10 +1895,10 @@ int app_crypt_test(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_node_info(const struct parsed_command *parsed, void *context)
|
||||
int app_node_info(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
const char *sid;
|
||||
cli_arg(parsed, "sid", &sid, NULL, "");
|
||||
|
||||
@ -1943,10 +1943,10 @@ int app_node_info(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_route_print(const struct parsed_command *parsed, void *context)
|
||||
int app_route_print(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
overlay_mdp_frame mdp;
|
||||
bzero(&mdp,sizeof(mdp));
|
||||
|
||||
@ -1987,10 +1987,10 @@ int app_route_print(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_reverse_lookup(const struct parsed_command *parsed, void *context)
|
||||
int app_reverse_lookup(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
const char *sid, *delay;
|
||||
if (cli_arg(parsed, "sid", &sid, str_is_subscriber_id, "") == -1)
|
||||
return -1;
|
||||
@ -2083,10 +2083,10 @@ int app_reverse_lookup(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_network_scan(const struct parsed_command *parsed, void *context)
|
||||
int app_network_scan(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
overlay_mdp_frame mdp;
|
||||
bzero(&mdp,sizeof(mdp));
|
||||
|
||||
@ -2130,7 +2130,7 @@ int app_network_scan(const struct parsed_command *parsed, void *context)
|
||||
Keep this list alphabetically sorted for user convenience.
|
||||
*/
|
||||
#define KEYRING_PIN_OPTIONS ,"[--keyring-pin=<pin>]","[--entry-pin=<pin>]..."
|
||||
struct command_line_option command_line_options[]={
|
||||
struct cli_schema command_line_options[]={
|
||||
{app_dna_lookup,{"dna","lookup","<did>","[<timeout>]",NULL},0,
|
||||
"Lookup the SIP/MDP address of the supplied telephone number (DID)."},
|
||||
{commandline_usage,{"help",NULL},CLIFLAG_PERMISSIVE_CONFIG,
|
||||
|
@ -1343,7 +1343,7 @@ keyring_file *keyring_open_instance()
|
||||
RETURN(k);
|
||||
}
|
||||
|
||||
keyring_file *keyring_open_instance_cli(const struct parsed_command *parsed)
|
||||
keyring_file *keyring_open_instance_cli(const struct cli_parsed *parsed)
|
||||
{
|
||||
IN();
|
||||
keyring_file *k = keyring_open_instance();
|
||||
|
@ -46,7 +46,7 @@ struct monitor_command_handler monitor_handlers[]={
|
||||
{.command="", .handler=remote_print},
|
||||
};
|
||||
|
||||
int app_monitor_cli(const struct parsed_command *parsed, void *context)
|
||||
int app_monitor_cli(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
struct pollfd fds[2];
|
||||
struct monitor_state *state;
|
||||
|
22
monitor.c
22
monitor.c
@ -382,7 +382,7 @@ void monitor_get_all_supported_codecs(unsigned char *codecs){
|
||||
}
|
||||
}
|
||||
|
||||
static int monitor_set(const struct parsed_command *parsed, void *context)
|
||||
static int monitor_set(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
struct monitor_context *c=context;
|
||||
if (strcase_startswith(parsed->args[1],"vomp",NULL)){
|
||||
@ -411,7 +411,7 @@ static int monitor_set(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int monitor_clear(const struct parsed_command *parsed, void *context)
|
||||
static int monitor_clear(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
struct monitor_context *c=context;
|
||||
if (strcase_startswith(parsed->args[1],"vomp",NULL))
|
||||
@ -432,7 +432,7 @@ static int monitor_clear(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int monitor_lookup_match(const struct parsed_command *parsed, void *context)
|
||||
static int monitor_lookup_match(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
struct monitor_context *c = context;
|
||||
const char *sid = parsed->args[2];
|
||||
@ -456,7 +456,7 @@ static int monitor_lookup_match(const struct parsed_command *parsed, void *conte
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int monitor_call(const struct parsed_command *parsed, void *context)
|
||||
static int monitor_call(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
struct monitor_context *c=context;
|
||||
unsigned char sid[SID_SIZE];
|
||||
@ -470,7 +470,7 @@ static int monitor_call(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int monitor_call_ring(const struct parsed_command *parsed, void *context)
|
||||
static int monitor_call_ring(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
struct vomp_call_state *call=vomp_find_call_by_session(strtol(parsed->args[1],NULL,16));
|
||||
if (!call)
|
||||
@ -480,7 +480,7 @@ static int monitor_call_ring(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int monitor_call_pickup(const struct parsed_command *parsed, void *context)
|
||||
static int monitor_call_pickup(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
struct vomp_call_state *call=vomp_find_call_by_session(strtol(parsed->args[1],NULL,16));
|
||||
if (!call)
|
||||
@ -490,7 +490,7 @@ static int monitor_call_pickup(const struct parsed_command *parsed, void *contex
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int monitor_call_audio(const struct parsed_command *parsed, void *context)
|
||||
static int monitor_call_audio(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
struct monitor_context *c=context;
|
||||
struct vomp_call_state *call=vomp_find_call_by_session(strtol(parsed->args[1],NULL,16));
|
||||
@ -508,7 +508,7 @@ static int monitor_call_audio(const struct parsed_command *parsed, void *context
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int monitor_call_hangup(const struct parsed_command *parsed, void *context)
|
||||
static int monitor_call_hangup(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
struct vomp_call_state *call=vomp_find_call_by_session(strtol(parsed->args[1],NULL,16));
|
||||
if (!call)
|
||||
@ -518,7 +518,7 @@ static int monitor_call_hangup(const struct parsed_command *parsed, void *contex
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int monitor_call_dtmf(const struct parsed_command *parsed, void *context)
|
||||
static int monitor_call_dtmf(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
struct monitor_context *c=context;
|
||||
struct vomp_call_state *call=vomp_find_call_by_session(strtol(parsed->args[1],NULL,16));
|
||||
@ -542,7 +542,7 @@ static int monitor_call_dtmf(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct command_line_option monitor_options[]={
|
||||
struct cli_schema monitor_options[]={
|
||||
{monitor_set,{"monitor","vomp","<codec>","...",NULL},0,""},
|
||||
{monitor_set,{"monitor","<type>",NULL},0,""},
|
||||
{monitor_clear,{"ignore","<type>",NULL},0,""},
|
||||
@ -561,7 +561,7 @@ int monitor_process_command(struct monitor_context *c)
|
||||
char *argv[16]={NULL,};
|
||||
int argc = parse_argv(c->line, ' ', argv, 16);
|
||||
|
||||
struct parsed_command parsed;
|
||||
struct cli_parsed parsed;
|
||||
int res = cli_parse(argc, (const char *const*)argv, monitor_options, &parsed);
|
||||
if (res == -1 || cli_invoke(&parsed, c))
|
||||
return monitor_write_error(c, "Invalid command");
|
||||
|
@ -57,8 +57,7 @@ static PaCtx *pa_phone_setup(void);
|
||||
|
||||
/* Declarations */
|
||||
|
||||
int
|
||||
app_pa_phone(int argc, const char *const *argv, const struct command_line_option *o)
|
||||
int app_pa_phone(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
PaCtx *ctx;
|
||||
|
||||
|
@ -513,10 +513,10 @@ static int rhizome_sync_with_peers(int mode, int peer_count, const struct config
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_rhizome_direct_sync(const struct parsed_command *parsed, void *context)
|
||||
int app_rhizome_direct_sync(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
/* Attempt to connect with a remote Rhizome Direct instance,
|
||||
and negotiate which BARs to synchronise. */
|
||||
const char *modeName = (parsed->argc >= 3 ? parsed->args[2] : "sync");
|
||||
|
12
serval.h
12
serval.h
@ -266,7 +266,7 @@ extern keyring_file *keyring;
|
||||
/* Public calls to keyring management */
|
||||
keyring_file *keyring_open(char *file);
|
||||
keyring_file *keyring_open_instance();
|
||||
keyring_file *keyring_open_instance_cli(const struct parsed_command *parsed);
|
||||
keyring_file *keyring_open_instance_cli(const struct cli_parsed *parsed);
|
||||
int keyring_enter_pin(keyring_file *k, const char *pin);
|
||||
int keyring_set_did(keyring_identity *id,char *did,char *name);
|
||||
int keyring_sanitise_position(const keyring_file *k,int *cn,int *in,int *kp);
|
||||
@ -656,13 +656,13 @@ int overlay_broadcast_ensemble(int interface_number,
|
||||
int directory_registration();
|
||||
int directory_service_init();
|
||||
|
||||
struct command_line_option;
|
||||
int app_rhizome_direct_sync(const struct parsed_command *parsed, void *context);
|
||||
struct cli_parsed;
|
||||
int app_rhizome_direct_sync(const struct cli_parsed *parsed, void *context);
|
||||
#ifdef HAVE_VOIPTEST
|
||||
int app_pa_phone(const struct parsed_command *parsed, void *context);
|
||||
int app_pa_phone(const struct cli_parsed *parsed, void *context);
|
||||
#endif
|
||||
int app_monitor_cli(const struct parsed_command *parsed, void *context);
|
||||
int app_vomp_console(const struct parsed_command *parsed, void *context);
|
||||
int app_monitor_cli(const struct cli_parsed *parsed, void *context);
|
||||
int app_vomp_console(const struct cli_parsed *parsed, void *context);
|
||||
|
||||
int monitor_get_fds(struct pollfd *fds,int *fdcount,int fdmax);
|
||||
|
||||
|
@ -186,7 +186,7 @@ struct monitor_command_handler console_handlers[]={
|
||||
{.command="MONITORSTATUS", .handler=remote_noop},
|
||||
};
|
||||
|
||||
static int console_dial(const struct parsed_command *parsed, void *context)
|
||||
static int console_dial(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (call_token!=-1){
|
||||
printf("Already in a call\n");
|
||||
@ -199,7 +199,7 @@ static int console_dial(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int console_answer(const struct parsed_command *parsed, void *context)
|
||||
static int console_answer(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (call_token==-1){
|
||||
printf("No active call to answer\n");
|
||||
@ -209,7 +209,7 @@ static int console_answer(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int console_hangup(const struct parsed_command *parsed, void *context)
|
||||
static int console_hangup(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (call_token==-1){
|
||||
printf("No call to hangup\n");
|
||||
@ -219,7 +219,7 @@ static int console_hangup(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int console_audio(const struct parsed_command *parsed, void *context)
|
||||
static int console_audio(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (call_token==-1){
|
||||
printf("No active call\n");
|
||||
@ -243,9 +243,9 @@ static int console_audio(const struct parsed_command *parsed, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int console_usage(const struct parsed_command *parsed, void *context);
|
||||
static int console_usage(const struct cli_parsed *parsed, void *context);
|
||||
|
||||
struct command_line_option console_commands[]={
|
||||
struct cli_schema console_commands[]={
|
||||
{console_answer,{"answer",NULL},0,"Answer an incoming phone call"},
|
||||
{console_dial,{"call","<sid>","[<local_number>]","[<remote_extension>]",NULL},0,"Start dialling a given person"},
|
||||
{console_hangup,{"hangup",NULL},0,"Hangup the phone line"},
|
||||
@ -254,7 +254,7 @@ struct command_line_option console_commands[]={
|
||||
{NULL},
|
||||
};
|
||||
|
||||
static int console_usage(const struct parsed_command *parsed, void *context)
|
||||
static int console_usage(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
cli_usage(console_commands);
|
||||
fflush(stdout);
|
||||
@ -265,7 +265,7 @@ static void console_command(char *line){
|
||||
char *argv[16];
|
||||
int argc = parse_argv(line, ' ', argv, 16);
|
||||
|
||||
struct parsed_command parsed;
|
||||
struct cli_parsed parsed;
|
||||
int ret = cli_parse(argc, (const char *const*)argv, console_commands, &parsed);
|
||||
if (ret == -1) {
|
||||
printf("Unknown command, try help\n");
|
||||
@ -312,10 +312,10 @@ static void monitor_read(struct sched_ent *alarm){
|
||||
}
|
||||
}
|
||||
|
||||
int app_vomp_console(const struct parsed_command *parsed, void *context)
|
||||
int app_vomp_console(const struct cli_parsed *parsed, void *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
DEBUG_parsed(parsed);
|
||||
DEBUG_cli_parsed(parsed);
|
||||
static struct profile_total stdin_profile={
|
||||
.name="read_lines",
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user