aboutsummaryrefslogtreecommitdiff
path: root/src/hostlist/gnunet-daemon-hostlist.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-06-12 00:34:47 +0000
committerChristian Grothoff <christian@grothoff.org>2009-06-12 00:34:47 +0000
commit4c72fa477ad226660df116c6275283833a3f5214 (patch)
tree9bab2c50101a44dc37c1f908a0488c58edbaf734 /src/hostlist/gnunet-daemon-hostlist.c
parent42c8b584e6e8554329ca6282545b775b63af9c39 (diff)
downloadgnunet-4c72fa477ad226660df116c6275283833a3f5214.tar.gz
gnunet-4c72fa477ad226660df116c6275283833a3f5214.zip
removing dead code / unused variables
Diffstat (limited to 'src/hostlist/gnunet-daemon-hostlist.c')
-rw-r--r--src/hostlist/gnunet-daemon-hostlist.c137
1 files changed, 137 insertions, 0 deletions
diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c
new file mode 100644
index 000000000..0fb77ecbd
--- /dev/null
+++ b/src/hostlist/gnunet-daemon-hostlist.c
@@ -0,0 +1,137 @@
1/*
2 This file is part of GNUnet.
3 (C) 2007, 2008, 2009 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 2, 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/**
22 * @file hostlist/gnunet-daemon-hostlist.c
23 * @brief code for bootstrapping via hostlist servers
24 * @author Christian Grothoff
25 */
26
27#include <stdlib.h>
28#include "platform.h"
29#include "gnunet_getopt_lib.h"
30#include "gnunet_protocols.h"
31#include "gnunet_program_lib.h"
32#include "gnunet_statistics_service.h"
33#include "gnunet_strings_lib.h"
34#include "gnunet_time_lib.h"
35
36
37/**
38 * Set if we are allowed to learn about peers by accessing
39 * hostlist servers.
40 */
41static int bootstrapping;
42
43/**
44 * Set if the user allows us to learn about new hostlists
45 * from the network.
46 */
47static int learning;
48
49/**
50 * Set if the user wants us to run a hostlist server.
51 */
52static int provide_hostlist;
53
54
55/**
56 * gnunet-daemon-hostlist command line options.
57 */
58static struct GNUNET_GETOPT_CommandLineOption options[] = {
59 { 'b', "bootstrap", NULL, gettext_noop ("bootstrap using hostlists (it is highly recommended that you always use this option)"),
60 GNUNET_NO, &GNUNET_GETOPT_set_one, &bootstrapping },
61 { 'e', "enable-learning", NULL, gettext_noop ("enable learning about hostlist servers from other peers"),
62 GNUNET_NO, &GNUNET_GETOPT_set_one, &learning},
63 { 'p', "provide-hostlist", NULL, gettext_noop ("provide a hostlist server"),
64 GNUNET_NO, &GNUNET_GETOPT_set_one, &provide_hostlist},
65 GNUNET_GETOPT_OPTION_END
66};
67
68
69
70/**
71 * Main function that will be run.
72 *
73 * @param cls closure
74 * @param sched the scheduler to use
75 * @param args remaining command-line arguments
76 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
77 * @param cfg configuration
78 */
79static void
80run (void *cls,
81 struct GNUNET_SCHEDULER_Handle * sched,
82 char *const *args,
83 const char *cfgfile,
84 struct GNUNET_CONFIGURATION_Handle * cfg)
85{
86 if ( (! bootstrapping) &&
87 (! learning) &&
88 (! provide_hostlist) )
89 {
90 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
91 _("None of the functions for the hostlist daemon were enabled. I have no reason to run!\n"));
92 return;
93 }
94 if (learning)
95 {
96 // FIXME!
97 // (register handler with core for hostlist ads)
98 }
99 if (bootstrapping)
100 {
101 // FIXME!
102 // (register handler with core to monitor number of active
103 // connections; trigger hostlist download via CURL if
104 // number is low)
105 }
106 if (provide_hostlist)
107 {
108 // FIXME!
109 // (initialize MHD server and run using scheduler;
110 // use peerinfo to gather HELLOs)
111 }
112}
113
114
115/**
116 * The main function for the hostlist daemon.
117 *
118 * @param argc number of arguments from the command line
119 * @param argv command line arguments
120 * @return 0 ok, 1 on error
121 */
122int
123main (int argc, char *const *argv)
124{
125 int ret;
126
127 ret = (GNUNET_OK ==
128 GNUNET_PROGRAM_run (argc,
129 argv,
130 "hostlist",
131 _("GNUnet hostlist server and client"),
132 options,
133 &run, NULL)) ? 0 : 1;
134 return ret;
135}
136
137/* end of gnunet-daemon-hostlist.c */