Ignore:
Timestamp:
Sep 20, 2013, 2:29:57 PM (11 years ago)
Author:
Bruno Cornec
Message:

Simplify the interface of mr_getline and mr_asprintf. With 3.1 compatibility now will allow backports from this branch into 3.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/mondo/src/common/newt-specific.c

    r3154 r3185  
    296296char *tmp1 = NULL;
    297297
    298     mr_asprintf(&tmp,"ps %s | grep \" %s \" | grep -v \"grep\" | awk '{print %s;}'", ps_options, str , ps_proc_id);
     298    mr_asprintf(tmp,"ps %s | grep \" %s \" | grep -v \"grep\" | awk '{print %s;}'", ps_options, str , ps_proc_id);
    299299    run_program_and_log_output(tmp, TRUE);
    300300    if (strlen(tmp) > 0) {
    301         mr_asprintf(&tmp1,"kill `%s`", tmp);
     301        mr_asprintf(tmp1,"kill `%s`", tmp);
    302302        run_program_and_log_output(tmp1, TRUE);
    303303        paranoid_free(tmp1);
     
    434434        run_program_and_log_output("umount -d " MNT_CDROM, FALSE);
    435435        if (g_selfmounted_isodir) {
    436             mr_asprintf(&command, "umount -d %s", g_selfmounted_isodir);
     436            mr_asprintf(command, "umount -d %s", g_selfmounted_isodir);
    437437            run_program_and_log_output(command, 1);
    438438            paranoid_free(command);
    439             mr_asprintf(&command, "rmdir %s", g_selfmounted_isodir);
     439            mr_asprintf(command, "rmdir %s", g_selfmounted_isodir);
    440440            run_program_and_log_output(command, 1);
    441441            paranoid_free(command);
     
    456456            if (strstr(bkpinfo->tmpdir ,"mondo.tmp.") != NULL) {
    457457                log_msg(8,"erasing tempdir %s",bkpinfo->tmpdir);
    458                 mr_asprintf(&command, "rm -Rf %s", bkpinfo->tmpdir);
     458                mr_asprintf(command, "rm -Rf %s", bkpinfo->tmpdir);
    459459                paranoid_system(command);
    460460                mr_free(command);
     
    465465            if (strstr(bkpinfo->scratchdir ,"mondo.scratch.") != NULL) {
    466466                log_msg(8,"erasing scratchdir %s",bkpinfo->scratchdir);
    467                 mr_asprintf(&command, "rm -Rf %s", bkpinfo->scratchdir);
     467                mr_asprintf(command, "rm -Rf %s", bkpinfo->scratchdir);
    468468                paranoid_system(command);
    469469                mr_free(command);
     
    515515        }
    516516        if (grep_for_me[0] != '\0') {
    517             mr_asprintf(&command, "grep '%s' %s | tail -n%d",
     517            mr_asprintf(command, "grep '%s' %s | tail -n%d",
    518518                    grep_for_me, filename, g_noof_log_lines);
    519519        } else {
    520             mr_asprintf(&command, "tail -n%d %s", g_noof_log_lines,
     520            mr_asprintf(command, "tail -n%d %s", g_noof_log_lines,
    521521                    filename);
    522522        }
     
    536536                    */
    537537                    if (!strncmp(err_log_lines[i], "root:", 5)) {
    538                         mr_asprintf(&tmp, "%s", err_log_lines[i] + 6);
     538                        mr_asprintf(tmp, "%s", err_log_lines[i] + 6);
    539539                        strncpy(err_log_lines[i], tmp, (size_t)MAX_NEWT_COMMENT_LEN);
    540540                        mr_free(tmp);
     
    10741074                    (long) time_remaining % 60);
    10751075            if (percentage < 3) {
    1076                 mr_asprintf(&pcline_str, " Working");
     1076                mr_asprintf(pcline_str, " Working");
    10771077                for (j = 0; j < g_mysterious_dot_counter; j++) {
    10781078                    mr_strcat(pcline_str, ".");
     
    10831083                mr_strcat(pcline_str, " %c", special_dot_char(g_mysterious_dot_counter));
    10841084            } else {
    1085                 mr_asprintf(&pcline_str, " %3d%% done              %3d%% to go",
     1085                mr_asprintf(pcline_str, " %3d%% done              %3d%% to go",
    10861086                        percentage, 100 - percentage);
    10871087            }
    10881088            if (g_text_mode) {
    1089                 mr_asprintf(&taskprogress, "TASK:  [");
     1089                mr_asprintf(taskprogress, "TASK:  [");
    10901090                for (i = 0; i < percentage; i += 5) {
    10911091                    mr_strcat(taskprogress, "*");
     
    12341234            printf("---progress-form---3--- %s\n", blurb3);
    12351235            printf("---progress-form---E---\n");
    1236             mr_asprintf(&taskprogress, "TASK:  [");
     1236            mr_asprintf(taskprogress, "TASK:  [");
    12371237            for (i = 0; i < percentage; i += 5) {
    12381238                mr_strcat(taskprogress, "*");
     
    14431443        newtPopWindow();
    14441444        if (b_res == b1) {
    1445             mr_asprintf(&output, "%s", "bzip2");
     1445            mr_asprintf(output, "%s", "bzip2");
    14461446        } else if (b_res == b2) {
    1447             mr_asprintf(&output, "%s", "gzip");
     1447            mr_asprintf(output, "%s", "gzip");
    14481448        } else if (b_res == b3) {
    1449             mr_asprintf(&output, "%s", "lzo");
     1449            mr_asprintf(output, "%s", "lzo");
    14501450        //} else if (b_res == b4) {
    1451             //mr_asprintf(&output, "%s", "lzma");
     1451            //mr_asprintf(output, "%s", "lzma");
    14521452        }
    14531453        newtPopHelpLine();
     
    15401540        }
    15411541
    1542         mr_asprintf(&tmp1,"%s/icantfindthesefiles.txt",bkpinfo->tmpdir);
     1542        mr_asprintf(tmp1,"%s/icantfindthesefiles.txt",bkpinfo->tmpdir);
    15431543        if (!(fout = fopen(tmp1, "a"))) {
    15441544            log_msg(2, "Can't write to %s", tmp1);
     
    16371637        assert(flentry != NULL);
    16381638        if (flentry->severity == 0) {
    1639             mr_asprintf(&tmp, "0   ");
     1639            mr_asprintf(tmp, "0   ");
    16401640        } else if (flentry->severity == 1) {
    1641             mr_asprintf(&tmp, "low ");
     1641            mr_asprintf(tmp, "low ");
    16421642        } else if (flentry->severity == 2) {
    1643             mr_asprintf(&tmp, "med ");
    1644         } else {
    1645             mr_asprintf(&tmp, "high");
     1643            mr_asprintf(tmp, "med ");
     1644        } else {
     1645            mr_asprintf(tmp, "high");
    16461646        }
    16471647        mr_strcat(tmp, "  ");
Note: See TracChangeset for help on using the changeset viewer.