Ignore:
Timestamp:
Mar 24, 2007, 1:48:55 AM (13 years ago)
Author:
Bruno Cornec
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)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.