| 
									
										
										
										
											2017-04-27 20:13:48 +02:00
										 |  |  | // SPDX-License-Identifier: GPL-2.0
 | 
					
						
							| 
									
										
										
										
											2015-11-08 18:50:05 +01:00
										 |  |  | #include <stdlib.h>
 | 
					
						
							|  |  |  | #include <stdio.h>
 | 
					
						
							| 
									
										
										
										
											2016-06-15 20:59:34 +02:00
										 |  |  | #include "core/dive.h"
 | 
					
						
							| 
									
										
										
										
											2020-05-01 13:43:52 +02:00
										 |  |  | #include "core/divelist.h"
 | 
					
						
							| 
									
										
										
										
											2015-11-08 18:50:05 +01:00
										 |  |  | #include "smrtk2ssrfc_window.h"
 | 
					
						
							|  |  |  | #include <QApplication>
 | 
					
						
							|  |  |  | #include <QDebug>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern "C" void smartrak_import(const char *file, struct dive_table *table); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Simple command line interface to call directly smartrak_import() or launch | 
					
						
							|  |  |  |  * the GUI if called without arguments. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int main(int argc, char *argv[]) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	char *infile, *outfile; | 
					
						
							|  |  |  | 	int i; | 
					
						
							| 
									
										
										
										
											2017-06-07 11:00:38 +02:00
										 |  |  | #ifndef COMMANDLINE
 | 
					
						
							| 
									
										
										
										
											2015-11-08 18:50:05 +01:00
										 |  |  | 	QApplication a(argc, argv); | 
					
						
							|  |  |  | 	Smrtk2ssrfcWindow w; | 
					
						
							| 
									
										
										
										
											2017-06-07 11:00:38 +02:00
										 |  |  | #else
 | 
					
						
							|  |  |  | 	QCoreApplication a(argc, argv); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2015-11-08 18:50:05 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	switch (argc) { | 
					
						
							|  |  |  | 	case 1: | 
					
						
							| 
									
										
										
										
											2017-06-07 11:00:38 +02:00
										 |  |  | #ifndef COMMANDLINE
 | 
					
						
							| 
									
										
										
										
											2015-11-08 18:50:05 +01:00
										 |  |  | 		w.show(); | 
					
						
							|  |  |  | 		return a.exec(); | 
					
						
							| 
									
										
										
										
											2017-06-07 11:00:38 +02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2015-11-08 18:50:05 +01:00
										 |  |  | 		break; | 
					
						
							|  |  |  | 	case 2: | 
					
						
							|  |  |  | 		qDebug() << "\nUsage:\n"; | 
					
						
							|  |  |  | 		qDebug() << "Smrtk2ssrfc importer can be used without arguments (in a graphical UI)"; | 
					
						
							|  |  |  | 		qDebug() << "or with, at least, two arguments (in a CLI, the file to be imported and"; | 
					
						
							|  |  |  | 		qDebug() << "the file to store the Subsurface formatted dives), so you have to use one"; | 
					
						
							|  |  |  | 		qDebug() << "of these examples:\n"; | 
					
						
							|  |  |  | 		qDebug() << "$smrtk2ssrfc"; | 
					
						
							|  |  |  | 		qDebug() << "or"; | 
					
						
							|  |  |  | 		qDebug() << "$smrtk2ssrfc /input/file.slg[ file_2[ file_n]] /output/file.xml\n\n"; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		outfile = argv[argc - 1]; | 
					
						
							|  |  |  | 		qDebug() << "\n[Importing]\n"; | 
					
						
							|  |  |  | 		for(i = 1; i < argc -1; i++) { | 
					
						
							|  |  |  | 			infile = argv[i]; | 
					
						
							|  |  |  | 			qDebug() << "\t" << infile << "\n"; | 
					
						
							|  |  |  | 			smartrak_import(infile, &dive_table); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		qDebug() << "\n[Writing]\n\t" << outfile << "\n"; | 
					
						
							| 
									
										
										
										
											2018-09-10 14:47:56 +02:00
										 |  |  | 		save_dives_logic(outfile, false, false); | 
					
						
							| 
									
										
										
										
											2015-11-08 18:50:05 +01:00
										 |  |  | 		break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } |