Changeset 2351 in MondoRescue for branches/2.2.10/mondo/src/common/libmondo-filelist.c
- Timestamp:
- Aug 28, 2009, 2:41:30 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-filelist.c
r2340 r2351 414 414 int call_exe_and_pipe_output_to_fd(char *syscall, FILE * pout) 415 415 { 416 FILE *pattr; 417 char *tmp; 416 FILE *pattr = NULL; 417 char *tmp = NULL; 418 418 419 pattr = popen(syscall, "r"); 419 420 if (!pattr) { … … 426 427 return (2); 427 428 } 428 malloc_string(tmp); 429 for ((void)fgets(tmp, MAX_STR_LEN, pattr); !feof(pattr); 430 (void)fgets(tmp, MAX_STR_LEN, pattr)) { 429 for (mr_getline(tmp, pattr); !feof(pattr); mr_getline(tmp, pattr)) { 431 430 fputs(tmp, pout); 432 } 431 mr_free(tmp); 432 } 433 mr_free(tmp); 433 434 paranoid_pclose(pattr); 434 paranoid_free(tmp);435 435 return (0); 436 436 } … … 441 441 char *auxlist_fname) 442 442 { 443 FILE *fin ;444 FILE *pout ;443 FILE *fin = NULL; 444 FILE *pout = NULL; 445 445 char *pout_command = NULL; 446 char *syscall ;447 char *file_to_analyze ;446 char *syscall = NULL; 447 char *file_to_analyze = NULL; 448 448 char *strtmp = NULL; 449 449 char *tmp = NULL; … … 463 463 mr_free(pout_command); 464 464 465 malloc_string(file_to_analyze); 466 for ((void)fgets(file_to_analyze, MAX_STR_LEN, fin); !feof(fin); 467 (void)fgets(file_to_analyze, MAX_STR_LEN, fin)) { 465 for (mr_getline(file_to_analyze, fin); !feof(fin); mr_getline(file_to_analyze, fin)) { 468 466 i = strlen(file_to_analyze); 469 467 if (i > 0 && file_to_analyze[i - 1] < 32) { … … 478 476 call_exe_and_pipe_output_to_fd(syscall, pout); 479 477 mr_free(syscall); 480 } 478 mr_free(file_to_analyze); 479 } 480 mr_free(file_to_analyze); 481 481 paranoid_fclose(fin); 482 482 paranoid_pclose(pout); 483 paranoid_free(file_to_analyze);484 483 return (0); 485 484 } … … 529 528 char *syscall_pin = NULL; 530 529 char *syscall_pout = NULL; 531 char *incoming ;532 char *current_subset_file ;530 char *incoming = NULL; 531 char *current_subset_file = NULL; 533 532 char *current_master_file = NULL; 534 533 char *masklist = NULL; … … 553 552 return (0); 554 553 } 555 malloc_string(incoming);556 malloc_string(current_subset_file);557 554 mr_asprintf(masklist, "%s/masklist", bkpinfo->tmpdir); 558 555 mr_asprintf(command, "cp -f %s %s", orig_msklist, masklist); … … 561 558 562 559 sort_file(masklist); 563 current_subset_file[0] = '\0';564 560 565 561 mr_asprintf(syscall_pout, "%s --restore - 2>> %s", executable, MONDO_LOGFILE); … … 594 590 // printf("Hi there. Starting the loop\n"); 595 591 596 (void)fgets(current_subset_file, MAX_STR_LEN, faclin);597 (void)fgets(incoming, MAX_STR_LEN, pin);592 mr_getline(current_subset_file, faclin); 593 mr_getline(incoming, pin); 598 594 while (!feof(pin) && !feof(faclin)) { 599 595 mr_asprintf(current_master_file, "%s", incoming + 8); … … 625 621 if (i < 0) { // read another subset file in. 626 622 log_msg(my_depth, "Reading next subset line in\n\n"); 627 (void)fgets(current_subset_file, MAX_STR_LEN, faclin); 623 mr_free(current_subset_file); 624 mr_getline(current_subset_file, faclin); 628 625 continue; 629 626 } … … 632 629 fputs(incoming, pout); 633 630 } 634 (void)fgets(incoming, MAX_STR_LEN, pin); 631 mr_free(incoming); 632 mr_getline(incoming, pin); 635 633 if (!i) { 636 634 log_msg(my_depth, "Copying master %s", q); … … 641 639 fputs(incoming, pout); 642 640 } 643 (void)fgets(incoming, MAX_STR_LEN, pin); 641 mr_free(incoming); 642 mr_getline(incoming, pin); 644 643 } 645 644 if (!i) { 646 (void)fgets(current_subset_file, MAX_STR_LEN, faclin); 645 mr_free(current_subset_file); 646 mr_getline(current_subset_file, faclin); 647 647 } 648 648 mr_free(current_master_file); 649 649 } 650 while (!feof(pin)) { 651 (void)fgets(incoming, MAX_STR_LEN, pin); 652 } 650 mr_free(current_subset_file); 651 mr_free(incoming); 653 652 fclose(faclin); 654 653 pclose(pin); 655 654 pclose(pout); 656 655 657 // printf("OK, loop is done\n");658 659 656 unlink(masklist); 660 657 mr_free(masklist); 661 658 662 paranoid_free(current_subset_file);663 paranoid_free(incoming);664 659 return (retval); 665 660 } … … 772 767 noof_chars = strlen(string_to_add) + 1; /* we include the '\0' */ 773 768 774 /* walk across tree if necessary */769 /* walk across tree if necessary */ 775 770 node = startnode; 776 771 char_to_add = string_to_add[0]; … … 781 776 } 782 777 783 /* walk down tree if appropriate */778 /* walk down tree if appropriate */ 784 779 if (node->down != NULL && node->ch == char_to_add) { 785 780 log_msg(7, "depth=%d char=%c --- going DOWN", depth, char_to_add); … … 795 790 } 796 791 797 /* add here */792 /* add here */ 798 793 if (!(newnode = (struct s_node *) malloc(sizeof(struct s_node)))) { 799 794 log_to_screen("failed to malloc"); … … 866 861 /*@ buffers **************************************************** */ 867 862 char *command_to_open_fname = NULL; 868 char fname[MAX_STR_LEN]; 869 char tmp[MAX_STR_LEN]; 870 char *tmp1 = NULL; 863 char *fname = NULL; 864 char *tmp = NULL; 871 865 int pos_in_fname; 872 866 /*@ int ******************************************************** */ … … 884 878 } 885 879 log_to_screen("Loading filelist"); 886 mr_asprintf(tmp 1, "zcat %s | wc -l", filelist_fname);887 log_msg(6, "tmp 1 = %s", tmp1);888 lines_in_filelist = atol(call_program_and_get_last_line_of_output(tmp 1));889 mr_free(tmp 1);880 mr_asprintf(tmp, "zcat %s | wc -l", filelist_fname); 881 log_msg(6, "tmp = %s", tmp); 882 lines_in_filelist = atol(call_program_and_get_last_line_of_output(tmp)); 883 mr_free(tmp); 890 884 891 885 if (lines_in_filelist < 3) { … … 913 907 914 908 open_evalcall_form("Loading filelist from disk"); 915 for ((void)fgets(fname, MAX_STR_LEN, pin); !feof(pin); 916 (void)fgets(fname, MAX_STR_LEN, pin)) { 917 if ((fname[strlen(fname) - 1] == 13 918 || fname[strlen(fname) - 1] == 10) && strlen(fname) > 0) { 909 for (mr_getline(fname, pin); !feof(pin); mr_getline(fname, pin)) { 910 if ((strlen(fname) > 0) && (fname[strlen(fname) - 1] == 13 || fname[strlen(fname) - 1] == 10)) { 919 911 fname[strlen(fname) - 1] = '\0'; 920 912 } 921 // strip_spaces (fname);922 913 if (!strlen(fname)) { 914 mr_free(fname); 923 915 continue; 924 916 } … … 927 919 continue; 928 920 } 929 strcpy(tmp, fname);921 mr_asprintf(tmp, "%s", fname); 930 922 tmp[pos_in_fname] = '\0'; 931 923 if (strlen(tmp)) { 932 924 add_string_at_node(filelist, tmp); 933 925 } 926 mr_free(tmp); 934 927 } 935 928 add_string_at_node(filelist, fname); 929 mr_free(fname); 930 936 931 if (!(++lino % 1111)) { 937 932 percentage = (int) (lino * 100 / lines_in_filelist); … … 939 934 } 940 935 } 936 mr_free(fname); 937 941 938 paranoid_pclose(pin); 942 939 close_evalcall_form(); … … 1835 1832 char *list_of_files_fname, bool flag_em) 1836 1833 { 1837 FILE *fin; 1838 char *tmp; 1839 struct s_node *nod; 1840 1841 malloc_string(tmp); 1834 FILE *fin = NULL; 1835 char *tmp = NULL; 1836 struct s_node *nod = NULL; 1837 1842 1838 log_msg(3, "Adding %s to filelist", list_of_files_fname); 1843 1839 if (!(fin = fopen(list_of_files_fname, "r"))) { … … 1845 1841 return (1); 1846 1842 } 1847 for ((void)fgets(tmp, MAX_STR_LEN, fin); !feof(fin); 1848 (void)fgets(tmp, MAX_STR_LEN, fin)) { 1843 for (mr_getline(tmp, fin); !feof(fin); mr_getline(tmp, fin)) { 1849 1844 if (!tmp[0]) { 1845 mr_free(tmp); 1850 1846 continue; 1851 1847 } 1852 if ((tmp[strlen(tmp) - 1] == 13 || tmp[strlen(tmp) - 1] == 10) 1853 && strlen(tmp) > 0) { 1848 if ((strlen(tmp) > 0) && (tmp[strlen(tmp) - 1] == 13 || tmp[strlen(tmp) - 1] == 10)) { 1854 1849 tmp[strlen(tmp) - 1] = '\0'; 1855 1850 } 1856 1851 log_msg(2, "tmp = '%s'", tmp); 1857 1852 if (!tmp[0]) { 1853 mr_free(tmp); 1858 1854 continue; 1859 1855 } … … 1869 1865 log_msg(5, "Flagged '%s'", tmp); 1870 1866 } 1871 } 1867 mr_free(tmp); 1868 } 1869 mr_free(tmp); 1872 1870 paranoid_fclose(fin); 1873 paranoid_free(tmp);1874 1871 return (0); 1875 1872 }
Note:
See TracChangeset
for help on using the changeset viewer.