Changeset 1594 in MondoRescue for branches/stable/mondo/src/lib/mr_conf.c


Ignore:
Timestamp:
Aug 26, 2007, 12:26:06 PM (17 years ago)
Author:
Bruno Cornec
Message:

Use of conf file entries (iso_burning_*, media_device, media_size)
and adapatation of the rest of the code to that (including bkpinfo)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/lib/mr_conf.c

    r1584 r1594  
    192192
    193193/*read integer number after string str in the current file*/
    194 int mr_conf_iread(const char *field_name) {
     194char *mr_conf_iread(const char *field_name) {
    195195    char *p = NULL;             /*pointer to the field */
    196     int ret = 0;                /*return value */
     196    char *p1 = NULL;            /*return field */
    197197
    198198    p = mr_conf_read(field_name);
    199199    if (p != NULL) {
    200         ret = atoi(p);
    201         }
    202     return ret;
     200        mr_asprintf(&p1, "%d", p);
     201        }
     202    return p1;
    203203}
    204204
    205205/*read float/double number after string str in the current file*/
    206 double mr_conf_fread(const char *field_name) {
     206char *mr_conf_fread(const char *field_name) {
    207207    char *p = NULL;             /*pointer to the field */
    208     double ret = 0.0;               /*return value */
     208    char *p1 = NULL;            /*return field */
    209209
    210210    p = mr_conf_read(field_name);
    211211    if (p != NULL) {
    212         ret = atof(p);
    213     }
    214     return ret;
     212        mr_asprintf(&p1, "%f", p);
     213    }
     214    return p1;
    215215}
    216216
     
    265265
    266266/*read boolean after string str in the current file*/
    267 bool mr_conf_bread(const char *field_name) {
     267char *mr_conf_bread(const char *field_name) {
    268268    char *p = NULL;             /*pointer to the field */
    269     bool ret = FALSE;
     269    char *p1 = NULL;                /*pointer to the field */
    270270   
    271     p = mr_conf_sread(field_name);
     271    p = mr_conf_read(field_name);
    272272    if (p != NULL) {
    273273        /* match if yes/true/1 */
     
    275275            (strncasecmp(p, "t" , (size_t)1) == 0) ||
    276276            (strncasecmp(p, "1" , (size_t)1) == 0)) {
    277             ret = TRUE;
    278         }
    279     }
    280     return ret;
     277            mr_asprintf(&p1, "%d", TRUE);
     278        } else {
     279            mr_asprintf(&p1, "%d", FALSE);
     280        }
     281    }
     282    return p1;
     283}
     284
     285/* Convert a string with decimal value of TRUE/FALSE in boolean */
     286bool mr_atob(const char *str) {
     287    bool ret = FALSE;
     288    char *p = NULL;
     289
     290    mr_asprintf(&p, "%d", FALSE);
     291    if (strcmp(str,p) != 0) {
     292        ret = TRUE;
     293    }
     294    mr_free(p);
     295    return(ret);
    281296}
    282297
Note: See TracChangeset for help on using the changeset viewer.