53 lines
1.4 KiB
C
53 lines
1.4 KiB
C
|
/**
|
||
|
* @PROJECT CGI Bash Shell Interface
|
||
|
* @COPYRIGHT See COPYING in the top level directory
|
||
|
* @FILE subshell.h
|
||
|
* @PURPOSE Subshell execution
|
||
|
* @DEVELOPERS Nathan Angelacos <nangel@users.sourceforge.net>
|
||
|
* Rafal Kupiec <belliash@asiotec.eu.org>
|
||
|
*/
|
||
|
|
||
|
#ifndef __SUBSHELL_H
|
||
|
#define __SUBSHELL_H
|
||
|
|
||
|
static int subshell_pid;
|
||
|
static int subshell_pipe[2];
|
||
|
|
||
|
enum pipe_t { PARENT_IN, PARENT_OUT };
|
||
|
enum tag_t { HTML, RUN, ECHO, TRANSLATE, NOOP };
|
||
|
|
||
|
typedef struct {
|
||
|
char* name;
|
||
|
int size;
|
||
|
uid_t uid;
|
||
|
gid_t gid;
|
||
|
char* buf;
|
||
|
size_t curpos;
|
||
|
void* next;
|
||
|
} script_t;
|
||
|
|
||
|
typedef struct {
|
||
|
script_t* script;
|
||
|
enum tag_t tag;
|
||
|
size_t len;
|
||
|
char* buf;
|
||
|
void* next;
|
||
|
} token_t;
|
||
|
|
||
|
token_t* build_token_list(script_t* scriptbuf, token_t* tokenlist);
|
||
|
void free_script_list(script_t* script);
|
||
|
void free_token_list(token_t* tokenlist);
|
||
|
script_t* load_script(char* filename, script_t* scriptlist);
|
||
|
void preprocess_token_list(token_t* tokenlist);
|
||
|
token_t* process_token_list(buffer_t* buf, token_t* tokenlist);
|
||
|
token_t* push_token_on_list(token_t* tokenlist, script_t* scriptbuf, char* start, size_t len);
|
||
|
void subshell_destroy(void);
|
||
|
void subshell_doscript(buffer_t* script, char* name);
|
||
|
void subshell_echo(buffer_t* buf, char* str, size_t len);
|
||
|
void subshell_eval(buffer_t* buf, char* str, size_t len);
|
||
|
void subshell_exec(buffer_t* buf, char* str);
|
||
|
void subshell_setup(char* shell, list_t* env);
|
||
|
void subshell_translate(buffer_t* buf, char* str, size_t len);
|
||
|
|
||
|
#endif
|