Changeset 2421 in MondoRescue for branches/2.2.10/mondo/src/common


Ignore:
Timestamp:
Sep 24, 2009, 3:50:38 PM (16 years ago)
Author:
Bruno Cornec
Message:
  • Remove some compiler warnings on main
  • Adds function mr_chomp and mr_strip_char and use them in mr_date and call_program_and_get_last_line_of_output
  • Fix call_program_and_get_last_line_of_output to return the right result using a temp file instead of popen
  • Fix an issue in mr_getline_int in case of eof (returns now an empty string)
  • Sequencing of Init of bkpinfo reviewed
Location:
branches/2.2.10/mondo/src/common
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/common/libmondo-archive.c

    r2420 r2421  
    993993        if (!does_file_exist(archiving_filelist_fname)) {
    994994            log_msg(3, "[%d:%d] - well, I would archive %d, except that it doesn't exist. I'll stop now.", getpid(), this_thread_no, archiving_set_no);
     995            mr_free(archiving_afioball_fname);
    995996            break;
    996997        }
     
    12911292    malloc_string(result_str);
    12921293    transfer_block = malloc(sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64);
    1293     memset((void *) transfer_block, 0,
    1294            sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64);
     1294    memset((void *) transfer_block, 0, sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64);
    12951295    p_last_set_archived = (int *) transfer_block;
    12961296    p_archival_threads_running = (int *) (transfer_block + 4);
    12971297    p_next_set_to_archive = (int *) (transfer_block + 8);
    12981298    p_list_of_fileset_flags = (char *) (transfer_block + 12);
    1299     memcpy((void *) (transfer_block + BKPINFO_LOC_OFFSET),
    1300            (void *) bkpinfo, sizeof(struct s_bkpinfo));
     1299    memcpy((void *) (transfer_block + BKPINFO_LOC_OFFSET), (void *) bkpinfo, sizeof(struct s_bkpinfo));
    13011300    pvp = &vp;
    13021301    vp = (void *) result_str;
     
    13101309                       "Please wait. This may take a couple of hours.",
    13111310                       "Working...",
    1312                        get_last_filelist_number() + 1);
     1311                       (long)get_last_filelist_number() + 1L);
    13131312
    13141313    log_msg(5, "We're gonna party like it's your birthday.");
  • branches/2.2.10/mondo/src/common/libmondo-devices.c

    r2405 r2421  
    22572257char *where_is_root_mounted() {
    22582258    /*@ buffers **************** */
    2259     char *output;
     2259    char *output = NULL;
    22602260
    22612261
  • branches/2.2.10/mondo/src/common/libmondo-fork.c

    r2420 r2421  
    88#include "my-stuff.h"
    99#include "mr_mem.h"
     10#include "mr_str.h"
    1011#include "mondostructures.h"
    1112#include "libmondo-fork.h"
     
    3940    char *result = NULL;
    4041    char *tmpf = NULL;
     42    char *newcall = NULL;
     43    char *tmp = NULL;
    4144
    4245    /*@ pointers **************************************************** */
    43     FILE *fin;
     46    FILE *fin = NULL;
    4447
    4548    /*@******************************************************************** */
     
    4750    assert_string_is_neither_NULL_nor_zerolength(call);
    4851
    49     mr_asprintf(tmpf, "%s/cpgll.out", bkpinfo->scratchdir);
    50     mr_strcat(call, " > %s", tmpf);
    51     log_msg(4, "Calling command: %s", call);
     52    mr_asprintf(tmpf, "%s/cpgll.out", bkpinfo->tmpdir);
     53    mr_asprintf(newcall, "%s > %s", call, tmpf);
     54    log_msg(4, "Calling command: %s", newcall);
    5255    /* By default return an empty string in any case */
    5356    mr_asprintf(result, "");
    5457
    55     system(call);
    56     if ((fin = fopen(ftmp, "r"))) {
     58    system(newcall);
     59    mr_free(newcall);
     60
     61    if ((fin = fopen(tmpf, "r"))) {
    5762        while (!feof(fin)) {
    58             mr_getline(result, fin);
    59             log_msg(9, "Loop result: %s", result);
    60         }
    61         log_msg(4, "Final Result: %s", result);
     63            mr_getline(tmp, fin);
     64            mr_chomp(tmp);
     65            /* In case of extreme debug ;-)
     66            log_msg(9, "Loop result: ***%s***", tmp);
     67            */
     68            /*  There is empty contant at the end of the file that needs to be skiped */
     69            if (strlen(tmp) > 0) {
     70                mr_free(result);
     71                mr_asprintf(result, "%s", tmp);
     72            }
     73            mr_free(tmp);
     74        }
     75        log_msg(4, "Result: %s", result);
    6276        mr_strip_spaces(result);
    6377        paranoid_pclose(fin);
    6478    } else {
    65         log_OS_error("Unable to popen call");
    66     }
    67     mr_free(ftmp)
    68     log_msg(4, "Returns: %s", result);
     79        log_OS_error("Unable to open resulting file");
     80    }
     81    mr_free(tmpf);
    6982    return(result);
    7083}
  • branches/2.2.10/mondo/src/common/libmondo-tools-EXT.h

    r2325 r2421  
    33extern void clean_up_KDE_desktop_if_necessary(void);
    44extern long get_time();
    5 extern char *mr_date(void);
    65extern void (*log_debug_msg) (int debug_level, const char *szFile,
    76                              const char *szFunction, int nLine,
  • branches/2.2.10/mondo/src/common/libmondo-tools.c

    r2406 r2421  
    803803    bkpinfo = (struct s_bkpinfo *)mr_malloc(sizeof(struct s_bkpinfo));
    804804
     805    /*  We need tmpdir as early as possible for further function calls */
     806    bkpinfo->tmpdir = NULL;         // Really setup after
     807    setup_tmpdir(NULL);
     808
    805809    /* Initialized in same order as in the structure declaration to detect errors more easily */
    806810    bkpinfo->media_device = NULL;
     
    822826    bkpinfo->use_star = FALSE;
    823827    bkpinfo->internal_tape_block_size = DEFAULT_INTERNAL_TAPE_BLOCK_SIZE;
    824     bkpinfo->disaster_recovery = (am_I_in_disaster_recovery_mode()? TRUE : FALSE);
     828    bkpinfo->disaster_recovery = am_I_in_disaster_recovery_mode();
    825829    if (bkpinfo->disaster_recovery) {
    826830        mr_asprintf(bkpinfo->isodir, "%s", "/");
     
    829833    }
    830834    mr_asprintf(bkpinfo->prefix, "%s", STD_PREFIX);
     835    /*   bkpinfo->tmpdir is here in the struct */
    831836    bkpinfo->scratchdir = NULL;     // Really setup after
    832     bkpinfo->tmpdir = NULL;         // Really setup after
    833837    bkpinfo->optimal_set_size = 0;
    834838    bkpinfo->backup_media_type = none;
     
    857861    bkpinfo->restore_mode = interactive;
    858862
    859     setup_tmpdir(NULL);
    860863    sensibly_set_scratchdir();
    861864}
     
    13641367        va_end(args);
    13651368
    1366         // do not slow down the progran if standard debug level
    1367         // must be enabled: if no flush, the log won't be up-to-date if there
    1368         // is a segfault
    1369         //if (g_dwDebugLevel != 1)
    1370 
    13711369        fprintf(fout, "\n");
    13721370        paranoid_fclose(fout);
  • branches/2.2.10/mondo/src/common/libmondo-tools.h

    r2325 r2421  
    66
    77long get_time();
    8 char *mr_date(void);
    98extern void (*log_debug_msg) (int debug_level, const char *szFile,
    109                              const char *szFunction, int nLine,
  • branches/2.2.10/mondo/src/common/newt-specific.c

    r2414 r2421  
    9696    extern int g_current_media_number;
    9797    pid_t g_main_pid = 0;       ///< The PID of the main Mondo process.
    98     long g_maximum_progress = 999;  ///< The maximum amount of progress (100%) for the currently opened progress form.
     98    long g_maximum_progress = 999L; ///< The maximum amount of progress (100%) for the currently opened progress form.
    9999    long g_current_progress = -999; ///< The current amount of progress (filelist #, etc.) for the currently opened progress form.
    100100    long g_start_time = 0L;     ///< The time (in seconds since the epoch) that the progress form was opened.
     
    644644            g_blurb3 = newtLabel(2, 4, blurb2);
    645645            newtCenteredWindow(60, 11, title);
    646             g_scale = newtScale(3, 6, 54, g_maximum_progress);
     646            g_scale = newtScale(3, 6, 54, (long long)g_maximum_progress);
    647647            g_progressForm = newtForm(NULL, NULL, 0);
    648648            g_percentline = newtLabel(10, 9, "This is the percentline");
Note: See TracChangeset for help on using the changeset viewer.