Changeset 45 in MondoRescue for trunk/mondo/mondo/common/libmondo-string.c


Ignore:
Timestamp:
Oct 5, 2005, 12:51:47 AM (19 years ago)
Author:
bcornec
Message:

asprint and getline now added

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mondo/mondo/common/libmondo-string.c

    r44 r45  
    6666
    6767
    68 
    6968/**
    7069 * Pad a string on both sides so it appears centered.
     
    101100
    102101
    103 
    104 
    105102inline void turn_wildcard_chars_into_literal_chars(char *sout, char *sin)
    106103{
     
    114111    *q = *p;                    // for the final '\0'
    115112}
    116 
    117113
    118114
     
    127123    char *pos_w_commas;
    128124    static char output[MAX_STR_LEN];
    129     char tmp[MAX_STR_LEN];
     125    char *tmp;
    130126    int j;
    131127
    132128    assert(input != NULL);
    133129
    134     strcpy(tmp, input);
     130    asprintf(tmp, "%s", input);
    135131    if (strlen(tmp) > 6) {
    136132        asprintf(&pos_w_commas, "%s", tmp);
     
    151147    strcpy(output, pos_w_commas);
    152148    paranoid_free(pos_w_commas);
     149    paranoid_free(tmp);
    153150    return (output);
    154151}
     
    169166
    170167    /*@ buffers ********************************************************** */
    171     static char output[MAX_STR_LEN];
     168    char *output;
    172169
    173170    assert(disklist != NULL);
    174171
    175     sprintf(output, "%-24s %8d", disklist->el[lino].device,
    176             disklist->el[lino].index);
     172    asprintf(&output, "%-24s %8d", disklist->el[lino].device,
     173             disklist->el[lino].index);
    177174    return (output);
    178175}
    179 
    180 
    181 
    182176
    183177
     
    214208    outval = atol(tmp);
    215209    paranoid_free(tmp);
     210
    216211    if (ch == 'g' || ch == 'G') {
    217212        outval = outval * 1024;
     
    563558
    564559
    565 
    566 
    567560/**
    568561 * Wrap @p flaws_str across three lines. The first two are no more than 74 characters wide.
     
    614607    }
    615608}
    616 
    617609
    618610
     
    852844    char *output;
    853845
    854 
    855 
    856846    if (raid_level >= 0) {
    857847        asprintf(&output, " RAID %-2d ", raid_level);
Note: See TracChangeset for help on using the changeset viewer.