summaryrefslogtreecommitdiffstats
path: root/src/h_script.h
blob: de49ff5c314f8a8dceb9a253da5b7866b3aa8eca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* --------------------------------------------------------------------------
 * Copyright 2003-2011 (inclusive) Nathan Angelacos 
 *                   (nangel@users.sourceforge.net)
 * 
 *   This file is part of haserl.
 *
 *   Haserl is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License version 2,
 *   as published by the Free Software Foundation.
 *
 *   Haserl is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with haserl.  If not, see <http://www.gnu.org/licenses/>.
 *
 * ------------------------------------------------------------------------ */

#ifndef H_SCRIPT_H
#define H_SCRIPT_H	1


/* Everything we care to know about a script */
typedef struct {
	char 	*name; 		/* pointer to name of script 	*/
	int	size;		/* size of script in bytes 	*/	
 	uid_t	uid;		/* user owner			*/
	gid_t	gid;		/* group owner			*/
	char 	*buf;	 /* pointer to malloc'ed buffer	*/
	size_t	curpos;		/* current position in buffer	*/	
	void    *next;		/* next script in our chain     */
	} script_t;

/* tag types */
#ifdef BASHEXTENSIONS
enum tag_t { HTML, RUN, INCLUDE, EVAL, COMMENT, IF, ELIF, ELSE, ENDIF, CASE, WHEN, OTHERWISE, ENDCASE, WHILE, ENDWHILE, UNTIL, ENDUNTIL, FOR, ENDFOR, UNLESS, ELUN, UNELSE, ENDUNLESS, NOOP };
#else
enum tag_t { HTML, RUN, INCLUDE, EVAL, COMMENT, NOOP };
#endif


/* token structure */
typedef struct {
	script_t 	*script;	/* the parent script		*/
	enum tag_t	tag;		/* the token type		*/
	size_t		len;		/* length of token		*/
	char		*buf;		/* pointer to start of token	*/
	void		*next;		/* the next token in the chain	*/
	} token_t;



/* h_script.c */
script_t *load_script(char *filename, script_t *scriptlist);
void free_script_list(script_t *script);
token_t *push_token_on_list(token_t *tokenlist, script_t *scriptbuf, char *start, size_t len);
void free_token_list(token_t *tokenlist);

#ifndef JUST_LUACSHELL

token_t *build_token_list(script_t *scriptbuf, token_t *tokenlist);
void preprocess_token_list(token_t *tokenlist);
token_t *process_token_list(buffer_t *buf, token_t *tokenlist);

#endif

#endif /* !H_SCRIPT_H */