2 * luaplugin - fast lua plugin indexing
3 * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2
7 * as published by the Free Software Foundation
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
23 struct luaplugin_entry {
24 struct luaplugin_ctx *ctx;
25 struct list_head list;
33 /* privdata for the caller */
37 struct luaplugin_ctx {
39 const struct luaplugin_ops *ops;
42 struct list_head *last;
43 struct list_head entries;
47 * initialize the luaplugin context (allocates a new lua context)
49 extern int luaplugin_init(struct luaplugin_ctx *ctx, const char *path);
52 * rescan the plugin cache
54 extern void luaplugin_scan(struct luaplugin_ctx *ctx);
57 * call out to a lua function.
58 * to be able to use this, you need to push the function name on the lua stack (ctx->L)
59 * and then narg function arguments afterwards.
60 * this call pops (narg + 1) arguments from the stack
61 * returns -ENOENT if the function was not found
63 extern int luaplugin_call(struct luaplugin_entry *e, int narg);
66 * drop the luaplugin context (and associated lua context)
67 * frees all memory allocated by the library
69 extern void luaplugin_done(struct luaplugin_ctx *ctx);