Changeset 3194 in MondoRescue for branches/3.2/mondo/src/common
- Timestamp:
- Sep 29, 2013, 7:27:11 PM (11 years ago)
- Location:
- branches/3.2/mondo/src/common
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mondo/src/common/libmondo-cli.c
r3191 r3194 75 75 int res = 0; 76 76 int retval = 0; 77 int i = 0 , j;77 int i = 0; 78 78 79 79 /*@ buffers *************** */ 80 char *tmp = NULL;81 80 char flag_val[128][MAX_STR_LEN]; 82 81 bool flag_set[128]; -
branches/3.2/mondo/src/common/libmondo-devices.c
r3191 r3194 884 884 if (!tmp[0]) { 885 885 mr_free(tmp); 886 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("cdrecord -scanbus 2> /dev/null | grep \)\ \' | grep -n '' | grep -E '[D|C][V|D]' | cut -d':' -f1"));886 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("cdrecord -scanbus 2> /dev/null | grep -E '\)\ \'' | grep -n '' | grep -E '[D|C][V|D]' | cut -d':' -f1")); 887 887 } 888 888 if (tmp[0]) { … … 2400 2400 2401 2401 /* Initiate bkpinfo netfs_mount path from running environment if not already done */ 2402 if ( !bkpinfo->netfs_mount == NULL) {2403 mr_asprintf(bkpinfo->netfs_mount, call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f1 | head -n1"));2402 if (bkpinfo->netfs_mount == NULL) { 2403 mr_asprintf(bkpinfo->netfs_mount, "%s", call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f1 | head -n1")); 2404 2404 } 2405 2405 #ifdef __FreeBSD__ … … 2417 2417 } 2418 2418 mr_free(bkpinfo->netfs_mount); 2419 mr_asprintf(bkpinfo->netfs_mount, "%s", p ;2419 mr_asprintf(bkpinfo->netfs_mount, "%s", p); 2420 2420 if (!bkpinfo->restore_data) { 2421 2421 if ((compression_type = which_compression_type()) == NULL) { … … 2448 2448 2449 2449 if (!bkpinfo->restore_data) { 2450 mr_ sprintf(sz_size, "%d", DEFAULT_DVD_DISK_SIZE); // 4.7 salesman's GB = 4.482 real GB = 4482 MB2450 mr_asprintf(sz_size, "%d", DEFAULT_DVD_DISK_SIZE); // 4.7 salesman's GB = 4.482 real GB = 4482 MB 2451 2451 mr_asprintf(comment, "How much data (in Megabytes) will each media store?"); 2452 2452 strcpy(tmp1, sz_size); … … 2496 2496 strcpy(tmp1, ""); 2497 2497 } 2498 if (!popup_and_get_string("Network user", "Which user should I use if any ?",tmp1 )) {2498 if (!popup_and_get_string("Network user", "Which user should I use if any ?",tmp1, MAX_STR_LEN)) { 2499 2499 log_to_screen("User has chosen not to backup the PC"); 2500 2500 finish(1); … … 2556 2556 finish(1); 2557 2557 } 2558 strcpy(bkpinfo->netfs_remote_dir, tmp1);2558 mr_asprintf(bkpinfo->netfs_remote_dir, "%s", tmp1); 2559 2559 2560 2560 // check whether writable - we better remove surrounding spaces for this 2561 strip_spaces(bkpinfo->netfs_remote_dir);2561 mr_strip_spaces(bkpinfo->netfs_remote_dir); 2562 2562 2563 2563 if (!popup_and_get_string … … 2820 2820 2821 2821 /* Handle devices passed in bkpinfo and print result */ 2822 /* the mr_make_devlist_from_pathlist function appends 2822 /* the mr_make_devlist_from_pathlist function appends */ 2823 2823 /* to the *_paths variables so copy before */ 2824 2824 mr_make_devlist_from_pathlist(bkpinfo->exclude_paths, 'E'); -
branches/3.2/mondo/src/common/libmondo-devices.h
r3154 r3194 12 12 long get_phys_size_of_drive(char *drive); 13 13 bool is_this_a_valid_disk_format(char *format); 14 int mount_CDROM_here(char *device, c har *mountpoint);14 int mount_CDROM_here(char *device, const char *mountpoint); 15 15 int find_device_in_mountlist(struct mountlist_itself *mountlist, 16 16 char *device); -
branches/3.2/mondo/src/common/libmondo-filelist.c
r3191 r3194 439 439 char *syscall = NULL; 440 440 char *file_to_analyze = NULL; 441 char *strtmp = NULL;442 441 char *tmp = NULL; 443 442 int i; … … 1791 1790 } 1792 1791 log_msg(5, "Found '%s'", fname); 1793 tmp = mr_stresc(fname, "[]*?", '\\', "'");1792 tmp = mr_stresc(fname, "[]*?", '\\', '\''); 1794 1793 mr_free(fname); 1795 1794 fname = tmp; -
branches/3.2/mondo/src/common/libmondo-files.c
r3191 r3194 291 291 log_it("Calling Mindi with kernel path of '%s'", kernel); 292 292 while (!kernel[0]) { 293 if (!ask_me_yes_or_no 294 ("Kernel not found or invalid. Choose another?")) { 293 if (!ask_me_yes_or_no("Kernel not found or invalid. Choose another?")) { 295 294 return (1); 296 295 } 297 if (!popup_and_get_string 298 ("Kernel path", 299 "What is the full path and filename of your kernel, please?", 300 kernel, MAX_STR_LEN / 4)) { 301 fatal_error 302 ("Kernel not found. Please specify with the '-k' flag."); 296 if (!popup_and_get_string("Kernel path", "What is the full path and filename of your kernel, please?", kernel, MAX_STR_LEN / 4)) { 297 fatal_error("Kernel not found. Please specify with the '-k' flag."); 303 298 } 304 299 log_it("User says kernel is at %s", kernel); … … 335 330 mr_free(incoming); 336 331 output[0] = '\0'; 337 return 332 return(NULL); // forget it :) 338 333 } 339 334 mr_asprintf(command, "file %s 2> /dev/null | cut -d':' -f1 2> /dev/null", incoming); 340 mr_free(incomi g);335 mr_free(incoming); 341 336 342 337 mr_asprintf(incoming, "%s", call_program_and_get_last_line_of_output(command)); … … 352 347 strcpy(output, incoming); 353 348 if (output[0] != '\0' && does_file_exist(output)) { 354 log_msg(4, "find_home_of_exe ()--- Found %s at %s", fname, incoming);349 log_msg(4, "find_home_of_exe --- Found %s at %s", fname, incoming); 355 350 } else { 356 351 output[0] = '\0'; 357 log_msg(4, "find_home_of_exe ()--- Could not find %s", fname);352 log_msg(4, "find_home_of_exe --- Could not find %s", fname); 358 353 } 359 354 mr_free(incoming); 360 355 if (!output[0]) { 361 return 356 return(NULL); 362 357 } else { 363 return 358 return(output); 364 359 } 365 360 } … … 433 428 if (!lastline[0]) { 434 429 mr_free(lastline); 435 return 430 return(0); 436 431 } 437 432 } else { … … 444 439 } else { 445 440 mr_free(lastline); 446 return 441 return(0); 447 442 } 448 443 … … 453 448 i = atoi(p); 454 449 mr_free(lastline); 455 return 450 return(i); 456 451 } 457 452 … … 471 466 static char output[MAX_STR_LEN]; 472 467 char *command = NULL; 468 char *p = NULL; 473 469 474 470 /*@ pointers **************************************************** */ … … 478 474 479 475 if (!does_file_exist(filename)) { 480 log_it("Tr ing to get last line of nonexistent file (%s)", filename);476 log_it("Trying to get last line of nonexistent file (%s)", filename); 481 477 output[0] = '\0'; 482 478 return (output); … … 493 489 output[strlen(output) - 1] = '\0'; 494 490 } 495 return 491 return(output); 496 492 } 497 493 … … 513 509 log_it("filename=%s", filename); 514 510 log_OS_error("Unable to openin filename"); 515 return 511 return(-1); 516 512 } 517 513 fseeko(fin, 0, SEEK_END); 518 514 length = ftello(fin); 519 515 paranoid_fclose(fin); 520 return 516 return(length); 521 517 } 522 518 … … 561 557 log_OS_error("Unable to fopen-in filelist"); 562 558 log_to_screen("Can't open filelist"); 563 return 559 return(1); 564 560 } 565 561 fout = fopen(cksumlist, "w"); … … 568 564 paranoid_fclose(fin); 569 565 log_to_screen("Can't open checksum list"); 570 return 566 return(1); 571 567 } 572 568 for (mr_getline(stub_fname, fin); !feof(fin); mr_getline(stub_fname, fin)) { 573 if (stub_fname[(i = strlen(stub_fname) - 1)] < 32) { 569 i = strlen(stub_fname) - 1; 570 if (stub_fname[i] < 32) { 574 571 stub_fname[i] = '\0'; 575 572 } … … 605 602 paranoid_fclose(fin); 606 603 log_it("Done."); 607 return 604 return(0); 608 605 } 609 606 … … 623 620 res = system(tmp); 624 621 mr_free(tmp); 625 return 622 return(res); 626 623 } 627 624 … … 659 656 660 657 unlink(outfile_fname); 661 return 658 return(0); 662 659 } 663 660 … … 687 684 if (!fin) { 688 685 log_OS_error("Unable to openin filelist_fname"); 689 return 686 return(0); 690 687 } 691 688 mr_getline(incoming, fin); … … 699 696 mr_free(incoming); 700 697 paranoid_fclose(fin); 701 return 698 return(matches); 702 699 } 703 700 … … 728 725 mr_free(command); 729 726 730 return 727 return(file_len_K); 731 728 } 732 729 … … 806 803 paranoid_fclose(fin); 807 804 log_it("Finished calculating total size of all biggiefiles"); 808 return 805 return(scratchL); 809 806 } 810 807 … … 848 845 mr_free(command); 849 846 850 return 847 return(llres); 851 848 } 852 849 … … 864 861 tmp = (crc >> 8) ^ c; 865 862 crc = (crc << 8) ^ crctttab[tmp & 255]; 866 return crc;863 return(crc); 867 864 } 868 865 … … 879 876 tmp = crc ^ c; 880 877 crc = (crc >> 8) ^ crc16tab[tmp & 0xff]; 881 return crc;878 return(crc); 882 879 } 883 880 … … 905 902 log_to_screen("There may be hyperlink at http://www.mondorescue.org which"); 906 903 log_to_screen("will take you to the relevant (missing) package."); 907 return 904 return(1); 908 905 } else { 909 return 906 return(0); 910 907 } 911 908 } … … 969 966 log_it("fname=%s", fname); 970 967 log_OS_error("Unable to openin fname"); 971 return 968 return(1); 972 969 } 973 970 res = fscanf(fin, "%s\n", contents); … … 978 975 paranoid_fclose(fin); 979 976 res = 0; 980 return (res); 981 } 982 983 984 977 return(res); 978 } 985 979 986 980 … … 1084 1078 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 1085 1079 } 1086 1087 1088 1089 1080 1090 1081 … … 1115 1106 char *p; 1116 1107 1117 if ( ! bkpinfo->netfs_mount) {1108 if (bkpinfo->netfs_mount == NULL) { 1118 1109 fatal_error("No netfs_mount found !"); 1119 1110 } … … 1152 1143 1153 1144 mr_asprintf(command, "ifconfig %s | head -1 | awk '{print $5}'", netfs_dev); 1154 mr_asprintf(netfs_client_hwaddr, "%s" call_program_and_get_last_line_of_output(command));1145 mr_asprintf(netfs_client_hwaddr, "%s", call_program_and_get_last_line_of_output(command)); 1155 1146 mr_free(command); 1156 1147 … … 1229 1220 mr_free(tmp); 1230 1221 1231 sprintf(tmp, "%s/NETFS-PROTO", bkpinfo->tmpdir);1222 mr_asprintf(tmp, "%s/NETFS-PROTO", bkpinfo->tmpdir); 1232 1223 write_one_liner_data_file(tmp, bkpinfo->netfs_proto); 1233 1224 mr_free(tmp); -
branches/3.2/mondo/src/common/libmondo-fork.c
r3191 r3194 43 43 /*@ pointers **************************************************** */ 44 44 FILE *fin = NULL; 45 int res = 0;46 45 47 46 /*@ initialize data ********************************************* */ -
branches/3.2/mondo/src/common/libmondo-stream.c
r3191 r3194 282 282 283 283 mr_asprintf(command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f2 | head -n1", cdr_exe); 284 mr_asprintf(tmp, "%s", all_program_and_get_last_line_of_output(command));284 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command)); 285 285 mr_free(command); 286 286 -
branches/3.2/mondo/src/common/libmondo-string-EXT.h
r3042 r3194 31 31 32 32 extern int compare_two_filelist_entries(void *va, void *vb); 33 extern int severity_of_difference(char *filename, char *out_reason); 34 33 extern int severity_of_difference(char *filename, char **out_reason); 35 34 extern char *percent_media_full_comment(); 36 35 -
branches/3.2/mondo/src/common/libmondo-string.c
r3191 r3194 866 866 * @return The severity (1-3). 867 867 */ 868 int severity_of_difference(char *fn, char * out_reason) {868 int severity_of_difference(char *fn, char **out_reason) { 869 869 870 870 int sev = 3; … … 971 971 } 972 972 if (out_reason) { 973 strcpy( out_reason, reason);973 strcpy(*out_reason, reason); 974 974 } 975 975 mr_free(filename); -
branches/3.2/mondo/src/common/libmondo-string.h
r3042 r3194 26 26 27 27 int compare_two_filelist_entries(void *va, void *vb); 28 int severity_of_difference(char *filename, char * out_reason);28 int severity_of_difference(char *filename, char **out_reason); 29 29 30 30 char *percent_media_full_comment(); -
branches/3.2/mondo/src/common/libmondo-tools.c
r3191 r3194 34 34 extern int g_current_media_number; 35 35 extern char *MONDO_LOGFILE; 36 extern char *g_serial_string;37 36 38 37 /* Reference to global bkpinfo */ … … 61 60 * The serial string (used to differentiate between backups) of the current backup. 62 61 */ 63 char *g_serial_string = NULL;62 extern char *g_serial_string; 64 63 65 64 /** … … 359 358 char *cdr_exe = NULL; 360 359 char *tmp = NULL; 361 char *p = NULL;362 360 char *call_before_iso_user = NULL; 363 361 char *iso_dev = NULL; … … 633 631 mr_asprintf(ip_address, "%s", inet_ntoa((struct in_addr) *((struct in_addr *) hent->h_addr))); 634 632 mr_strcat(ip_address, strchr(bkpinfo->netfs_mount, ':')); 635 strcpy(bkpinfo->netfs_mount, ip_address);636 mr_free(ip_address);633 mr_free(bkpinfo->netfs_mount); 634 bkpinfo->netfs_mount = ip_address; 637 635 } 638 636 } … … 801 799 void reset_bkpinfo() 802 800 { 803 int i;804 801 log_msg(1, "Initializing bkpinfo"); 805 802 … … 824 821 bkpinfo->internal_tape_block_size = DEFAULT_INTERNAL_TAPE_BLOCK_SIZE; 825 822 826 /* We need tmpdir as early as possible for further function calls */ 827 bkpinfo->tmpdir = NULL; // Really setup after 823 /* We need tmpdir as early as possible for further function calls */ 824 bkpinfo->tmpdir[0]= '\0'; // Really setup after 825 bkpinfo->scratchdir[0]= '\0'; // Really setup after 828 826 setup_tmpdir(NULL); 829 827 setup_scratchdir(NULL); … … 848 846 bkpinfo->call_after_iso[0] = '\0'; 849 847 bkpinfo->kernel_path[0] = '\0'; 850 bkpinfo->netfs_mount [0] = '\0';848 bkpinfo->netfs_mount = NULL; 851 849 bkpinfo->netfs_proto = NULL; 852 850 bkpinfo->netfs_user = NULL; 853 bkpinfo->netfs_remote_dir [0] = '\0';851 bkpinfo->netfs_remote_dir = NULL; 854 852 bkpinfo->postnuke_tarball[0] = '\0'; 855 853 bkpinfo->subdir = NULL; … … 1365 1363 * Function pointer to the @c log_debug_msg function to use. Points to standard_log_debug_msg() by default. 1366 1364 */ 1367 void (*log_debug_msg) (int, const char *, const char *, int, const char *, 1368 ...) = standard_log_debug_msg; 1365 void (*log_debug_msg) (int, const char *, const char *, int, const char *, ...) = standard_log_debug_msg; 1369 1366 1370 1367 -
branches/3.2/mondo/src/common/libmondo-verify.c
r3191 r3194 412 412 char *outlog = NULL; 413 413 char *tmp = NULL; 414 char *p = NULL;415 414 416 415 /*@ pointers ******************************************************* */ -
branches/3.2/mondo/src/common/newt-specific.c
r3191 r3194 20 20 #include "my-stuff.h" 21 21 #include "mr_mem.h" 22 #include "mr_str.h" 22 23 #include "mondostructures.h" 23 24 #include "newt-specific.h" … … 1579 1580 if (filelist->entries > 0) { 1580 1581 malloc_string(reason); 1581 severity_of_difference(filelist->el[currline]. 1582 severity_of_difference(filelist->el[currline].filename, &reason); 1582 1583 mr_asprintf(tmp, "%s --- %s", filelist->el[currline].filename, reason); 1583 1584
Note:
See TracChangeset
for help on using the changeset viewer.