nginx-0.0.1-2003-08-06-18:43:50 import

This commit is contained in:
Igor Sysoev 2003-08-06 14:43:50 +00:00
parent 7f4003a76a
commit 31ef351c23
2 changed files with 226 additions and 15 deletions

View File

@ -59,16 +59,20 @@ void ngx_destroy_pool(ngx_pool_t *pool)
free(l->alloc);
}
for (p = pool, n = pool->next; /* void */; p = n, n = n->next) {
/* we can use pool->log so we have to free() pool after all */
for (p = pool->next; p ; p = n) {
#if (NGX_DEBUG_ALLOC)
ngx_log_debug(pool->log, "free: %08x" _ p);
#endif
n = p->next;
free(p);
if (n == NULL) {
break;
}
}
#if (NGX_DEBUG_ALLOC)
ngx_log_debug(pool->log, "free: %08x" _ pool);
#endif
free(pool);
pool = NULL;
}

View File

@ -43,27 +43,234 @@ static int ngx_http_ssi_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
}
static void ngx_http_ssi_parse()
static int ngx_http_ssi_parse()
{
for ( ) {
ctx
new_hunk = 1;
looked = ctx->looked;
state = ctx->state;
while (p < h->last) {
ch = *p++;
switch (state) {
case ssi_start_state:
/* tight loop */
while (p < h->last) {
if (*p++ == '<') {
state = ssi_comment_state;
length = 1;
break;
if (new_hunk) {
if (looked) {
send looked hunk
}
new_hunk = 0;
}
/* fall through */
/* tight loop */
for ( ;; ) {
if (ch == '<') {
state = ssi_tag_state;
looked = 1;
break;
}
if (p < h->last) {
state = ssi_start_state;
looked = 0;
break;
}
ch = *p++;
}
case ssi_comment_state:
break;
case ssi_tag_state:
switch (ch) {
case '!':
state = ssi_comment0_state;
looked = 2;
break;
case '<':
break;
default:
state = ssi_start_state;
looked = 0;
break;
}
break;
case ssi_comment0_state:
switch (ch) {
case '-':
state = ssi_comment1_state;
looked = 3;
break;
case '<':
state = ssi_tag_state;
looked = 1;
break;
default:
state = ssi_start_state;
looked = 0;
break;
}
break;
case ssi_comment1_state:
switch (ch) {
case '-':
state = ssi_sharp_state;
looked = 4;
break;
case '<':
state = ssi_tag_state;
looked = 1;
break;
default:
state = ssi_start_state;
looked = 0;
break;
}
break;
case ssi_sharp_state:
switch (ch) {
case '#':
state = ssi_precommand_state;
looked = 0;
break;
case '<':
state = ssi_tag_state;
looked = 1;
break;
default:
state = ssi_start_state;
looked = 0;
break;
}
break;
case ssi_precommand_state:
switch (ch) {
case ' ':
case CR:
case LF:
case '\t':
break;
default:
ngx_test_null(ctx->command.data,
ngx_palloc(r->pool, NGX_SSI_COMMAND_LEN),
NGX_ERROR);
ctx->command.data[0] = ch;
ctx->command.len = 1;
state = ssi_command_state;
break;
}
break;
case ssi_command_state:
if ((ch >= 'a' && ch =< 'z') || (ch >= 'A' && ch <= 'Z')
|| (ch == '_') || (ch >= '0' && ch <= '9'))
{
ctx->command.data[ctx->command.len++] = ch;
} else if (ch == ' ' || ch == CR || ch == LF || ch == '\t') {
state = ssi_postcommand_state;
#if 0
} else if (ch == '=') {
state = ssi_preexpression_state;
#endif
} else {
return NGX_SSI_PARSE_INVALID_COMMAND;
}
break;
case ssi_postcommand_state:
switch (ch) {
case ' ':
case CR:
case LF:
case '\t':
break;
case '=':
state = ssi_preexpression_state;
break;
default:
return NGX_SSI_PARSE_INVALID_PARAM;
}
break;
case ssi_preexpression_state:
switch (ch) {
case ' ':
case CR:
case LF:
case '\t':
break;
case '"':
state = ssi_expression_state;
break;
default:
return NGX_SSI_PARSE_INVALID_PARAM;
}
break;
case ssi_expression_state:
switch (ch) {
case '\':
state = ssi_quote_state;
break;
case '"':
state = ssi_expression_state;
break;
default:
return NGX_SSI_PARSE_INVALID_PARAM;
}
break;
case ssi_quote_state:
state = ssi_expression_state;
break;
}
}
ctx->state = state;
ctx->looked = looked;
send hunk (size - looked);
return;
}