source: subsurface/smtk-import/smtk_standalone.cpp

Last change on this file was 6e2e363, checked in by Dirk Hohndel <dirk@…>, 5 months ago

smtk-import: partially revert and complete 6963b52d

6963b52d introduced a cmake option, COMMANDLINE to enable building a
pure command line version of smtk2ssrf importer, but then the

#define COMMANDLINE=1 forces building CLI mode.

This patch allows building GUI or CLI versions depending on selection of
the COMMANDLINE option.

Signed-off-by: Salvador Cuñat <salvador.cunat@…>

  • Property mode set to 100644
File size: 1.4 KB
Line 
1// SPDX-License-Identifier: GPL-2.0
2#include <stdlib.h>
3#include <stdio.h>
4#include "core/dive.h"
5#include "smrtk2ssrfc_window.h"
6#include <QApplication>
7#include <QDebug>
8
9extern "C" void smartrak_import(const char *file, struct dive_table *table);
10
11/*
12 * Simple command line interface to call directly smartrak_import() or launch
13 * the GUI if called without arguments.
14 */
15
16int main(int argc, char *argv[])
17{
18        char *infile, *outfile;
19        int i;
20#ifndef COMMANDLINE
21        QApplication a(argc, argv);
22        Smrtk2ssrfcWindow w;
23#else
24        QCoreApplication a(argc, argv);
25#endif
26
27        switch (argc) {
28        case 1:
29#ifndef COMMANDLINE
30                w.show();
31                return a.exec();
32#endif
33                break;
34        case 2:
35                qDebug() << "\nUsage:\n";
36                qDebug() << "Smrtk2ssrfc importer can be used without arguments (in a graphical UI)";
37                qDebug() << "or with, at least, two arguments (in a CLI, the file to be imported and";
38                qDebug() << "the file to store the Subsurface formatted dives), so you have to use one";
39                qDebug() << "of these examples:\n";
40                qDebug() << "$smrtk2ssrfc";
41                qDebug() << "or";
42                qDebug() << "$smrtk2ssrfc /input/file.slg[ file_2[ file_n]] /output/file.xml\n\n";
43                break;
44        default:
45                outfile = argv[argc - 1];
46                qDebug() << "\n[Importing]\n";
47                for(i = 1; i < argc -1; i++) {
48                        infile = argv[i];
49                        qDebug() << "\t" << infile << "\n";
50                        smartrak_import(infile, &dive_table);
51                }
52                qDebug() << "\n[Writing]\n\t" << outfile << "\n";
53                save_dives_logic(outfile, false);
54                break;
55        }
56}
Note: See TracBrowser for help on using the repository browser.