command_parser()

command_parser()#

Parse a command and its arguments based on a predefined command structure.

Prototype

PUBLIC int command_parser(
    const char  *command_line,
    const char  *commands[],
    int         (*callback)(const char *command, const char *args, void *user_data),
    void        *user_data
);
        

Parameters

Key

Type

Description

command_line

const char *

The full command line input to parse.

commands

const char *[]

An array of valid command strings.

callback

int (*)(const char *, const char *, void *)

A function pointer to process each parsed command and its arguments.

user_data

void *

User-defined data passed to the callback function.


Return Value

Returns 0 on success, or a negative value on failure.

Prototype

// Not applicable in JS

Prototype

# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples