Signed-off-by: Miika Turkia <[email protected]>
---
 parse-xml.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/parse-xml.c b/parse-xml.c
index 285c681..34cf5e2 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -2090,6 +2090,20 @@ extern int dm5_cylinders(void *handle, int columns, char 
**data, char **column)
        return 0;
 }
 
+extern int dm5_gaschange(void *handle, int columns, char **data, char **column)
+{
+       fprintf(stderr, " CAALLLLBBAACK\n");
+       event_start();
+       if (data[0])
+               cur_event.time.seconds = atoi(data[0]);
+       if (data[1]) {
+               strcpy(cur_event.name, "gaschange");
+               cur_event.value = atof(data[1]);
+       }
+       event_end();
+
+       return 0;
+}
 
 extern int dm4_tags(void *handle, int columns, char **data, char **column)
 {
@@ -2234,7 +2248,8 @@ extern int dm5_dive(void *param, int columns, char 
**data, char **column)
        char get_events_template[] = "select * from Mark where DiveId = %d";
        char get_tags_template[] = "select Text from DiveTag where DiveId = %d";
        char get_cylinders_template[] = "select * from DiveMixture where DiveId 
= %d";
-       char get_events[64];
+       char get_gaschange_template[] = "select GasChangeTime,Oxygen,Helium 
from DiveGasChange join DiveMixture on 
DiveGasChange.DiveMixtureId=DiveMixture.DiveMixtureId where DiveId = %d";
+       char get_events[512];
 
        dive_start();
        cur_dive->number = atoi(data[0]);
@@ -2333,6 +2348,15 @@ extern int dm5_dive(void *param, int columns, char 
**data, char **column)
                }
        }
 
+       snprintf(get_events, sizeof(get_events) - 1, get_gaschange_template, 
cur_dive->number);
+       fprintf(stderr, "DEBUG: %s\n", get_events);
+       retval = sqlite3_exec(handle, get_events, &dm5_gaschange, 0, &err);
+       fprintf(stderr, "DEBUG: errori: %d\n", retval);
+       if (retval != SQLITE_OK) {
+               fprintf(stderr, "%s", translate("gettextFromC", "Database query 
dm5_gaschange failed.\n"));
+               return 1;
+       }
+
        snprintf(get_events, sizeof(get_events) - 1, get_events_template, 
cur_dive->number);
        retval = sqlite3_exec(handle, get_events, &dm4_events, 0, &err);
        if (retval != SQLITE_OK) {
-- 
2.1.0

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to