uCmd
Simple command parser for microcontrollers
ucmd.h File Reference

uCmd source file More...

#include <limits.h>
Include dependency graph for ucmd.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Command
 simple struct to hold data for a single command More...

Defines

#define UCMD_CMD_NOT_FOUND   INT_MIN
 return value when no command match is found
#define UCMD_DEFAULT_DELIMETER   " "
 default delimeter to use if given NULL

Typedefs

typedef int(* Command_cb )(int, char *[])
 type for command callback functions

Functions

int ucmd_parse (Command[], const char *, const char *)
 Parse a command string and match against a Command List.

Detailed Description

uCmd source file

This file declares Command_cb() and Command types for use with ucmd_parse()

Author:
Dan Fekete <thefekete@gmail.com>
Date:
March 13, 2015

Definition in file ucmd.h.


Data Structure Documentation

struct Command

simple struct to hold data for a single command

Definition at line 36 of file ucmd.h.

Data Fields
const char * cmd the command string to match against
Command_cb fn the function to call when cmd is matched
const char * help the help text associated with cmd

Define Documentation

#define UCMD_CMD_NOT_FOUND   INT_MIN

return value when no command match is found

Definition at line 19 of file ucmd.h.

#define UCMD_DEFAULT_DELIMETER   " "

default delimeter to use if given NULL

Definition at line 22 of file ucmd.h.


Typedef Documentation

typedef int(* Command_cb)(int, char *[])

type for command callback functions

See Command callback functions for more information

Parameters:
intnumber of arguments (argc style)
char*[]array of strings (argv style)
Returns:
whatever you want (except UCMD_CMD_NOT_FOUND)

Definition at line 33 of file ucmd.h.


Function Documentation

int ucmd_parse ( Command  cmd_list[],
const char *  delim,
const char *  in 
)

Parse a command string and match against a Command List.

Parameters:
cmd_lista Command array (see the Command List section for more info)
delima null terminated string used to split the command string
ina null terminated command string to parse
Returns:
if a command is found, returns commands return code. Otherwise, returns UCMD_CMD_NOT_FOUND for unmatched command or 0 for an empty or NULL command string.

Definition at line 28 of file ucmd.c.

 All Data Structures Files Functions Variables Typedefs Defines