- Timestamp:
- 09/04/05 21:19:05 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/reglookup.c
r53 r54 184 184 185 185 /* XXX: this MULTI_SZ parser is pretty inefficient. Should be 186 * redone with fewer malloc and better string concatenation.186 * redone with fewer malloc calls and better string concatenation. 187 187 */ 188 188 case REG_MULTI_SZ: … … 317 317 if (buf == NULL) 318 318 return NULL; 319 buf[0] = '/'; 320 buf[1] = '\0'; 319 buf[0] = '\0'; 321 320 322 321 iter = void_stack_iterator_new(nk_stack); … … 472 471 473 472 474 /* XXX: this function is god-awful. Needs to be re-designed. */473 /* XXX: this function is awful. Needs to be re-designed. */ 475 474 void printKeyTree(REGF_FILE* f, void_stack* nk_stack, char* prefix) 476 475 { … … 479 478 char* path = NULL; 480 479 char* val_path = NULL; 481 482 480 int key_type = regfio_type_str2val("KEY"); 483 481 … … 486 484 cur->subkey_index = 0; 487 485 path = stack2Path(nk_stack); 488 486 487 if(print_verbose) 488 { 489 if(prefix[0] == '\0') 490 fprintf(stderr, "VERBOSE: Printing key tree under path: /\n"); 491 else 492 fprintf(stderr, "VERBOSE: Printing key tree under path: %s\n", 493 prefix); 494 } 489 495 490 496 val_path = (char*)malloc(strlen(prefix)+strlen(path)+1); 491 497 sprintf(val_path, "%s%s", prefix, path); 498 if(val_path[0] == '\0') 499 { 500 val_path[0] = '/'; 501 val_path[1] = '\0'; 502 } 503 492 504 if(!type_filter_enabled || (key_type == type_filter)) 493 505 printKey(cur, val_path); 494 495 506 if(!type_filter_enabled || (key_type != type_filter)) 496 507 printValueList(cur, val_path); … … 527 538 } 528 539 } 540 if(print_verbose) 541 fprintf(stderr, "VERBOSE: Finished printing key tree.\n"); 529 542 } 530 543 … … 559 572 cur = (REGF_NK_REC*)void_stack_cur(nk_stack); 560 573 574 if(print_verbose) 575 fprintf(stderr, "VERBOSE: Beginning retrieval of specified path: %s\n", 576 path_filter); 577 561 578 while(void_stack_size(path_stack) > 1) 562 579 { … … 575 592 } 576 593 } 594 if(print_verbose && !found_cur) 595 fprintf(stderr, "VERBOSE: Could not find KEY '%s' in specified path.\n", 596 cur_str); 597 577 598 free(cur_str); 578 579 599 if(!found_cur) 580 600 return 1; … … 583 603 /* Last round, search value and key records */ 584 604 cur_str = (char*)void_stack_pop(path_stack); 605 606 if(print_verbose) 607 fprintf(stderr, "VERBOSE: Searching values for last component" 608 " of specified path.\n"); 585 609 586 610 for(i=0; (i < cur->num_values); i++) … … 594 618 if(path != NULL) 595 619 free(path); 620 621 if(print_verbose) 622 fprintf(stderr, "VERBOSE: Found final path element as value.\n"); 623 596 624 return 0; 597 625 } 598 626 } 627 628 if(print_verbose) 629 fprintf(stderr, "VERBOSE: Searching keys for last component" 630 " of specified path.\n"); 599 631 600 632 while((sub = regfio_fetch_subkey(f, cur)) != NULL) … … 611 643 strcat(prefix, "/"); 612 644 strcat(prefix, sub->keyname); 645 646 if(print_verbose) 647 fprintf(stderr, "VERBOSE: Found final path element as key.\n"); 648 613 649 printKeyTree(f, sub_nk_stack, prefix); 650 614 651 return 0; 615 652 } 616 653 } 654 655 if(print_verbose) 656 fprintf(stderr, "VERBOSE: Could not find last element of path.\n"); 617 657 618 658 return 1;
Note: See TracChangeset
for help on using the changeset viewer.