mirror of
https://git.openwrt.org/project/uci.git
synced 2025-12-20 00:53:58 +08:00
remove plugin support, it has been unused for a long time and should not be used for any new code
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
This commit is contained in:
@@ -6,10 +6,9 @@ SET(CMAKE_INSTALL_PREFIX /usr)
|
||||
|
||||
ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -I. -DUCI_PREFIX="${CMAKE_INSTALL_PREFIX}")
|
||||
|
||||
OPTION(UCI_PLUGIN_SUPPORT "plugin support" ON)
|
||||
OPTION(UCI_DEBUG "debugging support" OFF)
|
||||
OPTION(UCI_DEBUG_TYPECAST "typecast debugging support" OFF)
|
||||
OPTION(BUILD_LUA "build Lua plugin" ON)
|
||||
OPTION(BUILD_LUA "build Lua binding" ON)
|
||||
|
||||
CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/uci_config.h.in ${CMAKE_SOURCE_DIR}/uci_config.h )
|
||||
|
||||
|
||||
8
cli.c
8
cli.c
@@ -27,7 +27,6 @@ static enum {
|
||||
CLI_FLAG_NOCOMMIT = (1 << 2),
|
||||
CLI_FLAG_BATCH = (1 << 3),
|
||||
CLI_FLAG_SHOW_EXT = (1 << 4),
|
||||
CLI_FLAG_NOPLUGINS= (1 << 5),
|
||||
} flags;
|
||||
|
||||
static FILE *input;
|
||||
@@ -147,7 +146,6 @@ static void uci_usage(void)
|
||||
"\t-c <path> set the search path for config files (default: /etc/config)\n"
|
||||
"\t-d <str> set the delimiter for list values in uci show\n"
|
||||
"\t-f <file> use <file> as input instead of stdin\n"
|
||||
"\t-L do not load any plugins\n"
|
||||
"\t-m when importing, merge data into an existing package\n"
|
||||
"\t-n name unnamed sections on export (default)\n"
|
||||
"\t-N don't name unnamed sections\n"
|
||||
@@ -664,9 +662,6 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case 'L':
|
||||
flags |= CLI_FLAG_NOPLUGINS;
|
||||
break;
|
||||
case 'm':
|
||||
flags |= CLI_FLAG_MERGE;
|
||||
break;
|
||||
@@ -712,9 +707,6 @@ int main(int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(flags & CLI_FLAG_NOPLUGINS))
|
||||
uci_load_plugins(ctx, NULL);
|
||||
|
||||
ret = uci_cmd(argc - 1, argv + 1);
|
||||
if (input != stdin)
|
||||
fclose(input);
|
||||
|
||||
111
libuci.c
111
libuci.c
@@ -37,8 +37,6 @@ static const char *uci_errstr[] = {
|
||||
[UCI_ERR_UNKNOWN] = "Unknown error",
|
||||
};
|
||||
|
||||
static void uci_unload_plugin(struct uci_context *ctx, struct uci_plugin *p);
|
||||
|
||||
#include "uci_internal.h"
|
||||
#include "list.c"
|
||||
|
||||
@@ -59,7 +57,6 @@ struct uci_context *uci_alloc_context(void)
|
||||
uci_list_init(&ctx->delta_path);
|
||||
uci_list_init(&ctx->backends);
|
||||
uci_list_init(&ctx->hooks);
|
||||
uci_list_init(&ctx->plugins);
|
||||
ctx->flags = UCI_FLAG_STRICT | UCI_FLAG_SAVED_DELTA;
|
||||
|
||||
ctx->confdir = (char *) uci_confdir;
|
||||
@@ -90,9 +87,6 @@ void uci_free_context(struct uci_context *ctx)
|
||||
uci_free_element(e);
|
||||
}
|
||||
UCI_TRAP_RESTORE(ctx);
|
||||
uci_foreach_element_safe(&ctx->root, tmp, e) {
|
||||
uci_unload_plugin(ctx, uci_to_plugin(e));
|
||||
}
|
||||
free(ctx);
|
||||
|
||||
ignore:
|
||||
@@ -232,56 +226,6 @@ int uci_load(struct uci_context *ctx, const char *name, struct uci_package **pac
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef UCI_PLUGIN_SUPPORT
|
||||
|
||||
__plugin int uci_add_backend(struct uci_context *ctx, struct uci_backend *b)
|
||||
{
|
||||
struct uci_element *e;
|
||||
UCI_HANDLE_ERR(ctx);
|
||||
|
||||
e = uci_lookup_list(&ctx->backends, b->e.name);
|
||||
if (e)
|
||||
UCI_THROW(ctx, UCI_ERR_DUPLICATE);
|
||||
|
||||
e = uci_malloc(ctx, sizeof(struct uci_backend));
|
||||
memcpy(e, b, sizeof(struct uci_backend));
|
||||
|
||||
uci_list_add(&ctx->backends, &e->list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
__plugin int uci_del_backend(struct uci_context *ctx, struct uci_backend *b)
|
||||
{
|
||||
struct uci_element *e, *tmp;
|
||||
|
||||
UCI_HANDLE_ERR(ctx);
|
||||
|
||||
e = uci_lookup_list(&ctx->backends, b->e.name);
|
||||
if (!e || uci_to_backend(e)->ptr != b->ptr)
|
||||
UCI_THROW(ctx, UCI_ERR_NOTFOUND);
|
||||
b = uci_to_backend(e);
|
||||
|
||||
if (ctx->backend && ctx->backend->ptr == b->ptr)
|
||||
ctx->backend = &uci_file_backend;
|
||||
|
||||
uci_foreach_element_safe(&ctx->root, tmp, e) {
|
||||
struct uci_package *p = uci_to_package(e);
|
||||
|
||||
if (!p->backend)
|
||||
continue;
|
||||
|
||||
if (p->backend->ptr == b->ptr)
|
||||
UCI_INTERNAL(uci_unload, ctx, p);
|
||||
}
|
||||
|
||||
uci_list_del(&b->e.list);
|
||||
free(b);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int uci_set_backend(struct uci_context *ctx, const char *name)
|
||||
{
|
||||
struct uci_element *e;
|
||||
@@ -331,58 +275,3 @@ int uci_remove_hook(struct uci_context *ctx, const struct uci_hook_ops *ops)
|
||||
}
|
||||
return UCI_ERR_NOTFOUND;
|
||||
}
|
||||
|
||||
int uci_load_plugin(struct uci_context *ctx, const char *filename)
|
||||
{
|
||||
struct uci_plugin *p;
|
||||
const struct uci_plugin_ops *ops;
|
||||
void *dlh;
|
||||
|
||||
UCI_HANDLE_ERR(ctx);
|
||||
dlh = dlopen(filename, RTLD_GLOBAL|RTLD_NOW);
|
||||
if (!dlh)
|
||||
UCI_THROW(ctx, UCI_ERR_NOTFOUND);
|
||||
|
||||
ops = dlsym(dlh, "uci_plugin");
|
||||
if (!ops || !ops->attach || (ops->attach(ctx) != 0)) {
|
||||
if (!ops)
|
||||
fprintf(stderr, "No ops\n");
|
||||
else if (!ops->attach)
|
||||
fprintf(stderr, "No attach\n");
|
||||
else
|
||||
fprintf(stderr, "Other weirdness\n");
|
||||
dlclose(dlh);
|
||||
UCI_THROW(ctx, UCI_ERR_INVAL);
|
||||
}
|
||||
|
||||
p = uci_alloc_element(ctx, plugin, filename, 0);
|
||||
p->dlh = dlh;
|
||||
p->ops = ops;
|
||||
uci_list_add(&ctx->plugins, &p->e.list);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void uci_unload_plugin(struct uci_context *ctx, struct uci_plugin *p)
|
||||
{
|
||||
if (p->ops->detach)
|
||||
p->ops->detach(ctx);
|
||||
dlclose(p->dlh);
|
||||
uci_free_element(&p->e);
|
||||
}
|
||||
|
||||
int uci_load_plugins(struct uci_context *ctx, const char *pattern)
|
||||
{
|
||||
glob_t gl;
|
||||
int i;
|
||||
|
||||
if (!pattern)
|
||||
pattern = UCI_PREFIX "/lib/uci_*.so";
|
||||
|
||||
memset(&gl, 0, sizeof(gl));
|
||||
glob(pattern, 0, NULL, &gl);
|
||||
for (i = 0; i < gl.gl_pathc; i++)
|
||||
uci_load_plugin(ctx, gl.gl_pathv[i]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
2
list.c
2
list.c
@@ -217,7 +217,7 @@ uci_free_section(struct uci_section *s)
|
||||
uci_free_element(&s->e);
|
||||
}
|
||||
|
||||
__plugin struct uci_package *
|
||||
__private struct uci_package *
|
||||
uci_alloc_package(struct uci_context *ctx, const char *name)
|
||||
{
|
||||
struct uci_package *p;
|
||||
|
||||
15
lua/uci.c
15
lua/uci.c
@@ -862,20 +862,6 @@ uci_lua_add_delta(lua_State *L)
|
||||
return uci_push_status(L, ctx, false);
|
||||
}
|
||||
|
||||
static int
|
||||
uci_lua_load_plugins(lua_State *L)
|
||||
{
|
||||
struct uci_context *ctx;
|
||||
int offset = 0;
|
||||
const char *str = NULL;
|
||||
|
||||
ctx = find_context(L, &offset);
|
||||
if (lua_isstring(L, -1))
|
||||
str = lua_tostring(L, -1);
|
||||
uci_load_plugins(ctx, str);
|
||||
return uci_push_status(L, ctx, false);
|
||||
}
|
||||
|
||||
static int
|
||||
uci_lua_set_savedir(lua_State *L)
|
||||
{
|
||||
@@ -945,7 +931,6 @@ static const luaL_Reg uci[] = {
|
||||
{ "foreach", uci_lua_foreach },
|
||||
{ "add_history", uci_lua_add_delta },
|
||||
{ "add_delta", uci_lua_add_delta },
|
||||
{ "load_plugins", uci_lua_load_plugins },
|
||||
{ "get_confdir", uci_lua_get_confdir },
|
||||
{ "set_confdir", uci_lua_set_confdir },
|
||||
{ "get_savedir", uci_lua_get_savedir },
|
||||
|
||||
39
uci.h
39
uci.h
@@ -61,7 +61,6 @@ struct uci_list
|
||||
};
|
||||
|
||||
struct uci_ptr;
|
||||
struct uci_plugin;
|
||||
struct uci_hook_ops;
|
||||
struct uci_element;
|
||||
struct uci_package;
|
||||
@@ -318,25 +317,6 @@ extern int uci_add_hook(struct uci_context *ctx, const struct uci_hook_ops *ops)
|
||||
*/
|
||||
extern int uci_remove_hook(struct uci_context *ctx, const struct uci_hook_ops *ops);
|
||||
|
||||
/**
|
||||
* uci_load_plugin: load an uci plugin
|
||||
* @ctx: uci context
|
||||
* @filename: path to the uci plugin
|
||||
*
|
||||
* NB: plugin will be unloaded automatically when the context is freed
|
||||
*/
|
||||
int uci_load_plugin(struct uci_context *ctx, const char *filename);
|
||||
|
||||
/**
|
||||
* uci_load_plugins: load all uci plugins from a directory
|
||||
* @ctx: uci context
|
||||
* @pattern: pattern of uci plugin files (optional)
|
||||
*
|
||||
* if pattern is NULL, then uci_load_plugins will call uci_load_plugin
|
||||
* for uci_*.so in <prefix>/lib/
|
||||
*/
|
||||
int uci_load_plugins(struct uci_context *ctx, const char *pattern);
|
||||
|
||||
/**
|
||||
* uci_parse_ptr: parse a uci string into a uci_ptr
|
||||
* @ctx: uci context
|
||||
@@ -387,7 +367,6 @@ enum uci_type {
|
||||
UCI_TYPE_BACKEND = 6,
|
||||
UCI_TYPE_ITEM = 7,
|
||||
UCI_TYPE_HOOK = 8,
|
||||
UCI_TYPE_PLUGIN = 9,
|
||||
};
|
||||
|
||||
enum uci_option_type {
|
||||
@@ -451,7 +430,6 @@ struct uci_context
|
||||
int bufsz;
|
||||
|
||||
struct uci_list hooks;
|
||||
struct uci_list plugins;
|
||||
};
|
||||
|
||||
struct uci_package
|
||||
@@ -540,19 +518,6 @@ struct uci_hook
|
||||
const struct uci_hook_ops *ops;
|
||||
};
|
||||
|
||||
struct uci_plugin_ops
|
||||
{
|
||||
int (*attach)(struct uci_context *ctx);
|
||||
void (*detach)(struct uci_context *ctx);
|
||||
};
|
||||
|
||||
struct uci_plugin
|
||||
{
|
||||
struct uci_element e;
|
||||
const struct uci_plugin_ops *ops;
|
||||
void *dlh;
|
||||
};
|
||||
|
||||
struct uci_parse_option {
|
||||
const char *name;
|
||||
enum uci_option_type type;
|
||||
@@ -629,7 +594,6 @@ struct uci_parse_option {
|
||||
#define uci_type_section UCI_TYPE_SECTION
|
||||
#define uci_type_option UCI_TYPE_OPTION
|
||||
#define uci_type_hook UCI_TYPE_HOOK
|
||||
#define uci_type_plugin UCI_TYPE_PLUGIN
|
||||
|
||||
/* element typecasting */
|
||||
#ifdef UCI_DEBUG_TYPECAST
|
||||
@@ -640,7 +604,6 @@ static const char *uci_typestr[] = {
|
||||
[uci_type_section] = "section",
|
||||
[uci_type_option] = "option",
|
||||
[uci_type_hook] = "hook",
|
||||
[uci_type_plugin] = "plugin",
|
||||
};
|
||||
|
||||
static void uci_typecast_error(int from, int to)
|
||||
@@ -663,7 +626,6 @@ BUILD_CAST(package)
|
||||
BUILD_CAST(section)
|
||||
BUILD_CAST(option)
|
||||
BUILD_CAST(hook)
|
||||
BUILD_CAST(plugin)
|
||||
|
||||
#else
|
||||
#define uci_to_backend(ptr) container_of(ptr, struct uci_backend, e)
|
||||
@@ -672,7 +634,6 @@ BUILD_CAST(plugin)
|
||||
#define uci_to_section(ptr) container_of(ptr, struct uci_section, e)
|
||||
#define uci_to_option(ptr) container_of(ptr, struct uci_option, e)
|
||||
#define uci_to_hook(ptr) container_of(ptr, struct uci_hook, e)
|
||||
#define uci_to_plugin(ptr) container_of(ptr, struct uci_plugin, e)
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
#cmakedefine UCI_PLUGIN_SUPPORT 1
|
||||
#cmakedefine UCI_DEBUG 1
|
||||
#cmakedefine UCI_DEBUG_TYPECAST 1
|
||||
|
||||
@@ -17,11 +17,6 @@
|
||||
|
||||
#define __private __attribute__((visibility("hidden")))
|
||||
#define __public
|
||||
#ifdef UCI_PLUGIN_SUPPORT
|
||||
#define __plugin extern
|
||||
#else
|
||||
#define __plugin __private
|
||||
#endif
|
||||
|
||||
struct uci_parse_context
|
||||
{
|
||||
@@ -43,13 +38,13 @@ struct uci_parse_context
|
||||
extern const char *uci_confdir;
|
||||
extern const char *uci_savedir;
|
||||
|
||||
__plugin void *uci_malloc(struct uci_context *ctx, size_t size);
|
||||
__plugin void *uci_realloc(struct uci_context *ctx, void *ptr, size_t size);
|
||||
__plugin char *uci_strdup(struct uci_context *ctx, const char *str);
|
||||
__plugin bool uci_validate_str(const char *str, bool name);
|
||||
__plugin void uci_add_delta(struct uci_context *ctx, struct uci_list *list, int cmd, const char *section, const char *option, const char *value);
|
||||
__plugin void uci_free_delta(struct uci_delta *h);
|
||||
__plugin struct uci_package *uci_alloc_package(struct uci_context *ctx, const char *name);
|
||||
__private void *uci_malloc(struct uci_context *ctx, size_t size);
|
||||
__private void *uci_realloc(struct uci_context *ctx, void *ptr, size_t size);
|
||||
__private char *uci_strdup(struct uci_context *ctx, const char *str);
|
||||
__private bool uci_validate_str(const char *str, bool name);
|
||||
__private void uci_add_delta(struct uci_context *ctx, struct uci_list *list, int cmd, const char *section, const char *option, const char *value);
|
||||
__private void uci_free_delta(struct uci_delta *h);
|
||||
__private struct uci_package *uci_alloc_package(struct uci_context *ctx, const char *name);
|
||||
|
||||
__private FILE *uci_open_stream(struct uci_context *ctx, const char *filename, int pos, bool write, bool create);
|
||||
__private void uci_close_stream(FILE *stream);
|
||||
@@ -130,7 +125,7 @@ extern struct uci_backend uci_file_backend;
|
||||
*
|
||||
* The default backend is "file", which uses /etc/config for config storage
|
||||
*/
|
||||
__plugin int uci_add_backend(struct uci_context *ctx, struct uci_backend *b);
|
||||
__private int uci_add_backend(struct uci_context *ctx, struct uci_backend *b);
|
||||
|
||||
/**
|
||||
* uci_add_backend: add an extra backend
|
||||
@@ -139,7 +134,7 @@ __plugin int uci_add_backend(struct uci_context *ctx, struct uci_backend *b);
|
||||
*
|
||||
* The default backend is "file", which uses /etc/config for config storage
|
||||
*/
|
||||
__plugin int uci_del_backend(struct uci_context *ctx, struct uci_backend *b);
|
||||
__private int uci_del_backend(struct uci_context *ctx, struct uci_backend *b);
|
||||
#endif
|
||||
|
||||
#define UCI_BACKEND(_var, _name, ...) \
|
||||
|
||||
8
util.c
8
util.c
@@ -31,7 +31,7 @@
|
||||
#include "uci.h"
|
||||
#include "uci_internal.h"
|
||||
|
||||
__plugin void *uci_malloc(struct uci_context *ctx, size_t size)
|
||||
__private void *uci_malloc(struct uci_context *ctx, size_t size)
|
||||
{
|
||||
void *ptr;
|
||||
|
||||
@@ -43,7 +43,7 @@ __plugin void *uci_malloc(struct uci_context *ctx, size_t size)
|
||||
return ptr;
|
||||
}
|
||||
|
||||
__plugin void *uci_realloc(struct uci_context *ctx, void *ptr, size_t size)
|
||||
__private void *uci_realloc(struct uci_context *ctx, void *ptr, size_t size)
|
||||
{
|
||||
ptr = realloc(ptr, size);
|
||||
if (!ptr)
|
||||
@@ -52,7 +52,7 @@ __plugin void *uci_realloc(struct uci_context *ctx, void *ptr, size_t size)
|
||||
return ptr;
|
||||
}
|
||||
|
||||
__plugin char *uci_strdup(struct uci_context *ctx, const char *str)
|
||||
__private char *uci_strdup(struct uci_context *ctx, const char *str)
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
@@ -68,7 +68,7 @@ __plugin char *uci_strdup(struct uci_context *ctx, const char *str)
|
||||
* for names, only alphanum and _ is allowed (shell compatibility)
|
||||
* for types, we allow more characters
|
||||
*/
|
||||
__plugin bool uci_validate_str(const char *str, bool name)
|
||||
__private bool uci_validate_str(const char *str, bool name)
|
||||
{
|
||||
if (!*str)
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user