Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only load apteryx API for XML files #30

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions alfred.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int luaopen_apteryx (lua_State *L);
int lua_apteryx_close (lua_State *L);
bool lua_apteryx_instance_lock (lua_State *L);
void lua_apteryx_instance_unlock (lua_State *L);
static lua_State *alfred_new_instance(const char *key);
static lua_State *alfred_new_instance(const char *key, bool api_required);

static void
alfred_error (lua_State *ls, int res)
Expand Down Expand Up @@ -714,7 +714,7 @@ load_config_files (alfred_instance alfred, const char *path)
}
rewinddir (dir);

lua_State *instance = alfred_new_instance ("xml-default");
lua_State *instance = alfred_new_instance ("xml-default", true);

/* Load all XML files */
for (entry = readdir (dir); entry; entry = readdir (dir))
Expand Down Expand Up @@ -788,7 +788,7 @@ load_script_files (alfred_instance alfred, const char *path)
{
char *filename = g_strdup_printf ("%s%s", path, entry->d_name);
int error;
lua_State *instance = alfred_new_instance (filename);
lua_State *instance = alfred_new_instance (filename, false);

DEBUG ("ALFRED: Load Lua file \"%s\"\n", filename);

Expand Down Expand Up @@ -1006,7 +1006,7 @@ after_quiet (lua_State *ls)


static lua_State *
alfred_new_instance (const char *key)
alfred_new_instance (const char *key, bool api_required)
{
/* Initialise the Lua state */
lua_State *instance = luaL_newstate ();
Expand Down Expand Up @@ -1037,7 +1037,7 @@ alfred_new_instance (const char *key)
/* Load the apteryx-xml API if available
api = require("apteryx.xml").api("/etc/apteryx/schema/")
*/
if (luaL_dostring (instance, "require('api')") != 0)
if (api_required && luaL_dostring (instance, "require('api')") != 0)
{
ERROR ("ALFRED: Failed to require('api')\n");
}
Expand Down
Loading