Changeset 1264


Ignore:
Timestamp:
Mar 24, 2007, 1:48:55 AM (13 years ago)
Author:
bruno
Message:
  • mr_exit used instead of exit
  • mr_rs_clean_conf/mr_rs_cleanup/mr_ar_clean_conf/mr_ar_cleanup added
  • compiltaion warnings suppressed
  • Addition of mr_types (for boolean with typedef)
  • struct mr_rs_conf added
  • help_screen removed (useless)
Location:
branches/stable/mondo/src
Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/common/libmondo-filelist.c

    r1259 r1264  
    13591359                "grep -Fv \"%s\" %s > %s.new 2> /dev/null", dir,
    13601360                g_skeleton_filelist, g_skeleton_filelist);
    1361 //    mr_msg(0, "fsm = %s", find_skeleton_marker);
    13621361        if (!system(find_skeleton_marker)) {
    13631362            percentage = (int) (skeleton_lino * 100 / g_skeleton_entries);
    13641363            skeleton_lino++;
    1365 //        mr_msg(5, "Found %s", dir);
    1366 //        mr_msg(2, "Incrementing skeleton_lino; now %ld/%ld (%d%%)", skeleton_lino, g_skeleton_entries, percentage);
    13671364            sprintf(find_skeleton_marker, "mv -f %s.new %s",
    13681365                    g_skeleton_filelist, g_skeleton_filelist);
    1369 //        mr_msg(6, "fsm = %s", find_skeleton_marker);
    13701366            run_program_and_log_output(find_skeleton_marker, 8);
    13711367            time(&this_time);
     
    13861382    depth++;
    13871383
    1388 //  mr_msg(0, "Cataloguing %s", dir);
    13891384    if (sth[0] == ' ') {
    13901385        skip_these = sth;
     
    14281423                                counter = 0;
    14291424                                uberctr++;
     1425#ifndef _XWIN
    14301426                                mr_asprintf(&strtmp, " %c ",
    14311427                                        special_dot_char(uberctr));
    1432 #ifndef _XWIN
    14331428                                if (!g_text_mode) {
    14341429                                    newtDrawRootText(77, g_noof_rows - 3,
    14351430                                                     strtmp);
    1436                                     mr_free(strtmp);
    14371431                                    newtRefresh();
    14381432                                }
     1433                                mr_free(strtmp);
    14391434#endif
    14401435                            }
  • branches/stable/mondo/src/common/newt-specific.c

    r1251 r1264  
    2121#include "mr_msg.h"
    2222#include "mr_str.h"
     23#include "mr_err.h"
    2324
    2425#include "mondostructures.h"
     
    398399    printf("Type 'less %s' to see the output log\n", MONDO_LOGFILE);
    399400    free_libmondo_global_strings();
    400     exit(signal_code);
     401    mr_exit(signal_code, "Execution run ended");
    401402}
    402403
  • branches/stable/mondo/src/include/mr_conf.h

    r1256 r1264  
    7979};
    8080
     81/* mondorestore structure storing conf info
     82 * each field of the configuration file should have an entry here
     83 */
     84struct mr_rs_conf {
     85    /* Default media size */
     86    int media_size;
     87    /* Default device of media */
     88    char *media_device;
     89    /* Is the CD tray manual ? */
     90    bool manual_tray;
     91    /* Default log level */
     92    int log_level;
     93    /* default prefix for ISO names */
     94    char *prefix;
     95    /* External tape blocksize */
     96    int external_tape_blocksize;
     97    /* Internal tape blocksize */
     98    int internal_tape_blocksize;
     99    /* Size in MB of the slices for biggiefiles */
     100    int slice_size;
     101    /* Boot loader to use */
     102    char *boot_loader;
     103    /* Differential backup ? */
     104    bool differential;
     105    /* Default compression tool */
     106    char *compression_tool;
     107    /* Which mode should be activated by default*/
     108    char *ui_mode;
     109    /* Activate automatic restore ? */
     110    bool automatic_restore;
     111    /* Images creation dir */
     112    char *images_dir;
     113};
     114
    81115/* functions (public methods) */
    82116
  • branches/stable/mondo/src/include/my-stuff.h

    r1166 r1264  
    3232#include "mr_mem.h"
    3333#include "mr_msg.h"
    34 
    35 #if !defined(bool) && !defined(__cplusplus)
    36 /**
    37  * Create the illusion of a Boolean type.
    38  */
    39 #define bool unsigned char
    40 #define TRUE 1
    41 #define FALSE 0
    42 #endif
     34#include "mr_types.h"
    4335
    4436#ifdef HAVE_CONFIG_H
  • branches/stable/mondo/src/lib/mr_conf.c

    r1256 r1264  
    1717#include <string.h>
    1818
     19#include "mr_types.h"
    1920#include "mr_msg.h"
    2021#include "mr_mem.h"
     
    278279
    279280/*removes all comments from the buffer*/
    280 static void mr_conf_remove_comments() {
     281static void mr_conf_remove_comments(void) {
    281282    char *tmp_buf;              /*temporary buffer without comments */
    282283    size_t length               /*initial length */ ;
  • branches/stable/mondo/src/lib/mr_err.c

    r1256 r1264  
    1919#include "mr_msg.h"
    2020
    21 /* This should be a pointer to func setup by the main function */
    22     /* Highly incomplete function for the moment */
    23 static void mr_cleanup(void) {
    24         /* We have to free all allocated memory */
    25         /* We have to remove all temporary files */
    26         /* We have to unmount what has been mounted */
    27         /* We have to properly end newt */
    28         /* We have to remind people of log files */
    29         mr_msg_close();
    30 }
     21/* Pointer to the right cleanup function provided by each main */
     22extern void *mr_cleanup(void);
    3123
    3224/*
  • branches/stable/mondo/src/mondoarchive/mondo-cli-EXT.h

    r1164 r1264  
    1111                                               flag_val[128][MAX_STR_LEN],
    1212                                               bool flag_set[128]);
    13 extern void help_screen(void);
    1413extern void terminate_daemon(int sig);
    1514extern void set_signals(int on);
  • branches/stable/mondo/src/mondoarchive/mondo-cli.c

    r1191 r1264  
    964964
    965965/**
    966  * Print a not-so-helpful help message and exit.
    967  */
    968 void help_screen(void)
    969 {
    970     mr_msg(1, "Type 'man mondo-archive' for more information\n");
    971     exit(1);
    972 }
    973 
    974 
    975 /**
    976966 * Terminate Mondo in response to a signal.
    977967 * @param sig The signal number received.
  • branches/stable/mondo/src/mondoarchive/mondo-cli.h

    r128 r1264  
    1111                                        char flag_val[128][MAX_STR_LEN],
    1212                                        bool flag_set[128]);
    13 void help_screen();
    1413void terminate_daemon(int sig);
    1514void set_signals(int on);
  • branches/stable/mondo/src/mondoarchive/mondoarchive.c

    r1256 r1264  
    2727#include "mr_msg.h"
    2828#include "mr_file.h"
     29#include "mr_err.h"
    2930#include "mr_conf.h"
    3031
     
    127128
    128129/* create the mr_ar_conf structure from mondo's conf file */
    129 static void mr_ar_store_conf(struct mr_ar_conf *mr_conf) {
     130static void mr_ar_store_conf(struct mr_ar_conf *mr_cnf) {
    130131   
    131     mr_asprintf(mr_conf->iso_creation_cmd, mr_conf_sread("mondo_iso_creation_cmd"));
    132     mr_asprintf(mr_conf->iso_creation_options, mr_conf_sread("mondo_iso_creation_options"));
    133     mr_asprintf(mr_conf->iso_burning_cmd, mr_conf_sread("mondo_iso_burning_cmd"));
    134     mr_asprintf(mr_conf->iso_burning_options, mr_conf_sread("mondo_iso_burning_options"));
    135     iso_burning_speed = mr_conf_iread("mondo_iso_burning_speed");
    136     media_size = mr_conf_iread("mondo_media_size");
    137     mr_asprintf(mr_conf->media_device, mr_conf_sread("mondo_media_device"));
    138     manual_tray = mr_conf_bread("mondo_manual_tray");
    139     log_level = mr_conf_iread("mondo_log_level");
    140     mr_asprintf(mr_conf->prefix, mr_conf_sread("mondo_prefix"));
    141     external_tape_blocksize = mr_conf_iread("mondo_external_tape_blocksize");
    142     internal_tape_blocksize = mr_conf_iread("mondo_internal_tape_blocksize");
    143     slice_size = mr_conf_iread("mondo_slice_size");
    144     mr_asprintf(mr_conf->deplist_file, mr_conf_sread("mondo_deplist_file"));
    145     write_boot_floppy = mr_conf_bread("mondo_write_boot_floppy");
    146     create_mindi_cd = mr_conf_bread("mondo_create_mindi_cd");
    147     mr_asprintf(mr_conf->kernel, mr_conf_sread("mondo_kernel"));
    148     mr_asprintf(mr_conf->additional_modules, mr_conf_sread("mondo_additional_modules"));
    149     mr_asprintf(mr_conf->boot_loader, mr_conf_sread("mondo_boot_loader"));
    150     differential = mr_conf_bread("mondo_differential");
    151     mr_asprintf(mr_conf->compression_tool, mr_conf_sread("mondo_compression_tool"));
    152     compression_level = mr_conf_iread("mondo_compression_level");
    153     mr_asprintf(mr_conf->exclude_paths, mr_conf_sread("mondo_exclude_paths"));
    154     mr_asprintf(mr_conf->include_paths, mr_conf_sread("mondo_include_paths"));
    155     mr_asprintf(mr_conf->ui_mode, mr_conf_sread("mondo_ui_mode"));
    156     automatic_restore = mr_conf_bread("mondo_automatic_restore");
    157     mr_asprintf(mr_conf->scratch_dir, mr_conf_sread("mondo_scratch_dir"));
    158     mr_asprintf(mr_conf->tmp_dir, mr_conf_sread("mondo_tmp_dir"));
    159     mr_asprintf(mr_conf->images_dir, mr_conf_sread("mondo_images_dir"));
     132    mr_asprintf(&mr_cnf->iso_creation_cmd, mr_conf_sread("mondo_iso_creation_cmd"));
     133    mr_asprintf(&mr_cnf->iso_creation_options, mr_conf_sread("mondo_iso_creation_options"));
     134    mr_asprintf(&mr_cnf->iso_burning_cmd, mr_conf_sread("mondo_iso_burning_cmd"));
     135    mr_asprintf(&mr_cnf->iso_burning_options, mr_conf_sread("mondo_iso_burning_options"));
     136    mr_cnf->iso_burning_speed = mr_conf_iread("mondo_iso_burning_speed");
     137    mr_cnf->media_size = mr_conf_iread("mondo_media_size");
     138    mr_asprintf(&mr_cnf->media_device, mr_conf_sread("mondo_media_device"));
     139    mr_cnf->manual_tray = mr_conf_bread("mondo_manual_tray");
     140    mr_cnf->log_level = mr_conf_iread("mondo_log_level");
     141    mr_asprintf(&mr_cnf->prefix, mr_conf_sread("mondo_prefix"));
     142    mr_cnf->external_tape_blocksize = mr_conf_iread("mondo_external_tape_blocksize");
     143    mr_cnf->internal_tape_blocksize = mr_conf_iread("mondo_internal_tape_blocksize");
     144    mr_cnf->slice_size = mr_conf_iread("mondo_slice_size");
     145    mr_asprintf(&mr_cnf->deplist_file, mr_conf_sread("mondo_deplist_file"));
     146    mr_cnf->write_boot_floppy = mr_conf_bread("mondo_write_boot_floppy");
     147    mr_cnf->create_mindi_cd = mr_conf_bread("mondo_create_mindi_cd");
     148    mr_asprintf(&mr_cnf->kernel, mr_conf_sread("mondo_kernel"));
     149    mr_asprintf(&mr_cnf->additional_modules, mr_conf_sread("mondo_additional_modules"));
     150    mr_asprintf(&mr_cnf->boot_loader, mr_conf_sread("mondo_boot_loader"));
     151    mr_cnf->differential = mr_conf_bread("mondo_differential");
     152    mr_asprintf(&mr_cnf->compression_tool, mr_conf_sread("mondo_compression_tool"));
     153    mr_cnf->compression_level = mr_conf_iread("mondo_compression_level");
     154    mr_asprintf(&mr_cnf->exclude_paths, mr_conf_sread("mondo_exclude_paths"));
     155    mr_asprintf(&mr_cnf->include_paths, mr_conf_sread("mondo_include_paths"));
     156    mr_asprintf(&mr_cnf->ui_mode, mr_conf_sread("mondo_ui_mode"));
     157    mr_cnf->automatic_restore = mr_conf_bread("mondo_automatic_restore");
     158    mr_asprintf(&mr_cnf->scratch_dir, mr_conf_sread("mondo_scratch_dir"));
     159    mr_asprintf(&mr_cnf->tmp_dir, mr_conf_sread("mondo_tmp_dir"));
     160    mr_asprintf(&mr_cnf->images_dir, mr_conf_sread("mondo_images_dir"));
     161    mr_msg(5, "Directory for images is %s", mr_cnf->images_dir);
     162}
     163
     164/* destroy the mr_ar_conf structure's content */
     165static void mr_ar_clean_conf(struct mr_ar_conf *mr_cnf) {
     166   
     167    if (mr_cnf == NULL) {
     168        return;
     169    }
     170    mr_free(mr_cnf->iso_creation_cmd);
     171    mr_free(mr_cnf->iso_creation_options);
     172    mr_free(mr_cnf->iso_burning_cmd);
     173    mr_free(mr_cnf->iso_burning_options);
     174    mr_free(mr_cnf->media_device);
     175    mr_free(mr_cnf->prefix);
     176    mr_free(mr_cnf->deplist_file);
     177    mr_free(mr_cnf->kernel);
     178    mr_free(mr_cnf->additional_modules);
     179    mr_free(mr_cnf->boot_loader);
     180    mr_free(mr_cnf->compression_tool);
     181    mr_free(mr_cnf->exclude_paths);
     182    mr_free(mr_cnf->include_paths);
     183    mr_free(mr_cnf->ui_mode);
     184    mr_free(mr_cnf->scratch_dir);
     185    mr_free(mr_cnf->tmp_dir);
     186    mr_free(mr_cnf->images_dir);
     187}
     188
     189/* Create the pointer to the function called in mr_exit */
     190void (*mr_cleanup)(void) = NULL;
     191
     192/* Cleanup all memory allocated in various structures */
     193void mr_ar_cleanup(void) {
     194    /* Highly incomplete function for the moment */
     195    /* We have to free all allocated memory */
     196    mr_ar_clean_conf(&mr_conf);
     197    /* We have to remove all temporary files */
     198    /* We have to unmount what has been mounted */
     199    /* We have to properly end newt */
     200    /* We have to remind people of log files */
     201
     202    mr_msg_close();
    160203}
    161204
     
    184227    printf(_("Initializing..."));
    185228
     229    /* Reference the right cleanup function for mr_exit */
     230    mr_cleanup = mr_ar_cleanup;
     231
    186232    /* initialize log file with time stamp */
    187233    /* We start with a loglevel of 4 - Adapted later on */
     
    484530    } else {
    485531        printf(_("See %s for details of backup run.\n"), MONDO_LOGFILE);
    486         exit(retval);
     532        mr_exit(retval, NULL);
    487533    }
    488534
  • branches/stable/mondo/src/mondorestore/mondo-prep.c

    r1252 r1264  
    520520  /** buffers ***********************************************************/
    521521  char *devices = NULL;
    522   char *strtmp  = NULL;
    523522  char *level   = NULL;
    524523  char *program = NULL;
     
    624623    char *program2 = NULL;
    625624    char *tmp = NULL;
    626     char *tmp1 = NULL;
    627625#ifdef __FreeBSD__
    628626    char *line = NULL;
     
    13891387    char *format = NULL;
    13901388    char *tmp = NULL;
    1391     char *tmp1 = NULL;
    13921389
    13931390    /** end *************************************************************/
  • branches/stable/mondo/src/mondorestore/mondorestore.c

    r1251 r1264  
    1919#include "mr_msg.h"
    2020#include "mr_str.h"
     21#include "mr_err.h"
    2122
    2223#include "mondostructures.h"
     
    129130extern int copy_from_src_to_dest(FILE * f_orig, FILE * f_archived,
    130131                                 char direction);
     132
     133struct mr_rs_conf mr_conf;
     134
     135/* destroy the mr_rs_conf structure's content */
     136static void mr_rs_clean_conf(struct mr_rs_conf *mr_cnf) {
     137   
     138    if (mr_cnf == NULL) {
     139        return;
     140    }
     141    mr_free(&mr_cnf->media_device);
     142    mr_free(&mr_cnf->prefix);
     143    mr_free(&mr_cnf->boot_loader);
     144    mr_free(&mr_cnf->compression_tool);
     145    mr_free(&mr_cnf->ui_mode);
     146    mr_free(&mr_cnf->images_dir);
     147}
     148
     149/* Create the pointer to the function called in mr_exit */
     150void (*mr_cleanup)(void) = NULL;
     151
     152/* Cleanup all memory allocated in various structures */
     153void mr_rs_cleanup(void) {
     154    /* Highly incomplete function for the moment */
     155    /* We have to free all allocated memory */
     156        /* Not allocated yet
     157    mr_rs_clean_conf(&mr_conf);
     158    */
     159    /* We have to remove all temporary files */
     160    /* We have to unmount what has been mounted */
     161    /* We have to properly end newt */
     162    /* We have to remind people of log files */
     163
     164    mr_msg_close();
     165}
    131166
    132167/**************************************************************************
     
    954989    int res = 0;
    955990    int old_loglevel;
    956     char *sz_msg = NULL;
    957991    struct s_node *node = NULL;
    958992
     
    17101744
    17111745  /** malloc add ***/
    1712     char *tmp = NULL;
    17131746    char *command = NULL;
    17141747    char *afio_fname = NULL;
     
    27542787#endif
    27552788
     2789    /* Reference the right cleanup function for mr_exit */
     2790    mr_cleanup = mr_rs_cleanup;
     2791
    27562792    if (getuid() != 0) {
    27572793        fprintf(stderr, _("Please run as root.\n"));
    2758         exit(127);
     2794        mr_exit(127, NULL);
    27592795    }
    27602796
     
    32053241    unlink("/tmp/filelist.full.gz");
    32063242
    3207     exit(retval);
     3243    mr_exit(retval, NULL);
    32083244}
    32093245
Note: See TracChangeset for help on using the changeset viewer.