Whitespace cleanup for parse-xml.c and save-xml.c

This is looking really good. Done using our whitespace tool.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-02-16 15:42:56 -08:00
parent 42f32671a8
commit e80a6822d5
2 changed files with 270 additions and 263 deletions

View file

@ -68,7 +68,7 @@ static void record_dive_to_table(struct dive *dive, struct dive_table *table)
table->allocated = allocated; table->allocated = allocated;
} }
dives[nr] = fixup_dive(dive); dives[nr] = fixup_dive(dive);
table->nr = nr+1; table->nr = nr + 1;
} }
void record_dive(struct dive *dive) void record_dive(struct dive *dive)
@ -80,14 +80,14 @@ static void start_match(const char *type, const char *name, char *buffer)
{ {
if (verbose > 2) if (verbose > 2)
printf("Matching %s '%s' (%s)\n", printf("Matching %s '%s' (%s)\n",
type, name, buffer); type, name, buffer);
} }
static void nonmatch(const char *type, const char *name, char *buffer) static void nonmatch(const char *type, const char *name, char *buffer)
{ {
if (verbose > 1) if (verbose > 1)
printf("Unable to match %s '%s' (%s)\n", printf("Unable to match %s '%s' (%s)\n",
type, name, buffer); type, name, buffer);
} }
typedef void (*matchfn_t)(char *buffer, void *); typedef void (*matchfn_t)(char *buffer, void *);
@ -97,7 +97,8 @@ static int match(const char *pattern, int plen,
matchfn_t fn, char *buf, void *data) matchfn_t fn, char *buf, void *data)
{ {
switch (name[plen]) { switch (name[plen]) {
case '\0': case '.': case '\0':
case '.':
break; break;
default: default:
return 0; return 0;
@ -127,11 +128,11 @@ static struct {
const char *name; const char *name;
} cur_event; } cur_event;
static struct { static struct {
struct { struct {
const char *model; const char *model;
uint32_t deviceid; uint32_t deviceid;
const char *nickname, *serial_nr, *firmware; const char *nickname, *serial_nr, *firmware;
} dc; } dc;
} cur_settings; } cur_settings;
static bool in_settings = false; static bool in_settings = false;
static struct tm cur_tm; static struct tm cur_tm;
@ -145,7 +146,7 @@ static int lastcylinderindex, lastsensor;
*/ */
static struct divecomputer *get_dc(void) static struct divecomputer *get_dc(void)
{ {
return cur_dc ? : &cur_dive->dc; return cur_dc ?: &cur_dive->dc;
} }
static enum import_source { static enum import_source {
@ -157,11 +158,13 @@ static enum import_source {
static void divedate(char *buffer, void *_when) static void divedate(char *buffer, void *_when)
{ {
int d,m,y; int d, m, y;
int hh,mm,ss; int hh, mm, ss;
timestamp_t *when = _when; timestamp_t *when = _when;
hh = 0; mm = 0; ss = 0; hh = 0;
mm = 0;
ss = 0;
if (sscanf(buffer, "%d.%d.%d %d:%d:%d", &d, &m, &y, &hh, &mm, &ss) >= 3) { if (sscanf(buffer, "%d.%d.%d %d:%d:%d", &d, &m, &y, &hh, &mm, &ss) >= 3) {
/* This is ok, and we got at least the date */ /* This is ok, and we got at least the date */
} else if (sscanf(buffer, "%d-%d-%d %d:%d:%d", &y, &m, &d, &hh, &mm, &ss) >= 3) { } else if (sscanf(buffer, "%d-%d-%d %d:%d:%d", &y, &m, &d, &hh, &mm, &ss) >= 3) {
@ -171,7 +174,7 @@ static void divedate(char *buffer, void *_when)
return; return;
} }
cur_tm.tm_year = y; cur_tm.tm_year = y;
cur_tm.tm_mon = m-1; cur_tm.tm_mon = m - 1;
cur_tm.tm_mday = d; cur_tm.tm_mday = d;
cur_tm.tm_hour = hh; cur_tm.tm_hour = hh;
cur_tm.tm_min = mm; cur_tm.tm_min = mm;
@ -182,7 +185,7 @@ static void divedate(char *buffer, void *_when)
static void divetime(char *buffer, void *_when) static void divetime(char *buffer, void *_when)
{ {
int h,m,s = 0; int h, m, s = 0;
timestamp_t *when = _when; timestamp_t *when = _when;
if (sscanf(buffer, "%d:%d:%d", &h, &m, &s) >= 2) { if (sscanf(buffer, "%d:%d:%d", &h, &m, &s) >= 2) {
@ -196,14 +199,14 @@ static void divetime(char *buffer, void *_when)
/* Libdivecomputer: "2011-03-20 10:22:38" */ /* Libdivecomputer: "2011-03-20 10:22:38" */
static void divedatetime(char *buffer, void *_when) static void divedatetime(char *buffer, void *_when)
{ {
int y,m,d; int y, m, d;
int hr,min,sec; int hr, min, sec;
timestamp_t *when = _when; timestamp_t *when = _when;
if (sscanf(buffer, "%d-%d-%d %d:%d:%d", if (sscanf(buffer, "%d-%d-%d %d:%d:%d",
&y, &m, &d, &hr, &min, &sec) == 6) { &y, &m, &d, &hr, &min, &sec) == 6) {
cur_tm.tm_year = y; cur_tm.tm_year = y;
cur_tm.tm_mon = m-1; cur_tm.tm_mon = m - 1;
cur_tm.tm_mday = d; cur_tm.tm_mday = d;
cur_tm.tm_hour = hr; cur_tm.tm_hour = hr;
cur_tm.tm_min = min; cur_tm.tm_min = min;
@ -212,7 +215,10 @@ static void divedatetime(char *buffer, void *_when)
} }
} }
enum ParseState {FINDSTART, FINDEND}; enum ParseState {
FINDSTART,
FINDEND
};
static void divetags(char *buffer, void *_tags) static void divetags(char *buffer, void *_tags)
{ {
struct tag_entry *tags = _tags; struct tag_entry *tags = _tags;
@ -220,18 +226,18 @@ static void divetags(char *buffer, void *_tags)
enum ParseState state = FINDEND; enum ParseState state = FINDEND;
int len = buffer ? strlen(buffer) : 0; int len = buffer ? strlen(buffer) : 0;
while(i < len) { while (i < len) {
if (buffer[i] == ',') { if (buffer[i] == ',') {
if (state == FINDSTART) { if (state == FINDSTART) {
/* Detect empty tags */ /* Detect empty tags */
} else if (state == FINDEND) { } else if (state == FINDEND) {
/* Found end of tag */ /* Found end of tag */
if (i > 0 && buffer[i - 1] != '\\') { if (i > 0 && buffer[i - 1] != '\\') {
buffer[i] = '\0'; buffer[i] = '\0';
state=FINDSTART; state = FINDSTART;
taglist_add_tag(tags, buffer+start); taglist_add_tag(tags, buffer + start);
} else { } else {
state=FINDSTART; state = FINDSTART;
} }
} }
} else if (buffer[i] == ' ') { } else if (buffer[i] == ' ') {
@ -413,7 +419,7 @@ static void temperature(char *buffer, void *_temperature)
} }
/* temperatures outside -40C .. +70C should be ignored */ /* temperatures outside -40C .. +70C should be ignored */
if (temperature->mkelvin < ZERO_C_IN_MKELVIN - 40000 || if (temperature->mkelvin < ZERO_C_IN_MKELVIN - 40000 ||
temperature->mkelvin > ZERO_C_IN_MKELVIN + 70000) temperature->mkelvin > ZERO_C_IN_MKELVIN + 70000)
temperature->mkelvin = 0; temperature->mkelvin = 0;
} }
@ -430,7 +436,7 @@ static void sampletime(char *buffer, void *_time)
min = 0; min = 0;
/* fallthrough */ /* fallthrough */
case 2: case 2:
time->seconds = sec + min*60; time->seconds = sec + min * 60;
break; break;
default: default:
printf("Strange sample time reading %s\n", buffer); printf("Strange sample time reading %s\n", buffer);
@ -442,9 +448,9 @@ static void duration(char *buffer, void *_time)
/* DivingLog 5.08 (and maybe other versions) appear to sometimes /* DivingLog 5.08 (and maybe other versions) appear to sometimes
* store the dive time as 44.00 instead of 44:00; * store the dive time as 44.00 instead of 44:00;
* This attempts to parse this in a fairly robust way */ * This attempts to parse this in a fairly robust way */
if (!strchr(buffer,':') && strchr(buffer,'.')) { if (!strchr(buffer, ':') && strchr(buffer, '.')) {
char *mybuffer = strdup(buffer); char *mybuffer = strdup(buffer);
char *dot = strchr(mybuffer,'.'); char *dot = strchr(mybuffer, '.');
*dot = ':'; *dot = ':';
sampletime(mybuffer, _time); sampletime(mybuffer, _time);
free(mybuffer); free(mybuffer);
@ -475,7 +481,7 @@ static void percent(char *buffer, void *_fraction)
break; break;
} }
default: default:
printf(translate("gettextFromC","Strange percentage reading %s\n"), buffer); printf(translate("gettextFromC", "Strange percentage reading %s\n"), buffer);
break; break;
} }
} }
@ -517,7 +523,7 @@ static void utf8_string(char *buffer, void *_res)
while (isspace(*buffer)) while (isspace(*buffer))
buffer++; buffer++;
size = strlen(buffer); size = strlen(buffer);
while (size && isspace(buffer[size-1])) while (size && isspace(buffer[size - 1]))
size--; size--;
if (!size) if (!size)
return; return;
@ -528,7 +534,7 @@ static void utf8_string(char *buffer, void *_res)
} }
#define MATCH(pattern, fn, dest) \ #define MATCH(pattern, fn, dest) \
match(pattern, strlen(pattern), name, fn, buf, dest) match(pattern, strlen(pattern), name, fn, buf, dest)
static void get_index(char *buffer, void *_i) static void get_index(char *buffer, void *_i)
{ {
@ -644,11 +650,11 @@ static void psi_or_bar(char *buffer, void *_pressure)
static int divinglog_fill_sample(struct sample *sample, const char *name, char *buf) static int divinglog_fill_sample(struct sample *sample, const char *name, char *buf)
{ {
return MATCH("time.p", sampletime, &sample->time) || return MATCH("time.p", sampletime, &sample->time) ||
MATCH("depth.p", depth, &sample->depth) || MATCH("depth.p", depth, &sample->depth) ||
MATCH("temp.p", fahrenheit, &sample->temperature) || MATCH("temp.p", fahrenheit, &sample->temperature) ||
MATCH("press1.p", psi_or_bar, &sample->cylinderpressure) || MATCH("press1.p", psi_or_bar, &sample->cylinderpressure) ||
0; 0;
} }
static void uddf_gasswitch(char *buffer, void *_sample) static void uddf_gasswitch(char *buffer, void *_sample)
@ -664,12 +670,12 @@ static void uddf_gasswitch(char *buffer, void *_sample)
static int uddf_fill_sample(struct sample *sample, const char *name, char *buf) static int uddf_fill_sample(struct sample *sample, const char *name, char *buf)
{ {
return MATCH("divetime", sampletime, &sample->time) || return MATCH("divetime", sampletime, &sample->time) ||
MATCH("depth", depth, &sample->depth) || MATCH("depth", depth, &sample->depth) ||
MATCH("temperature", temperature, &sample->temperature) || MATCH("temperature", temperature, &sample->temperature) ||
MATCH("tankpressure", pressure, &sample->cylinderpressure) || MATCH("tankpressure", pressure, &sample->cylinderpressure) ||
MATCH("ref.switchmix", uddf_gasswitch, sample) || MATCH("ref.switchmix", uddf_gasswitch, sample) ||
0; 0;
} }
static void eventtime(char *buffer, void *_duration) static void eventtime(char *buffer, void *_duration)
@ -790,11 +796,11 @@ void add_gas_switch_event(struct dive *dive, struct divecomputer *dc, int second
int he = get_he(&dive->cylinder[idx].gasmix); int he = get_he(&dive->cylinder[idx].gasmix);
int value; int value;
o2 = (o2+5) / 10; o2 = (o2 + 5) / 10;
he = (he+5) / 10; he = (he + 5) / 10;
value = o2 + (he << 16); value = o2 + (he << 16);
add_event(dc, seconds, 25, 0, value, "gaschange"); /* SAMPLE_EVENT_GASCHANGE2 */ add_event(dc, seconds, 25, 0, value, "gaschange"); /* SAMPLE_EVENT_GASCHANGE2 */
} }
static void get_cylinderindex(char *buffer, void *_i) static void get_cylinderindex(char *buffer, void *_i)
@ -884,15 +890,15 @@ static void divinglog_place(char *place, void *_location)
int len; int len;
len = snprintf(buffer, sizeof(buffer), len = snprintf(buffer, sizeof(buffer),
"%s%s%s%s%s", "%s%s%s%s%s",
place, place,
city ? ", " : "", city ? ", " : "",
city ? city : "", city ? city : "",
country ? ", " : "", country ? ", " : "",
country ? country : ""); country ? country : "");
p = malloc(len+1); p = malloc(len + 1);
memcpy(p, buffer, len+1); memcpy(p, buffer, len + 1);
*location = p; *location = p;
city = NULL; city = NULL;
@ -901,22 +907,22 @@ static void divinglog_place(char *place, void *_location)
static int divinglog_dive_match(struct dive *dive, const char *name, char *buf) static int divinglog_dive_match(struct dive *dive, const char *name, char *buf)
{ {
return MATCH("divedate", divedate, &dive->when) || return MATCH("divedate", divedate, &dive->when) ||
MATCH("entrytime", divetime, &dive->when) || MATCH("entrytime", divetime, &dive->when) ||
MATCH("divetime", duration, &dive->dc.duration) || MATCH("divetime", duration, &dive->dc.duration) ||
MATCH("depth", depth, &dive->dc.maxdepth) || MATCH("depth", depth, &dive->dc.maxdepth) ||
MATCH("depthavg", depth, &dive->dc.meandepth) || MATCH("depthavg", depth, &dive->dc.meandepth) ||
MATCH("tanktype", utf8_string, &dive->cylinder[0].type.description) || MATCH("tanktype", utf8_string, &dive->cylinder[0].type.description) ||
MATCH("tanksize", cylindersize, &dive->cylinder[0].type.size) || MATCH("tanksize", cylindersize, &dive->cylinder[0].type.size) ||
MATCH("presw", pressure, &dive->cylinder[0].type.workingpressure) || MATCH("presw", pressure, &dive->cylinder[0].type.workingpressure) ||
MATCH("press", pressure, &dive->cylinder[0].start) || MATCH("press", pressure, &dive->cylinder[0].start) ||
MATCH("prese", pressure, &dive->cylinder[0].end) || MATCH("prese", pressure, &dive->cylinder[0].end) ||
MATCH("comments", utf8_string, &dive->notes) || MATCH("comments", utf8_string, &dive->notes) ||
MATCH("names.buddy", utf8_string, &dive->buddy) || MATCH("names.buddy", utf8_string, &dive->buddy) ||
MATCH("name.country", utf8_string, &country) || MATCH("name.country", utf8_string, &country) ||
MATCH("name.city", utf8_string, &city) || MATCH("name.city", utf8_string, &city) ||
MATCH("name.place", divinglog_place, &dive->location) || MATCH("name.place", divinglog_place, &dive->location) ||
0; 0;
} }
/* /*
@ -927,7 +933,7 @@ static int divinglog_dive_match(struct dive *dive, const char *name, char *buf)
static void uddf_datetime(char *buffer, void *_when) static void uddf_datetime(char *buffer, void *_when)
{ {
char c; char c;
int y,m,d,hh,mm,ss; int y, m, d, hh, mm, ss;
timestamp_t *when = _when; timestamp_t *when = _when;
struct tm tm = { 0 }; struct tm tm = { 0 };
int i; int i;
@ -961,11 +967,13 @@ success:
*when = utc_mktime(&tm); *when = utc_mktime(&tm);
} }
#define uddf_datedata(name, offset) \ #define uddf_datedata(name, offset) \
static void uddf_##name(char *buffer, void *_when) \ static void uddf_##name(char *buffer, void *_when) \
{ timestamp_t *when = _when; \ { \
cur_tm.tm_##name = atoi(buffer) + offset; \ timestamp_t *when = _when; \
*when = utc_mktime(&cur_tm); } cur_tm.tm_##name = atoi(buffer) + offset; \
*when = utc_mktime(&cur_tm); \
}
uddf_datedata(year, 0) uddf_datedata(year, 0)
uddf_datedata(mon, -1) uddf_datedata(mon, -1)
@ -975,15 +983,15 @@ uddf_datedata(min, 0)
static int uddf_dive_match(struct dive *dive, const char *name, char *buf) static int uddf_dive_match(struct dive *dive, const char *name, char *buf)
{ {
return MATCH("datetime", uddf_datetime, &dive->when) || return MATCH("datetime", uddf_datetime, &dive->when) ||
MATCH("diveduration", duration, &dive->dc.duration) || MATCH("diveduration", duration, &dive->dc.duration) ||
MATCH("greatestdepth", depth, &dive->dc.maxdepth) || MATCH("greatestdepth", depth, &dive->dc.maxdepth) ||
MATCH("year.date", uddf_year, &dive->when) || MATCH("year.date", uddf_year, &dive->when) ||
MATCH("month.date", uddf_mon, &dive->when) || MATCH("month.date", uddf_mon, &dive->when) ||
MATCH("day.date", uddf_mday, &dive->when) || MATCH("day.date", uddf_mday, &dive->when) ||
MATCH("hour.time", uddf_hour, &dive->when) || MATCH("hour.time", uddf_hour, &dive->when) ||
MATCH("minute.time", uddf_min, &dive->when) || MATCH("minute.time", uddf_min, &dive->when) ||
0; 0;
} }
/* /*
@ -1001,12 +1009,12 @@ static degrees_t parse_degrees(char *buf, char **end)
switch (*buf) { switch (*buf) {
case '-': case '-':
sign = -1; sign = -1;
/* fallthrough */ /* fallthrough */
case '+': case '+':
buf++; buf++;
} }
while (isdigit(*buf)) { while (isdigit(*buf)) {
value = 10*value + *buf - '0'; value = 10 * value + *buf - '0';
buf++; buf++;
} }
@ -1300,8 +1308,8 @@ static void event_end(void)
if (cur_event.name) { if (cur_event.name) {
if (strcmp(cur_event.name, "surface") != 0) if (strcmp(cur_event.name, "surface") != 0)
add_event(dc, cur_event.time.seconds, add_event(dc, cur_event.time.seconds,
cur_event.type, cur_event.flags, cur_event.type, cur_event.flags,
cur_event.value, cur_event.name); cur_event.value, cur_event.name);
free((void *)cur_event.name); free((void *)cur_event.name);
} }
cur_event.active = 0; cur_event.active = 0;
@ -1425,7 +1433,7 @@ static const char *nodename(xmlNode *node, char *buf, int len)
/* Make sure it's always NUL-terminated */ /* Make sure it's always NUL-terminated */
p[--len] = 0; p[--len] = 0;
for(;;) { for (;;) {
const char *name = node->name; const char *name = node->name;
char c; char c;
while ((c = *name++) != 0) { while ((c = *name++) != 0) {
@ -1514,29 +1522,28 @@ static struct nesting {
const char *name; const char *name;
void (*start)(void), (*end)(void); void (*start)(void), (*end)(void);
} nesting[] = { } nesting[] = {
{ "divecomputerid", dc_settings_start, dc_settings_end }, { "divecomputerid", dc_settings_start, dc_settings_end },
{ "settings", settings_start, settings_end }, { "settings", settings_start, settings_end },
{ "dive", dive_start, dive_end }, { "dive", dive_start, dive_end },
{ "Dive", dive_start, dive_end }, { "Dive", dive_start, dive_end },
{ "trip", trip_start, trip_end }, { "trip", trip_start, trip_end },
{ "sample", sample_start, sample_end }, { "sample", sample_start, sample_end },
{ "waypoint", sample_start, sample_end }, { "waypoint", sample_start, sample_end },
{ "SAMPLE", sample_start, sample_end }, { "SAMPLE", sample_start, sample_end },
{ "reading", sample_start, sample_end }, { "reading", sample_start, sample_end },
{ "event", event_start, event_end }, { "event", event_start, event_end },
{ "mix", cylinder_start, cylinder_end }, { "mix", cylinder_start, cylinder_end },
{ "gasmix", cylinder_start, cylinder_end }, { "gasmix", cylinder_start, cylinder_end },
{ "cylinder", cylinder_start, cylinder_end }, { "cylinder", cylinder_start, cylinder_end },
{ "weightsystem", ws_start, ws_end }, { "weightsystem", ws_start, ws_end },
{ "divecomputer", divecomputer_start, divecomputer_end }, { "divecomputer", divecomputer_start, divecomputer_end },
{ "P", sample_start, sample_end }, { "P", sample_start, sample_end },
/* Import type recognition */ /* Import type recognition */
{ "Divinglog", DivingLog_importer }, { "Divinglog", DivingLog_importer },
{ "uddf", uddf_importer }, { "uddf", uddf_importer },
{ NULL, }
{ NULL, } };
};
static void traverse(xmlNode *root) static void traverse(xmlNode *root)
{ {
@ -1596,7 +1603,7 @@ const char *preprocess_divelog_de(const char *buffer)
return buffer; return buffer;
ctx = xmlCreateMemoryParserCtxt(buf, sizeof(buf)); ctx = xmlCreateMemoryParserCtxt(buf, sizeof(buf));
ret = xmlStringLenDecodeEntities(ctx, ret, strlen(ret), XML_SUBSTITUTE_REF, 0, 0, 0); ret = xmlStringLenDecodeEntities(ctx, ret, strlen(ret), XML_SUBSTITUTE_REF, 0, 0, 0);
return ret; return ret;
} }
@ -1604,7 +1611,7 @@ const char *preprocess_divelog_de(const char *buffer)
} }
void parse_xml_buffer(const char *url, const char *buffer, int size, void parse_xml_buffer(const char *url, const char *buffer, int size,
struct dive_table *table, const char **params, char **error) struct dive_table *table, const char **params, char **error)
{ {
xmlDoc *doc; xmlDoc *doc;
const char *res = preprocess_divelog_de(buffer); const char *res = preprocess_divelog_de(buffer);
@ -1615,8 +1622,8 @@ void parse_xml_buffer(const char *url, const char *buffer, int size,
free((char *)res); free((char *)res);
if (!doc) { if (!doc) {
fprintf(stderr, translate("gettextFromC","Failed to parse '%s'.\n"), url); fprintf(stderr, translate("gettextFromC", "Failed to parse '%s'.\n"), url);
parser_error(error, translate("gettextFromC","Failed to parse '%s'"), url); parser_error(error, translate("gettextFromC", "Failed to parse '%s'"), url);
return; return;
} }
reset_all(); reset_all();
@ -1635,92 +1642,92 @@ extern int dm4_events(void *handle, int columns, char **data, char **column)
if (data[2]) { if (data[2]) {
switch (atoi(data[2])) { switch (atoi(data[2])) {
case 1: case 1:
/* 1 Mandatory Safety Stop */ /* 1 Mandatory Safety Stop */
cur_event.name = strdup("safety stop (mandatory)"); cur_event.name = strdup("safety stop (mandatory)");
break; break;
case 3: case 3:
/* 3 Deco */ /* 3 Deco */
/* What is Subsurface's term for going to /* What is Subsurface's term for going to
* deco? */ * deco? */
cur_event.name = strdup("deco"); cur_event.name = strdup("deco");
break; break;
case 4: case 4:
/* 4 Ascent warning */ /* 4 Ascent warning */
cur_event.name = strdup("ascent"); cur_event.name = strdup("ascent");
break; break;
case 5: case 5:
/* 5 Ceiling broken */ /* 5 Ceiling broken */
cur_event.name = strdup("violation"); cur_event.name = strdup("violation");
break; break;
case 6: case 6:
/* 6 Mandatory safety stop ceiling error */ /* 6 Mandatory safety stop ceiling error */
cur_event.name = strdup("violation"); cur_event.name = strdup("violation");
break; break;
case 7: case 7:
/* 7 Below deco floor */ /* 7 Below deco floor */
cur_event.name = strdup("below floor"); cur_event.name = strdup("below floor");
break; break;
case 8: case 8:
/* 8 Dive time alarm */ /* 8 Dive time alarm */
cur_event.name = strdup("divetime"); cur_event.name = strdup("divetime");
break; break;
case 9: case 9:
/* 9 Depth alarm */ /* 9 Depth alarm */
cur_event.name = strdup("maxdepth"); cur_event.name = strdup("maxdepth");
break; break;
case 10: case 10:
/* 10 OLF 80% */ /* 10 OLF 80% */
case 11: case 11:
/* 11 OLF 100% */ /* 11 OLF 100% */
cur_event.name = strdup("OLF"); cur_event.name = strdup("OLF");
break; break;
case 12: case 12:
/* 12 High ppO2 */ /* 12 High ppO2 */
cur_event.name = strdup("PO2"); cur_event.name = strdup("PO2");
break; break;
case 13: case 13:
/* 13 Air time */ /* 13 Air time */
cur_event.name = strdup("airtime"); cur_event.name = strdup("airtime");
break; break;
case 17: case 17:
/* 17 Ascent warning */ /* 17 Ascent warning */
cur_event.name = strdup("ascent"); cur_event.name = strdup("ascent");
break; break;
case 18: case 18:
/* 18 Ceiling error */ /* 18 Ceiling error */
cur_event.name = strdup("ceiling"); cur_event.name = strdup("ceiling");
break; break;
case 19: case 19:
/* 19 Surfaced */ /* 19 Surfaced */
cur_event.name = strdup("surface"); cur_event.name = strdup("surface");
break; break;
case 20: case 20:
/* 20 Deco */ /* 20 Deco */
cur_event.name = strdup("deco"); cur_event.name = strdup("deco");
break; break;
case 22: case 22:
/* 22 Mandatory safety stop violation */ /* 22 Mandatory safety stop violation */
cur_event.name = strdup("violation"); cur_event.name = strdup("violation");
break; break;
case 257: case 257:
/* 257 Dive active */ /* 257 Dive active */
/* This seems to be given after surface /* This seems to be given after surface
* when descending again. Ignoring it. */ * when descending again. Ignoring it. */
break; break;
case 258: case 258:
/* 258 Bookmark */ /* 258 Bookmark */
if (data[3]) { if (data[3]) {
cur_event.name = strdup("heading"); cur_event.name = strdup("heading");
cur_event.value = atoi(data[3]); cur_event.value = atoi(data[3]);
} else { } else {
cur_event.name = strdup("bookmark"); cur_event.name = strdup("bookmark");
} }
break; break;
default: default:
cur_event.name = strdup("unknown"); cur_event.name = strdup("unknown");
cur_event.value = atoi(data[2]); cur_event.value = atoi(data[2]);
break; break;
} }
} }
event_end(); event_end();
@ -1786,7 +1793,7 @@ extern int dm4_dive(void *param, int columns, char **data, char **column)
if (data[8]) if (data[8])
cur_dive->dc.airtemp.mkelvin = C_to_mkelvin(atoi(data[8])); cur_dive->dc.airtemp.mkelvin = C_to_mkelvin(atoi(data[8]));
if (data[9]) if (data[9])
cur_dive->dc.watertemp.mkelvin = C_to_mkelvin(atoi(data[9])); cur_dive->dc.watertemp.mkelvin = C_to_mkelvin(atoi(data[9]));
/* /*
* TODO: handle multiple cylinders * TODO: handle multiple cylinders
@ -1817,7 +1824,7 @@ extern int dm4_dive(void *param, int columns, char **data, char **column)
profileBlob = (float *)data[17]; profileBlob = (float *)data[17];
tempBlob = (unsigned char *)data[18]; tempBlob = (unsigned char *)data[18];
pressureBlob = (int *)data[19]; pressureBlob = (int *)data[19];
for (i=0; interval && i * interval < cur_dive->duration.seconds; i++) { for (i = 0; interval && i * interval < cur_dive->duration.seconds; i++) {
sample_start(); sample_start();
cur_sample->time.seconds = i * interval; cur_sample->time.seconds = i * interval;
if (profileBlob) if (profileBlob)
@ -1828,21 +1835,21 @@ extern int dm4_dive(void *param, int columns, char **data, char **column)
if (data[18] && data[18][0]) if (data[18] && data[18][0])
cur_sample->temperature.mkelvin = C_to_mkelvin(tempBlob[i]); cur_sample->temperature.mkelvin = C_to_mkelvin(tempBlob[i]);
if (data[19] && data[19][0]) if (data[19] && data[19][0])
cur_sample->cylinderpressure.mbar = pressureBlob[i] ; cur_sample->cylinderpressure.mbar = pressureBlob[i];
sample_end(); sample_end();
} }
snprintf(get_events, sizeof(get_events) - 1, get_events_template, cur_dive->number); snprintf(get_events, sizeof(get_events) - 1, get_events_template, cur_dive->number);
retval = sqlite3_exec(handle, get_events, &dm4_events, 0, &err); retval = sqlite3_exec(handle, get_events, &dm4_events, 0, &err);
if (retval != SQLITE_OK) { if (retval != SQLITE_OK) {
fprintf(stderr, "%s", translate("gettextFromC","Database query get_events failed.\n")); fprintf(stderr, "%s", translate("gettextFromC", "Database query get_events failed.\n"));
return 1; return 1;
} }
snprintf(get_events, sizeof(get_events) - 1, get_tags_template, cur_dive->number); snprintf(get_events, sizeof(get_events) - 1, get_tags_template, cur_dive->number);
retval = sqlite3_exec(handle, get_events, &dm4_tags, 0, &err); retval = sqlite3_exec(handle, get_events, &dm4_tags, 0, &err);
if (retval != SQLITE_OK) { if (retval != SQLITE_OK) {
fprintf(stderr, "%s", translate("gettextFromC","Database query get_tags failed.\n")); fprintf(stderr, "%s", translate("gettextFromC", "Database query get_tags failed.\n"));
return 1; return 1;
} }
@ -1863,7 +1870,7 @@ extern int dm4_dive(void *param, int columns, char **data, char **column)
} }
int parse_dm4_buffer(sqlite3 *handle, const char *url, const char *buffer, int size, int parse_dm4_buffer(sqlite3 *handle, const char *url, const char *buffer, int size,
struct dive_table *table, char **error) struct dive_table *table, char **error)
{ {
int retval; int retval;
char *err = NULL; char *err = NULL;
@ -1876,7 +1883,7 @@ int parse_dm4_buffer(sqlite3 *handle, const char *url, const char *buffer, int s
retval = sqlite3_exec(handle, get_dives, &dm4_dive, handle, &err); retval = sqlite3_exec(handle, get_dives, &dm4_dive, handle, &err);
if (retval != SQLITE_OK) { if (retval != SQLITE_OK) {
fprintf(stderr, translate("gettextFromC","Database query failed '%s'.\n"), url); fprintf(stderr, translate("gettextFromC", "Database query failed '%s'.\n"), url);
return 1; return 1;
} }
@ -1925,7 +1932,7 @@ extern int shearwater_profile_sample(void *handle, int columns, char **data, cha
if (data[5]) if (data[5])
cur_sample->cns = atoi(data[5]); cur_sample->cns = atoi(data[5]);
if (data[6]) if (data[6])
cur_sample->stopdepth.mm = metric ? atoi(data[6]) * 1000 : feet_to_mm(atoi(data[6])); cur_sample->stopdepth.mm = metric ? atoi(data[6]) * 1000 : feet_to_mm(atoi(data[6]));
/* We don't actually have data[3], but it should appear in the /* We don't actually have data[3], but it should appear in the
* SQL query at some point. * SQL query at some point.
@ -1987,21 +1994,21 @@ extern int shearwater_dive(void *param, int columns, char **data, char **column)
snprintf(get_buffer, sizeof(get_buffer) - 1, get_cylinder_template, cur_dive->number); snprintf(get_buffer, sizeof(get_buffer) - 1, get_cylinder_template, cur_dive->number);
retval = sqlite3_exec(handle, get_buffer, &shearwater_cylinders, 0, &err); retval = sqlite3_exec(handle, get_buffer, &shearwater_cylinders, 0, &err);
if (retval != SQLITE_OK) { if (retval != SQLITE_OK) {
fprintf(stderr, "%s", translate("gettextFromC","Database query get_cylinders failed.\n")); fprintf(stderr, "%s", translate("gettextFromC", "Database query get_cylinders failed.\n"));
return 1; return 1;
} }
snprintf(get_buffer, sizeof(get_buffer) - 1, get_changes_template, cur_dive->number, cur_dive->number); snprintf(get_buffer, sizeof(get_buffer) - 1, get_changes_template, cur_dive->number, cur_dive->number);
retval = sqlite3_exec(handle, get_buffer, &shearwater_changes, 0, &err); retval = sqlite3_exec(handle, get_buffer, &shearwater_changes, 0, &err);
if (retval != SQLITE_OK) { if (retval != SQLITE_OK) {
fprintf(stderr, "%s", translate("gettextFromC","Database query get_changes failed.\n")); fprintf(stderr, "%s", translate("gettextFromC", "Database query get_changes failed.\n"));
return 1; return 1;
} }
snprintf(get_buffer, sizeof(get_buffer) - 1, get_profile_template, cur_dive->number); snprintf(get_buffer, sizeof(get_buffer) - 1, get_profile_template, cur_dive->number);
retval = sqlite3_exec(handle, get_buffer, &shearwater_profile_sample, 0, &err); retval = sqlite3_exec(handle, get_buffer, &shearwater_profile_sample, 0, &err);
if (retval != SQLITE_OK) { if (retval != SQLITE_OK) {
fprintf(stderr, "%s", translate("gettextFromC","Database query get_profile_sample failed.\n")); fprintf(stderr, "%s", translate("gettextFromC", "Database query get_profile_sample failed.\n"));
return 1; return 1;
} }
@ -2012,7 +2019,7 @@ extern int shearwater_dive(void *param, int columns, char **data, char **column)
int parse_shearwater_buffer(sqlite3 *handle, const char *url, const char *buffer, int size, int parse_shearwater_buffer(sqlite3 *handle, const char *url, const char *buffer, int size,
struct dive_table *table, char **error) struct dive_table *table, char **error)
{ {
int retval; int retval;
char *err = NULL; char *err = NULL;
@ -2023,7 +2030,7 @@ int parse_shearwater_buffer(sqlite3 *handle, const char *url, const char *buffer
retval = sqlite3_exec(handle, get_dives, &shearwater_dive, handle, &err); retval = sqlite3_exec(handle, get_dives, &shearwater_dive, handle, &err);
if (retval != SQLITE_OK) { if (retval != SQLITE_OK) {
fprintf(stderr, translate("gettextFromC","Database query failed '%s'.\n"), url); fprintf(stderr, translate("gettextFromC", "Database query failed '%s'.\n"), url);
return 1; return 1;
} }
@ -2045,21 +2052,21 @@ static struct xslt_files {
const char *file; const char *file;
const char *attribute; const char *attribute;
} xslt_files[] = { } xslt_files[] = {
{ "SUUNTO", "SuuntoSDM.xslt", NULL }, { "SUUNTO", "SuuntoSDM.xslt", NULL },
{ "Dive", "SuuntoDM4.xslt", "xmlns" }, { "Dive", "SuuntoDM4.xslt", "xmlns" },
{ "Dive", "shearwater.xslt", "version" }, { "Dive", "shearwater.xslt", "version" },
{ "JDiveLog", "jdivelog2subsurface.xslt", NULL }, { "JDiveLog", "jdivelog2subsurface.xslt", NULL },
{ "dives", "MacDive.xslt", NULL }, { "dives", "MacDive.xslt", NULL },
{ "DIVELOGSDATA", "divelogs.xslt", NULL }, { "DIVELOGSDATA", "divelogs.xslt", NULL },
{ "uddf", "uddf.xslt", NULL }, { "uddf", "uddf.xslt", NULL },
{ "UDDF", "uddf.xslt", NULL }, { "UDDF", "uddf.xslt", NULL },
{ "profile", "udcf.xslt", NULL }, { "profile", "udcf.xslt", NULL },
{ "Divinglog", "DivingLog.xslt", NULL }, { "Divinglog", "DivingLog.xslt", NULL },
{ "csv", "csv2xml.xslt", NULL }, { "csv", "csv2xml.xslt", NULL },
{ "sensuscsv", "sensuscsv.xslt", NULL }, { "sensuscsv", "sensuscsv.xslt", NULL },
{ "manualcsv", "manualcsv2xml.xslt", NULL }, { "manualcsv", "manualcsv2xml.xslt", NULL },
{ NULL, } { NULL, }
}; };
static xmlDoc *test_xslt_transforms(xmlDoc *doc, const char **params, char **error) static xmlDoc *test_xslt_transforms(xmlDoc *doc, const char **params, char **error)
{ {
@ -2092,7 +2099,7 @@ static xmlDoc *test_xslt_transforms(xmlDoc *doc, const char **params, char **err
xmlSubstituteEntitiesDefault(1); xmlSubstituteEntitiesDefault(1);
xslt = get_stylesheet(info->file); xslt = get_stylesheet(info->file);
if (xslt == NULL) { if (xslt == NULL) {
parser_error(error, translate("gettextFromC","Can't open stylesheet %s"), info->file); parser_error(error, translate("gettextFromC", "Can't open stylesheet %s"), info->file);
return doc; return doc;
} }
transformed = xsltApplyStylesheet(xslt, doc, params); transformed = xsltApplyStylesheet(xslt, doc, params);

View file

@ -34,7 +34,8 @@ static void quote(struct membuffer *b, const char *text, int is_attribute)
escape = NULL; escape = NULL;
break; break;
case 1 ... 8: case 1 ... 8:
case 11: case 12: case 11:
case 12:
case 14 ... 31: case 14 ... 31:
escape = "?"; escape = "?";
break; break;
@ -77,7 +78,7 @@ static void show_utf8(struct membuffer *b, const char *text, const char *pre, co
len = strlen(text); len = strlen(text);
if (!len) if (!len)
return; return;
while (len && isspace(text[len-1])) while (len && isspace(text[len - 1]))
len--; len--;
/* FIXME! Quoting! */ /* FIXME! Quoting! */
put_string(b, pre); put_string(b, pre);
@ -156,16 +157,16 @@ static int format_degrees(char *buffer, degrees_t value)
udeg = -udeg; udeg = -udeg;
} }
return sprintf(buffer, "%s%u.%06u", return sprintf(buffer, "%s%u.%06u",
sign, udeg / 1000000, udeg % 1000000); sign, udeg / 1000000, udeg % 1000000);
} }
static int format_location(char *buffer, degrees_t latitude, degrees_t longitude) static int format_location(char *buffer, degrees_t latitude, degrees_t longitude)
{ {
int len = sprintf(buffer, "gps='"); int len = sprintf(buffer, "gps='");
len += format_degrees(buffer+len, latitude); len += format_degrees(buffer + len, latitude);
buffer[len++] = ' '; buffer[len++] = ' ';
len += format_degrees(buffer+len, longitude); len += format_degrees(buffer + len, longitude);
buffer[len++] = '\''; buffer[len++] = '\'';
return len; return len;
@ -187,9 +188,9 @@ static void show_location(struct membuffer *b, struct dive *dive)
if (latitude.udeg || longitude.udeg) { if (latitude.udeg || longitude.udeg) {
int len = sprintf(buffer, " <location "); int len = sprintf(buffer, " <location ");
len += format_location(buffer+len, latitude, longitude); len += format_location(buffer + len, latitude, longitude);
if (!dive->location) { if (!dive->location) {
memcpy(buffer+len, "/>\n", 4); memcpy(buffer + len, "/>\n", 4);
put_string(b, buffer); put_string(b, buffer);
return; return;
} }
@ -197,16 +198,16 @@ static void show_location(struct membuffer *b, struct dive *dive)
buffer[len] = 0; buffer[len] = 0;
prefix = buffer; prefix = buffer;
} }
show_utf8(b, dive->location, prefix,"</location>\n", 0); show_utf8(b, dive->location, prefix, "</location>\n", 0);
} }
static void save_overview(struct membuffer *b, struct dive *dive) static void save_overview(struct membuffer *b, struct dive *dive)
{ {
show_location(b, dive); show_location(b, dive);
show_utf8(b, dive->divemaster, " <divemaster>","</divemaster>\n", 0); show_utf8(b, dive->divemaster, " <divemaster>", "</divemaster>\n", 0);
show_utf8(b, dive->buddy, " <buddy>","</buddy>\n", 0); show_utf8(b, dive->buddy, " <buddy>", "</buddy>\n", 0);
show_utf8(b, dive->notes, " <notes>","</notes>\n", 0); show_utf8(b, dive->notes, " <notes>", "</notes>\n", 0);
show_utf8(b, dive->suit, " <suit>","</suit>\n", 0); show_utf8(b, dive->suit, " <suit>", "</suit>\n", 0);
} }
static int nr_cylinders(struct dive *dive) static int nr_cylinders(struct dive *dive)
@ -214,7 +215,7 @@ static int nr_cylinders(struct dive *dive)
int nr; int nr;
for (nr = MAX_CYLINDERS; nr; --nr) { for (nr = MAX_CYLINDERS; nr; --nr) {
cylinder_t *cylinder = dive->cylinder+nr-1; cylinder_t *cylinder = dive->cylinder + nr - 1;
if (!cylinder_nodata(cylinder)) if (!cylinder_nodata(cylinder))
break; break;
} }
@ -228,7 +229,7 @@ static void save_cylinder_info(struct membuffer *b, struct dive *dive)
nr = nr_cylinders(dive); nr = nr_cylinders(dive);
for (i = 0; i < nr; i++) { for (i = 0; i < nr; i++) {
cylinder_t *cylinder = dive->cylinder+i; cylinder_t *cylinder = dive->cylinder + i;
int volume = cylinder->type.size.mliter; int volume = cylinder->type.size.mliter;
const char *description = cylinder->type.description; const char *description = cylinder->type.description;
int o2 = cylinder->gasmix.o2.permille; int o2 = cylinder->gasmix.o2.permille;
@ -255,7 +256,7 @@ static int nr_weightsystems(struct dive *dive)
int nr; int nr;
for (nr = MAX_WEIGHTSYSTEMS; nr; --nr) { for (nr = MAX_WEIGHTSYSTEMS; nr; --nr) {
weightsystem_t *ws = dive->weightsystem+nr-1; weightsystem_t *ws = dive->weightsystem + nr - 1;
if (!weightsystem_none(ws)) if (!weightsystem_none(ws))
break; break;
} }
@ -269,7 +270,7 @@ static void save_weightsystem_info(struct membuffer *b, struct dive *dive)
nr = nr_weightsystems(dive); nr = nr_weightsystems(dive);
for (i = 0; i < nr; i++) { for (i = 0; i < nr; i++) {
weightsystem_t *ws = dive->weightsystem+i; weightsystem_t *ws = dive->weightsystem + i;
int grams = ws->weight.grams; int grams = ws->weight.grams;
const char *description = ws->description; const char *description = ws->description;
@ -288,7 +289,7 @@ static void show_index(struct membuffer *b, int value, const char *pre, const ch
static void save_sample(struct membuffer *b, struct sample *sample, struct sample *old) static void save_sample(struct membuffer *b, struct sample *sample, struct sample *old)
{ {
put_format(b, " <sample time='%u:%02u min'", FRACTION(sample->time.seconds,60)); put_format(b, " <sample time='%u:%02u min'", FRACTION(sample->time.seconds, 60));
put_milli(b, " depth='", sample->depth.mm, " m'"); put_milli(b, " depth='", sample->depth.mm, " m'");
put_temperature(b, sample->temperature, " temp='", " C'"); put_temperature(b, sample->temperature, " temp='", " C'");
put_pressure(b, sample->cylinderpressure, " pressure='", " bar'"); put_pressure(b, sample->cylinderpressure, " pressure='", " bar'");
@ -337,7 +338,7 @@ static void save_sample(struct membuffer *b, struct sample *sample, struct sampl
static void save_one_event(struct membuffer *b, struct event *ev) static void save_one_event(struct membuffer *b, struct event *ev)
{ {
put_format(b, " <event time='%d:%02d min'", FRACTION(ev->time.seconds,60)); put_format(b, " <event time='%d:%02d min'", FRACTION(ev->time.seconds, 60));
show_index(b, ev->type, "type='", "'"); show_index(b, ev->type, "type='", "'");
show_index(b, ev->flags, "flags='", "'"); show_index(b, ev->flags, "flags='", "'");
show_index(b, ev->value, "value='", "'"); show_index(b, ev->value, "value='", "'");
@ -385,14 +386,14 @@ static void show_date(struct membuffer *b, timestamp_t when)
utc_mkdate(when, &tm); utc_mkdate(when, &tm);
put_format(b, " date='%04u-%02u-%02u'", put_format(b, " date='%04u-%02u-%02u'",
tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday); tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
put_format(b, " time='%02u:%02u:%02u'", put_format(b, " time='%02u:%02u:%02u'",
tm.tm_hour, tm.tm_min, tm.tm_sec); tm.tm_hour, tm.tm_min, tm.tm_sec);
} }
static void save_samples(struct membuffer *b, int nr, struct sample *s) static void save_samples(struct membuffer *b, int nr, struct sample *s)
{ {
struct sample dummy = { }; struct sample dummy = {};
while (--nr >= 0) { while (--nr >= 0) {
save_sample(b, s, &dummy); save_sample(b, s, &dummy);
@ -443,7 +444,7 @@ void save_one_dive(struct membuffer *b, struct dive *dive)
show_date(b, dive->when); show_date(b, dive->when);
put_format(b, " duration='%u:%02u min'>\n", put_format(b, " duration='%u:%02u min'>\n",
FRACTION(dive->dc.duration.seconds, 60)); FRACTION(dive->dc.duration.seconds, 60));
save_overview(b, dive); save_overview(b, dive);
save_cylinder_info(b, dive); save_cylinder_info(b, dive);
save_weightsystem_info(b, dive); save_weightsystem_info(b, dive);
@ -460,7 +461,7 @@ void save_one_dive(struct membuffer *b, struct dive *dive)
void save_dive(FILE *f, struct dive *dive) void save_dive(FILE *f, struct dive *dive)
{ {
struct membuffer buf = {0}; struct membuffer buf = { 0 };
save_one_dive(&buf, dive); save_one_dive(&buf, dive);
flush_buffer(&buf, f); flush_buffer(&buf, f);
@ -473,9 +474,9 @@ static void save_trip(struct membuffer *b, dive_trip_t *trip)
put_format(b, "<trip"); put_format(b, "<trip");
show_date(b, trip->when); show_date(b, trip->when);
show_utf8(b, trip->location, " location=\'","\'", 1); show_utf8(b, trip->location, " location=\'", "\'", 1);
put_format(b, ">\n"); put_format(b, ">\n");
show_utf8(b, trip->notes, "<notes>","</notes>\n", 0); show_utf8(b, trip->notes, "<notes>", "</notes>\n", 0);
/* /*
* Incredibly cheesy: we want to save the dives sorted, and they * Incredibly cheesy: we want to save the dives sorted, and they
@ -491,7 +492,7 @@ static void save_trip(struct membuffer *b, dive_trip_t *trip)
put_format(b, "</trip>\n"); put_format(b, "</trip>\n");
} }
static void save_one_device(void *_f, const char * model, uint32_t deviceid, static void save_one_device(void *_f, const char *model, uint32_t deviceid,
const char *nickname, const char *serial_nr, const char *firmware) const char *nickname, const char *serial_nr, const char *firmware)
{ {
struct membuffer *b = _f; struct membuffer *b = _f;
@ -549,10 +550,9 @@ void save_dives_buffer(struct membuffer *b, const bool select_only)
/* save the dives */ /* save the dives */
for_each_dive(i, dive) { for_each_dive(i, dive) {
if (select_only) { if (select_only) {
if(!dive->selected) if (!dive->selected)
continue; continue;
save_one_dive(b, dive); save_one_dive(b, dive);
@ -587,10 +587,10 @@ static void save_backup(const char *name, const char *ext, const char *new_ext)
len -= a; len -= a;
if (len <= 1) if (len <= 1)
return; return;
if (name[len-1] != '.') if (name[len - 1] != '.')
return; return;
/* msvc doesn't have strncasecmp, has _strnicmp instead - crazy */ /* msvc doesn't have strncasecmp, has _strnicmp instead - crazy */
if (strncasecmp(name+len, ext, a)) if (strncasecmp(name + len, ext, a))
return; return;
newname = malloc(len + b + 1); newname = malloc(len + b + 1);
@ -598,7 +598,7 @@ static void save_backup(const char *name, const char *ext, const char *new_ext)
return; return;
memcpy(newname, name, len); memcpy(newname, name, len);
memcpy(newname+len, new_ext, b+1); memcpy(newname + len, new_ext, b + 1);
/* /*
* Ignore errors. Maybe we can't create the backup file, * Ignore errors. Maybe we can't create the backup file,
@ -611,9 +611,9 @@ static void save_backup(const char *name, const char *ext, const char *new_ext)
void save_dives_logic(const char *filename, const bool select_only) void save_dives_logic(const char *filename, const bool select_only)
{ {
struct membuffer buf = {0}; struct membuffer buf = { 0 };
FILE *f; FILE *f;
char extension[][5] = {"xml", "ssrf", ""}; char extension[][5] = { "xml", "ssrf", "" };
int i = 0; int i = 0;
int flen = strlen(filename); int flen = strlen(filename);
@ -638,7 +638,7 @@ void save_dives_logic(const char *filename, const bool select_only)
void export_dives_uddf(const char *filename, const bool selected) void export_dives_uddf(const char *filename, const bool selected)
{ {
FILE *f; FILE *f;
struct membuffer buf = {0}; struct membuffer buf = { 0 };
xmlDoc *doc; xmlDoc *doc;
xsltStylesheetPtr xslt = NULL; xsltStylesheetPtr xslt = NULL;
xmlDoc *transformed; xmlDoc *transformed;