Logo Search packages:      
Sourcecode: qfits version File versions  Download package

int qfits_save_table_hdrdump ( const void **  array,
const qfits_table table,
const qfits_header fh 
)

Save a table to a FITS file with a given FITS header.

Parameters:
array Data array.
table table
fh FITS header to insert in the output file.
Returns:
-1 in error case, 0 otherwise

Definition at line 1470 of file qfits_table.c.

References filename, qfits_datamd5(), qfits_header_dump(), qfits_replace_card(), and tab_t.

{
    FILE        *   outfile ;
    const char  *   md5hash ;
    char            md5card[81];

    /* Open the destination file */
    if ((outfile = fopen(table->filename, "w")) == NULL) {
        qfits_error("cannot open file [%s]", table->filename) ;
        return -1 ;
    }
    /* Write the fits header in the file 'outname' */
    if (qfits_header_dump(fh, outfile) == -1) {
        qfits_error("cannot dump header in file") ;
        fclose(outfile) ;
        return -1 ;
    }
    /* Append the extension */
    if (table->tab_t == QFITS_BINTABLE) {
        if (qfits_table_append_bin_xtension(outfile, table, array) == -1) {
            qfits_error("in writing fits table") ;
            fclose(outfile) ;
            return -1 ;
        }
    } else if (table->tab_t == QFITS_ASCIITABLE) {
        if (qfits_table_append_ascii_xtension(outfile, table, array) == -1) {
            qfits_error("in writing fits table") ;
            fclose(outfile) ;
            return -1 ;
        }
    } else {
        qfits_error("Unrecognized table type") ;
        fclose(outfile) ;
        return -1 ;
    }
    fclose(outfile) ;
    /* Update MD5 keyword */
    if (strcmp(table->filename, "STDOUT")) {
        md5hash = qfits_datamd5(table->filename);
        if (md5hash==NULL) {
            qfits_error("computing MD5 signature for output file %s", 
                    table->filename);
            return -1 ;
        }
        sprintf(md5card, "DATAMD5 = '%s' / MD5 checksum", md5hash);
        qfits_replace_card(table->filename, "DATAMD5", md5card);
    }
    return 0 ;
}


Generated by  Doxygen 1.6.0   Back to index