Changeset 688 in MondoRescue for trunk/mondo/mondo/common/newt-specific.c
- Timestamp:
- Jul 17, 2006, 3:44:46 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/mondo/common/newt-specific.c
r588 r688 13 13 #define MAX_NEWT_COMMENT_LEN 200 14 14 15 #if __cplusplus 16 extern "C" { 17 #endif 15 #include <unistd.h> 18 16 19 17 #include "my-stuff.h" … … 111 109 if (g_text_mode) { 112 110 while (1) { 113 sy stem("sync");111 sync(); 114 112 printf 115 113 ("---promptdialogYN---1--- %s\r\n---promptdialogYN---Q--- [yes] [no] ---\r\n--> ", … … 130 128 return (FALSE); 131 129 } else { 132 sy stem("sync");130 sync(); 133 131 printf 134 132 (_("Please enter either YES or NO (or yes or no, or y or n, or...)\n")); … … 156 154 assert_string_is_neither_NULL_nor_zerolength(prompt); 157 155 if (g_text_mode) { 158 sy stem("sync");156 sync(); 159 157 printf 160 158 ("---promptdialogOKC---1--- %s\r\n---promptdialogOKC---Q--- [OK] [Cancel] ---\r\n--> ", … … 279 277 paranoid_system("killall mindi 2> /dev/null"); 280 278 kill_anything_like_this("/mondo/do-not"); 281 kill_anything_like_this(" tmp.mondo");279 kill_anything_like_this("mondo.tmp"); 282 280 kill_anything_like_this("ntfsclone"); 283 281 sync(); … … 291 289 paranoid_free(tmp); 292 290 293 if (g_erase_tmpdir_and_scratchdir [0]) {291 if (g_erase_tmpdir_and_scratchdir) { 294 292 run_program_and_log_output(g_erase_tmpdir_and_scratchdir, 5); 295 293 } … … 339 337 void 340 338 finish(int signal) { 341 char *command; 342 malloc_string(command); 339 char *command = NULL; 343 340 344 341 /* if (signal==0) { popup_and_OK("Please press <enter> to quit."); } */ … … 349 346 chdir("/"); 350 347 run_program_and_log_output("umount " MNT_CDROM, FALSE); 351 run_program_and_log_output("rm -Rf /mondo.scratch.* / tmp.mondo.*",348 run_program_and_log_output("rm -Rf /mondo.scratch.* /mondo.tmp.*", 352 349 FALSE); 353 350 if (g_erase_tmpdir_and_scratchdir) { … … 394 391 395 392 /*@ buffers ********************************************************** */ 396 char *command ;397 char *tmp ;393 char *command = NULL; 394 char *tmp = NULL; 398 395 399 396 /*@ pointers ********************************************************* */ 400 FILE *fin ;397 FILE *fin = NULL; 401 398 402 399 /*@ int ************************************************************** */ 403 400 int i = 0; 401 size_t n = 0; 404 402 405 403 assert_string_is_neither_NULL_nor_zerolength(filename); … … 420 418 } else { 421 419 for (i = 0; i < g_noof_log_lines; i++) { 422 for (err_log_lines[i][0] = '\0'; 423 strlen(err_log_lines[i]) < 2 && !feof(fin);) { 424 (void) fgets(err_log_lines[i], MAX_NEWT_COMMENT_LEN, 425 fin); 420 for (; 421 strlen(err_log_lines[i]) < 2 && !feof(fin);) { 422 getline(&(err_log_lines[i]), &n, fin); 426 423 strip_spaces(err_log_lines[i]); 427 424 if (!strncmp(err_log_lines[i], "root:", 5)) { 428 425 asprintf(&tmp, "%s", err_log_lines[i] + 6); 429 strcpy(err_log_lines[i], tmp);430 paranoid_free(tmp);426 paranoid_free(err_log_lines[i]); 427 err_log_lines[i] = tmp; 431 428 } 432 429 if (feof(fin)) { … … 456 453 457 454 /*@ buffers ********************************************************** */ 458 char *output ;455 char *output = NULL; 459 456 460 457 … … 472 469 473 470 if (err_log_lines) { 471 paranoid_free(&err_log_lines[0]); 474 472 for (i = 1; i < g_noof_log_lines; i++) { 475 strcpy(err_log_lines[i - 1], 476 " "); 477 strcpy(err_log_lines[i - 1], err_log_lines[i]); 473 err_log_lines[i - 1] = err_log_lines[i]; 478 474 } 479 475 } … … 487 483 } 488 484 if (err_log_lines) 489 strcpy(err_log_lines[g_noof_log_lines - 1], output);485 err_log_lines[g_noof_log_lines - 1] = output; 490 486 if (g_text_mode) { 491 487 printf("%s\n", output); … … 493 489 refresh_log_screen(); 494 490 } 495 paranoid_free(output); 496 } 497 498 491 } 499 492 500 493 … … 670 663 * @param b The blurb (e.g. what you want the user to enter). 671 664 * @param output The string to put the user's answer in. It has to be freed by the caller 672 * @param maxsize The size in bytes allocated to @p output.673 665 * @return TRUE if the user pressed OK, FALSE if they pressed Cancel. 674 666 */ 675 bool popup_and_get_string(char *title, char *b, char *output, 676 int maxsize) { 667 bool popup_and_get_string(char *title, char *b, char *output) { 677 668 678 669 /*@ newt ************************************************************ */ … … 685 676 686 677 /*@ pointers ********************************************************* */ 687 char *entry_value ;678 char *entry_value = NULL; 688 679 689 680 /*@ buffers ********************************************************** */ 690 char *blurb; 691 char *original_contents; 681 char *blurb = NULL; 692 682 size_t n = 0; 683 bool ret = TRUE; 693 684 694 685 assert_string_is_neither_NULL_nor_zerolength(title); … … 699 690 ("---promptstring---1--- %s\r\n---promptstring---2--- %s\r\n---promptstring---Q---\r\n--> ", 700 691 title, b); 692 paranoid_free(output); 701 693 (void) getline(&output, &n, stdin); 702 694 if (output[strlen(output) - 1] == '\n') 703 695 output[strlen(output) - 1] = '\0'; 704 return ( TRUE);696 return (ret); 705 697 } 706 698 asprintf(&blurb, b); 707 699 text = newtTextboxReflowed(2, 1, blurb, 48, 5, 5, 0); 708 original_contents = output;709 700 710 701 type_here = 711 702 newtEntry(2, newtTextboxGetNumLines(text) + 2, 712 original_contents, 50, 713 #ifdef __cplusplus 714 0, NEWT_FLAG_RETURNEXIT 715 #else 716 (void *) &entry_value, NEWT_FLAG_RETURNEXIT 717 #endif 703 output, 50, 704 &entry_value, NEWT_FLAG_RETURNEXIT 718 705 ); 719 706 b_1 = newtButton(6, newtTextboxGetNumLines(text) + 4, _(" OK ")); 720 707 b_2 = newtButton(18, newtTextboxGetNumLines(text) + 4, _("Cancel")); 721 // newtOpenWindow (8, 5, 54, newtTextboxGetNumLines (text) + 9, title);722 708 newtCenteredWindow(54, newtTextboxGetNumLines(text) + 9, title); 723 709 myForm = newtForm(NULL, NULL, 0); … … 727 713 newtPushHelpLine(blurb); 728 714 paranoid_free(blurb); 715 729 716 b_res = newtRunForm(myForm); 730 output = entry_value;731 717 newtPopHelpLine(); 718 if (b_res == b_2) { 719 ret = FALSE; 720 } else { 721 // Copy entry_value before destroying the form 722 // clearing potentially output before 723 paranoid_alloc(output,entry_value); 724 } 732 725 newtFormDestroy(myForm); 733 726 newtPopWindow(); 734 if (b_res == b_2) { 735 paranoid_free(output); 736 output = original_contents; 737 paranoid_free(original_contents); 738 return (FALSE); 739 } else { 740 paranoid_free(original_contents); 741 return (TRUE); 742 } 727 return(ret); 743 728 } 744 729 … … 846 831 newtRefresh(); 847 832 for (i = g_noof_log_lines - 1; i >= 0; i--) { 848 err_log_lines[i][79] = '\0';833 //BERLIOS : removed for now, Think it's useless : err_log_lines[i][79] = '\0'; 849 834 newtDrawRootText(0, i + g_noof_rows - 1 - g_noof_log_lines, 850 835 err_log_lines[i]); … … 884 869 885 870 for (i = 0; i < g_noof_log_lines; i++) { 886 err_log_lines[i] = (char *) malloc(MAX_NEWT_COMMENT_LEN); 887 if (!err_log_lines[i]) { 888 fatal_error("Out of memory"); 889 } 890 } 891 892 for (i = 0; i < g_noof_log_lines; i++) { 893 err_log_lines[i][0] = '\0'; 871 err_log_lines[i] = NULL; 894 872 } 895 873 } … … 1575 1553 1576 1554 1577 #if __cplusplus1578 } /* extern "C" */1579 #endif1580 1581 1582 1555 void wait_until_software_raids_are_prepped(char *mdstat_file, 1583 1556 int wait_for_percentage);
Note:
See TracChangeset
for help on using the changeset viewer.