#include <stdio.h>
#include <stdlib.h>
#include <time.h>
typedef struct zone
{
time_t offset;
} zone;
static time_t local_to_utc(
void *user,
const sdfio_date *local)
{
time_t clock = 0;
? clock - ((const zone *)user)->offset
}
static bool utc_to_local(
void *user, time_t utc,
sdfio_date *local)
{
}
static void print_date(const char *label, time_t date)
{
char text[32];
strftime(text, sizeof text, "%Y-%m-%d %H:%M", gmtime(&date));
printf("%-38s %s\n", label, text);
}
const char *path)
{
{
}
return date;
}
int main(int argc, char **argv)
{
if (argc < 2)
{
fprintf(stderr, "usage: %s output.sdf\n", argv[0]);
return EXIT_FAILURE;
}
const char *path = argv[1];
zone central_europe = {3600};
utc_to_local};
const time_t written = 1782900000;
const float height = 1e-6F;
{
}
{
}
{
}
{
return EXIT_FAILURE;
}
print_date("written, UTC:", written);
print_date("read with the time zone, UTC:",
read_creation_date(&time_zone, path));
print_date("read without, the clock of the file:",
read_creation_date(NULL, path));
return EXIT_SUCCESS;
}
Files by path, and the stream over a C file.
sdfio_status sdfio_open_file(sdfio_reader *reader, const char *path)
Opens the file at a path as the source and reads its header, as sdfio_open_stream() does for a stream...
sdfio_status sdfio_create_file(sdfio_writer *writer, const char *path, const sdfio_header *header)
Creates the file at a path and starts it as sdfio_create_stream() does.
const sdfio_layout * sdfio_layout_packed(sdfio_data_type type)
Returns the layout of a plain array: the elements follow each other and the rows follow each other.
sdfio_status sdfio_reader_set_time_zone(sdfio_reader *reader, const sdfio_time_zone *time_zone)
Sets the conversion of the dates of ISO-1.0 files.
sdfio_status sdfio_reader_add_binary(sdfio_reader *reader)
Adds the binary format to the formats that the reader reads, the version numbers bISO-1....
const sdfio_header * sdfio_reader_header(const sdfio_reader *reader)
Returns the header of the opened file, or null if no file is open.
struct sdfio_reader sdfio_reader
Opaque handle of a reader.
Definition reader.h:58
sdfio_status sdfio_reader_create(const sdfio_allocator *allocator, sdfio_reader **reader)
Creates a reader.
void sdfio_reader_free(sdfio_reader *reader)
Releases a reader and closes the file that sdfio_open_file() opened, if any.
Reading and writing of ISO 25178-71 SDF surface data files.
Calendar fields of a date and the time of day, with a resolution of one minute.
Definition types.h:251
Conversion of the dates of ISO-1.0 files between the local clock of the writer and UTC.
Definition types.h:311
@ SDFIO_ISO_1_0
Revision ISO-1.0.
Definition types.h:74
sdfio_status
Result of a function call.
Definition types.h:31
@ SDFIO_OK
The call succeeded.
Definition types.h:33
const sdfio_allocator * sdfio_default_allocator(void)
Returns the allocator that uses malloc() and free().
@ SDFIO_TYPE_FLOAT
float: IEEE 754 binary32.
Definition types.h:114
@ SDFIO_TYPE_INT16
int16_t.
Definition types.h:118
#define SDFIO_NO_TIME
Value of a date that is not recorded: a time_t of -1.
Definition types.h:146
sdfio_status sdfio_date_to_time(const sdfio_date *date, time_t *utc)
Converts the fields of a date to a time, as if they were UTC.
sdfio_status sdfio_date_from_time(time_t utc, sdfio_date *date)
Converts a time to the fields of its UTC date.
sdfio_status sdfio_writer_add_binary(sdfio_writer *writer)
Adds the binary format to the formats that the writer writes.
sdfio_status sdfio_writer_create(const sdfio_allocator *allocator, sdfio_writer **writer)
Creates a writer.
struct sdfio_writer sdfio_writer
Opaque handle of a writer.
Definition writer.h:69
const char * sdfio_writer_error_message(const sdfio_writer *writer)
Returns a description of the most recent failure of the writer, or an empty string if none occurred.
void sdfio_writer_free(sdfio_writer *writer)
Releases a writer.
sdfio_status sdfio_write_heights(sdfio_writer *writer, const sdfio_layout *layout, const void *src)
Writes the whole data area from a matrix of heights in metres that lies in memory as the layout descr...
sdfio_status sdfio_writer_set_time_zone(sdfio_writer *writer, const sdfio_time_zone *time_zone)
Sets the conversion of the dates of ISO-1.0 files.
sdfio_status sdfio_end_file(sdfio_writer *writer)
Ends the file: closes the trailer, the last record, flushes the stream and, for a file that sdfio_cre...