Changeset 3611 in MondoRescue
- Timestamp:
- Nov 10, 2016, 9:09:54 PM (8 years ago)
- Location:
- branches/3.2/mondo/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mondo/src/common/libmondo-files.c
r3610 r3611 1116 1116 /*@ buffers *************** */ 1117 1117 char *tmp = NULL; 1118 char *tmp1 = NULL; 1118 1119 char *mds = NULL; 1119 1120 … … 1142 1143 scratchLL++; 1143 1144 } 1145 tmp1 = number_to_text((int) (scratchLL + 1)); 1144 1146 if (scratchLL <= 1) { 1145 1147 mds = media_descriptor_string(bkpinfo->backup_media_type); 1146 1148 mr_asprintf(tmp, "Your backup will probably occupy a single %s. Maybe two.", mds); 1147 1149 mr_free(mds); 1148 } else if (scratchLL > 4) {1149 mr_asprintf(tmp, "Your backup will occupy one meeeeellion media! (maybe %s)", number_to_text((int) (scratchLL + 1)));1150 } else if (scratchLL > 5) { 1151 mr_asprintf(tmp, "Your backup will occupy one meeeeellion media! (maybe %s)", tmp1); 1150 1152 } else { 1151 mr_asprintf(tmp, "Your backup will occupy approximately %s media.", number_to_text((int) (scratchLL + 1)));1153 mr_asprintf(tmp, "Your backup will occupy approximately %s media.", tmp1); 1152 1154 } 1153 1155 if (scratchLL < 50) { 1154 1156 log_to_screen(tmp); 1155 1157 } 1158 mr_free(tmp1); 1156 1159 mr_free(tmp); 1157 1160 } -
branches/3.2/mondo/src/common/libmondo-stream.c
r3610 r3611 1177 1177 /*@ buffers ***************************************************** */ 1178 1178 char *tempblock; 1179 char *tmp = NULL; 1179 1180 1180 1181 /*@ int ********************************************************* */ … … 1208 1209 } 1209 1210 tempblock[i] = '\0'; 1210 log_msg(6, "%s (fname=%s, size=%ld K)",1211 marker_to_string(*pcontrol_char), tempblock + 1000,1212 (long) (*plen) >> 10);1211 tmp = marker_to_string(*pcontrol_char); 1212 log_msg(6, "%s (fname=%s, size=%ld K)", tmp, tempblock + 1000, (long) (*plen) >> 10); 1213 mr_free(tmp); 1213 1214 paranoid_free(tempblock); 1214 1215 return (retval); … … 1751 1752 char tempblock[TAPE_BLOCK_SIZE]; 1752 1753 char *p; 1754 char *tmp = NULL; 1753 1755 1754 1756 /*@ int ******************************************************** */ … … 1782 1784 strcpy(tempblock + 1000, filename); 1783 1785 g_tape_posK += fwrite(tempblock, 1, (size_t) TAPE_BLOCK_SIZE, g_tape_stream) / 1024; 1784 log_msg(6, "%s (fname=%s, size=%ld K)", marker_to_string(control_char), p, (long) length_of_incoming_file >> 10); 1786 tmp = marker_to_string(control_char); 1787 log_msg(6, "%s (fname=%s, size=%ld K)", tmp, p, (long) length_of_incoming_file >> 10); 1788 mr_free(tmp); 1785 1789 return (0); 1786 1790 } … … 1802 1806 void wrong_marker(int should_be, int it_is) 1803 1807 { 1804 log_to_screen("Wrong marker! (Should be %s, is actually %s)", marker_to_string(should_be), marker_to_string(it_is)); 1808 char *tmp1 = NULL; 1809 char *tmp2 = NULL; 1810 tmp1 = marker_to_string(should_be); 1811 tmp2 = marker_to_string(it_is); 1812 log_to_screen("Wrong marker! (Should be %s, is actually %s)", tmp1, tmp2); 1813 mr_free(tmp1); 1814 mr_free(tmp2); 1805 1815 } 1806 1816 -
branches/3.2/mondo/src/common/libmondo-string.c
r3413 r3611 147 147 148 148 /** 149 * Add commas every third place in @p input.150 * @param input The string to commarize.151 * @return The string with commas.152 * @note The returned string points to static storage that will be overwritten with each call.153 */154 char *commarize(char *input)155 {156 char pos_w_commas[MAX_STR_LEN];157 static char output[MAX_STR_LEN];158 char tmp[MAX_STR_LEN];159 int j;160 161 assert(input != NULL);162 163 strcpy(tmp, input);164 if (strlen(tmp) > 6) {165 strcpy(pos_w_commas, tmp);166 j = (int) strlen(pos_w_commas);167 tmp[j - 6] = ',';168 strcpy(tmp + j - 5, pos_w_commas + j - 6);169 strcpy(pos_w_commas, tmp);170 }171 if (strlen(tmp) > 3) {172 j = (int) strlen(tmp);173 strcpy(pos_w_commas, tmp);174 pos_w_commas[j - 3] = ',';175 strcpy(pos_w_commas + j - 2, tmp + j - 3);176 } else {177 strcpy(pos_w_commas, tmp);178 }179 strcpy(output, pos_w_commas);180 return (output);181 }182 183 184 /**185 149 * Turn an entry from the RAID editor's disklist into a GUI-friendly string. 186 150 * The format is: the device left-aligned and padded to 24 places, followed by a space and the … … 190 154 * @param lino The line number from @p disklist to convert to a string. 191 155 * @return The string form of the disklist entry. 192 * @note The returned string points to static storage and will be overwritten with each call. 156 * @note The returned string points to storage that needs to be freed by 157 * caller 193 158 */ 194 159 char *disklist_entry_to_string(struct list_of_disks *disklist, int lino) … … 196 161 197 162 /*@ buffers ********************************************************** */ 198 static char output[MAX_STR_LEN];163 char *output = NULL; 199 164 200 165 assert(disklist != NULL); 201 166 202 sprintf(output, "%-24s %8d", disklist->el[lino].device, 203 disklist->el[lino].index); 204 return (output); 167 mr_asprintf(output, "%-24s %8d", disklist->el[lino].device, disklist->el[lino].index); 168 return(output); 205 169 } 206 170 … … 301 265 * @param marker The marker byte to stringify. 302 266 * @return @p marker as a string. 303 * @note The returned string points to static storage that will be overwritten with each call. 267 * @note The returned string points to storage that needs to be freed by 268 * caller 304 269 */ 305 270 char *marker_to_string(int marker) 306 271 { 307 272 /*@ buffer ****************************************************** */ 308 static char outstr[MAX_STR_LEN];273 char *outstr = NULL; 309 274 310 275 … … 313 278 switch (marker) { 314 279 case BLK_START_OF_BACKUP: 315 strcpy(outstr, "BLK_START_OF_BACKUP");280 mr_asprintf(outstr, "BLK_START_OF_BACKUP"); 316 281 break; 317 282 case BLK_START_OF_TAPE: 318 strcpy(outstr, "BLK_START_OF_TAPE");283 mr_asprintf(outstr, "BLK_START_OF_TAPE"); 319 284 break; 320 285 case BLK_START_AN_AFIO_OR_SLICE: 321 strcpy(outstr, "BLK_START_AN_AFIO_OR_SLICE");286 mr_asprintf(outstr, "BLK_START_AN_AFIO_OR_SLICE"); 322 287 break; 323 288 case BLK_STOP_AN_AFIO_OR_SLICE: 324 strcpy(outstr, "BLK_STOP_AN_AFIO_OR_SLICE");289 mr_asprintf(outstr, "BLK_STOP_AN_AFIO_OR_SLICE"); 325 290 break; 326 291 case BLK_START_AFIOBALLS: 327 strcpy(outstr, "BLK_START_AFIOBALLS");292 mr_asprintf(outstr, "BLK_START_AFIOBALLS"); 328 293 break; 329 294 case BLK_STOP_AFIOBALLS: 330 strcpy(outstr, "BLK_STOP_AFIOBALLS");295 mr_asprintf(outstr, "BLK_STOP_AFIOBALLS"); 331 296 break; 332 297 case BLK_STOP_BIGGIEFILES: 333 strcpy(outstr, "BLK_STOP_BIGGIEFILES");298 mr_asprintf(outstr, "BLK_STOP_BIGGIEFILES"); 334 299 break; 335 300 case BLK_START_A_NORMBIGGIE: 336 strcpy(outstr, "BLK_START_A_NORMBIGGIE");301 mr_asprintf(outstr, "BLK_START_A_NORMBIGGIE"); 337 302 break; 338 303 case BLK_START_A_PIHBIGGIE: 339 strcpy(outstr, "BLK_START_A_PIHBIGGIE");304 mr_asprintf(outstr, "BLK_START_A_PIHBIGGIE"); 340 305 break; 341 306 case BLK_START_EXTENDED_ATTRIBUTES: 342 strcpy(outstr, "BLK_START_EXTENDED_ATTRIBUTES");307 mr_asprintf(outstr, "BLK_START_EXTENDED_ATTRIBUTES"); 343 308 break; 344 309 case BLK_STOP_EXTENDED_ATTRIBUTES: 345 strcpy(outstr, "BLK_STOP_EXTENDED_ATTRIBUTES");310 mr_asprintf(outstr, "BLK_STOP_EXTENDED_ATTRIBUTES"); 346 311 break; 347 312 case BLK_START_EXAT_FILE: 348 strcpy(outstr, "BLK_START_EXAT_FILE");313 mr_asprintf(outstr, "BLK_START_EXAT_FILE"); 349 314 break; 350 315 case BLK_STOP_EXAT_FILE: 351 strcpy(outstr, "BLK_STOP_EXAT_FILE");316 mr_asprintf(outstr, "BLK_STOP_EXAT_FILE"); 352 317 break; 353 318 case BLK_START_BIGGIEFILES: 354 strcpy(outstr, "BLK_START_BIGGIEFILES");319 mr_asprintf(outstr, "BLK_START_BIGGIEFILES"); 355 320 break; 356 321 case BLK_STOP_A_BIGGIE: 357 strcpy(outstr, "BLK_STOP_A_BIGGIE");322 mr_asprintf(outstr, "BLK_STOP_A_BIGGIE"); 358 323 break; 359 324 case BLK_END_OF_TAPE: 360 strcpy(outstr, "BLK_END_OF_TAPE");325 mr_asprintf(outstr, "BLK_END_OF_TAPE"); 361 326 break; 362 327 case BLK_END_OF_BACKUP: 363 strcpy(outstr, "BLK_END_OF_BACKUP");328 mr_asprintf(outstr, "BLK_END_OF_BACKUP"); 364 329 break; 365 330 case BLK_ABORTED_BACKUP: 366 strcpy(outstr, "BLK_ABORTED_BACKUP");331 mr_asprintf(outstr, "BLK_ABORTED_BACKUP"); 367 332 break; 368 333 case BLK_START_FILE: 369 strcpy(outstr, "BLK_START_FILE");334 mr_asprintf(outstr, "BLK_START_FILE"); 370 335 break; 371 336 case BLK_STOP_FILE: 372 strcpy(outstr, "BLK_STOP_FILE");337 mr_asprintf(outstr, "BLK_STOP_FILE"); 373 338 break; 374 339 default: 375 sprintf(outstr, "BLK_UNKNOWN (%d)", marker);340 mr_asprintf(outstr, "BLK_UNKNOWN (%d)", marker); 376 341 break; 377 342 } 378 343 return (outstr); 379 344 } 380 381 382 345 383 346 … … 391 354 * @param lino The line number in @p mountlist to stringify. 392 355 * @return The string form of <tt>mountlist</tt>-\>el[<tt>lino</tt>]. 393 * @note The returned string points to static storage and will be overwritten with each call. 394 */ 395 char *mountlist_entry_to_string(struct mountlist_itself *mountlist, 396 int lino) 397 { 356 * @note The returned string points to storage that needs to be freed by 357 * caller 358 */ 359 char *mountlist_entry_to_string(struct mountlist_itself *mountlist, int lino) { 398 360 399 361 /*@ buffer *********************************************************** */ 400 static char output[MAX_STR_LEN];362 char *output = NULL; 401 363 402 364 assert(mountlist != NULL); 403 365 404 sprintf(output, "%-24s %-24s %-10s %8lld", mountlist->el[lino].device, 405 mountlist->el[lino].mountpoint, mountlist->el[lino].format, 406 mountlist->el[lino].size / 1024L); 407 return (output); 366 mr_asprintf(output, "%-24s %-24s %-10s %8lld", mountlist->el[lino].device, mountlist->el[lino].mountpoint, mountlist->el[lino].format, mountlist->el[lino].size / 1024L); 367 return(output); 408 368 } 409 369 … … 453 413 * @param i The number to stringify. 454 414 * @return The string form of @p i. 455 * @note The returned value points to static strorage that will be overwritten with each call. 415 * @note The returned value points to strorage that needs to be freed by 416 * caller 456 417 */ 457 418 char *number_to_text(int i) … … 459 420 460 421 /*@ buffers ***************************************************** */ 461 static char output[MAX_STR_LEN];422 char *output = NULL; 462 423 463 424 … … 466 427 switch (i) { 467 428 case 0: 468 strcpy(output, "zero");429 mr_asprintf(output, "zero"); 469 430 break; 470 431 case 1: 471 strcpy(output, "one");432 mr_asprintf(output, "one"); 472 433 break; 473 434 case 2: 474 strcpy(output, "two");435 mr_asprintf(output, "two"); 475 436 break; 476 437 case 3: 477 strcpy(output, "three");438 mr_asprintf(output, "three"); 478 439 break; 479 440 case 4: 480 strcpy(output, "four");441 mr_asprintf(output, "four"); 481 442 break; 482 443 case 5: 483 strcpy(output, "five");444 mr_asprintf(output, "five"); 484 445 break; 485 446 case 6: 486 strcpy(output, "six");447 mr_asprintf(output, "six"); 487 448 break; 488 449 case 7: 489 strcpy(output, "seven");450 mr_asprintf(output, "seven"); 490 451 break; 491 452 case 8: 492 strcpy(output, "eight");453 mr_asprintf(output, "eight"); 493 454 break; 494 455 case 9: 495 strcpy(output, "nine");456 mr_asprintf(output, "nine"); 496 457 case 10: 497 strcpy(output, "ten");458 mr_asprintf(output, "ten"); 498 459 default: 499 sprintf(output, "%d", i);460 mr_asprintf(output, "%d", i); 500 461 } 501 462 return (output); … … 875 836 * @param raid_level The RAID level to stringify. 876 837 * @return The string form of @p raid_level. 877 * @note The returned value points to st atic storage that will be overwritten with each call.838 * @note The returned value points to storage that needs to be freed by caller 878 839 */ 879 840 char *turn_raid_level_number_to_string(int raid_level) … … 881 842 882 843 /*@ buffer ********************************************************** */ 883 static char output[MAX_STR_LEN];844 char *output = NULL; 884 845 885 846 886 847 887 848 if (raid_level >= 0) { 888 sprintf(output, " RAID %-2d ", raid_level);849 mr_asprintf(output, " RAID %-2d ", raid_level); 889 850 } else { 890 sprintf(output, "Linear RAID");891 } 892 return 851 mr_asprintf(output, "Linear RAID"); 852 } 853 return(output); 893 854 } 894 855 … … 1068 1029 char *pos_w_commas = NULL; 1069 1030 char *mds = NULL; 1070 char *tmp = NULL;1071 1031 1072 1032 assert(bkpinfo != NULL); 1073 1033 1074 1034 if (bkpinfo->media_size <= 0) { 1075 mr_asprintf(tmp, "%lld", g_tape_posK); 1076 mr_asprintf(pos_w_commas, "%s", commarize(tmp)); 1077 mr_free(tmp); 1035 mr_asprintf(pos_w_commas, "%lld", g_tape_posK); 1078 1036 mr_asprintf(outstr, "Volume %d: %s kilobytes archived so far", g_current_media_number, pos_w_commas); 1079 1037 mr_free(pos_w_commas); -
branches/3.2/mondo/src/mondorestore/mondo-prep.c
r3610 r3611 1839 1839 mr_asprintf(partcode, ""); 1840 1840 } else if (strlen(format) >= 1 && strlen(format) <= 2) { 1841 mr_asprintf(partcode, format);1841 mr_asprintf(partcode, "%s", format); 1842 1842 } else { 1843 1843 /* probably an image */ … … 1847 1847 1848 1848 #ifdef __FreeBSD__ 1849 mr_asprintf(partcode, format); // was a51849 mr_asprintf(partcode, "%s", format); // was a5 1850 1850 #else 1851 mr_asprintf(partcode, format); // was 831851 mr_asprintf(partcode, "%s", format); // was 83 1852 1852 #endif 1853 1853 } -
branches/3.2/mondo/src/mondorestore/mondo-rstr-mountlist.c
r3564 r3611 55 55 /*@ buffers ******************************************************** */ 56 56 char tmp = NULL; 57 char tmp1 = NULL; 57 58 char device[MAX_STR_LEN]; 58 59 … … 112 113 } 113 114 if (device_copies > 1) { 114 mr_asprintf(tmp, " %s %s's.", number_to_text(device_copies), device); 115 tmp1 = number_to_text(device_copies); 116 mr_asprintf(tmp, " %s %s's.", tmp1, device); 117 mr_free(tmp1); 115 118 if (!strstr(flaws_str, tmp)) { 116 119 log_it(tmp); … … 209 212 } 210 213 if (device_copies > 1) { 211 mr_asprintf(tmp, " %s %s's.", number_to_text(device_copies), device); 214 tmp1 = number_to_text(device_copies); 215 mr_asprintf(tmp, " %s %s's.", tmp1, device); 216 mr_free(tmp1); 212 217 if (!strstr(flaws_str, "%s", tmp)) { 213 218 log_it(tmp); … … 271 276 } 272 277 if (device_copies > 1) { 273 mr_asprintf(tmp, " %s %s's.", number_to_text(device_copies), device); 278 tmp1 = number_to_text(device_copies); 279 mr_asprintf(tmp, " %s %s's.", tmp1, device); 280 mr_free(tmp1); 274 281 if (!strstr(flaws_str, tmp)) { 275 282 log_it(tmp); … … 374 381 /*@ buffers ******************************************************** */ 375 382 char *tmp = NULL; 383 char *tmp1 = NULL; 376 384 char *device = NULL; 377 385 char *flaws_str = NULL; … … 452 460 } 453 461 if (device_copies > 1) { 454 mr_asprintf(tmp, " %s %s's.", number_to_text(device_copies), device); 462 tmp1 = number_to_text(device_copies); 463 mr_asprintf(tmp, " %s %s's.", tmp1, device); 464 mr_free(tmp1); 455 465 if (!strstr(flaws_str, tmp)) { 456 466 log_it(tmp); … … 536 546 struct list_of_disks *drivelist; 537 547 char *tmp = NULL; 548 char *tmp1 = NULL; 538 549 char *flaws_str = NULL; 539 550 … … 589 600 } 590 601 if (copies > 1 && last_copy == currline && strcmp(curr_mountpoint, "raid")) { 591 mr_asprintf(tmp, " %s %s's.", number_to_text(copies), curr_mountpoint); 602 tmp1 = number_to_text(copies); 603 mr_asprintf(tmp, " %s %s's.", tmp1, curr_mountpoint); 604 mr_free(tmp1); 592 605 log_msg(8,"Adding: %s to flaws_str", tmp); 593 606 if (flaws_str != NULL) { -
branches/3.2/mondo/src/mondorestore/mondo-rstr-newt.c
r3289 r3611 1296 1296 } 1297 1297 mr_free(size_str); 1298 newtListboxSetEntry(listbox, (long) keylist[currline], 1299 mountlist_entry_to_string(mountlist, currline)); 1298 1299 tmp = mountlist_entry_to_string(mountlist, currline); 1300 newtListboxSetEntry(listbox, (long) keylist[currline], tmp); 1301 mr_free(tmp); 1302 1300 1303 /* if new /dev/md RAID device then do funky stuff */ 1301 1304 if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB) … … 1580 1583 mr_free(title_of_editraidForm_window); 1581 1584 mr_asprintf(title_of_editraidForm_window, "Edit %s", raidrec->raid_device); 1582 mr_asprintf(sz_raid_level, "%s", turn_raid_level_number_to_string(raidrec->raid_level));1585 sz_raid_level = turn_raid_level_number_to_string(raidrec->raid_level); 1583 1586 sz_data_disks = number_of_disks_as_string(raidrec->data_disks.entries, "data"); 1584 1587 sz_spare_disks = number_of_disks_as_string(raidrec->spare_disks.entries, "spare"); … … 2335 2338 /** long **************************************************************/ 2336 2339 long i = 0; 2340 char *tmp = NULL; 2337 2341 2338 2342 assert(disklist != NULL); … … 2346 2350 } 2347 2351 for (i = 0; i < disklist->entries; i++) { 2348 newtListboxAppendEntry(listbox,2349 disklist_entry_to_string(disklist, i),2350 keylist[i]);2352 tmp = disklist_entry_to_string(disklist, i); 2353 newtListboxAppendEntry(listbox, tmp, keylist[i]); 2354 mr_free(tmp); 2351 2355 } 2352 2356 } … … 2367 2371 /** long **************************************************************/ 2368 2372 long i = 0; 2373 char * tmp = NULL; 2369 2374 2370 2375 assert(mountlist != NULL); … … 2378 2383 } 2379 2384 for (i = 0; i < mountlist->entries; i++) { 2380 newtListboxAppendEntry(listbox,2381 mountlist_entry_to_string(mountlist, i),2382 keylist[i]);2385 tmp = mountlist_entry_to_string(mountlist, i); 2386 newtListboxAppendEntry(listbox, tmp, keylist[i]); 2387 mr_free(tmp); 2383 2388 } 2384 2389 }
Note:
See TracChangeset
for help on using the changeset viewer.