/* take a string and execute the function or print help */
int execute_line(char * line)
{
- command_t *cmd, *ambig;
- char *prev;
- char *next, *tmp;
- char *argv[MAXARGS];
- int i;
- int rc = 0;
-
- switch (process(line, &next, top_level, &cmd, &prev)) {
- case CMD_AMBIG:
- fprintf(stderr, "Ambiguous command \'%s\'\nOptions: ", line);
- while( (ambig = find_cmd(prev, cmd, &tmp)) ) {
- fprintf(stderr, "%s ", ambig->pc_name);
- cmd = ambig + 1;
- }
- fprintf(stderr, "\n");
- break;
- case CMD_NONE:
- fprintf(stderr, "No such command, type help\n");
- break;
- case CMD_INCOMPLETE:
- fprintf(stderr,
- "'%s' incomplete command. Use '%s x' where x is one of:\n",
- line, line);
- fprintf(stderr, "\t");
- for (i = 0; cmd->pc_sub_cmd[i].pc_name; i++) {
- fprintf(stderr, "%s ", cmd->pc_sub_cmd[i].pc_name);
- }
- fprintf(stderr, "\n");
- break;
- case CMD_COMPLETE:
- i = line2args(line, argv, MAXARGS);
- rc = (cmd->pc_func)(i, argv);
-
- if (rc == CMD_HELP)
- fprintf(stderr, "%s\n", cmd->pc_help);
-
- break;
- }
+ command_t *cmd, *ambig;
+ char *prev;
+ char *next, *tmp;
+ char *argv[MAXARGS];
+ int i;
+ int rc = 0;
+
+ switch (process(line, &next, top_level, &cmd, &prev)) {
+ case CMD_AMBIG:
+ fprintf(stderr, "Ambiguous command \'%s\'\nOptions: ", line);
+ while ((ambig = find_cmd(prev, cmd, &tmp))) {
+ fprintf(stderr, "%s ", ambig->pc_name);
+ cmd = ambig + 1;
+ }
+ fprintf(stderr, "\n");
+ break;
+ case CMD_NONE:
+ fprintf(stderr, "No such command, type help\n");
+ break;
+ case CMD_INCOMPLETE:
+ fprintf(stderr, "'%s' incomplete command. Use '%s x' where "
+ "x is one of:\n", line, line);
+ fprintf(stderr, "\t");
+ for (i = 0; cmd->pc_sub_cmd[i].pc_name; i++)
+ fprintf(stderr, "%s ", cmd->pc_sub_cmd[i].pc_name);
+ fprintf(stderr, "\n");
+ break;
+ case CMD_COMPLETE:
+ optind = 0;
+ i = line2args(line, argv, MAXARGS);
+ rc = (cmd->pc_func)(i, argv);
+
+ if (rc == CMD_HELP)
+ fprintf(stderr, "%s\n", cmd->pc_help);
+
+ break;
+ }
- return rc;
+ return rc;
}
#ifdef HAVE_LIBREADLINE
struct cYAML *err_rc = NULL;
bool load_mod_params = false;
int rc, opt;
- optind = 0;
const char *const short_options = "ah";
const struct option long_options[] = {
{
struct cYAML *err_rc = NULL;
int rc;
- optind = 0;
if (handle_help(lnet_cmds, "lnet", "unconfigure", argc, argv) == 0)
return 0;
long int hop = -1, prio = -1;
struct cYAML *err_rc = NULL;
int rc, opt;
- optind = 0;
const char *const short_options = "n:g:c:p:h";
const struct option long_options[] = {
long int pto = -1, pc = -1, pbc = -1, cre = -1;
struct cYAML *err_rc = NULL;
int rc, opt;
- optind = 0;
const char *const short_options = "n:i:p:t:c:b:r:s:h";
const struct option long_options[] = {
char *network = NULL, *gateway = NULL;
struct cYAML *err_rc = NULL;
int rc, opt;
- optind = 0;
const char *const short_options = "n:g:h";
const struct option long_options[] = {
char *network = NULL;
struct cYAML *err_rc = NULL;
int rc, opt;
- optind = 0;
const char *const short_options = "n:h";
const struct option long_options[] = {
long int hop = -1, prio = -1;
int detail = 0, rc, opt;
struct cYAML *err_rc = NULL, *show_rc = NULL;
- optind = 0;
const char *const short_options = "n:g:h:p:vh";
const struct option long_options[] = {
char *network = NULL;
int detail = 0, rc, opt;
struct cYAML *err_rc = NULL, *show_rc = NULL;
- optind = 0;
const char *const short_options = "n:vh";
const struct option long_options[] = {
{
int rc;
struct cYAML *show_rc = NULL, *err_rc = NULL;
- optind = 0;
if (handle_help(credits_cmds, "peer_credits", "show", argc, argv) == 0)
return 0;
struct cYAML *err_rc = NULL;
struct cYAML *show_rc = NULL;
int rc = 0, opt, opt_found = 0;
- optind = 0;
char cmd = 'a';
const char *const short_options = "adsh";
struct cYAML *err_rc = NULL;
int rc, opt;
FILE *f = NULL;
- optind = 0;
const char *const short_options = "h";
const struct option long_options[] = {
if (strcmp(argv[0], "migrate") == 0)
migrate_mode = true;
- optind = 0;
while ((c = getopt_long(argc, argv, "c:di:o:p:s:S:",
long_opts, NULL)) >= 0) {
switch (c) {
time(&t);
- optind = 0;
/* when getopt_long_only() hits '!' it returns 1, puts "!" in optarg */
while ((c = getopt_long_only(argc, argv,
"-A:c:C:D:g:G:i:L:m:M:n:O:Ppqrs:S:t:u:U:v",
int c, rc;
param->fp_max_depth = 1;
- optind = 0;
while ((c = getopt_long(argc, argv, "cdDghiLMoO:pqrRsSv",
long_opts, NULL)) != -1) {
switch (c) {
{0, 0, 0, 0}
};
- optind = 0;
-
while ((c = getopt_long(argc, argv, "c:Di:m:t:", long_opts,
NULL)) >= 0) {
switch (c) {
{0, 0, 0, 0}
};
- optind = 0;
while ((c = getopt_long(argc, argv, "hilp:", long_opts, NULL)) != -1) {
switch (c) {
case 'i':
int rc = 0, index = 0, c;
char buf[sizeof(struct obd_uuid)];
- optind = 0;
while ((c = getopt(argc, argv, "h")) != -1)
return CMD_HELP;
memset(&qchk, 0, sizeof(qchk));
- optind = 0;
while ((c = getopt(argc, argv, "gu")) != -1) {
switch (c) {
case 'u':
memset(&qctl, 0, sizeof(qctl));
qctl.qc_cmd = LUSTRE_Q_QUOTAON;
- optind = 0;
while ((c = getopt(argc, argv, "fgu")) != -1) {
switch (c) {
case 'u':
memset(&qctl, 0, sizeof(qctl));
qctl.qc_cmd = LUSTRE_Q_QUOTAOFF;
- optind = 0;
while ((c = getopt(argc, argv, "gu")) != -1) {
switch (c) {
case 'u':
qctl.qc_cmd = LUSTRE_Q_SETINFO;
qctl.qc_type = UGQUOTA;
- optind = 0;
while ((c = getopt_long(argc, argv, "b:gi:tu", long_opts, NULL)) != -1) {
switch (c) {
case 'u':
* so it can be used as a marker that qc_type
* isn't reinitialized from command line */
- optind = 0;
while ((c = getopt_long(argc, argv, "b:B:g:i:I:u:", long_opts, NULL)) != -1) {
switch (c) {
case 'u':
__u64 total_ialloc = 0, total_balloc = 0;
bool human_readable = false;
- optind = 0;
while ((c = getopt(argc, argv, "gi:I:o:qtuvh")) != -1) {
switch (c) {
case 'u':
int index = 0;
int rc = 0;
- optind = 0;
while ((c = getopt(argc, argv, "k")) != -1) {
switch (c) {
case 'k':
char short_opts[] = "f";
int rc, follow = 0;
- optind = 0;
while ((rc = getopt_long(argc, argv, short_opts,
long_opts, NULL)) != -1) {
switch (rc) {
int printcur = 0;
int rc = 0;
- optind = 0;
-
while ((rc = getopt_long(argc, argv, short_opts,
long_opts, NULL)) != -1) {
switch (rc) {
int rc = 0;
bool show_parents = false;
- optind = 0;
while ((rc = getopt_long(argc, argv, short_opts,
long_opts, NULL)) != -1) {
switch (rc) {
if (argc < 2)
return CMD_HELP;
- optind = 0;
while ((c = getopt(argc, argv, "nrw")) != -1) {
switch (c) {
case 'n':
if (argc < 3)
return CMD_HELP;
- optind = 0;
while ((c = getopt_long(argc, argv, short_opts,
long_opts, NULL)) != -1) {
switch (c) {
if (argc < 2)
return CMD_HELP;
- optind = 0;
while ((c = getopt_long(argc, argv, short_opts,
long_opts, NULL)) != -1) {
switch (c) {
{0, 0, 0, 0}
};
- optind = 0;
while ((c = getopt_long(argc, argv, "b:c:d:D:m:n:t:v",
long_opts, NULL)) >= 0) {
switch (c) {