diff --git a/examples/output_xml.c b/examples/output_xml.c index b66fc27..1e9c569 100644 --- a/examples/output_xml.c +++ b/examples/output_xml.c @@ -400,6 +400,24 @@ dctool_xml_output_write (dctool_output_t *abstract, dc_parser_t *parser, const u convert_pressure(atmospheric, output->units)); } + message ("Parsing strings.\n"); + int idx; + for (idx = 0; idx < 100; idx++) { + dc_field_string_t str = { NULL }; + status = dc_parser_get_field(parser, DC_FIELD_STRING, idx, &str); + if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) { + ERROR ("Error parsing strings"); + goto cleanup; + } + if (status == DC_STATUS_UNSUPPORTED) + break; + if (!str.desc || !str.value) + break; + fprintf (output->ostream, "\n", + str.desc, str.value); + + } + // Parse the sample data. message ("Parsing the sample data.\n"); status = dc_parser_samples_foreach (parser, sample_cb, &sampledata); diff --git a/include/libdivecomputer/parser.h b/include/libdivecomputer/parser.h index 98827f1..965deda 100644 --- a/include/libdivecomputer/parser.h +++ b/include/libdivecomputer/parser.h @@ -62,9 +62,13 @@ typedef enum dc_field_type_t { DC_FIELD_TEMPERATURE_MAXIMUM, DC_FIELD_TANK_COUNT, DC_FIELD_TANK, - DC_FIELD_DIVEMODE + DC_FIELD_DIVEMODE, + DC_FIELD_STRING, } dc_field_type_t; +// Make it easy to test support compile-time with "#ifdef DC_FIELD_STRING" +#define DC_FIELD_STRING DC_FIELD_STRING + typedef enum parser_sample_event_t { SAMPLE_EVENT_NONE, SAMPLE_EVENT_DECOSTOP, @@ -199,6 +203,11 @@ typedef struct dc_tank_t { double endpressure; /* End pressure (bar) */ } dc_tank_t; +typedef struct dc_field_string_t { + const char *desc; + const char *value; +} dc_field_string_t; + typedef union dc_sample_value_t { unsigned int time; double depth;