X-Git-Url: http://git.datanom.net/lensdb.git/blobdiff_plain/59849e5440d32749758396b86aacb8a11ea89862..refs/heads/0.9.5:/src/main.c diff --git a/src/main.c b/src/main.c index e69de29..468ed17 100644 --- a/src/main.c +++ b/src/main.c @@ -0,0 +1,66 @@ +/* + * main.c + * + * Copyright 2024 Michael Rasmussen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * + */ + +#ifdef HAVE_CONFIG_H +# include +#endif +#include +#include +#include +#include +#include +#include "sqlite-storage.h" +#include "gui.h" +#include "csv.h" +#include "lib/scanner.h" + +gint main(gint argc, gchar** argv) { + gint status = 0; + gchar* path = g_build_filename(g_get_user_config_dir(), PACKAGE, NULL); + if (!g_file_test(path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) { + if (g_mkdir(path, 0766)) { + fprintf(stderr, "%s: Failed to create dir for database\n", path); + g_free(path); + return EXIT_FAILURE; + } + } + fprintf(stdout, "workdir: %s\n", path); + if ((status = init_storage(path)) > 0) { + fprintf(stderr, "%s: Failed to open DB\n", path); + } else { + gtk_init(&argc, &argv); + if (init_gui()) { + g_free(path); + close_storage(); + gchar* err = g_strdup_printf("Failed initializing GUI\n"); + fprintf(stderr, err); + show_message(GTK_MESSAGE_ERROR, err); + g_free(err); + return EXIT_FAILURE; + } + } + g_free(path); + close_storage(); + + return status; +}