nicboul/DNDS — pull request #5 by sajean (2012-04-18 22:59:31+00:00)
Title: A command line interface through UNIX domain socket

This is a simple and non-intrusive command line interface API. It makes it easy for a DNDS component to register a set of commands available to a local DNDS console (dndscli) communicating through a UNIX domain socket.

Components initialize the command interpreter using cli_server_init(unix_socket_path). The API handles socket creation, communication, command execution, arguments parsing and three core commands :

1/ quit: to terminate console communication
2/ list: to send a list of registered commands to console
3/ help: to give console user a simple list of commands with short description

The component registers its own set of commands using cli_register_entry(command_list_head, module_name, command_array, command_array_size)

The commad_list_head is provided by the API through a cli_server_t structure returned by cli_server_init().

The component call cli_server_fini(cli_server_t) to terminate the command line interpreter.

Commands registered can send output to the console through a STX/ETX marker protocol. Then, a command summary is given to the console to detail command execution status.

Files setx.c and setx.h provides the STX/ETX buffer output protocol.
Files usocket.c and usocket.h implements the UNIX domain socket part.
Files cli.c and cli.h contains the command line interface API, core commands and wrappers to the setx and usocket API leaving the component to deal only with the CLI API.