2 * LuCI Template - Parser header
4 * Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 #ifndef _TEMPLATE_PARSER_H_
20 #define _TEMPLATE_PARSER_H_
34 #define T_READBUFSZ 1024
35 #define T_OUTBUFSZ T_READBUFSZ * 3
38 #define T_STATE_TEXT_INIT 0
39 #define T_STATE_TEXT_NEXT 1
40 #define T_STATE_CODE_INIT 2
41 #define T_STATE_CODE_NEXT 3
42 #define T_STATE_SKIP 4
45 #define T_FLAG_EOF 0x01
46 #define T_FLAG_SKIPWS 0x02
48 /* tokens used in matching and expression generation */
49 #define T_TOK_START "<%"
50 #define T_TOK_END "%>"
51 #define T_TOK_SKIPWS "-"
54 #define T_GEN_START 0x01
55 #define T_GEN_END 0x02
59 #define T_TYPE_COMMENT 1
61 #define T_TYPE_INCLUDE 3
63 #define T_TYPE_I18N_RAW 5
67 struct template_parser {
74 char buf[T_READBUFSZ];
79 const char *template_reader(lua_State *L, void *ud, size_t *sz);