User Tools

Site Tools


docs:cli_parser

This is an old revision of the document!


CLI parser

Data structure is a lookup tree.

Each node is structured as such:

arg_node
char* full_name
char* quick_name
size_t nb_leaves
arg_node **leaves
void (*callback)(void)

The command parser works as such:

arg_node cfg_root = ....;
 
arg_node *cfg_cur = cfg_root;
 
void process_cmd( arg_node *cfg_cur, const char* command)
{
    arg = ...;
 
    if( leaves != null )
    {
        for( size_t i=0; i<cfg_cur->nb_leaves; ++i)
        {
            if( strncmp( cfg_cur->quick_name, arg, strlen(cfg_cur->quick_name))
            {
            }
        }
    }
}
docs/cli_parser.1601539732.txt.gz · Last modified: 2020/10/01 10:08 by root

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki