parser: add DC_FIELD_STRING field type for parse-time information

This can be used to return almost arbitrary information to the dive log
application at dive parse time, by returning a number of strings (with a
descriptor) for dive state.

NOTE! The strings are supposed to be human-readable, so that the dive
log application can just show them unedited - and without understanding
them - to the user, together with the description.  So if your dive
computer supports returning a battery voltage, for example, you can
return it as a

  { "Voltage", "4.449V" }

descriptor/value string pair, and the application could then put these
string pairs together and show (somewhere) an informational line like
"Voltage: 4.449V" along with the other information you return.

Some dive log applications migth recognize particular descriptor strings
and use them specially to fill in other information (ie serial numbers,
weight and suit information etc), but in general the interface is very
much meant to be informational free-form for a human user.

So do *not* use this interface to encode things that are not human-
readable.  Serial numbers or version information that is meaningful to
humans are fine. But random encoded data structures are not.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Linus Torvalds 2014-10-22 11:23:09 -07:00 committed by Dirk Hohndel
parent 5381714d08
commit eac8e98ee7

View File

@ -59,9 +59,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,
@ -181,6 +185,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;