blob: 4019e7bcaf230b3ebcd6ac500ee0efb16881ff32 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include "config.h"
#include "lauxlib.h"
#include "lualib.h"
int pow_open_config(pow_config *cfg, char *path) {
int err;
cfg->L = luaL_newstate();
if (!cfg->L) {
return 1;
}
lua_State *L = cfg->L; // just easier to access
luaL_openlibs(L);
err = luaL_loadfile(L, path);
if (err) {
return 1;
}
err = lua_pcall(L, 0, 0, 0);
if (err) {
printf("%s\n", lua_tostring(L, -1));
return 1;
}
return 0;
}
|