Changeset 5675
- Timestamp:
- 02/24/10 13:51:20 (3 years ago)
- Location:
- luci2/cbi2
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
luci2/cbi2/cbi.c
r5674 r5675 540 540 } 541 541 542 struct cbi_ctx* cbi_load_files(const char *dir) 542 static const char* cbi_virt_path(struct cbi_ctx *ctx, const char *path, const char *file) 543 { 544 static char buf[256]; 545 buf[255] = '\0'; 546 snprintf(buf, 255, "%s%s%s", (ctx->vroot)?(ctx->vroot):(""), path, (file)?(file):("")); 547 return buf; 548 } 549 550 struct cbi_ctx* cbi_load_files(struct cbi_ctx *ctx) 543 551 { 544 552 glob_t gl; 545 553 int gl_flags = GLOB_NOESCAPE | GLOB_NOSORT | GLOB_MARK; 546 struct cbi_ctx *ctx = cbi_alloc_ctx(); 547 if(glob(dir, gl_flags, NULL, &gl) >= 0) 554 if(glob(cbi_virt_path(ctx, ctx->path, "*.lucio"), gl_flags, NULL, &gl) >= 0) 548 555 { 549 556 int i; … … 568 575 } 569 576 570 void cbi_check_new_files(struct cbi_ctx *ctx , const char *dir)577 void cbi_check_new_files(struct cbi_ctx *ctx) 571 578 { 572 579 glob_t gl; 573 580 int gl_flags = GLOB_NOESCAPE | GLOB_NOSORT | GLOB_MARK; 574 if(glob( dir, gl_flags, NULL, &gl) >= 0)581 if(glob(cbi_virt_path(ctx, ctx->path, "*.luco"), gl_flags, NULL, &gl) >= 0) 575 582 { 576 583 int i; … … 581 588 } 582 589 583 void cbi_check_new_files_src(struct cbi_ctx *ctx , const char *dir)590 void cbi_check_new_files_src(struct cbi_ctx *ctx) 584 591 { 585 592 glob_t gl; 586 593 int gl_flags = GLOB_NOESCAPE | GLOB_NOSORT | GLOB_MARK; 587 if(glob( dir, gl_flags, NULL, &gl) >= 0)594 if(glob(cbi_virt_path(ctx, ctx->path, "*.luci"), gl_flags, NULL, &gl) >= 0) 588 595 { 589 596 int i; … … 608 615 { 609 616 cbi_check_old_files(ctx); 610 cbi_check_new_files_src(ctx, "/lib/luci2/*.luci"); 611 cbi_check_new_files(ctx, "/lib/luci2/*.luco"); 612 } 613 614 struct cbi_ctx* cbi_load(void) 615 { 616 struct cbi_ctx *ctx = cbi_load_files("/lib/luci2/*.luco"); 617 cbi_check_new_files_src(ctx); 618 cbi_check_new_files(ctx); 619 } 620 621 struct cbi_ctx* cbi_init(const char *vroot, const char *path) 622 { 623 struct cbi_ctx *ctx = cbi_alloc_ctx(); 624 if(!path) 625 ctx->path = strdup("/lib/luci2/"); 626 else 627 ctx->path = strdup(path); 628 if(vroot) 629 ctx->vroot = strdup(vroot); 630 else 631 ctx->vroot = 0; 632 cbi_load_files(ctx); 617 633 cbi_index(ctx); 618 634 cbi_reindex(ctx); 619 635 return ctx; 620 636 } 621 -
luci2/cbi2/cbi.h
r5673 r5675 24 24 struct list_head menus; 25 25 struct uvl_context *uvl; 26 const char *vroot; 27 const char *path; 26 28 }; 27 29 … … 92 94 }; 93 95 94 struct cbi_ctx* cbi_ load(void);96 struct cbi_ctx* cbi_init(const char *vroot, const char *path); 95 97 void cbi_dump(struct cbi_ctx *ctx); 96 98 void cbi_free_context(struct cbi_ctx *ctx); -
luci2/cbi2/luci.c
r5674 r5675 62 62 int daemonize = 0; 63 63 int sock = 0; 64 int blob ;65 char *b_file ;64 int blob = 0; 65 char *b_file = 0; 66 66 int uvl = 0; 67 67 char *u_file = 0; … … 129 129 daemon(0,0); 130 130 131 ctx = cbi_ load();131 ctx = cbi_init(vpath, "/lib/luci2/"); 132 132 133 133 cbi_dump(ctx);
