static const struct cmd_struct *
parse_command_token(const char *arg, const struct cmd_group *grp)
{
	const struct cmd_struct *cmd = NULL;

	switch(parse_one_token(arg, grp, &cmd)) {
	case -1:
		help_unknown_token(arg, grp);
	case -2:
		help_ambiguous_token(arg, grp);
	}

	return cmd;
}
Exemple #2
0
//
// breaks up a format string into its parts and returns a list of them
LIST *decompose_parse_format(const char *format) {
  const char  *fmt = format; 
  bool       error = FALSE;
  LIST *token_list = newList();

  // try to parse all of our format down into tokens
  while(*fmt != '\0' && !error) {
    PARSE_TOKEN *token = parse_one_token(&fmt);

    // did the token parse OK?
    if(token != NULL)
      listQueue(token_list, token);
    else
      error = TRUE;
  }

  // did we encounter an error?
  if(error == TRUE) {
    deleteListWith(token_list, deleteParseToken);
    token_list = NULL;
  }

  return token_list;
}