3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "lua_api/l_base.h"
26 class ModApiUtil : public ModApiBase
31 The functions in this module are available in the in-game API
32 as well as in the mainmenu API.
34 All functions that don't require either a Server or
35 GUIEngine instance should be in here.
39 // Writes a line to the logger.
40 // The one-argument version logs to infostream.
41 // The two-argument version accepts a log level.
42 static int l_log(lua_State *L);
44 // get us precision time
45 static int l_get_us_time(lua_State *L);
47 // parse_json(str[, nullvalue])
48 static int l_parse_json(lua_State *L);
50 // write_json(data[, styled])
51 static int l_write_json(lua_State *L);
53 // get_dig_params(groups, tool_capabilities[, time_from_last_punch])
54 static int l_get_dig_params(lua_State *L);
56 // get_hit_params(groups, tool_capabilities[, time_from_last_punch])
57 static int l_get_hit_params(lua_State *L);
59 // check_password_entry(name, entry, password)
60 static int l_check_password_entry(lua_State *L);
62 // get_password_hash(name, raw_password)
63 static int l_get_password_hash(lua_State *L);
66 static int l_is_yes(lua_State *L);
69 static int l_is_nan(lua_State *L);
72 static int l_get_builtin_path(lua_State *L);
74 // compress(data, method, ...)
75 static int l_compress(lua_State *L);
77 // decompress(data, method, ...)
78 static int l_decompress(lua_State *L);
81 static int l_mkdir(lua_State *L);
83 // get_dir_list(path, is_dir)
84 static int l_get_dir_list(lua_State *L);
86 // safe_file_write(path, content)
87 static int l_safe_file_write(lua_State *L);
89 // request_insecure_environment()
90 static int l_request_insecure_environment(lua_State *L);
92 // encode_base64(string)
93 static int l_encode_base64(lua_State *L);
95 // decode_base64(string)
96 static int l_decode_base64(lua_State *L);
99 static int l_get_version(lua_State *L);
102 static int l_sha1(lua_State *L);
105 static void Initialize(lua_State *L, int top);
106 static void InitializeAsync(lua_State *L, int top);
107 static void InitializeClient(lua_State *L, int top);
109 static void InitializeAsync(AsyncEngine &engine);