Subversion Repositories Games.Descent

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * This file is part of the DXX-Rebirth project <https://www.dxx-rebirth.com/>.
  3.  * It is copyright by its individual contributors, as recorded in the
  4.  * project's Git history.  See COPYING.txt at the top level for license
  5.  * terms and a link to the Git history.
  6.  *
  7.  */
  8. /*
  9.  *
  10.  * Command parsing and processing
  11.  *
  12.  */
  13.  
  14. #pragma once
  15. #include "dxxsconf.h"
  16.  
  17. void cmd_init(void);
  18.  
  19. /* Maximum length for a single command */
  20. #define CMD_MAX_LENGTH 2048
  21. /* Maximum number of tokens per command */
  22. #define CMD_MAX_TOKENS 64
  23.  
  24. /* Add some commands to the queue to be executed */
  25. void cmd_enqueue(int insert, const char *input);
  26. __attribute_format_printf(2, 3)
  27. void cmd_enqueuef(int insert, const char *fmt, ...);
  28. #define cmd_append(input) cmd_enqueue(0, (input))
  29. #define cmd_appendf(...) cmd_enqueuef(0, __VA_ARGS__)
  30. #define cmd_insert(input) cmd_enqueue(1, (input))
  31. #define cmd_insertf(...) cmd_enqueuef(1, __VA_ARGS__)
  32.  
  33. /* Execute pending commands */
  34. int cmd_queue_process(void);
  35.  
  36. /* execute until there are no commands left */
  37. void cmd_queue_flush(void);
  38.  
  39. /* Attempt to autocomplete an input string */
  40. const char *cmd_complete(const char *input);
  41.  
  42. typedef void (*cmd_handler_t)(unsigned long argc, const char *const *argv);
  43.  
  44. void cmd_addcommand(const char *cmd_name, cmd_handler_t cmd_func, const char *cmd_help_text);
  45.