Changeset 1173 in MondoRescue for branches/stable/mondo/src/common/libmondo-fork.c
- Timestamp:
- Feb 16, 2007, 12:25:24 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/common/libmondo-fork.c
r1168 r1173 46 46 47 47 assert_string_is_neither_NULL_nor_zerolength(call); 48 48 49 if ((fin = popen(call, "r"))) { 49 50 for (fgets(tmp, MAX_STR_LEN, fin); !feof(fin); … … 184 185 char *callstr = NULL; 185 186 char *incoming = NULL; 186 char *tmp = NULL;187 187 188 188 /*@ int ********************************************************* */ 189 189 int res = 0; 190 190 size_t n = 0; 191 int i;192 int len;193 191 bool log_if_failure = FALSE; 194 192 bool log_if_success = FALSE; … … 325 323 } 326 324 } 327 #ifdef _XWIN328 /* This only can update when newline goes into the file,329 but it's *much* prettier/faster on Qt. */330 while (does_file_exist(lockfile)) {331 while (!feof(fin)) {332 if (!fgets(tmp, 512, fin))333 break;334 log_to_screen(tmp);335 }336 usleep(500000);337 }338 #else339 325 /* This works on Newt, and it gives quicker updates. */ 340 326 for (; does_file_exist(lockfile); sleep(1)) { … … 342 328 update_evalcall_form(1); 343 329 } 344 #endif345 330 /* Evaluate the status returned by pclose to get the exit code of the called program. */ 346 331 errno = 0; … … 379 364 // if dir=='r' then copy from archived to orig 380 365 char *tmp = NULL; 366 char *tmp1 = NULL; 381 367 char *buf = NULL; 382 368 long int bytes_to_be_read, bytes_read_in, bytes_written_out = … … 396 382 fin = f_orig; 397 383 fout = f_archived; 398 sprintf(tmp, "%-64s", PIMP_START_SZ);399 if (fwrite(tmp , 1, 64, fout) != 64) {384 mr_asprintf(&tmp1, "%-64s", PIMP_START_SZ); 385 if (fwrite(tmp1, 1, 64, fout) != 64) { 400 386 fatal_error("Can't write the introductory block"); 401 387 } 388 mr_free(tmp1); 389 402 390 while (1) { 403 391 bytes_to_be_read = bytes_read_in = fread(buf, 1, bufcap, fin); … … 405 393 break; 406 394 } 407 sprintf(tmp, "%-64ld", bytes_read_in);408 if (fwrite(tmp , 1, 64, fout) != 64) {395 mr_asprintf(&tmp1, "%-64ld", bytes_read_in); 396 if (fwrite(tmp1, 1, 64, fout) != 64) { 409 397 fatal_error("Cannot write introductory block"); 410 398 } 399 mr_free(tmp1); 400 411 401 mr_msg(7, 412 402 "subslice #%ld --- I have read %ld of %ld bytes in from f_orig", 413 403 subsliceno, bytes_read_in, bytes_to_be_read); 414 404 bytes_written_out += fwrite(buf, 1, bytes_read_in, fout); 415 sprintf(tmp, "%-64ld", subsliceno);416 if (fwrite(tmp , 1, 64, fout) != 64) {405 mr_asprintf(&tmp1, "%-64ld", subsliceno); 406 if (fwrite(tmp1, 1, 64, fout) != 64) { 417 407 fatal_error("Cannot write post-thingy block"); 418 408 } 409 mr_free(tmp1); 410 419 411 mr_msg(7, "Subslice #%d written OK", subsliceno); 420 412 subsliceno++; … … 427 419 fin = f_archived; 428 420 fout = f_orig; 421 tmp = mr_malloc(64L); 429 422 if (fread(tmp, 1, 64L, fin) != 64L) { 430 423 fatal_error("Cannot read the introductory block"); … … 447 440 } 448 441 bytes_written_out += fwrite(buf, 1, bytes_read_in, fout); 449 if (fread(tmp, 1, 64 , fin) != 64) {442 if (fread(tmp, 1, 64L, fin) != 64L) { 450 443 fatal_error("Cannot read post-thingy block"); 451 444 } … … 456 449 mr_msg(7, "Subslice #%ld read OK", subsliceno); 457 450 subsliceno++; 458 if (fread(tmp, 1, 64 , fin) != 64) {451 if (fread(tmp, 1, 64L, fin) != 64L) { 459 452 fatal_error("Cannot read introductory block"); 460 453 } … … 466 459 467 460 if (direction == 'w') { 468 sprintf(tmp, "%-64s", PIMP_END_SZ);469 if (fwrite(tmp , 1, 64, fout) != 64) {461 mr_asprintf(&tmp1, "%-64s", PIMP_END_SZ); 462 if (fwrite(tmp1, 1, 64L, fout) != 64L) { 470 463 fatal_error("Can't write the final block"); 471 464 } 465 mr_free(tmp1); 472 466 } else { 473 467 mr_msg(1, "tmpA is %s", tmp); 474 468 if (!strstr(tmp, PIMP_END_SZ)) { 475 if (fread(tmp, 1, 64 , fin) != 64) {469 if (fread(tmp, 1, 64L, fin) != 64L) { 476 470 fatal_error("Can't read the final block"); 477 471 } … … 479 473 if (!strstr(tmp, PIMP_END_SZ)) { 480 474 ftmp = fopen("/tmp/out.leftover", "w"); 481 bytes_read_in = fread(tmp, 1, 64 , fin);475 bytes_read_in = fread(tmp, 1, 64L, fin); 482 476 mr_msg(1, "bytes_read_in = %ld", bytes_read_in); 483 477 // if (bytes_read_in!=128+64) { fatal_error("Can't read the terminating block"); }
Note:
See TracChangeset
for help on using the changeset viewer.