chxtfhdr
Description
chxtfhdr is a C utility library that provides functions for converting raw XTF (Extended Triton Format) binary header data into more accessible C structures. Itβs designed to correctly interpret XTF files by handling potential endianness differences (byte swapping) and extracting various header components, including file-level information, ping-specific details, attitude data, and channel-specific parameters. The library also offers functions to print the contents of these converted headers for inspection and debugging.
Functions
void cvtChanInfo(cCHANINFO *buffer, CHANINFO *ChanInfo)
Converts a raw cCHANINFO buffer to a structured CHANINFO object, performing byte swaps where necessary.
buffer: Pointer to the rawcCHANINFOdata.ChanInfo: Pointer to theCHANINFOstructure to populate.
void cvtFileHeader(cXTFFILEHEADER *buffer, XTFFILEHEADER *FileHeader)
Converts a raw cXTFFILEHEADER buffer to a structured XTFFILEHEADER object, performing byte swaps.
buffer: Pointer to the rawcXTFFILEHEADERdata.FileHeader: Pointer to theXTFFILEHEADERstructure to populate.
void printFileHeader(XTFFILEHEADER *FileHeader)
Prints the contents of an XTFFILEHEADER structure to standard output.
FileHeader: Pointer to theXTFFILEHEADERstructure to print.
void cvtPingHeader(cXTFPINGHEADER *buffer, XTFPINGHEADER *PingHead)
Converts a raw cXTFPINGHEADER buffer to a structured XTFPINGHEADER object, performing byte swaps.
buffer: Pointer to the rawcXTFPINGHEADERdata.PingHead: Pointer to theXTFPINGHEADERstructure to populate.
void cvtAttitudeData(cXTFATTITUDEDATA *buffer, XTFATTITUDEDATA *AtData)
Converts a raw cXTFATTITUDEDATA buffer to a structured XTFATTITUDEDATA object, performing byte swaps.
buffer: Pointer to the rawcXTFATTITUDEDATAdata.AtData: Pointer to theXTFATTITUDEDATAstructure to populate.
void cvtNotesHeader(cXTFNOTESHEADER *buffer, XTFNOTESHEADER *Notes)
Converts a raw cXTFNOTESHEADER buffer to a structured XTFNOTESHEADER object, performing byte swaps.
buffer: Pointer to the rawcXTFNOTESHEADERdata.Notes: Pointer to theXTFNOTESHEADERstructure to populate.
void cvtRawSerialHeader(cXTFRAWSERIALHEADER *buffer, XTFRAWSERIALHEADER *SerialHead)
Converts a raw cXTFRAWSERIALHEADER buffer to a structured XTFRAWSERIALHEADER object, performing byte swaps.
buffer: Pointer to the rawcXTFRAWSERIALHEADERdata.SerialHead: Pointer to theXTFRAWSERIALHEADERstructure to populate.
void cvtPingChanHeader(cXTFPINGCHANHEADER *buffer, XTFPINGCHANHEADER *PingChanHdr)
Converts a raw cXTFPINGCHANHEADER buffer to a structured XTFPINGCHANHEADER object, performing byte swaps.
buffer: Pointer to the rawcXTFPINGCHANHEADERdata.PingChanHdr: Pointer to theXTFPINGCHANHEADERstructure to populate.
void printPingChanHdr(XTFPINGCHANHEADER *PingChanHdr)
Prints the contents of an XTFPINGCHANHEADER structure to standard output.
PingChanHdr: Pointer to theXTFPINGCHANHEADERstructure to print.
How It Works
The chxtfhdr library functions utilize the bytes2func library for fundamental byte-to-data-type conversions, including endianness handling. Each cvt* function takes a pointer to a raw (compact) XTF header structure (prefixed with c) and a pointer to a βcookedβ (standard) C structure. It then systematically copies individual fields from the raw buffer to the cooked structure, calling the appropriate bytes2short, bytes2int, bytes2float, or bytes2double function from bytes2func to ensure correct byte ordering and data interpretation. String fields are copied directly. The print* functions simply access and print the members of the converted structures.