diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-06-03 08:41:00 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-06-03 08:41:00 +0000 |
commit | af4dff0ff8a129c05c75180446b691a0b2cd74c7 (patch) | |
tree | c3c02b821df02ea396e64a9b9a06ea9e9e85553b /src/hostlist/gnunet-daemon-hostlist.c | |
parent | d7cf4a2a573e31c21630c08b038c2c648e5d3785 (diff) | |
download | gnunet-af4dff0ff8a129c05c75180446b691a0b2cd74c7.tar.gz gnunet-af4dff0ff8a129c05c75180446b691a0b2cd74c7.zip |
-doxygen, code cleanup
Diffstat (limited to 'src/hostlist/gnunet-daemon-hostlist.c')
-rw-r--r-- | src/hostlist/gnunet-daemon-hostlist.c | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c index a93d7e37d..62ecc5dfd 100644 --- a/src/hostlist/gnunet-daemon-hostlist.c +++ b/src/hostlist/gnunet-daemon-hostlist.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2007, 2008, 2009 Christian Grothoff (and other contributing authors) | 3 | (C) 2007, 2008, 2009, 2014 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 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 | 6 | it under the terms of the GNU General Public License as published |
@@ -23,10 +23,8 @@ | |||
23 | * @brief code for bootstrapping via hostlist servers | 23 | * @brief code for bootstrapping via hostlist servers |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
26 | |||
27 | #include <stdlib.h> | ||
28 | #include "platform.h" | 26 | #include "platform.h" |
29 | #include "hostlist-client.h" | 27 | #include "gnunet-daemon-hostlist_client.h" |
30 | #include "gnunet_core_service.h" | 28 | #include "gnunet_core_service.h" |
31 | #include "gnunet_util_lib.h" | 29 | #include "gnunet_util_lib.h" |
32 | #include "gnunet_protocols.h" | 30 | #include "gnunet_protocols.h" |
@@ -34,7 +32,7 @@ | |||
34 | 32 | ||
35 | #if HAVE_MHD | 33 | #if HAVE_MHD |
36 | 34 | ||
37 | #include "hostlist-server.h" | 35 | #include "gnunet-daemon-hostlist_server.h" |
38 | 36 | ||
39 | /** | 37 | /** |
40 | * Set if we are allowed to advertise our hostlist to others. | 38 | * Set if we are allowed to advertise our hostlist to others. |
@@ -123,9 +121,19 @@ struct GNUNET_HOSTLIST_ADV_Message | |||
123 | }; | 121 | }; |
124 | GNUNET_NETWORK_STRUCT_END | 122 | GNUNET_NETWORK_STRUCT_END |
125 | 123 | ||
124 | |||
125 | /** | ||
126 | * Our own peer identity. | ||
127 | */ | ||
126 | static struct GNUNET_PeerIdentity me; | 128 | static struct GNUNET_PeerIdentity me; |
127 | 129 | ||
128 | 130 | ||
131 | /** | ||
132 | * Callback invoked once our connection to CORE service is up. | ||
133 | * | ||
134 | * @param cls NULL | ||
135 | * @param my_identity our peer's identity | ||
136 | */ | ||
129 | static void | 137 | static void |
130 | core_init (void *cls, | 138 | core_init (void *cls, |
131 | const struct GNUNET_PeerIdentity *my_identity) | 139 | const struct GNUNET_PeerIdentity *my_identity) |
@@ -143,7 +151,8 @@ core_init (void *cls, | |||
143 | * @return #GNUNET_OK on success | 151 | * @return #GNUNET_OK on success |
144 | */ | 152 | */ |
145 | static int | 153 | static int |
146 | advertisement_handler (void *cls, const struct GNUNET_PeerIdentity *peer, | 154 | advertisement_handler (void *cls, |
155 | const struct GNUNET_PeerIdentity *peer, | ||
147 | const struct GNUNET_MessageHeader *message) | 156 | const struct GNUNET_MessageHeader *message) |
148 | { | 157 | { |
149 | GNUNET_assert (NULL != client_adv_handler); | 158 | GNUNET_assert (NULL != client_adv_handler); |
@@ -182,7 +191,8 @@ connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
182 | * @param peer peer identity this notification is about | 191 | * @param peer peer identity this notification is about |
183 | */ | 192 | */ |
184 | static void | 193 | static void |
185 | disconnect_handler (void *cls, const struct GNUNET_PeerIdentity *peer) | 194 | disconnect_handler (void *cls, |
195 | const struct GNUNET_PeerIdentity *peer) | ||
186 | { | 196 | { |
187 | if (0 == memcmp (&me, peer, sizeof (struct GNUNET_PeerIdentity))) | 197 | if (0 == memcmp (&me, peer, sizeof (struct GNUNET_PeerIdentity))) |
188 | return; | 198 | return; |
@@ -200,13 +210,17 @@ disconnect_handler (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
200 | /** | 210 | /** |
201 | * Last task run during shutdown. Disconnects us from | 211 | * Last task run during shutdown. Disconnects us from |
202 | * the other services. | 212 | * the other services. |
213 | * | ||
214 | * @param cls NULL | ||
215 | * @param tc scheduler context | ||
203 | */ | 216 | */ |
204 | static void | 217 | static void |
205 | cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 218 | cleaning_task (void *cls, |
219 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
206 | { | 220 | { |
207 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 221 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
208 | "Hostlist daemon is shutting down\n"); | 222 | "Hostlist daemon is shutting down\n"); |
209 | if (core != NULL) | 223 | if (NULL != core) |
210 | { | 224 | { |
211 | GNUNET_CORE_disconnect (core); | 225 | GNUNET_CORE_disconnect (core); |
212 | core = NULL; | 226 | core = NULL; |
@@ -221,7 +235,7 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
221 | GNUNET_HOSTLIST_server_stop (); | 235 | GNUNET_HOSTLIST_server_stop (); |
222 | } | 236 | } |
223 | #endif | 237 | #endif |
224 | if (stats != NULL) | 238 | if (NULL != stats) |
225 | { | 239 | { |
226 | GNUNET_STATISTICS_destroy (stats, GNUNET_NO); | 240 | GNUNET_STATISTICS_destroy (stats, GNUNET_NO); |
227 | stats = NULL; | 241 | stats = NULL; |
@@ -238,7 +252,9 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
238 | * @param cfg configuration | 252 | * @param cfg configuration |
239 | */ | 253 | */ |
240 | static void | 254 | static void |
241 | run (void *cls, char *const *args, const char *cfgfile, | 255 | run (void *cls, |
256 | char *const *args, | ||
257 | const char *cfgfile, | ||
242 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 258 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
243 | { | 259 | { |
244 | static const struct GNUNET_CORE_MessageHandler learn_handlers[] = { | 260 | static const struct GNUNET_CORE_MessageHandler learn_handlers[] = { |
@@ -248,15 +264,14 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
248 | static const struct GNUNET_CORE_MessageHandler no_learn_handlers[] = { | 264 | static const struct GNUNET_CORE_MessageHandler no_learn_handlers[] = { |
249 | {NULL, 0, 0} | 265 | {NULL, 0, 0} |
250 | }; | 266 | }; |
251 | if ((!bootstrapping) && (!learning) | 267 | if ((! bootstrapping) && (! learning) |
252 | #if HAVE_MHD | 268 | #if HAVE_MHD |
253 | && (!provide_hostlist) | 269 | && (! provide_hostlist) |
254 | #endif | 270 | #endif |
255 | ) | 271 | ) |
256 | { | 272 | { |
257 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 273 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
258 | _ | 274 | _("None of the functions for the hostlist daemon were enabled. I have no reason to run!\n")); |
259 | ("None of the functions for the hostlist daemon were enabled. I have no reason to run!\n")); | ||
260 | return; | 275 | return; |
261 | } | 276 | } |
262 | stats = GNUNET_STATISTICS_create ("hostlist", cfg); | 277 | stats = GNUNET_STATISTICS_create ("hostlist", cfg); |
@@ -332,7 +347,8 @@ main (int argc, char *const *argv) | |||
332 | ret = | 347 | ret = |
333 | (GNUNET_OK == | 348 | (GNUNET_OK == |
334 | GNUNET_PROGRAM_run (argc, argv, "hostlist", | 349 | GNUNET_PROGRAM_run (argc, argv, "hostlist", |
335 | _("GNUnet hostlist server and client"), options, | 350 | _("GNUnet hostlist server and client"), |
351 | options, | ||
336 | &run, NULL)) ? 0 : 1; | 352 | &run, NULL)) ? 0 : 1; |
337 | GNUNET_free ((void*) argv); | 353 | GNUNET_free ((void*) argv); |
338 | return ret; | 354 | return ret; |