diff options
Diffstat (limited to 'src/backend/taler-merchant-dbinit.c')
-rw-r--r-- | src/backend/taler-merchant-dbinit.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/backend/taler-merchant-dbinit.c b/src/backend/taler-merchant-dbinit.c new file mode 100644 index 00000000..07731b47 --- /dev/null +++ b/src/backend/taler-merchant-dbinit.c | |||
@@ -0,0 +1,79 @@ | |||
1 | /* | ||
2 | This file is part of TALER | ||
3 | (C) 2014 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | TALER is free software; you can redistribute it and/or modify it under the | ||
6 | terms of the GNU General Public License as published by the Free Software | ||
7 | Foundation; either version 3, or (at your option) any later version. | ||
8 | |||
9 | TALER is distributed in the hope that it will be useful, but WITHOUT ANY | ||
10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
11 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
12 | |||
13 | You should have received a copy of the GNU General Public License along with | ||
14 | TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/> | ||
15 | */ | ||
16 | |||
17 | /** | ||
18 | * @file merchant/taler_merchant_dbinit.c | ||
19 | * @brief Program to initialise merchant database | ||
20 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> | ||
21 | */ | ||
22 | |||
23 | #include "platform.h" | ||
24 | #include <gnunet/gnunet_util_lib.h> | ||
25 | #include "merchant_db.h" | ||
26 | |||
27 | |||
28 | /** | ||
29 | * Global execution result | ||
30 | */ | ||
31 | static int result; | ||
32 | |||
33 | |||
34 | /** | ||
35 | * Main function that will be run by the scheduler. | ||
36 | * | ||
37 | * @param cls closure | ||
38 | * @param args remaining command-line arguments | ||
39 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) | ||
40 | * @param config configuration | ||
41 | */ | ||
42 | static void | ||
43 | run (void *cls, char *const *args, const char *cfgfile, | ||
44 | const struct GNUNET_CONFIGURATION_Handle *config) | ||
45 | { | ||
46 | PGconn *conn; | ||
47 | |||
48 | conn = MERCHANT_DB_connect (config); | ||
49 | if (NULL == conn) | ||
50 | return; | ||
51 | if (GNUNET_OK == MERCHANT_DB_initialize (conn, GNUNET_NO)) | ||
52 | result = GNUNET_OK; | ||
53 | MERCHANT_DB_disconnect (conn); | ||
54 | } | ||
55 | |||
56 | |||
57 | /** | ||
58 | * The main function | ||
59 | * | ||
60 | * @param argc number of arguments from the command line | ||
61 | * @param argv command line arguments | ||
62 | * @return 0 ok, 1 on error | ||
63 | */ | ||
64 | int | ||
65 | main (int argc, char *const *argv) | ||
66 | { | ||
67 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
68 | GNUNET_GETOPT_OPTION_END | ||
69 | }; | ||
70 | |||
71 | result = GNUNET_SYSERR; | ||
72 | if (GNUNET_OK != | ||
73 | GNUNET_PROGRAM_run (argc, argv, "taler-merchant-dbinit", | ||
74 | gettext_noop | ||
75 | ("Initialise Taler Merchant's database"), | ||
76 | options, &run, NULL)) | ||
77 | return 3; | ||
78 | return (GNUNET_OK == result) ? 0 : 1; | ||
79 | } | ||