···22 io.close(f)
23end
2425+function HWLIB.printf(...)
26+ local function wrapper(...) io.write(string.format(...)) end
27+ local status, result = pcall(wrapper, ...)
28+ if not status then error(result, 2) end
29end
···1+/* Copyright (C) 2012-2015 Papavasileiou Dimitris
2+ *
3+ * Permission is hereby granted, free of charge, to any person
4+ * obtaining a copy of this software and associated documentation
5+ * files (the "Software"), to deal in the Software without
6+ * restriction, including without limitation the rights to use, copy,
7+ * modify, merge, publish, distribute, sublicense, and/or sell copies
8+ * of the Software, and to permit persons to whom the Software is
9+ * furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice shall be
12+ * included in all copies or substantial portions of the Software.
13+ *
14+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+ * SOFTWARE.
22+ */
23+24+#ifndef _PROMPT_H_
25+#define _PROMPT_H_
26+27+#include <lualib.h>
28+#include <lauxlib.h>
29+30+#define HAVE_LIBREADLINE
31+#define HAVE_READLINE_HISTORY
32+#define HAVE_IOCTL
33+#define COMPLETE_KEYWORDS
34+#define COMPLETE_MODULES
35+#define COMPLETE_TABLE_KEYS
36+#define COMPLETE_METATABLE_KEYS
37+#define COMPLETE_FILE_NAMES
38+39+#define LUAP_VERSION "0.6"
40+41+void luap_setprompts(lua_State *L, const char *single, const char *multi);
42+void luap_sethistory(lua_State *L, const char *file);
43+void luap_setname(lua_State *L, const char *name);
44+void luap_setcolor(lua_State *L, int enable);
45+46+void luap_getprompts(lua_State *L, const char **single, const char **multi);
47+void luap_gethistory(lua_State *L, const char **file);
48+void luap_getcolor(lua_State *L, int *enabled);
49+void luap_getname(lua_State *L, const char **name);
50+51+void luap_enter(lua_State *L, bool *terminate);
52+char *luap_describe (lua_State *L, int index);
53+int luap_call (lua_State *L, int n);
54+55+#endif