kb_cmdparser.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  kb_command_s

Typedefs

typedef struct kb_command_s kb_command_t

Functions

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


Typedef Documentation

typedef struct kb_command_s kb_command_t


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[] 
)

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