Ignore:
Timestamp:
Sep 19, 2007, 9:32:00 AM (13 years ago)
Author:
Bruno Cornec
Message:

Continue to use configuration file data (may not compile)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/common/libmondo-stream.c

    r1594 r1638  
    1717#include "mr_list.h"
    1818#include "mr_gettext.h"
     19#include "mr_conf.h"
    1920
    2021#include "mondostructures.h"
     
    3839extern char *g_getfattr;
    3940extern char *MONDO_LOGFILE;
     41
     42extern struct mr_conf *mr_conf;
    4043
    4144/**
     
    864867    malloc_string(temp_fname);
    865868    malloc_string(temp_cksum);
    866     datablock = mr_malloc(TAPE_BLOCK_SIZE);
     869    datablock = mr_malloc(mr_conf->external_tape_blocksize);
    867870    crc16 = 0;
    868871    crctt = 0;
     
    904907         bytes_read) {
    905908        bytes_to_write =
    906             (size < TAPE_BLOCK_SIZE) ? (long) size : TAPE_BLOCK_SIZE;
    907         bytes_to_read = TAPE_BLOCK_SIZE;
     909            (size < mr_conf->external_tape_blocksize) ? (long) size : mr_conf->external_tape_blocksize;
     910        bytes_to_read = mr_conf->external_tape_blocksize;
    908911        bytes_read = fread(datablock, 1, bytes_to_read, g_tape_stream);
    909912        while (bytes_read < bytes_to_read) {    // next tape!
     
    995998    /*@ end vars *************************************************** */
    996999
    997     tempblock = (char *) mr_malloc((size_t) TAPE_BLOCK_SIZE);
    998 
    999     for (i = 0; i < (int) TAPE_BLOCK_SIZE; i++) {
     1000    tempblock = (char *) mr_malloc((size_t) mr_conf->external_tape_blocksize);
     1001
     1002    for (i = 0; i < (int) mr_conf->external_tape_blocksize; i++) {
    10001003        tempblock[i] = 0;
    10011004    }
    10021005    while (!(*pcontrol_char = tempblock[7000])) {
    10031006        g_tape_posK +=
    1004             fread(tempblock, 1, (size_t) TAPE_BLOCK_SIZE,
     1007            fread(tempblock, 1, (size_t) mr_conf->external_tape_blocksize,
    10051008                  g_tape_stream) / 1024;
    10061009    }
     
    11311134    long bytes_to_write;
    11321135
    1133     datablock = mr_malloc(TAPE_BLOCK_SIZE);
     1136    datablock = mr_malloc(mr_conf->external_tape_blocksize);
    11341137    malloc_string(temp_fname);
    11351138    pB = strrchr(the_file_I_was_reading, '/');
     
    11811184        for (size = temp_size; size > 0; size -= bytes_to_write) {
    11821185            bytes_to_write =
    1183                 (size < TAPE_BLOCK_SIZE) ? (long) size : TAPE_BLOCK_SIZE;
     1186                (size < mr_conf->external_tape_blocksize) ? (long) size : mr_conf->external_tape_blocksize;
    11841187            // FIXME - needs error-checking and -catching
    1185             fread(datablock, 1, (size_t) TAPE_BLOCK_SIZE, g_tape_stream);
     1188            fread(datablock, 1, (size_t) mr_conf->external_tape_blocksize, g_tape_stream);
    11861189        }
    11871190        res =
     
    14441447    /*@ buffers **************************************************** */
    14451448    char *tmp = NULL;
    1446     char datablock[TAPE_BLOCK_SIZE];
     1449    char *datablock = NULL;
    14471450    char *checksum = NULL;
    14481451    char *infile_basename = NULL;
     
    14731476    crc16 = 0;
    14741477    crctt = 0;
     1478    datablock = mr_malloc(mr_conf->external_tape_blocksize);
    14751479
    14761480    /*@ end vars *************************************************** */
     
    15081512    for (noof_blocks = 0; filesize > 0;
    15091513         noof_blocks++, filesize -= bytes_to_read) {
    1510         if (filesize < TAPE_BLOCK_SIZE) {
     1514        if (filesize < mr_conf->external_tape_blocksize) {
    15111515            bytes_to_read = (long) filesize;
    1512             for (i = 0; i < TAPE_BLOCK_SIZE; i++) {
     1516            for (i = 0; i < mr_conf->external_tape_blocksize; i++) {
    15131517                datablock[i] = '\0';
    15141518            }
    15151519        } else {
    1516             bytes_to_read = TAPE_BLOCK_SIZE;
     1520            bytes_to_read = mr_conf->external_tape_blocksize;
    15171521        }
    15181522        (void) fread(datablock, 1, (size_t) bytes_to_read, fin);
    15191523        g_tape_posK += fwrite(datablock, 1, /*bytes_to_read */
    1520                               (size_t) TAPE_BLOCK_SIZE,
     1524                              (size_t) mr_conf->external_tape_blocksize,
    15211525                              g_tape_stream) / 1024;
    15221526        if (g_sigpipe) {
     
    15361540#endif
    15371541    }
     1542    paranoid_free(datablock);
    15381543    paranoid_fclose(fin);
    15391544    mr_asprintf(&checksum, "%04x%04x", crc16, crctt);
     
    15631568{
    15641569    /*@ buffers **************************************************** */
    1565     char tempblock[TAPE_BLOCK_SIZE];
     1570    char *tempblock;
    15661571    char *p;
    15671572
     
    15731578    /*@ end vars *************************************************** */
    15741579
     1580    tempblock = mr_malloc(mr_conf->external_tape_blocksize);
    15751581
    15761582    olen = length_of_incoming_file;
     
    15861592        return (1);
    15871593    }
    1588     for (i = 0; i < (int) TAPE_BLOCK_SIZE; i++) {
     1594    for (i = 0; i < (int) mr_conf->external_tape_blocksize; i++) {
    15891595        tempblock[i] = 0;
    15901596    }
     
    15941600    strcpy(tempblock + 1000, filename);
    15951601    g_tape_posK +=
    1596         fwrite(tempblock, 1, (size_t) TAPE_BLOCK_SIZE,
     1602        fwrite(tempblock, 1, (size_t) mr_conf->external_tape_blocksize,
    15971603               g_tape_stream) / 1024;
     1604    paranoid_free(tempblock);
    15981605    mr_msg(6, "%s (fname=%s, size=%ld K)",
    15991606            marker_to_string(control_char), p,
Note: See TracChangeset for help on using the changeset viewer.