interpreter.h 786 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef INTERPRETER_H
  2. #define INTERPRETER_H
  3. #include <stdbool.h>
  4. #include <unistd.h>
  5. #include <stdint.h>
  6. #include <sys/select.h>
  7. #define MAX_DATA_SIZE 4096
  8. #define PONG 0
  9. void init_readline();
  10. void set_dispatch_functions();
  11. struct session {
  12. bool cont;
  13. unsigned char cmd;
  14. char data[MAX_DATA_SIZE];
  15. uint32_t i;
  16. int fd;
  17. fd_set rset;
  18. char* string;
  19. char *argv0;
  20. int lisp_argc;
  21. char **lisp_argv;
  22. char *line_read;
  23. size_t line_read_len;
  24. size_t line_read_start;
  25. char readline_prompt[256];
  26. size_t readline_prompt_len;
  27. bool readline_prompt_fail;
  28. };
  29. typedef int (*dispatch_fun_t)(struct session *);
  30. #define NUM_COMMANDS 18
  31. extern dispatch_fun_t dispatch_functions[NUM_COMMANDS];
  32. int cmd_from_lisp(struct session *s);
  33. #endif