2015-02-11 07:35:44 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the DXX-Rebirth project <http://www.dxx-rebirth.com/>.
|
|
|
|
* It is copyright by its individual contributors, as recorded in the
|
|
|
|
* project's Git history. See COPYING.txt at the top level for license
|
|
|
|
* terms and a link to the Git history.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Command parsing and processing
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _CMD_H_
|
|
|
|
#define _CMD_H_ 1
|
|
|
|
|
|
|
|
|
|
|
|
void cmd_init(void);
|
|
|
|
|
|
|
|
/* Maximum length for a single command */
|
|
|
|
#define CMD_MAX_LENGTH 2048
|
|
|
|
/* Maximum number of tokens per command */
|
|
|
|
#define CMD_MAX_TOKENS 64
|
|
|
|
|
|
|
|
/* Add some commands to the queue to be executed */
|
2015-02-12 06:34:18 +00:00
|
|
|
void cmd_enqueue(int insert, const char *input);
|
|
|
|
void cmd_enqueuef(int insert, const char *fmt, ...);
|
2015-02-11 07:35:44 +00:00
|
|
|
#define cmd_append(input) cmd_enqueue(0, (input))
|
|
|
|
#define cmd_appendf(...) cmd_enqueuef(0, __VA_ARGS__)
|
|
|
|
#define cmd_insert(input) cmd_enqueue(1, (input))
|
|
|
|
#define cmd_insertf(...) cmd_enqueuef(1, __VA_ARGS__)
|
|
|
|
|
|
|
|
/* Execute pending commands */
|
|
|
|
int cmd_queue_process(void);
|
|
|
|
|
|
|
|
/* execute until there are no commands left */
|
|
|
|
void cmd_queue_flush(void);
|
|
|
|
|
|
|
|
/* Attempt to autocomplete an input string */
|
2015-02-12 06:34:18 +00:00
|
|
|
const char *cmd_complete(char *input);
|
2015-02-11 07:35:44 +00:00
|
|
|
|
|
|
|
typedef void (*cmd_handler_t)(int argc, char *argv[]);
|
|
|
|
|
2015-02-12 06:34:18 +00:00
|
|
|
void cmd_addcommand(const char *cmd_name, cmd_handler_t cmd_func, const char *cmd_help_text);
|
2015-02-11 07:35:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif /* _CMD_H_ */
|