aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-dht-get.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:46:35 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:46:35 +0000
commit502af2167f7c218366666ca4944bd7cc54b5b19a (patch)
treea91fec5cc9769d260640bd91c6633cb9cf395524 /src/dht/gnunet-dht-get.c
parent03af5a603b7cc53432249d5854cd412aa90dde0d (diff)
downloadgnunet-502af2167f7c218366666ca4944bd7cc54b5b19a.tar.gz
gnunet-502af2167f7c218366666ca4944bd7cc54b5b19a.zip
indentation
Diffstat (limited to 'src/dht/gnunet-dht-get.c')
-rw-r--r--src/dht/gnunet-dht-get.c74
1 files changed, 35 insertions, 39 deletions
diff --git a/src/dht/gnunet-dht-get.c b/src/dht/gnunet-dht-get.c
index 8bedc269e..b807a798f 100644
--- a/src/dht/gnunet-dht-get.c
+++ b/src/dht/gnunet-dht-get.c
@@ -82,10 +82,10 @@ static void
82shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 82shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
83{ 83{
84 if (dht_handle != NULL) 84 if (dht_handle != NULL)
85 { 85 {
86 GNUNET_DHT_disconnect (dht_handle); 86 GNUNET_DHT_disconnect (dht_handle);
87 dht_handle = NULL; 87 dht_handle = NULL;
88 } 88 }
89} 89}
90 90
91 91
@@ -93,10 +93,10 @@ static void
93cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 93cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
94{ 94{
95 if (get_handle != NULL) 95 if (get_handle != NULL)
96 { 96 {
97 GNUNET_DHT_get_stop (get_handle); 97 GNUNET_DHT_get_stop (get_handle);
98 get_handle = NULL; 98 get_handle = NULL;
99 } 99 }
100 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); 100 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
101} 101}
102 102
@@ -120,16 +120,12 @@ void
120get_result_iterator (void *cls, 120get_result_iterator (void *cls,
121 struct GNUNET_TIME_Absolute exp, 121 struct GNUNET_TIME_Absolute exp,
122 const GNUNET_HashCode * key, 122 const GNUNET_HashCode * key,
123 const struct GNUNET_PeerIdentity * const *get_path, 123 const struct GNUNET_PeerIdentity *const *get_path,
124 const struct GNUNET_PeerIdentity * const *put_path, 124 const struct GNUNET_PeerIdentity *const *put_path,
125 enum GNUNET_BLOCK_Type type, 125 enum GNUNET_BLOCK_Type type, size_t size, const void *data)
126 size_t size,
127 const void *data)
128{ 126{
129 fprintf (stdout, "Result %d, type %d:\n%.*s\n", 127 fprintf (stdout, "Result %d, type %d:\n%.*s\n",
130 result_count, type, 128 result_count, type, (unsigned int) size, (char *) data);
131 (unsigned int) size,
132 (char *) data);
133 result_count++; 129 result_count++;
134} 130}
135 131
@@ -149,50 +145,50 @@ run (void *cls,
149{ 145{
150 struct GNUNET_TIME_Relative timeout; 146 struct GNUNET_TIME_Relative timeout;
151 GNUNET_HashCode key; 147 GNUNET_HashCode key;
148
152 cfg = c; 149 cfg = c;
153 150
154 if (query_key == NULL) 151 if (query_key == NULL)
155 { 152 {
156 if (verbose) 153 if (verbose)
157 fprintf (stderr, "Must provide key for DHT GET!\n"); 154 fprintf (stderr, "Must provide key for DHT GET!\n");
158 ret = 1; 155 ret = 1;
159 return; 156 return;
160 } 157 }
161 158
162 dht_handle = GNUNET_DHT_connect (cfg, 1); 159 dht_handle = GNUNET_DHT_connect (cfg, 1);
163 160
164 if (dht_handle == NULL) 161 if (dht_handle == NULL)
165 { 162 {
166 if (verbose) 163 if (verbose)
167 fprintf (stderr, "Couldn't connect to DHT service!\n"); 164 fprintf (stderr, "Couldn't connect to DHT service!\n");
168 ret = 1; 165 ret = 1;
169 return; 166 return;
170 } 167 }
171 else if (verbose) 168 else if (verbose)
172 fprintf (stderr, "Connected to DHT service!\n"); 169 fprintf (stderr, "Connected to DHT service!\n");
173 170
174 if (query_type == GNUNET_BLOCK_TYPE_ANY) /* Type of data not set */ 171 if (query_type == GNUNET_BLOCK_TYPE_ANY) /* Type of data not set */
175 query_type = GNUNET_BLOCK_TYPE_TEST; 172 query_type = GNUNET_BLOCK_TYPE_TEST;
176 173
177 GNUNET_CRYPTO_hash (query_key, strlen (query_key), &key); 174 GNUNET_CRYPTO_hash (query_key, strlen (query_key), &key);
178 175
179 timeout = 176 timeout =
180 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, timeout_request); 177 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, timeout_request);
181 absolute_timeout = GNUNET_TIME_relative_to_absolute (timeout); 178 absolute_timeout = GNUNET_TIME_relative_to_absolute (timeout);
182 179
183 if (verbose) 180 if (verbose)
184 fprintf (stderr, "Issuing GET request for %s!\n", query_key); 181 fprintf (stderr, "Issuing GET request for %s!\n", query_key);
185 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining 182 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining
186 (absolute_timeout), &cleanup_task, NULL); 183 (absolute_timeout), &cleanup_task, NULL);
187 get_handle = GNUNET_DHT_get_start (dht_handle, 184 get_handle = GNUNET_DHT_get_start (dht_handle,
188 timeout, 185 timeout,
189 query_type, 186 query_type,
190 &key, 187 &key,
191 DEFAULT_GET_REPLICATION, 188 DEFAULT_GET_REPLICATION,
192 GNUNET_DHT_RO_NONE, 189 GNUNET_DHT_RO_NONE,
193 NULL, 0, 190 NULL, 0,
194 NULL, 0, 191 NULL, 0, &get_result_iterator, NULL);
195 &get_result_iterator, NULL);
196 192
197} 193}
198 194