Changeset 783 in MondoRescue for trunk/mondo/mondo/common/libmondo-fork.c


Ignore:
Timestamp:
Aug 31, 2006, 5:09:20 PM (18 years ago)
Author:
Bruno Cornec
Message:
  • Massive rewrite continues for memory management.
  • main structure should now have all parameters allocated dynamically
  • new lib libmr.a + dir + build process reviewed to support it.
  • new include subdir to host external definitions of the new lib
  • code now compiles. Still one remaining link issues for mondorestore. This should allow for some tests soon.

(goal is to separate completely reviewed code and functions and provide clean interfaces)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mondo/mondo/common/libmondo-fork.c

    r689 r783  
    1111#include "libmondo-tools-EXT.h"
    1212
    13 extern char *g_tmpfs_mountpt;
    14 extern t_bkptype g_backup_media_type;
    1513extern bool g_text_mode;
    1614pid_t g_buffer_pid = 0;
     
    107105    log_msg(4, "Calling open_evalcall_form() with what_i_am_doing='%s'",
    108106            what_i_am_doing);
    109     strcpy(tmp, command);
    110107    if (bkpinfo->manual_cd_tray) {
    111         p = strstr(tmp, "2>>");
     108        /* Find everything after a 2>> and remove it */
     109        p = strstr(command, "2>>");
    112110        if (p) {
    113             sprintf(p, "   ");
    114             while (*p == ' ') {
    115                 p++;
    116             }
    117             for (; *p != ' '; p++) {
     111            for (; *p != ' ' && *p != '\0'; p++) {
    118112                *p = ' ';
    119113            }
    120114        }
    121         paranoid_free(command);
    122         asprintf(&command, tmp);
    123115#ifndef _XWIN
    124116        if (!g_text_mode) {
     
    164156{
    165157    /*@ buffer ****************************************************** */
    166     char *callstr;
     158    char *callstr = NULL;
    167159    char *incoming = NULL;
    168     char tmp[MAX_STR_LEN * 2];
    169160
    170161    /*@ int ********************************************************* */
    171     int res;
    172     int i;
     162    int res = 0;
    173163    size_t n = 0;
    174     int len;
    175164    bool log_if_failure = FALSE;
    176165    bool log_if_success = FALSE;
     
    203192
    204193
    205     len = (int) strlen(program);
    206     for (i = 0; i < 35 - len / 2; i++) {
    207         tmp[i] = '-';
    208     }
    209     tmp[i] = '\0';
    210     strcat(tmp, " ");
    211     strcat(tmp, program);
    212     strcat(tmp, " ");
    213     for (i = 0; i < 35 - len / 2; i++) {
    214         strcat(tmp, "-");
    215     }
    216194    res = system(callstr);
    217195    if (((res == 0) && log_if_success) || ((res != 0) && log_if_failure)) {
     
    361339// if dir=='w' then copy from orig to archived
    362340// if dir=='r' then copy from archived to orig
    363     char *tmp;
    364     char *buf;
     341    char *tmp = NULL;
     342    char *buf = NULL;
    365343    long int bytes_to_be_read, bytes_read_in, bytes_written_out =
    366344        0, bufcap, subsliceno = 0;
    367345    int retval = 0;
    368     FILE *fin;
    369     FILE *fout;
    370     FILE *ftmp;
     346    FILE *fin = NULL;
     347    FILE *fout = NULL;
     348    FILE *ftmp = NULL;
    371349
    372350    log_msg(5, "Opening.");
     
    439417            }
    440418            bytes_written_out += fwrite(buf, 1, bytes_read_in, fout);
    441             if (fread(tmp, 1, 64, fin) != 64) {
     419            if (fread(tmp, 1, 64L, fin) != 64L) {
    442420                fatal_error("Cannot read post-thingy block");
    443421            }
     
    448426            log_msg(7, "Subslice #%ld read OK", subsliceno);
    449427            subsliceno++;
    450             if (fread(tmp, 1, 64, fin) != 64) {
     428            if (fread(tmp, 1, 64L, fin) != 64L) {
    451429                fatal_error("Cannot read introductory block");
    452430            }
     
    458436
    459437    if (direction == 'w') {
     438        paranoid_free(tmp);
    460439        asprintf(&tmp, "%-64s", PIMP_END_SZ);
    461         if (fwrite(tmp, 1, 64, fout) != 64) {
     440        if (fwrite(tmp, 1, 64L, fout) != 64L) {
    462441            fatal_error("Can't write the final block");
    463442        }
     
    466445        log_msg(1, "tmpA is %s", tmp);
    467446        if (!strstr(tmp, PIMP_END_SZ)) {
    468             if (fread(tmp, 1, 64, fin) != 64) {
     447            if (fread(tmp, 1, 64L, fin) != 64L) {
    469448                fatal_error("Can't read the final block");
    470449            }
     
    472451            if (!strstr(tmp, PIMP_END_SZ)) {
    473452                ftmp = fopen("/tmp/out.leftover", "w");
    474                 bytes_read_in = fread(tmp, 1, 64, fin);
     453                bytes_read_in = fread(tmp, 1, 64L, fin);
    475454                log_msg(1, "bytes_read_in = %ld", bytes_read_in);
    476455//      if (bytes_read_in!=128+64) { fatal_error("Can't read the terminating block"); }
    477456                fwrite(tmp, 1, bytes_read_in, ftmp);
     457               
    478458                paranoid_free(tmp);
    479                
    480459                if (!(tmp = malloc(512))) {
    481460                    fatal_error("Failed to malloc() tmp");
    482461                }
    483462                /* BERLIOS : strange ???
    484                 sprintf(tmp, "I am here - %llu", ftello(fin));
    485       log_msg(0, tmp);
    486 */
     463                s-printf(tmp, "I am here - %llu", ftello(fin));
     464                log_msg(0, tmp);
     465                */
    487466                fread(tmp, 1, 512, fin);
    488467                log_msg(0, "tmp = '%s'", tmp);
     
    571550        if (pcno <= 5 && last_pcno > 40) {
    572551            close_evalcall_form();
    573             open_evalcall_form("_(Verifying..."));
     552            open_evalcall_form("_(Verifying...");
    574553        }
    575554        last_pcno = pcno;
Note: See TracChangeset for help on using the changeset viewer.