static signed long get_personality(const char *name, const char *lxcpath) { char *p = lxc_cmd_get_config_item(name, "lxc.arch", lxcpath); signed long ret; if (!p) return -1; ret = lxc_config_parse_arch(p); free(p); return ret; }
static int cmd_get_config_item(lua_State *L) { int arg_cnt = lua_gettop(L); const char *name = luaL_checkstring(L, 1); const char *key = luaL_checkstring(L, 2); const char *lxcpath = NULL; char *value; if (arg_cnt > 2) lxcpath = luaL_checkstring(L, 3); value = lxc_cmd_get_config_item(name, key, lxcpath); if (!value) goto not_found; lua_pushstring(L, value); return 1; not_found: lua_pushnil(L); return 1; }