]> git.datanom.net - lensdb.git/blob - src/main.c
Fix segmentation fault
[lensdb.git] / src / main.c
1 /*
2 * main.c
3 *
4 * Copyright 2024 Michael Rasmussen <mir@datanom.net>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 * MA 02110-1301, USA.
20 *
21 *
22 */
23
24 #ifdef HAVE_CONFIG_H
25 # include <config.h>
26 #endif
27 #include <gtk/gtk.h>
28 #include <glib.h>
29 #include <glib/gstdio.h>
30 #include <glib-object.h>
31 #include <stdio.h>
32 #include "sqlite-storage.h"
33 #include "gui.h"
34 #include "lib/scanner.h"
35
36 gint main(gint argc, gchar** argv) {
37 gint status = 0;
38
39 //gchar* path = g_path_get_dirname(argv[0]);
40 gchar* path = g_build_filename(g_get_user_config_dir(), PACKAGE, NULL); //g_strconcat(g_get_home_dir(), "/.local/share/", PACKAGE, NULL);
41 if (!g_file_test(path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
42 if (g_mkdir(path, 0766)) {
43 fprintf(stderr, "%s: Failed to create dir for database\n", path);
44 return EXIT_FAILURE;
45 }
46 }
47 fprintf(stdout, "workdir: %s\n", path);
48 if ((status = init_storage(path)) > 0) {
49 fprintf(stderr, "%s: Failed to open DB\n", path);
50 } else {
51 gtk_init(&argc, &argv);
52 if (init_gui()) {
53 gchar* err = g_strdup_printf("Failed initializing GUI\n");
54 fprintf(stderr, err);
55 show_err_msg(GTK_MESSAGE_ERROR, err);
56 g_free(err);
57 return EXIT_FAILURE;
58 }
59 }
60 g_free(path);
61 close_storage();
62
63 return status;
64 }
This page took 0.49278 seconds and 6 git commands to generate.