diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-07-14 18:20:55 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-07-14 18:20:55 +0000 |
commit | e43155e9ea536991a489e0fe04890e0269869af1 (patch) | |
tree | b6488239217f7c00d7dc109641292b4ba5092ded /src/identity/gnunet-identity.c | |
parent | 206b8c58b7e6843ddb4832692b11032d4fe57541 (diff) | |
download | gnunet-e43155e9ea536991a489e0fe04890e0269869af1.tar.gz gnunet-e43155e9ea536991a489e0fe04890e0269869af1.zip |
-skeleton for identity service
Diffstat (limited to 'src/identity/gnunet-identity.c')
-rw-r--r-- | src/identity/gnunet-identity.c | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/src/identity/gnunet-identity.c b/src/identity/gnunet-identity.c new file mode 100644 index 000000000..77ba6c2cd --- /dev/null +++ b/src/identity/gnunet-identity.c | |||
@@ -0,0 +1,106 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2013 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @file identity/gnunet-identity.c | ||
22 | * @brief IDENTITY monitoring command line tool | ||
23 | * @author Christian Grothoff | ||
24 | */ | ||
25 | #include "platform.h" | ||
26 | #include "gnunet_util_lib.h" | ||
27 | #include "gnunet_identity_service.h" | ||
28 | |||
29 | /** | ||
30 | * Handle to IDENTITY service. | ||
31 | */ | ||
32 | static struct GNUNET_IDENTITY_Handle *sh; | ||
33 | |||
34 | /** | ||
35 | * Was verbose specified? | ||
36 | */ | ||
37 | static int verbose; | ||
38 | |||
39 | |||
40 | /** | ||
41 | * Task run on shutdown. | ||
42 | * | ||
43 | * @param cls NULL | ||
44 | * @param tc unused | ||
45 | */ | ||
46 | static void | ||
47 | shutdown_task (void *cls, | ||
48 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
49 | { | ||
50 | GNUNET_IDENTITY_disconnect (sh); | ||
51 | sh = NULL; | ||
52 | } | ||
53 | |||
54 | |||
55 | /** | ||
56 | * Main function that will be run by the scheduler. | ||
57 | * | ||
58 | * @param cls closure | ||
59 | * @param args remaining command-line arguments | ||
60 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) | ||
61 | * @param cfg configuration | ||
62 | */ | ||
63 | static void | ||
64 | run (void *cls, char *const *args, const char *cfgfile, | ||
65 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
66 | { | ||
67 | sh = GNUNET_IDENTITY_connect (cfg, NULL, NULL); | ||
68 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | ||
69 | &shutdown_task, NULL); | ||
70 | } | ||
71 | |||
72 | |||
73 | /** | ||
74 | * The main function. | ||
75 | * | ||
76 | * @param argc number of arguments from the command line | ||
77 | * @param argv command line arguments | ||
78 | * @return 0 ok, 1 on error | ||
79 | */ | ||
80 | int | ||
81 | main (int argc, char *const *argv) | ||
82 | { | ||
83 | int res; | ||
84 | |||
85 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
86 | {'V', "verbose", NULL, | ||
87 | gettext_noop ("verbose output"), | ||
88 | 0, &GNUNET_GETOPT_set_one, &verbose}, | ||
89 | GNUNET_GETOPT_OPTION_END | ||
90 | }; | ||
91 | |||
92 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | ||
93 | return 2; | ||
94 | |||
95 | res = GNUNET_PROGRAM_run (argc, argv, "gnunet-identity", | ||
96 | gettext_noop ("Print information about IDENTITY state"), | ||
97 | options, &run, | ||
98 | NULL); | ||
99 | GNUNET_free ((void *) argv); | ||
100 | |||
101 | if (GNUNET_OK != res) | ||
102 | return 1; | ||
103 | return 0; | ||
104 | } | ||
105 | |||
106 | /* end of gnunet-identity.c */ | ||