Changeset 5781

Show
Ignore:
Timestamp:
03/09/10 19:00:38 (3 years ago)
Author:
blogic
Message:

move lots of code around and rename some functions

Location:
luci2/cbi2
Files:
2 added
13 modified
2 moved

Legend:

Unmodified
Added
Removed
  • luci2/cbi2/cbi.c

    r5779 r5781  
    1818#include "json.h" 
    1919 
    20 struct cbi_property* cbi_parse_properties(struct blob_attr *prop) 
     20struct cbi_property* cbi_prop_parse(struct blob_attr *prop) 
    2121{ 
    2222    int rem = blob_len(prop); 
     
    3838} 
    3939 
    40 void cbi_add_property(struct cbi_element *e, const char *name, const char *val, int generated) 
     40void cbi_prop_add(struct cbi_element *e, const char *name, const char *val, int generated) 
    4141{ 
    4242    struct cbi_property *p = malloc(sizeof(struct cbi_property)); 
     
    4949} 
    5050 
    51 const char* cbi_find_prop(struct cbi_element *e, const char *key) 
     51const char* cbi_prop_find(struct cbi_element *e, const char *key) 
    5252{ 
    5353    struct list_head *q; 
     
    6262} 
    6363 
    64 int cbi_find_prop_int(struct cbi_element *e, char *key, int def) 
    65 { 
    66     const char *c = cbi_find_prop(e, key); 
     64int cbi_prop_find_int(struct cbi_element *e, char *key, int def) 
     65{ 
     66    const char *c = cbi_prop_find(e, key); 
    6767    if(c) 
    6868        return atoi(c); 
     
    7676        return; 
    7777    cbi_get_element_id(e->parent, buffer, file); 
    78     id = cbi_find_prop(e, "id"); 
     78    id = cbi_prop_find(e, "id"); 
    7979    if(!id && (CAPS(e) & CAP_DATA)) 
    80         id = cbi_find_prop(e, "src"); 
     80        id = cbi_prop_find(e, "src"); 
    8181    if(!id) 
    8282        return; 
     
    9090    char tmp[128]; 
    9191    char buffer[256]; 
    92     const char *id = cbi_find_prop(e, "id"); 
     92    const char *id = cbi_prop_find(e, "id"); 
    9393    if(id) 
    9494        return; 
     
    9797    if(e->w) 
    9898        if(e->w->caps & CAP_DATA) 
    99             id = cbi_find_prop(e, "src"); 
     99            id = cbi_prop_find(e, "src"); 
    100100    if(!id) 
    101         id = cbi_find_prop(e, "name"); 
     101        id = cbi_prop_find(e, "name"); 
    102102    if(id) 
    103103    { 
     
    108108        if(*b == '@') 
    109109            b++; 
    110         cbi_add_property(e, "id", b, 1); 
     110        cbi_prop_add(e, "id", b, 1); 
    111111        return; 
    112112    } 
     
    114114    snprintf(tmp, 127, "%s%d", e->widget, *count); 
    115115    tmp[127] = '\0'; 
    116     cbi_add_property(e, "id", tmp, 1); 
     116    cbi_prop_add(e, "id", tmp, 1); 
    117117    *buffer = 0; 
    118118    cbi_get_element_id(e->parent, buffer, 1); 
     
    140140    { 
    141141        struct cbi_element *e = container_of(p, struct cbi_element, list); 
    142         const char *id2 = cbi_find_prop(e, "id"); 
     142        const char *id2 = cbi_prop_find(e, "id"); 
    143143        if(id2) 
    144144        { 
     
    188188            break; 
    189189        case CBI_PROPERTY: 
    190             p = cbi_parse_properties(element); 
     190            p = cbi_prop_parse(element); 
    191191            list_add_tail(&p->list, &e->properties); 
    192192            break; 
     
    280280} 
    281281 
    282 struct cbi_file* cbi_find_file(struct cbi_ctx *ctx, const char *name) 
    283 { 
    284     struct list_head *p; 
    285  
    286     list_for_each(p, &ctx->files) 
    287     { 
    288         struct cbi_file *f = container_of(p, struct cbi_file, list); 
    289         if(!strcmp(f->file, name)) 
    290             return f; 
    291     } 
    292     return 0; 
    293 } 
    294  
    295 static struct cbi_element* cbi_resolv_element(struct cbi_element *e, char *ref) 
    296 { 
    297     char *tok; 
    298     struct cbi_element *next; 
    299     tok = strstr(ref, "."); 
    300     if(!tok) 
    301     { 
    302         const char *id = cbi_find_prop(e, "id"); 
    303         if(!strcmp(id, ref)) 
    304             return e; 
    305         else 
    306             return 0; 
    307     } 
    308     *tok = '\0'; 
    309     tok++; 
    310     next = cbi_find_element(e, tok); 
    311     if(next) 
    312         return cbi_resolv_element(next, tok); 
    313     return 0; 
    314 } 
    315  
    316 struct cbi_element* cbi_resolv(struct cbi_ctx *ctx, const char *ref) 
    317 { 
    318     struct cbi_element *ret = 0; 
    319     struct list_head *p; 
    320     list_for_each(p, &ctx->elements) 
    321     { 
    322         struct cbi_element *e2 = container_of(p, struct cbi_element, list); 
    323         char *buf = strdup(ref); 
    324         ret = cbi_resolv_element(e2, buf); 
    325         free(buf); 
    326         if(ret) 
    327             break; 
    328     } 
    329     return ret; 
    330 } 
    331  
    332 void cbi_index_verify(struct cbi_ctx *ctx, struct cbi_element *e) 
    333 { 
    334     struct list_head *p; 
    335     if(e->w->caps & CAP_TEMPLATE) 
    336         return; 
    337     widget_verify(ctx, e); 
    338     if(e->broken) 
    339         return; 
    340     list_for_each(p, &e->elements) 
    341     { 
    342         struct cbi_element *e = container_of(p, struct cbi_element, list); 
    343         cbi_index_verify(ctx, e); 
    344     } 
    345 } 
    346  
    347 void cbi_index_add(struct cbi_ctx *ctx, struct cbi_file *f) 
    348 { 
    349     struct list_head *p; 
    350     LOG("indexing %s\n", f->name); 
    351     list_for_each(p, &f->e->elements) 
    352     { 
    353         struct cbi_element *e = container_of(p, struct cbi_element, list); 
    354         cbi_index_verify(ctx, e); 
    355         if(CAPS(e) & CAP_PAGE) 
    356             list_add_tail(&e->index, &ctx->pages); 
    357         else if(CAPS(e) & (CAP_PACKAGE | CAP_SECTION) && !(CAPS(e) & CAP_TEMPLATE)) 
    358             list_add_tail(&e->index, &ctx->globals); 
    359         else if(CAPS(e) & (CAP_MENU)) 
    360             list_add_tail(&e->index, &ctx->menus); 
    361     } 
    362 } 
    363  
    364 void cbi_index(struct cbi_ctx *ctx) 
    365 { 
    366     struct list_head *p; 
    367     list_for_each(p, &ctx->files) 
    368     { 
    369         struct cbi_file *f = container_of(p, struct cbi_file, list); 
    370         cbi_index_add(ctx, f); 
    371     } 
    372 } 
    373  
    374 void cbi_index_remove(struct cbi_file *f) 
    375 { 
    376     struct list_head *p; 
    377     LOG("unindexing %s\n", f->name); 
    378     list_for_each(p, &f->e->elements) 
    379     { 
    380         struct cbi_element *e = container_of(p, struct cbi_element, list); 
    381         list_del(&e->index); 
    382     } 
    383 } 
    384  
    385282void cbi_free_property(struct cbi_property *prop) 
    386283{ 
     
    412309} 
    413310 
    414 void cbi_free_file(struct cbi_ctx *ctx, struct cbi_file *file) 
    415 { 
    416     struct list_head *p, *q; 
    417     cbi_index_remove(file); 
    418     LOG("dropping %s\n", file->name); 
    419     list_for_each_safe(p, q, &file->e->elements) 
    420     { 
    421         struct cbi_element *e = container_of(p, struct cbi_element, list); 
    422         cbi_free_element(e); 
    423     } 
    424     free(file->name); 
    425     free(file->file); 
    426     list_del(&file->list); 
    427     list_del(&file->e->list); 
    428     free(file); 
    429 } 
    430  
    431 void cbi_free_context(struct cbi_ctx *ctx) 
    432 { 
    433     struct list_head *p, *q; 
    434     list_for_each_safe(p, q, &ctx->files) 
    435     { 
    436         struct cbi_file *f = container_of(p, struct cbi_file, list); 
    437         cbi_free_file(ctx, f); 
    438     } 
    439     free(ctx); 
    440 } 
    441  
    442 void cbi_index_flush(struct cbi_ctx *ctx) 
    443 { 
    444     INIT_LIST_HEAD(&ctx->pages); 
    445     INIT_LIST_HEAD(&ctx->globals); 
    446     INIT_LIST_HEAD(&ctx->menus); 
    447 } 
    448  
    449 int cbi_add_file(struct cbi_ctx *ctx, char *filename, int index) 
    450 { 
    451     struct stat st; 
    452     int fd, err, rem; 
    453     void *map = NULL; 
    454     struct cbi_file *f; 
    455     struct blob_attr *pos; 
    456     struct stat s; 
    457     int count = 0; 
    458     assert(ctx != NULL); 
    459     f = cbi_find_file(ctx, filename); 
    460     if(f) 
    461     { 
    462         if(!stat(filename, &s)) 
    463         { 
    464             if(f->mtime == s.st_mtime) 
    465                 return 0; 
    466             cbi_free_file(ctx, f); 
    467             f = 0; 
    468         } 
    469     } 
    470     LOG("loading %s\n", filename); 
    471     fd = open(filename, O_RDONLY); 
    472     if(fd < 0) 
    473         return fd; 
    474     err = fstat(fd, &st); 
    475     if (err < 0) 
    476         goto error; 
    477     err = -EINVAL; 
    478     if (st.st_size == 0) 
    479         goto error; 
    480     map = mmap(NULL, st.st_size, PROT_READ, MAP_FILE | MAP_PRIVATE, fd, 0); 
    481     if (map == MAP_FAILED) 
    482         goto error; 
    483     if (blob_pad_len(map) > st.st_size) 
    484         goto error; 
    485     err = -ENOMEM; 
    486     f = malloc(sizeof(struct cbi_file)); 
    487     assert(f != NULL); 
    488     memset(f, 0, sizeof(struct cbi_file)); 
    489     f->file = strdup(filename); 
    490     f->name = strdup(basename(filename)); 
    491     f->name[strlen(f->name) - 5] = '\0'; 
    492     f->mtime = st.st_mtime; 
    493     f->e = malloc(sizeof(struct cbi_element)); 
    494     memset(f->e, 0, sizeof(struct cbi_element)); 
    495     INIT_LIST_HEAD(&f->e->elements); 
    496     INIT_LIST_HEAD(&f->e->properties); 
    497     INIT_LIST_HEAD(&f->e->filters); 
    498     f->e->namespace = strdup(ctx->namespace); 
    499     f->e->widget = strdup("file"); 
    500     f->e->w = widget_find(ctx->namespace, "file"); 
    501     cbi_add_property(f->e, "src", f->name, 1); 
    502     cbi_add_property(f->e, "id", f->name, 1); 
    503     blob_for_each_attr(pos, map, rem) 
    504     { 
    505         struct cbi_element *e; 
    506         if(blob_id(pos) != CBI_ELEMENT) 
    507             continue; 
    508         e = cbi_parse_element(ctx, pos, &count, f->e); 
    509         if(e) 
    510             list_add_tail(&e->list, &f->e->elements); 
    511     } 
    512     list_add_tail(&f->e->list, &ctx->elements); 
    513     list_add_tail(&f->list, &ctx->files); 
    514     if(index) 
    515         cbi_index_add(ctx, f); 
    516     return 0; 
    517  
    518 error: 
    519     return err; 
    520 } 
    521  
    522 static inline void print_spaces(int d) 
    523 { 
    524     while(d--) 
    525         printf("\t"); 
    526 } 
    527  
    528 void cbi_dump_element(struct cbi_element *e, int depth) 
    529 { 
    530     struct list_head *p; 
    531     char nl = (!list_empty(&e->elements))?('\n'):('\0'); 
    532     if(e->broken) 
    533         return; 
    534     if(e->w->caps & CAP_TEMPLATE) 
    535         return; 
    536     print_spaces(depth); 
    537     printf("<%s:%s", e->namespace, e->widget); 
    538     list_for_each(p, &e->properties) 
    539     { 
    540         struct cbi_property *q = container_of(p, struct cbi_property, list); 
    541         printf(" %s=\"%s\"", q->key, q->value); 
    542     } 
    543     if(!nl && !e->value) 
    544         printf("/"); 
    545     printf(">%c", nl); 
    546     if(e->value) 
    547     { 
    548         if(nl) 
    549             print_spaces(depth + 1); 
    550         printf("%s%c", e->value, nl); 
    551     } 
    552     list_for_each(p, &e->elements) 
    553     { 
    554         struct cbi_element *e = container_of(p, struct cbi_element, list); 
    555         cbi_dump_element(e, depth + 1); 
    556     } 
    557     if(nl) 
    558         print_spaces(depth); 
    559     if(nl || e->value) 
    560         printf("</%s:%s>\n", e->namespace, e->widget); 
    561     else 
    562         printf("\n"); 
    563 } 
    564  
    565 void cbi_dump_list(struct list_head *h) 
    566 { 
    567     struct list_head *p; 
    568     list_for_each(p, h) 
    569     { 
    570         struct cbi_element *e = container_of(p, struct cbi_element, index); 
    571         const char *id = cbi_find_prop(e, "id"); 
    572         if(id) 
    573             printf("%s -> %s\n", e->widget, id); 
    574     } 
    575 } 
    576  
    577 void cbi_dump(struct cbi_ctx *ctx) 
    578 { 
    579     struct list_head *p; 
    580  
    581     list_for_each(p, &ctx->elements) 
    582     { 
    583         struct cbi_element *e = container_of(p, struct cbi_element, list); 
    584         cbi_dump_element(e, 0); 
    585     } 
    586     printf("pages:\n"); 
    587     cbi_dump_list(&ctx->pages); 
    588     printf("globals:\n"); 
    589     cbi_dump_list(&ctx->globals); 
    590     printf("menus:\n"); 
    591     cbi_dump_list(&ctx->menus); 
    592 } 
    593  
    594 const char* cbi_virt_path(struct cbi_ctx *ctx, const char *path, const char *file) 
    595 { 
    596     static char buf[256]; 
    597     buf[255] = '\0'; 
    598     snprintf(buf, 255, "%s%s%s", (ctx->vroot)?(ctx->vroot):(""), path, (file)?(file):("")); 
    599     return buf; 
    600 } 
    601  
    602 struct cbi_ctx* cbi_load_files(struct cbi_ctx *ctx) 
    603 { 
    604     glob_t gl; 
    605     int gl_flags = GLOB_NOESCAPE | GLOB_NOSORT | GLOB_MARK; 
    606     if(glob(cbi_virt_path(ctx, ctx->path, "*.lucio"), gl_flags, NULL, &gl) >= 0) 
    607     { 
    608         int i; 
    609         for(i = 0; i < gl.gl_pathc; i++) 
    610             cbi_add_file(ctx, gl.gl_pathv[i], 0); 
    611         globfree(&gl); 
    612     } 
    613     return ctx; 
    614 } 
    615  
    616 void cbi_check_old_files(struct cbi_ctx *ctx) 
    617 { 
    618     struct list_head *p, *q; 
    619  
    620     list_for_each_safe(p, q, &ctx->files) 
    621     { 
    622         struct cbi_file *f = container_of(p, struct cbi_file, list); 
    623         struct stat s; 
    624         if(stat(f->file, &s)) 
    625             cbi_free_file(ctx, f); 
    626     } 
    627 } 
    628  
    629 void cbi_check_new_files(struct cbi_ctx *ctx) 
    630 { 
    631     glob_t gl; 
    632     int gl_flags = GLOB_NOESCAPE | GLOB_NOSORT | GLOB_MARK; 
    633     if(glob(cbi_virt_path(ctx, ctx->path, "*.luco"), gl_flags, NULL, &gl) >= 0) 
    634     { 
    635         int i; 
    636         for(i = 0; i < gl.gl_pathc; i++) 
    637             cbi_add_file(ctx, gl.gl_pathv[i], 1); 
    638         globfree(&gl); 
    639     } 
    640 } 
    641  
    642 void cbi_check_new_files_src(struct cbi_ctx *ctx) 
    643 { 
    644     glob_t gl; 
    645     int gl_flags = GLOB_NOESCAPE | GLOB_NOSORT | GLOB_MARK; 
    646     if(glob(cbi_virt_path(ctx, ctx->path, "*.luci"), gl_flags, NULL, &gl) >= 0) 
    647     { 
    648         int i; 
    649         for(i = 0; i < gl.gl_pathc; i++) 
    650         { 
    651             char *out = strdup(gl.gl_pathv[i]); 
    652             out[strlen(out) - 1] = 'o'; 
    653             LOG("compiling %s -> %s\n", gl.gl_pathv[i], out); 
    654             if(!lucic_main(gl.gl_pathv[i], out)) 
    655             { 
    656                 LOG("deleting %s\n", gl.gl_pathv[i]); 
    657                 unlink(gl.gl_pathv[i]); 
    658             } else { 
    659                 LOG("failed\n"); 
    660             } 
    661         } 
    662         globfree(&gl); 
    663     } 
    664 } 
    665  
    666 void cbi_reindex(struct cbi_ctx *ctx) 
    667 { 
    668     cbi_check_old_files(ctx); 
    669     cbi_check_new_files_src(ctx); 
    670     cbi_check_new_files(ctx); 
    671 } 
    672  
    673 struct cbi_ctx* cbi_alloc_ctx(void) 
    674 { 
    675     struct cbi_ctx *ctx = malloc(sizeof(struct cbi_ctx)); 
    676  
    677     assert(ctx != NULL); 
    678     memset(ctx, 0, sizeof(struct cbi_ctx)); 
    679     INIT_LIST_HEAD(&ctx->files); 
    680     INIT_LIST_HEAD(&ctx->pages); 
    681     INIT_LIST_HEAD(&ctx->globals); 
    682     INIT_LIST_HEAD(&ctx->menus); 
    683     INIT_LIST_HEAD(&ctx->elements); 
    684  
    685     return ctx; 
    686 } 
    687  
    688 int cbi_dump_blob(char *file) 
    689 { 
    690     struct cbi_ctx *ctx = cbi_alloc_ctx(); 
    691     cbi_add_file(ctx, file, 0); 
    692     cbi_index(ctx); 
    693     cbi_dump(ctx); 
    694     cbi_free_context(ctx); 
    695     return 0; 
    696 } 
    697  
    698 struct cbi_ctx* cbi_init(const char *vroot, const char *path, const char *namespace) 
    699 { 
    700     struct cbi_ctx *ctx = cbi_alloc_ctx(); 
    701     ctx->path = strdup((path)?(path):("/lib/luci2/")); 
    702     ctx->namespace = strdup((namespace)?(namespace):("luci")); 
    703     if(vroot) 
    704         ctx->vroot = strdup(vroot); 
    705     validate_init(ctx); 
    706     cbi_load_files(ctx); 
    707     cbi_index(ctx); 
    708     cbi_reindex(ctx); 
    709     return ctx; 
    710 } 
    711  
    712 void cbi_request(struct cbi_ctx *ctx, char *request) 
    713 { 
    714     json_object *out, *in = json_tokener_parse(request); 
    715     if(is_error(in)) 
    716     { 
    717         printf("bad json\n"); 
    718         return; 
    719     } 
    720     out = json_request(ctx, in); 
    721     if(out) 
    722     { 
    723         printf("res -> %s\n", json_object_to_json_string(out)); 
    724         json_object_put(out); 
    725     } 
    726     json_object_put(in); 
    727 } 
     311 
  • luci2/cbi2/cbi.h

    r5780 r5781  
    150150}; 
    151151 
     152struct cbi_ctx* cbi_alloc_ctx(void); 
     153int cbi_add_file(struct cbi_ctx *ctx, char *filename, int index); 
     154void cbi_free_element(struct cbi_element *element); 
     155struct cbi_element* cbi_find_element(struct cbi_element *e, const char *id); 
     156struct cbi_element* cbi_parse_element(struct cbi_ctx *ctx, struct blob_attr *attr, int *count, struct cbi_element *parent); 
     157 
     158void cbi_index(struct cbi_ctx *ctx); 
    152159struct cbi_ctx* cbi_init(const char *vroot, const char *path, const char *namespace); 
    153160void cbi_dump(struct cbi_ctx *ctx); 
     
    155162void cbi_reindex(struct cbi_ctx *ctx); 
    156163void cbi_gen_default_id(struct cbi_element *e, int *count); 
    157 const char* cbi_find_prop(struct cbi_element *e, const char *key); 
     164 
     165const char* cbi_prop_find(struct cbi_element *e, const char *key); 
     166void cbi_prop_add(struct cbi_element *e, const char *name, const char *val, int generated); 
     167 
    158168void cbi_add_property(struct cbi_element *e, const char *name, const char *val, int generated); 
    159169void cbi_get_element_id(struct cbi_element *e, char *buffer, int file); 
  • luci2/cbi2/json.c

    r5723 r5781  
    88    struct list_head *p; 
    99    json_object *j = 0; 
    10     const char *id = cbi_find_prop(e, "id"); 
     10    const char *id = cbi_prop_find(e, "id"); 
    1111    int descend = 1; 
    1212    int container = ((CAPS(e) & CAP_CONTAINER) && (e->source)); 
     
    5151    if(!container) 
    5252    { 
    53         id = cbi_find_prop(e, "id"); 
     53        id = cbi_prop_find(e, "id"); 
    5454        json_object_object_add(q, id, j); 
    5555    } 
  • luci2/cbi2/lucic.c

    r5674 r5781  
    88#include <fcntl.h> 
    99 
    10 #include "lucip.h" 
     10#include "parser.h" 
    1111#include "lucic.h" 
    1212 
  • luci2/cbi2/Makefile

    r5780 r5781  
    88all: $(BINARY) 
    99 
    10 luci: luci.c lucic.c lucip.c uci.c json.c cbi.c source.c session.c u_sock.c validate.c uvl.c lang.c blob.c widget.c log.c handler.c validator/*.c widgets/luci/*.c sources/*.c liblmo.a 
     10luci: luci.c lucic.c parser.c uci.c json.c cbi.c cbi_dump.c cbi_core.c source.c session.c u_sock.c validate.c uvl.c lang.c blob.c widget.c log.c handler.c validator/*.c widgets/luci/*.c sources/*.c liblmo.a 
    1111    $(CC) $(CFLAGS) -o $@ $^ -luci -ljson -lcrypt  
    1212 
  • luci2/cbi2/parser.c

    r5710 r5781  
    99#include <ctype.h> 
    1010 
    11 #include "lucip.h" 
     11#include "parser.h" 
    1212#include "cbi.h" 
    1313 
  • luci2/cbi2/source.c

    r5723 r5781  
    4747static int source_detemine(struct cbi_element *e) 
    4848{ 
    49     const char *src = cbi_find_prop(e, "src"); 
     49    const char *src = cbi_prop_find(e, "src"); 
    5050    if((CAPS(e) & CAP_DEPENDENCY) && !src) 
    5151        return 0; 
  • luci2/cbi2/sources/uci.c

    r5729 r5781  
    149149{ 
    150150    struct uci_src_priv *p = malloc(sizeof(struct uci_src_priv)); 
    151     const char *src = cbi_find_prop(e, "src"); 
     151    const char *src = cbi_prop_find(e, "src"); 
    152152    const char *dot1 = 0, *dot2 = 0, *tmp = src; 
    153153    int use_parent = 0; 
     
    303303        value = uvalue = ucix_get_option(ucictx, p->package, p->section, p->option); 
    304304        if(!value) 
    305             value = cbi_find_prop(e, "default"); 
     305            value = cbi_prop_find(e, "default"); 
    306306        if(value) 
    307307            json_object_object_add(j, "value", json_object_new_string(value)); 
     
    370370    if((CAPS(e) & CAP_DEPENDENCY) != CAP_DEPENDENCY) 
    371371        return 1; 
    372     value = cbi_find_prop(e, "value"); 
     372    value = cbi_prop_find(e, "value"); 
    373373    if(!p->package || !p->section || !p->option || !value) 
    374374    { 
  • luci2/cbi2/widget.c

    r5779 r5781  
    4949    { 
    5050        if(e->w->props[i].type == PROP_REQUIRED) 
    51             if(!cbi_find_prop(e, e->w->props[i].name)) 
     51            if(!cbi_prop_find(e, e->w->props[i].name)) 
    5252            { 
    5353                CBILOG(e, "missing required property %s\n", e->w->props[i].name); 
     
    9898static int widget_abstract(struct cbi_ctx *ctx, struct cbi_element *e) 
    9999{ 
    100     const char *ref = cbi_find_prop(e, "ref"); 
     100    const char *ref = cbi_prop_find(e, "ref"); 
    101101    struct cbi_element *r; 
    102102    if(!ref) 
  • luci2/cbi2/widgets/luci/content.c

    r5780 r5781  
    99{ 
    1010    json_object *j = json_object_new_object(); 
    11     const char *css = cbi_find_prop(e, "css"); 
     11    const char *css = cbi_prop_find(e, "css"); 
    1212    json_object_object_add(j, "type", json_object_new_string("text")); 
    1313    if(css) 
     
    3636{ 
    3737    content_init(ctx, e); 
    38     cbi_add_property(e, "css", "title", 1); 
     38    cbi_prop_add(e, "css", "title", 1); 
    3939    return 0; 
    4040} 
  • luci2/cbi2/widgets/luci/field.c

    r5780 r5781  
    33int field_init(struct cbi_ctx *ctx, struct cbi_element *e) 
    44{ 
    5     const char *type = cbi_find_prop(e, "type"); 
     5    const char *type = cbi_prop_find(e, "type"); 
    66    if(!type) 
    7         cbi_add_property(e, "type", "string", 1); 
    8     type = cbi_find_prop(e, "type"); 
     7        cbi_prop_add(e, "type", "string", 1); 
     8    type = cbi_prop_find(e, "type"); 
    99    if(!(e->validate = validator_find(type))) 
    1010    { 
     
    2525{ 
    2626    json_object *j = json_object_new_object(); 
    27     const char *type = cbi_find_prop(e, "type"); 
    28     const char *def = cbi_find_prop(e, "default"); 
     27    const char *type = cbi_prop_find(e, "type"); 
     28    const char *def = cbi_prop_find(e, "default"); 
    2929    json_object_object_add(j, "type", json_object_new_string((type)?(type):("string"))); 
    3030    if(def) 
  • luci2/cbi2/widgets/luci/file.c

    r5780 r5781  
    44{ 
    55    json_object *j = json_object_new_object(); 
    6     const char *type = cbi_find_prop(e, "type"); 
     6    const char *type = cbi_prop_find(e, "type"); 
    77    json_object_object_add(j, "type", json_object_new_string((type)?(type):("package"))); 
    88    return j; 
  • luci2/cbi2/widgets/luci/icon.c

    r5780 r5781  
    33int icon_init(struct cbi_ctx *ctx, struct cbi_element *e) 
    44{ 
    5     const char *handler = cbi_find_prop(e, "handler"); 
    6     const char *link = cbi_find_prop(e, "link"); 
    7     const char *ref = cbi_find_prop(e, "ref"); 
     5    const char *handler = cbi_prop_find(e, "handler"); 
     6    const char *link = cbi_prop_find(e, "link"); 
     7    const char *ref = cbi_prop_find(e, "ref"); 
    88    if(!handler && !link && !ref) 
    99    { 
     
    2727{ 
    2828    json_object *j = json_object_new_object(); 
    29     const char *link = cbi_find_prop(e, "link"); 
    30     const char *ref = cbi_find_prop(e, "ref"); 
    31     const char *confirm = cbi_find_prop(e, "confirm"); 
    32     const char *icon = cbi_find_prop(e, "icon"); 
     29    const char *link = cbi_prop_find(e, "link"); 
     30    const char *ref = cbi_prop_find(e, "ref"); 
     31    const char *confirm = cbi_prop_find(e, "confirm"); 
     32    const char *icon = cbi_prop_find(e, "icon"); 
    3333    json_object_object_add(j, "type", json_object_new_string("icon")); 
    3434    if(link) 
  • luci2/cbi2/widgets/luci/menu.c

    r5780 r5781  
    1010int menu_init(struct cbi_ctx *ctx, struct cbi_element *e) 
    1111{ 
    12     const char *tag = cbi_find_prop(e, "name"); 
     12    const char *tag = cbi_prop_find(e, "name"); 
    1313    if(!tag) 
    14         tag = cbi_find_prop(e, "id"); 
     14        tag = cbi_prop_find(e, "id"); 
    1515    e->lmo = sfh_hash(tag, strlen(tag)); 
    1616    return 0; 
     
    2020{ 
    2121    json_object *j = json_object_new_object(); 
    22     const char *icon = cbi_find_prop(e, "icon"); 
    23     const char *name = cbi_find_prop(e, "name"); 
     22    const char *icon = cbi_prop_find(e, "icon"); 
     23    const char *name = cbi_prop_find(e, "name"); 
    2424    json_object_object_add(j, "type", json_object_new_string("menu")); 
    2525    json_object_object_add(j, "icon", json_object_new_string((icon)?(icon):("default"))); 
     
    2727        json_object_object_add(j, "caption", json_object_new_string(lmo_translate_key(ctx, e->lmo, name))); 
    2828    else 
    29         json_object_object_add(j, "caption", json_object_new_string(lmo_translate_key(ctx, e->lmo, cbi_find_prop(e, "id")))); 
     29        json_object_object_add(j, "caption", json_object_new_string(lmo_translate_key(ctx, e->lmo, cbi_prop_find(e, "id")))); 
    3030    return j; 
    3131} 
     
    6161{ 
    6262    json_object *j = json_object_new_object(); 
    63     const char *icon = cbi_find_prop(e, "icon"); 
    64     const char *page = cbi_find_prop(e, "page"); 
     63    const char *icon = cbi_prop_find(e, "icon"); 
     64    const char *page = cbi_prop_find(e, "page"); 
    6565    json_object_object_add(j, "type", json_object_new_string("entry")); 
    6666    json_object_object_add(j, "page", json_object_new_string(page));