diff options
author | Nathan Angelacos <nangel@alpinelinux.org> | 2007-09-22 17:24:38 +0000 |
---|---|---|
committer | Nathan Angelacos <nangel@alpinelinux.org> | 2007-09-22 17:24:38 +0000 |
commit | d57abcf87f74fe83c2add23b5b38530960b854d5 (patch) | |
tree | 1df868417f6a0ff58294fc1ad292ab52224dfc7b /src | |
parent | 9f67767d2a09460155382d885043413d99018e8f (diff) | |
download | haserl-d57abcf87f74fe83c2add23b5b38530960b854d5.tar.bz2 haserl-d57abcf87f74fe83c2add23b5b38530960b854d5.tar.xz |
Merged in Comment code
Diffstat (limited to 'src')
-rw-r--r-- | src/h_bash.c | 4 | ||||
-rw-r--r-- | src/h_script.c | 60 | ||||
-rw-r--r-- | src/h_script.h | 2 | ||||
-rw-r--r-- | src/haserl.c | 16 | ||||
-rw-r--r-- | src/rfc2388.c | 13 |
5 files changed, 56 insertions, 39 deletions
diff --git a/src/h_bash.c b/src/h_bash.c index 7f6d149..80494e8 100644 --- a/src/h_bash.c +++ b/src/h_bash.c @@ -43,10 +43,6 @@ #include "h_script.h" #include "haserl.h" -#ifdef DEBUG -#include <syslog.h> -#endif - /* Local subshell variables */ static int subshell_pipe[2]; static int subshell_pid; diff --git a/src/h_script.c b/src/h_script.c index f719953..541e379 100644 --- a/src/h_script.c +++ b/src/h_script.c @@ -37,13 +37,14 @@ #include "h_bash.h" #include "haserl.h" -/* HTML, RUN, INCLUDE, EVAL NOOP }; */ +/* HTML, RUN, INCLUDE, EVAL, COMMENT, NOOP }; */ const char *g_tag[] = { "", "", "in", "=", + "#", "" }; @@ -185,10 +186,51 @@ free_token_list (token_t * tokenlist) #ifndef JUST_LUACSHELL +/* return the point in a script where the "comment" ends */ +char * +skip_comment (char *startbuf, char *endbuf) +{ + unsigned int c_lev = 1; + char *s_tag, *e_tag; + + startbuf += 2; + while (startbuf < endbuf) + { + s_tag = strstr (startbuf, open_tag); + e_tag = strstr (startbuf, close_tag); + + if (!e_tag) + { + break; + } + + if ((s_tag) && (s_tag < e_tag)) + { + c_lev++; + startbuf = s_tag + 2; + continue; + } + /* otherwise, we have an end tag first */ + c_lev--; + startbuf = e_tag; + if (c_lev == 0) + { + return (startbuf); + } + startbuf += 2; + + } + return NULL; +} + /* build a tokenchain from a script. This step just * splits a script buf into parts that are separated - * by <? ?>. If the <? ?> are out of order, then it + * by <% %>. If the <% %> are out of order, then it * flags that, but doesn't try to do anything else. + * + * For nesting comments, this function IS aware of + * the comment tag, and will try accomodate commented + * tags. Commented script never enters the token list */ token_t * build_token_list (script_t * scriptbuf, token_t * tokenlist) @@ -197,7 +239,6 @@ build_token_list (script_t * scriptbuf, token_t * tokenlist) char *start, *end, *curpos, *endpos; token_t *curtoken, *firsttoken; - curtoken = tokenlist; firsttoken = tokenlist; @@ -209,6 +250,17 @@ build_token_list (script_t * scriptbuf, token_t * tokenlist) start = strstr (curpos, open_tag); end = strstr (curpos, close_tag); + /* if this is a comment tag, the end is at the end of the comment */ + if ((start) && (memcmp (start + 2, g_tag[COMMENT], 1) == 0)) + { + end = skip_comment (start, endpos); + if (end) + { + curpos = end + 2; + continue; + } + } + if (start && !end) die_with_message (scriptbuf, start, g_err_msg[E_NO_END_MARKER], open_tag[1]); @@ -221,7 +273,6 @@ build_token_list (script_t * scriptbuf, token_t * tokenlist) && (strstr (start + 1, open_tag) < end))) die_with_message (scriptbuf, start, g_err_msg[E_NO_END_MARKER], open_tag[1]); - if (end) { /* push curpos to the start of the token */ @@ -234,7 +285,6 @@ build_token_list (script_t * scriptbuf, token_t * tokenlist) push_token_on_list (curtoken, scriptbuf, start, end - start); if (firsttoken == NULL) firsttoken = curtoken; - /* push start of token to end of token */ curpos = end + 2; } else diff --git a/src/h_script.h b/src/h_script.h index 97c9ed2..fa80b26 100644 --- a/src/h_script.h +++ b/src/h_script.h @@ -17,7 +17,7 @@ typedef struct { } script_t; /* tag types */ -enum tag_t { HTML, RUN, INCLUDE, EVAL, NOOP }; +enum tag_t { HTML, RUN, INCLUDE, EVAL, COMMENT, NOOP }; /* token structure */ diff --git a/src/haserl.c b/src/haserl.c index 96ae420..1f3737c 100644 --- a/src/haserl.c +++ b/src/haserl.c @@ -72,10 +72,6 @@ #include "h_luac.h" #endif -#ifdef DEBUG -#include <syslog.h> -#endif - #include "haserl.h" #ifndef TEMPDIR @@ -632,11 +628,6 @@ main (int argc, char *argv[]) list_t *env = NULL; - #ifdef DEBUG - openlog("haserl", LOG_NDELAY, LOG_LOCAL0); - syslog (LOG_ERR, "Haserl starting..."); - #endif - assignGlobalStartupValues(); #ifndef JUST_LUACSHELL buffer_init (&script_text); @@ -760,10 +751,6 @@ main (int argc, char *argv[]) } } - #ifdef DEBUG - syslog (LOG_ERR, "The script is going to start."); - #endif - /* build a copy of the script to send to the shell */ #ifndef JUST_LUACSHELL if (strcmp (global.shell, "luac")) @@ -796,9 +783,6 @@ main (int argc, char *argv[]) shell_destroy (); } - #ifdef DEBUG - syslog (LOG_ERR, "The script has finished."); - #endif if (global.uploadlist) { diff --git a/src/rfc2388.c b/src/rfc2388.c index 7bdb3d7..13b6987 100644 --- a/src/rfc2388.c +++ b/src/rfc2388.c @@ -43,10 +43,6 @@ #include "sliding_buffer.h" #include "rfc2388.h" -#if DEBUG -#include <syslog.h> -#endif - #include "haserl.h" void @@ -233,9 +229,6 @@ mime_exec (mime_var_t * obj, char *fifo) execv (av[0], av); /* if we get here, we had a failure. Not much we can do. * We are the child, so we can't even warn the parent */ -#ifdef DEBUG - syslog (LOG_ERR, "execv of %s failed.", global.uploadhandler); -#endif fh = open (fifo, O_RDONLY); while (read (fh, &c, 1)) { @@ -311,10 +304,6 @@ mime_var_open_target (mime_var_t * obj) die_with_message (NULL, NULL, g_err_msg[E_FILE_OPEN_FAIL], tmpname); } -/* add this to the list of things to unlink at the end */ -#include <syslog.h> - openlog ("haserl", LOG_NDELAY, LOG_LOCAL0); - curtoken = push_token_on_list (curtoken, NULL, tmpname, strlen (tmpname) + 1); if (global.uploadlist == NULL) @@ -322,8 +311,6 @@ mime_var_open_target (mime_var_t * obj) global.uploadlist = curtoken; } - syslog (LOG_ERR, "global.uploadlist is %p", global.uploadlist); - } |