eaarl-io  1.0.1+71abbd4
EAARL Input/Output Library (Public API)
Data Structures | Macros | Functions
tld.h File Reference

Read/write support for the TLD file format. More...

#include "eaarlio/error.h"
#include "eaarlio/memory.h"
#include "eaarlio/raster.h"
#include "eaarlio/stream.h"
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  eaarlio_tld_header
 TLD record header. More...
 

Macros

#define EAARLIO_TLD_TYPE_RASTER   5
 Type value for an EAARL-A/B raster record. More...
 
#define eaarlio_tld_header_empty()
 Empty eaarlio_tld_header value. More...
 

Functions

eaarlio_error eaarlio_tld_read_record (struct eaarlio_stream *stream, struct eaarlio_tld_header *record_header, struct eaarlio_raster *raster, struct eaarlio_memory *memory, int include_pulses, int include_waveforms)
 Read a TLD record from a stream. More...
 
eaarlio_error eaarlio_tld_read_raster (struct eaarlio_stream *stream, struct eaarlio_raster *raster, struct eaarlio_memory *memory, int include_pulses, int include_waveforms)
 Read a raster from a TLD stream. More...
 
eaarlio_error eaarlio_tld_write_raster (struct eaarlio_stream *stream, struct eaarlio_raster *raster, struct eaarlio_memory *memory)
 Write a raster to a TLD stream. More...
 

Detailed Description

Read/write support for the TLD file format.


Data Structure Documentation

◆ eaarlio_tld_header

struct eaarlio_tld_header

TLD record header.

Each record in a TLD file starts with one of these.

Data Fields
uint32_t record_length Byte length of this record (including the header)
uint8_t record_type Record type.

This is always EAARLIO_TLD_TYPE_RASTER (5) for EAARL-A/EAARL-B.

Macro Definition Documentation

◆ eaarlio_tld_header_empty

#define eaarlio_tld_header_empty ( )
Value:
{ \
0, 0 \
}
TLD record header.
Definition: tld.h:32

Empty eaarlio_tld_header value.

All fields will contain zero values.

◆ EAARLIO_TLD_TYPE_RASTER

#define EAARLIO_TLD_TYPE_RASTER   5

Type value for an EAARL-A/B raster record.

Only records with eaarlio_tld_header::record_type == EAARLIO_TLD_TYPE_RASTER are understood to be rasters by this library.

Function Documentation

◆ eaarlio_tld_read_raster()

eaarlio_error eaarlio_tld_read_raster ( struct eaarlio_stream stream,
struct eaarlio_raster raster,
struct eaarlio_memory memory,
int  include_pulses,
int  include_waveforms 
)

Read a raster from a TLD stream.

This function is convenience wrapper around eaarlio_tld_read_record and works nearly identically to it. The differences are:

Please refer to eaarlio_tld_read_record for further documentation.

Examples:
example_file_tld_opener.c.

◆ eaarlio_tld_read_record()

eaarlio_error eaarlio_tld_read_record ( struct eaarlio_stream stream,
struct eaarlio_tld_header record_header,
struct eaarlio_raster raster,
struct eaarlio_memory memory,
int  include_pulses,
int  include_waveforms 
)

Read a TLD record from a stream.

Parameters
[in]streamStream with data to read
[out]record_headerPointer to record header to be populated
[out]rasterPointer to raster to be populated
[in]memoryMemory handler, or NULL for stdlib
[in]include_pulsesShould pulse data be read? 1 = yes, 0 = no
[in]include_waveformsShould waveform data be read? 1 = yes, 0 = no
Returns
On success, EAARLIO_SUCCESS.
On failure, eaarlio_error representing the failure condition.
Precondition
stream must be open for reading.
Postcondition
On success, the stream is advanced to the end of the record.
On success, record_header is populated.
On success, if record_header->record_type is EAARLIO_TLD_TYPE_RASTER, then raster->header is populated.
On success, if record_header->record_type is EAARLIO_TLD_TYPE_RASTER and include_pulses = 1, then raster->pulse is populated; each pulse will have its header populated.
On success, if record_header->record_type is EAARLIO_TLD_TYPE_RASTER and include_pulses = 1 and include_waveforms = 1, then the waveforms for each pulse in raster->pulse are populated.
On failure, anything might be partially populated.
Any non-null pointers in raster are newly-allocated memory.

◆ eaarlio_tld_write_raster()

eaarlio_error eaarlio_tld_write_raster ( struct eaarlio_stream stream,
struct eaarlio_raster raster,
struct eaarlio_memory memory 
)

Write a raster to a TLD stream.

Parameters
[in]streamStream to be written to
[in]rasterRaster to write
[in]memoryMemory handler, or NULL for stdlib
Returns
On success, EAARLIO_SUCCESS.
On failure, eaarlio_error representing the failure condition.
Precondition
stream must be open for writing
Postcondition
On success, the encoded data was written to stream.
On failure, the encoded data may have been partially written to stream.
Remarks
The raster will be written as a TLD record of type EAARLIO_TLD_TYPE_RASTER.
This function performs some memory allocation internally. However, all allocated memory is released before the function returns.