Improved 'help' output
This commit is contained in:
parent
294f7e9d1c
commit
bbc4af49e9
|
@ -2079,53 +2079,37 @@ void telephone_event(call_relation_t *relation, struct telephone_event *te)
|
|||
routing_send(&relation->call->routing, digit_string);
|
||||
}
|
||||
|
||||
void routing_help(const char *command)
|
||||
void routing_help(void)
|
||||
{
|
||||
int i, j, k;
|
||||
|
||||
if (!command) {
|
||||
printf("Available routing commands:\n\n");
|
||||
for (i = 0; command_def[i].name; i++) {
|
||||
printf("Command: %s\n", command_def[i].name);
|
||||
printf(" Description: %s\n", command_def[i].description);
|
||||
}
|
||||
printf("\nUse '-h <command>' for detailled description of a command.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Available routing commands:\n\n");
|
||||
for (i = 0; command_def[i].name; i++) {
|
||||
if (!strcasecmp(command, command_def[i].name))
|
||||
break;
|
||||
}
|
||||
if (!command_def[i].name) {
|
||||
printf("Given Command '%s' unknown!\n", command);
|
||||
return;
|
||||
}
|
||||
struct param_def *param_def = command_def[i].param_list;
|
||||
|
||||
printf("Command: %s\n", command_def[i].name);
|
||||
printf("Description: %s\n", command_def[i].description);
|
||||
printf("Command: %s\n", command_def[i].name);
|
||||
printf(" Description: %s\n", command_def[i].description);
|
||||
|
||||
struct param_def *param_def = command_def[i].param_list;
|
||||
if (!param_def) {
|
||||
printf(" This command does not have any parameters.\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!param_def) {
|
||||
printf("This command does not have any parameters.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (j = 0; param_def[j].n; j++) {
|
||||
printf("Parameter: %s%s\n", param_def[j].n, (param_def[j].mandatory) ? " (manatory)" : "");
|
||||
printf(" Description: %s\n", param_def[j].d);
|
||||
if (param_def[j].o || param_def[j].t) {
|
||||
for (k = 0; codecs_def[k].payload_name; k++) {
|
||||
printf(" Value: '%s'\n", codecs_def[k].payload_name);
|
||||
}
|
||||
} else if (param_def[j].no_value) {
|
||||
printf(" No value\n");
|
||||
} else if (param_def[j].i && param_def[j].value2name) {
|
||||
for (k = 0; k < param_def[j].num; k++) {
|
||||
const char *name = param_def[j].value2name(k);
|
||||
if (name && name[0] != '<')
|
||||
printf(" Value: '%d' or '%s'\n", k, name);
|
||||
for (j = 0; param_def[j].n; j++) {
|
||||
printf(" Parameter: %s%s\n", param_def[j].n, (param_def[j].mandatory) ? " (manatory)" : "");
|
||||
printf(" Description: %s\n", param_def[j].d);
|
||||
if (param_def[j].o || param_def[j].t) {
|
||||
for (k = 0; codecs_def[k].payload_name; k++) {
|
||||
printf(" Value: '%s'\n", codecs_def[k].payload_name);
|
||||
}
|
||||
} else if (param_def[j].no_value) {
|
||||
printf(" No value\n");
|
||||
} else if (param_def[j].i && param_def[j].value2name) {
|
||||
for (k = 0; k < param_def[j].num; k++) {
|
||||
const char *name = param_def[j].value2name(k);
|
||||
if (name && name[0] != '<')
|
||||
printf(" Value: '%d' or '%s'\n", k, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,5 +98,5 @@ int call_handle(void);
|
|||
void cc_message(osmo_cc_endpoint_t *ep, uint32_t callref, osmo_cc_msg_t *msg);
|
||||
void telephone_event(call_relation_t *relation, struct telephone_event *te);
|
||||
|
||||
void routing_help(const char *command);
|
||||
void routing_help(void);
|
||||
|
||||
|
|
|
@ -183,16 +183,12 @@ int main(int argc, char *argv[])
|
|||
if (argi <= 0)
|
||||
return argi;
|
||||
if (show_help) {
|
||||
if (argi < argc) {
|
||||
routing_help(argv[argi]);
|
||||
return 0;
|
||||
}
|
||||
print_usage(argv[0]);
|
||||
print_help();
|
||||
printf("\n");
|
||||
env_help();
|
||||
printf("\n");
|
||||
routing_help(NULL);
|
||||
routing_help();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -131,14 +131,17 @@ static void env_add(routing_t *routing, const char *name)
|
|||
|
||||
void env_help(void)
|
||||
{
|
||||
int i;
|
||||
int i, j;
|
||||
|
||||
printf("Available environment variables:\n\n");
|
||||
printf("Available environment variables at routing script:\n\n");
|
||||
for (i = 0; env_def[i].n; i++) {
|
||||
printf("Variable: CC_%s\n", env_def[i].n);
|
||||
printf("Variable: CC_%s=<value>\n", env_def[i].n);
|
||||
printf(" Description: %s\n", env_def[i].d);
|
||||
if (env_def[i].value2name) {
|
||||
printf(" Additional variable: CC_%s_NAME\n", env_def[i].n);
|
||||
for (j = 0; j < 256; j++) {
|
||||
if (env_def[i].value2name(j)[0] != '<')
|
||||
printf(" Alternative variable for value '%d': CC_%s_NAME=%s\n", j, env_def[i].n, env_def[i].value2name(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue