Changeset 2377 in MondoRescue
- Timestamp:
- Sep 9, 2009, 1:03:53 PM (15 years ago)
- Location:
- branches/2.2.10/mondo/src/common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-string.c
r2356 r2377 868 868 * @return The severity (1-3). 869 869 */ 870 int severity_of_difference(char *fn, char *out_reason) 871 { 870 int severity_of_difference(char *fn, char *out_reason) { 871 872 872 int sev; 873 873 char *reason = NULL; -
branches/2.2.10/mondo/src/common/newt-specific.c
r2376 r2377 230 230 } 231 231 if (g_current_progress == -999) { 232 log_msg(2, 233 "Trying to close the progress form when it ain't open!"); 232 log_msg(2, "Trying to close the progress form when it ain't open!"); 234 233 return; 235 234 } … … 278 277 * @note This function never returns. 279 278 */ 280 void 281 fatal_error(char *error_string) { 279 void fatal_error(char *error_string) { 280 282 281 /*@ buffers ***************************************************** */ 283 282 char *command = NULL; … … 364 363 * @note This function never returns. 365 364 */ 366 365 void finish(int signal) { 367 366 368 367 char *command = NULL; … … 473 472 * @note The message is also written to the logfile. 474 473 */ 475 void 476 log_to_screen(const char *fmt, ...) { 474 void log_to_screen(const char *fmt, ...) { 477 475 478 476 /*@ int ************************************************************** */ … … 530 528 * @param output The string to write. 531 529 */ 532 void 533 mvaddstr_and_log_it(int y, int x, char *output) { 530 void mvaddstr_and_log_it(int y, int x, char *output) { 531 534 532 assert_string_is_neither_NULL_nor_zerolength(output); 535 533 log_msg(0, output); … … 549 547 * @param ttl The title to use for the evalcall form. 550 548 */ 551 void 552 open_evalcall_form(char *ttl) { 549 void open_evalcall_form(char *ttl) { 553 550 554 551 /*@ buffers ********************************************************* */ … … 603 600 * @param max_val The maximum amount of progress (number of filesets, etc.) 604 601 */ 605 void 606 open_progress_form(char *title, char *b1, char *b2, char *b3, 607 long max_val) { 602 void open_progress_form(char *title, char *b1, char *b2, char *b3, long max_val) { 608 603 609 604 /*@ buffers ********************************************************* */ … … 616 611 g_mysterious_dot_counter = 0; 617 612 618 malloc_string(blurb1);619 malloc_string(blurb2);620 malloc_string(blurb3);621 613 malloc_string(b1c); 622 614 … … 626 618 assert(b3 != NULL); 627 619 628 strcpy(blurb1, b1); 629 strcpy(blurb2, b2); 630 strcpy(blurb3, b3); 620 mr_asprintf(blurb1, "%s", b1); 621 mr_asprintf(blurb2, "%s", b2); 622 mr_asprintf(blurb3, "%s", b3); 623 631 624 strcpy(b1c, b1); 632 625 center_string(b1c, 80); … … 649 642 g_blurb2 = newtLabel(2, 2, blurb3); 650 643 g_blurb3 = newtLabel(2, 4, blurb2); 651 // newtOpenWindow (10, 4, 60, 11, title);652 644 newtCenteredWindow(60, 11, title); 653 645 g_scale = newtScale(3, 6, 54, g_maximum_progress); … … 655 647 g_percentline = newtLabel(10, 9, "This is the percentline"); 656 648 g_timeline = newtLabel(10, 8, "This is the timeline"); 657 newtFormAddComponents(g_progressForm, g_percentline, 658 g_timeline, g_scale, g_blurb1, g_blurb3, 659 g_blurb2, NULL); 649 newtFormAddComponents(g_progressForm, g_percentline, g_timeline, g_scale, g_blurb1, g_blurb3, g_blurb2, NULL); 660 650 newtPushHelpLine(b1c); 661 651 newtRefresh(); … … 672 662 * @param prompt The message. 673 663 */ 674 void 675 popup_and_OK(char *prompt) { 664 void popup_and_OK(char *prompt) { 665 676 666 char ch; 677 667 … … 680 670 log_msg(0, prompt); 681 671 if (g_text_mode) { 682 printf 683 ("---promptpopup---1--- %s\n---promptpopup---Q--- [OK] ---\n--> ", 684 prompt); 672 printf("---promptpopup---1--- %s\n---promptpopup---Q--- [OK] ---\n--> ", prompt); 685 673 while (((ch = getchar()) != '\n') && (ch != EOF)); 686 674 } else { … … 696 684 * @return output string if the user pressed OK, NULL if they pressed Cancel. 697 685 */ 698 686 char *popup_and_get_string(char *title, char *b, char *input) { 699 687 700 688 /*@ newt ************************************************************ */ … … 731 719 mr_asprintf(blurb, "%s", b); 732 720 text = newtTextboxReflowed(2, 1, blurb, 48, 5, 5, 0); 733 type_here = 734 newtEntry(2, newtTextboxGetNumLines(text) + 2, 735 input, 50, 721 type_here = newtEntry(2, newtTextboxGetNumLines(text) + 2, input, 50, 736 722 #ifdef __cplusplus 737 723 0, NEWT_FLAG_RETURNEXIT … … 768 754 * @return TRUE if @p button1 was pushed, FALSE otherwise. 769 755 */ 770 756 bool popup_with_buttons(char *p, char *button1, char *button2) { 771 757 772 758 /*@ buffers *********************************************************** */ … … 808 794 prompt[MAX_NEWT_COMMENT_LEN - 1] = '\0'; 809 795 text = newtTextboxReflowed(1, 1, prompt, 40, 5, 5, 0); 810 b_1 = 811 newtButton(20 - 812 ((button2[0] != 813 '\0') ? strlen(button1) + 814 2 : strlen(button1) / 2), 815 newtTextboxGetNumLines(text) + 3, button1); 796 b_1 = newtButton(20 - ((button2[0] != '\0') ? strlen(button1) + 2 : strlen(button1) / 2), newtTextboxGetNumLines(text) + 3, button1); 816 797 if (button2[0] != '\0') { 817 b_2 = 818 newtButton(24, newtTextboxGetNumLines(text) + 3, button2); 798 b_2 = newtButton(24, newtTextboxGetNumLines(text) + 3, button2); 819 799 } else { 820 800 b_2 = NULL; 821 801 } 822 // newtOpenWindow (25, 5, 46, newtTextboxGetNumLines (text) + 7, "Alert");823 802 newtCenteredWindow(46, newtTextboxGetNumLines(text) + 7, "Alert"); 824 803 myForm = newtForm(NULL, NULL, 0); … … 846 825 * on the screen. 847 826 */ 848 void 849 refresh_log_screen() { 827 void refresh_log_screen() { 850 828 851 829 /*@ int *********************************************************** */ … … 874 852 * only allocate some memory. 875 853 */ 876 void 877 setup_newt_stuff() { 854 void setup_newt_stuff() { 878 855 879 856 /*@ int *********************************************************** */ … … 908 885 * @param denom The denomenator of the ratio. 909 886 */ 910 void 911 update_evalcall_form_ratio(int num, int denom) { 887 void update_evalcall_form_ratio(int num, int denom) { 912 888 913 889 /*@ long ************************************************************ */ … … 1001 977 * @param curr The current amount of progress (percentage) in the evalcall form. 1002 978 */ 1003 void 1004 update_evalcall_form(int curr) { 979 void update_evalcall_form(int curr) { 980 1005 981 update_evalcall_form_ratio(curr, 100); 1006 982 } 1007 983 1008 984 … … 1013 989 * @param blurb3 The new third line of the blurb; use @p g_blurb_str_2 (no, that's not a typo) to keep it the same. 1014 990 */ 1015 void 1016 update_progress_form(char *blurb3) { 991 void update_progress_form(char *blurb3) { 992 1017 993 if (g_current_progress == -999) { 1018 994 return; 1019 995 } 1020 996 strcpy(g_blurb_str_2, blurb3); 1021 update_progress_form_full(g_blurb_str_1, g_blurb_str_2, 1022 g_blurb_str_3); 1023 } 997 update_progress_form_full(g_blurb_str_1, g_blurb_str_2, g_blurb_str_3); 998 } 1024 999 1025 1000 … … 1030 1005 * @param blurb3 The third line of the blurb. Use @p g_blurb_str_2 (no, that's not a typo either) to keep it the same. 1031 1006 */ 1032 void 1033 update_progress_form_full(char *blurb1, char *blurb2, char *blurb3) { 1007 void update_progress_form_full(char *blurb1, char *blurb2, char *blurb3) { 1008 1034 1009 /*@ long ***************************************************** */ 1035 1010 long current_time = 0L; … … 1136 1111 * @return The backup type chosen, or @c none if the user chose "Exit to shell". 1137 1112 */ 1138 1113 t_bkptype which_backup_media_type(bool restoring) { 1139 1114 1140 1115 /*@ char ************************************************************ */ … … 1145 1120 char *title_sz = NULL; 1146 1121 char *minimsg_sz = NULL; 1147 static t_bkptype possible_bkptypes[] = 1148 { none, cdr, cdrw, dvd, tape, cdstream, udev, nfs, iso }; 1149 static char *possible_responses[] = 1150 { "none", "cdr", "cdrw", "dvd", "tape", "cdstream", "udev", 1151 "nfs", "iso", NULL }; 1122 static t_bkptype possible_bkptypes[] = { none, cdr, cdrw, dvd, tape, cdstream, udev, nfs, iso }; 1123 static char *possible_responses[] = { "none", "cdr", "cdrw", "dvd", "tape", "cdstream", "udev", "nfs", "iso", NULL }; 1152 1124 char *outstr = NULL; 1153 1125 t_bkptype backup_type; … … 1240 1212 * @return The compression level (0-9) chosen, or -1 for "Exit". 1241 1213 */ 1242 int 1243 which_compression_level() { 1214 int which_compression_level() { 1244 1215 1245 1216 /*@ char ************************************************************ */ … … 1258 1229 1259 1230 newtDrawRootText(18, 0, WELCOME_STRING); 1260 newtPushHelpLine 1261 (" Please specify the level of compression that you want."); 1262 // newtOpenWindow (23, 3, 34, 13, "How much compression?"); 1231 newtPushHelpLine(" Please specify the level of compression that you want."); 1263 1232 newtCenteredWindow(34, 13, "How much compression?"); 1264 1233 b1 = newtButton(4, 1, "Maximum"); … … 1297 1266 * @param source_file The file containing a list of filenames to load into @p filelist. 1298 1267 */ 1299 int load_filelist_into_array(struct s_filelist *filelist, 1300 char *source_file) { 1268 int load_filelist_into_array(struct s_filelist *filelist, char *source_file) { 1269 1301 1270 int i; 1302 1271 int j = 0; … … 1326 1295 1327 1296 log_msg(2, "Loading %s", source_file); 1328 for (filelist->entries = 0; filelist->entries <= ARBITRARY_MAXIMUM; filelist->entries++) { 1329 god_i_hate_gotos: 1297 for (filelist->entries = 0; filelist->entries <= ARBITRARY_MAXIMUM; ) { 1330 1298 if (tmp != NULL) { 1331 1299 mr_free(tmp); … … 1337 1305 i = (int) strlen(tmp); 1338 1306 if (i < 2) { 1339 goto god_i_hate_gotos;1307 continue; 1340 1308 } 1341 1309 if (tmp[i - 1] < 32) { … … 1343 1311 } 1344 1312 if (i < 2) { 1345 goto god_i_hate_gotos;1313 continue; 1346 1314 } 1347 1315 if (!does_file_exist(tmp) && !feof(fin)) { 1348 1316 j++; 1349 1317 fprintf(fout, "%s\n", tmp); 1350 1351 goto god_i_hate_gotos; 1318 continue; 1352 1319 } 1353 1320 filelist->el[filelist->entries].severity = severity_of_difference(tmp, NULL); … … 1356 1323 break; 1357 1324 } 1325 filelist->entries++; 1358 1326 } 1359 1327 mr_free(tmp); … … 1398 1366 1399 1367 1400 1401 1368 /** 1402 1369 * Generate a pretty string based on @p flentry. … … 1405 1372 * @note The returned value points to static storage that will be overwritten with each call. 1406 1373 */ 1407 char *filelist_entry_to_string(struct s_filelist_entry *flentry) { 1408 static char comment[100]; 1374 char *filelist_entry_to_string(struct s_filelist_entry *flentry) { 1409 1375 char *tmp = NULL; 1410 1376 1411 log_ it("entering");1377 log_msg(8, "entering"); 1412 1378 assert(flentry != NULL); 1413 1379 if (flentry->severity == 0) { … … 1420 1386 mr_asprintf(tmp, "high"); 1421 1387 } 1422 mr_strcat(tmp, " "); 1423 mr_strcat(tmp, flentry->filename); 1424 strncpy(comment, tmp, 99); 1425 paranoid_free(tmp); 1426 1427 log_it("leaving"); 1428 return (comment); 1429 } 1430 1431 1432 1388 mr_strcat(tmp, " %s", flentry->filename); 1389 1390 log_msg(8, "leaving"); 1391 return (tmp); 1392 } 1433 1393 1434 1394 … … 1438 1398 * @param source_file The file containing a list of changed files. 1439 1399 */ 1440 void popup_changelist_from_file(char *source_file) { 1400 void popup_changelist_from_file(char *source_file) { 1401 1441 1402 char *reason; 1442 1403 newtComponent myForm; … … 1489 1450 return; 1490 1451 } 1491 log_msg(2, "%d files loaded into filelist array", 1492 filelist->entries); 1452 log_msg(2, "%d files loaded into filelist array", filelist->entries); 1493 1453 for (i = 0; i < filelist->entries; i++) { 1494 1454 keylist[i] = (void *) i; 1495 newtListboxAppendEntry(fileListbox, 1496 filelist_entry_to_string(& 1497 (filelist-> 1498 el[i])), 1499 keylist[i]); 1455 tmp = filelist_entry_to_string(&(filelist->el[i])), keylist[i]; 1456 newtListboxAppendEntry(fileListbox, tmp); 1457 mr_free(tmp); 1500 1458 } 1501 1459 mr_asprintf(differ_sz, " %ld files differ. Hit 'Select' to pick a file. Hit 'Close' to quit the list.", i); … … 1511 1469 newtOpenWindow(5, 4, 70, 16, "Non-matching files"); 1512 1470 myForm = newtForm(NULL, NULL, 0); 1513 newtFormAddComponents(myForm, headerMsg, fileListbox, bClose, 1514 bSelect, NULL); 1471 newtFormAddComponents(myForm, headerMsg, fileListbox, bClose, bSelect, NULL); 1515 1472 1516 1473 malloc_string(reason); … … 1554 1511 1555 1512 1556 void wait_until_software_raids_are_prepped(char *mdstat_file, 1557 int wait_for_percentage); 1513 void wait_until_software_raids_are_prepped(char *mdstat_file, int wait_for_percentage);
Note:
See TracChangeset
for help on using the changeset viewer.