Changeset 900 in MondoRescue for trunk/mondo/src/common/newt-specific.c
- Timestamp:
- Oct 24, 2006, 8:49:18 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/src/common/newt-specific.c
r838 r900 26 26 #include "libmondo-fork-EXT.h" 27 27 #include "newt-specific-EXT.h" 28 #include "mr_mem.h" 28 29 29 30 /*@unused@*/ … … 116 117 ("---promptdialogYN---1--- %s\r\n---promptdialogYN---Q--- [yes] [no] ---\r\n--> ", 117 118 prompt); 118 (void)getline(&tmp, &n, stdin);119 mr_getline(&tmp, &n, stdin); 119 120 if (tmp[strlen(tmp) - 1] == '\n') 120 121 tmp[strlen(tmp) - 1] = '\0'; … … 125 126 } 126 127 if (strstr(_("yesYES"), tmp)) { 127 paranoid_free(tmp);128 mr_free(tmp); 128 129 return (TRUE); 129 130 } else if (strstr(_("NOno"), tmp)) { 130 paranoid_free(tmp);131 mr_free(tmp); 131 132 return (FALSE); 132 133 } else { … … 161 162 ("---promptdialogOKC---1--- %s\r\n---promptdialogOKC---Q--- [OK] [Cancel] ---\r\n--> ", 162 163 prompt); 163 (void)getline(&tmp, &n, stdin);164 mr_getline(&tmp, &n, stdin); 164 165 if (tmp[strlen(tmp) - 1] == '\n') 165 166 tmp[strlen(tmp) - 1] = '\0'; … … 170 171 } 171 172 if (strstr(_("okOKOkYESyes"), tmp)) { 172 paranoid_free(tmp);173 mr_free(tmp); 173 174 return (TRUE); 174 175 } else { 175 paranoid_free(tmp);176 mr_free(tmp); 176 177 return (FALSE); 177 178 } … … 243 244 char *tmp = NULL; 244 245 245 asprintf(&tmp,"kill `ps %s | grep \" %s \" | awk '{print $1;}' | grep -vx \"\\?\"`", ps_options, str);246 mr_asprintf(&tmp,"kill `ps %s | grep \" %s \" | awk '{print $1;}' | grep -vx \"\\?\"`", ps_options, str); 246 247 run_program_and_log_output(tmp, TRUE); 247 paranoid_free(tmp);248 mr_free(tmp); 248 249 } 249 250 … … 264 265 /*@ end vars **************************************************** */ 265 266 266 asprintf(&fatalstr, "-------FATAL ERROR---------");267 mr_asprintf(&fatalstr, "-------FATAL ERROR---------"); 267 268 set_signals(FALSE); // link to external func 268 269 g_exiting = TRUE; … … 297 298 sync(); 298 299 if (g_tmpfs_mountpt != NULL) { 299 asprintf(&tmp, "umount %s", g_tmpfs_mountpt);300 mr_asprintf(&tmp, "umount %s", g_tmpfs_mountpt); 300 301 chdir("/"); 301 302 for (i = 0; i < 10 && run_program_and_log_output(tmp, 5); i++) { … … 304 305 run_program_and_log_output(tmp, 5); 305 306 } 306 paranoid_free(tmp);307 mr_free(tmp); 307 308 } 308 309 … … 312 313 313 314 if (g_selfmounted_isodir) { 314 asprintf(&command, "umount %s", g_selfmounted_isodir);315 mr_asprintf(&command, "umount %s", g_selfmounted_isodir); 315 316 run_program_and_log_output(command, 5); 316 asprintf(&command, "rmdir %s", g_selfmounted_isodir);317 mr_asprintf(&command, "rmdir %s", g_selfmounted_isodir); 317 318 run_program_and_log_output(command, 5); 318 paranoid_free(g_selfmounted_isodir);319 mr_free(g_selfmounted_isodir); 319 320 } 320 321 … … 322 323 log_msg(0, fatalstr); 323 324 log_msg(0, error_string); 324 // popup_and_OK (error_string);325 325 newtFinished(); 326 326 } 327 327 328 system329 ("gzip -9c "MONDO_LOGFILE" > /tmp/MA.log.gz 2> /dev/null");330 328 printf 331 329 (_("If you require technical support, please contact the mailing list.\n")); … … 334 332 (_("The list's members can help you, if you attach that file to your e-mail.\n")); 335 333 printf(_("Log file: %s\n"), MONDO_LOGFILE); 336 if (does_file_exist("/tmp/MA.log.gz")) {337 printf338 (_("FYI, I have gzipped the log and saved it to /tmp/MA.log.gz\n"));339 }340 334 printf(_("Mondo has aborted.\n")); 341 335 register_pid(0, "mondo"); // finish() does this too, FYI … … 357 351 finish(int signal) { 358 352 char *command = NULL; 359 360 /* if (signal==0) { popup_and_OK("Please press <enter> to quit."); } */361 362 /* newtPopHelpLine(); */363 353 364 354 register_pid(0, "mondo"); … … 371 361 } 372 362 if (g_selfmounted_isodir) { 373 asprintf(&command, "umount %s", g_selfmounted_isodir);363 mr_asprintf(&command, "umount %s", g_selfmounted_isodir); 374 364 run_program_and_log_output(command, 1); 375 asprintf(&command, "rmdir %s", g_selfmounted_isodir);365 mr_asprintf(&command, "rmdir %s", g_selfmounted_isodir); 376 366 run_program_and_log_output(command, 1); 377 paranoid_free(g_selfmounted_isodir); 378 } 379 // iamhere("foo"); 380 /* system("clear"); */ 381 // iamhere("About to call newtFinished"); 367 mr_free(g_selfmounted_isodir); 368 } 382 369 if (!g_text_mode) { 383 370 if (does_file_exist("/THIS-IS-A-RAMDISK")) { … … 389 376 } 390 377 } 391 // system("clear");392 // iamhere("Finished calling newtFinished");393 378 printf(_("Execution run ended; result=%d\n"), signal); 394 379 printf(_("Type 'less %s' to see the output log\n"), MONDO_LOGFILE); … … 428 413 } 429 414 if (grep_for_me[0] != '\0') { 430 asprintf(&command, "grep '%s' %s | tail -n%d",415 mr_asprintf(&command, "grep '%s' %s | tail -n%d", 431 416 grep_for_me, filename, g_noof_log_lines); 432 417 } else { 433 asprintf(&command, "tail -n%d %s", g_noof_log_lines, filename);418 mr_asprintf(&command, "tail -n%d %s", g_noof_log_lines, filename); 434 419 } 435 420 fin = popen(command, "r"); … … 440 425 for (; 441 426 strlen(err_log_lines[i]) < 2 && !feof(fin);) { 442 getline(&(err_log_lines[i]), &n, fin);427 mr_getline(&(err_log_lines[i]), &n, fin); 443 428 strip_spaces(err_log_lines[i]); 444 429 if (!strncmp(err_log_lines[i], "root:", 5)) { 445 asprintf(&tmp, "%s", err_log_lines[i] + 6);446 paranoid_free(err_log_lines[i]);430 mr_asprintf(&tmp, "%s", err_log_lines[i] + 6); 431 mr_free(err_log_lines[i]); 447 432 err_log_lines[i] = tmp; 448 433 } … … 455 440 } 456 441 refresh_log_screen(); 457 paranoid_free(command);442 mr_free(command); 458 443 } 459 444 … … 477 462 478 463 va_start(args, fmt); 479 vasprintf(&output, fmt, args);464 mr_vasprintf(&output, fmt, args); 480 465 log_msg(0, output); 481 466 if (strlen(output) > 80) { … … 489 474 490 475 if (err_log_lines) { 491 paranoid_free(err_log_lines[0]);476 mr_free(err_log_lines[0]); 492 477 for (i = 1; i < g_noof_log_lines; i++) { 493 478 err_log_lines[i - 1] = err_log_lines[i]; … … 549 534 550 535 assert(ttl != NULL); 551 asprintf(&title, ttl);536 mr_asprintf(&title, ttl); 552 537 // BERLIOS: We need to unallocate it somewhere 553 asprintf(&g_isoform_header_str, title);538 mr_asprintf(&g_isoform_header_str, title); 554 539 // center_string (title, 80); 555 540 if (g_text_mode) { 556 541 log_msg(0, title); 557 542 } else { 558 asprintf(&tmp, title);543 mr_asprintf(&tmp, title); 559 544 /* BERLIOS: center_string is now broken replace it ! */ 560 545 //center_string(tmp, 80); 561 546 newtPushHelpLine(tmp); 562 paranoid_free(tmp);547 mr_free(tmp); 563 548 } 564 549 /* BERLIOS: center_string is now broken replace it ! */ … … 581 566 } 582 567 update_evalcall_form(0); 583 paranoid_free(title);568 mr_free(title); 584 569 } 585 570 … … 613 598 assert(b3 != NULL); 614 599 615 asprintf(&blurb1, b1);616 asprintf(&blurb2, b2);617 asprintf(&blurb3, b3);618 asprintf(&b1c, b1);600 mr_asprintf(&blurb1, b1); 601 mr_asprintf(&blurb2, b2); 602 mr_asprintf(&blurb3, b3); 603 mr_asprintf(&b1c, b1); 619 604 /* BERLIOS: center_string is now broken replace it ! */ 620 605 //center_string(b1c, 80); … … 627 612 g_current_progress = 0; 628 613 // BERLIOS: We need to unallocate them 629 asprintf(&g_blurb_str_1, blurb1);630 asprintf(&g_blurb_str_2, blurb3);631 asprintf(&g_blurb_str_3, blurb2);614 mr_asprintf(&g_blurb_str_1, blurb1); 615 mr_asprintf(&g_blurb_str_2, blurb3); 616 mr_asprintf(&g_blurb_str_3, blurb2); 632 617 if (g_text_mode) { 633 618 log_msg(0, blurb1); … … 651 636 } 652 637 update_progress_form_full(blurb1, blurb2, blurb3); 653 paranoid_free(b1c);654 paranoid_free(blurb1);655 paranoid_free(blurb2);656 paranoid_free(blurb3);638 mr_free(b1c); 639 mr_free(blurb1); 640 mr_free(blurb2); 641 mr_free(blurb3); 657 642 } 658 643 … … 710 695 ("---promptstring---1--- %s\r\n---promptstring---2--- %s\r\n---promptstring---Q---\r\n--> ", 711 696 title, b); 712 paranoid_free(output);713 (void)getline(&output, &n, stdin);697 mr_free(output); 698 mr_getline(&output, &n, stdin); 714 699 if (output[strlen(output) - 1] == '\n') 715 700 output[strlen(output) - 1] = '\0'; 716 701 return (ret); 717 702 } 718 asprintf(&blurb, b);703 mr_asprintf(&blurb, b); 719 704 text = newtTextboxReflowed(2, 1, blurb, 48, 5, 5, 0); 720 705 … … 732 717 //center_string(blurb, 80); 733 718 newtPushHelpLine(blurb); 734 paranoid_free(blurb);719 mr_free(blurb); 735 720 736 721 b_res = newtRunForm(myForm); … … 741 726 // Copy entry_value before destroying the form 742 727 // clearing potentially output before 743 paranoid_alloc(output,*entry_value);728 mr_allocstr(output,*entry_value); 744 729 } 745 730 newtFormDestroy(myForm); … … 779 764 printf("%s (%s or %s) --> ", p, button1, button2); 780 765 } 781 for ( asprintf(&tmp, " ");766 for (mr_asprintf(&tmp, " "); 782 767 strcmp(tmp, button1) && (strlen(button2) == 0 783 768 || strcmp(tmp, button2));) { 784 769 printf("--> "); 785 paranoid_free(tmp);786 (void)getline(&tmp, &n, stdin);770 mr_free(tmp); 771 mr_getline(&tmp, &n, stdin); 787 772 } 788 773 if (!strcmp(tmp, button1)) { 789 paranoid_free(tmp);774 mr_free(tmp); 790 775 return (TRUE); 791 776 } else { 792 paranoid_free(tmp);777 mr_free(tmp); 793 778 return (FALSE); 794 779 } 795 780 } 796 781 797 asprintf(&prompt, p);782 mr_asprintf(&prompt, p); 798 783 text = newtTextboxReflowed(1, 1, prompt, 40, 5, 5, 0); 799 784 b_1 = … … 816 801 //center_string(prompt, 80); 817 802 newtPushHelpLine(prompt); 818 paranoid_free(prompt);803 mr_free(prompt); 819 804 b_res = newtRunForm(myForm); 820 805 newtPopHelpLine(); … … 943 928 || percentage > g_isoform_old_progress) { 944 929 g_isoform_old_progress = percentage; 945 asprintf(&timeline_str,930 mr_asprintf(&timeline_str, 946 931 _("%2ld:%02ld taken %2ld:%02ld remaining"), 947 932 time_taken / 60, time_taken % 60, time_remaining / 60, … … 968 953 *p = '\0'; 969 954 970 asprintf(&pcline_str, " Working%s%s %c", tmp1, tmp2,955 mr_asprintf(&pcline_str, " Working%s%s %c", tmp1, tmp2, 971 956 special_dot_char(g_mysterious_dot_counter)); 972 paranoid_free(tmp1);973 paranoid_free(tmp2);957 mr_free(tmp1); 958 mr_free(tmp2); 974 959 } else { 975 asprintf(&pcline_str,960 mr_asprintf(&pcline_str, 976 961 _(" %3d%% done %3d%% to go"), 977 962 percentage, 100 - percentage); … … 992 977 993 978 if (percentage >= 3) { 994 asprintf(&taskprogress,979 mr_asprintf(&taskprogress, 995 980 "TASK: [%s%s] %3d%% done; %2ld:%02ld to go", 996 981 tmp1, tmp2, percentage, time_remaining / 60, … … 1000 985 printf("---evalcall---2--- %s\r\n", taskprogress); 1001 986 printf("---evalcall---E---\r\n"); 1002 paranoid_free(taskprogress);987 mr_free(taskprogress); 1003 988 } 1004 989 } else { … … 1010 995 } 1011 996 } 1012 paranoid_free(timeline_str);1013 paranoid_free(pcline_str);997 mr_free(timeline_str); 998 mr_free(pcline_str); 1014 999 } 1015 1000 if (!g_text_mode) { … … 1032 1017 return; 1033 1018 } 1034 paranoid_free(g_blurb_str_2);1035 asprintf(&g_blurb_str_2, blurb3);1019 mr_free(g_blurb_str_2); 1020 mr_asprintf(&g_blurb_str_2, blurb3); 1036 1021 update_progress_form_full(g_blurb_str_1, g_blurb_str_2, 1037 1022 g_blurb_str_3); … … 1081 1066 } else { 1082 1067 if (g_current_progress > g_maximum_progress) { 1083 asprintf(&tmp,1068 mr_asprintf(&tmp, 1084 1069 "update_progress_form_full(%s,%s,%s) --- g_current_progress=%ld; g_maximum_progress=%ld", 1085 1070 blurb1, blurb2, blurb3, g_current_progress, 1086 1071 g_maximum_progress); 1087 1072 log_msg(0, tmp); 1088 paranoid_free(tmp);1073 mr_free(tmp); 1089 1074 g_current_progress = g_maximum_progress; 1090 1075 } … … 1108 1093 /* BERLIOS/ Is it useful here ? */ 1109 1094 //g_mysterious_dot_counter = (g_mysterious_dot_counter + 1) % 27; 1110 asprintf(&timeline_str,1095 mr_asprintf(&timeline_str, 1111 1096 "%2ld:%02ld taken %2ld:%02ld remaining ", 1112 1097 time_taken / 60, time_taken % 60, time_remaining / 60, 1113 1098 time_remaining % 60); 1114 asprintf(&percentline_str,1099 mr_asprintf(&percentline_str, 1115 1100 " %3d%% done %3d%% to go", percentage, 1116 1101 100 - percentage); … … 1138 1123 log_msg(2, _("percentage = %d"), percentage); 1139 1124 } 1140 asprintf(&taskprogress,1125 mr_asprintf(&taskprogress, 1141 1126 _("TASK: [%s%s] %3d%% done; %2ld:%02ld to go"), tmp1, 1142 1127 tmp2, percentage, time_remaining / 60, … … 1144 1129 1145 1130 printf(_("---progress-form---4--- %s\r\n"), taskprogress); 1146 paranoid_free(taskprogress);1131 mr_free(taskprogress); 1147 1132 } else { 1148 1133 /* BERLIOS: center_string is now broken replace it ! */ … … 1162 1147 newtRefresh(); 1163 1148 } 1164 paranoid_free(percentline_str);1165 paranoid_free(timeline_str);1149 mr_free(percentline_str); 1150 mr_free(timeline_str); 1166 1151 } 1167 1152 … … 1214 1199 } 1215 1200 printf(")\n--> "); 1216 (void)getline(&outstr, &n, stdin);1201 mr_getline(&outstr, &n, stdin); 1217 1202 strip_spaces(outstr); 1218 1203 for (i = 0; possible_responses[i]; i++) { … … 1222 1207 } 1223 1208 } 1224 paranoid_free(outstr);1209 mr_free(outstr); 1225 1210 return (backup_type); 1226 1211 } 1227 1212 newtDrawRootText(18, 0, WELCOME_STRING); 1228 1213 if (restoring) { 1229 asprintf(&title_sz,1214 mr_asprintf(&title_sz, 1230 1215 _("Please choose the backup media from which you want to read data.")); 1231 asprintf(&minimsg_sz, _("Read from:"));1232 } else { 1233 asprintf(&title_sz,1216 mr_asprintf(&minimsg_sz, _("Read from:")); 1217 } else { 1218 mr_asprintf(&title_sz, 1234 1219 _("Please choose the backup media to which you want to archive data.")); 1235 asprintf(&minimsg_sz, _("Backup to:"));1220 mr_asprintf(&minimsg_sz, _("Backup to:")); 1236 1221 } 1237 1222 newtPushHelpLine(title_sz); 1238 paranoid_free(title_sz);1223 mr_free(title_sz); 1239 1224 1240 1225 // newtOpenWindow (23, 3, 34, 17, minimsg_sz); 1241 1226 newtCenteredWindow(34, 17, minimsg_sz); 1242 paranoid_free(minimsg_sz);1227 mr_free(minimsg_sz); 1243 1228 1244 1229 b1 = newtButton(1, 1, _("CD-R disks ")); … … 1363 1348 break; 1364 1349 } 1365 (void)getline(&tmp, &n, fin);1350 mr_getline(&tmp, &n, fin); 1366 1351 i = (int) strlen(tmp); 1367 1352 if (i < 2) { … … 1385 1370 filelist->el[filelist->entries].severity = 1386 1371 severity_of_difference(tmp, reason); 1387 paranoid_free(reason);1372 mr_free(reason); 1388 1373 strcpy(filelist->el[filelist->entries].filename, tmp); 1389 1374 if (feof(fin)) { … … 1394 1379 if (filelist->entries >= ARBITRARY_MAXIMUM) { 1395 1380 log_to_screen(_("Arbitrary limits suck, man!")); 1396 paranoid_free(tmp);1381 mr_free(tmp); 1397 1382 return (1); 1398 1383 } 1399 paranoid_free(tmp);1384 mr_free(tmp); 1400 1385 1401 1386 for (done = FALSE; !done;) { … … 1442 1427 assert(flentry != NULL); 1443 1428 if (flentry->severity == 0) { 1444 asprintf(&comment, "0 %93s", flentry->filename);1429 mr_asprintf(&comment, "0 %93s", flentry->filename); 1445 1430 } else if (flentry->severity == 1) { 1446 asprintf(&comment, "low %93s", flentry->filename);1431 mr_asprintf(&comment, "low %93s", flentry->filename); 1447 1432 } else if (flentry->severity == 2) { 1448 asprintf(&comment, "med %93s", flentry->filename);1449 } else { 1450 asprintf(&comment, "high %93s", flentry->filename);1433 mr_asprintf(&comment, "med %93s", flentry->filename); 1434 } else { 1435 mr_asprintf(&comment, "high %93s", flentry->filename); 1451 1436 } 1452 1437 iamhere("leaving"); … … 1525 1510 keylist[i]); 1526 1511 } 1527 asprintf(&differ_sz,1512 mr_asprintf(&differ_sz, 1528 1513 _(" %ld files differ. Hit 'Select' to pick a file. Hit 'Close' to quit the list."), 1529 1514 i); 1530 1515 newtPushHelpLine(differ_sz); 1531 paranoid_free(differ_sz);1516 mr_free(differ_sz); 1532 1517 1533 1518 bClose = newtCompactButton(10, 15, _(" Close ")); 1534 1519 bSelect = newtCompactButton(30, 15, _(" Select ")); 1535 asprintf(&tmp, "%-10s %-20s", _("Priority"),1520 mr_asprintf(&tmp, "%-10s %-20s", _("Priority"), 1536 1521 _("Filename")); 1537 1522 headerMsg = newtLabel(2, 1, tmp); 1538 paranoid_free(tmp);1523 mr_free(tmp); 1539 1524 1540 1525 newtOpenWindow(5, 4, 70, 16, _("Non-matching files")); … … 1558 1543 severity_of_difference(filelist->el[currline]. 1559 1544 filename, reason); 1560 asprintf(&tmp, "%s --- %s",1545 mr_asprintf(&tmp, "%s --- %s", 1561 1546 filelist->el[currline].filename, reason); 1562 1547 popup_and_OK(tmp); 1563 paranoid_free(tmp);1564 paranoid_free(reason);1548 mr_free(tmp); 1549 mr_free(reason); 1565 1550 } 1566 1551 }
Note:
See TracChangeset
for help on using the changeset viewer.