apreq_parser.c revision 6ac28b74a504006c016d4df3fb84d2cd2e373942
/*
** Licensed to the Apache Software Foundation (ASF) under one or more
** contributor license agreements. See the NOTICE file distributed with
** this work for additional information regarding copyright ownership.
** The ASF licenses this file to You under the Apache License, Version 2.0
** (the "License"); you may not use this file except in compliance with
** the License. You may obtain a copy of the License at
**
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
#include "apreq_error.h"
#include "apreq_parser.h"
#include "apreq_util.h"
#include "apr_strings.h"
#include "apr_xml.h"
#include "apr_hash.h"
#define PARSER_STATUS_CHECK(PREFIX) do { \
return APREQ_ERROR_GENERAL; \
return APR_SUCCESS; \
return APR_INCOMPLETE; \
} while (0);
const char *content_type,
const char *temp_dir,
void *ctx)
{
p->content_type = content_type;
p->bucket_alloc = ba;
p->brigade_limit = brigade_limit;
return p;
}
void *ctx)
{
return h;
}
/*XXX this may need to check the parser's state before modifying the hook list */
apreq_hook_t *h)
{
apreq_hook_t *last = h;
p->hook = h;
return APR_SUCCESS;
}
static int default_parsers_lock = 0;
{
default_parsers_lock = 0;
return APR_SUCCESS;
}
{
if (default_parser_pool != NULL)
return APR_SUCCESS;
if (default_parsers_lock)
return APREQ_ERROR_GENERAL;
if (status != APR_SUCCESS)
return status;
return APR_SUCCESS;
}
{
(void)pool;
if (default_parser_pool == NULL)
return APREQ_ERROR_GENERAL;
default_parsers_lock = 1;
return APR_SUCCESS;
}
{
if (s != APR_SUCCESS)
return s;
return apreq_post_initialize(pool);
}
{
apreq_parser_function_t *f = NULL;
if (default_parsers == NULL)
return APR_EINIT;
return APR_EINVAL;
if (default_parsers_lock)
return APREQ_ERROR_GENERAL;
f = apr_palloc(default_parser_pool, sizeof *f);
*f = pfn;
}
APR_HASH_KEY_STRING, f);
return APR_SUCCESS;
}
{
apr_size_t tlen = 0;
return NULL;
++tlen;
if (f != NULL)
return *f;
else
return NULL;
}
{
}
{
apr_status_t s = APR_SUCCESS;
return s;
}
/* generic parser */
struct gen_ctx {
enum {
} status;
};
{
apr_status_t s = APR_SUCCESS;
unsigned saw_eos = 0;
}
while (e != APR_BRIGADE_SENTINEL(bb)) {
if (APR_BUCKET_IS_EOS(e)) {
saw_eos = 1;
break;
}
e = APR_BUCKET_PREV(e);
}
if (s != APR_SUCCESS) {
return s;
}
}
if (s != APR_SUCCESS) {
return s;
}
if (saw_eos) {
return APR_SUCCESS;
}
else
return APR_INCOMPLETE;
}
struct xml_ctx {
enum {
} status;
};
{
apr_status_t s = APR_SUCCESS;
apr_bucket *e;
}
e = APR_BUCKET_NEXT(e))
{
const char *data;
if (APR_BUCKET_IS_EOS(e)) {
if (s == APR_SUCCESS) {
}
else {
}
return s;
}
else if (APR_BUCKET_IS_METADATA(e)) {
continue;
}
if (s != APR_SUCCESS) {
return s;
}
if (s != APR_SUCCESS) {
return s;
}
}
return APR_SUCCESS;
}
{
if (is_final && s == APR_SUCCESS
}
return s;
}