parser.h File Reference
serial protocol parser and commands. More...
#include <cpu/types.h>Go to the source code of this file.
Data Structures | |
| union | parms |
| union that contains parameters passed to and from commands More... | |
| struct | CmdTemplate |
| Define a command that can be tokenized by the parser. More... | |
Defines | |
| #define | PARSER_MAX_ARGS 8 |
| Max number of arguments and results for each command. | |
Typedefs | |
| typedef ResultCode(* | CmdFuncPtr )(parms args_results[]) |
| pointer to commands | |
Enumerations | |
| enum | ResultCode { RC_ERROR = -1, RC_OK = 0, RC_REPLY = 1, RC_SKIP = 2 } |
Error generated by the commands through the return code. More... | |
Functions | |
| void | parser_init (void) |
| Initialize the parser module. | |
| void | parser_register_cmd (const struct CmdTemplate *cmd) |
| Register a new command into the parser. | |
| const char * | parser_rl_match (void *dummy, const char *word, int word_len) |
| Hook for readline to provide completion support for the commands registered in the parser. | |
| bool | parser_process_line (const char *line) |
| Command input handler. | |
| bool | parser_execute_cmd (const struct CmdTemplate *templ, parms args[PARSER_MAX_ARGS]) |
| Execute a command with its arguments, and fetch its results. | |
| struct CmdTemplate * | parser_get_cmd_template (const char *line) |
| Find the template for the command contained in the text line. | |
| bool | parser_get_cmd_arguments (const char *line, const struct CmdTemplate *templ, parms args[PARSER_MAX_ARGS]) |
| Extract the arguments for the command contained in the text line. | |
| bool | parser_get_cmd_id (const char *line, unsigned long *ID) |
| Extract the ID from the command text line. | |
Detailed Description
serial protocol parser and commands.
- Version:
- Id
- parser.h 2506 2009-04-15 08:29:07Z duplo
Definition in file parser.h.
Enumeration Type Documentation
| enum ResultCode |
Function Documentation
| bool parser_execute_cmd | ( | const struct CmdTemplate * | templ, | |
| parms | args[PARSER_MAX_ARGS] | |||
| ) | [inline] |
| bool parser_get_cmd_arguments | ( | const char * | line, | |
| const struct CmdTemplate * | templ, | |||
| parms | args[PARSER_MAX_ARGS] | |||
| ) |
Extract the arguments for the command contained in the text line.
- Parameters:
-
line Text line to be processed (ASCIIZ) templ Command template for this line args Will contain the extracted parameters
- Returns:
- True if everything OK, false in case of parsing error.
| bool parser_get_cmd_id | ( | const char * | line, | |
| unsigned long * | ID | |||
| ) |
| struct CmdTemplate* parser_get_cmd_template | ( | const char * | line | ) | [read] |
Find the template for the command contained in the text line.
The template can be used to tokenize the command and interpret it.
This function can be used to find out which command is contained in a given text line without parsing all the parameters and executing it.
- Parameters:
-
line Text line to be processed (ASCIIZ)
- Returns:
- The command template associated with the command contained in the line, or NULL if the command is invalid.
| void parser_init | ( | void | ) |
| bool parser_process_line | ( | const char * | line | ) |
Command input handler.
Process the input, calling the requested command (if found) and calling printResult() to give out the result (on device specified with parameter fd).
- Parameters:
-
line Text line to be processed (ASCIIZ)
- Returns:
- true if everything is OK, false in case of errors
| void parser_register_cmd | ( | const struct CmdTemplate * | cmd | ) |
| const char* parser_rl_match | ( | void * | dummy, | |
| const char * | word, | |||
| int | word_len | |||
| ) |
Hook for readline to provide completion support for the commands registered in the parser.
- Note:
- This is meant to be used with mware/readline.c. See the documentation there for a description of this hook.
