2 Copyright (C) 2010-2011 wpitchoune@gmail.com
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 #define LUATPL_ERROR_LUA_FILE_LOAD 1
26 #define LUATPL_ERROR_INIT 2
27 #define LUATPL_ERROR_LUA_EXECUTION 3
28 #define LUATPL_ERROR_WRONG_RETURN_TYPE 4
29 #define LUATPL_ERROR_LUA_STATE_OPEN 5
38 Generates a string which is the result of a Lua script execution.
40 The string is retrieved from the top element of the Lua stack
41 after the Lua script execution.
43 If not 'NULL' the 'init' function is called after Lua environment
44 setup and before Lua script execution. This function typically puts
45 input information for the Lua script into the stack.
47 'init_data' is passed to the second parameter of 'init' function
49 Returns the generated string on success, or NULL on error.
51 char *luatpl_generate(const char *lua,
52 int (*init) (lua_State *, void *),
54 struct luatpl_error *err);
57 Generates a file which is the result of a Lua script execution.
59 See luatpl_generate function for 'init', 'init_data', and 'err'
62 'dst_path' is the path of the generated file
64 Returns '1' on success, or '0' on error.
67 int luatpl_generate_file(const char *lua,
68 int (*init) (lua_State *, void *),
71 struct luatpl_error *err);
73 void luatpl_fprint_error(FILE *stream,
74 const struct luatpl_error *err,
76 const char *dst_path);