Changeset 2357 in MondoRescue for branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c
- Timestamp:
- Aug 29, 2009, 3:22:10 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c
r2351 r2357 107 107 * @ingroup restoreUtilityGroup 108 108 */ 109 void ask_about_these_imagedevs(char *infname, char *outfname) 110 { 109 void ask_about_these_imagedevs(char *infname, char *outfname) { 110 111 111 FILE *fin; 112 112 FILE *fout; 113 /************************************************************************ 114 * allocate memory regions. test and set -sab 16 feb 2003 * 115 ************************************************************************/ 116 char *incoming_ptr; 117 char *question_ptr = NULL; 118 119 char incoming[MAX_STR_LEN] = "\0"; 113 char *incoming = NULL; 114 char *question = NULL; 120 115 121 116 assert_string_is_neither_NULL_nor_zerolength(infname); 122 117 assert_string_is_neither_NULL_nor_zerolength(outfname); 123 118 124 incoming_ptr = malloc(sizeof(incoming));125 if (incoming_ptr == NULL) {126 fprintf(stderr, "Out of Memory\n");127 exit(EXIT_FAILURE);128 }129 130 memset(incoming_ptr, '\0', sizeof(incoming));131 132 119 if (!(fin = fopen(infname, "r"))) { 133 fatal_error("Cannot openin infname");120 fatal_error("Cannot openin infname"); 134 121 } 135 122 if (!(fout = fopen(outfname, "w"))) { 136 fatal_error("Cannot openin outfname"); 137 } 138 for (fgets(incoming_ptr, MAX_STR_LEN, fin); 139 !feof(fin); fgets(incoming_ptr, MAX_STR_LEN, fin)) { 140 strip_spaces(incoming_ptr); 141 142 if (incoming[0] == '\0') { 143 continue; 144 } 145 146 mr_asprintf(question_ptr, "Should I restore the image of %s ?", incoming_ptr); 147 148 if (ask_me_yes_or_no(question_ptr)) { 149 fprintf(fout, "%s\n", incoming_ptr); 150 } 151 } 152 153 /*** free memory ***********/ 154 paranoid_free(incoming_ptr); 155 incoming_ptr = NULL; 156 mr_free(question_ptr); 123 fatal_error("Cannot openin outfname"); 124 } 125 for (mr_getline(incoming, fin); !feof(fin); mr_getline(incoming, fin)) { 126 mr_strip_spaces(incoming); 127 128 if (incoming[0] == '\0') { 129 mr_free(incoming); 130 continue; 131 } 132 133 mr_asprintf(question, "Should I restore the image of %s ?", incoming); 134 135 if (ask_me_yes_or_no(question)) { 136 fprintf(fout, "%s\n", incoming); 137 } 138 mr_free(incoming); 139 } 140 mr_free(incoming); 141 mr_free(question); 157 142 paranoid_fclose(fout); 158 143 paranoid_fclose(fin); … … 619 604 mr_free(bkpinfo->media_device); 620 605 if (bkpinfo->disaster_recovery && does_file_exist("/tmp/CDROM-LIVES-HERE")) { 621 mr_asprintf(bkpinfo->media_device, "%s", last_line_of_file("/tmp/CDROM-LIVES-HERE"));606 bkpinfo->media_device = last_line_of_file("/tmp/CDROM-LIVES-HERE"); 622 607 } else { 623 608 bkpinfo->media_device = find_cdrom_device(TRUE); … … 1119 1104 char *command = NULL; 1120 1105 char *tmp; 1106 char *tmp1 = NULL; 1121 1107 int res = 0; 1122 1108 pid_t pid; … … 1260 1246 if (g_text_mode) { 1261 1247 printf("Restore which directory? --> "); 1262 fgets(tmp, sizeof(tmp), stdin);1263 toggle_path_selection(filelist, tmp , TRUE);1264 if (strlen(tmp ) == 0) {1248 mr_getline(tmp1, stdin); 1249 toggle_path_selection(filelist, tmp1, TRUE); 1250 if (strlen(tmp1) == 0) { 1265 1251 res = 1; 1266 1252 } else { 1267 1253 res = 0; 1268 1254 } 1255 mr_free(tmp1); 1269 1256 } else { 1270 1257 res = edit_filelist(filelist); … … 1938 1925 FILE *fin; 1939 1926 FILE *fout; 1940 /** malloc **/ 1941 char *incoming; 1927 char *incoming = NULL; 1942 1928 1943 1929 assert_string_is_neither_NULL_nor_zerolength(output_file); 1944 1930 assert_string_is_neither_NULL_nor_zerolength(input_file); 1945 malloc_string(incoming);1946 1931 1947 1932 if (!(fin = fopen(input_file, "r"))) { … … 1952 1937 fatal_error("cannot open output_file"); 1953 1938 } 1954 for (fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin); 1955 fgets(incoming, MAX_STR_LEN - 1, fin)) { 1939 for (mr_getline(incoming, fin); !feof(fin); mr_getline(incoming, fin)) { 1956 1940 if (strncmp(incoming, "etc/adjtime", 11) 1957 1941 && strncmp(incoming, "etc/mtab", 8) … … 1962 1946 && strncmp(incoming, "var/", 4)) 1963 1947 fprintf(fout, "%s", incoming); /* don't need \n here, for some reason.. */ 1964 } 1948 mr_free(incoming); 1949 } 1950 mr_free(incoming); 1965 1951 paranoid_fclose(fout); 1966 1952 paranoid_fclose(fin); 1967 paranoid_free(incoming);1968 1953 } 1969 1954
Note:
See TracChangeset
for help on using the changeset viewer.