CGI Bash Shell Interface
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

subshell.h 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * @PROJECT CGI Bash Shell Interface
  3. * @COPYRIGHT See COPYING in the top level directory
  4. * @FILE subshell.h
  5. * @PURPOSE Subshell execution
  6. * @DEVELOPERS Nathan Angelacos <nangel@users.sourceforge.net>
  7. * Rafal Kupiec <belliash@asiotec.eu.org>
  8. */
  9. #ifndef __SUBSHELL_H
  10. #define __SUBSHELL_H
  11. static int subshell_pid;
  12. static int subshell_pipe[2];
  13. enum pipe_t { PARENT_IN, PARENT_OUT };
  14. enum tag_t { HTML, RUN, ECHO, TRANSLATE, NOOP };
  15. typedef struct {
  16. char* name;
  17. int size;
  18. uid_t uid;
  19. gid_t gid;
  20. char* buf;
  21. size_t curpos;
  22. void* next;
  23. } script_t;
  24. typedef struct {
  25. script_t* script;
  26. enum tag_t tag;
  27. size_t len;
  28. char* buf;
  29. void* next;
  30. } token_t;
  31. token_t* build_token_list(script_t* scriptbuf, token_t* tokenlist);
  32. void free_script_list(script_t* script);
  33. void free_token_list(token_t* tokenlist);
  34. script_t* load_script(char* filename, script_t* scriptlist);
  35. void preprocess_token_list(token_t* tokenlist);
  36. token_t* process_token_list(buffer_t* buf, token_t* tokenlist);
  37. token_t* push_token_on_list(token_t* tokenlist, script_t* scriptbuf, char* start, size_t len);
  38. void subshell_destroy(void);
  39. void subshell_doscript(buffer_t* script, char* name);
  40. void subshell_echo(buffer_t* buf, char* str, size_t len);
  41. void subshell_eval(buffer_t* buf, char* str, size_t len);
  42. void subshell_exec(buffer_t* buf, char* str);
  43. void subshell_setup(char* shell, list_t* env);
  44. void subshell_translate(buffer_t* buf, char* str, size_t len);
  45. #endif