IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29876


Ignore:
Timestamp:
Nov 29, 2010, 11:39:13 AM (15 years ago)
Author:
eugene
Message:

if no compression is requested, use standard fopen / fwrite functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101103/ppConfigDump/src/ppConfigDump.c

    r29821 r29876  
    2828          psMetadata *md,           // Metadata to dump
    2929          const char *compressMode
    30           )
     30    )
    3131{
    3232    if (!filename || strlen(filename) == 0) {
     
    4040        }
    4141
    42 # if (PS_SLURP_GZIP)
    43 
    44         char modeString[4];
    45 
    4642        if (compressMode) {
    4743            if (strlen(compressMode) > 2) {
     
    4945                die(PS_EXIT_CONFIG_ERROR);
    5046            }
     47            char modeString[4];
    5148            snprintf (modeString, 4, "w%s", compressMode);
     49
     50            gzFile file = gzdopen (STDOUT_FILENO, modeString);
     51            if (file == Z_NULL) {
     52                psErrorStackPrint(stderr, "Failed to open file\n");
     53                die(PS_EXIT_SYS_ERROR);
     54            }
     55            int nbytes = gzwrite (file, string, strlen(string));
     56            if (nbytes != strlen(string)) {
     57                psErrorStackPrint(stderr, "Failed to write contents of configuration file %s", filename);
     58                psFree(string);
     59                gzclose(file);
     60                die(PS_EXIT_SYS_ERROR);
     61            }
     62            psFree(string);
     63            if (gzclose(file) != Z_OK) {
     64                psErrorStackPrint(stderr, "Failed to close file, %s\n", filename);
     65                die(PS_EXIT_SYS_ERROR);
     66            }
    5267        } else {
    53             strcpy (modeString, "w0");
    54         }       
    55 
    56         gzFile file = gzdopen (STDOUT_FILENO, modeString);
    57         if (file == Z_NULL) {
    58             psErrorStackPrint(stderr, "Failed to open file\n");
     68            fprintf(stdout, "%s", string);
     69        }
     70        psFree(string);
     71    } else {
     72        if (!psMetadataConfigWrite(md, filename, compressMode)) {
     73            psErrorStackPrint(stderr, "Can't write %s to %s\n", description, filename);
    5974            die(PS_EXIT_SYS_ERROR);
    6075        }
    61         int nbytes = gzwrite (file, string, strlen(string));
    62         if (nbytes != strlen(string)) {
    63             psErrorStackPrint(stderr, "Failed to write contents of configuration file %s", filename);
    64             psFree(string);
    65             gzclose(file);
    66             die(PS_EXIT_SYS_ERROR);
    67         }
    68         psFree(string);
    69         if (gzclose(file) != Z_OK) {
    70             psErrorStackPrint(stderr, "Failed to close file, %s\n", filename);
    71             die(PS_EXIT_SYS_ERROR);
    72         }
    73 # else
    74         fprintf(stdout, "%s", string);
    75 # endif
    76         psFree(string);
    77     } else if (!psMetadataConfigWrite(md, filename, compressMode)) {
    78         psErrorStackPrint(stderr, "Can't write %s to %s\n", description, filename);
    79         die(PS_EXIT_SYS_ERROR);
    8076    }
    8177}
Note: See TracChangeset for help on using the changeset viewer.