]> git.datanom.net - lensdb.git/blob - src/main.c
Handle length of NULL strings
[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 "csv.h"
35 #include "lib/scanner.h"
36
37 gint main(gint argc, gchar** argv) {
38 gint status = 0;
39 gchar* path = g_build_filename(g_get_user_config_dir(), PACKAGE, NULL);
40 if (!g_file_test(path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
41 if (g_mkdir(path, 0766)) {
42 fprintf(stderr, "%s: Failed to create dir for database\n", path);
43 g_free(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 g_free(path);
54 close_storage();
55 gchar* err = g_strdup_printf("Failed initializing GUI\n");
56 fprintf(stderr, err);
57 show_message(GTK_MESSAGE_ERROR, err);
58 g_free(err);
59 return EXIT_FAILURE;
60 }
61 }
62 g_free(path);
63 close_storage();
64
65 return status;
66 }
This page took 0.620259 seconds and 6 git commands to generate.