Extend field-cache infrastructure to support the Suunto EON Steel
This adds a few misc fields that the EON Steel wants, and changes the string insertion interface to return a 'dc_status_t', which will be used by that back-end. The existing deepblu users don't care. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
f73b6836ad
commit
842592fb55
@ -13,7 +13,7 @@
|
||||
* dynamically on the stack or whatever without having to
|
||||
* worry about it.
|
||||
*/
|
||||
void dc_field_add_string(dc_field_cache_t *cache, const char *desc, const char *value)
|
||||
dc_status_t dc_field_add_string(dc_field_cache_t *cache, const char *desc, const char *value)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -22,23 +22,33 @@ void dc_field_add_string(dc_field_cache_t *cache, const char *desc, const char *
|
||||
dc_field_string_t *str = cache->strings+i;
|
||||
if (str->desc)
|
||||
continue;
|
||||
str->desc = desc;
|
||||
str->value = strdup(value);
|
||||
break;
|
||||
if (!str->value)
|
||||
return DC_STATUS_NOMEMORY;
|
||||
str->desc = desc;
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
return DC_STATUS_INVALIDARGS;
|
||||
}
|
||||
|
||||
void dc_field_add_string_fmt(dc_field_cache_t *cache, const char *desc, const char *fmt, ...)
|
||||
dc_status_t dc_field_add_string_fmt(dc_field_cache_t *cache, const char *desc, const char *fmt, ...)
|
||||
{
|
||||
char buffer[256];
|
||||
va_list ap;
|
||||
|
||||
/*
|
||||
* We ignore the return value from vsnprintf, and we
|
||||
* always NUL-terminate the destination buffer ourselves.
|
||||
*
|
||||
* That way we don't have to worry about random bad legacy
|
||||
* implementations.
|
||||
*/
|
||||
va_start(ap, fmt);
|
||||
buffer[sizeof(buffer)-1] = 0;
|
||||
(void) vsnprintf(buffer, sizeof(buffer)-1, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
dc_field_add_string(cache, desc, buffer);
|
||||
return dc_field_add_string(cache, desc, buffer);
|
||||
}
|
||||
|
||||
dc_status_t dc_field_get_string(dc_field_cache_t *cache, unsigned idx, dc_field_string_t *value)
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
typedef struct dc_field_cache {
|
||||
unsigned int initialized;
|
||||
|
||||
// DC_GET_FIELD_xyz
|
||||
unsigned int DIVETIME;
|
||||
double MAXDEPTH;
|
||||
double AVGDEPTH;
|
||||
@ -14,11 +15,24 @@ typedef struct dc_field_cache {
|
||||
dc_salinity_t SALINITY;
|
||||
dc_gasmix_t GASMIX[MAXGASES];
|
||||
|
||||
// misc - clean me up!
|
||||
double lowsetpoint;
|
||||
double highsetpoint;
|
||||
double customsetpoint;
|
||||
|
||||
// This (slong with GASMIX) should be something like
|
||||
// dc_tank_t TANK[MAXGASES]
|
||||
// but that's for later
|
||||
dc_tankinfo_t tankinfo[MAXGASES];
|
||||
double tanksize[MAXGASES];
|
||||
double tankworkingpressure[MAXGASES];
|
||||
|
||||
// DC_GET_FIELD_STRING
|
||||
dc_field_string_t strings[MAXSTRINGS];
|
||||
} dc_field_cache_t;
|
||||
|
||||
void dc_field_add_string(dc_field_cache_t *, const char *desc, const char *data);
|
||||
void dc_field_add_string_fmt(dc_field_cache_t *, const char *desc, const char *fmt, ...);
|
||||
dc_status_t dc_field_add_string(dc_field_cache_t *, const char *desc, const char *data);
|
||||
dc_status_t dc_field_add_string_fmt(dc_field_cache_t *, const char *desc, const char *fmt, ...);
|
||||
dc_status_t dc_field_get_string(dc_field_cache_t *, unsigned idx, dc_field_string_t *value);
|
||||
|
||||
/*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user