Changeset 3294 in MondoRescue for branches/3.2/mondo/src/lib


Ignore:
Timestamp:
Jun 3, 2014, 8:20:52 AM (10 years ago)
Author:
Bruno Cornec
Message:
  • Fix a compilation issue in libmondo-archive.c on mindi call with lack of parameter
  • Fix compilation warnings in mr_mem.c
  • Adds function mr_str_substitute in mr_str (not yet used) and test code
Location:
branches/3.2/mondo/src/lib
Files:
3 edited

Legend:

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

    r3185 r3294  
    44 *
    55 * Based on the work done by Anton (c)2002-2004 Anton Kulchitsky  mailto:anton@kulchitsky.org
    6  * Code (c)2006 Bruno Cornec <bruno@mondorescue.org>
     6 * Code (c)2006-2014 Bruno Cornec <bruno@mondorescue.org>
    77 *   
    88 *     Main file of mr_conf : a very small and simple
     
    174174        p += strlen(field_name);
    175175        while ((*p != '\n') && (*p != '\0') && (*p != '=')) {
    176                 p++;
     176            p++;
    177177        }
    178178        if (*p != '=') {
  • branches/3.2/mondo/src/lib/mr_mem.c

    r3292 r3294  
    7777        /* free a variable which should be already free */
    7878        mr_msg_int(1,line,file,"mr_getline_ found a non freed variable here");
    79         mr_free_int(lineptr,line,file);
     79        mr_free_int((void **)lineptr,line,file);
    8080    }
    8181    ret = getline(lineptr,&n,fd);
     
    8686    /*  We reached end of file, allocating empty string */
    8787    if (ret == -1) {
    88         mr_free_int(lineptr,line,file);
     88        mr_free_int((void **)lineptr,line,file);
    8989        mr_asprintf_int(lineptr,line,file,"");
    9090    }
  • branches/3.2/mondo/src/lib/mr_str.c

    r3194 r3294  
    194194}
    195195
     196char *mr_str_substitute(const char *in, const char *token, const char *subst) {
     197
     198char *output = NULL;
     199char *tmp = NULL;
     200int i = 0;
     201
     202mr_asprintf(output, "%s", in);
     203tmp = strstr(output, token);
     204if (tmp == NULL) {
     205    // token not found returning initial string unmodified
     206    return(output);
     207}
     208// token found end string here for now
     209*tmp = '\0';
     210
     211// Add subst content to the string
     212mr_strcat(output,subst);
     213
     214// now add the rest of in
     215tmp = strstr(in, token);
     216for (; i < strlen(token) ; i++) {
     217    tmp++;
     218}
     219mr_strcat(output,tmp);
     220return(output);
     221}
     222
    196223
    197224/*
Note: See TracChangeset for help on using the changeset viewer.