| 284 | |
| 285 | |
| 286 | static int ll_loadfunc (lua_State *L, const char *path, const char *sym) { |
| 287 | void *reg = ll_checkclib(L, path); /* check loaded C libraries */ |
| 288 | if (reg == NULL) { /* must load library? */ |
| 289 | reg = ll_load(L, path, *sym == '*'); |
| 290 | if (reg == NULL) return ERRLIB; /* unable to load library */ |
| 291 | ll_addtoclib(L, path, reg); |
| 292 | } |
| 293 | if (*sym == '*') { /* loading only library (no function)? */ |
| 294 | lua_pushboolean(L, 1); /* return 'true' */ |
| 295 | return 0; /* no errors */ |
| 296 | } |
| 297 | else { |
| 298 | lua_CFunction f = ll_sym(L, reg, sym); |
| 299 | if (f == NULL) |
| 300 | return ERRFUNC; /* unable to find function */ |
| 301 | lua_pushcfunction(L, f); /* else create new function */ |
| 302 | return 0; /* no errors */ |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | |
| 307 | static int ll_loadlib (lua_State *L) { |
no test coverage detected