Changeset 2357 in MondoRescue for branches/2.2.10/mondo/src/mondorestore


Ignore:
Timestamp:
Aug 29, 2009, 3:22:10 AM (15 years ago)
Author:
Bruno Cornec
Message:
  • Some more fgets => mr_getline transformations
  • XWIN define is gone
Location:
branches/2.2.10/mondo/src/mondorestore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/mondorestore/mondo-prep.c

    r2334 r2357  
    188188{
    189189    /**  buffers **********************************************/
    190     char *tmp;
     190    char *tmp = NULL;
    191191    char *tmp1 = NULL;
    192     char *incoming;
     192    char *incoming = NULL;
    193193    char *command;
    194194    char *lvscan_sz = NULL;
     
    225225    }
    226226
    227     malloc_string(tmp);
    228     malloc_string(incoming);
    229227    command = malloc(1024);
    230228
     
    271269    log_msg(1, "OK, rewound i-want-my-lvm. Doing funky stuff...");
    272270    rewind(fin);
    273     for (fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin); fgets(incoming, MAX_STR_LEN - 1, fin)) {
     271    for (mr_getline(incoming, fin); !feof(fin); mr_getline(incoming, fin)) {
    274272        fgetpos(fin, &orig_pos);
    275273        if (incoming[0] != '#') {
     274            mr_free(incoming);
    276275            continue;
    277276        }
     
    284283        if ((p = strstr(incoming, "vgcreate"))) {
    285284            // include next line(s) if they end in /dev (cos we've got a broken i-want-my-lvm)
    286             for (fgets(tmp, MAX_STR_LEN - 1, fin); !feof(fin); fgets(tmp, MAX_STR_LEN - 1, fin)) {
     285            for (mr_getline(tmp, fin); !feof(fin); mr_getline(tmp, fin)) {
    287286                if (tmp[0] == '#') {
    288287                    fsetpos(fin, &orig_pos);
     
    290289                } else {
    291290                    fgetpos(fin, &orig_pos);
    292                     strcat(incoming, tmp);
     291                    mr_strcat(incoming, tmp);
    293292                }
    294             }
     293                mr_free(tmp);
     294            }
     295            mr_free(tmp);
     296
    295297            for (q = incoming; *q != '\0'; q++) {
    296298                if (*q < 32) {
     
    298300                }
    299301            }
    300             strcpy(tmp, p + strlen("vgcreate") + 1);
     302            mr_asprintf(tmp, "%s", p + strlen("vgcreate") + 1);
    301303            for (q = tmp; *q > 32; q++);
    302304            *q = '\0';
    303305            log_msg(1, "Deleting old entries at /dev/%s", tmp);
    304306            mr_asprintf(tmp1, "rm -Rf /dev/%s", tmp);
     307            mr_free(tmp);
     308
    305309            run_program_and_log_output(tmp1, 1);
    306310            mr_free(tmp1);
     
    308312            run_program_and_log_output(vgscan_sz, 1);
    309313            run_program_and_log_output(pvscan_sz, 1);
    310             log_msg(3,
    311                     "After working around potentially broken i-want-my-lvm, incoming[] is now '%s'",
    312                     incoming);
     314            log_msg(3, "After working around potentially broken i-want-my-lvm, incoming[] is now '%s'", incoming);
    313315        }
    314316        for (p = incoming + 1; *p == ' '; p++);
     317        mr_free(incoming);
     318
    315319        strcpy(command, p);
    316320        for (p = command; *p != '\0'; p++);
     
    330334            if (strstr(command, "lvm lvcreate"))
    331335                lvmversion = 2;
    332             log_it("%s... so I'll get creative.", tmp);
    333336            if (lvmversion == 2) {
    334337                mr_asprintf(tmp1, "tail -n5 %s | grep Insufficient | tail -n1", MONDO_LOGFILE);
    335                 strcpy(tmp, call_program_and_get_last_line_of_output(tmp1));
     338                mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(tmp1));
    336339                mr_free(tmp1);
    337340            } else {
    338341                mr_asprintf(tmp1, "tail -n5 %s | grep lvcreate | tail -n1", MONDO_LOGFILE);
    339                 strcpy(tmp, call_program_and_get_last_line_of_output(tmp1));
     342                mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(tmp1));
    340343                mr_free(tmp1);
    341344            }
     
    343346            extents = atol(p);
    344347            log_msg(5, "p='%s' --> extents=%ld", p, extents);
     348            mr_free(tmp);
     349
    345350            p = strstr(command, "-L");
    346351            if (!p) {
     
    395400        sleep(1);
    396401    }
     402    mr_free(incoming);
    397403    mr_free(vgscan_sz);
    398404    mr_free(pvscan_sz);
     
    401407    log_msg(1, "Closed i-want-my-lvm. Finished doing funky stuff.");
    402408    }
    403     paranoid_free(tmp);
    404     paranoid_free(incoming);
    405409    paranoid_free(command);
    406410    system("sync");
     
    440444
    441445    /** buffers **********************************************************/
    442     char *incoming;
     446    char *incoming = NULL;
    443447
    444448    /** pointers *********************************************************/
     
    450454    /** end **************************************************************/
    451455
    452     malloc_string(incoming);
    453456    assert(new_mountlist != NULL);
    454457    assert(old_mountlist != NULL);
    455458
    456459#ifdef __FreeBSD__
    457     log_to_screen
    458         ("I don't know how to extrapolate the mountlist on FreeBSD. Sorry.");
     460    log_to_screen("I don't know how to extrapolate the mountlist on FreeBSD. Sorry.");
    459461    return (1);
    460462#endif
     
    472474                finish(1);
    473475            }
    474             for (fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin)
    475                  && !strstr(incoming, old_mountlist->el[lino].device);
    476                  fgets(incoming, MAX_STR_LEN - 1, fin));
     476            mr_getline(incoming, fin);
     477            while (feof(fin) && !strstr(incoming, old_mountlist->el[lino].device)) {
     478                mr_free(incoming);
     479                mr_getline(incoming, fin);
     480            }
     481            mr_free(incoming);
     482           
    477483            if (!feof(fin)) {
    478484                log_it("Investigating %s", old_mountlist->el[lino].device);
    479485
    480                 for (fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin)
    481                      && !strstr(incoming, "raiddev");
    482                      fgets(incoming, MAX_STR_LEN - 1, fin)) {
    483                     if (strstr(incoming, OSSWAP("device", "drive"))
    484                         && !strchr(incoming, '#')) {
    485                         for (p = incoming + strlen(incoming);
    486                              *(p - 1) <= 32; p--);
     486                for (mr_getline(incoming, fin); !feof(fin) && !strstr(incoming, "raiddev"); mr_getline(incoming, fin)) {
     487                    if (strstr(incoming, OSSWAP("device", "drive")) && !strchr(incoming, '#')) {
     488                        for (p = incoming + strlen(incoming); *(p - 1) <= 32; p--);
    487489                        *p = '\0';
    488490                        for (p--; p > incoming && *(p - 1) > 32; p--);
     491
    489492                        log_it("Extrapolating %s", p);
    490493
    491                         for (j = 0;
    492                              j < new_mountlist->entries
    493                              && strcmp(new_mountlist->el[j].device, p);
    494                              j++);
     494                        for (j = 0; j < new_mountlist->entries && strcmp(new_mountlist->el[j].device, p); j++);
    495495                        if (j >= new_mountlist->entries) {
    496                             strcpy(new_mountlist->
    497                                    el[new_mountlist->entries].device, p);
    498                             strcpy(new_mountlist->
    499                                    el[new_mountlist->entries].mountpoint,
    500                                    "raid");
    501                             strcpy(new_mountlist->
    502                                    el[new_mountlist->entries].format,
    503                                    "raid");
    504                             new_mountlist->el[new_mountlist->entries].
    505                                 size = old_mountlist->el[lino].size;
     496                            strcpy(new_mountlist->el[new_mountlist->entries].device, p);
     497                            strcpy(new_mountlist->el[new_mountlist->entries].mountpoint, "raid");
     498                            strcpy(new_mountlist->el[new_mountlist->entries].format, "raid");
     499                            new_mountlist->el[new_mountlist->entries].size = old_mountlist->el[lino].size;
    506500                            new_mountlist->entries++;
    507501                        } else {
    508502                            log_it("Not adding %s to mountlist: it's already there", p);
    509503                        }
     504                        mr_free(incoming);
    510505                    }
    511506                }
     507                mr_free(incoming);
    512508            }
    513509            paranoid_fclose(fin);
     
    656652#ifdef __FreeBSD__
    657653    static bool vinum_started_yet = FALSE;
     654    char *line = NULL;
     655    char *status;
    658656#endif
    659657
     
    710708        if (vinum_started_yet) {
    711709            FILE *fin;
    712             char line[MAX_STR_LEN];
    713710
    714711            log_to_screen("Initializing Vinum device %s (this may take a *long* time)", device);
     
    723720
    724721            fin = fopen("/tmp/plexes", "r");
    725             while (fgets(line, MAX_STR_LEN - 1, fin)) {
     722            /* BERLIOS: doesn't work */
     723            while (mr_getline(line, fin)) {
    726724                if (strchr(line, '\n'))
    727725                    *(strchr(line, '\n')) = '\0';   // get rid of the \n on the end
     
    740738                    mr_free(tmp);
    741739
    742                     char status[MAX_STR_LEN / 4];
    743                     fgets(status, MAX_STR_LEN / 4 - 1, pin);
     740                    mr_getline(status, pin);
    744741                    pclose(pin);
    745742
    746743                    if (!strcmp(status, "up")) {
     744                        mr_free(status);
    747745                        break;  /* it's done */
    748746                    }
    749747                    update_evalcall_form(atoi(status));
    750748                    usleep(250000);
     749                    mr_free(status);
    751750                }
    752751                close_evalcall_form();
    753             }
     752                mr_free(line);
     753            }
     754            mr_free(line);
    754755            fclose(fin);
    755756            unlink("/tmp/plexes");
     
    17211722        fput_string_one_char_at_a_time(pout_to_fdisk, output);
    17221723        fput_string_one_char_at_a_time(pout_to_fdisk, "\n\np\n");
    1723         mr_asprintf(tmp, "%s", last_line_of_file(FDISK_LOG));
     1724        tmp = last_line_of_file(FDISK_LOG);
    17241725        if (strstr(tmp, " (m ")) {
    17251726            log_msg(1, "Successfully created partition %d on %s", partno, drive);
     
    19121913    char *output = NULL;
    19131914    char *tmp = NULL;
     1915    char *tmp1 = NULL;
    19141916    char *partcode = NULL;
    19151917
     
    19811983            res = 0;
    19821984            fput_string_one_char_at_a_time(pout_to_fdisk, "t\n");
    1983             if (partno > 1
    1984                 || strstr(last_line_of_file(FDISK_LOG), " (1-4)")) {
     1985            tmp1 = last_line_of_file(FDISK_LOG);
     1986            if (partno > 1 || strstr(tmp1, " (1-4)")) {
    19851987                log_msg(5, "Specifying partno (%d) - yay", partno);
    19861988                mr_asprintf(tmp, "%d\n", partno);
     
    19881990                mr_free(tmp);
    19891991
    1990                 log_msg(5, "A - last line = '%s'",
    1991                         last_line_of_file(FDISK_LOG));
    1992             }
     1992                mr_free(tmp1);
     1993                tmp1 = last_line_of_file(FDISK_LOG);
     1994                log_msg(5, "A - last line = '%s'", tmp1);
     1995            }
     1996            mr_free(tmp1);
    19931997
    19941998            mr_asprintf(tmp, "%s\n", partcode);
     
    19962000            mr_free(tmp);
    19972001
    1998             log_msg(5, "B - last line = '%s'",
    1999                     last_line_of_file(FDISK_LOG));
     2002            tmp1 = last_line_of_file(FDISK_LOG);
     2003            log_msg(5, "B - last line = '%s'", tmp1);
     2004            mr_free(tmp1);
     2005
    20002006            fput_string_one_char_at_a_time(pout_to_fdisk, "\n");
    2001             log_msg(5, "C - last line = '%s'",
    2002                     last_line_of_file(FDISK_LOG));
    2003 
    2004             mr_asprintf(tmp, "%s", last_line_of_file(FDISK_LOG));
    2005             if (!strstr(tmp, " (m ")) {
    2006                 log_msg(1, "last line = '%s'; part type set failed", tmp);
     2007            tmp1 = last_line_of_file(FDISK_LOG);
     2008            log_msg(5, "C - last line = '%s'", tmp1);
     2009            mr_free(tmp1);
     2010
     2011            tmp1 = last_line_of_file(FDISK_LOG);
     2012            if (!strstr(tmp1, " (m ")) {
     2013                log_msg(1, "last line = '%s'; part type set failed", tmp1);
    20072014                res++;
    20082015                fput_string_one_char_at_a_time(pout_to_fdisk, "\n");
    20092016            }
    2010             mr_free(tmp);
     2017            mr_free(tmp1);
    20112018
    20122019            fput_string_one_char_at_a_time(pout_to_fdisk, "p\n");
    20132020        } else {
    20142021            mr_asprintf(output, "t\n%d\n%s\nw\n", partno, partcode);
    2015             mr_asprintf(command, "parted2fdisk %s >> %s 2>> %s", drive,
    2016                     MONDO_LOGFILE, MONDO_LOGFILE);
     2022            mr_asprintf(command, "parted2fdisk %s >> %s 2>> %s", drive, MONDO_LOGFILE, MONDO_LOGFILE);
    20172023            log_msg(5, "output = '%s'", output);
    20182024            log_msg(5, "partno=%d; partcode=%s", partno, partcode);
     
    21572163    /** int *************************************************************/
    21582164    int retval = 0;
     2165
     2166    /** char ************************************************************/
     2167    char *incoming = NULL;
    21592168#ifndef __FreeBSD__
     2169    char *dev;
     2170    char *p;
    21602171    int res;
    21612172#endif
    21622173
    2163     /** char ************************************************************/
    2164     char *incoming;
    2165 #ifndef __FreeBSD__
    2166     char *dev;
    2167 #endif
    21682174    /** pointers ********************************************************/
    2169 #ifndef __FreeBSD__
    2170     char *p;
    2171 #endif
    21722175    FILE *fin;
    21732176    int i;
     
    21752178    /** end ****************************************************************/
    21762179
    2177     malloc_string(dev);
    2178     malloc_string(incoming);
    21792180    assert(mountlist != NULL);
    21802181
    21812182    for (i = 0; i < 3; i++) {
    21822183#ifdef __FreeBSD__
    2183         fin =
    2184             popen
    2185             ("vinum list | grep '^[PVS]' | sed 's/S/1/;s/P/2/;s/V/3/' | sort | cut -d' ' -f2",
    2186              "r");
     2184        fin = popen("vinum list | grep '^[PVS]' | sed 's/S/1/;s/P/2/;s/V/3/' | sort | cut -d' ' -f2", "r");
    21872185        if (!fin) {
    2188             paranoid_free(dev);
    2189             paranoid_free(incoming);
    21902186            return (1);
    21912187        }
    2192         for (fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin);
    2193              fgets(incoming, MAX_STR_LEN - 1, fin)) {
     2188        for (mr_getline(incoming, fin); !feof(fin); mr_getline(incoming, fin)) {
    21942189            retval += stop_raid_device(incoming);
    2195         }
     2190            mr_free(incoming);
     2191        }
     2192        mr_free(incoming);
    21962193#else
    21972194        fin = fopen("/proc/mdstat", "r");
    21982195        if (!fin) {
    21992196            log_OS_error("/proc/mdstat");
    2200             paranoid_free(dev);
    2201             paranoid_free(incoming);
    22022197            return (1);
    22032198        }
    2204         for (fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin);
    2205              fgets(incoming, MAX_STR_LEN - 1, fin)) {
    2206             for (p = incoming;
    2207                  *p != '\0' && (*p != 'm' || *(p + 1) != 'd'
    2208                                 || !isdigit(*(p + 2))); p++);
     2199        for (mr_getline(incoming, fin); !feof(fin); mr_getline(incoming, fin)) {
     2200            for (p = incoming; *p != '\0' && (*p != 'm' || *(p + 1) != 'd' || !isdigit(*(p + 2))); p++);
    22092201            if (*p != '\0') {
    2210                 sprintf(dev, "/dev/%s", p);
     2202                mr_asprintf(dev, "/dev/%s", p);
    22112203                for (p = dev; *p > 32; p++);
    22122204                *p = '\0';
    22132205                res = stop_raid_device(dev);
    2214             }
    2215         }
     2206                mr_free(dev);
     2207            }
     2208            mr_free(incoming);
     2209        }
     2210        mr_free(incoming);
    22162211#endif
    22172212    }
     
    22202215        log_msg(1, "Warning - unable to stop some RAID devices");
    22212216    }
    2222     paranoid_free(dev);
    2223     paranoid_free(incoming);
    22242217    system("sync");
    22252218    system("sync");
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-compare.c

    r2338 r2357  
    670670    mr_free(bkpinfo->media_device);
    671671    if (bkpinfo->disaster_recovery && does_file_exist("/tmp/CDROM-LIVES-HERE")) {
    672         mr_asprintf(bkpinfo->media_device, "%s", last_line_of_file("/tmp/CDROM-LIVES-HERE"));
     672        bkpinfo->media_device = last_line_of_file("/tmp/CDROM-LIVES-HERE");
    673673    } else {
    674674        bkpinfo->media_device = find_cdrom_device(FALSE);
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-newt.c

    r2356 r2357  
    533533
    534534    system("grep Pers /proc/mdstat > /tmp/raid-personalities.txt 2> /dev/null");
    535     mr_asprintf(personalities, "%s", last_line_of_file("/tmp/raid-personalities.txt"));
     535    personalities = last_line_of_file("/tmp/raid-personalities.txt");
    536536    mr_asprintf(prompt, "Please enter the RAID level you want. %s", personalities);
    537537    mr_free(personalities);
     
    22912291    if (does_file_exist("/tmp/NFS-SERVER-PATH")) {
    22922292        mr_free(idev);
    2293         mr_asprintf(idev, "%s", last_line_of_file("/tmp/NFS-SERVER-MOUNT"));
     2293        idev = last_line_of_file("/tmp/NFS-SERVER-MOUNT");
    22942294        mr_asprintf(isodir_format, "nfs");
    22952295        mr_free(isodir_path);
    2296         mr_asprintf(isodir_path, "%s", last_line_of_file("/tmp/NFS-SERVER-PATH"));
     2296        isodir_path = last_line_of_file("/tmp/NFS-SERVER-PATH");
    22972297    }
    22982298
     
    28612861  /** char *************************************************************/
    28622862    char output = '\0';
    2863     char tmp[MAX_STR_LEN];
     2863    char *tmp = NULL;
    28642864
    28652865  /** newt *************************************************************/
     
    28732873
    28742874    if (g_text_mode) {
    2875         for (output = 'z'; !strchr("AICE", output); output = tmp[0]) {
    2876             printf
    2877                 ("Which mode - (A)utomatic, (I)nteractive, \n(C)ompare only, or (E)xit to shell?\n--> ");
    2878             fgets(tmp, MAX_STR_LEN - 1, stdin);
     2875        while (!strchr("AICE", output)) {
     2876            printf("Which mode - (A)utomatic, (I)nteractive, \n(C)ompare only, or (E)xit to shell?\n--> ");
     2877            mr_getline(tmp, stdin);
     2878            output = tmp[0];
     2879            free(tmp);
    28792880        }
    28802881        return (output);
    28812882    }
    28822883
    2883     newtPushHelpLine
    2884         ("   Do you want to 'nuke' your system, restore interactively, or just compare?");
     2884    newtPushHelpLine("   Do you want to 'nuke' your system, restore interactively, or just compare?");
    28852885    newtOpenWindow(24, 3, 32, 17, "How should I restore?");
    28862886    b1 = newtButton(7, 1, "Automatically");
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c

    r2351 r2357  
    107107* @ingroup restoreUtilityGroup
    108108*/
    109 void ask_about_these_imagedevs(char *infname, char *outfname)
    110 {
     109void ask_about_these_imagedevs(char *infname, char *outfname) {
     110
    111111FILE *fin;
    112112FILE *fout;
    113 /************************************************************************
    114 * allocate memory regions. test and set  -sab 16 feb 2003              *
    115 ************************************************************************/
    116 char *incoming_ptr;
    117 char *question_ptr = NULL;
    118 
    119 char incoming[MAX_STR_LEN] = "\0";
     113char *incoming = NULL;
     114char *question = NULL;
    120115
    121116assert_string_is_neither_NULL_nor_zerolength(infname);
    122117assert_string_is_neither_NULL_nor_zerolength(outfname);
    123118
    124 incoming_ptr = malloc(sizeof(incoming));
    125 if (incoming_ptr == NULL) {
    126 fprintf(stderr, "Out of Memory\n");
    127 exit(EXIT_FAILURE);
    128 }
    129 
    130 memset(incoming_ptr, '\0', sizeof(incoming));
    131 
    132119if (!(fin = fopen(infname, "r"))) {
    133 fatal_error("Cannot openin infname");
     120    fatal_error("Cannot openin infname");
    134121}
    135122if (!(fout = fopen(outfname, "w"))) {
    136 fatal_error("Cannot openin outfname");
    137 }
    138 for (fgets(incoming_ptr, MAX_STR_LEN, fin);
    139  !feof(fin); fgets(incoming_ptr, MAX_STR_LEN, fin)) {
    140 strip_spaces(incoming_ptr);
    141 
    142 if (incoming[0] == '\0') {
    143     continue;
    144 }
    145 
    146 mr_asprintf(question_ptr, "Should I restore the image of %s ?", incoming_ptr);
    147 
    148 if (ask_me_yes_or_no(question_ptr)) {
    149     fprintf(fout, "%s\n", incoming_ptr);
    150 }
    151 }
    152 
    153 /*** free memory ***********/
    154 paranoid_free(incoming_ptr);
    155 incoming_ptr = NULL;
    156 mr_free(question_ptr);
     123    fatal_error("Cannot openin outfname");
     124}
     125for (mr_getline(incoming, fin); !feof(fin); mr_getline(incoming, fin)) {
     126    mr_strip_spaces(incoming);
     127
     128    if (incoming[0] == '\0') {
     129        mr_free(incoming);
     130        continue;
     131    }
     132
     133    mr_asprintf(question, "Should I restore the image of %s ?", incoming);
     134   
     135    if (ask_me_yes_or_no(question)) {
     136        fprintf(fout, "%s\n", incoming);
     137    }
     138    mr_free(incoming);
     139}
     140mr_free(incoming);
     141mr_free(question);
    157142paranoid_fclose(fout);
    158143paranoid_fclose(fin);
     
    619604        mr_free(bkpinfo->media_device);
    620605        if (bkpinfo->disaster_recovery && does_file_exist("/tmp/CDROM-LIVES-HERE")) {
    621             mr_asprintf(bkpinfo->media_device, "%s", last_line_of_file("/tmp/CDROM-LIVES-HERE"));
     606            bkpinfo->media_device = last_line_of_file("/tmp/CDROM-LIVES-HERE");
    622607        } else {
    623608            bkpinfo->media_device = find_cdrom_device(TRUE);
     
    11191104char *command = NULL;
    11201105char *tmp;
     1106char *tmp1 = NULL;
    11211107int res = 0;
    11221108pid_t pid;
     
    12601246    if (g_text_mode) {
    12611247        printf("Restore which directory? --> ");
    1262         fgets(tmp, sizeof(tmp), stdin);
    1263         toggle_path_selection(filelist, tmp, TRUE);
    1264         if (strlen(tmp) == 0) {
     1248        mr_getline(tmp1, stdin);
     1249        toggle_path_selection(filelist, tmp1, TRUE);
     1250        if (strlen(tmp1) == 0) {
    12651251            res = 1;
    12661252        } else {
    12671253            res = 0;
    12681254        }
     1255        mr_free(tmp1);
    12691256    } else {
    12701257        res = edit_filelist(filelist);
     
    19381925    FILE *fin;
    19391926    FILE *fout;
    1940   /** malloc **/
    1941     char *incoming;
     1927    char *incoming = NULL;
    19421928
    19431929    assert_string_is_neither_NULL_nor_zerolength(output_file);
    19441930    assert_string_is_neither_NULL_nor_zerolength(input_file);
    1945     malloc_string(incoming);
    19461931
    19471932    if (!(fin = fopen(input_file, "r"))) {
     
    19521937        fatal_error("cannot open output_file");
    19531938    }
    1954     for (fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin);
    1955          fgets(incoming, MAX_STR_LEN - 1, fin)) {
     1939    for (mr_getline(incoming, fin); !feof(fin); mr_getline(incoming, fin)) {
    19561940        if (strncmp(incoming, "etc/adjtime", 11)
    19571941            && strncmp(incoming, "etc/mtab", 8)
     
    19621946            && strncmp(incoming, "var/", 4))
    19631947            fprintf(fout, "%s", incoming);  /* don't need \n here, for some reason.. */
    1964     }
     1948        mr_free(incoming);
     1949    }
     1950    mr_free(incoming);
    19651951    paranoid_fclose(fout);
    19661952    paranoid_fclose(fin);
    1967     paranoid_free(incoming);
    19681953}
    19691954
Note: See TracChangeset for help on using the changeset viewer.