Ignore:
Timestamp:
Aug 18, 2009, 3:05:43 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3334@localhost: bruno | 2009-08-08 12:17:37 +0200

  • Change mr_asprintf interface to pass only the char * (makes bkpinfo usage more easy)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/common/libmondo-string.c

    r2322 r2323  
    4545    assert(partno >= 0);
    4646
    47     mr_asprintf(&partition, drive);
     47    mr_asprintf(partition, drive);
    4848    /* is this a devfs device path? */
    4949    c = strrchr(partition, '/');
     
    241241        fatal_error("Integer overflow.");
    242242    } else if (ch != 'm' && ch != 'M') {
    243         mr_asprintf(&tmp1, "Re: parameter '%s' - bad multiplier ('%c')", incoming, ch);
     243        mr_asprintf(tmp1, "Re: parameter '%s' - bad multiplier ('%c')", incoming, ch);
    244244        fatal_error(tmp1);
    245245    }
     
    420420        p = ' ';
    421421    }
    422     mr_asprintf(&output, "%d %s disk%c", noof_disks, label, p);
     422    mr_asprintf(output, "%d %s disk%c", noof_disks, label, p);
    423423    while (strlen(output) < 14) {
    424424        mr_strcat(output, " ");
     
    511511            mr_strcat(output, "%s%s", q, value);
    512512        } else {
    513             mr_asprintf(&output, "%s%s", q, value);
     513            mr_asprintf(output, "%s%s", q, value);
    514514        }
    515515        p+= strlen(token);
     
    520520    } else {
    521521        /* just in case the token doesn't appear in string at all */
    522         mr_asprintf(&output, "%s", q);
     522        mr_asprintf(output, "%s", q);
    523523    }
    524524    return(output);
     
    555555    assert_string_is_neither_NULL_nor_zerolength(path);
    556556    if (s[0] != '\0') {
    557         mr_asprintf(&suffix, ".%s", s);
     557        mr_asprintf(suffix, ".%s", s);
    558558    } else {
    559         mr_asprintf(&suffix, "");
     559        mr_asprintf(suffix, "");
    560560    }
    561561    sprintf(output, "%s/slice-%07ld.%05ld.dat%s", path, bigfileno, sliceno, suffix);
     
    622622    if (strlen(flaws_str) > 0) {
    623623        paranoid_free(flaws_str_A);
    624         mr_asprintf(&flaws_str_A, "%s", flaws_str + 1);
     624        mr_asprintf(flaws_str_A, "%s", flaws_str + 1);
    625625    }
    626626    if (strlen(flaws_str_A) >= 74) {
    627627        for (i = 74; flaws_str_A[i] != ' '; i--);
    628628        paranoid_free(flaws_str_B);
    629         mr_asprintf(&flaws_str_B, "%s", flaws_str_A + i + 1);
     629        mr_asprintf(flaws_str_B, "%s", flaws_str_A + i + 1);
    630630        flaws_str_A[i] = '\0';
    631631    }
     
    633633        for (i = 74; flaws_str_B[i] != ' '; i--);
    634634        paranoid_free(flaws_str_C);
    635         mr_asprintf(&flaws_str_C, "%s", flaws_str_B + i + 1);
     635        mr_asprintf(flaws_str_C, "%s", flaws_str_B + i + 1);
    636636        flaws_str_B[i] = '\0';
    637637    }
     
    830830
    831831    assert_string_is_neither_NULL_nor_zerolength(partition);
    832     mr_asprintf(&trunc, "%s", partition);
     832    mr_asprintf(trunc, "%s", partition);
    833833
    834834#ifdef __FreeBSD__
     
    931931    assert_string_is_neither_NULL_nor_zerolength(fn);
    932932    if (!strncmp(fn, MNT_RESTORING, strlen(MNT_RESTORING))) {
    933         mr_asprintf(&filename, "%s", fn + strlen(MNT_RESTORING));
     933        mr_asprintf(filename, "%s", fn + strlen(MNT_RESTORING));
    934934    } else if (fn[0] != '/') {
    935         mr_asprintf(&filename, "/%s", fn);
     935        mr_asprintf(filename, "/%s", fn);
    936936    } else {
    937         mr_asprintf(&filename, "%s", fn);
     937        mr_asprintf(filename, "%s", fn);
    938938    }
    939939
    940940    sev = 3;
    941     mr_asprintf(&reason, "Changed since backup. Consider running a differential backup in a day or two.");
     941    mr_asprintf(reason, "Changed since backup. Consider running a differential backup in a day or two.");
    942942
    943943    if (!strncmp(filename, "/var/", 5)) {
    944944        sev = 2;
    945945        mr_free(reason);
    946         mr_asprintf(&reason, "/var's contents will change regularly, inevitably.");
     946        mr_asprintf(reason, "/var's contents will change regularly, inevitably.");
    947947    }
    948948    if (!strncmp(filename, "/home", 5)) {
    949949        sev = 2;
    950950        mr_free(reason);
    951         mr_asprintf(&reason, "It's in your /home directory. Therefore, it is important.");
     951        mr_asprintf(reason, "It's in your /home directory. Therefore, it is important.");
    952952    }
    953953    if (!strncmp(filename, "/usr/", 5)) {
    954954        sev = 3;
    955955        mr_free(reason);
    956         mr_asprintf(&reason, "You may have installed/removed software during the backup.");
     956        mr_asprintf(reason, "You may have installed/removed software during the backup.");
    957957    }
    958958    if (!strncmp(filename, "/etc/", 5)) {
    959959        sev = 3;
    960960        mr_free(reason);
    961         mr_asprintf(&reason, "Do not edit config files while backing up your PC.");
     961        mr_asprintf(reason, "Do not edit config files while backing up your PC.");
    962962    }
    963963    if (!strcmp(filename, "/etc/adjtime")
     
    965965        sev = 1;
    966966        mr_free(reason);
    967         mr_asprintf(&reason, "This file changes all the time. It's OK.");
     967        mr_asprintf(reason, "This file changes all the time. It's OK.");
    968968    }
    969969    if (!strncmp(filename, "/root/", 6)) {
    970970        sev = 3;
    971971        mr_free(reason);
    972         mr_asprintf(&reason, "Were you compiling/editing something in /root?");
     972        mr_asprintf(reason, "Were you compiling/editing something in /root?");
    973973    }
    974974    if (!strncmp(filename, "/root/.", 7)) {
    975975        sev = 2;
    976976        mr_free(reason);
    977         mr_asprintf(&reason, "Temp or 'dot' files changed in /root.");
     977        mr_asprintf(reason, "Temp or 'dot' files changed in /root.");
    978978    }
    979979    if (!strncmp(filename, "/var/lib/", 9)) {
    980980        sev = 2;
    981981        mr_free(reason);
    982         mr_asprintf(&reason, "Did you add/remove software during backing?");
     982        mr_asprintf(reason, "Did you add/remove software during backing?");
    983983    }
    984984    if (!strncmp(filename, "/var/lib/rpm", 12)) {
    985985        sev = 3;
    986986        mr_free(reason);
    987         mr_asprintf(&reason, "Did you add/remove software during backing?");
     987        mr_asprintf(reason, "Did you add/remove software during backing?");
    988988    }
    989989    if (!strncmp(filename, "/var/lib/slocate", 16)) {
    990990        sev = 1;
    991991        mr_free(reason);
    992         mr_asprintf(&reason, "The 'update' daemon ran during backup. This does not affect the integrity of your backup.");
     992        mr_asprintf(reason, "The 'update' daemon ran during backup. This does not affect the integrity of your backup.");
    993993    }
    994994    if (!strncmp(filename, "/var/log/", 9)
     
    997997        sev = 1;
    998998        mr_free(reason);
    999         mr_asprintf(&reason, "Log files change frequently as the computer runs. Fret not.");
     999        mr_asprintf(reason, "Log files change frequently as the computer runs. Fret not.");
    10001000    }
    10011001    if (!strncmp(filename, "/var/spool", 10)) {
    10021002        sev = 1;
    10031003        mr_free(reason);
    1004         mr_asprintf(&reason, "Background processes or printers were active. This does not affect the integrity of your backup.");
     1004        mr_asprintf(reason, "Background processes or printers were active. This does not affect the integrity of your backup.");
    10051005    }
    10061006    if (!strncmp(filename, "/var/spool/mail", 10)) {
    10071007        sev = 2;
    10081008        mr_free(reason);
    1009         mr_asprintf(&reason, "Mail was sent/received during backup.");
     1009        mr_asprintf(reason, "Mail was sent/received during backup.");
    10101010    }
    10111011    if (filename[strlen(filename) - 1] == '~') {
    10121012        sev = 1;
    10131013        mr_free(reason);
    1014         mr_asprintf(&reason, "Backup copy of another file which was modified recently.");
     1014        mr_asprintf(reason, "Backup copy of another file which was modified recently.");
    10151015    }
    10161016    if (strstr(filename, "cache")) {
    10171017        sev = 1;
    10181018        mr_free(reason);
    1019         mr_asprintf(&reason, "Part of a cache of data. Caches change from time to time. Don't worry.");
     1019        mr_asprintf(reason, "Part of a cache of data. Caches change from time to time. Don't worry.");
    10201020    }
    10211021    if (!strncmp(filename, "/var/run/", 9)
     
    10251025        sev = 1;
    10261026        mr_free(reason);
    1027         mr_asprintf(&reason, "Temporary file (a lockfile, perhaps) used by software such as X or KDE to register its presence.");
     1027        mr_asprintf(reason, "Temporary file (a lockfile, perhaps) used by software such as X or KDE to register its presence.");
    10281028    }
    10291029    if (out_reason) {
     
    10881088
    10891089    if (bkpinfo->media_size[g_current_media_number] <= 0) {
    1090         mr_asprintf(&tmp, "%lld", g_tape_posK);
    1091         mr_asprintf(&pos_w_commas, "%s", commarize(tmp));
     1090        mr_asprintf(tmp, "%lld", g_tape_posK);
     1091        mr_asprintf(pos_w_commas, "%s", commarize(tmp));
    10921092        mr_free(tmp);
    1093         mr_asprintf(&outstr, "Volume %d: %s kilobytes archived so far", g_current_media_number, pos_w_commas);
     1093        mr_asprintf(outstr, "Volume %d: %s kilobytes archived so far", g_current_media_number, pos_w_commas);
    10941094        mr_free(pos_w_commas);
    10951095        return (outstr);
     
    11041104            percentage = 100;
    11051105        }
    1106         mr_asprintf(&outstr, "Volume %d: [", g_current_media_number);
     1106        mr_asprintf(outstr, "Volume %d: [", g_current_media_number);
    11071107    } else {
    11081108        percentage =
     
    11101110                   bkpinfo->media_size[g_current_media_number]);
    11111111        mds = media_descriptor_string(bkpinfo->backup_media_type);
    1112         mr_asprintf(&outstr, "%s %d: [", mds, g_current_media_number);
     1112        mr_asprintf(outstr, "%s %d: [", mds, g_current_media_number);
    11131113        mr_free(mds);
    11141114    }
     
    11361136    switch (type_of_bkp) {
    11371137    case dvd:
    1138         mr_asprintf(&type_of_backup, "DVD");
     1138        mr_asprintf(type_of_backup, "DVD");
    11391139        break;
    11401140    case cdr:
    1141         mr_asprintf(&type_of_backup, "CDR");
     1141        mr_asprintf(type_of_backup, "CDR");
    11421142        break;
    11431143    case cdrw:
    1144         mr_asprintf(&type_of_backup, "CDRW");
     1144        mr_asprintf(type_of_backup, "CDRW");
    11451145        break;
    11461146    case tape:
    1147         mr_asprintf(&type_of_backup, "tape");
     1147        mr_asprintf(type_of_backup, "tape");
    11481148        break;
    11491149    case cdstream:
    1150         mr_asprintf(&type_of_backup, "CDR");
     1150        mr_asprintf(type_of_backup, "CDR");
    11511151        break;
    11521152    case udev:
    1153         mr_asprintf(&type_of_backup, "udev");
     1153        mr_asprintf(type_of_backup, "udev");
    11541154        break;
    11551155    case iso:
    1156         mr_asprintf(&type_of_backup, "ISO");
     1156        mr_asprintf(type_of_backup, "ISO");
    11571157        break;
    11581158    case nfs:
    1159         mr_asprintf(&type_of_backup, "nfs");
     1159        mr_asprintf(type_of_backup, "nfs");
    11601160        break;
    11611161    case usb:
    1162         mr_asprintf(&type_of_backup, "USB");
     1162        mr_asprintf(type_of_backup, "USB");
    11631163        break;
    11641164    default:
    1165         mr_asprintf(&type_of_backup, "ISO");
     1165        mr_asprintf(type_of_backup, "ISO");
    11661166    }
    11671167    return (type_of_backup);
Note: See TracChangeset for help on using the changeset viewer.