Changeset 1422


Ignore:
Timestamp:
May 9, 2007, 11:02:24 AM (12 years ago)
Author:
bruno
Message:

mr_conf now handles # inside strings correctly (before they were considered as a comment which they are not !)

Location:
branches/stable/mondo/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/include/mr_conf.h

    r1264 r1422  
    1414#ifndef MR_CONF_H
    1515#define MR_CONF_H
     16
     17#include "mr_types.h"
    1618
    1719/* mondoarchive structure storing conf info
  • branches/stable/mondo/src/lib/mr_conf.c

    r1264 r1422  
    6767/*"private" members declarations*/
    6868static size_t mr_conf_filesize(const char *name);
    69 static void mr_conf_error_msg(int error_code, const char *add_line);
     69#define mr_conf_error_msg(x, y) {mr_conf_error_msg_int(x, y, __LINE__,__FILE__);}
     70static void mr_conf_error_msg_int(int error_code, const char *add_line, int line, const char *file);
    7071static void mr_conf_remove_comments(void);
    7172static int mr_conf_check_int_flag(const int flag);
     
    284285    size_t i;                   /*iterator */
    285286    size_t k;                   /*conditioned iterator for tmp_buffer */
     287    bool found_quote = FALSE;
    286288
    287289    length = strlen(buffer);
     
    291293    i = 0;
    292294    while (i < length) {
    293         if (buffer[i] != MRCONF_COMM_CHAR) {
     295        /* Handle quotes */
     296        if (buffer[i] = '"') {
     297            if (found_quote) {
     298                found_quote = FALSE;
     299            } else {
     300                found_quote = TRUE;
     301            }
     302        if ((buffer[i] != MRCONF_COMM_CHAR) && (! found_quote)){
    294303            k++;
    295304            i++;
     
    306315    i = 0;
    307316    while (i < length) {
    308         if (buffer[i] != MRCONF_COMM_CHAR) {
     317        if (buffer[i] = '"') {
     318            if (found_quote) {
     319                found_quote = FALSE;
     320            } else {
     321                found_quote = TRUE;
     322            }
     323        if ((buffer[i] != MRCONF_COMM_CHAR) && (! found_quote)){
    309324            tmp_buf[k++] = buffer[i++];
    310325        } else {
     
    352367
    353368/*output error message*/
    354 static void mr_conf_error_msg(int error_code, const char *add_line) {
     369static void mr_conf_error_msg_int(int error_code, const char *add_line, int line, const char *file) {
    355370    if ((mr_conf_flags & MRCONF_FLAG_VERBOSE)) {    /*if verbose mode */
    356371        switch (error_code) {
    357372        case MRCONF_BAD_FILE:
    358             mr_msg(0,"%s %s %s\n", MRCONF_STR_ERROR, MRCONF_STR_BAD_FILE,
     373            mr_msg_int(0,line,file,"%s %s %s\n", MRCONF_STR_ERROR, MRCONF_STR_BAD_FILE,
    359374                   add_line);
    360375            break;
    361376
    362377        case MRCONF_READING_FAILED:
    363             mr_msg(0,"%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_READING_FAILED);
     378            mr_msg_int(0,line,file,"%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_READING_FAILED);
    364379            break;
    365380
    366381        case MRCONF_FIELD_NOT_FOUND:
    367             mr_msg(0,"%s %s \"%s\"\n", MRCONF_STR_ERROR, MRCONF_STR_FIELD_NOT_FOUND, add_line);
    368             mr_msg(0,"%s %s\n", MRCONF_STR_WARNING, MRCONF_STR_SET_TO_ZERO);
     382            mr_msg_int(0,line,file,"%s %s \"%s\"\n", MRCONF_STR_ERROR, MRCONF_STR_FIELD_NOT_FOUND, add_line);
     383            mr_msg_int(0,line,file,"%s %s\n", MRCONF_STR_WARNING, MRCONF_STR_SET_TO_ZERO);
    369384            break;
    370385
    371386        case MRCONF_FIELD_NO_VALUE:
    372             mr_msg(0,"%s %s \"%s\"\n", MRCONF_STR_ERROR, MRCONF_STR_FIELD_NO_VALUE, add_line);
    373             mr_msg(0,"%s %s\n", MRCONF_STR_WARNING, MRCONF_STR_IGNORE);
     387            mr_msg_int(0,line,file,"%s %s \"%s\"\n", MRCONF_STR_ERROR, MRCONF_STR_FIELD_NO_VALUE, add_line);
     388            mr_msg_int(0,line,file,"%s %s\n", MRCONF_STR_WARNING, MRCONF_STR_IGNORE);
    374389            break;
    375390
    376391        case MRCONF_CLOSE_BUT_NOT_OPEN:
    377             mr_msg(0,"%s %s\n", MRCONF_STR_WARNING, MRCONF_STR_CLOSE_BUT_NOT_OPEN);
     392            mr_msg_int(0,line,file,"%s %s\n", MRCONF_STR_WARNING, MRCONF_STR_CLOSE_BUT_NOT_OPEN);
    378393            break;
    379394
    380395        case MRCONF_CALL_BUT_NOT_OPEN:
    381             mr_msg(0,"%s %s\n", MRCONF_STR_WARNING, MRCONF_STR_CALL_BUT_NOT_OPEN);
     396            mr_msg_int(0,line,file,"%s %s\n", MRCONF_STR_WARNING, MRCONF_STR_CALL_BUT_NOT_OPEN);
    382397            break;
    383398
    384399        case MRCONF_OPEN_OPENED:
    385             mr_msg(0,"%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_OPEN_OPENED);
     400            mr_msg_int(0,line,file,"%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_OPEN_OPENED);
    386401            break;
    387402
    388403        case MRCONF_STRING_QUOTE:
    389             mr_msg(0,"%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_STRING_QUOTE);
     404            mr_msg_int(0,line,file,"%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_STRING_QUOTE);
    390405            break;
    391406
    392407        default:
    393             mr_msg(0,"%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_DEFAULT_ERROR);
    394             break;
    395         }
    396     }
    397 }
     408            mr_msg_int(0,line,file,"%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_DEFAULT_ERROR);
     409            break;
     410        }
     411    }
     412}
  • branches/stable/mondo/src/lib/mr_err.c

    r1390 r1422  
    2525void mr_exit(int errorcode, const char *message) {
    2626
    27     mr_cleanup();
     27    if (mr_cleanup != NULL) {
     28        mr_cleanup();
     29    }
    2830    if (message != NULL) {
    2931        fprintf(stderr,"%s\n",message);
  • branches/stable/mondo/src/mondoarchive/mondoarchive.c

    r1415 r1422  
    136136   
    137137    char *p = NULL;
    138 
    139     mr_asprintf(&p, mr_conf_sread("mondo_iso_creation_cmd"));
     138    char *s = NULL;
     139
     140    s = mr_conf_sread("mondo_iso_creation_cmd");
     141    fprintf(stderr,"s: %s\n",s);
     142    mr_asprintf(&p, s);
    140143    mr_cnf->iso_creation_cmd = p;
    141     mr_asprintf(&mr_cnf->iso_creation_options, mr_conf_sread("mondo_iso_creation_options"));
    142     mr_asprintf(&mr_cnf->iso_burning_cmd, mr_conf_sread("mondo_iso_burning_cmd"));
    143     mr_asprintf(&mr_cnf->iso_burning_options, mr_conf_sread("mondo_iso_burning_options"));
     144    p = NULL;
     145
     146    mr_asprintf(&p, mr_conf_sread("mondo_iso_creation_options"));
     147    mr_cnf->iso_creation_options = p;
     148    p = NULL;
     149
     150    mr_asprintf(&p, mr_conf_sread("mondo_iso_burning_cmd"));
     151    mr_cnf->iso_burning_cmd = p;
     152    p = NULL;
     153
     154    mr_asprintf(&p, mr_conf_sread("mondo_iso_burning_options"));
     155    mr_cnf->iso_burning_options = p;
     156    p = NULL;
     157
    144158    mr_cnf->iso_burning_speed = mr_conf_iread("mondo_iso_burning_speed");
    145159    mr_cnf->media_size = mr_conf_iread("mondo_media_size");
    146     mr_asprintf(&mr_cnf->media_device, mr_conf_sread("mondo_media_device"));
     160
     161    mr_asprintf(&p, mr_conf_sread("mondo_media_device"));
     162    mr_cnf->media_device = p;
     163    p = NULL;
     164
    147165    mr_cnf->manual_tray = mr_conf_bread("mondo_manual_tray");
    148166    mr_cnf->log_level = mr_conf_iread("mondo_log_level");
    149     mr_asprintf(&mr_cnf->prefix, mr_conf_sread("mondo_prefix"));
     167
     168    mr_asprintf(&p, mr_conf_sread("mondo_prefix"));
     169    mr_cnf->prefix = p;
     170    p = NULL;
     171
    150172    mr_cnf->external_tape_blocksize = mr_conf_iread("mondo_external_tape_blocksize");
    151173    mr_cnf->internal_tape_blocksize = mr_conf_iread("mondo_internal_tape_blocksize");
    152174    mr_cnf->slice_size = mr_conf_iread("mondo_slice_size");
    153     mr_asprintf(&mr_cnf->deplist_file, mr_conf_sread("mondo_deplist_file"));
     175
     176    mr_asprintf(&p, mr_conf_sread("mondo_deplist_file"));
     177    mr_cnf->deplist_file = p;
     178    p = NULL;
     179
    154180    mr_cnf->write_boot_floppy = mr_conf_bread("mondo_write_boot_floppy");
    155181    mr_cnf->create_mindi_cd = mr_conf_bread("mondo_create_mindi_cd");
    156     mr_asprintf(&mr_cnf->kernel, mr_conf_sread("mondo_kernel"));
    157     mr_asprintf(&mr_cnf->additional_modules, mr_conf_sread("mondo_additional_modules"));
    158     mr_asprintf(&mr_cnf->boot_loader, mr_conf_sread("mondo_boot_loader"));
     182
     183    mr_asprintf(&p, mr_conf_sread("mondo_kernel"));
     184    mr_cnf->kernel = p;
     185    p = NULL;
     186
     187    mr_asprintf(&p, mr_conf_sread("mondo_additional_modules"));
     188    mr_cnf->additional_modules = p;
     189    p = NULL;
     190
     191    mr_asprintf(&p, mr_conf_sread("mondo_boot_loader"));
     192    mr_cnf->boot_loader = p;
     193    p = NULL;
     194
    159195    mr_cnf->differential = mr_conf_bread("mondo_differential");
    160     mr_asprintf(&mr_cnf->compression_tool, mr_conf_sread("mondo_compression_tool"));
     196
     197    mr_asprintf(&p, mr_conf_sread("mondo_compression_tool"));
     198    mr_cnf->compression_tool = p;
     199    p = NULL;
     200
    161201    mr_cnf->compression_level = mr_conf_iread("mondo_compression_level");
    162     mr_asprintf(&mr_cnf->exclude_paths, mr_conf_sread("mondo_exclude_paths"));
    163     mr_asprintf(&mr_cnf->include_paths, mr_conf_sread("mondo_include_paths"));
    164     mr_asprintf(&mr_cnf->ui_mode, mr_conf_sread("mondo_ui_mode"));
     202
     203    mr_asprintf(&p, mr_conf_sread("mondo_exclude_paths"));
     204    mr_cnf->exclude_paths = p;
     205    p = NULL;
     206
     207    mr_asprintf(&p, mr_conf_sread("mondo_include_paths"));
     208    mr_cnf->include_paths = p;
     209    p = NULL;
     210
     211    mr_asprintf(&p, mr_conf_sread("mondo_ui_mode"));
     212    mr_cnf->ui_mode = p;
     213    p = NULL;
     214
    165215    mr_cnf->automatic_restore = mr_conf_bread("mondo_automatic_restore");
    166     mr_asprintf(&mr_cnf->scratch_dir, mr_conf_sread("mondo_scratch_dir"));
    167     mr_asprintf(&mr_cnf->tmp_dir, mr_conf_sread("mondo_tmp_dir"));
    168     mr_asprintf(&mr_cnf->images_dir, mr_conf_sread("mondo_images_dir"));
     216
     217    mr_asprintf(&p, mr_conf_sread("mondo_scratch_dir"));
     218    mr_cnf->scratch_dir = p;
     219    p = NULL;
     220
     221    mr_asprintf(&p, mr_conf_sread("mondo_tmp_dir"));
     222    mr_cnf->tmp_dir = p;
     223    p = NULL;
     224
     225    mr_asprintf(&p, mr_conf_sread("mondo_images_dir"));
     226    mr_cnf->images_dir = p;
     227    p = NULL;
    169228    mr_msg(5, "Directory for images is %s", mr_cnf->images_dir);
    170229}
Note: See TracChangeset for help on using the changeset viewer.