diff options
author | Thiago Macieira <thiago@macieira.org> | 2013-12-19 17:03:24 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-12-20 09:53:05 -0800 |
commit | 64f24234ab268aae601880a6f8a0fa9d2b4ce4d4 (patch) | |
tree | 8498af47284c18569887fb380c995454c4d5080f /qt-ui/subsurfacewebservices.cpp | |
parent | de47937dd1b5d84ce84c668dc3508651f86ec5bb (diff) | |
download | subsurface-64f24234ab268aae601880a6f8a0fa9d2b4ce4d4.tar.gz |
Move the variable initialisations closer to use and add blanks
Makes the code easier to read, IMHO.
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/subsurfacewebservices.cpp')
-rw-r--r-- | qt-ui/subsurfacewebservices.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp index bcc5ae3f9..b78b57b01 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/qt-ui/subsurfacewebservices.cpp @@ -106,15 +106,7 @@ bool DivelogsDeWebServices::prepare_dives_for_divelogs(const QString &tempfile, return false; } - int i; - struct dive *dive; - FILE *f; - char filename[PATH_MAX]; - int streamsize; - char *membuf; xsltStylesheetPtr xslt = NULL; - xmlDoc *transformed; - struct zip_source *s[dive_table.nr]; struct zip *zip; xslt = get_stylesheet("divelogs-export.xslt"); @@ -135,8 +127,19 @@ bool DivelogsDeWebServices::prepare_dives_for_divelogs(const QString &tempfile, } /* walk the dive list in chronological order */ - for (i = 0; i < dive_table.nr; i++) { - dive = get_dive(i); + for (int i = 0; i < dive_table.nr; i++) { + FILE *f; + char filename[PATH_MAX]; + int streamsize; + char *membuf; + xmlDoc *transformed; + struct zip_source *s[dive_table.nr]; + + /* + * Get the i'th dive in XML format so we can process it. + * We need to save to a file before we can reload it back into memory... + */ + struct dive *dive = get_dive(i); if (!dive) continue; if (selected && !dive->selected) @@ -150,6 +153,7 @@ bool DivelogsDeWebServices::prepare_dives_for_divelogs(const QString &tempfile, fseek(f, 0, SEEK_END); streamsize = ftell(f); rewind(f); + membuf = (char *)malloc(streamsize + 1); if (!membuf || !fread(membuf, streamsize, 1, f)) { *errorMsg = tr("internal error: %1").arg(qt_error_string()); @@ -159,6 +163,7 @@ bool DivelogsDeWebServices::prepare_dives_for_divelogs(const QString &tempfile, } membuf[streamsize] = 0; fclose(f); + /* * Parse the memory buffer into XML document and * transform it to divelogs.de format, finally dumping @@ -172,10 +177,12 @@ bool DivelogsDeWebServices::prepare_dives_for_divelogs(const QString &tempfile, goto error_close_zip; } free((void *)membuf); + transformed = xsltApplyStylesheet(xslt, doc, NULL); xmlDocDumpMemory(transformed, (xmlChar **) &membuf, &streamsize); xmlFreeDoc(doc); xmlFreeDoc(transformed); + /* * Save the XML document into a zip file. */ |