Changeset 1207 in MondoRescue
- Timestamp:
- Feb 26, 2007, 6:20:46 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/src/mondorestore/mondo-rstr-newt.c
r1106 r1207 1 /* **************************************************************************1 /* 2 2 * $Id$ 3 3 */ 4 #include "mr_mem.h" 5 #include "mr_msg.h" 6 #include "mr_str.h" 7 4 8 5 9 /** … … 15 19 16 20 #include "mondo-rstr-newt.h" 17 #include "mr_mem.h" 21 22 //static char cvsid[] = "$Id$"; 18 23 19 24 /** … … 201 206 mr_free(device_str); 202 207 mr_asprintf(&device_str, device_here); 203 strip_spaces(device_str);208 mr_strip_spaces(device_str); 204 209 205 210 mr_free(format_str); 206 211 mr_asprintf(&format_str, format_here); 207 strip_spaces(format_str);212 mr_strip_spaces(format_str); 208 213 209 214 mr_free(mountpoint_str); 210 215 mr_asprintf(&mountpoint_str, mountpoint_here); 211 strip_spaces(mountpoint_str);216 mr_strip_spaces(mountpoint_str); 212 217 213 218 mr_free(size_str); 214 219 mr_asprintf(&size_str, size_here); 215 strip_spaces(size_str);220 mr_strip_spaces(size_str); 216 221 217 222 if (b_res == bOK) { … … 232 237 newtPopWindow(); 233 238 if (b_res == bCancel) { 239 mr_free(device_str); 240 mr_free(format_str); 241 mr_free(mountpoint_str); 242 mr_free(size_str); 234 243 return; 235 244 } … … 237 246 for (i = strlen(drive_to_add); isdigit(drive_to_add[i - 1]); i--); 238 247 num_to_add = atoi(drive_to_add + i); 239 drive_to_add[i] = '\0';240 248 mr_free(drive_to_add); 241 249 … … 282 290 ("Add variable", _("Enter the name of the variable to add"), 283 291 sz_out)) { 292 mr_strip_spaces(sz_out); 284 293 items = raidrec->additional_vars.entries; 285 294 for (i = 0; … … 322 331 int noof_partitions = 0; 323 332 324 long total_size = 0 ;325 long plex_size = 0 ;333 long total_size = 0L; 334 long plex_size = 0L; 326 335 long smallest_partition = 999999999; 327 336 long smallest_plex = 999999999; 328 long sp = 0; 329 330 char *tmp = NULL; 337 long sp = 0L; 338 331 339 char *devname = NULL; 332 340 … … 335 343 && strcmp(raidlist->el[i].volname, basename(raid_device)); i++); 336 344 if (i == raidlist->entries) { 337 mr_asprintf(&tmp, 338 "Cannot calc size of raid device %s - cannot find it in raidlist", 339 raid_device); 340 log_it(tmp); 341 mr_free(tmp); 345 log_it("Cannot calc size of raid device %s - cannot find it in raidlist", 346 raid_device); 342 347 return (0); // Isn't this more sensible than 999999999? If the raid dev !exists, 343 348 // then it has no size, right? … … 400 405 } 401 406 402 mr_asprintf(&tmp, "I have calculated %s's real size to be %ld", 403 raid_device, (long) smallest_plex); 404 log_it(tmp); 405 mr_free(tmp); 407 log_it("I have calculated %s's real size to be %ld", raid_device, 408 (long) smallest_plex); 406 409 return (smallest_plex); 407 410 #else … … 420 423 long sp = 0; 421 424 422 /** buffers ***********************************************************/423 char *tmp = NULL;424 425 425 assert(mountlist != NULL); 426 426 assert(raidlist != NULL); … … 431 431 && strcmp(raidlist->el[i].raid_device, raid_device); i++); 432 432 if (i == raidlist->entries) { 433 mr_asprintf(&tmp, 434 "Cannot calc size of raid device %s - cannot find it in raidlist", 435 raid_device); 436 log_it(tmp); 437 mr_free(tmp); 433 log_it("Cannot calc size of raid device %s - cannot find it in raidlist", 434 raid_device); 438 435 return (999999999); 439 436 } … … 458 455 total_size = smallest_partition * (noof_partitions - 1); 459 456 } 460 mr_asprintf(&tmp, "I have calculated %s's real size to be %ld", 461 raid_device, (long) total_size); 462 log_it(tmp); 463 mr_free(tmp); 457 log_it("I have calculated %s's real size to be %ld", raid_device, 458 (long) total_size); 464 459 return (total_size); 465 460 #endif … … 498 493 } 499 494 for (out = 999; out == 999;) { 500 res = popup_and_get_string( "Specify RAID level", prompt, tmp);495 res = popup_and_get_string(_("Specify RAID level"), prompt, tmp); 501 496 if (!res) { 497 mr_free(tmp); 498 mr_free(prompt); 502 499 return; 503 500 } 501 mr_strip_spaces(tmp); 504 502 /* BERLIOS: Useless ??? 505 503 if (tmp[0] == '[' && tmp[strlen(tmp) - 1] == ']') { … … 516 514 } else if (!strcmp(tmp, "raid5")) { 517 515 out = 5; 516 } else { 517 continue; 518 518 } 519 519 log_it(tmp); 520 520 mr_free(tmp); 521 521 522 if (is_this_raid_personality_registered(out)) { 522 523 log_it … … 524 525 } else { 525 526 if (ask_me_yes_or_no 526 ( "You have chosen a RAID personality which is not registered with the kernel. Make another selection?"))527 (_("You have chosen a RAID personality which is not registered with the kernel. Make another selection?"))) 527 528 { 528 529 out = 999; … … 556 557 out != -1 && out != 0 && out != 1 && out != 4 && out != 5 557 558 && out != 10;) { 558 res = 559 popup_and_get_string(_("Specify RAID level"), prompt, tmp); 559 res = popup_and_get_string(_("Specify RAID level"), prompt, tmp); 560 560 if (!res) { 561 561 return; 562 562 } 563 mr_strip_spaces(tmp); 563 564 /* BERLIOS: Useless ??? 564 565 if (tmp[0] == '[' && tmp[strlen(tmp) - 1] == ']') { … … 887 888 888 889 /** long **************************************************************/ 889 long i = 0 ;890 long i = 0L; 890 891 891 892 /** structures *******************************************************/ … … 897 898 898 899 /** bool *************************************************************/ 899 /* void*dummyptr; */ 900 bool dummybool; 901 static bool warned_already; 900 bool dummybool = FALSE; 901 static bool warned_already = FALSE; 902 902 903 903 assert(filelist != NULL); … … 943 943 lines_in_flist_window = ARBITRARY_MAXIMUM; 944 944 } 945 /* do an elementary sort */945 /* do an elementary sort */ 946 946 for (i = 1; i < lines_in_flist_window; i++) { 947 947 if (strcmp … … 960 960 } 961 961 } 962 /* write list to screen */962 /* write list to screen */ 963 963 newtListboxClear(listbox); 964 964 for (i = 0; i < lines_in_flist_window; i++) { … … 967 967 (g_is_path_expanded[i] ? '+' : '-'), 968 968 strip_path(g_strings_of_flist_window[i])); 969 // BERLIOS: this is dangerous now => Memory leak970 969 if (strlen(tmp) > 71) { 971 970 tmp[70] = '\0'; … … 1060 1059 1061 1060 /** ???? **************************************************************/ 1062 void *curr_choice ;1061 void *curr_choice = NULL; 1063 1062 void *keylist[ARBITRARY_MAXIMUM]; 1064 1063 1065 1064 /** bool **************************************************************/ 1066 bool dummybool; 1067 1068 /* struct s_node *node; */ 1065 bool dummybool = FALSE; 1066 1069 1067 1070 1068 assert(filelist != NULL); … … 1163 1161 return (0); 1164 1162 } else { 1165 /* popup_and_OK("You pushed 'cancel'. I shall now abort."); */1166 1163 return (1); 1167 1164 } … … 1230 1227 mr_asprintf(&size_str, "%lld", mountlist->el[currline].size / 1024); 1231 1228 1232 newtOpenWindow(20, 5, 48, 10, "Edit entry");1229 newtOpenWindow(20, 5, 48, 10, _("Edit entry")); 1233 1230 label0 = newtLabel(2, 1, _("Device:")); 1234 1231 label1 = newtLabel(2, 2, _("Mountpoint:")); … … 1269 1266 for (b_res = NULL; b_res != bOK && b_res != bCancel;) { 1270 1267 b_res = newtRunForm(myForm); 1271 1272 1268 mr_free(device_str); 1273 1269 mr_asprintf(&device_str, device_here); 1274 strip_spaces(device_str);1270 mr_strip_spaces(device_str); 1275 1271 1276 1272 mr_free(mountpoint_str); 1277 1273 mr_asprintf(&mountpoint_str, mountpoint_here); 1278 strip_spaces(mountpoint_str);1274 mr_strip_spaces(mountpoint_str); 1279 1275 1280 1276 mr_free(format_str); 1281 1277 mr_asprintf(&format_str, format_here); 1282 mr_ free(format_here);1283 strip_spaces(format_str); 1278 mr_strip_spaces(format_str); 1279 1284 1280 if (b_res == bOK && strstr(device_str, RAID_DEVICE_STUB) 1285 1281 && strstr(device_used_to_be, RAID_DEVICE_STUB) … … 1297 1293 mr_free(mountpt_used_to_be); 1298 1294 1295 mr_free(size_str); 1299 1296 if (!strstr(mountlist->el[currline].device, RAID_DEVICE_STUB) 1300 1297 && strcmp(mountlist->el[currline].mountpoint, "image")) { 1301 1298 mr_asprintf(&size_str, size_here); 1302 strip_spaces(size_str);1299 mr_strip_spaces(size_str); 1303 1300 } else { 1304 1301 mr_asprintf(&size_str, "%ld", … … 1308 1305 newtLabelSetText(sizeComp, size_str); 1309 1306 } 1310 mr_free(size_here);1311 1307 1312 1308 /* do not let user click RAID button if user has changed device_str */ … … 1339 1335 } 1340 1336 } 1341 mr_free(device_here);1342 mr_free(mountpoint_here);1343 1344 1337 newtFormDestroy(myForm); 1345 1338 newtPopHelpLine(); … … 1415 1408 struct vinum_plex *raidrec, char *temp) 1416 1409 { 1417 int i ;1410 int i = 0; 1418 1411 bool found = FALSE; 1419 1412 … … 1488 1481 1489 1482 /** buffers ***********************************************************/ 1490 char *title_of_editraidForm_window ;1483 char *title_of_editraidForm_window = NULL; 1491 1484 1492 1485 /** newt **************************************************************/ … … 1571 1564 mr_free(raidlevel); 1572 1565 newtListboxAppendEntry(plexesListbox, entry, keylist[i]); 1566 /* BERLIOS : hope it's not necessary anymore */ 1573 1567 mr_free(entry); 1574 1568 } … … 1733 1727 calculate_raid_device_size(mountlist, raidlist, 1734 1728 raidrec->raid_device); 1735 mr_free( (void*)bkp_raidrec);1729 mr_free(bkp_raidrec); 1736 1730 #endif 1737 1731 } 1732 1733 1738 1734 #ifdef __FreeBSD__ 1739 1740 1735 1741 1736 /** … … 1778 1773 1779 1774 void *keylist[ARBITRARY_MAXIMUM]; 1780 void *curr_choice_a , *curr_choice_u;1781 int currline_a , currline_u;1782 int i ;1775 void *curr_choice_a = NULL, *curr_choice_u = NULL; 1776 int currline_a = 0, currline_u = 0; 1777 int i = 0; 1783 1778 1784 1779 struct mountlist_itself *unallocparts = NULL; … … 1800 1795 switch (raidrec->raidlevel) { 1801 1796 case -1: 1802 mr_asprintf(&tmp, "concat");1797 mr_asprintf(&tmp, _("concat")); 1803 1798 break; 1804 1799 case 0: 1805 mr_asprintf(&tmp, "striped");1800 mr_asprintf(&tmp, _("striped")); 1806 1801 break; 1807 1802 case 5: 1808 mr_asprintf(&tmp, "raid5");1803 mr_asprintf(&tmp, _("raid5")); 1809 1804 break; 1810 1805 default: … … 1832 1827 bDelete = newtCompactButton(42, 16, _("Delete")); 1833 1828 1834 1835 // plexesListbox = newtListbox (2, 7, 9, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);1836 1829 unallocListbox = 1837 1830 newtListbox(2, 7, 7, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); … … 2026 2019 assert(raidlist != NULL); 2027 2020 2021 mr_asprintf(&flaws_str_A, "xxxxxxxxx"); 2022 mr_asprintf(&flaws_str_B, "xxxxxxxxx"); 2023 mr_asprintf(&flaws_str_C, "xxxxxxxxx"); 2028 2024 if (mountlist->entries > ARBITRARY_MAXIMUM) { 2029 2025 log_to_screen(_("Arbitrary limits suck, man!")); … … 2043 2039 _("Format"), _("Size (MB)")); 2044 2040 headerMsg = newtLabel(2, 1, tmp); 2045 flawsLabelA = newtLabel(2, 13, "x"); 2046 flawsLabelB = newtLabel(2, 14, "x"); 2047 flawsLabelC = newtLabel(2, 15, "x"); 2041 flawsLabelA = newtLabel(2, 13, flaws_str_A); 2042 flawsLabelB = newtLabel(2, 14, flaws_str_B); 2043 flawsLabelC = newtLabel(2, 15, flaws_str_C); 2044 mr_free(flaws_str_A); 2045 mr_free(flaws_str_B); 2046 mr_free(flaws_str_C); 2047 2048 2048 partitionsListbox = 2049 2049 newtListbox(2, 2, 10, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); … … 2123 2123 return (0); 2124 2124 } else { 2125 /* popup_and_OK("You pushed 'cancel'. I shall now abort."); */2126 2125 return (1); 2127 2126 } … … 2263 2262 2264 2263 /** bool **************************************************************/ 2265 bool done ;2264 bool done = FALSE; 2266 2265 2267 2266 assert(disklist != NULL); … … 2364 2363 if (popup_and_get_string 2365 2364 (_("ISO Mode - format"), 2366 _ 2367 ("What is the disk format of the device? (Hit ENTER if you don't know.)"), 2365 _("What is the disk format of the device? (Hit ENTER if you don't know.)"), 2368 2366 isodir_format)) { 2369 2367 if (popup_and_get_string 2370 2368 (_("ISO Mode - path"), 2371 _ 2372 ("At what path on this device can the ISO files be found?"), 2369 _("At what path on this device can the ISO files be found?"), 2373 2370 isodir_path)) { 2374 2371 // Same pb: … … 2532 2529 2533 2530 newtListboxClear(listbox); 2534 // sort_mountlist_by_device (mountlist);2535 2531 for (i = 0; i < ARBITRARY_MAXIMUM; i++) { 2536 2532 keylist[i] = (void *) i; … … 2669 2665 char *new_dev) 2670 2666 { 2671 /** buffers ********************************************************/2672 char *tmp;2673 2667 2674 2668 /** int ************************************************************/ … … 2682 2676 pos = which_raid_device_is_using_this_partition(raidlist, old_dev); 2683 2677 if (pos < 0) { 2684 mr_asprintf(&tmp,"No need to rejig %s in raidlist: it's not listed.",2678 log_it("No need to rejig %s in raidlist: it's not listed.", 2685 2679 old_dev); 2686 log_it(tmp);2687 mr_free(tmp);2688 2680 } else { 2689 2681 if ((j = … … 2717 2709 #endif 2718 2710 else { 2719 mr_asprintf(&tmp, 2720 "%s is supposed to be listed in this raid dev but it's not...", 2711 log_it("%s is supposed to be listed in this raid dev but it's not...", 2721 2712 old_dev); 2722 log_it(tmp);2723 mr_free(tmp);2724 2713 } 2725 2714 } … … 2829 2818 newtPushHelpLine(help_text); 2830 2819 mr_free(help_text); 2820 2831 2821 for (b_res = (newtComponent) 12345; b_res != bOK && b_res != bCancel;) { 2832 2822 headerMsg = newtLabel(1, 1, header_text); … … 2850 2840 b_res = newtRunForm(myForm); 2851 2841 if (b_res == bOK || b_res == bCancel) { /* do nothing */ 2852 // That's OK. At the end of this subroutine (after this do/while loop),2853 // we'll throw away the changes if Cancel was pushed.2842 // That's OK. At the end of this subroutine (after this do/while loop), 2843 // we'll throw away the changes if Cancel was pushed. 2854 2844 } else { 2855 2845 curr_choice = newtListboxGetCurrent(partitionsListbox); … … 2895 2885 mr_free(tmp); 2896 2886 mr_free(sz_res); 2887 2897 2888 redraw_disklist(disklist, keylist, partitionsListbox); 2898 2889 } … … 2914 2905 sizeof(struct list_of_disks)); 2915 2906 } 2916 mr_free( (void*)bkp_raidrec);2917 mr_free( (void*)bkp_disklist);2918 mr_free( (void*)bkp_raidlist);2919 mr_free( (void*)unallocated_raid_partitions);2907 mr_free(bkp_raidrec); 2908 mr_free(bkp_disklist); 2909 mr_free(bkp_raidlist); 2910 mr_free(unallocated_raid_partitions); 2920 2911 } 2921 2912 #endif
Note:
See TracChangeset
for help on using the changeset viewer.