Added ucix_get_list and ucix_set_list function (#780)
This commit is contained in:
@@ -107,6 +107,45 @@ const char *ucix_get_option(
|
||||
return value;
|
||||
}
|
||||
|
||||
int ucix_get_list(
|
||||
char *value[254],
|
||||
struct uci_context *ctx,
|
||||
const char *p,
|
||||
const char *s,
|
||||
const char *o)
|
||||
{
|
||||
struct uci_element *e = NULL;
|
||||
int n;
|
||||
if (ucix_get_ptr(ctx, p, s, o, NULL)) {
|
||||
return 0;
|
||||
}
|
||||
if (!(ptr.flags & UCI_LOOKUP_COMPLETE)) {
|
||||
return 0;
|
||||
}
|
||||
e = ptr.last;
|
||||
switch (e->type) {
|
||||
case UCI_TYPE_OPTION:
|
||||
switch (ptr.o->type) {
|
||||
case UCI_TYPE_LIST:
|
||||
n = 0;
|
||||
uci_foreach_element(&ptr.o->v.list, e)
|
||||
{
|
||||
value[n] = e->name;
|
||||
n++;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
n = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
int ucix_get_option_int(
|
||||
struct uci_context *ctx,
|
||||
const char *p,
|
||||
@@ -145,6 +184,29 @@ void ucix_add_option(
|
||||
uci_set(ctx, &ptr);
|
||||
}
|
||||
|
||||
void ucix_set_list(
|
||||
struct uci_context *ctx,
|
||||
const char *p,
|
||||
const char *s,
|
||||
const char *o,
|
||||
char value[254][64],
|
||||
int l)
|
||||
{
|
||||
int i;
|
||||
ucix_get_ptr(ctx, p, s, o, NULL);
|
||||
uci_delete(ctx, &ptr);
|
||||
uci_save(ctx, NULL);
|
||||
for (i = 0; i < l; i++) {
|
||||
if (value[i]) {
|
||||
ucix_get_ptr(ctx, p, s, o, value[i]);
|
||||
uci_add_list(ctx, &ptr);
|
||||
} else {
|
||||
ucix_get_ptr(ctx, p, s, o, NULL);
|
||||
uci_add_list(ctx, &ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ucix_add_option_int(
|
||||
struct uci_context *ctx, const char *p, const char *s, const char *o, int t)
|
||||
{
|
||||
|
||||
@@ -24,6 +24,13 @@ BACNET_STACK_EXPORT
|
||||
const char *ucix_get_option(
|
||||
struct uci_context *ctx, const char *p, const char *s, const char *o);
|
||||
BACNET_STACK_EXPORT
|
||||
int ucix_get_list(
|
||||
char *value[254],
|
||||
struct uci_context *ctx,
|
||||
const char *p,
|
||||
const char *s,
|
||||
const char *o);
|
||||
BACNET_STACK_EXPORT
|
||||
int ucix_get_option_int(
|
||||
struct uci_context *ctx,
|
||||
const char *p,
|
||||
@@ -41,6 +48,14 @@ void ucix_add_option(
|
||||
const char *o,
|
||||
const char *t);
|
||||
BACNET_STACK_EXPORT
|
||||
BACNET_STACK_EXPORT
|
||||
void ucix_set_list(
|
||||
struct uci_context *ctx,
|
||||
const char *p,
|
||||
const char *s,
|
||||
const char *o,
|
||||
char value[254][64],
|
||||
int l);
|
||||
void ucix_add_option_int(
|
||||
struct uci_context *ctx,
|
||||
const char *p,
|
||||
|
||||
Reference in New Issue
Block a user