Ignore:
Timestamp:
Nov 5, 2016, 6:12:23 PM (7 years ago)
Author:
Bruno Cornec
Message:
  • Change interfaces for the call_program_and_get_last_line_of_output and where_is_root_mounted(now return dynamically allocated string)
  • removes useless function store_netfs_config
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mondo/src/common/libmondo-fork.c

    r3604 r3610  
    3535 * @param call The program to run.
    3636 * @return The last line of its output.
    37  * @note The returned value points to static storage that will be overwritten with each call.
     37 * @note The returned value points to storage that needs to be freed by the
     38 * caller
    3839 */
    3940char *call_program_and_get_last_line_of_output(char *call)
    4041{
    4142    /*@ buffers ***************************************************** */
    42     static char result[MAX_STR_LEN];
     43    char *result = NULL;
    4344    char *tmp = NULL;
    4445
     
    4647    FILE *fin = NULL;
    4748    char *eng_call = NULL;
    48 
    49     /*@ initialize data ********************************************* */
    50     result[0] = '\0';
    5149
    5250    /*@******************************************************************** */
     
    5755    if ((fin = popen(eng_call, "r"))) {
    5856        while (!feof(fin)) {
    59             mr_getline(tmp, fin);
    60             if (strlen(tmp) > 1) {
    61                 strcpy(result, tmp);
     57            mr_free(result);
     58            mr_getline(result, fin);
     59            if (strlen(result) > 1) {
    6260                log_msg(7, "result = '%s'", result);
    6361            }
    64             mr_free(tmp);
    6562        }
    6663        paranoid_pclose(fin);
     
    6966    }
    7067    mr_free(eng_call);
    71     strip_spaces(result);
     68    mr_strip_spaces(result);
    7269    log_msg(5, "cpaglloo returns '%s'", result);
    7370    return(result);
Note: See TracChangeset for help on using the changeset viewer.