#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
if (argc < 2)
{
fprintf(stderr, "usage: %s input.sdf\n", argv[0]);
return EXIT_FAILURE;
}
{
return EXIT_FAILURE;
}
{
fprintf(stderr, "the file does not contain int16 coded values\n");
return EXIT_FAILURE;
}
size_t row_size = 0;
? malloc(row_size)
: NULL;
if (row == NULL)
{
fprintf(stderr, "a row does not fit in memory\n");
return EXIT_FAILURE;
}
size_t not_measured = 0;
size_t measured = 0;
double sum = 0.0;
for (size_t y = 0; y < rows; ++y)
{
{
break;
}
for (size_t x = 0; x < columns; ++x)
{
{
++not_measured;
}
else
{
sum += row[x];
++measured;
}
}
}
{
}
else
{
const double mean = sum / (double)measured;
printf("%s %lu x %lu, %zu points not measured, mean %g coded value = "
"%g m\n",
: "ISO-2.0",
(unsigned long)columns, (unsigned long)rows, not_measured, mean,
}
free(row);
return status ==
SDFIO_OK ? EXIT_SUCCESS : EXIT_FAILURE;
}
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...
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_read_data(sdfio_reader *reader, const sdfio_layout *layout, void *dst, size_t rows)
Reads the next rows of the data area as the file codes them.
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.
const char * sdfio_reader_error_message(const sdfio_reader *reader)
Returns a description of the most recent failure of the reader, or an empty string if none occurred.
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.
sdfio_status sdfio_data_row_size(const sdfio_header *header, size_t *bytes)
Returns the size in bytes of a buffer for one row of the data area, to read or write the data row by ...
Description of a buffer of the caller for heights or for the values of the data area: the type of its...
Definition layout.h:45
@ SDFIO_ISO_1_0
Revision ISO-1.0.
Definition types.h:74
const char * sdfio_status_string(sdfio_status status)
Returns a constant description of a status.
sdfio_status
Result of a function call.
Definition types.h:31
@ SDFIO_OK
The call succeeded.
Definition types.h:33
#define SDFIO_BAD_INT16
The bad value of SDFIO_TYPE_INT16.
Definition types.h:136
const sdfio_allocator * sdfio_default_allocator(void)
Returns the allocator that uses malloc() and free().
@ SDFIO_TYPE_INT16
int16_t.
Definition types.h:118