Changeset 2357 in MondoRescue for branches/2.2.10/mondo/src/common
- Timestamp:
- Aug 29, 2009, 3:22:10 AM (15 years ago)
- Location:
- branches/2.2.10/mondo/src/common
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-archive.c
r2351 r2357 227 227 log_msg(5, "command='%s'", command); 228 228 res = system(command); 229 mr_asprintf(tmp, "%s", last_line_of_file(MONDO_LOGFILE));229 tmp = last_line_of_file(MONDO_LOGFILE); 230 230 log_msg(1, "res=%d; tmp='%s'", res, tmp); 231 231 if (bkpinfo->use_star && (res == 254 || res == 65024) … … 558 558 559 559 mr_asprintf(tmp, "%s/LAST-FILELIST-NUMBER", bkpinfo->tmpdir); 560 mr_asprintf(last_filelist_number, "%s", last_line_of_file(tmp));560 last_filelist_number = last_line_of_file(tmp); 561 561 mr_free(tmp); 562 562 … … 2034 2034 res = slice_up_file_etc(bigfile_fname, ntfsprog_fifo, biggie_file_number, noof_biggie_files, use_ntfsprog); 2035 2035 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 2036 write_header_block_to_stream((off_t)0, calc_checksum_of_file(bigfile_fname), BLK_STOP_A_BIGGIE); 2036 tmp = calc_checksum_of_file(bigfile_fname); 2037 write_header_block_to_stream((off_t)0, tmp, BLK_STOP_A_BIGGIE); 2038 mr_free(tmp); 2037 2039 } 2038 2040 retval += res; … … 2049 2051 } 2050 2052 mr_free(bigfile_fname); 2051 #ifndef _XWIN2052 2053 if (!g_text_mode) { 2053 2054 newtDrawRootText(0, g_noof_rows - 2, tmp); 2054 2055 newtRefresh(); 2055 2056 } 2056 #endif2057 2057 mr_free(tmp); 2058 2058 } … … 2654 2654 mr_free(mds); 2655 2655 2656 cd_number = atoi(last_line_of_file(szcdno)); 2656 tmp = last_line_of_file(szcdno); 2657 cd_number = atoi(tmp); 2658 mr_free(tmp); 2659 2657 2660 mr_asprintf(tmp, "cat %s 2> /dev/null", szserfname); 2658 2661 mr_free(our_serial_str); … … 2982 2985 mr_asprintf(tmp, "%s - Bigfile #%ld, slice #%ld compressed OK ", biggie_filename, biggie_file_number + 1, slice_num); 2983 2986 } 2984 #ifndef _XWIN2985 2987 if (!g_text_mode) { 2986 2988 newtDrawRootText(0, g_noof_rows - 2, tmp); … … 2989 2991 log_msg(2, tmp); 2990 2992 } 2991 #else2992 log_msg(2, tmp);2993 #endif2994 2993 mr_free(tmp); 2995 2994 … … 3111 3110 log_msg(2, tmp); 3112 3111 center_string(tmp, 80); 3113 #ifndef _XWIN3114 3112 if (!g_text_mode) { 3115 3113 newtPushHelpLine(tmp); 3116 3114 } 3117 #endif3118 3115 res = write_iso_and_go_on(TRUE); 3119 #ifndef _XWIN3120 3116 if (!g_text_mode) { 3121 3117 newtPopHelpLine(); 3122 3118 } 3123 #endif3124 3119 log_msg(2, "Returning from writing final ISO (res=%d)", res); 3125 3120 paranoid_free(tmp); -
branches/2.2.10/mondo/src/common/libmondo-devices.c
r2351 r2357 2185 2185 mr_asprintf(tmp, "mount | grep iso9660 | awk '{print $3;}'"); 2186 2186 mr_asprintf(mountdev, "%s%s", call_program_and_get_last_line_of_output(tmp), "/archives/THIS-CD-NUMBER"); 2187 cd_number = atoi(last_line_of_file(mountdev)); 2187 mr_free(tmp); 2188 2189 tmp = last_line_of_file(mountdev); 2190 cd_number = atoi(tmp); 2191 mr_free(tmp); 2188 2192 mr_free(mountdev); 2189 mr_free(tmp);2190 2191 2193 return (cd_number); 2192 2194 } … … 2210 2212 mr_free(mountdev); 2211 2213 2212 cd_number = atoi(last_line_of_file(MNT_CDROM "/archives/THIS-CD-NUMBER")); 2214 tmp = last_line_of_file(MNT_CDROM "/archives/THIS-CD-NUMBER"); 2215 cd_number = atoi(tmp); 2216 mr_free(tmp); 2213 2217 return (cd_number); 2214 2218 } -
branches/2.2.10/mondo/src/common/libmondo-filelist.c
r2351 r2357 346 346 then update_progress_form() won't show the "time taken / time remaining" 347 347 line. The bug only crops up AFTER the call to chop_filelist(). Weird. */ 348 #ifndef _XWIN349 348 if (!g_text_mode) { 350 349 open_progress_form("", "", "", "", 100); … … 353 352 newtPopWindow(); 354 353 } 355 #endif356 354 return (err ? 0 : curr_set_no + 1); 357 355 } … … 471 469 tmp = mr_stresc(file_to_analyze, "`$\\\"(){}[]'*?&|!#~", '\\'); 472 470 mr_asprintf(strtmp, syscall_sprintf, tmp); 473 paranoid_free(tmp); 471 mr_free(tmp); 472 474 473 mr_asprintf(syscall, "%s 2>> /dev/null", strtmp); // " MONDO_LOGFILE); 475 474 mr_free(strtmp); 475 476 476 call_exe_and_pipe_output_to_fd(syscall, pout); 477 477 mr_free(syscall); … … 927 927 } 928 928 add_string_at_node(filelist, fname); 929 mr_free(fname);930 929 931 930 if (!(++lino % 1111)) { … … 933 932 update_evalcall_form(percentage); 934 933 } 934 mr_free(fname); 935 935 } 936 936 mr_free(fname); … … 1414 1414 if (this_time != last_time) { 1415 1415 last_time = this_time; 1416 #ifndef _XWIN1417 1416 if (!g_text_mode) { 1418 1417 mr_asprintf(tmp, "Reading %-68s", dir); … … 1420 1419 mr_free(tmp); 1421 1420 } 1422 #endif1423 1421 update_evalcall_form(percentage); 1424 1422 } … … 1468 1466 counter = 0; 1469 1467 uberctr++; 1470 #ifndef _XWIN1471 1468 mr_asprintf(tmp, " %c ", special_dot_char(uberctr)); 1472 1469 if (!g_text_mode) { … … 1475 1472 } 1476 1473 mr_free(tmp); 1477 #endif1478 1474 } 1479 1475 } -
branches/2.2.10/mondo/src/common/libmondo-files.c
r2341 r2357 46 46 { 47 47 /*@ buffers ***************************************************** */ 48 static char output[MAX_STR_LEN];48 char *output = NULL; 49 49 char *command = NULL; 50 50 51 51 /*@ pointers **************************************************** */ 52 char *p ;52 char *p = NULL; 53 53 FILE *fin; 54 55 /*@ initialize pointers ***************************************** */56 57 p = output;58 54 59 55 /*@************************************************************** */ … … 64 60 fin = popen(command, "r"); 65 61 if (fin) { 66 (void) fgets(output, MAX_STR_LEN, fin);62 mr_getline(output, fin); 67 63 p = strchr(output, ' '); 64 if (p != NULL) { 65 *p = '\0'; 66 } else { 67 mr_free(output); 68 mr_asprintf(output, ""); 69 } 68 70 paranoid_pclose(fin); 69 71 } … … 71 73 } else { 72 74 log_it("File '%s' not found; cannot calc checksum", filename); 73 } 74 if (p) { 75 *p = '\0'; 75 mr_asprintf(output, ""); 76 76 } 77 77 return (output); … … 125 125 /*@ buffers ***************************************************** */ 126 126 char *command = NULL; 127 char incoming[MAX_STR_LEN];127 char *incoming = NULL; 128 128 129 129 /*@ long ******************************************************** */ … … 132 132 /*@ pointers **************************************************** */ 133 133 FILE *fin; 134 135 /*@ initialize [0] to null ******************************************** */136 incoming[0] = '\0';137 134 138 135 assert_string_is_neither_NULL_nor_zerolength(filename); … … 152 149 noof_lines = 0; 153 150 } else { 154 (void) fgets(incoming, MAX_STR_LEN - 1, fin); 155 while (strlen(incoming) > 0 156 && incoming[strlen(incoming) - 1] < 32) { 151 mr_getline(incoming, fin); 152 while (strlen(incoming) > 0 && incoming[strlen(incoming) - 1] < 32) { 157 153 incoming[strlen(incoming) - 1] = '\0'; 158 154 } 159 155 noof_lines = atol(incoming); 156 mr_free(incoming); 160 157 } 161 158 paranoid_pclose(fin); … … 206 203 char *outfname = NULL; 207 204 char *tmp = NULL; 208 char incoming[MAX_STR_LEN];205 char *incoming = NULL; 209 206 210 207 /*@ int ********************************************************* */ … … 236 233 mr_free(outfname); 237 234 238 for (fgets(incoming, MAX_STR_LEN, fin); !feof(fin); 239 fgets(incoming, MAX_STR_LEN, fin)) { 235 for (mr_getline(incoming, fin); !feof(fin); mr_getline(incoming, fin)) { 240 236 i = strlen(incoming) - 1; 241 237 if (i >= 0 && incoming[i] < 32) { … … 247 243 log_it("Excluding '%s'-nonexistent\n", incoming); 248 244 } 249 } 245 mr_free(incoming); 246 } 247 mr_free(incoming); 248 250 249 paranoid_fclose(fout); 251 250 paranoid_fclose(fin); … … 470 469 { 471 470 /*@ buffers ***************************************************** */ 472 static char output[MAX_STR_LEN];471 char *output = NULL; 473 472 char *command = NULL; 474 473 … … 480 479 if (!does_file_exist(filename)) { 481 480 log_it("Tring to get last line of nonexistent file (%s)", filename); 482 output[0] = '\0';481 mr_asprintf(output, ""); 483 482 return (output); 484 483 } … … 487 486 mr_free(command); 488 487 489 (void) fgets(output, MAX_STR_LEN, fin);488 mr_getline(output, fin); 490 489 paranoid_pclose(fin); 491 490 while (strlen(output) > 0 && output[strlen(output) - 1] < 32) { … … 526 525 * @bug I don't know what this function does. However, it seems orphaned, so it should probably be removed. 527 526 */ 528 int 529 make_checksum_list_file(char *filelist, char *cksumlist, char *comppath) 530 { 527 int make_checksum_list_file(char *filelist, char *cksumlist, char *comppath) { 531 528 /*@ pointers **************************************************** */ 532 529 FILE *fin; … … 539 536 540 537 /*@ buffer ****************************************************** */ 541 char stub_fname[1000];542 char curr_fname[1000];538 char *stub_fname = NULL; 539 char *curr_fname = NULL; 543 540 char *curr_cksum = NULL; 544 541 char *tmp = NULL; … … 571 568 return (1); 572 569 } 573 for (fgets(stub_fname, 999, fin); !feof(fin); 574 fgets(stub_fname, 999, fin)) { 570 for (mr_getline(stub_fname, fin); !feof(fin); mr_getline(stub_fname, fin)) { 575 571 if (stub_fname[(i = strlen(stub_fname) - 1)] < 32) { 576 572 stub_fname[i] = '\0'; 577 573 } 578 574 mr_asprintf(tmp, "%s%s", comppath, stub_fname); 579 strcpy(curr_fname, tmp + 1); 575 mr_free(stub_fname); 576 577 mr_asprintf(curr_fname, "%s", tmp + 1); 580 578 mr_free(tmp); 581 579 … … 587 585 current_time = get_time(); 588 586 counter = 0; 587 /* BERLIOS: 37 really ? */ 589 588 curr_fname[37] = '\0'; 590 589 curr_pos = ftello(fin) / 1024; 591 590 percentage = (int) (curr_pos * 100 / filelist_length); 592 591 time_taken = current_time - start_time; 593 if (percentage == 0) { 594 /* printf("%0d%% done \r",percentage); */ 595 } else { 592 if (percentage != 0) { 596 593 time_remaining = time_taken * 100 / (long) (percentage) - time_taken; 597 594 log_to_screen("%02d%% done %02d:%02d taken %02d:%02d remaining %-37s\r", percentage, (int) (time_taken / 60), (int) (time_taken % 60), (int) (time_remaining / 60), (int) (time_remaining % 60), curr_fname); … … 599 596 sync(); 600 597 } 601 } 598 mr_free(curr_fname); 599 } 600 mr_free(stub_fname); 601 602 602 paranoid_fclose(fout); 603 603 paranoid_fclose(fin); … … 678 678 679 679 /*@ buffers **************************************************** */ 680 char incoming[MAX_STR_LEN];680 char *incoming = NULL; 681 681 682 682 /*@ end vars *************************************************** */ … … 689 689 return (0); 690 690 } 691 (void) fgets(incoming, MAX_STR_LEN - 1, fin);691 mr_getline(incoming, fin); 692 692 while (!feof(fin)) { 693 693 if (strstr(incoming, wildcard)) { 694 694 matches++; 695 695 } 696 (void) fgets(incoming, MAX_STR_LEN - 1, fin); 697 } 696 mr_free(incoming); 697 mr_getline(incoming, fin); 698 } 699 mr_free(incoming); 698 700 paranoid_fclose(fin); 699 701 return (matches); … … 737 739 { 738 740 /*@ buffers ***************************************************** */ 739 char *fname ;741 char *fname = NULL; 740 742 char *biggielist = NULL; 741 743 char *tmp = NULL; … … 751 753 /*@ end vars *************************************************** */ 752 754 753 malloc_string(fname);754 755 log_it("Calculating size of all biggiefiles (in total)"); 755 756 mr_asprintf(biggielist, "%s/biggielist.txt", bkpinfo->tmpdir); … … 762 763 } else { 763 764 log_msg(4, "Reading it..."); 764 for (fgets(fname, MAX_STR_LEN, fin); !feof(fin); 765 fgets(fname, MAX_STR_LEN, fin)) { 765 for (mr_getline(fname, fin); !feof(fin); mr_getline(fname, fin)) { 766 766 if (fname[strlen(fname) - 1] <= 32) { 767 767 fname[strlen(fname) - 1] = '\0'; … … 772 772 if (!tmp) { 773 773 mr_free(tmp); 774 mr_free(fname); 774 775 fatal_error("ntfsresize not found"); 775 776 } … … 799 800 break; 800 801 } 801 } 802 mr_free(fname); 803 } 804 mr_free(fname); 802 805 } 803 806 log_it("Closing..."); 804 807 paranoid_fclose(fin); 805 808 log_it("Finished calculating total size of all biggiefiles"); 806 paranoid_free(fname);807 809 return (scratchL); 808 810 } … … 817 819 { 818 820 /*@ buffer ****************************************************** */ 819 char tmp[MAX_STR_LEN];821 char *tmp = NULL; 820 822 char *command = NULL; 821 823 long long llres; … … 833 835 llres = 0; 834 836 } else { 835 (void) fgets(tmp, MAX_STR_LEN, fin);837 mr_getline(tmp, fin); 836 838 paranoid_pclose(fin); 837 839 p = strchr(tmp, '\t'); … … 843 845 llres += (int) (*p - '0'); 844 846 } 847 mr_free(tmp); 845 848 } 846 849 mr_free(command); … … 1289 1292 } 1290 1293 /* BERLIOS: This is just plain WRONG !! */ 1291 mr_asprintf(do_not_compress_these, "%s", last_line_of_file(tmp));1294 do_not_compress_these = last_line_of_file(tmp); 1292 1295 mr_free(tmp); 1293 1296 -
branches/2.2.10/mondo/src/common/libmondo-fork.c
r2339 r2357 38 38 /*@ buffers ***************************************************** */ 39 39 static char result[512]; 40 char *tmp ;40 char *tmp = NULL; 41 41 42 42 /*@ pointers **************************************************** */ … … 44 44 45 45 /*@ initialize data ********************************************* */ 46 malloc_string(tmp);47 46 result[0] = '\0'; 48 tmp[0] = '\0';49 47 50 48 /*@******************************************************************** */ … … 52 50 assert_string_is_neither_NULL_nor_zerolength(call); 53 51 if ((fin = popen(call, "r"))) { 54 for (fgets(tmp, MAX_STR_LEN, fin); !feof(fin); 55 fgets(tmp, MAX_STR_LEN, fin)) { 52 for (mr_getline(tmp, fin); !feof(fin); mr_getline(tmp, fin)) { 56 53 if (strlen(tmp) > 1) { 57 strcpy(result, tmp); 58 } 59 } 54 strncpy(result, 511, tmp); 55 } 56 mr_free(tmp); 57 } 58 mr_free(tmp); 60 59 paranoid_pclose(fin); 61 60 } else { … … 63 62 } 64 63 strip_spaces(result); 65 paranoid_free(tmp);66 64 return (result); 67 65 } … … 163 161 mr_free(command); 164 162 command = tmp2; 165 #ifndef _XWIN166 163 if (!g_text_mode) { 167 164 newtSuspend(); 168 165 } 169 #endif170 166 log_msg(1, "command = '%s'", command); 171 167 retval += system(command); … … 294 290 fin = fopen(tmp1, "r"); 295 291 if (fin) { 296 for (fgets(incoming, MAX_STR_LEN, fin); !feof(fin); 297 fgets(incoming, MAX_STR_LEN, fin)) { 292 for (fgets(incoming, MAX_STR_LEN, fin); !feof(fin); fgets(incoming, MAX_STR_LEN, fin)) { 298 293 p = incoming; 299 294 while (p && *p) { … … 304 299 } 305 300 strip_spaces(incoming); 306 if ((res == 0 && log_if_success) 307 || (res != 0 && log_if_failure)) { 301 if ((res == 0 && log_if_success) || (res != 0 && log_if_failure)) { 308 302 log_msg(0, incoming); 309 303 } … … 375 369 } 376 370 } 377 #ifdef _XWIN 378 /* This only can update when newline goes into the file, 379 but it's *much* prettier/faster on Qt. */ 380 while (does_file_exist(lockfile)) { 381 while (!feof(fin)) { 382 if (!fgets(tmp1, 512, fin)) 383 break; 384 log_to_screen(tmp1); 385 } 386 usleep(500000); 387 } 388 #else 389 /* This works on Newt, and it gives quicker updates. */ 371 390 372 for (; does_file_exist(lockfile); sleep(1)) { 391 373 log_file_end_to_screen(MONDO_LOGFILE, ""); 392 374 update_evalcall_form(1); 393 375 } 394 #endif 376 395 377 /* Evaluate the status returned by pclose to get the exit code of the called program. */ 396 378 errno = 0; -
branches/2.2.10/mondo/src/common/libmondo-gui-EXT.h
r541 r2357 1 1 /* libmondo-gui-EXT.h */ 2 2 3 #ifdef _XWIN4 #include "X-specific-EXT.h"5 #else6 3 #include "newt-specific-EXT.h" 7 #endif -
branches/2.2.10/mondo/src/common/libmondo-gui.c
r541 r2357 9 9 */ 10 10 11 #ifdef _XWIN12 #include "X-specific.c"13 #else14 11 #include "newt-specific.c" 15 #endif -
branches/2.2.10/mondo/src/common/libmondo-gui.h
r541 r2357 3 3 */ 4 4 5 #ifdef _XWIN6 #include "X-specific.h"7 #else8 5 #include "newt-specific.h" 9 #endif -
branches/2.2.10/mondo/src/common/libmondo-mountlist.c
r2352 r2357 821 821 return (1); 822 822 } 823 malloc_string(incoming);824 823 malloc_string(siz); 825 (void) fgets(incoming, MAX_STR_LEN - 1, fin);826 824 log_it("Loading mountlist..."); 825 mr_getline(incoming, fin); 827 826 while (!feof(fin)) { 828 827 #if linux 829 res = sscanf(incoming, 830 "%s %s %s %s %s", 831 mountlist->el[items].device, 832 mountlist->el[items].mountpoint, 833 mountlist->el[items].format, 834 siz, mountlist->el[items].label); 828 res = sscanf(incoming, "%s %s %s %s %s", mountlist->el[items].device, mountlist->el[items].mountpoint, mountlist->el[items].format, siz, mountlist->el[items].label); 835 829 if (res < 5) { 836 830 /* no label found */ … … 839 833 } 840 834 #elif __FreeBSD__ 841 res = sscanf(incoming, 842 "%s %s %s %s", 843 mountlist->el[items].device, 844 mountlist->el[items].mountpoint, 845 mountlist->el[items].format, siz); 835 res = sscanf(incoming, "%s %s %s %s", mountlist->el[items].device, mountlist->el[items].mountpoint, mountlist->el[items].format, siz); 846 836 strcpy(mountlist->el[items].label,""); 847 837 #endif … … 854 844 !strcmp(mountlist->el[items].device, "devpts") 855 845 ) { 856 log_msg(1, 857 "Ignoring %s in mountlist - not loading that line :) ", 858 mountlist->el[items].device); 859 (void) fgets(incoming, MAX_STR_LEN - 1, fin); 846 log_msg(1, "Ignoring %s in mountlist - not loading that line :) ", mountlist->el[items].device); 847 mr_free(incoming); 848 mr_getline(incoming, fin); 860 849 continue; 861 850 } … … 880 869 *(p + 2) = *(p + 3); 881 870 } 882 log_it("It was %s; it is now %s", 883 mountlist->el[items].device, tmp); 871 log_it("It was %s; it is now %s", mountlist->el[items].device, tmp); 884 872 strcpy(mountlist->el[items].device, tmp); 885 873 } 886 874 paranoid_free(tmp); 887 875 888 log_it("%s %s %s %lld %s", 889 mountlist->el[items].device, 890 mountlist->el[items].mountpoint, 891 mountlist->el[items].format, 892 mountlist->el[items].size, 893 mountlist->el[items].label); 876 log_it("%s %s %s %lld %s", mountlist->el[items].device, mountlist->el[items].mountpoint, mountlist->el[items].format, mountlist->el[items].size, mountlist->el[items].label); 894 877 items++; 895 878 if (items >= MAX_MOUNTLIST_ENTRIES) { … … 898 881 } 899 882 } 900 (void) fgets(incoming, MAX_STR_LEN - 1, fin); 901 } 883 mr_free(incoming); 884 mr_getline(incoming, fin); 885 } 886 mr_free(incoming); 902 887 paranoid_fclose(fin); 903 888 mountlist->entries = items; … … 906 891 log_it("%d entries in mountlist", items); 907 892 908 paranoid_free(incoming);909 893 paranoid_free(siz); 910 894 return (0); -
branches/2.2.10/mondo/src/common/libmondo-raid.c
r2334 r2357 427 427 int get_next_raidtab_line(FILE * fin, char *label, char *value) 428 428 { 429 char *incoming ;429 char *incoming = NULL; 430 430 char *p; 431 431 432 malloc_string(incoming);433 432 assert(fin != NULL); 434 433 assert(label != NULL); … … 437 436 label[0] = value[0] = '\0'; 438 437 if (feof(fin)) { 439 paranoid_free(incoming);440 438 return (1); 441 439 } 442 for (fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin); 443 fgets(incoming, MAX_STR_LEN - 1, fin)) { 444 strip_spaces(incoming); 440 for (mr_getline(incoming, fin); !feof(fin); mr_getline(incoming, fin)) { 441 mr_strip_spaces(incoming); 445 442 p = strchr(incoming, ' '); 446 443 if (strlen(incoming) < 3 || incoming[0] == '#' || !p) { 444 mr_free(incoming); 447 445 continue; 448 446 } … … 453 451 strcpy(label, incoming); 454 452 strcpy(value, p); 455 paranoid_free(incoming);453 mr_free(incoming); 456 454 return (0); 457 455 } 456 mr_free(incoming); 458 457 return (1); 459 458 } … … 805 804 static char *argv[64]; 806 805 char **ap; 807 char *line = (char *) malloc(MAX_STR_LEN); 808 if (!line) 809 errx(1, 810 "unable to allocate %i bytes of memory for `char *line' at %s:%i", 811 MAX_STR_LEN, __FILE__, __LINE__); 812 (void) fgets(line, MAX_STR_LEN, f); 806 char *line = NULL; 807 808 mr_getline(line, f); 813 809 if (feof(f)) { 814 810 log_it("[GNVCL] Uh... I reached the EOF."); … … 822 818 cnt++; 823 819 } 820 mr_free(line); 824 821 825 822 if (strchr(argv[cnt - 1], '\n')) { -
branches/2.2.10/mondo/src/common/libmondo-tools.c
r2338 r2357 108 108 return; 109 109 } 110 #ifndef _XWIN111 110 if (!g_text_mode) 112 111 newtSuspend(); 113 #endif114 112 printf("ASSERTION FAILED: `%s'\n", exp); 115 113 printf("\tat %s:%d in %s\n\n", file, line, function); … … 158 156 getchar(); // skip \n 159 157 160 #ifndef _XWIN161 158 if (!g_text_mode) 162 159 newtResume(); 163 #endif164 160 } 165 161 … … 344 340 output[i - 1] = '\0'; 345 341 } 346 if (g_text_mode 347 /* && !strstr(last_line_of_file(MONDO_LOGFILE),output) */ ) { 342 if (g_text_mode) { 348 343 printf("%s\n", output); 349 344 } -
branches/2.2.10/mondo/src/common/libmondo-verify.c
r2338 r2357 411 411 char *command = NULL; 412 412 char *outlog = NULL; 413 char *tmp; 414 // char *p; 413 char *tmp = NULL; 415 414 416 415 /*@ pointers ******************************************************* */ … … 422 421 423 422 424 malloc_string(tmp);425 423 assert(bkpinfo != NULL); 426 424 assert_string_is_neither_NULL_nor_zerolength(tarball_fname); … … 499 497 pin = popen(command, "r"); 500 498 if (pin) { 501 for (fgets(tmp, MAX_STR_LEN, pin); !feof(pin); 502 fgets(tmp, MAX_STR_LEN, pin)) { 499 for (mr_getline(tmp, pin); !feof(pin); mr_getline(tmp, pin)) { 503 500 if (bkpinfo->use_star) { 504 501 if (!strstr(tmp, "diffopts=")) { 505 while (strlen(tmp) > 0 506 && tmp[strlen(tmp) - 1] < 32) { 502 while (strlen(tmp) > 0 && tmp[strlen(tmp) - 1] < 32) { 507 503 tmp[strlen(tmp) - 1] = '\0'; 508 504 } 509 505 if (strchr(tmp, '/')) { 510 506 if (!diffs) { 511 log_msg(0, "'%s' - differences found", 512 tarball_fname); 507 log_msg(0, "'%s' - differences found", tarball_fname); 513 508 } 514 log_msg(0, "star: /%s", 515 strip_afio_output_line(tmp)); 509 log_msg(0, "star: /%s", strip_afio_output_line(tmp)); 516 510 diffs++; 517 511 } … … 519 513 } else { 520 514 if (!diffs) { 521 log_msg(0, "'%s' - differences found", 522 tarball_fname); 515 log_msg(0, "'%s' - differences found", tarball_fname); 523 516 } 524 517 log_msg(0, "afio: /%s", strip_afio_output_line(tmp)); 525 518 diffs++; 526 519 } 520 mr_free(tmp); 527 521 } 522 mr_free(tmp); 528 523 paranoid_pclose(pin); 529 524 } else { … … 533 528 mr_free(command); 534 529 mr_free(outlog); 535 paranoid_free(tmp);536 530 return (0); 537 531 } … … 681 675 mr_asprintf(biggie_cksum, "%s", slice_fnam); 682 676 if (biggie_cksum[0] != '\0') { 683 mr_asprintf(orig_cksum, "%s", calc_checksum_of_file(biggie_fname));677 orig_cksum = calc_checksum_of_file(biggie_fname); 684 678 if (strcmp(biggie_cksum, orig_cksum)) { 685 679 log_msg(2, "orig cksum=%s; curr cksum=%s", biggie_cksum, orig_cksum); … … 690 684 mr_free(tmp); 691 685 } 686 mr_free(orig_cksum); 692 687 } 693 688 mr_free(biggie_cksum); 694 689 mr_free(test_file); 695 mr_free(orig_cksum);696 690 paranoid_free(slice_fnam); 697 691 return (retval); -
branches/2.2.10/mondo/src/common/newt-specific.c
r2340 r2357 124 124 /*@ buffers ********************************************************** */ 125 125 int i; 126 char *tmp; 126 127 127 128 assert_string_is_neither_NULL_nor_zerolength(prompt); 128 129 129 130 if (g_text_mode) { 130 131 char *tmp;132 tmp = malloc(MAX_NEWT_COMMENT_LEN);133 134 131 while (1) { 135 132 system("sync"); 136 printf 137 ("---promptdialogYN---1--- %s\n---promptdialogYN---Q--- [yes] [no] ---\n--> ", 138 prompt); 139 (void) fgets(tmp, MAX_NEWT_COMMENT_LEN, stdin); 133 printf("---promptdialogYN---1--- %s\n---promptdialogYN---Q--- [yes] [no] ---\n--> ", prompt); 134 mr_getline(tmp, stdin); 140 135 if (tmp[strlen(tmp) - 1] == '\n') 141 136 tmp[strlen(tmp) - 1] = '\0'; … … 146 141 } 147 142 if (strstr("yesYES", tmp)) { 148 paranoid_free(tmp);143 mr_free(tmp); 149 144 return (TRUE); 150 145 } else if (strstr("NOno", tmp)) { 151 paranoid_free(tmp);146 mr_free(tmp); 152 147 return (FALSE); 153 148 } else { 154 149 system("sync"); 155 printf 156 ("Please enter either YES or NO (or yes or no, or y or n, or...)\n"); 150 printf("Please enter either YES or NO (or yes or no, or y or n, or...)\n"); 157 151 } 158 152 } … … 172 166 173 167 /*@ buffer *********************************************************** */ 174 char *tmp ;168 char *tmp = NULL; 175 169 int i; 176 170 177 tmp = malloc(MAX_NEWT_COMMENT_LEN);178 171 assert_string_is_neither_NULL_nor_zerolength(prompt); 172 179 173 if (g_text_mode) { 180 174 system("sync"); 181 printf 182 ("---promptdialogOKC---1--- %s\n---promptdialogOKC---Q--- [OK] [Cancel] ---\n--> ", 183 prompt); 184 (void) fgets(tmp, MAX_NEWT_COMMENT_LEN, stdin); 175 printf("---promptdialogOKC---1--- %s\n---promptdialogOKC---Q--- [OK] [Cancel] ---\n--> ", prompt); 176 mr_getline(tmp, stdin); 185 177 if (tmp[strlen(tmp) - 1] == '\n') 186 178 tmp[strlen(tmp) - 1] = '\0'; … … 191 183 } 192 184 if (strstr("okOKOkYESyes", tmp)) { 193 paranoid_free(tmp);185 mr_free(tmp); 194 186 return (TRUE); 195 187 } else { 196 paranoid_free(tmp);188 mr_free(tmp); 197 189 return (FALSE); 198 190 } 199 191 } else { 200 paranoid_free(tmp);201 192 return (popup_with_buttons(prompt, " Okay ", "Cancel")); 202 193 } … … 431 422 * @param grep_for_me If not "", then only give lines in @p filename that match this regular expression. 432 423 */ 433 void 434 log_file_end_to_screen(char *filename, char *grep_for_me) { 424 void log_file_end_to_screen(char *filename, char *grep_for_me) { 435 425 436 426 /*@ buffers ********************************************************** */ … … 462 452 for (err_log_lines[i][0] = '\0'; 463 453 strlen(err_log_lines[i]) < 2 && !feof(fin);) { 464 (void) fgets(err_log_lines[i], MAX_NEWT_COMMENT_LEN, 465 fin); 454 (void) fgets(err_log_lines[i], MAX_NEWT_COMMENT_LEN, fin); 466 455 /* Commented to make valgrind happy and avoid crash 467 456 strip_spaces(err_log_lines[i]); … … 787 776 788 777 /*@ buffers *********************************************************** */ 789 char *prompt ;778 char *prompt = NULL; 790 779 791 780 /*@ newt ************************************************************** */ … … 799 788 assert(button1 != NULL); 800 789 assert(button2 != NULL); 801 prompt = malloc(MAX_NEWT_COMMENT_LEN);802 790 if (g_text_mode) { 803 791 if (strlen(button2) == 0) { … … 806 794 printf("%s (%s or %s) --> ", p, button1, button2); 807 795 } 808 for (prompt[0] = '\0'; 809 strcmp(prompt, button1) && (strlen(button2) == 0 810 || strcmp(prompt, button2));) { 796 mr_getline(prompt, stdin); 797 while (strcmp(prompt, button1) && (strlen(button2) == 0 || strcmp(prompt, button2))) { 811 798 printf("--> "); 812 (void) fgets(prompt, MAX_NEWT_COMMENT_LEN, stdin); 799 mr_free(prompt); 800 mr_getline(prompt, stdin); 813 801 } 814 802 if (!strcmp(prompt, button1)) { 815 paranoid_free(prompt);803 mr_free(prompt); 816 804 return (TRUE); 817 805 } else { 818 paranoid_free(prompt);806 mr_free(prompt); 819 807 return (FALSE); 820 808 } 821 809 } 822 810 811 prompt = malloc(MAX_NEWT_COMMENT_LEN); 823 812 strncpy(prompt, p, MAX_NEWT_COMMENT_LEN - 1); 824 813 prompt[MAX_NEWT_COMMENT_LEN - 1] = '\0'; … … 1166 1155 { "none", "cdr", "cdrw", "dvd", "tape", "cdstream", "udev", 1167 1156 "nfs", "iso", NULL }; 1168 char *outstr ;1157 char *outstr = NULL; 1169 1158 t_bkptype backup_type; 1170 1159 int i; … … 1181 1170 newtComponent myForm; 1182 1171 1183 outstr = malloc(MAX_NEWT_COMMENT_LEN);1184 1172 if (g_text_mode) { 1185 1173 for (backup_type = none; backup_type == none;) { … … 1190 1178 } 1191 1179 printf(")\n--> "); 1192 (void) fgets(outstr, MAX_NEWT_COMMENT_LEN, stdin);1193 strip_spaces(outstr);1180 mr_getline(outstr, stdin); 1181 mr_strip_spaces(outstr); 1194 1182 for (i = 0; possible_responses[i]; i++) { 1195 1183 if (!strcmp(possible_responses[i], outstr)) { … … 1197 1185 } 1198 1186 } 1199 }1200 paranoid_free(outstr);1187 mr_free(outstr); 1188 } 1201 1189 return (backup_type); 1202 1190 } … … 1319 1307 int j = 0; 1320 1308 bool done; 1321 char *tmp ;1309 char *tmp = NULL; 1322 1310 char *tmp1 = NULL; 1323 1311 FILE *fin, *fout; … … 1338 1326 if (!(fout = fopen(tmp1, "a"))) { 1339 1327 log_msg(2, "Can't write to %s", tmp1); 1328 mr_free(tmp1); 1340 1329 return(1); 1341 1330 } 1342 1331 1343 malloc_string(tmp);1344 1332 log_msg(2, "Loading %s", source_file); 1345 for (filelist->entries = 0; filelist->entries <= ARBITRARY_MAXIMUM; 1346 filelist->entries++) { 1333 for (filelist->entries = 0; filelist->entries <= ARBITRARY_MAXIMUM; filelist->entries++) { 1347 1334 god_i_hate_gotos: 1335 if (tmp != NULL) { 1336 mr_free(tmp); 1337 } 1348 1338 if (feof(fin)) { 1349 1339 break; 1350 1340 } 1351 (void) fgets(tmp, MAX_NEWT_COMMENT_LEN, fin);1341 mr_getline(tmp, fin); 1352 1342 i = (int) strlen(tmp); 1353 1343 if (i < 2) { … … 1366 1356 goto god_i_hate_gotos; 1367 1357 } 1368 filelist->el[filelist->entries].severity = 1369 severity_of_difference(tmp, NULL); 1358 filelist->el[filelist->entries].severity = severity_of_difference(tmp, NULL); 1370 1359 strcpy(filelist->el[filelist->entries].filename, tmp); 1371 1360 if (feof(fin)) { … … 1373 1362 } 1374 1363 } 1364 mr_free(tmp); 1375 1365 paranoid_fclose(fin); 1376 1366 paranoid_fclose(fout); … … 1378 1368 log_to_screen("%d files listed in %s/changed.files have been deleted since backup was made\nand are referenced in %s", j, bkpinfo->tmpdir,tmp1); 1379 1369 } 1380 paranoid_free(tmp1);1370 mr_free(tmp1); 1381 1371 if (filelist->entries >= ARBITRARY_MAXIMUM) { 1382 1372 log_to_screen("Arbitrary limits suck, man!"); 1383 paranoid_free(tmp);1384 1373 return (1); 1385 1374 } … … 1409 1398 } 1410 1399 } 1411 paranoid_free(tmp);1412 1400 log_it("leaving"); 1413 1401 return (0);
Note:
See TracChangeset
for help on using the changeset viewer.