Changeset 5781
- Timestamp:
- 03/09/10 19:00:38 (3 years ago)
- Location:
- luci2/cbi2
- Files:
-
- 2 added
- 13 modified
- 2 moved
-
cbi.c (modified) (13 diffs)
-
cbi.h (modified) (2 diffs)
-
cbi_core.c (added)
-
cbi_dump.c (added)
-
json.c (modified) (2 diffs)
-
lucic.c (modified) (1 diff)
-
Makefile (modified) (1 diff)
-
parser.c (moved) (moved from luci2/cbi2/lucip.c) (1 diff)
-
parser.h (moved) (moved from luci2/cbi2/lucip.h)
-
source.c (modified) (1 diff)
-
sources/uci.c (modified) (3 diffs)
-
widget.c (modified) (2 diffs)
-
widgets/luci/content.c (modified) (2 diffs)
-
widgets/luci/field.c (modified) (2 diffs)
-
widgets/luci/file.c (modified) (1 diff)
-
widgets/luci/icon.c (modified) (2 diffs)
-
widgets/luci/menu.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
luci2/cbi2/cbi.c
r5779 r5781 18 18 #include "json.h" 19 19 20 struct cbi_property* cbi_p arse_properties(struct blob_attr *prop)20 struct cbi_property* cbi_prop_parse(struct blob_attr *prop) 21 21 { 22 22 int rem = blob_len(prop); … … 38 38 } 39 39 40 void cbi_ add_property(struct cbi_element *e, const char *name, const char *val, int generated)40 void cbi_prop_add(struct cbi_element *e, const char *name, const char *val, int generated) 41 41 { 42 42 struct cbi_property *p = malloc(sizeof(struct cbi_property)); … … 49 49 } 50 50 51 const char* cbi_ find_prop(struct cbi_element *e, const char *key)51 const char* cbi_prop_find(struct cbi_element *e, const char *key) 52 52 { 53 53 struct list_head *q; … … 62 62 } 63 63 64 int cbi_ find_prop_int(struct cbi_element *e, char *key, int def)65 { 66 const char *c = cbi_ find_prop(e, key);64 int cbi_prop_find_int(struct cbi_element *e, char *key, int def) 65 { 66 const char *c = cbi_prop_find(e, key); 67 67 if(c) 68 68 return atoi(c); … … 76 76 return; 77 77 cbi_get_element_id(e->parent, buffer, file); 78 id = cbi_ find_prop(e, "id");78 id = cbi_prop_find(e, "id"); 79 79 if(!id && (CAPS(e) & CAP_DATA)) 80 id = cbi_ find_prop(e, "src");80 id = cbi_prop_find(e, "src"); 81 81 if(!id) 82 82 return; … … 90 90 char tmp[128]; 91 91 char buffer[256]; 92 const char *id = cbi_ find_prop(e, "id");92 const char *id = cbi_prop_find(e, "id"); 93 93 if(id) 94 94 return; … … 97 97 if(e->w) 98 98 if(e->w->caps & CAP_DATA) 99 id = cbi_ find_prop(e, "src");99 id = cbi_prop_find(e, "src"); 100 100 if(!id) 101 id = cbi_ find_prop(e, "name");101 id = cbi_prop_find(e, "name"); 102 102 if(id) 103 103 { … … 108 108 if(*b == '@') 109 109 b++; 110 cbi_ add_property(e, "id", b, 1);110 cbi_prop_add(e, "id", b, 1); 111 111 return; 112 112 } … … 114 114 snprintf(tmp, 127, "%s%d", e->widget, *count); 115 115 tmp[127] = '\0'; 116 cbi_ add_property(e, "id", tmp, 1);116 cbi_prop_add(e, "id", tmp, 1); 117 117 *buffer = 0; 118 118 cbi_get_element_id(e->parent, buffer, 1); … … 140 140 { 141 141 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"); 143 143 if(id2) 144 144 { … … 188 188 break; 189 189 case CBI_PROPERTY: 190 p = cbi_p arse_properties(element);190 p = cbi_prop_parse(element); 191 191 list_add_tail(&p->list, &e->properties); 192 192 break; … … 280 280 } 281 281 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 else306 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 385 282 void cbi_free_property(struct cbi_property *prop) 386 283 { … … 412 309 } 413 310 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 150 150 }; 151 151 152 struct cbi_ctx* cbi_alloc_ctx(void); 153 int cbi_add_file(struct cbi_ctx *ctx, char *filename, int index); 154 void cbi_free_element(struct cbi_element *element); 155 struct cbi_element* cbi_find_element(struct cbi_element *e, const char *id); 156 struct cbi_element* cbi_parse_element(struct cbi_ctx *ctx, struct blob_attr *attr, int *count, struct cbi_element *parent); 157 158 void cbi_index(struct cbi_ctx *ctx); 152 159 struct cbi_ctx* cbi_init(const char *vroot, const char *path, const char *namespace); 153 160 void cbi_dump(struct cbi_ctx *ctx); … … 155 162 void cbi_reindex(struct cbi_ctx *ctx); 156 163 void cbi_gen_default_id(struct cbi_element *e, int *count); 157 const char* cbi_find_prop(struct cbi_element *e, const char *key); 164 165 const char* cbi_prop_find(struct cbi_element *e, const char *key); 166 void cbi_prop_add(struct cbi_element *e, const char *name, const char *val, int generated); 167 158 168 void cbi_add_property(struct cbi_element *e, const char *name, const char *val, int generated); 159 169 void cbi_get_element_id(struct cbi_element *e, char *buffer, int file); -
luci2/cbi2/json.c
r5723 r5781 8 8 struct list_head *p; 9 9 json_object *j = 0; 10 const char *id = cbi_ find_prop(e, "id");10 const char *id = cbi_prop_find(e, "id"); 11 11 int descend = 1; 12 12 int container = ((CAPS(e) & CAP_CONTAINER) && (e->source)); … … 51 51 if(!container) 52 52 { 53 id = cbi_ find_prop(e, "id");53 id = cbi_prop_find(e, "id"); 54 54 json_object_object_add(q, id, j); 55 55 } -
luci2/cbi2/lucic.c
r5674 r5781 8 8 #include <fcntl.h> 9 9 10 #include " lucip.h"10 #include "parser.h" 11 11 #include "lucic.h" 12 12 -
luci2/cbi2/Makefile
r5780 r5781 8 8 all: $(BINARY) 9 9 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.a10 luci: 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 11 11 $(CC) $(CFLAGS) -o $@ $^ -luci -ljson -lcrypt 12 12 -
luci2/cbi2/parser.c
r5710 r5781 9 9 #include <ctype.h> 10 10 11 #include " lucip.h"11 #include "parser.h" 12 12 #include "cbi.h" 13 13 -
luci2/cbi2/source.c
r5723 r5781 47 47 static int source_detemine(struct cbi_element *e) 48 48 { 49 const char *src = cbi_ find_prop(e, "src");49 const char *src = cbi_prop_find(e, "src"); 50 50 if((CAPS(e) & CAP_DEPENDENCY) && !src) 51 51 return 0; -
luci2/cbi2/sources/uci.c
r5729 r5781 149 149 { 150 150 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"); 152 152 const char *dot1 = 0, *dot2 = 0, *tmp = src; 153 153 int use_parent = 0; … … 303 303 value = uvalue = ucix_get_option(ucictx, p->package, p->section, p->option); 304 304 if(!value) 305 value = cbi_ find_prop(e, "default");305 value = cbi_prop_find(e, "default"); 306 306 if(value) 307 307 json_object_object_add(j, "value", json_object_new_string(value)); … … 370 370 if((CAPS(e) & CAP_DEPENDENCY) != CAP_DEPENDENCY) 371 371 return 1; 372 value = cbi_ find_prop(e, "value");372 value = cbi_prop_find(e, "value"); 373 373 if(!p->package || !p->section || !p->option || !value) 374 374 { -
luci2/cbi2/widget.c
r5779 r5781 49 49 { 50 50 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)) 52 52 { 53 53 CBILOG(e, "missing required property %s\n", e->w->props[i].name); … … 98 98 static int widget_abstract(struct cbi_ctx *ctx, struct cbi_element *e) 99 99 { 100 const char *ref = cbi_ find_prop(e, "ref");100 const char *ref = cbi_prop_find(e, "ref"); 101 101 struct cbi_element *r; 102 102 if(!ref) -
luci2/cbi2/widgets/luci/content.c
r5780 r5781 9 9 { 10 10 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"); 12 12 json_object_object_add(j, "type", json_object_new_string("text")); 13 13 if(css) … … 36 36 { 37 37 content_init(ctx, e); 38 cbi_ add_property(e, "css", "title", 1);38 cbi_prop_add(e, "css", "title", 1); 39 39 return 0; 40 40 } -
luci2/cbi2/widgets/luci/field.c
r5780 r5781 3 3 int field_init(struct cbi_ctx *ctx, struct cbi_element *e) 4 4 { 5 const char *type = cbi_ find_prop(e, "type");5 const char *type = cbi_prop_find(e, "type"); 6 6 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"); 9 9 if(!(e->validate = validator_find(type))) 10 10 { … … 25 25 { 26 26 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"); 29 29 json_object_object_add(j, "type", json_object_new_string((type)?(type):("string"))); 30 30 if(def) -
luci2/cbi2/widgets/luci/file.c
r5780 r5781 4 4 { 5 5 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"); 7 7 json_object_object_add(j, "type", json_object_new_string((type)?(type):("package"))); 8 8 return j; -
luci2/cbi2/widgets/luci/icon.c
r5780 r5781 3 3 int icon_init(struct cbi_ctx *ctx, struct cbi_element *e) 4 4 { 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"); 8 8 if(!handler && !link && !ref) 9 9 { … … 27 27 { 28 28 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"); 33 33 json_object_object_add(j, "type", json_object_new_string("icon")); 34 34 if(link) -
luci2/cbi2/widgets/luci/menu.c
r5780 r5781 10 10 int menu_init(struct cbi_ctx *ctx, struct cbi_element *e) 11 11 { 12 const char *tag = cbi_ find_prop(e, "name");12 const char *tag = cbi_prop_find(e, "name"); 13 13 if(!tag) 14 tag = cbi_ find_prop(e, "id");14 tag = cbi_prop_find(e, "id"); 15 15 e->lmo = sfh_hash(tag, strlen(tag)); 16 16 return 0; … … 20 20 { 21 21 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"); 24 24 json_object_object_add(j, "type", json_object_new_string("menu")); 25 25 json_object_object_add(j, "icon", json_object_new_string((icon)?(icon):("default"))); … … 27 27 json_object_object_add(j, "caption", json_object_new_string(lmo_translate_key(ctx, e->lmo, name))); 28 28 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")))); 30 30 return j; 31 31 } … … 61 61 { 62 62 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"); 65 65 json_object_object_add(j, "type", json_object_new_string("entry")); 66 66 json_object_object_add(j, "page", json_object_new_string(page));
