Changeset 1176 in MondoRescue for trunk/mondo/src/common/libmondo-fork.c
- Timestamp:
- Feb 16, 2007, 2:16:14 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/src/common/libmondo-fork.c
r1161 r1176 4 4 #include "my-stuff.h" 5 5 #include "mr_mem.h" 6 #include "mr_msg.h" 7 #include "mr_str.h" 8 6 9 #include "mondostructures.h" 7 10 #include "libmondo-fork.h" … … 10 13 #include "libmondo-files-EXT.h" 11 14 #include "libmondo-tools-EXT.h" 12 #include "mr_mem.h"13 15 14 16 extern bool g_text_mode; … … 164 166 165 167 /*@ pointers *************************************************** */ 166 FILE *fin ;167 char *p ;168 FILE *fin = NULL; 169 char *p = NULL; 168 170 169 171 /*@ end vars *************************************************** */ … … 188 190 *p = ' '; 189 191 } /* single '=' is intentional */ 190 191 192 192 193 res = system(callstr); … … 208 209 fin = fopen("/tmp/mondo-run-prog-thing.tmp", "r"); 209 210 if (fin) { 210 for (mr_getline(&incoming, &n, fin); !feof(fin); 211 mr_getline(&incoming, &n, fin)) { 211 for (mr_getline(&incoming, &n, fin); !feof(fin); mr_getline(&incoming, &n, fin)) { 212 212 /* patch by Heiko Schlittermann */ 213 213 p = incoming; … … 219 219 } 220 220 /* end of patch */ 221 strip_spaces(incoming);221 mr_strip_spaces(incoming); 222 222 if ((res == 0 && log_if_success) 223 223 || (res != 0 && log_if_failure)) { … … 238 238 } 239 239 } 240 // else241 // { mr_msg (0, "-------------------------------ran w/ res=%d------------------------------", res); }242 240 return (res); 243 241 } … … 339 337 // if dir=='r' then copy from archived to orig 340 338 char *tmp = NULL; 339 char *tmp1 = NULL; 341 340 char *buf = NULL; 342 341 long int bytes_to_be_read, bytes_read_in, bytes_written_out = … … 354 353 fin = f_orig; 355 354 fout = f_archived; 356 mr_asprintf(&tmp , "%-64s", PIMP_START_SZ);357 if (fwrite(tmp , 1, 64, fout) != 64) {355 mr_asprintf(&tmp1, "%-64s", PIMP_START_SZ); 356 if (fwrite(tmp1, 1, 64, fout) != 64) { 358 357 fatal_error("Can't write the introductory block"); 359 358 } 360 mr_free(tmp );359 mr_free(tmp1); 361 360 362 361 while (1) { … … 365 364 break; 366 365 } 367 mr_asprintf(&tmp , "%-64ld", bytes_read_in);368 if (fwrite(tmp , 1, 64, fout) != 64) {366 mr_asprintf(&tmp1, "%-64ld", bytes_read_in); 367 if (fwrite(tmp1, 1, 64, fout) != 64) { 369 368 fatal_error("Cannot write introductory block"); 370 369 } 371 mr_free(tmp );370 mr_free(tmp1); 372 371 373 372 mr_msg(7, … … 375 374 subsliceno, bytes_read_in, bytes_to_be_read); 376 375 bytes_written_out += fwrite(buf, 1, bytes_read_in, fout); 377 mr_asprintf(&tmp , "%-64ld", subsliceno);378 if (fwrite(tmp , 1, 64, fout) != 64) {376 mr_asprintf(&tmp1, "%-64ld", subsliceno); 377 if (fwrite(tmp1, 1, 64, fout) != 64) { 379 378 fatal_error("Cannot write post-thingy block"); 380 379 } 381 mr_free(tmp );380 mr_free(tmp1); 382 381 383 382 mr_msg(7, "Subslice #%d written OK", subsliceno); … … 391 390 fin = f_archived; 392 391 fout = f_orig; 393 if (!(tmp = malloc(64L))) { 394 fatal_error("Failed to malloc() tmp"); 395 } 392 tmp = mr_malloc(64L); 396 393 if (fread(tmp, 1, 64L, fin) != 64L) { 397 394 fatal_error("Cannot read the introductory block"); … … 433 430 434 431 if (direction == 'w') { 435 mr_free(tmp); 436 mr_asprintf(&tmp, "%-64s", PIMP_END_SZ); 437 if (fwrite(tmp, 1, 64L, fout) != 64L) { 432 mr_asprintf(&tmp1, "%-64s", PIMP_END_SZ); 433 if (fwrite(tmp1, 1, 64L, fout) != 64L) { 438 434 fatal_error("Can't write the final block"); 439 435 } 440 mr_free(tmp );436 mr_free(tmp1); 441 437 } else { 442 438 mr_msg(1, "tmpA is %s", tmp); … … 468 464 } 469 465 } 470 mr_free(tmp);471 466 } 472 467 473 468 mr_free(buf); 469 mr_free(tmp); 474 470 mr_msg(3, "Successfully copied %ld bytes", bytes_written_out); 475 471 return (retval);
Note:
See TracChangeset
for help on using the changeset viewer.