/* Copyright 2005-2006 Garrett Rooney. * * Licensed 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * 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. */ #ifndef ETL_COMMON_H #define ETL_COMMON_H #include "etl_template.h" typedef enum { ETL_NODE_PRINT, ETL_NODE_IF, ETL_NODE_UNLESS, ETL_NODE_FOR, ETL_NODE_LITERAL, ETL_NODE_FILTER } etl_template_node_type_t; typedef struct etl_template_node_t etl_template_node_t; typedef struct { char *var; etl_template_node_t *yes_task; etl_template_node_t *no_task; } etl_if_contents_t; typedef struct { char *var; char *arr; etl_template_node_t *task; } etl_for_contents_t; typedef struct { char *var; } etl_print_contents_t; typedef struct { char *data; } etl_literal_contents_t; typedef enum { etl_template_filter_html = 0, etl_template_filter_xml = 1, etl_template_filter_url = 2 } etl_template_filter_type_t; typedef struct { char *var; etl_template_filter_type_t filter; } etl_filter_contents_t; struct etl_template_node_t { etl_template_node_type_t type; /* note: contents with a size == sizeof (void *) are stored inline, * others get stored as a pointer so we can minimize the size * of the contents union. */ union { etl_if_contents_t *i; etl_for_contents_t *f; etl_print_contents_t p; etl_literal_contents_t l; etl_filter_contents_t *flt; } contents; etl_template_node_t *next; }; struct etl_template_t { etl_template_node_t *tree; }; typedef struct { apr_pool_t *pool; etl_template_t *tmpl; const char *error; } etl_parser_state_t; void *etl_parser_alloc (void *(*alloc_func) (size_t)); void etl_parser_parse (void *parser, int token, char *data, etl_parser_state_t *state); void etl_parser_free (void *parser, void (*free_func) (void *)); /* Force Lemon to produce the kind of symbols I want... */ #define etl_parser_parseAlloc etl_parser_alloc #define etl_parser_parseFree etl_parser_free #define etl_parser_parseTokenName etl_parser_token_name #define etl_parser_parseTrace etl_parser_trace #endif /* ETL_COMMON_H */