Changeset 1206 in MondoRescue
- Timestamp:
- Feb 26, 2007, 6:20:12 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/mondorestore/mondo-rstr-newt.c
r1168 r1206 1 /* **************************************************************************1 /* 2 2 * $Id$ 3 3 */ … … 16 16 #ifdef __FreeBSD__ 17 17 #define OSSWAP(linux,fbsd) fbsd 18 //#include <libgen.h>19 18 #else 20 19 #define OSSWAP(linux,fbsd) linux … … 62 61 { 63 62 /** buffers ***********************************************************/ 64 char tmp[MAX_STR_LEN];63 char *tmp = NULL; 65 64 66 65 /** newt **************************************************************/ … … 87 86 88 87 newtPushHelpLine 89 (" Add one of the following unallocated RAID partitions to this RAID device."); 90 sprintf(tmp, "%-26s %s", "Device", "Size"); 88 (_ 89 (" Add one of the following unallocated RAID partitions to this RAID device.")); 90 mr_asprintf(&tmp, "%-26s %s", _("Device"), _("Size")); 91 91 headerMsg = newtLabel(1, 1, tmp); 92 mr_free(tmp); 93 92 94 partitionsListbox = 93 95 newtListbox(1, 2, 6, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); … … 95 97 partitionsListbox); 96 98 i = 7; 97 bOK = newtCompactButton(i, 9, " OK ");98 bCancel = newtCompactButton(i += 9, 9, "Cancel");99 newtOpenWindow(22, 6, 36, 10, "Unallocated RAID partitions");99 bOK = newtCompactButton(i, 9, _(" OK ")); 100 bCancel = newtCompactButton(i += 9, 9, _("Cancel")); 101 newtOpenWindow(22, 6, 36, 10, _("Unallocated RAID partitions")); 100 102 myForm = newtForm(NULL, NULL, 0); 101 103 newtFormAddComponents(myForm, headerMsg, partitionsListbox, bOK, … … 127 129 128 130 129 130 131 131 /** 132 132 * Add an entry to @p mountlist. … … 162 162 newtComponent formatComp; 163 163 164 /** buffers **********************************************************/ 165 char drive_to_add[MAX_STR_LEN]; 166 char mountpoint_str[MAX_STR_LEN]; 167 char size_str[MAX_STR_LEN]; 168 char device_str[MAX_STR_LEN]; 169 char format_str[MAX_STR_LEN]; 170 171 /** pointers *********************************************************/ 172 char *mountpoint_here; 173 char *size_here; 174 char *device_here; 175 char *format_here; 164 char *drive_to_add = NULL; 165 char *mountpoint_str = NULL; 166 char *size_str = NULL; 167 char *device_str = NULL; 168 char *format_str = NULL; 169 char *mountpoint_here = NULL; 170 char *size_here = NULL; 171 char *device_here = NULL; 172 char *format_here = NULL; 176 173 177 174 assert(mountlist != NULL); … … 180 177 assert(keylist != NULL); 181 178 182 strcpy(device_str, "/dev/");183 strcpy(mountpoint_str, "/");179 mr_asprintf(&device_str, "/dev/"); 180 mr_asprintf(&mountpoint_str, "/"); 184 181 #ifdef __FreeBSD__ 185 strcpy(format_str, "ufs");182 mr_asprintf(&format_str, "ufs"); 186 183 #else 187 strcpy(format_str, "ext2");184 mr_asprintf(&format_str, "ext2"); 188 185 #endif 189 size_str[0] = '\0'; 190 /* sprintf(size_str,""); */ 191 newtOpenWindow(20, 5, 48, 10, "Add entry"); 192 label0 = newtLabel(2, 1, "Device: "); 193 label1 = newtLabel(2, 2, "Mountpoint:"); 194 label2 = newtLabel(2, 3, "Size (MB): "); 195 label3 = newtLabel(2, 4, "Format: "); 186 newtOpenWindow(20, 5, 48, 10, _("Add entry")); 187 label0 = newtLabel(2, 1, _("Device: ")); 188 label1 = newtLabel(2, 2, _("Mountpoint:")); 189 label2 = newtLabel(2, 3, _("Size (MB): ")); 190 label3 = newtLabel(2, 4, _("Format: ")); 196 191 deviceComp = 197 192 newtEntry(14, 1, device_str, 30, (void *) &device_here, 0); 198 193 mountpointComp = 199 194 newtEntry(14, 2, mountpoint_str, 30, (void *) &mountpoint_here, 0); 195 200 196 formatComp = 201 197 newtEntry(14, 4, format_str, 15, (void *) &format_here, 0); 202 198 sizeComp = newtEntry(14, 3, size_str, 10, (void *) &size_here, 0); 203 bOK = newtButton(5, 6, " OK ");204 bCancel = newtButton(17, 6, "Cancel");199 bOK = newtButton(5, 6, _(" OK ")); 200 bCancel = newtButton(17, 6, _("Cancel")); 205 201 newtPushHelpLine 206 ("To add an entry to the mountlist, please fill in these fields and then hit 'OK'"); 202 (_ 203 ("To add an entry to the mountlist, please fill in these fields and then hit 'OK'")); 207 204 myForm = newtForm(NULL, NULL, 0); 208 205 newtFormAddComponents(myForm, deviceComp, mountpointComp, sizeComp, … … 211 208 for (b_res = NULL; b_res != bOK && b_res != bCancel;) { 212 209 b_res = newtRunForm(myForm); 213 strcpy(device_str, device_here); 214 strcpy(mountpoint_str, mountpoint_here); 215 strcpy(format_str, format_here); 216 strcpy(size_str, size_here); 217 // log_it ("Originals = %s,%s,%s,%s", device_str, mountpoint_str, format_str, size_str); 210 211 mr_free(device_str); 212 mr_asprintf(&device_str, device_here); 218 213 mr_strip_spaces(device_str); 214 215 mr_free(format_str); 216 mr_asprintf(&format_str, format_here); 217 mr_strip_spaces(format_str); 218 219 mr_free(mountpoint_str); 220 mr_asprintf(&mountpoint_str, mountpoint_here); 219 221 mr_strip_spaces(mountpoint_str); 220 mr_strip_spaces(format_str); 222 223 mr_free(size_str); 224 mr_asprintf(&size_str, size_here); 221 225 mr_strip_spaces(size_str); 222 // log_it ("Modified = %s,%s,%s,%s", device_str, mountpoint_str, format_str, size_str); 226 223 227 if (b_res == bOK) { 224 228 if (device_str[strlen(device_str) - 1] == '/') { 225 popup_and_OK( "You left the device nearly blank!");229 popup_and_OK(_("You left the device nearly blank!")); 226 230 b_res = NULL; 227 231 } 228 232 if (size_of_specific_device_in_mountlist(mountlist, device_str) 229 233 >= 0) { 230 popup_and_OK("Can't add this - you've got one already!"); 234 popup_and_OK(_ 235 ("Can't add this - you've got one already!")); 231 236 b_res = NULL; 232 237 } … … 237 242 newtPopWindow(); 238 243 if (b_res == bCancel) { 244 mr_free(device_str); 245 mr_free(format_str); 246 mr_free(mountpoint_str); 247 mr_free(size_str); 239 248 return; 240 249 } 241 strcpy(drive_to_add, device_str);250 mr_asprintf(&drive_to_add, device_str); 242 251 for (i = strlen(drive_to_add); isdigit(drive_to_add[i - 1]); i--); 243 252 num_to_add = atoi(drive_to_add + i); 244 drive_to_add[i] = '\0'; 253 mr_free(drive_to_add); 254 245 255 currline = mountlist->entries; 246 256 strcpy(mountlist->el[currline].device, device_str); 247 257 strcpy(mountlist->el[currline].mountpoint, mountpoint_str); 258 mr_free(mountpoint_str); 259 248 260 strcpy(mountlist->el[currline].format, format_str); 261 mr_free(format_str); 262 249 263 mountlist->el[currline].size = atol(size_str) * 1024; 264 mr_free(size_str); 265 250 266 mountlist->entries++; 251 267 if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)) { … … 253 269 device_str); 254 270 } 271 mr_free(device_str); 255 272 redraw_mountlist(mountlist, keylist, listbox); 256 273 } … … 267 284 268 285 /** buffers ***********************************************************/ 269 char sz_out[MAX_STR_LEN];286 char *sz_out = NULL; 270 287 271 288 /** int ****************************************************************/ … … 275 292 assert(raidrec != NULL); 276 293 277 sz_out[0] = '\0';294 malloc_string(sz_out); 278 295 if (popup_and_get_string 279 ("Add variable", "Enter the name of the variable to add", sz_out,296 ("Add variable", _("Enter the name of the variable to add"), sz_out, 280 297 MAX_STR_LEN)) { 281 298 mr_strip_spaces(sz_out); … … 286 303 if (i < items) { 287 304 popup_and_OK 288 ("No need to add that variable. It is already listed here."); 305 (_ 306 ("No need to add that variable. It is already listed here.")); 289 307 } else { 290 308 strcpy(raidrec->additional_vars.el[items].label, sz_out); … … 293 311 } 294 312 } 313 mr_free(sz_out); 295 314 } 296 315 #endif … … 313 332 314 333 /** structures ********************************************************/ 315 struct vinum_volume *raidrec; 316 317 /** int ***************************************************************/ 334 struct vinum_volume *raidrec = NULL; 335 318 336 int i = 0, j = 0; 319 337 int noof_partitions = 0; 320 338 321 /** long **************************************************************/ 322 long total_size = 0; 323 long plex_size = 0; 339 long total_size = 0L; 340 long plex_size = 0L; 324 341 long smallest_partition = 999999999; 325 342 long smallest_plex = 999999999; 326 long sp = 0; 327 328 /** buffers ***********************************************************/ 329 char tmp[MAX_STR_LEN]; 330 331 332 343 long sp = 0L; 344 345 char *devname = NULL; 333 346 334 347 for (i = 0; … … 336 349 && strcmp(raidlist->el[i].volname, basename(raid_device)); i++); 337 350 if (i == raidlist->entries) { 338 sprintf(tmp, 339 "Cannot calc size of raid device %s - cannot find it in raidlist", 351 log_it("Cannot calc size of raid device %s - cannot find it in raidlist", 340 352 raid_device); 341 log_it(tmp);342 353 return (0); // Isn't this more sensible than 999999999? If the raid dev !exists, 343 354 // then it has no size, right? … … 351 362 int k = 0, l = 0; 352 363 for (k = 0; k < raidrec->plex[j].subdisks; ++k) { 353 char devname[64]; 354 strcpy(devname, raidrec->plex[j].sd[k].which_device); 364 mr_asprintf(&devname, raidrec->plex[j].sd[k].which_device); 355 365 for (l = 0; l < raidlist->disks.entries; ++l) { 356 366 if (!strcmp(devname, raidlist->disks.el[l].name)) { … … 380 390 } 381 391 } 392 mr_free(devname); 382 393 } 383 394 … … 400 411 } 401 412 402 sprintf(tmp,"I have calculated %s's real size to be %ld", raid_device,413 log_it("I have calculated %s's real size to be %ld", raid_device, 403 414 (long) smallest_plex); 404 log_it(tmp);405 415 return (smallest_plex); 406 416 #else … … 408 418 409 419 /** structures ********************************************************/ 410 struct raid_device_record *raidrec ;420 struct raid_device_record *raidrec = NULL; 411 421 412 422 /** int ***************************************************************/ … … 419 429 long sp = 0; 420 430 421 /** buffers ***********************************************************/422 char tmp[MAX_STR_LEN];423 424 431 assert(mountlist != NULL); 425 432 assert(raidlist != NULL); … … 430 437 && strcmp(raidlist->el[i].raid_device, raid_device); i++); 431 438 if (i == raidlist->entries) { 432 sprintf(tmp, 433 "Cannot calc size of raid device %s - cannot find it in raidlist", 439 log_it("Cannot calc size of raid device %s - cannot find it in raidlist", 434 440 raid_device); 435 log_it(tmp);436 441 return (999999999); 437 442 } … … 456 461 total_size = smallest_partition * (noof_partitions - 1); 457 462 } 458 sprintf(tmp,"I have calculated %s's real size to be %ld", raid_device,463 log_it("I have calculated %s's real size to be %ld", raid_device, 459 464 (long) total_size); 460 log_it(tmp);461 465 return (total_size); 462 466 #endif 463 467 } 464 465 468 466 469 … … 481 484 482 485 /** buffers ***********************************************************/ 483 char tmp[MAX_STR_LEN]; 484 char prompt[MAX_STR_LEN]; 485 char sz[MAX_STR_LEN]; 486 487 sprintf(prompt, 488 "Please enter the RAID level you want. (concat, striped, raid5)"); 486 char *tmp = NULL; 487 char *prompt = NULL; 488 char *sz = NULL; 489 490 malloc_string(tmp); 491 mr_asprintf(&prompt, 492 _ 493 ("Please enter the RAID level you want. (concat, striped, raid5)")); 489 494 if (raidrec->raidlevel == -1) { 490 495 strcpy(tmp, "concat"); … … 492 497 strcpy(tmp, "striped"); 493 498 } else { 494 s printf(tmp, "raid%i", raidrec->raidlevel);499 strcpy(tmp, "raid%i", raidrec->raidlevel); 495 500 } 496 501 for (out = 999; out == 999;) { 497 res = popup_and_get_string( "Specify RAID level", prompt, tmp, 10);502 res = popup_and_get_string(_("Specify RAID level"), prompt, tmp, 10); 498 503 if (!res) { 504 mr_free(tmp); 505 mr_free(prompt); 499 506 return; 500 507 } 501 508 mr_strip_spaces(tmp); 509 /* BERLIOS: Useless ??? */ 502 510 if (tmp[0] == '[' && tmp[strlen(tmp) - 1] == ']') { 503 strcpy(sz, tmp);511 mr_asprintf(&sz, tmp); 504 512 strncpy(tmp, sz + 1, strlen(sz) - 2); 505 513 tmp[strlen(sz) - 2] = '\0'; 514 mr_free(sz); 506 515 } 507 516 if (!strcmp(tmp, "concat")) { … … 511 520 } else if (!strcmp(tmp, "raid5")) { 512 521 out = 5; 522 } else { 523 continue; 524 } 525 log_it(tmp); 526 527 if (is_this_raid_personality_registered(out)) { 528 log_it 529 ("Groovy. You've picked a RAID personality which is registered."); 530 } else { 531 if (ask_me_yes_or_no 532 (_("You have chosen a RAID personality which is not registered with the kernel. Make another selection?"))) 533 { 534 out = 999; 535 } 536 } 537 } 538 mr_free(prompt); 539 mr_free(tmp); 540 raidrec->raidlevel = out; 541 #else 542 /** buffers ***********************************************************/ 543 char *tmp = NULL; 544 char *personalities = NULL; 545 char *prompt = NULL; 546 char *sz = NULL; 547 int out = 0, res = 0; 548 549 malloc_string(tmp); 550 assert(raidrec != NULL); 551 system 552 ("grep Pers /proc/mdstat > /tmp/raid-personalities.txt 2> /dev/null"); 553 mr_asprintf(&personalities, 554 last_line_of_file("/tmp/raid-personalities.txt")); 555 mr_asprintf(&prompt, _("Please enter the RAID level you want. %s"), 556 personalities); 557 mr_free(personalities); 558 559 if (raidrec->raid_level == -1) { 560 strcpy(tmp, "linear"); 561 } else { 562 sprintf(tmp, "%d", raidrec->raid_level); 563 } 564 for (out = 999; 565 out != -1 && out != 0 && out != 1 && out != 4 && out != 5 566 && out != 10;) { 567 res = popup_and_get_string(_("Specify RAID level"), prompt, tmp, 10); 568 if (!res) { 569 return; 570 } 571 mr_strip_spaces(tmp); 572 /* BERLIOS: Useless ??? */ 573 if (tmp[0] == '[' && tmp[strlen(tmp) - 1] == ']') { 574 mr_asprintf(&sz, tmp); 575 strncpy(tmp, sz + 1, strlen(sz) - 2); 576 tmp[strlen(sz) - 2] = '\0'; 577 mr_free(sz); 578 } 579 if (!strcmp(tmp, "linear")) { 580 out = -1; 581 } else if (!strncmp(tmp, "raid", 4)) { 582 out = atoi(tmp + 4); 583 } else { 584 out = atoi(tmp); 513 585 } 514 586 log_it(tmp); … … 518 590 } else { 519 591 if (ask_me_yes_or_no 520 ("You have chosen a RAID personality which is not registered with the kernel. Make another selection?")) 592 (_ 593 ("You have chosen a RAID personality which is not registered with the kernel. Make another selection?"))) 521 594 { 522 595 out = 999; … … 524 597 } 525 598 } 526 raidrec->raidlevel = out; 527 #else 528 /** buffers ***********************************************************/ 529 char tmp[MAX_STR_LEN]; 530 char personalities[MAX_STR_LEN]; 531 char prompt[MAX_STR_LEN]; 532 char sz[MAX_STR_LEN]; 533 int out = 0, res = 0; 534 535 536 assert(raidrec != NULL); 537 system 538 ("grep Pers /proc/mdstat > /tmp/raid-personalities.txt 2> /dev/null"); 539 strcpy(personalities, 540 last_line_of_file("/tmp/raid-personalities.txt")); 541 sprintf(prompt, "Please enter the RAID level you want. %s", 542 personalities); 543 if (raidrec->raid_level == -1) { 544 strcpy(tmp, "linear"); 545 } else { 546 sprintf(tmp, "%d", raidrec->raid_level); 547 } 548 for (out = 999; 549 out != -1 && out != 0 && out != 1 && out != 4 && out != 5 550 && out != 10;) { 551 res = popup_and_get_string("Specify RAID level", prompt, tmp, 10); 552 if (!res) { 553 return; 554 } 555 mr_strip_spaces(tmp); 556 if (tmp[0] == '[' && tmp[strlen(tmp) - 1] == ']') { 557 strcpy(sz, tmp); 558 strncpy(tmp, sz + 1, strlen(sz) - 2); 559 tmp[strlen(sz) - 2] = '\0'; 560 } 561 if (!strcmp(tmp, "linear")) { 562 out = -1; 563 } else if (!strncmp(tmp, "raid", 4)) { 564 out = atoi(tmp + 4); 565 } else { 566 out = atoi(tmp); 567 } 568 log_it(tmp); 569 if (is_this_raid_personality_registered(out)) { 570 log_it 571 ("Groovy. You've picked a RAID personality which is registered."); 572 } else { 573 if (ask_me_yes_or_no 574 ("You have chosen a RAID personality which is not registered with the kernel. Make another selection?")) 575 { 576 out = 999; 577 } 578 } 579 } 599 mr_free(tmp); 600 mr_free(prompt); 580 601 raidrec->raid_level = out; 581 602 #endif 582 603 } 583 584 604 585 605 … … 602 622 int pos = 0; 603 623 604 /** buffers ***********************************************************/605 char tmp[MAX_STR_LEN];606 607 624 assert(mountlist != NULL); 608 625 assert(raidlist != NULL); … … 615 632 pos++); 616 633 if (pos < mountlist->entries) { 617 sprintf(tmp, 618 "Deleting partition %s cos it was part of a now-defunct RAID", 619 mountlist->el[pos].device); 620 log_it(tmp); 634 log_it("Deleting partition %s cos it was part of a now-defunct RAID", 635 mountlist->el[pos].device); 621 636 memcpy((void *) &mountlist->el[pos], 622 637 (void *) &mountlist->el[mountlist->entries - 1], … … 626 641 } 627 642 } 628 629 643 630 644 … … 646 660 647 661 /** buffers ***********************************************************/ 648 char tmp[MAX_STR_LEN];662 char *tmp = NULL; 649 663 650 664 assert(disklist != NULL); 651 665 assert_string_is_neither_NULL_nor_zerolength(raid_device); 652 666 653 sprintf(tmp, "Delete %s from RAID device %s - are you sure?",654 disklist->el[currline].device, raid_device);667 mr_asprintf(&tmp, _("Delete %s from RAID device %s - are you sure?"), 668 disklist->el[currline].device, raid_device); 655 669 if (!ask_me_yes_or_no(tmp)) { 670 mr_free(tmp); 656 671 return; 657 672 } 673 mr_free(tmp); 658 674 for (pos = currline; pos < disklist->entries - 1; pos++) { 659 675 /* memcpy((void*)&disklist->el[pos], (void*)&disklist->el[pos+1], sizeof(struct s_disk)); */ … … 662 678 disklist->entries--; 663 679 } 664 665 680 666 681 … … 685 700 686 701 /** buffers ***********************************************************/ 687 char tmp[MAX_STR_LEN]; 688 char device[MAX_STR_LEN]; 689 702 char *tmp = NULL; 703 char *device = NULL; 690 704 691 705 assert(mountlist != NULL); … … 699 713 device); 700 714 if (pos >= 0) { 701 sprintf(tmp, "Cannot delete %s: it is in use by RAID device %s", 702 mountlist->el[currline].device, 703 raidlist->el[pos].OSSWAP(raid_device, volname)); 715 mr_asprintf(&tmp, 716 _("Cannot delete %s: it is in use by RAID device %s"), 717 mountlist->el[currline].device, 718 raidlist->el[pos].OSSWAP(raid_device, volname)); 704 719 popup_and_OK(tmp); 720 mr_free(tmp); 705 721 return; 706 722 } 707 sprintf(tmp, "Delete %s - are you sure?",708 mountlist->el[currline].device);723 mr_asprintf(&tmp, _("Delete %s - are you sure?"), 724 mountlist->el[currline].device); 709 725 if (!ask_me_yes_or_no(tmp)) { 726 mr_free(tmp); 710 727 return; 711 728 } 729 mr_free(tmp); 730 712 731 if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)) { 713 strcpy(device, mountlist->el[currline].device);732 mr_asprintf(&device, mountlist->el[currline].device); 714 733 delete_raidlist_entry(mountlist, raidlist, device); 715 734 for (currline = 0; … … 717 736 && strcmp(mountlist->el[currline].device, device); 718 737 currline++); 719 if (currline == mountlist->entries) { 720 log_it("Dev is gone. I can't delete it. Ho-hum"); 721 return; 722 } 738 if (currline == mountlist->entries) { 739 log_it("Dev is gone. I can't delete it. Ho-hum"); 740 mr_free(device); 741 return; 742 } 743 mr_free(device); 723 744 } 724 745 memcpy((void *) &mountlist->el[currline], … … 750 771 751 772 /** buffers ***********************************************************/ 752 char tmp[MAX_STR_LEN];773 char *tmp = NULL; 753 774 754 775 assert(mountlist != NULL); … … 760 781 return; 761 782 } 762 sprintf(tmp, "Do you want me to delete %s's partitions, too?", device); 783 mr_asprintf(&tmp, 784 _("Do you want me to delete %s's partitions, too?"), device); 763 785 delete_partitions_too = ask_me_yes_or_no(tmp); 764 786 if (delete_partitions_too) { … … 804 826 items--; 805 827 } 828 mr_free(tmp); 829 806 830 raidlist->entries = items; 807 831 } … … 819 843 820 844 /** buffers ************************************************************/ 821 char tmp[MAX_STR_LEN];845 char *tmp = NULL; 822 846 823 847 /** structures *********************************************************/ 824 struct additional_raid_variables *av ;848 struct additional_raid_variables *av = NULL; 825 849 826 850 assert(raidrec != NULL); 827 851 828 852 av = &raidrec->additional_vars; 829 sprintf(tmp, "Delete %s - are you sure?", av->el[lino].label);853 mr_asprintf(&tmp, _("Delete %s - are you sure?"), av->el[lino].label); 830 854 if (ask_me_yes_or_no(tmp)) { 831 855 if (!strcmp(av->el[lino].label, "persistent-superblock") 832 856 || !strcmp(av->el[lino].label, "chunk-size")) { 833 sprintf(tmp, "%s must not be deleted. It would be bad.", 834 av->el[lino].label); 857 mr_free(tmp); 858 mr_asprintf(&tmp, _("%s must not be deleted. It would be bad."), 859 av->el[lino].label); 835 860 popup_and_OK(tmp); 836 861 } else { … … 839 864 } 840 865 } 866 mr_free(tmp); 841 867 } 842 868 #endif … … 861 887 862 888 /** long **************************************************************/ 863 long i = 0 ;889 long i = 0L; 864 890 865 891 /** structures *******************************************************/ 866 struct s_node *node ;892 struct s_node *node = NULL; 867 893 868 894 /** buffers **********************************************************/ 869 895 static char current_filename[MAX_STR_LEN]; 870 char tmp[MAX_STR_LEN + 2];896 char *tmp = NULL; 871 897 872 898 /** bool *************************************************************/ 873 /* void*dummyptr; */ 874 bool dummybool; 875 static bool warned_already; 899 bool dummybool = FALSE; 900 static bool warned_already = FALSE; 876 901 877 902 assert(filelist != NULL); 878 903 assert(keylist != NULL); 879 904 assert(listbox != NULL); 880 881 905 882 906 if (depth == 0) { … … 899 923 if (!warned_already) { 900 924 warned_already = TRUE; 901 sprintf(tmp, 902 "Too many lines. Displaying first %d entries only. Close a directory to see more.", 903 ARBITRARY_MAXIMUM); 925 mr_asprintf(&tmp, 926 _ 927 ("Too many lines. Displaying first %d entries only. Close a directory to see more."), 928 ARBITRARY_MAXIMUM); 904 929 popup_and_OK(tmp); 930 mr_free(tmp); 905 931 } 906 932 } else { … … 916 942 lines_in_flist_window = ARBITRARY_MAXIMUM; 917 943 } 918 /* do an elementary sort */944 /* do an elementary sort */ 919 945 for (i = 1; i < lines_in_flist_window; i++) { 920 946 if (strcmp 921 947 (g_strings_of_flist_window[i], 922 948 g_strings_of_flist_window[i - 1]) < 0) { 923 strcpy(tmp, g_strings_of_flist_window[i]);949 mr_asprintf(&tmp, g_strings_of_flist_window[i]); 924 950 strcpy(g_strings_of_flist_window[i], 925 951 g_strings_of_flist_window[i - 1]); 926 952 strcpy(g_strings_of_flist_window[i - 1], tmp); 953 mr_free(tmp); 954 927 955 dummybool = g_is_path_selected[i]; 928 956 g_is_path_selected[i] = g_is_path_selected[i - 1]; … … 931 959 } 932 960 } 933 /* write list to screen */961 /* write list to screen */ 934 962 newtListboxClear(listbox); 935 963 for (i = 0; i < lines_in_flist_window; i++) { 936 sprintf(tmp, "%c%c %-80s", (g_is_path_selected[i] ? '*' : ' '), 937 (g_is_path_expanded[i] ? '+' : '-'), 938 strip_path(g_strings_of_flist_window[i])); 939 tmp[70] = '\0'; 964 mr_asprintf(&tmp, "%c%c %-80s", 965 (g_is_path_selected[i] ? '*' : ' '), 966 (g_is_path_expanded[i] ? '+' : '-'), 967 strip_path(g_strings_of_flist_window[i])); 968 if (strlen(tmp) > 71) { 969 tmp[70] = '\0'; 970 } 940 971 keylist[i] = (void *) i; 941 972 newtListboxAppendEntry(listbox, tmp, keylist[i]); 973 mr_free(tmp); 942 974 } 943 975 return (lines_in_flist_window); … … 977 1009 slashcount--; /* Keep one slash 'cos Hugh does... */ 978 1010 1011 /* BERLIOS: tmpnopath and prev not defined !! How can this compile ?? */ 979 1012 for (i = 0; i < slashcount; i++) { /* Replace each dir with a space char */ 980 1013 tmpnopath[i] = ' '; … … 1025 1058 1026 1059 /** ???? **************************************************************/ 1027 void *curr_choice ;1060 void *curr_choice = NULL; 1028 1061 void *keylist[ARBITRARY_MAXIMUM]; 1029 1062 1030 /** buffers ***********************************************************/1031 char tmp[MAX_STR_LEN];1032 1033 1063 /** bool **************************************************************/ 1034 bool dummybool; 1035 1036 /* struct s_node *node; */ 1064 bool dummybool = FALSE; 1065 1037 1066 1038 1067 assert(filelist != NULL); 1039 1068 1040 log_to_screen( "Editing filelist");1069 log_to_screen(_("Editing filelist")); 1041 1070 newtPushHelpLine 1042 (" Please edit the filelist to your satisfaction, then click OK or Cancel."); 1071 (_ 1072 (" Please edit the filelist to your satisfaction, then click OK or Cancel.")); 1043 1073 j = 4; 1044 bLess = newtCompactButton(j, 17, " Less ");1045 bMore = newtCompactButton(j += 12, 17, " More ");1046 bToggle = newtCompactButton(j += 12, 17, "Toggle");1047 bRegex = newtCompactButton(j += 12, 17, "RegEx");1048 bCancel = newtCompactButton(j += 12, 17, "Cancel");1049 bOK = newtCompactButton(j += 12, 17, " OK ");1074 bLess = newtCompactButton(j, 17, _(" Less ")); 1075 bMore = newtCompactButton(j += 12, 17, _(" More ")); 1076 bToggle = newtCompactButton(j += 12, 17, _("Toggle")); 1077 bRegex = newtCompactButton(j += 12, 17, _("RegEx")); 1078 bCancel = newtCompactButton(j += 12, 17, _("Cancel")); 1079 bOK = newtCompactButton(j += 12, 17, _(" OK ")); 1050 1080 filelistListbox = 1051 1081 newtListbox(2, 1, 15, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); … … 1053 1083 lines_in_flist_window = 1054 1084 redraw_filelist(filelist, keylist, filelistListbox); 1055 newtOpenWindow(1, 3, 77, 18, "Editing filelist");1085 newtOpenWindow(1, 3, 77, 18, _("Editing filelist")); 1056 1086 myForm = newtForm(NULL, NULL, 0); 1057 1087 newtFormAddComponents(myForm, filelistListbox, bLess, bMore, bToggle, … … 1062 1092 finished = 1063 1093 ask_me_yes_or_no 1064 ( "Are you happy with your file selection?");1094 (_("Are you happy with your file selection?")); 1065 1095 } else if (b_res == bCancel) { 1066 1096 finished = TRUE; 1067 1097 } else if (b_res == bRegex) { 1068 popup_and_OK( "I haven't implemented this yet...");1098 popup_and_OK(_("I haven't implemented this yet...")); 1069 1099 } else { 1070 1100 curr_choice = newtListboxGetCurrent(filelistListbox); … … 1077 1107 indexno = 0; 1078 1108 } 1079 sprintf(tmp,"You selected '%s'",1109 log_it("You selected '%s'", 1080 1110 g_strings_of_flist_window[indexno]); 1081 log_it(tmp);1082 1111 if (b_res == bMore) { 1083 1112 g_is_path_expanded[indexno] = TRUE; … … 1131 1160 return (0); 1132 1161 } else { 1133 /* popup_and_OK("You pushed 'cancel'. I shall now abort."); */1134 1162 return (1); 1135 1163 } … … 1170 1198 newtComponent b_raid = NULL; 1171 1199 1172 /** buffers ***********************************************************/ 1173 char device_str[MAX_STR_LEN]; 1174 char mountpoint_str[MAX_STR_LEN]; 1175 char size_str[MAX_STR_LEN]; 1176 char format_str[MAX_STR_LEN]; 1177 char tmp[MAX_STR_LEN]; 1178 char device_used_to_be[MAX_STR_LEN]; 1179 char mountpt_used_to_be[MAX_STR_LEN]; 1180 1181 /** pointers **********************************************************/ 1182 char *device_here; 1183 char *mountpoint_here; 1184 char *size_here; 1185 char *format_here; 1186 1187 /** int ***************************************************************/ 1200 char *device_str = NULL; 1201 char *mountpoint_str = NULL; 1202 char *size_str = NULL; 1203 char *format_str = NULL; 1204 char *tmp = NULL; 1205 char *device_used_to_be = NULL; 1206 char *mountpt_used_to_be = NULL; 1207 char *device_here = NULL; 1208 char *mountpoint_here = NULL; 1209 char *size_here = NULL; 1210 char *format_here = NULL; 1211 1188 1212 int j = 0; 1189 1213 … … 1195 1219 memcpy((void *) &bkp_raidlist, (void *) raidlist, 1196 1220 sizeof(struct raidlist_itself)); 1197 strcpy(device_str, mountlist->el[currline].device); 1198 strcpy(device_used_to_be, mountlist->el[currline].device); 1199 strcpy(mountpoint_str, mountlist->el[currline].mountpoint); 1200 strcpy(mountpt_used_to_be, mountlist->el[currline].mountpoint); 1201 strcpy(format_str, mountlist->el[currline].format); 1202 sprintf(size_str, "%lld", mountlist->el[currline].size / 1024); 1203 newtOpenWindow(20, 5, 48, 10, "Edit entry"); 1204 label0 = newtLabel(2, 1, "Device:"); 1205 label1 = newtLabel(2, 2, "Mountpoint:"); 1206 label2 = newtLabel(2, 3, "Size (MB): "); 1207 label3 = newtLabel(2, 4, "Format: "); 1221 mr_asprintf(&device_str, mountlist->el[currline].device); 1222 mr_asprintf(&device_used_to_be, mountlist->el[currline].device); 1223 mr_asprintf(&mountpoint_str, mountlist->el[currline].mountpoint); 1224 mr_asprintf(&mountpt_used_to_be, mountlist->el[currline].mountpoint); 1225 mr_asprintf(&format_str, mountlist->el[currline].format); 1226 mr_asprintf(&size_str, "%lld", mountlist->el[currline].size / 1024); 1227 1228 newtOpenWindow(20, 5, 48, 10, _("Edit entry")); 1229 label0 = newtLabel(2, 1, _("Device:")); 1230 label1 = newtLabel(2, 2, _("Mountpoint:")); 1231 label2 = newtLabel(2, 3, _("Size (MB): ")); 1232 label3 = newtLabel(2, 4, _("Format: ")); 1208 1233 deviceComp = 1209 1234 newtEntry(14, 1, device_str, 30, (void *) &device_here, 0); 1235 mr_free(device_str); 1236 1210 1237 mountpointComp = 1211 1238 newtEntry(14, 2, mountpoint_str, 30, (void *) &mountpoint_here, 0); 1239 mr_free(mountpoint_str); 1240 1212 1241 formatComp = 1213 1242 newtEntry(14, 4, format_str, 15, (void *) &format_here, 0); 1243 mr_free(format_str); 1244 1214 1245 if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB) 1215 1246 || !strcmp(mountlist->el[currline].mountpoint, "image")) { … … 1218 1249 sizeComp = newtEntry(14, 3, size_str, 10, (void *) &size_here, 0); 1219 1250 } 1220 bOK = newtButton(2, 6, " OK "); 1221 bCancel = newtButton(14, 6, "Cancel"); 1251 mr_free(size_str); 1252 1253 bOK = newtButton(2, 6, _(" OK ")); 1254 bCancel = newtButton(14, 6, _("Cancel")); 1222 1255 if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)) { 1223 1256 b_raid = newtButton(26, 6, "RAID.."); 1224 1257 } 1225 1258 newtPushHelpLine 1226 (" Edit this partition's mountpoint, size and format; then click 'OK'."); 1259 (_ 1260 (" Edit this partition's mountpoint, size and format; then click 'OK'.")); 1227 1261 myForm = newtForm(NULL, NULL, 0); 1228 1262 newtFormAddComponents(myForm, deviceComp, mountpointComp, sizeComp, … … 1231 1265 for (b_res = NULL; b_res != bOK && b_res != bCancel;) { 1232 1266 b_res = newtRunForm(myForm); 1233 strcpy(device_str, device_here); 1267 mr_free(device_str); 1268 mr_asprintf(&device_str, device_here); 1234 1269 mr_strip_spaces(device_str); 1235 strcpy(mountpoint_str, mountpoint_here); 1270 1271 mr_free(mountpoint_str); 1272 mr_asprintf(&mountpoint_str, mountpoint_here); 1236 1273 mr_strip_spaces(mountpoint_str); 1237 strcpy(format_str, format_here); 1274 1275 mr_free(format_str); 1276 mr_asprintf(&format_str, format_here); 1238 1277 mr_strip_spaces(format_str); 1278 1239 1279 if (b_res == bOK && strstr(device_str, RAID_DEVICE_STUB) 1240 1280 && strstr(device_used_to_be, RAID_DEVICE_STUB) 1241 1281 && strcmp(device_str, device_used_to_be)) { 1242 popup_and_OK( "You can't change /dev/mdX to /dev/mdY.");1282 popup_and_OK(_("You can't change /dev/mdX to /dev/mdY.")); 1243 1283 b_res = NULL; 1244 1284 continue; 1245 1285 } else if (b_res == bOK && !strcmp(mountpoint_str, "image") 1246 1286 && strcmp(mountpt_used_to_be, "image")) { 1247 popup_and_OK("You can't change a regular device to an image."); 1287 popup_and_OK(_ 1288 ("You can't change a regular device to an image.")); 1248 1289 b_res = NULL; 1249 1290 continue; 1250 1291 } 1292 mr_free(mountpt_used_to_be); 1293 1294 mr_free(size_str); 1251 1295 if (!strstr(mountlist->el[currline].device, RAID_DEVICE_STUB) 1252 1296 && strcmp(mountlist->el[currline].mountpoint, "image")) { 1253 strcpy(size_str, size_here);1297 mr_asprintf(&size_str, size_here); 1254 1298 mr_strip_spaces(size_str); 1255 1299 } else { 1256 sprintf(size_str, "%ld",1300 mr_asprintf(&size_str, "%ld", 1257 1301 calculate_raid_device_size(mountlist, raidlist, 1258 1302 mountlist->el[currline]. … … 1260 1304 newtLabelSetText(sizeComp, size_str); 1261 1305 } 1306 1262 1307 /* do not let user click RAID button if user has changed device_str */ 1263 1308 if (b_res == b_raid) { … … 1268 1313 */ 1269 1314 popup_and_OK 1270 ("You cannot edit the RAID settings until you have OK'd your change to the device node."); 1315 (_ 1316 ("You cannot edit the RAID settings until you have OK'd your change to the device node.")); 1271 1317 } else { 1272 1318 j = find_raid_device_in_raidlist(raidlist, … … 1274 1320 device); 1275 1321 if (j < 0) { 1276 sprintf(tmp, 1277 "/etc/raidtab does not have an entry for %s; please delete it and add it again", 1322 mr_asprintf(&tmp, 1323 _ 1324 ("/etc/raidtab does not have an entry for %s; please delete it and add it again"), 1278 1325 mountlist->el[currline].device); 1279 1326 popup_and_OK(tmp); 1327 mr_free(tmp); 1280 1328 } else { 1281 log_it( "edit_raidlist_entry - calling");1329 log_it(_("edit_raidlist_entry - calling")); 1282 1330 edit_raidlist_entry(mountlist, raidlist, 1283 1331 &raidlist->el[j], currline); … … 1296 1344 strcpy(mountlist->el[currline].device, device_str); 1297 1345 strcpy(mountlist->el[currline].mountpoint, mountpoint_str); 1346 mr_free(mountpoint_str); 1347 1298 1348 strcpy(mountlist->el[currline].format, format_str); 1349 mr_free(format_str); 1350 1299 1351 if (strcmp(mountlist->el[currline].mountpoint, "image")) { 1300 1352 if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)) { … … 1306 1358 } 1307 1359 } 1360 mr_free(size_str); 1361 1308 1362 newtListboxSetEntry(listbox, (long) keylist[currline], 1309 1363 mountlist_entry_to_string(mountlist, currline)); … … 1330 1384 else if (strcmp(device_used_to_be, device_str)) { 1331 1385 popup_and_OK 1332 ("You are renaming a RAID device as another RAID device. I don't like it but I'll allow it."); 1386 (_ 1387 ("You are renaming a RAID device as another RAID device. I don't like it but I'll allow it.")); 1333 1388 } 1334 1389 #endif 1335 1390 redraw_mountlist(mountlist, keylist, listbox); 1391 mr_free(device_str); 1392 mr_free(device_used_to_be); 1336 1393 } 1337 1394 … … 1350 1407 struct vinum_plex *raidrec, char *temp) 1351 1408 { 1352 int i ;1409 int i = 0; 1353 1410 bool found = FALSE; 1354 1411 … … 1392 1449 } 1393 1450 1451 1394 1452 void 1395 1453 edit_raidlist_plex(struct mountlist_itself *mountlist, … … 1422 1480 1423 1481 /** buffers ***********************************************************/ 1424 char title_of_editraidForm_window[MAX_STR_LEN];1482 char *title_of_editraidForm_window = NULL; 1425 1483 1426 1484 /** newt **************************************************************/ … … 1436 1494 1437 1495 void *keylist[10]; 1438 void *curr_choice ;1496 void *curr_choice = NULL; 1439 1497 1440 1498 int currline2 = 0; 1441 1442 log_it("Started edit_raidlist_entry"); 1499 char *pname = NULL; 1500 char *raidlevel = NULL; 1501 char *chunksize = NULL; 1502 char *entry = NULL; 1503 char *msg = NULL; 1504 int i = 0; 1505 char *headerstr = NULL; 1506 1507 log_it(_("Started edit_raidlist_entry")); 1443 1508 memcpy((void *) &bkp_raidrec, (void *) raidrec, 1444 1509 sizeof(struct vinum_volume)); 1445 sprintf(title_of_editraidForm_window, "Plexes on %s",1510 mr_asprintf(&title_of_editraidForm_window, _("Plexes on %s"), 1446 1511 raidrec->volname); 1447 newtPushHelpLine( " Please select a plex to edit");1512 newtPushHelpLine(_(" Please select a plex to edit")); 1448 1513 newtOpenWindow(13, 5, 54, 15, title_of_editraidForm_window); 1514 mr_free(title_of_editraidForm_window); 1515 1449 1516 for (;;) { 1450 int i; 1451 char headerstr[MAX_STR_LEN]; 1452 snprintf(headerstr, MAX_STR_LEN, "%-14s %-8s %11s %8s", 1453 "Plex", "Level", "Stripe Size", "Subdisks"); 1454 1455 bOK = newtCompactButton(2, 13, " OK "); 1456 bCancel = newtCompactButton(12, 13, "Cancel"); 1457 bAdd = newtCompactButton(22, 13, " Add "); 1458 bEdit = newtCompactButton(32, 13, " Edit "); 1459 bDelete = newtCompactButton(42, 13, "Delete"); 1517 mr_asprintf(&headerstr, "%-14s %-8s %11s %8s", _("Plex"), _("Level",) _("Stripe Size"), _("Subdisks")); 1518 1519 bOK = newtCompactButton(2, 13, _(" OK ")); 1520 bCancel = newtCompactButton(12, 13, _("Cancel")); 1521 bAdd = newtCompactButton(22, 13, _(" Add ")); 1522 bEdit = newtCompactButton(32, 13, _(" Edit ")); 1523 bDelete = newtCompactButton(42, 13, _("Delete")); 1460 1524 1461 1525 plexesListbox = 1462 1526 newtListbox(2, 3, 9, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); 1463 1527 plexesHeader = newtLabel(2, 2, headerstr); 1528 mr_free(headerstr); 1529 1464 1530 editraidForm = newtForm(NULL, NULL, 0); 1465 1531 … … 1468 1534 keylist[i] = (void *) i; 1469 1535 if (i < raidrec->plexes) { 1470 char pname[64], entry[MAX_STR_LEN], raidlevel[64],1471 chunksize[64];1472 1536 switch (raidrec->plex[i].raidlevel) { 1473 1537 case -1: 1474 strcpy(raidlevel, "concat");1538 mr_asprintf(&raidlevel, "concat"); 1475 1539 break; 1476 1540 case 0: 1477 strcpy(raidlevel, "striped");1541 mr_asprintf(&raidlevel, "striped"); 1478 1542 break; 1479 1543 case 5: 1480 strcpy(raidlevel, "raid5");1544 mr_asprintf(&raidlevel, "raid5"); 1481 1545 break; 1482 1546 default: 1483 sprintf(raidlevel, "raid%i",1547 mr_asprintf(&raidlevel, "raid%i", 1484 1548 raidrec->plex[i].raidlevel); 1485 1549 break; … … 1487 1551 1488 1552 if (raidrec->plex[i].raidlevel == -1) { 1489 strcpy(chunksize, "N/A");1553 mr_asprintf(&chunksize, "N/A"); 1490 1554 } else { 1491 sprintf(chunksize, "%dk", raidrec->plex[i].stripesize);1555 mr_asprintf(&chunksize, "%dk", raidrec->plex[i].stripesize); 1492 1556 } 1493 snprintf(pname, 64, "%s.p%i", raidrec->volname, i);1494 snprintf(entry, MAX_STR_LEN, "%-14s %-8s %11s %8d",1557 mr_asprintf(&pname, "%s.p%i", raidrec->volname, i); 1558 mr_asprintf(&entry, "%-14s %-8s %11s %8d", 1495 1559 pname, raidlevel, chunksize, 1496 1560 raidrec->plex[i].subdisks); 1561 mr_free(pname); 1562 mr_free(chunksize); 1563 mr_free(raidlevel); 1497 1564 newtListboxAppendEntry(plexesListbox, entry, keylist[i]); 1565 /* BERLIOS : hope it's not necessary anymore */ 1566 mr_free(entry); 1498 1567 } 1499 1568 } … … 1516 1585 1517 1586 if (b_res == bDelete) { 1518 char msg[MAX_STR_LEN]; 1519 sprintf(msg, "Are you sure you want to delete %s.p%i?", 1587 mr_asprintf(&msg, _("Are you sure you want to delete %s.p%i?"), 1520 1588 raidrec->volname, currline2); 1521 1589 if (ask_me_yes_or_no(msg)) { 1522 log_it( "Deleting RAID plex");1590 log_it(_("Deleting RAID plex")); 1523 1591 memcpy((void *) &raidrec->plex[currline2], 1524 1592 (void *) &raidrec->plex[raidrec->plexes - 1], … … 1526 1594 raidrec->plexes--; 1527 1595 } 1596 mr_free(msg); 1528 1597 continue; 1529 1598 } … … 1548 1617 #else 1549 1618 /** structures ********************************************************/ 1550 struct raid_device_record *bkp_raidrec ;1619 struct raid_device_record *bkp_raidrec = NULL; 1551 1620 1552 1621 1553 1622 /** buffers ***********************************************************/ 1554 char *title_of_editraidForm_window ;1555 char *sz_raid_level ;1556 char *sz_data_disks ;1557 char *sz_spare_disks ;1558 char *sz_parity_disks ;1559 char *sz_failed_disks ;1623 char *title_of_editraidForm_window = NULL; 1624 char *sz_raid_level = NULL; 1625 char *sz_data_disks = NULL; 1626 char *sz_spare_disks = NULL; 1627 char *sz_parity_disks = NULL; 1628 char *sz_failed_disks = NULL; 1560 1629 1561 1630 /** newt **************************************************************/ … … 1575 1644 assert(raidrec != NULL); 1576 1645 1577 malloc_string(title_of_editraidForm_window);1578 malloc_string(sz_raid_level);1579 malloc_string(sz_data_disks);1580 malloc_string(sz_spare_disks);1581 malloc_string(sz_parity_disks);1582 malloc_string(sz_failed_disks);1583 1646 bkp_raidrec = mr_malloc(sizeof(struct raid_device_record)); 1584 1647 … … 1587 1650 memcpy((void *) bkp_raidrec, (void *) raidrec, 1588 1651 sizeof(struct raid_device_record)); 1589 sprintf(title_of_editraidForm_window, "%s", raidrec->raid_device);1652 mr_asprintf(&title_of_editraidForm_window, _("Edit %s"), raidrec->raid_device); 1590 1653 mr_msg(2, "Opening newt window"); 1591 1654 newtOpenWindow(20, 5, 40, 14, title_of_editraidForm_window); 1655 mr_free(title_of_editraidForm_window); 1656 1592 1657 for (;;) { 1593 1658 mr_msg(2, "Main loop"); 1594 sprintf(title_of_editraidForm_window, "Edit %s", 1595 raidrec->raid_device); 1596 strcpy(sz_raid_level, 1659 mr_asprintf(&sz_raid_level, 1597 1660 turn_raid_level_number_to_string(raidrec->raid_level)); 1598 strcpy(sz_data_disks,1661 mr_asprintf(&sz_data_disks, 1599 1662 number_of_disks_as_string(raidrec->data_disks.entries, 1600 "data"));1601 strcpy(sz_spare_disks,1663 _("data"))); 1664 mr_asprintf(&sz_spare_disks, 1602 1665 number_of_disks_as_string(raidrec->spare_disks.entries, 1603 "spare"));1604 strcpy(sz_parity_disks,1666 _("spare"))); 1667 mr_asprintf(&sz_parity_disks, 1605 1668 number_of_disks_as_string(raidrec->parity_disks.entries, 1606 "parity"));1607 strcpy(sz_failed_disks,1669 _("parity"))); 1670 mr_asprintf(&sz_failed_disks, 1608 1671 number_of_disks_as_string(raidrec->failed_disks.entries, 1609 "failed"));1672 _("failed"))); 1610 1673 bSelectData = newtButton(1, 1, sz_data_disks); 1611 1674 bSelectSpare = newtButton(20, 1, sz_spare_disks); … … 1613 1676 bSelectFailed = newtButton(20, 5, sz_failed_disks); 1614 1677 bChangeRaid = newtButton(1, 9, sz_raid_level); 1615 bOK = newtButton(16 + (raidrec->raid_level == -1), 9, " OK "); 1616 bCancel = newtButton(28, 9, "Cancel"); 1678 mr_free(sz_raid_level); 1679 mr_free(sz_data_disks); 1680 mr_free(sz_spare_disks); 1681 mr_free(sz_parity_disks); 1682 mr_free(sz_failed_disks); 1683 1684 bOK = newtButton(16 + (raidrec->raid_level == -1), 9, _(" OK ")); 1685 bCancel = newtButton(28, 9, _("Cancel")); 1617 1686 bAdditional = 1618 1687 newtCompactButton(1, 13, 1619 "Additional settings and information");1688 _("Additional settings and information")); 1620 1689 newtPushHelpLine 1621 (" Edit the RAID device's settings to your heart's content, then hit OK/Cancel."); 1690 (_ 1691 (" Edit the RAID device's settings to your heart's content, then hit OK/Cancel.")); 1622 1692 editraidForm = newtForm(NULL, NULL, 0); 1623 1693 newtFormAddComponents(editraidForm, bSelectData, bSelectParity, … … 1628 1698 choose_raid_level(raidrec); 1629 1699 } else if (b_res == bSelectData) { 1630 select_raid_disks(mountlist, raidlist, raidrec, "data",1700 select_raid_disks(mountlist, raidlist, raidrec, _("data"), 1631 1701 &raidrec->data_disks); 1632 1702 } else if (b_res == bSelectSpare) { 1633 select_raid_disks(mountlist, raidlist, raidrec, "spare",1703 select_raid_disks(mountlist, raidlist, raidrec, _("spare"), 1634 1704 &raidrec->spare_disks); 1635 1705 } else if (b_res == bSelectParity) { 1636 select_raid_disks(mountlist, raidlist, raidrec, "parity",1706 select_raid_disks(mountlist, raidlist, raidrec, _("parity"), 1637 1707 &raidrec->parity_disks); 1638 1708 } else if (b_res == bSelectFailed) { 1639 select_raid_disks(mountlist, raidlist, raidrec, "failed",1709 select_raid_disks(mountlist, raidlist, raidrec, _("failed"), 1640 1710 &raidrec->failed_disks); 1641 1711 } else if (b_res == bAdditional) { … … 1656 1726 calculate_raid_device_size(mountlist, raidlist, 1657 1727 raidrec->raid_device); 1658 mr_free(title_of_editraidForm_window);1659 mr_free(sz_raid_level);1660 mr_free(sz_data_disks);1661 mr_free(sz_spare_disks);1662 mr_free(sz_parity_disks);1663 mr_free(sz_failed_disks);1664 1728 mr_free(bkp_raidrec); 1665 1729 #endif 1666 1730 } 1731 1667 1732 1668 1733 #ifdef __FreeBSD__ … … 1689 1754 1690 1755 /** buffers ***********************************************************/ 1691 char title_of_editraidForm_window[MAX_STR_LEN]; 1756 char *title_of_editraidForm_window = NULL; 1757 char *tmp = NULL; 1758 char *entry = NULL; 1692 1759 1693 1760 /** newt **************************************************************/ … … 1705 1772 1706 1773 void *keylist[ARBITRARY_MAXIMUM]; 1707 void *curr_choice_a, *curr_choice_u; 1708 int currline_a, currline_u; 1709 1710 struct mountlist_itself *unallocparts; 1774 void *curr_choice_a = NULL, *curr_choice_u = NULL; 1775 int currline_a = 0, currline_u = 0; 1776 int i = 0; 1777 1778 struct mountlist_itself *unallocparts = NULL; 1711 1779 1712 1780 unallocparts = mr_malloc(sizeof(struct mountlist_itself)); … … 1715 1783 memcpy((void *) &bkp_raidrec, (void *) raidrec, 1716 1784 sizeof(struct vinum_plex)); 1717 sprintf(title_of_editraidForm_window, "%s.p%i",1785 mr_asprintf(&title_of_editraidForm_window, "%s.p%i", 1718 1786 raidlist->el[currline].volname, currline2); 1719 1787 newtPushHelpLine 1720 (" Please select a subdisk to edit, or edit this plex's parameters"); 1788 (_ 1789 (" Please select a subdisk to edit, or edit this plex's parameters")); 1721 1790 newtOpenWindow(13, 3, 54, 18, title_of_editraidForm_window); 1791 mr_free(title_of_editraidForm_window); 1792 1722 1793 for (;;) { 1723 int i;1724 char headerstr[MAX_STR_LEN];1725 char tmp[64];1726 snprintf(headerstr, MAX_STR_LEN, "%-24s %s", "Subdisk", "Device");1727 1728 1729 1794 switch (raidrec->raidlevel) { 1730 1795 case -1: 1731 strcpy(tmp, "concat");1796 mr_asprintf(&tmp, _("concat")); 1732 1797 break; 1733 1798 case 0: 1734 strcpy(tmp, "striped");1799 mr_asprintf(&tmp, _("striped")); 1735 1800 break; 1736 1801 case 5: 1737 strcpy(tmp, "raid5");1802 mr_asprintf(&tmp, _("raid5")); 1738 1803 break; 1739 1804 default: 1740 sprintf(tmp, "unknown (%i)", raidrec->raidlevel);1805 mr_asprintf(&tmp, _("unknown (%i)"), raidrec->raidlevel); 1741 1806 break; 1742 1807 } 1743 bLevel = newtCompactButton(2, 2, " RAID level ");1808 bLevel = newtCompactButton(2, 2, _(" RAID level ")); 1744 1809 sLevel = newtLabel(19, 2, tmp); 1810 mr_free(tmp); 1745 1811 1746 1812 if (raidrec->raidlevel >= 0) { 1747 sprintf(tmp, "%ik", raidrec->stripesize);1748 bStripeSize = newtCompactButton(2, 4, " Stripe size ");1813 mr_asprintf(&tmp, "%ik", raidrec->stripesize); 1814 bStripeSize = newtCompactButton(2, 4, _(" Stripe size ")); 1749 1815 } else { 1750 strcpy(tmp, "N/A");1751 bStripeSize = newtLabel(2, 4, "Stripe size:");1816 mr_asprintf(&tmp, "N/A"); 1817 bStripeSize = newtLabel(2, 4, _("Stripe size:")); 1752 1818 } 1753 1819 sStripeSize = newtLabel(19, 4, tmp); 1754 1755 bOK = newtCompactButton(2, 16, " OK "); 1756 bCancel = newtCompactButton(12, 16, "Cancel"); 1757 bAdd = newtCompactButton(22, 16, " Add "); 1758 bEdit = newtCompactButton(32, 16, " Edit "); 1759 bDelete = newtCompactButton(42, 16, "Delete"); 1760 1761 1762 // plexesListbox = newtListbox (2, 7, 9, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); 1763 // plexesHeader = newtLabel (2, 6, headerstr); 1820 mr_free(tmp); 1821 1822 bOK = newtCompactButton(2, 16, _(" OK ")); 1823 bCancel = newtCompactButton(12, 16, _("Cancel")); 1824 bAdd = newtCompactButton(22, 16, _(" Add ")); 1825 bEdit = newtCompactButton(32, 16, _(" Edit ")); 1826 bDelete = newtCompactButton(42, 16, _("Delete")); 1827 1764 1828 unallocListbox = 1765 1829 newtListbox(2, 7, 7, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); … … 1777 1841 raidlist); 1778 1842 for (i = 0; i < ARBITRARY_MAXIMUM; ++i) { 1779 char entry[MAX_STR_LEN];1780 1843 keylist[i] = (void *) i; 1781 1844 if (i < raidrec->subdisks) { 1782 snprintf(entry, MAX_STR_LEN, "%-17s",1845 mr_asprintf(&entry, "%-17s", 1783 1846 find_dev_entry_for_raid_device_name(raidlist, 1784 1847 raidrec-> … … 1786 1849 which_device)); 1787 1850 newtListboxAppendEntry(allocListbox, entry, keylist[i]); 1851 mr_free(entry); 1788 1852 } 1789 1853 if (i < unallocparts->entries) { 1790 snprintf(entry, MAX_STR_LEN, "%-17s", 1791 unallocparts->el[i].device); 1854 mr_asprintf(&entry, "%-17s", unallocparts->el[i].device); 1792 1855 newtListboxAppendEntry(unallocListbox, entry, keylist[i]); 1856 mr_free(entry); 1793 1857 } 1794 1858 } … … 1840 1904 choose_raid_level(raidrec); 1841 1905 } else if (b_res == bStripeSize) { 1842 char tmp[64];1906 malloc_string(tmp); 1843 1907 sprintf(tmp, "%i", raidrec->stripesize); 1844 1908 if (popup_and_get_string 1845 ( "Stripe size",1846 "Please enter the stripe size in kilobytes.", tmp, 20)) {1909 (_("Stripe size"), 1910 _("Please enter the stripe size in kilobytes."), tmp, 20)) { 1847 1911 raidrec->stripesize = atoi(tmp); 1848 1912 } 1913 mr_free(tmp); 1849 1914 } else if ((b_res == bAlloc) || (b_res == unallocListbox)) { 1850 1915 if (currline_u <= unallocparts->entries) … … 1887 1952 1888 1953 /** buffers ***********************************************************/ 1889 char header[MAX_STR_LEN];1890 char comment[MAX_STR_LEN];1891 char sz_out[MAX_STR_LEN];1954 char *header = NULL; 1955 char *comment = NULL; 1956 char *sz_out = NULL; 1892 1957 1893 1958 assert(raidrec != 0); 1894 1959 assert(lino >= 0); 1895 1960 1961 malloc_string(sz_out); 1896 1962 strcpy(sz_out, raidrec->additional_vars.el[lino].value); 1897 sprintf(header, "Edit %s", raidrec->additional_vars.el[lino].label);1898 sprintf(comment, "Please set %s's value (currently '%s')",1963 mr_asprintf(&header, _("Edit %s"), raidrec->additional_vars.el[lino].label); 1964 mr_asprintf(&comment, _("Please set %s's value (currently '%s')"), 1899 1965 raidrec->additional_vars.el[lino].label, sz_out); 1900 1966 if (popup_and_get_string(header, comment, sz_out, MAX_STR_LEN)) { … … 1902 1968 strcpy(raidrec->additional_vars.el[lino].value, sz_out); 1903 1969 } 1904 } 1905 1906 1907 /* I'm not racist against white people. I just don't like people who think Liberia is near Spain. - Hugo, 09/01/2001 */ 1908 1970 mr_free(sz_out); 1971 mr_free(header); 1972 mr_free(comment); 1973 } 1909 1974 #endif 1975 1910 1976 1911 1977 /** … … 1937 2003 1938 2004 /** ???? *************************************************************/ 1939 void *curr_choice ;2005 void *curr_choice = NULL; 1940 2006 void *keylist[ARBITRARY_MAXIMUM]; 1941 2007 … … 1944 2010 int currline = 0; 1945 2011 int finished = FALSE; 2012 int res = 0; 1946 2013 1947 2014 /** buffers **********************************************************/ 1948 char tmp[MAX_STR_LEN];1949 char flaws_str_A[MAX_STR_LEN];1950 char flaws_str_B[MAX_STR_LEN];1951 char flaws_str_C[MAX_STR_LEN];2015 char *tmp = NULL; 2016 char *flaws_str_A = NULL; 2017 char *flaws_str_B = NULL; 2018 char *flaws_str_C = NULL; 1952 2019 1953 2020 assert(mountlist != NULL); 1954 2021 assert(raidlist != NULL); 1955 2022 1956 strcpy(flaws_str_A, "xxxxxxxxx");1957 strcpy(flaws_str_B, "xxxxxxxxx");1958 strcpy(flaws_str_C, "xxxxxxxxx");2023 mr_asprintf(&flaws_str_A, "xxxxxxxxx"); 2024 mr_asprintf(&flaws_str_B, "xxxxxxxxx"); 2025 mr_asprintf(&flaws_str_C, "xxxxxxxxx"); 1959 2026 if (mountlist->entries > ARBITRARY_MAXIMUM) { 1960 log_to_screen( "Arbitrary limits suck, man!");2027 log_to_screen(_("Arbitrary limits suck, man!")); 1961 2028 finish(1); 1962 2029 } 1963 2030 newtPushHelpLine 1964 (" Please edit the mountlist to your satisfaction, then click OK or Cancel."); 2031 (_ 2032 (" Please edit the mountlist to your satisfaction, then click OK or Cancel.")); 1965 2033 i = 4; 1966 bAdd = newtCompactButton(i, 17, " Add ");1967 bEdit = newtCompactButton(i += 11, 17, " Edit ");1968 bDelete = newtCompactButton(i += 12, 17, "Delete");1969 bReload = newtCompactButton(i += 12, 17, "Reload");1970 bCancel = newtCompactButton(i += 12, 17, "Cancel");1971 bOK = newtCompactButton(i += 12, 17, " OK ");1972 sprintf(tmp, "%-24s %-24s %-8s %s", "Device", "Mountpoint", "Format",1973 "Size (MB)");2034 bAdd = newtCompactButton(i, 17, _(" Add ")); 2035 bEdit = newtCompactButton(i += 11, 17, _(" Edit ")); 2036 bDelete = newtCompactButton(i += 12, 17, _("Delete")); 2037 bReload = newtCompactButton(i += 12, 17, _("Reload")); 2038 bCancel = newtCompactButton(i += 12, 17, _("Cancel")); 2039 bOK = newtCompactButton(i += 12, 17, _(" OK ")); 2040 mr_asprintf(&tmp, "%-24s %-24s %-8s %s", _("Device"), _("Mountpoint"), 2041 _("Format"), _("Size (MB)")); 1974 2042 headerMsg = newtLabel(2, 1, tmp); 1975 2043 flawsLabelA = newtLabel(2, 13, flaws_str_A); 1976 2044 flawsLabelB = newtLabel(2, 14, flaws_str_B); 1977 2045 flawsLabelC = newtLabel(2, 15, flaws_str_C); 2046 mr_free(flaws_str_A); 2047 mr_free(flaws_str_B); 2048 mr_free(flaws_str_C); 2049 1978 2050 partitionsListbox = 1979 2051 newtListbox(2, 2, 10, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); 1980 2052 redraw_mountlist(mountlist, keylist, partitionsListbox); 1981 newtOpenWindow(1, 3, 77, 18, "Editing mountlist");2053 newtOpenWindow(1, 3, 77, 18, _("Editing mountlist")); 1982 2054 myForm = newtForm(NULL, NULL, 0); 1983 2055 newtFormAddComponents(myForm, headerMsg, partitionsListbox, 1984 2056 flawsLabelA, flawsLabelB, flawsLabelC, bAdd, 1985 2057 bEdit, bDelete, bReload, bCancel, bOK, NULL); 2058 2059 malloc_string(flaws_str_A); 2060 malloc_string(flaws_str_B); 2061 malloc_string(flaws_str_C); 1986 2062 while (!finished) { 1987 2063 evaluate_mountlist(mountlist, flaws_str_A, flaws_str_B, … … 1990 2066 newtLabelSetText(flawsLabelB, flaws_str_B); 1991 2067 newtLabelSetText(flawsLabelC, flaws_str_C); 2068 1992 2069 b_res = newtRunForm(myForm); 1993 2070 if (b_res == bOK) { … … 1996 2073 finished = 1997 2074 ask_me_yes_or_no 1998 ( "Your mountlist might not work. Continue anyway?");2075 (_("Your mountlist might not work. Continue anyway?")); 1999 2076 } else { 2000 2077 finished = 2001 2078 ask_me_yes_or_no 2002 ("Are you sure you want to save your mountlist and continue? (No changes will be made to your partition table at this time.)"); 2079 (_ 2080 ("Are you sure you want to save your mountlist and continue? (No changes will be made to your partition table at this time.)")); 2003 2081 } 2004 2082 } else if (b_res == bCancel) { 2005 2083 finished = TRUE; 2006 2084 } else if (b_res == bReload) { 2007 if (ask_me_yes_or_no("Reload original mountlist?")) { 2008 /* 2009 This would be really dumb. RAIDTAB_FNAME is #define'd. --- Hugo, 2003/04/24 2010 if (!RAIDTAB_FNAME[0]) 2011 { 2012 strcpy(RAIDTAB_FNAME, "/etc/raidtab"); 2013 log_it("Warning - raidtab_fname is blank. Assuming %s", g_raidtab_fname); 2014 } 2015 */ 2085 if (ask_me_yes_or_no(_("Reload original mountlist?"))) { 2016 2086 load_mountlist(mountlist, mountlist_fname); 2017 2087 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); … … 2023 2093 i < mountlist->entries && keylist[i] != curr_choice; i++); 2024 2094 if (i == mountlist->entries && mountlist->entries > 0) { 2025 log_to_screen( "I don't know what that button does!");2095 log_to_screen(_("I don't know what that button does!")); 2026 2096 } else { 2027 2097 currline = i; … … 2041 2111 } else { 2042 2112 popup_and_OK 2043 ("Please add an entry. Then press ENTER to edit it."); 2113 (_ 2114 ("Please add an entry. Then press ENTER to edit it.")); 2044 2115 } 2045 2116 } … … 2051 2122 newtPopHelpLine(); 2052 2123 if (b_res == bOK) { 2053 log_it( "You pushed 'OK'. I shall now continue.");2124 log_it(_("You pushed 'OK'. I shall now continue.")); 2054 2125 return (0); 2055 2126 } else { 2056 /* popup_and_OK("You pushed 'cancel'. I shall now abort."); */2057 2127 return (1); 2058 2128 } 2059 2129 } 2060 2061 2130 2062 2131 … … 2072 2141 { 2073 2142 int res = 0; 2074 // char tmp[MAX_STR_LEN];2075 2143 2076 2144 iamhere("entering eml"); … … 2086 2154 return (res); 2087 2155 } 2088 2089 2090 2156 2091 2157 … … 2114 2180 2115 2181 /** ?? ***************************************************************/ 2116 void *keylist[ARBITRARY_MAXIMUM], *curr_choice ;2182 void *keylist[ARBITRARY_MAXIMUM], *curr_choice = NULL; 2117 2183 2118 2184 /** buffers **********************************************************/ 2119 char title_of_window[MAX_STR_LEN];2185 char *title_of_window = NULL; 2120 2186 2121 2187 /** int **************************************************************/ … … 2128 2194 memcpy((void *) &bkp_raidrec, (void *) raidrec, 2129 2195 sizeof(struct raid_device_record)); 2130 sprintf(title_of_window, "Additional variables");2196 mr_asprintf(&title_of_window, "Additional variables"); 2131 2197 newtPushHelpLine 2132 (" Edit the additional fields to your heart's content, then click OK or Cancel."); 2133 headerMsg = newtLabel(1, 1, "Label Value"); 2198 (_ 2199 (" Edit the additional fields to your heart's content, then click OK or Cancel.")); 2200 headerMsg = 2201 newtLabel(1, 1, _("Label Value")); 2134 2202 varsListbox = 2135 2203 newtListbox(1, 2, 6, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); 2136 2204 i = 1; 2137 bAdd = newtCompactButton(i, 9, " Add ");2138 bEdit = newtCompactButton(i += 8, 9, " Edit ");2139 bDelete = newtCompactButton(i += 9, 9, "Delete");2140 bOK = newtCompactButton(i += 9, 9, " OK ");2141 bCancel = newtCompactButton(i += 9, 9, "Cancel");2205 bAdd = newtCompactButton(i, 9, _(" Add ")); 2206 bEdit = newtCompactButton(i += 8, 9, _(" Edit ")); 2207 bDelete = newtCompactButton(i += 9, 9, _("Delete")); 2208 bOK = newtCompactButton(i += 9, 9, _(" OK ")); 2209 bCancel = newtCompactButton(i += 9, 9, _("Cancel")); 2142 2210 newtOpenWindow(17, 7, 46, 10, title_of_window); 2211 mr_free(title_of_window); 2212 2143 2213 myForm = newtForm(NULL, NULL, 0); 2144 2214 newtFormAddComponents(myForm, headerMsg, varsListbox, bAdd, bEdit, … … 2194 2264 2195 2265 /** bool **************************************************************/ 2196 bool done ;2266 bool done = FALSE; 2197 2267 2198 2268 assert(disklist != NULL); … … 2212 2282 2213 2283 2214 2215 2284 /** 2216 2285 * Locate @p device in @p raidlist. … … 2228 2297 int i = 0; 2229 2298 #ifdef __FreeBSD__ 2230 char vdev[64]; 2231 #else 2232 // Linux 2299 char *vdev = NULL; 2233 2300 #endif 2234 2301 … … 2238 2305 #ifdef __FreeBSD__ 2239 2306 for (i = 0; i < raidlist->entries; i++) { 2240 sprintf(vdev, "/dev/vinum/%s", raidlist->el[i].volname); 2241 if (!strcmp(device, vdev)) 2307 mr_asprintf(&vdev, "/dev/vinum/%s", raidlist->el[i].volname); 2308 if (!strcmp(device, vdev)) { 2309 mr_free(vdev); 2242 2310 break; 2311 } 2312 mr_free(vdev); 2243 2313 } 2244 2314 #else … … 2260 2330 * @param isodir_device Where to put the device (e.g. /dev/hda4) the user enters. 2261 2331 * @param isodir_format Where to put the format (e.g. ext2) the user enters. 2262 * @param isodir_path Where to put the path (e.g. / root/images/mondo) the user enters.2332 * @param isodir_path Where to put the path (e.g. /var/cache/mondo) the user enters. 2263 2333 * @param nuke_me_please Whether we're planning on nuking or not. 2264 2334 * @return TRUE if OK was pressed, FALSE otherwise. … … 2297 2367 2298 2368 if (popup_and_get_string 2299 ( "ISO Mode - device", "On what device do the ISO files live?",2369 (_("ISO Mode - device"), _("On what device do the ISO files live?"), 2300 2370 isodir_device, MAX_STR_LEN / 4)) { 2301 2371 if (popup_and_get_string 2302 ( "ISO Mode - format",2303 "What is the disk format of the device? (Hit ENTER if you don't know.)",2372 (_("ISO Mode - format"), 2373 _("What is the disk format of the device? (Hit ENTER if you don't know.)"), 2304 2374 isodir_format, 16)) { 2305 2375 if (popup_and_get_string 2306 ( "ISO Mode - path",2307 "At what path on this device can the ISO files be found?",2376 (_("ISO Mode - path"), 2377 _("At what path on this device can the ISO files be found?"), 2308 2378 isodir_path, MAX_STR_LEN / 4)) { 2309 2379 mr_strip_spaces(isodir_device); … … 2332 2402 int currline, char *device) 2333 2403 { 2334 2335 2404 /** structure *********************************************************/ 2336 2405 struct OSSWAP (raid_device_record, vinum_volume) * raidrec; … … 2385 2454 raidrec->additional_vars.entries = items; 2386 2455 } 2387 2388 2456 #endif 2457 2389 2458 2390 2459 /** … … 2403 2472 2404 2473 newtPushHelpLine 2405 ("This is where I nuke your hard drives. Mhahahahaha. No-one can stop Mojo Jojo!"); 2406 newtOpenWindow(24, 3, 32, 13, "Nuking"); 2407 b1 = newtButton(7, 1, "Slowly"); 2408 b2 = newtButton(7, 5, "Medium"); 2409 b3 = newtButton(7, 9, "Quickly"); 2474 (_ 2475 ("This is where I nuke your hard drives. Mhahahahaha. No-one can stop Mojo Jojo!")); 2476 newtOpenWindow(24, 3, 32, 13, _("Nuking")); 2477 b1 = newtButton(7, 1, _("Slowly")); 2478 b2 = newtButton(7, 5, _("Medium")); 2479 b3 = newtButton(7, 9, _("Quickly")); 2410 2480 myForm = newtForm(NULL, NULL, 0); 2411 2481 newtFormAddComponents(myForm, b1, b2, b3, NULL); … … 2417 2487 2418 2488 2419 2420 2489 /** 2421 2490 * Redraw the disklist. … … 2470 2539 2471 2540 newtListboxClear(listbox); 2472 // sort_mountlist_by_device (mountlist);2473 2541 for (i = 0; i < ARBITRARY_MAXIMUM; i++) { 2474 2542 keylist[i] = (void *) i; … … 2480 2548 } 2481 2549 } 2482 2483 2484 2550 2485 2551 … … 2501 2567 2502 2568 /** buffers **********************************************************/ 2503 char tmp[MAX_STR_LEN];2569 char *tmp = NULL; 2504 2570 2505 2571 assert(unallocated_raid_partitions != NULL); … … 2512 2578 } 2513 2579 for (i = 0; i < unallocated_raid_partitions->entries; i++) { 2514 sprintf(tmp, "%-22s %8lld",2580 mr_asprintf(&tmp, "%-22s %8lld", 2515 2581 unallocated_raid_partitions->el[i].device, 2516 2582 unallocated_raid_partitions->el[i].size / 1024); 2517 2583 newtListboxAppendEntry(listbox, tmp, keylist[i]); 2518 } 2519 } 2584 mr_free(tmp); 2585 } 2586 } 2587 2520 2588 2521 2589 #ifndef __FreeBSD__ … … 2535 2603 2536 2604 /** buffers *********************************************************/ 2537 char tmp[MAX_STR_LEN];2605 char *tmp; 2538 2606 2539 2607 assert(additional_vars != NULL); … … 2547 2615 } 2548 2616 for (i = 0; i < additional_vars->entries; i++) { 2549 sprintf(tmp, "%-32s %-8s", additional_vars->el[i].label,2617 mr_asprintf(&tmp, "%-32s %-8s", additional_vars->el[i].label, 2550 2618 additional_vars->el[i].value); 2551 2619 newtListboxAppendEntry(listbox, tmp, keylist[i]); 2620 mr_free(tmp); 2552 2621 } 2553 2622 } … … 2593 2662 #endif 2594 2663 2664 2595 2665 /** 2596 2666 * Change all RAID devices to use @p new_dev instead of @p old_dev. … … 2605 2675 char *new_dev) 2606 2676 { 2607 /** buffers ********************************************************/2608 char tmp[MAX_STR_LEN];2609 2677 2610 2678 /** int ************************************************************/ … … 2618 2686 pos = which_raid_device_is_using_this_partition(raidlist, old_dev); 2619 2687 if (pos < 0) { 2620 sprintf(tmp,"No need to rejig %s in raidlist: it's not listed.",2688 log_it("No need to rejig %s in raidlist: it's not listed.", 2621 2689 old_dev); 2622 log_it(tmp);2623 2690 } else { 2624 2691 if ((j = … … 2652 2719 #endif 2653 2720 else { 2654 sprintf(tmp, 2655 "%s is supposed to be listed in this raid dev but it's not...", 2721 log_it("%s is supposed to be listed in this raid dev but it's not...", 2656 2722 old_dev); 2657 log_it(tmp);2658 2723 } 2659 2724 } … … 2688 2753 res = read_variableINT_and_remove_from_raidvars(raidrec, "block-size"); 2689 2754 } 2755 2690 2756 2691 2757 /** … … 2705 2771 struct list_of_disks *disklist) 2706 2772 { 2707 void *curr_choice; 2708 2709 /** ??? ***************************************************************/ 2773 void *curr_choice = NULL; 2710 2774 2711 2775 /** structures ********************************************************/ 2712 struct raidlist_itself *bkp_raidlist ;2713 struct raid_device_record *bkp_raidrec ;2714 struct list_of_disks *bkp_disklist ;2715 struct mountlist_itself *unallocated_raid_partitions ;2776 struct raidlist_itself *bkp_raidlist = NULL; 2777 struct raid_device_record *bkp_raidrec = NULL; 2778 struct list_of_disks *bkp_disklist = NULL; 2779 struct mountlist_itself *unallocated_raid_partitions = NULL; 2716 2780 2717 2781 /** newt **************************************************************/ … … 2727 2791 /** buffers **********************************************************/ 2728 2792 void *keylist[ARBITRARY_MAXIMUM]; 2729 char *tmp ;2730 char *help_text ;2731 char *title_of_window ;2732 char *sz_res ;2733 char *header_text ;2793 char *tmp = NULL; 2794 char *help_text = NULL; 2795 char *title_of_window = NULL; 2796 char *sz_res = NULL; 2797 char *header_text = NULL; 2734 2798 2735 2799 /** int **************************************************************/ … … 2744 2808 2745 2809 iamhere("malloc'ing"); 2746 malloc_string(tmp);2747 malloc_string(help_text);2748 malloc_string(title_of_window);2749 malloc_string(sz_res);2750 malloc_string(header_text);2751 2810 bkp_raidrec = mr_malloc(sizeof(struct raid_device_record)); 2752 2811 bkp_disklist = mr_malloc(sizeof(struct list_of_disks)); … … 2762 2821 2763 2822 iamhere("Post-malloc"); 2764 strcpy(help_text, 2765 " Edit this RAID device's list of partitions. Choose OK or Cancel when done."); 2766 sprintf(header_text, "%-24s %s", "Device", "Index"); 2767 sprintf(title_of_window, "%s contains...", raidrec->raid_device); 2823 mr_asprintf(&help_text, 2824 _ 2825 (" Edit this RAID device's list of partitions. Choose OK or Cancel when done.")); 2826 mr_asprintf(&header_text, "%-24s %s", _("Device"), _("Index")); 2827 mr_asprintf(&title_of_window, _("%s contains..."), raidrec->raid_device); 2768 2828 newtPushHelpLine(help_text); 2829 mr_free(help_text); 2830 2769 2831 for (b_res = (newtComponent) 12345; b_res != bOK && b_res != bCancel;) { 2770 2832 headerMsg = newtLabel(1, 1, header_text); … … 2773 2835 redraw_disklist(disklist, keylist, partitionsListbox); 2774 2836 i = 1; 2775 bAdd = newtCompactButton(i, 9, " Add ");2776 bDelete = newtCompactButton(i += 8, 9, "Delete");2777 bOK = newtCompactButton(i += 9, 9, " OK ");2778 bCancel = newtCompactButton(i += 9, 9, "Cancel");2837 bAdd = newtCompactButton(i, 9, _(" Add ")); 2838 bDelete = newtCompactButton(i += 8, 9, _("Delete")); 2839 bOK = newtCompactButton(i += 9, 9, _(" OK ")); 2840 bCancel = newtCompactButton(i += 9, 9, _("Cancel")); 2779 2841 newtOpenWindow(21, 7, 38, 10, title_of_window); 2780 2842 myForm = newtForm(NULL, NULL, 0); … … 2788 2850 b_res = newtRunForm(myForm); 2789 2851 if (b_res == bOK || b_res == bCancel) { /* do nothing */ 2790 // That's OK. At the end of this subroutine (after this do/while loop),2791 // we'll throw away the changes if Cancel was pushed.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. 2792 2854 } else { 2793 2855 curr_choice = newtListboxGetCurrent(partitionsListbox); … … 2795 2857 i++); 2796 2858 if (i == disklist->entries && disklist->entries > 0) { 2797 log_to_screen( "I don't know what that button does!");2859 log_to_screen(_("I don't know what that button does!")); 2798 2860 } else { 2799 2861 currline = i; 2800 2862 if (b_res == bAdd) { 2801 log_it( "Making list of unallocated RAID slices");2863 log_it(_("Making list of unallocated RAID slices")); 2802 2864 make_list_of_unallocated_raid_partitions 2803 2865 (unallocated_raid_partitions, mountlist_dontedit, … … 2805 2867 if (unallocated_raid_partitions->entries <= 0) { 2806 2868 popup_and_OK 2807 ("There are no unallocated partitions marked for RAID."); 2869 (_ 2870 ("There are no unallocated partitions marked for RAID.")); 2808 2871 } else { 2809 2872 log_it 2810 ("Done. The user may add one or more of the above to RAID device"); 2873 (_ 2874 ("Done. The user may add one or more of the above to RAID device")); 2811 2875 add_disklist_entry(disklist, raidrec->raid_device, 2812 2876 unallocated_raid_partitions); 2813 log_it("I have finished adding a disklist entry."); 2877 log_it(_ 2878 ("I have finished adding a disklist entry.")); 2814 2879 redraw_disklist(disklist, keylist, 2815 2880 partitionsListbox); … … 2820 2885 redraw_disklist(disklist, keylist, partitionsListbox); 2821 2886 } else { 2822 sprintf(tmp, "%s's index is %d. What should it be?",2887 mr_asprintf(&tmp, _("%s's index is %d. What should it be?"), 2823 2888 raidrec->raid_device, 2824 2889 disklist->el[currline].index); 2890 malloc_string(sz_res); 2825 2891 sprintf(sz_res, "%d", disklist->el[currline].index); 2826 if (popup_and_get_string("Set index", tmp, sz_res, 10)) { 2892 if (popup_and_get_string 2893 (_("Set index"), tmp, sz_res, 10)) { 2827 2894 disklist->el[currline].index = atoi(sz_res); 2828 2895 } 2896 mr_free(tmp); 2897 mr_free(sz_res); 2898 2829 2899 redraw_disklist(disklist, keylist, partitionsListbox); 2830 2900 } … … 2834 2904 newtPopWindow(); 2835 2905 } 2906 mr_free(title_of_window); 2907 mr_free(header_text); 2908 2836 2909 newtPopHelpLine(); 2837 2910 if (b_res == bCancel) { … … 2843 2916 sizeof(struct list_of_disks)); 2844 2917 } 2845 mr_free(tmp);2846 mr_free(help_text);2847 mr_free(title_of_window);2848 mr_free(sz_res);2849 mr_free(header_text);2850 2918 mr_free(bkp_raidrec); 2851 2919 mr_free(bkp_disklist); … … 2856 2924 2857 2925 2858 2859 2926 /** 2860 2927 * Ask the user which restore mode (nuke, interactive, or compare) we should use. … … 2867 2934 /** char *************************************************************/ 2868 2935 char output = '\0'; 2869 char tmp[MAX_STR_LEN]; 2936 char *tmp = NULL; 2937 size_t n = 0; 2870 2938 2871 2939 /** newt *************************************************************/ … … 2881 2949 for (output = 'z'; !strchr("AICE", output); output = tmp[0]) { 2882 2950 printf 2883 ("Which mode - (A)utomatic, (I)nteractive, \n(C)ompare only, or (E)xit to shell?\n--> "); 2884 fgets(tmp, MAX_STR_LEN - 1, stdin); 2885 } 2951 (_ 2952 ("Which mode - (A)utomatic, (I)nteractive, \n(C)ompare only, or (E)xit to shell?\n--> ")); 2953 mr_getline(&tmp, &n, stdin); 2954 } 2955 mr_free(tmp); 2886 2956 return (output); 2887 2957 } 2888 2958 2889 2959 newtPushHelpLine 2890 (" Do you want to 'nuke' your system, restore interactively, or just compare?"); 2891 newtOpenWindow(24, 3, 32, 17, "How should I restore?"); 2892 b1 = newtButton(7, 1, "Automatically"); 2893 b2 = newtButton(7, 5, "Interactively"); 2894 b3 = newtButton(7, 9, "Compare only!"); 2895 b4 = newtButton(7, 13, "Exit to shell"); 2960 (_ 2961 (" Do you want to 'nuke' your system, restore interactively, or just compare?")); 2962 newtOpenWindow(24, 3, 32, 17, _("How should I restore?")); 2963 b1 = newtButton(7, 1, _("Automatically")); 2964 b2 = newtButton(7, 5, _("Interactively")); 2965 b3 = newtButton(7, 9, _("Compare only!")); 2966 b4 = newtButton(7, 13, _("Exit to shell")); 2896 2967 myForm = newtForm(NULL, NULL, 0); 2897 2968 newtFormAddComponents(myForm, b1, b2, b3, b4, NULL);
Note:
See TracChangeset
for help on using the changeset viewer.