diff options
author | Jo-Philipp Wich <jo@mein.io> | 2020-11-19 19:11:52 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2020-11-19 19:51:49 +0100 |
commit | a162cf7aadacd08eb11af072bcb9dd041866b579 (patch) | |
tree | e0a829f63600c869268d61d6fecd1663bd65c5ea /lib | |
parent | ff441aa908ad48ab5d197f4efd7d6e879fe185a2 (diff) |
treewide: rebrand to ucode
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fs.c | 130 | ||||
-rw-r--r-- | lib/math.c | 46 | ||||
-rw-r--r-- | lib/ubus.c | 54 | ||||
-rw-r--r-- | lib/uci.c | 96 |
4 files changed, 163 insertions, 163 deletions
@@ -27,12 +27,12 @@ #define err_return(err) do { last_error = err; return NULL; } while(0) -static const struct ut_ops *ops; +static const struct uc_ops *ops; static int last_error = 0; static struct json_object * -ut_fs_error(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_error(struct uc_state *s, uint32_t off, struct json_object *args) { struct json_object *errmsg; @@ -46,7 +46,7 @@ ut_fs_error(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_fs_read_common(struct ut_state *s, uint32_t off, struct json_object *args, const char *type) +uc_fs_read_common(struct uc_state *s, uint32_t off, struct json_object *args, const char *type) { struct json_object *limit = json_object_array_get_idx(args, 0); struct json_object *rv = NULL; @@ -138,7 +138,7 @@ ut_fs_read_common(struct ut_state *s, uint32_t off, struct json_object *args, co } static struct json_object * -ut_fs_write_common(struct ut_state *s, uint32_t off, struct json_object *args, const char *type) +uc_fs_write_common(struct uc_state *s, uint32_t off, struct json_object *args, const char *type) { struct json_object *data = json_object_array_get_idx(args, 0); size_t len, wsize; @@ -168,7 +168,7 @@ ut_fs_write_common(struct ut_state *s, uint32_t off, struct json_object *args, c static struct json_object * -ut_fs_pclose(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_pclose(struct uc_state *s, uint32_t off, struct json_object *args) { FILE **fp = (FILE **)ops->get_type(s->ctx, "fs.proc"); int rc; @@ -192,19 +192,19 @@ ut_fs_pclose(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_fs_pread(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_pread(struct uc_state *s, uint32_t off, struct json_object *args) { - return ut_fs_read_common(s, off, args, "fs.proc"); + return uc_fs_read_common(s, off, args, "fs.proc"); } static struct json_object * -ut_fs_pwrite(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_pwrite(struct uc_state *s, uint32_t off, struct json_object *args) { - return ut_fs_write_common(s, off, args, "fs.proc"); + return uc_fs_write_common(s, off, args, "fs.proc"); } static struct json_object * -ut_fs_popen(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_popen(struct uc_state *s, uint32_t off, struct json_object *args) { struct json_object *comm = json_object_array_get_idx(args, 0); struct json_object *mode = json_object_array_get_idx(args, 1); @@ -232,7 +232,7 @@ ut_fs_popen(struct ut_state *s, uint32_t off, struct json_object *args) static struct json_object * -ut_fs_close(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_close(struct uc_state *s, uint32_t off, struct json_object *args) { FILE **fp = (FILE **)ops->get_type(s->ctx, "fs.file"); @@ -246,19 +246,19 @@ ut_fs_close(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_fs_read(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_read(struct uc_state *s, uint32_t off, struct json_object *args) { - return ut_fs_read_common(s, off, args, "fs.file"); + return uc_fs_read_common(s, off, args, "fs.file"); } static struct json_object * -ut_fs_write(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_write(struct uc_state *s, uint32_t off, struct json_object *args) { - return ut_fs_write_common(s, off, args, "fs.file"); + return uc_fs_write_common(s, off, args, "fs.file"); } static struct json_object * -ut_fs_seek(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_seek(struct uc_state *s, uint32_t off, struct json_object *args) { struct json_object *ofs = json_object_array_get_idx(args, 0); struct json_object *how = json_object_array_get_idx(args, 1); @@ -293,7 +293,7 @@ ut_fs_seek(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_fs_tell(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_tell(struct uc_state *s, uint32_t off, struct json_object *args) { long offset; @@ -311,7 +311,7 @@ ut_fs_tell(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_fs_open(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_open(struct uc_state *s, uint32_t off, struct json_object *args) { struct json_object *path = json_object_array_get_idx(args, 0); struct json_object *mode = json_object_array_get_idx(args, 1); @@ -339,7 +339,7 @@ ut_fs_open(struct ut_state *s, uint32_t off, struct json_object *args) static struct json_object * -ut_fs_readdir(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_readdir(struct uc_state *s, uint32_t off, struct json_object *args) { DIR **dp = (DIR **)ops->get_type(s->ctx, "fs.dir"); struct dirent *e; @@ -357,7 +357,7 @@ ut_fs_readdir(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_fs_telldir(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_telldir(struct uc_state *s, uint32_t off, struct json_object *args) { DIR **dp = (DIR **)ops->get_type(s->ctx, "fs.dir"); long position; @@ -374,7 +374,7 @@ ut_fs_telldir(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_fs_seekdir(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_seekdir(struct uc_state *s, uint32_t off, struct json_object *args) { struct json_object *ofs = json_object_array_get_idx(args, 0); DIR **dp = (DIR **)ops->get_type(s->ctx, "fs.dir"); @@ -394,7 +394,7 @@ ut_fs_seekdir(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_fs_closedir(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_closedir(struct uc_state *s, uint32_t off, struct json_object *args) { DIR **dp = (DIR **)ops->get_type(s->ctx, "fs.dir"); @@ -408,7 +408,7 @@ ut_fs_closedir(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_fs_opendir(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_opendir(struct uc_state *s, uint32_t off, struct json_object *args) { struct json_object *path = json_object_array_get_idx(args, 0); struct json_object *diro; @@ -433,7 +433,7 @@ ut_fs_opendir(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_fs_readlink(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_readlink(struct uc_state *s, uint32_t off, struct json_object *args) { struct json_object *path = json_object_array_get_idx(args, 0); struct json_object *res; @@ -473,7 +473,7 @@ ut_fs_readlink(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_fs_stat_common(struct ut_state *s, uint32_t off, struct json_object *args, bool use_lstat) +uc_fs_stat_common(struct uc_state *s, uint32_t off, struct json_object *args, bool use_lstat) { struct json_object *path = json_object_array_get_idx(args, 0); struct json_object *res, *o; @@ -557,19 +557,19 @@ ut_fs_stat_common(struct ut_state *s, uint32_t off, struct json_object *args, bo } static struct json_object * -ut_fs_stat(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_stat(struct uc_state *s, uint32_t off, struct json_object *args) { - return ut_fs_stat_common(s, off, args, false); + return uc_fs_stat_common(s, off, args, false); } static struct json_object * -ut_fs_lstat(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_lstat(struct uc_state *s, uint32_t off, struct json_object *args) { - return ut_fs_stat_common(s, off, args, true); + return uc_fs_stat_common(s, off, args, true); } static struct json_object * -ut_fs_mkdir(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_mkdir(struct uc_state *s, uint32_t off, struct json_object *args) { struct json_object *path = json_object_array_get_idx(args, 0); struct json_object *mode = json_object_array_get_idx(args, 1); @@ -585,7 +585,7 @@ ut_fs_mkdir(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_fs_rmdir(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_rmdir(struct uc_state *s, uint32_t off, struct json_object *args) { struct json_object *path = json_object_array_get_idx(args, 0); @@ -599,7 +599,7 @@ ut_fs_rmdir(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_fs_symlink(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_symlink(struct uc_state *s, uint32_t off, struct json_object *args) { struct json_object *dest = json_object_array_get_idx(args, 0); struct json_object *path = json_object_array_get_idx(args, 1); @@ -615,7 +615,7 @@ ut_fs_symlink(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_fs_unlink(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_unlink(struct uc_state *s, uint32_t off, struct json_object *args) { struct json_object *path = json_object_array_get_idx(args, 0); @@ -629,7 +629,7 @@ ut_fs_unlink(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_fs_getcwd(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_getcwd(struct uc_state *s, uint32_t off, struct json_object *args) { struct json_object *res; char *buf = NULL, *tmp; @@ -664,7 +664,7 @@ ut_fs_getcwd(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_fs_chdir(struct ut_state *s, uint32_t off, struct json_object *args) +uc_fs_chdir(struct uc_state *s, uint32_t off, struct json_object *args) { struct json_object *path = json_object_array_get_idx(args, 0); @@ -677,41 +677,41 @@ ut_fs_chdir(struct ut_state *s, uint32_t off, struct json_object *args) return json_object_new_boolean(true); } -static const struct { const char *name; ut_c_fn *func; } proc_fns[] = { - { "read", ut_fs_pread }, - { "write", ut_fs_pwrite }, - { "close", ut_fs_pclose }, +static const struct { const char *name; uc_c_fn *func; } proc_fns[] = { + { "read", uc_fs_pread }, + { "write", uc_fs_pwrite }, + { "close", uc_fs_pclose }, }; -static const struct { const char *name; ut_c_fn *func; } file_fns[] = { - { "read", ut_fs_read }, - { "write", ut_fs_write }, - { "seek", ut_fs_seek }, - { "tell", ut_fs_tell }, - { "close", ut_fs_close }, +static const struct { const char *name; uc_c_fn *func; } file_fns[] = { + { "read", uc_fs_read }, + { "write", uc_fs_write }, + { "seek", uc_fs_seek }, + { "tell", uc_fs_tell }, + { "close", uc_fs_close }, }; -static const struct { const char *name; ut_c_fn *func; } dir_fns[] = { - { "read", ut_fs_readdir }, - { "seek", ut_fs_seekdir }, - { "tell", ut_fs_telldir }, - { "close", ut_fs_closedir }, +static const struct { const char *name; uc_c_fn *func; } dir_fns[] = { + { "read", uc_fs_readdir }, + { "seek", uc_fs_seekdir }, + { "tell", uc_fs_telldir }, + { "close", uc_fs_closedir }, }; -static const struct { const char *name; ut_c_fn *func; } global_fns[] = { - { "error", ut_fs_error }, - { "open", ut_fs_open }, - { "opendir", ut_fs_opendir }, - { "popen", ut_fs_popen }, - { "readlink", ut_fs_readlink }, - { "stat", ut_fs_stat }, - { "lstat", ut_fs_lstat }, - { "mkdir", ut_fs_mkdir }, - { "rmdir", ut_fs_rmdir }, - { "symlink", ut_fs_symlink }, - { "unlink", ut_fs_unlink }, - { "getcwd", ut_fs_getcwd }, - { "chdir", ut_fs_chdir }, +static const struct { const char *name; uc_c_fn *func; } global_fns[] = { + { "error", uc_fs_error }, + { "open", uc_fs_open }, + { "opendir", uc_fs_opendir }, + { "popen", uc_fs_popen }, + { "readlink", uc_fs_readlink }, + { "stat", uc_fs_stat }, + { "lstat", uc_fs_lstat }, + { "mkdir", uc_fs_mkdir }, + { "rmdir", uc_fs_rmdir }, + { "symlink", uc_fs_symlink }, + { "unlink", uc_fs_unlink }, + { "getcwd", uc_fs_getcwd }, + { "chdir", uc_fs_chdir }, }; @@ -730,7 +730,7 @@ static void close_dir(void *ud) { closedir((DIR *)ud); } -void ut_module_init(const struct ut_ops *ut, struct ut_state *s, struct json_object *scope) +void uc_module_init(const struct uc_ops *ut, struct uc_state *s, struct json_object *scope) { struct json_object *proc_proto, *file_proto, *dir_proto; @@ -19,7 +19,7 @@ #include <math.h> #include <sys/time.h> -static const struct ut_ops *ops; +static const struct uc_ops *ops; static double to_double(struct json_object *v) @@ -40,7 +40,7 @@ to_int64(struct json_object *v) } static struct json_object * -ut_abs(struct ut_state *s, uint32_t off, struct json_object *args) +uc_abs(struct uc_state *s, uint32_t off, struct json_object *args) { struct json_object *v = json_object_array_get_idx(args, 0); enum json_type t; @@ -59,7 +59,7 @@ ut_abs(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_atan2(struct ut_state *s, uint32_t off, struct json_object *args) +uc_atan2(struct uc_state *s, uint32_t off, struct json_object *args) { double d1 = to_double(json_object_array_get_idx(args, 0)); double d2 = to_double(json_object_array_get_idx(args, 1)); @@ -71,7 +71,7 @@ ut_atan2(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_cos(struct ut_state *s, uint32_t off, struct json_object *args) +uc_cos(struct uc_state *s, uint32_t off, struct json_object *args) { double d = to_double(json_object_array_get_idx(args, 0)); @@ -82,7 +82,7 @@ ut_cos(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_exp(struct ut_state *s, uint32_t off, struct json_object *args) +uc_exp(struct uc_state *s, uint32_t off, struct json_object *args) { double d = to_double(json_object_array_get_idx(args, 0)); @@ -93,7 +93,7 @@ ut_exp(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_log(struct ut_state *s, uint32_t off, struct json_object *args) +uc_log(struct uc_state *s, uint32_t off, struct json_object *args) { double d = to_double(json_object_array_get_idx(args, 0)); @@ -104,7 +104,7 @@ ut_log(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_sin(struct ut_state *s, uint32_t off, struct json_object *args) +uc_sin(struct uc_state *s, uint32_t off, struct json_object *args) { double d = to_double(json_object_array_get_idx(args, 0)); @@ -115,7 +115,7 @@ ut_sin(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_sqrt(struct ut_state *s, uint32_t off, struct json_object *args) +uc_sqrt(struct uc_state *s, uint32_t off, struct json_object *args) { double d = to_double(json_object_array_get_idx(args, 0)); @@ -126,7 +126,7 @@ ut_sqrt(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_pow(struct ut_state *s, uint32_t off, struct json_object *args) +uc_pow(struct uc_state *s, uint32_t off, struct json_object *args) { double x = to_double(json_object_array_get_idx(args, 0)); double y = to_double(json_object_array_get_idx(args, 1)); @@ -138,7 +138,7 @@ ut_pow(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_rand(struct ut_state *s, uint32_t off, struct json_object *args) +uc_rand(struct uc_state *s, uint32_t off, struct json_object *args) { struct timeval tv; @@ -153,7 +153,7 @@ ut_rand(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_srand(struct ut_state *s, uint32_t off, struct json_object *args) +uc_srand(struct uc_state *s, uint32_t off, struct json_object *args) { int64_t n = to_int64(json_object_array_get_idx(args, 0)); @@ -164,20 +164,20 @@ ut_srand(struct ut_state *s, uint32_t off, struct json_object *args) return NULL; } -static const struct { const char *name; ut_c_fn *func; } global_fns[] = { - { "abs", ut_abs }, - { "atan2", ut_atan2 }, - { "cos", ut_cos }, - { "exp", ut_exp }, - { "log", ut_log }, - { "sin", ut_sin }, - { "sqrt", ut_sqrt }, - { "pow", ut_pow }, - { "rand", ut_rand }, - { "srand", ut_srand }, +static const struct { const char *name; uc_c_fn *func; } global_fns[] = { + { "abs", uc_abs }, + { "atan2", uc_atan2 }, + { "cos", uc_cos }, + { "exp", uc_exp }, + { "log", uc_log }, + { "sin", uc_sin }, + { "sqrt", uc_sqrt }, + { "pow", uc_pow }, + { "rand", uc_rand }, + { "srand", uc_srand }, }; -void ut_module_init(const struct ut_ops *ut, struct ut_state *s, struct json_object *scope) +void uc_module_init(const struct uc_ops *ut, struct uc_state *s, struct json_object *scope) { ops = ut; @@ -23,7 +23,7 @@ #define err_return(err) do { last_error = err; return NULL; } while(0) -static const struct ut_ops *ops; +static const struct uc_ops *ops; static enum ubus_msg_status last_error = 0; @@ -34,7 +34,7 @@ struct ubus_connection { }; static struct json_object * -ut_ubus_error(struct ut_state *s, uint32_t off, struct json_object *args) +uc_ubus_error(struct uc_state *s, uint32_t off, struct json_object *args) { struct json_object *errmsg; @@ -48,10 +48,10 @@ ut_ubus_error(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_blob_to_json(struct blob_attr *attr, bool table, const char **name); +uc_blob_to_json(struct blob_attr *attr, bool table, const char **name); static struct json_object * -ut_blob_array_to_json(struct blob_attr *attr, size_t len, bool table) +uc_blob_array_to_json(struct blob_attr *attr, size_t len, bool table) { struct json_object *o = table ? json_object_new_object() : json_object_new_array(); struct json_object *v; @@ -64,7 +64,7 @@ ut_blob_array_to_json(struct blob_attr *attr, size_t len, bool table) __blob_for_each_attr(pos, attr, rem) { name = NULL; - v = ut_blob_to_json(pos, table, &name); + v = uc_blob_to_json(pos, table, &name); if (table && name) json_object_object_add(o, name, v); @@ -78,7 +78,7 @@ ut_blob_array_to_json(struct blob_attr *attr, size_t len, bool table) } static struct json_object * -ut_blob_to_json(struct blob_attr *attr, bool table, const char **name) +uc_blob_to_json(struct blob_attr *attr, bool table, const char **name) { void *data; int len; @@ -120,10 +120,10 @@ ut_blob_to_json(struct blob_attr *attr, bool table, const char **name) return json_object_new_string(data); case BLOBMSG_TYPE_ARRAY: - return ut_blob_array_to_json(data, len, false); + return uc_blob_array_to_json(data, len, false); case BLOBMSG_TYPE_TABLE: - return ut_blob_array_to_json(data, len, true); + return uc_blob_array_to_json(data, len, true); default: return NULL; @@ -132,7 +132,7 @@ ut_blob_to_json(struct blob_attr *attr, bool table, const char **name) static struct json_object * -ut_ubus_connect(struct ut_state *s, uint32_t off, struct json_object *args) +uc_ubus_connect(struct uc_state *s, uint32_t off, struct json_object *args) { struct json_object *socket = json_object_array_get_idx(args, 0); struct json_object *timeout = json_object_array_get_idx(args, 1); @@ -173,7 +173,7 @@ ut_ubus_connect(struct ut_state *s, uint32_t off, struct json_object *args) } static void -ut_ubus_signatures_cb(struct ubus_context *c, struct ubus_object_data *o, void *p) +uc_ubus_signatures_cb(struct ubus_context *c, struct ubus_object_data *o, void *p) { struct json_object *arr = p; struct json_object *sig; @@ -181,14 +181,14 @@ ut_ubus_signatures_cb(struct ubus_context *c, struct ubus_object_data *o, void * if (!o->signature) return; - sig = ut_blob_array_to_json(blob_data(o->signature), blob_len(o->signature), true); + sig = uc_blob_array_to_json(blob_data(o->signature), blob_len(o->signature), true); if (sig) json_object_array_add(arr, sig); } static void -ut_ubus_objects_cb(struct ubus_context *c, struct ubus_object_data *o, void *p) +uc_ubus_objects_cb(struct ubus_context *c, struct ubus_object_data *o, void *p) { struct json_object *arr = p; struct json_object *obj; @@ -200,7 +200,7 @@ ut_ubus_objects_cb(struct ubus_context *c, struct ubus_object_data *o, void *p) } static struct json_object * -ut_ubus_list(struct ut_state *s, uint32_t off, struct json_object *args) +uc_ubus_list(struct uc_state *s, uint32_t off, struct json_object *args) { struct ubus_connection **c = (struct ubus_connection **)ops->get_type(s->ctx, "ubus.connection"); struct json_object *objname = json_object_array_get_idx(args, 0); @@ -220,7 +220,7 @@ ut_ubus_list(struct ut_state *s, uint32_t off, struct json_object *args) rv = ubus_lookup((*c)->ctx, objname ? json_object_get_string(objname) : NULL, - objname ? ut_ubus_signatures_cb : ut_ubus_objects_cb, + objname ? uc_ubus_signatures_cb : uc_ubus_objects_cb, res); if (rv != UBUS_STATUS_OK) @@ -230,15 +230,15 @@ ut_ubus_list(struct ut_state *s, uint32_t off, struct json_object *args) } static void -ut_ubus_call_cb(struct ubus_request *req, int type, struct blob_attr *msg) +uc_ubus_call_cb(struct ubus_request *req, int type, struct blob_attr *msg) { struct json_object **res = (struct json_object **)req->priv; - *res = msg ? ut_blob_array_to_json(blob_data(msg), blob_len(msg), true) : NULL; + *res = msg ? uc_blob_array_to_json(blob_data(msg), blob_len(msg), true) : NULL; } static struct json_object * -ut_ubus_call(struct ut_state *s, uint32_t off, struct json_object *args) +uc_ubus_call(struct uc_state *s, uint32_t off, struct json_object *args) { struct ubus_connection **c = (struct ubus_connection **)ops->get_type(s->ctx, "ubus.connection"); struct json_object *objname = json_object_array_get_idx(args, 0); @@ -267,7 +267,7 @@ ut_ubus_call(struct ut_state *s, uint32_t off, struct json_object *args) err_return(rv); rv = ubus_invoke((*c)->ctx, id, json_object_get_string(funname), (*c)->buf.head, - ut_ubus_call_cb, &res, (*c)->timeout * 1000); + uc_ubus_call_cb, &res, (*c)->timeout * 1000); if (rv != UBUS_STATUS_OK) err_return(rv); @@ -276,7 +276,7 @@ ut_ubus_call(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_ubus_disconnect(struct ut_state *s, uint32_t off, struct json_object *args) +uc_ubus_disconnect(struct uc_state *s, uint32_t off, struct json_object *args) { struct ubus_connection **c = (struct ubus_connection **)ops->get_type(s->ctx, "ubus.connection"); @@ -290,15 +290,15 @@ ut_ubus_disconnect(struct ut_state *s, uint32_t off, struct json_object *args) } -static const struct { const char *name; ut_c_fn *func; } global_fns[] = { - { "error", ut_ubus_error }, - { "connect", ut_ubus_connect }, +static const struct { const char *name; uc_c_fn *func; } global_fns[] = { + { "error", uc_ubus_error }, + { "connect", uc_ubus_connect }, }; -static const struct { const char *name; ut_c_fn *func; } conn_fns[] = { - { "list", ut_ubus_list }, - { "call", ut_ubus_call }, - { "disconnect", ut_ubus_disconnect }, +static const struct { const char *name; uc_c_fn *func; } conn_fns[] = { + { "list", uc_ubus_list }, + { "call", uc_ubus_call }, + { "disconnect", uc_ubus_disconnect }, }; @@ -313,7 +313,7 @@ static void close_connection(void *ud) { free(conn); } -void ut_module_init(const struct ut_ops *ut, struct ut_state *s, struct json_object *scope) +void uc_module_init(const struct uc_ops *ut, struct uc_state *s, struct json_object *scope) { struct json_object *conn_proto; @@ -21,7 +21,7 @@ #define err_return(err) do { last_error = err; return NULL; } while(0) -static const struct ut_ops *ops; +static const struct uc_ops *ops; static int last_error = 0; @@ -32,7 +32,7 @@ enum pkg_cmd { }; static struct json_object * -ut_uci_error(struct ut_state *s, uint32_t off, struct json_object *args) +uc_uci_error(struct uc_state *s, uint32_t off, struct json_object *args) { char buf[sizeof("Unknown error: -9223372036854775808")]; struct json_object *errmsg; @@ -65,7 +65,7 @@ ut_uci_error(struct ut_state *s, uint32_t off, struct json_object *args) static struct json_object * -ut_uci_cursor(struct ut_state *s, uint32_t off, struct json_object *args) +uc_uci_cursor(struct uc_state *s, uint32_t off, struct json_object *args) { struct json_object *cdir = json_object_array_get_idx(args, 0); struct json_object *sdir = json_object_array_get_idx(args, 1); @@ -108,7 +108,7 @@ ut_uci_cursor(struct ut_state *s, uint32_t off, struct json_object *args) static struct json_object * -ut_uci_load(struct ut_state *s, uint32_t off, struct json_object *args) +uc_uci_load(struct uc_state *s, uint32_t off, struct json_object *args) { struct uci_context **c = (struct uci_context **)ops->get_type(s->ctx, "uci.cursor"); struct json_object *conf = json_object_array_get_idx(args, 0); @@ -134,7 +134,7 @@ ut_uci_load(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_uci_unload(struct ut_state *s, uint32_t off, struct json_object *args) +uc_uci_unload(struct uc_state *s, uint32_t off, struct json_object *args) { struct uci_context **c = (struct uci_context **)ops->get_type(s->ctx, "uci.cursor"); struct json_object *conf = json_object_array_get_idx(args, 0); @@ -255,7 +255,7 @@ package_to_json(struct uci_package *p) } static struct json_object * -ut_uci_get_any(struct ut_state *s, uint32_t off, struct json_object *args, bool all) +uc_uci_get_any(struct uc_state *s, uint32_t off, struct json_object *args, bool all) { struct uci_context **c = (struct uci_context **)ops->get_type(s->ctx, "uci.cursor"); struct json_object *conf = json_object_array_get_idx(args, 0); @@ -315,19 +315,19 @@ ut_uci_get_any(struct ut_state *s, uint32_t off, struct json_object *args, bool } static struct json_object * -ut_uci_get(struct ut_state *s, uint32_t off, struct json_object *args) +uc_uci_get(struct uc_state *s, uint32_t off, struct json_object *args) { - return ut_uci_get_any(s, off, args, false); + return uc_uci_get_any(s, off, args, false); } static struct json_object * -ut_uci_get_all(struct ut_state *s, uint32_t off, struct json_object *args) +uc_uci_get_all(struct uc_state *s, uint32_t off, struct json_object *args) { - return ut_uci_get_any(s, off, args, true); + return uc_uci_get_any(s, off, args, true); } static struct json_object * -ut_uci_get_first(struct ut_state *s, uint32_t off, struct json_object *args) +uc_uci_get_first(struct uc_state *s, uint32_t off, struct json_object *args) { struct uci_context **c = (struct uci_context **)ops->get_type(s->ctx, "uci.cursor"); struct json_object *conf = json_object_array_get_idx(args, 0); @@ -385,7 +385,7 @@ ut_uci_get_first(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_uci_add(struct ut_state *s, uint32_t off, struct json_object *args) +uc_uci_add(struct uc_state *s, uint32_t off, struct json_object *args) { struct uci_context **c = (struct uci_context **)ops->get_type(s->ctx, "uci.cursor"); struct json_object *conf = json_object_array_get_idx(args, 0); @@ -464,7 +464,7 @@ json_to_value(struct json_object *val, const char **p, bool *is_list) } static struct json_object * -ut_uci_set(struct ut_state *s, uint32_t off, struct json_object *args) +uc_uci_set(struct uc_state *s, uint32_t off, struct json_object *args) { struct uci_context **c = (struct uci_context **)ops->get_type(s->ctx, "uci.cursor"); struct json_object *conf = json_object_array_get_idx(args, 0); @@ -564,7 +564,7 @@ ut_uci_set(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_uci_delete(struct ut_state *s, uint32_t off, struct json_object *args) +uc_uci_delete(struct uc_state *s, uint32_t off, struct json_object *args) { struct uci_context **c = (struct uci_context **)ops->get_type(s->ctx, "uci.cursor"); struct json_object *conf = json_object_array_get_idx(args, 0); @@ -599,7 +599,7 @@ ut_uci_delete(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_uci_rename(struct ut_state *s, uint32_t off, struct json_object *args) +uc_uci_rename(struct uc_state *s, uint32_t off, struct json_object *args) { struct uci_context **c = (struct uci_context **)ops->get_type(s->ctx, "uci.cursor"); struct json_object *conf = json_object_array_get_idx(args, 0); @@ -659,7 +659,7 @@ ut_uci_rename(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_uci_reorder(struct ut_state *s, uint32_t off, struct json_object *args) +uc_uci_reorder(struct uc_state *s, uint32_t off, struct json_object *args) { struct uci_context **c = (struct uci_context **)ops->get_type(s->ctx, "uci.cursor"); struct json_object *conf = json_object_array_get_idx(args, 0); @@ -699,7 +699,7 @@ ut_uci_reorder(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_uci_pkg_command(struct ut_state *s, uint32_t off, struct json_object *args, enum pkg_cmd cmd) +uc_uci_pkg_command(struct uc_state *s, uint32_t off, struct json_object *args, enum pkg_cmd cmd) { struct uci_context **c = (struct uci_context **)ops->get_type(s->ctx, "uci.cursor"); struct json_object *conf = json_object_array_get_idx(args, 0); @@ -746,21 +746,21 @@ ut_uci_pkg_command(struct ut_state *s, uint32_t off, struct json_object *args, e } static struct json_object * -ut_uci_save(struct ut_state *s, uint32_t off, struct json_object *args) +uc_uci_save(struct uc_state *s, uint32_t off, struct json_object *args) { - return ut_uci_pkg_command(s, off, args, CMD_SAVE); + return uc_uci_pkg_command(s, off, args, CMD_SAVE); } static struct json_object * -ut_uci_commit(struct ut_state *s, uint32_t off, struct json_object *args) +uc_uci_commit(struct uc_state *s, uint32_t off, struct json_object *args) { - return ut_uci_pkg_command(s, off, args, CMD_COMMIT); + return uc_uci_pkg_command(s, off, args, CMD_COMMIT); } static struct json_object * -ut_uci_revert(struct ut_state *s, uint32_t off, struct json_object *args) +uc_uci_revert(struct uc_state *s, uint32_t off, struct json_object *args) { - return ut_uci_pkg_command(s, off, args, CMD_REVERT); + return uc_uci_pkg_command(s, off, args, CMD_REVERT); } static struct json_object * @@ -853,7 +853,7 @@ changes_to_json(struct uci_context *ctx, const char *package) } static struct json_object * -ut_uci_changes(struct ut_state *s, uint32_t off, struct json_object *args) +uc_uci_changes(struct uc_state *s, uint32_t off, struct json_object *args) { struct uci_context **c = (struct uci_context **)ops->get_type(s->ctx, "uci.cursor"); struct json_object *conf = json_object_array_get_idx(args, 0); @@ -892,7 +892,7 @@ ut_uci_changes(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_uci_foreach(struct ut_state *s, uint32_t off, struct json_object *args) +uc_uci_foreach(struct uc_state *s, uint32_t off, struct json_object *args) { struct uci_context **c = (struct uci_context **)ops->get_type(s->ctx, "uci.cursor"); struct json_object *conf = json_object_array_get_idx(args, 0); @@ -938,7 +938,7 @@ ut_uci_foreach(struct ut_state *s, uint32_t off, struct json_object *args) rv = ops->invoke(s, off, NULL, func, fnargs); /* forward exceptions from callback function */ - if (ut_is_type(rv, T_EXCEPTION)) { + if (uc_is_type(rv, T_EXCEPTION)) { json_object_put(fnargs); return rv; @@ -959,7 +959,7 @@ ut_uci_foreach(struct ut_state *s, uint32_t off, struct json_object *args) } static struct json_object * -ut_uci_configs(struct ut_state *s, uint32_t off, struct json_object *args) +uc_uci_configs(struct uc_state *s, uint32_t off, struct json_object *args) { struct uci_context **c = (struct uci_context **)ops->get_type(s->ctx, "uci.cursor"); struct json_object *a; @@ -987,28 +987,28 @@ ut_uci_configs(struct ut_state *s, uint32_t off, struct json_object *args) } -static const struct { const char *name; ut_c_fn *func; } cursor_fns[] = { - { "load", ut_uci_load }, - { "unload", ut_uci_unload }, - { "get", ut_uci_get }, - { "get_all", ut_uci_get_all }, - { "get_first", ut_uci_get_first }, - { "add", ut_uci_add }, - { "set", ut_uci_set }, - { "rename", ut_uci_rename }, - { "save", ut_uci_save }, - { "delete", ut_uci_delete }, - { "commit", ut_uci_commit }, - { "revert", ut_uci_revert }, - { "reorder", ut_uci_reorder }, - { "changes", ut_uci_changes }, - { "foreach", ut_uci_foreach }, - { "configs", ut_uci_configs }, +static const struct { const char *name; uc_c_fn *func; } cursor_fns[] = { + { "load", uc_uci_load }, + { "unload", uc_uci_unload }, + { "get", uc_uci_get }, + { "get_all", uc_uci_get_all }, + { "get_first", uc_uci_get_first }, + { "add", uc_uci_add }, + { "set", uc_uci_set }, + { "rename", uc_uci_rename }, + { "save", uc_uci_save }, + { "delete", uc_uci_delete }, + { "commit", uc_uci_commit }, + { "revert", uc_uci_revert }, + { "reorder", uc_uci_reorder }, + { "changes", uc_uci_changes }, + { "foreach", uc_uci_foreach }, + { "configs", uc_uci_configs }, }; -static const struct { const char *name; ut_c_fn *func; } global_fns[] = { - { "error", ut_uci_error }, - { "cursor", ut_uci_cursor }, +static const struct { const char *name; uc_c_fn *func; } global_fns[] = { + { "error", uc_uci_error }, + { "cursor", uc_uci_cursor }, }; @@ -1016,7 +1016,7 @@ static void close_uci(void *ud) { uci_free_context((struct uci_context *)ud); } -void ut_module_init(const struct ut_ops *ut, struct ut_state *s, struct json_object *scope) +void uc_module_init(const struct uc_ops *ut, struct uc_state *s, struct json_object *scope) { struct json_object *uci_proto; |