The following routines either compute or validate the checksums for the
CHDU. The DATASUM keyword is used to store the numerical value of the
32-bit, 1's complement checksum for the data unit alone. If there is
no data unit then the value is set to zero. The numerical value is
stored as an ASCII string of digits, enclosed in quotes, because the
value may be too large to represent as a 32-bit signed integer. The
CHECKSUM keyword is used to store the ASCII encoded COMPLEMENT of the
checksum for the entire HDU. Storing the complement, rather than the
actual checksum, forces the checksum for the whole HDU to equal zero.
If the file has been modified since the checksums were computed, then
the HDU checksum will usually not equal zero. These checksum keyword
conventions are based on a paper by Rob Seaman published in the
proceedings of the ADASS IV conference in Baltimore in November 1994
and a later revision in June 1995. See Appendix B for the definition
of the parameters used in these routines.
- 1
- Compute and write the DATASUM and CHECKSUM keyword values for the CHDU
into the current header. If the keywords already exist, their values
will be updated only if necessary (i.e., if the file
has been modified since the original keyword
values were computed).
int fits_write_chksum / ffpcks
(fitsfile *fptr, > int *status)
- 2
- Update the CHECKSUM keyword value in the CHDU, assuming that the
DATASUM keyword exists and already has the correct value. This routine
calculates the new checksum for the current header unit, adds it to the
data unit checksum, encodes the value into an ASCII string, and writes
the string to the CHECKSUM keyword.
int fits_update_chksum / ffupck
(fitsfile *fptr, > int *status)
- 3
- Verify the CHDU by computing the checksums and comparing
them with the keywords. The data unit is verified correctly
if the computed checksum equals the value of the DATASUM
keyword. The checksum for the entire HDU (header plus data unit) is
correct if it equals zero. The output DATAOK and HDUOK parameters
in this routine are integers which will have a value = 1
if the data or HDU is verified correctly, a value = 0
if the DATASUM or CHECKSUM keyword is not present, or value = -1
if the computed checksum is not correct.
int fits_verify_chksum / ffvcks
(fitsfile *fptr, > int *dataok, int *hduok, int *status)
- 4
- Compute and return the checksum values for the CHDU
without creating or modifying the
CHECKSUM and DATASUM keywords. This routine is used internally by
ffvcks, but may be useful in other situations as well.
int fits_get_chksum/ /ffgcks
(fitsfile *fptr, > unsigned long *datasum, unsigned long *hdusum,
int *status)
- 5
- Encode a checksum value
into a 16-character string. If complm is non-zero (true) then the 32-bit
sum value will be complemented before encoding.
int fits_encode_chksum / ffesum
(unsigned long sum, int complm, > char *ascii);
- 6
- Decode a 16-character checksum string into a unsigned long value.
If is non-zero (true). then the 32-bit sum value will be complemented
after decoding. The checksum value is also returned as the
value of the function.
unsigned long fits_decode_chksum / ffdsum
(char *ascii, int complm, > unsigned long *sum);