kb_cmdparser.c File Reference

This module provides basic command parsing facilities. More...

Include dependency graph for kb_cmdparser.c:

Go to the source code of this file.

Defines

#define ARGV_SIZE   128

Functions

char * kb_get_arg (char *cmd, unsigned arg)
int kb_parse_command (char *line, kb_command_t *cmds, void *data)
int kb_find_command (const char *cmd_name, const kb_command_t *cmd_list)
int kb_find_string (const char *str, const char **list)


Detailed Description

This module provides basic command parsing facilities.

Command Parser

Author:
Cédric Gaudin (K-Team SA)
Note:
Copyright (C) 2004 K-TEAM SA
Bug:
none discovered.
Todo:
nothing.

Definition in file kb_cmdparser.c.


Define Documentation

#define ARGV_SIZE   128

Maximal number of arguments

Definition at line 27 of file kb_cmdparser.c.

Referenced by kb_get_arg(), and kb_parse_command().


Function Documentation

int kb_find_command ( const char *  cmd_name,
const kb_command_t cmd_list 
)

This function finds a command in an array of command_s

Parameters:
cmd_name Pointer to the command name.
cmd_list Pointer to the array of commands.
Returns:
A value:
  • >= 0 index of the command in the array
  • KB_ERROR_UNKCMD if the command is unknown
Remarks:
The comparaison is case insensitive.

Definition at line 165 of file kb_cmdparser.c.

References KB_ERROR, KB_ERROR_UNKCMD, and kb_command_s::name.

Referenced by ksock_remove_command().

int kb_find_string ( const char *  str,
const char **  list 
)

This function finds a string in an array of strings

Parameters:
str Pointer to the string to search in the array.
list Pointer to the array of strings.
Returns:
A value:
  • >0 index of the string in the array
  • -1 no matching string found
Remarks:
The comparaison is case insensitive.

Definition at line 190 of file kb_cmdparser.c.

Referenced by kb_parse_device(), and kb_parse_modbus().

char* kb_get_arg ( char *  cmd,
unsigned  arg 
)

return the given argument from the given command string.

Parameters:
cmd the command string
arg the argument to find
Returns:
the argument or NULL

Definition at line 36 of file kb_cmdparser.c.

References ARGV_SIZE, and kb_free.

int kb_parse_command ( char *  line,
kb_command_t cmds,
void *  data 
)

This function parses a given command line and executes commands found in a given command descriptor table.

Parameters:
line Pointer to the command line.
cmds Pointer to an array of command descriptor
data Pointer to additional data that the application may need to pass to the command
Returns:
an error code:
  • <0 on error
  • 0 on success
Remarks:
All comparaison are case insensitive.

Definition at line 79 of file kb_cmdparser.c.

References ARGV_SIZE, kb_error(), KB_ERROR, KB_ERROR_CMDARGMAX, KB_ERROR_CMDARGMIN, KB_ERROR_INVAL, KB_ERROR_TOOMANYARGS, KB_ERROR_UNKCMD, and kb_command_s::name.

Referenced by kb_parse_config_file(), ksock_exec_command(), ksock_exec_command_pending(), and main().

Here is the call graph for this function:


Generated on Wed Dec 15 11:49:27 2010 for KoreBot Library by  doxygen 1.5.5