2013-04-09 07:48:37 +00:00
|
|
|
/*
|
|
|
|
Serval DNA command-line functions
|
|
|
|
Copyright (C) 2010-2013 Serval Project, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2012-09-25 04:01:34 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <strings.h>
|
2013-04-09 07:48:37 +00:00
|
|
|
#include <assert.h>
|
2012-09-25 04:01:34 +00:00
|
|
|
#include "cli.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "serval.h"
|
|
|
|
#include "rhizome.h"
|
2013-03-25 01:35:26 +00:00
|
|
|
#include "strbuf_helpers.h"
|
2012-09-25 04:01:34 +00:00
|
|
|
|
2013-03-25 01:35:26 +00:00
|
|
|
int cli_usage(const struct cli_schema *commands, XPRINTF xpf)
|
|
|
|
{
|
|
|
|
return cli_usage_args(0, NULL, commands, xpf);
|
|
|
|
}
|
|
|
|
|
|
|
|
int cli_usage_parsed(const struct cli_parsed *parsed, XPRINTF xpf)
|
|
|
|
{
|
|
|
|
if (parsed->varargi == -1)
|
|
|
|
return cli_usage(parsed->commands, xpf);
|
|
|
|
return cli_usage_args(parsed->argc - parsed->varargi, &parsed->args[parsed->varargi], parsed->commands, xpf);
|
|
|
|
}
|
|
|
|
|
|
|
|
int cli_usage_args(const int argc, const char *const *args, const struct cli_schema *commands, XPRINTF xpf)
|
|
|
|
{
|
2013-02-18 06:43:30 +00:00
|
|
|
unsigned cmd;
|
2013-03-25 01:35:26 +00:00
|
|
|
int matched_any = 0;
|
2013-02-18 06:43:30 +00:00
|
|
|
for (cmd = 0; commands[cmd].function; ++cmd) {
|
|
|
|
unsigned opt;
|
|
|
|
const char *word;
|
2013-03-25 01:35:26 +00:00
|
|
|
int matched = 1;
|
|
|
|
for (opt = 0; matched && opt < argc && (word = commands[cmd].words[opt]); ++opt)
|
|
|
|
if (strncmp(word, args[opt], strlen(args[opt])) != 0)
|
|
|
|
matched = 0;
|
|
|
|
if (matched) {
|
|
|
|
matched_any = 1;
|
|
|
|
for (opt = 0; (word = commands[cmd].words[opt]); ++opt) {
|
2013-04-12 07:48:25 +00:00
|
|
|
if (word[0] == '|')
|
2013-03-25 01:35:26 +00:00
|
|
|
++word;
|
|
|
|
xprintf(xpf, " %s", word);
|
|
|
|
}
|
|
|
|
xputc('\n', xpf);
|
|
|
|
if (commands[cmd].description && commands[cmd].description[0])
|
|
|
|
xprintf(xpf, " %s\n", commands[cmd].description);
|
2013-02-18 06:43:30 +00:00
|
|
|
}
|
2013-03-25 01:35:26 +00:00
|
|
|
}
|
|
|
|
if (!matched_any && argc) {
|
|
|
|
strbuf b = strbuf_alloca(160);
|
|
|
|
strbuf_append_argv(b, argc, args);
|
|
|
|
xprintf(xpf, " No commands matching %s\n", strbuf_str(b));
|
2012-09-25 04:01:34 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-04-09 07:48:37 +00:00
|
|
|
/* Returns 0 if a command is matched and parsed, with the results of the parsing in the '*parsed'
|
|
|
|
* structure.
|
|
|
|
*
|
|
|
|
* Returns 1 and logs an error if no command matches the argument list, contents of '*parsed' are
|
|
|
|
* undefined.
|
|
|
|
*
|
|
|
|
* Returns 2 if the argument list is ambiguous, ie, matches more than one command, contents of
|
|
|
|
* '*parsed' are undefined.
|
|
|
|
*
|
|
|
|
* Returns -1 and logs an error if the parsing fails due to an internal error (eg, malformed command
|
|
|
|
* schema), contents of '*parsed' are undefined.
|
|
|
|
*
|
|
|
|
* @author Andrew Bettison <andrew@servalproject.com>
|
|
|
|
*/
|
2013-02-13 07:13:24 +00:00
|
|
|
int cli_parse(const int argc, const char *const *args, const struct cli_schema *commands, struct cli_parsed *parsed)
|
2013-02-12 07:30:37 +00:00
|
|
|
{
|
|
|
|
int ambiguous = 0;
|
|
|
|
int matched_cmd = -1;
|
|
|
|
int cmd;
|
|
|
|
for (cmd = 0; commands[cmd].function; ++cmd) {
|
2013-02-13 07:13:24 +00:00
|
|
|
struct cli_parsed cmdpa;
|
2013-02-12 07:30:37 +00:00
|
|
|
memset(&cmdpa, 0, sizeof cmdpa);
|
2013-03-25 01:35:26 +00:00
|
|
|
cmdpa.commands = commands;
|
|
|
|
cmdpa.cmdi = cmd;
|
2013-02-12 07:30:37 +00:00
|
|
|
cmdpa.args = args;
|
|
|
|
cmdpa.argc = argc;
|
|
|
|
cmdpa.labelc = 0;
|
|
|
|
cmdpa.varargi = -1;
|
2013-04-09 07:48:37 +00:00
|
|
|
const char *pattern = NULL;
|
2013-02-13 05:25:00 +00:00
|
|
|
unsigned arg = 0;
|
|
|
|
unsigned opt = 0;
|
2013-04-09 07:48:37 +00:00
|
|
|
while ((pattern = commands[cmd].words[opt])) {
|
|
|
|
//DEBUGF("cmd=%d opt=%d pattern='%s' args[arg=%d]='%s'", cmd, opt, pattern, arg, arg < argc ? args[arg] : "");
|
|
|
|
unsigned patlen = strlen(pattern);
|
2013-02-12 07:30:37 +00:00
|
|
|
if (cmdpa.varargi != -1)
|
2013-04-09 07:48:37 +00:00
|
|
|
return WHYF("Internal error: commands[%d].word[%d]=\"%s\" - more words not allowed after \"...\"", cmd, opt, commands[cmd].words[opt]);
|
2013-02-13 05:25:00 +00:00
|
|
|
/* These are the argument matching rules:
|
|
|
|
*
|
|
|
|
* "..." consumes all remaining arguments
|
|
|
|
*
|
2013-04-09 07:48:37 +00:00
|
|
|
* "word" consumes one argument that exactly matches "word", does not label it (this is the
|
|
|
|
* "simple" case in the code below; all other rules label something that matched)
|
2013-02-13 05:25:00 +00:00
|
|
|
*
|
2013-04-09 07:48:37 +00:00
|
|
|
* "word1|word2|...|wordN" consumes one argument that exactly matches "word1" or "word2" etc.
|
|
|
|
* or "wordN", labels it with the matched word (an empty alternative, eg "|word" does not
|
|
|
|
* match an empty argument)
|
2013-02-18 06:43:30 +00:00
|
|
|
*
|
2013-04-12 07:48:25 +00:00
|
|
|
* (as a special case of the above rule, "|word" consumes one argument that exactly matches
|
|
|
|
* "word" and labels it "word", but it appears in the help description as "word")
|
2013-02-18 06:43:30 +00:00
|
|
|
*
|
2013-02-13 05:25:00 +00:00
|
|
|
* "<label>" consumes exactly one argument "ANY", records it with label "label"
|
|
|
|
*
|
|
|
|
* "prefix=<any>" consumes one argument "prefix=ANY" or two arguments "prefix" "ANY",
|
|
|
|
* and records the text matching ANY with label "prefix"
|
|
|
|
*
|
|
|
|
* "prefix <any>" consumes one argyment "prefix ANY" if available or two arguments "prefix"
|
|
|
|
* "ANY", and records the text matching ANY with label "prefix"
|
|
|
|
*
|
|
|
|
* "prefix<any>" consumes one argument "prefixANY", and records the text matching ANY with
|
|
|
|
* label "prefix"
|
|
|
|
*
|
2013-04-09 07:48:37 +00:00
|
|
|
* "[ANY]..." consumes all remaining arguments which match ANY, as defined below
|
|
|
|
*
|
|
|
|
* "[word]" consumes one argument if it exactly matches "word", records it with label
|
|
|
|
* "word"
|
|
|
|
*
|
|
|
|
* "[word1|word2|...|wordN]" consumes one argument if it exactly matches "word1" or "word2"
|
|
|
|
* etc. or "wordN", labels it with the matched word
|
|
|
|
*
|
2013-02-13 05:25:00 +00:00
|
|
|
* "[<label>]" consumes one argument "ANY" if available, records it with label "label"
|
|
|
|
*
|
|
|
|
* "[prefix=<any>]" consumes one argument "prefix=ANY" if available or two arguments
|
|
|
|
* "prefix" "ANY" if available, records the text matching ANY with label "prefix"
|
|
|
|
*
|
|
|
|
* "[prefix <any>]" consumes one argument "prefix ANY" if available or two arguments
|
|
|
|
* "prefix" "ANY" if available, records the text matching ANY with label "prefix"
|
|
|
|
*
|
|
|
|
* "[prefix<any>]" consumes one argument "prefixANY" if available, records the text matching
|
|
|
|
* ANY with label "prefix"
|
|
|
|
*/
|
2013-04-09 07:48:37 +00:00
|
|
|
if (patlen == 3 && pattern[0] == '.' && pattern[1] == '.' && pattern[2] == '.') {
|
2013-02-12 07:30:37 +00:00
|
|
|
cmdpa.varargi = arg;
|
|
|
|
arg = argc;
|
2013-02-13 05:25:00 +00:00
|
|
|
++opt;
|
|
|
|
} else {
|
|
|
|
int optional = 0;
|
|
|
|
int repeating = 0;
|
2013-04-09 07:48:37 +00:00
|
|
|
if (patlen > 5 && pattern[0] == '[' && pattern[patlen-4] == ']' && pattern[patlen-3] == '.' && pattern[patlen-2] == '.' && pattern[patlen-1] == '.') {
|
2013-02-13 05:25:00 +00:00
|
|
|
optional = repeating = 1;
|
2013-04-09 07:48:37 +00:00
|
|
|
pattern += 1;
|
|
|
|
patlen -= 5;
|
2013-02-13 05:25:00 +00:00
|
|
|
}
|
2013-04-09 07:48:37 +00:00
|
|
|
else if (patlen > 2 && pattern[0] == '[' && pattern[patlen-1] == ']') {
|
2013-02-13 05:25:00 +00:00
|
|
|
optional = 1;
|
2013-04-09 07:48:37 +00:00
|
|
|
pattern += 1;
|
|
|
|
patlen -= 2;
|
2013-02-13 05:25:00 +00:00
|
|
|
}
|
2013-04-09 07:48:37 +00:00
|
|
|
unsigned oarg = arg;
|
|
|
|
const char *text = NULL;
|
2013-02-13 05:25:00 +00:00
|
|
|
const char *label = NULL;
|
|
|
|
unsigned labellen = 0;
|
2013-04-12 07:48:25 +00:00
|
|
|
const char *word = pattern;
|
2013-04-09 07:48:37 +00:00
|
|
|
unsigned wordlen = 0;
|
|
|
|
char simple = 0;
|
|
|
|
unsigned alt = 0;
|
2013-04-12 07:48:25 +00:00
|
|
|
if (patlen && *word == '|') {
|
|
|
|
++alt;
|
|
|
|
++word;
|
|
|
|
}
|
|
|
|
if (patlen == 0)
|
|
|
|
return WHYF("Internal error: commands[%d].word[%d]=\"%s\" - empty words not allowed", cmd, opt, commands[cmd].words[opt]);
|
|
|
|
for (; word < &pattern[patlen]; word += wordlen + 1, ++alt) {
|
2013-04-09 07:48:37 +00:00
|
|
|
// Skip over empty "||word" alternative (but still count it).
|
2013-04-12 07:48:25 +00:00
|
|
|
if (*word == '|')
|
|
|
|
return WHYF("Internal error: commands[%d].word[%d]=\"%s\" - empty alternatives not allowed", cmd, opt, commands[cmd].words[opt]);
|
2013-04-09 07:48:37 +00:00
|
|
|
// Find end of "word|" alternative.
|
|
|
|
wordlen = 1;
|
|
|
|
while (&word[wordlen] < &pattern[patlen] && word[wordlen] != '|')
|
|
|
|
++wordlen;
|
|
|
|
// Skip remaining alternatives if we already got a match.
|
|
|
|
if (text)
|
|
|
|
continue;
|
|
|
|
// Look for a match.
|
|
|
|
const char *prefix = NULL;
|
|
|
|
unsigned prefixlen = 0;
|
|
|
|
char prefixarglen = 0;
|
|
|
|
const char *caret = strchr(word, '<');
|
|
|
|
if (wordlen > 2 && caret && word[wordlen-1] == '>') {
|
|
|
|
if ((prefixarglen = prefixlen = caret - word)) {
|
|
|
|
prefix = word;
|
|
|
|
if (prefixlen > 1 && (prefix[prefixlen-1] == '=' || prefix[prefixlen-1] == ' '))
|
|
|
|
--prefixarglen;
|
|
|
|
label = prefix;
|
|
|
|
labellen = prefixarglen;
|
|
|
|
if (arg < argc) {
|
|
|
|
unsigned arglen = strlen(args[arg]);
|
|
|
|
if (arglen >= prefixlen && strncmp(args[arg], prefix, prefixlen) == 0) {
|
|
|
|
text = args[arg++] + prefixlen;
|
|
|
|
} else if (arg + 1 < argc && arglen == prefixarglen && strncmp(args[arg], prefix, prefixarglen) == 0) {
|
|
|
|
++arg;
|
|
|
|
text = args[arg++];
|
|
|
|
}
|
2013-02-13 05:25:00 +00:00
|
|
|
}
|
2013-04-09 07:48:37 +00:00
|
|
|
} else {
|
|
|
|
label = &word[1];
|
|
|
|
labellen = wordlen - 2;
|
|
|
|
if (arg < argc)
|
|
|
|
text = args[arg++];
|
2013-02-13 05:25:00 +00:00
|
|
|
}
|
2013-04-09 07:48:37 +00:00
|
|
|
} else if (arg < argc && strlen(args[arg]) == wordlen && strncmp(args[arg], word, wordlen) == 0) {
|
|
|
|
simple = 1;
|
2013-02-13 05:25:00 +00:00
|
|
|
text = args[arg];
|
|
|
|
label = word;
|
|
|
|
labellen = wordlen;
|
2013-04-09 07:48:37 +00:00
|
|
|
++arg;
|
2013-02-13 05:25:00 +00:00
|
|
|
}
|
|
|
|
}
|
2013-04-09 07:48:37 +00:00
|
|
|
assert(alt > 0);
|
2013-02-13 05:25:00 +00:00
|
|
|
if (arg == oarg && !optional)
|
2013-02-12 07:30:37 +00:00
|
|
|
break;
|
2013-04-09 07:48:37 +00:00
|
|
|
if (labellen && text && (optional || !simple || alt > 1)) {
|
2013-02-13 05:25:00 +00:00
|
|
|
if (cmdpa.labelc >= NELS(cmdpa.labelv))
|
2013-04-09 07:48:37 +00:00
|
|
|
return WHYF("Internal error: commands[%d].word[%d]=\"%s\" - label limit exceeded", cmd, opt, commands[cmd].words[opt]);
|
2013-02-13 05:25:00 +00:00
|
|
|
cmdpa.labelv[cmdpa.labelc].label = label;
|
|
|
|
cmdpa.labelv[cmdpa.labelc].len = labellen;
|
|
|
|
cmdpa.labelv[cmdpa.labelc].text = text;
|
|
|
|
++cmdpa.labelc;
|
|
|
|
if (!repeating)
|
|
|
|
++opt;
|
|
|
|
} else
|
|
|
|
++opt;
|
|
|
|
}
|
2012-09-25 04:01:34 +00:00
|
|
|
}
|
2013-02-13 05:25:00 +00:00
|
|
|
//DEBUGF("cmd=%d opt=%d args[arg=%d]='%s'", cmd, opt, arg, arg < argc ? args[arg] : "");
|
2013-04-09 07:48:37 +00:00
|
|
|
if (!pattern && arg == argc) {
|
2012-09-25 04:01:34 +00:00
|
|
|
/* A match! We got through the command definition with no internal errors and all literal
|
2013-04-09 07:48:37 +00:00
|
|
|
args matched and we have a proper number of args. If we have multiple matches, then note
|
|
|
|
that the call is ambiguous. */
|
2013-02-12 07:30:37 +00:00
|
|
|
if (matched_cmd >= 0)
|
|
|
|
++ambiguous;
|
|
|
|
if (ambiguous == 1) {
|
2013-04-09 07:48:37 +00:00
|
|
|
NOWHENCE(WHY_argv("Ambiguous command:", argc, args));
|
|
|
|
NOWHENCE(HINT("Matches the following:"));
|
|
|
|
NOWHENCE(HINT_argv(" ", argc, commands[matched_cmd].words));
|
2012-09-25 04:01:34 +00:00
|
|
|
}
|
|
|
|
if (ambiguous)
|
2013-04-09 07:48:37 +00:00
|
|
|
NOWHENCE(HINT_argv(" ", argc, commands[cmd].words));
|
2013-02-12 07:30:37 +00:00
|
|
|
matched_cmd = cmd;
|
|
|
|
*parsed = cmdpa;
|
2012-09-25 04:01:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Don't process ambiguous calls */
|
2013-02-12 07:30:37 +00:00
|
|
|
if (ambiguous)
|
2013-04-09 07:48:37 +00:00
|
|
|
return 2;
|
2012-09-25 04:01:34 +00:00
|
|
|
/* Complain if we found no matching calls */
|
2013-02-12 07:30:37 +00:00
|
|
|
if (matched_cmd < 0) {
|
2013-04-09 07:48:37 +00:00
|
|
|
if (argc)
|
|
|
|
NOWHENCE(WHY_argv("Unknown command:", argc, args));
|
|
|
|
return 1;
|
2012-09-25 04:01:34 +00:00
|
|
|
}
|
2013-04-09 07:48:37 +00:00
|
|
|
return 0;
|
2013-02-12 07:30:37 +00:00
|
|
|
}
|
2012-12-04 06:22:49 +00:00
|
|
|
|
2013-02-13 07:13:24 +00:00
|
|
|
void _debug_cli_parsed(struct __sourceloc __whence, const struct cli_parsed *parsed)
|
2013-02-12 07:30:37 +00:00
|
|
|
{
|
|
|
|
DEBUG_argv("command", parsed->argc, parsed->args);
|
|
|
|
strbuf b = strbuf_alloca(1024);
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < parsed->labelc; ++i) {
|
|
|
|
const struct labelv *lab = &parsed->labelv[i];
|
2013-02-13 05:25:00 +00:00
|
|
|
strbuf_sprintf(b, " %s=%s", alloca_toprint(-1, lab->label, lab->len), alloca_str_toprint(lab->text));
|
2013-02-12 07:30:37 +00:00
|
|
|
}
|
|
|
|
if (parsed->varargi >= 0)
|
|
|
|
strbuf_sprintf(b, " varargi=%d", parsed->varargi);
|
|
|
|
DEBUGF("parsed%s", strbuf_str(b));
|
2012-12-04 06:22:49 +00:00
|
|
|
}
|
|
|
|
|
2013-02-13 07:13:24 +00:00
|
|
|
int cli_invoke(const struct cli_parsed *parsed, void *context)
|
2012-12-04 06:22:49 +00:00
|
|
|
{
|
2013-01-03 03:46:33 +00:00
|
|
|
IN();
|
2013-03-25 01:35:26 +00:00
|
|
|
int ret = parsed->commands[parsed->cmdi].function(parsed, context);
|
2013-01-03 03:46:33 +00:00
|
|
|
RETURN(ret);
|
2013-02-16 17:47:24 +00:00
|
|
|
OUT();
|
2012-09-25 04:01:34 +00:00
|
|
|
}
|
|
|
|
|
2013-02-14 05:30:47 +00:00
|
|
|
int _cli_arg(struct __sourceloc __whence, const struct cli_parsed *parsed, char *label, const char **dst, int (*validator)(const char *arg), char *defaultvalue)
|
2012-09-25 04:01:34 +00:00
|
|
|
{
|
2013-02-12 07:30:37 +00:00
|
|
|
int labellen = strlen(label);
|
|
|
|
if (dst)
|
|
|
|
*dst = defaultvalue;
|
2012-09-25 04:01:34 +00:00
|
|
|
int i;
|
2013-02-12 07:30:37 +00:00
|
|
|
for (i = 0; i < parsed->labelc; ++i) {
|
|
|
|
if (parsed->labelv[i].len == labellen && strncasecmp(label, parsed->labelv[i].label, labellen) == 0) {
|
2013-02-13 05:25:00 +00:00
|
|
|
const char *value = parsed->labelv[i].text;
|
2012-09-25 04:01:34 +00:00
|
|
|
if (validator && !(*validator)(value))
|
2013-02-14 05:30:47 +00:00
|
|
|
return WHYF("Invalid '%s' argument \"%s\"", label, value);
|
2013-02-12 07:30:37 +00:00
|
|
|
if (dst)
|
|
|
|
*dst = value;
|
2012-09-25 04:01:34 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* No matching valid argument was found, so return default value. It might seem that this should
|
|
|
|
never happen, but it can because more than one version of a command line option may exist, one
|
|
|
|
with a given argument and another without, and allowing a default value means we can have a
|
|
|
|
single function handle both in a fairly simple manner. */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int cli_lookup_did(const char *text)
|
|
|
|
{
|
|
|
|
return text[0] == '\0' || strcmp(text, "*") == 0 || str_is_did(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
int cli_absolute_path(const char *arg)
|
|
|
|
{
|
|
|
|
return arg[0] == '/' && arg[1] != '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
int cli_optional_sid(const char *arg)
|
|
|
|
{
|
|
|
|
return !arg[0] || str_is_subscriber_id(arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
int cli_optional_bundle_key(const char *arg)
|
|
|
|
{
|
|
|
|
return !arg[0] || rhizome_str_is_bundle_key(arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
int cli_manifestid(const char *arg)
|
|
|
|
{
|
|
|
|
return rhizome_str_is_manifest_id(arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
int cli_fileid(const char *arg)
|
|
|
|
{
|
|
|
|
return rhizome_str_is_file_hash(arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
int cli_optional_bundle_crypt_key(const char *arg)
|
|
|
|
{
|
|
|
|
return !arg[0] || rhizome_str_is_bundle_crypt_key(arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
int cli_uint(const char *arg)
|
|
|
|
{
|
|
|
|
register const char *s = arg;
|
2013-02-15 09:03:44 +00:00
|
|
|
while (isdigit(*s))
|
|
|
|
++s;
|
2012-09-25 04:01:34 +00:00
|
|
|
return s != arg && *s == '\0';
|
|
|
|
}
|
|
|
|
|
2013-04-22 06:31:38 +00:00
|
|
|
int cli_interval_ms(const char *arg)
|
|
|
|
{
|
|
|
|
return str_to_uint64_interval_ms(arg, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2012-09-25 04:01:34 +00:00
|
|
|
int cli_optional_did(const char *text)
|
|
|
|
{
|
|
|
|
return text[0] == '\0' || str_is_did(text);
|
|
|
|
}
|