aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gns/gns_api.c42
-rw-r--r--src/gns/gnunet-service-gns_resolver.c10
2 files changed, 28 insertions, 24 deletions
diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c
index de5c6062a..49d224621 100644
--- a/src/gns/gns_api.c
+++ b/src/gns/gns_api.c
@@ -34,6 +34,8 @@
34#include "gnunet_gns_service.h" 34#include "gnunet_gns_service.h"
35 35
36 36
37#define LOG(kind,...) GNUNET_log_from (kind, "gns-api",__VA_ARGS__)
38
37/** 39/**
38 * Handle to a lookup request 40 * Handle to a lookup request
39 */ 41 */
@@ -189,8 +191,8 @@ static void
189reconnect (struct GNUNET_GNS_Handle *handle) 191reconnect (struct GNUNET_GNS_Handle *handle)
190{ 192{
191 GNUNET_assert (NULL == handle->client); 193 GNUNET_assert (NULL == handle->client);
192 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 194 LOG (GNUNET_ERROR_TYPE_DEBUG,
193 "Trying to connect to GNS\n"); 195 "Trying to connect to GNS\n");
194 handle->client = GNUNET_CLIENT_connect ("gns", handle->cfg); 196 handle->client = GNUNET_CLIENT_connect ("gns", handle->cfg);
195 GNUNET_assert (NULL != handle->client); 197 GNUNET_assert (NULL != handle->client);
196 process_pending_messages (handle); 198 process_pending_messages (handle);
@@ -286,9 +288,9 @@ process_pending_messages (struct GNUNET_GNS_Handle *handle)
286 if (NULL == p) 288 if (NULL == p)
287 return; /* no messages pending */ 289 return; /* no messages pending */
288 290
289 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 291 LOG (GNUNET_ERROR_TYPE_DEBUG,
290 "Trying to transmit %u bytes\n", 292 "Trying to transmit %u bytes\n",
291 (unsigned int) p->size); 293 (unsigned int) p->size);
292 handle->th = 294 handle->th =
293 GNUNET_CLIENT_notify_transmit_ready (handle->client, 295 GNUNET_CLIENT_notify_transmit_ready (handle->client,
294 p->size, 296 p->size,
@@ -318,8 +320,8 @@ transmit_pending (void *cls, size_t size, void *buf)
318 handle->th = NULL; 320 handle->th = NULL;
319 if ((0 == size) || (NULL == buf)) 321 if ((0 == size) || (NULL == buf))
320 { 322 {
321 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 323 LOG (GNUNET_ERROR_TYPE_DEBUG,
322 "Transmission to GNS service failed!\n"); 324 "Transmission to GNS service failed!\n");
323 force_reconnect (handle); 325 force_reconnect (handle);
324 return 0; 326 return 0;
325 } 327 }
@@ -343,9 +345,9 @@ transmit_pending (void *cls, size_t size, void *buf)
343 handle->in_receive = GNUNET_YES; 345 handle->in_receive = GNUNET_YES;
344 } 346 }
345 } 347 }
346 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 348 LOG (GNUNET_ERROR_TYPE_DEBUG,
347 "Sending %u bytes\n", 349 "Sending %u bytes\n",
348 (unsigned int) tsize); 350 (unsigned int) tsize);
349 process_pending_messages (handle); 351 process_pending_messages (handle);
350 return tsize; 352 return tsize;
351} 353}
@@ -381,15 +383,15 @@ process_lookup_reply (struct GNUNET_GNS_LookupRequest *qe,
381 rd_count, 383 rd_count,
382 rd)) 384 rd))
383 { 385 {
384 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 386 LOG (GNUNET_ERROR_TYPE_ERROR,
385 _("Failed to serialize lookup reply from GNS service!\n")); 387 _("Failed to serialize lookup reply from GNS service!\n"));
386 qe->lookup_proc (qe->proc_cls, 0, NULL); 388 qe->lookup_proc (qe->proc_cls, 0, NULL);
387 } 389 }
388 else 390 else
389 { 391 {
390 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 392 LOG (GNUNET_ERROR_TYPE_DEBUG,
391 "Received lookup reply from GNS service (%u records)\n", 393 "Received lookup reply from GNS service (%u records)\n",
392 (unsigned int) rd_count); 394 (unsigned int) rd_count);
393 qe->lookup_proc (qe->proc_cls, rd_count, rd); 395 qe->lookup_proc (qe->proc_cls, rd_count, rd);
394 } 396 }
395 GNUNET_CONTAINER_DLL_remove (handle->lookup_head, handle->lookup_tail, qe); 397 GNUNET_CONTAINER_DLL_remove (handle->lookup_head, handle->lookup_tail, qe);
@@ -419,8 +421,8 @@ process_message (void *cls, const struct GNUNET_MessageHeader *msg)
419 switch (ntohs (msg->type)) 421 switch (ntohs (msg->type))
420 { 422 {
421 case GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT: 423 case GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT:
422 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 424 LOG (GNUNET_ERROR_TYPE_DEBUG,
423 "Got LOOKUP_RESULT msg\n"); 425 "Got LOOKUP_RESULT msg\n");
424 if (ntohs (msg->size) < sizeof (struct GNUNET_GNS_ClientLookupResultMessage)) 426 if (ntohs (msg->size) < sizeof (struct GNUNET_GNS_ClientLookupResultMessage))
425 { 427 {
426 GNUNET_break (0); 428 GNUNET_break (0);
@@ -539,9 +541,9 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
539 GNUNET_break (0); 541 GNUNET_break (0);
540 return NULL; 542 return NULL;
541 } 543 }
542 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 544 LOG (GNUNET_ERROR_TYPE_DEBUG,
543 "Trying to lookup `%s' in GNS\n", 545 "Trying to lookup `%s' in GNS\n",
544 name); 546 name);
545 msize = sizeof (struct GNUNET_GNS_ClientLookupMessage) 547 msize = sizeof (struct GNUNET_GNS_ClientLookupMessage)
546 + strlen (name) + 1; 548 + strlen (name) + 1;
547 if (msize > UINT16_MAX) 549 if (msize > UINT16_MAX)
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index f1b40f206..d7f2958f7 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -495,13 +495,15 @@ fail_resolution (void *cls,
495/* Don't have this on W32, here's a naive implementation 495/* Don't have this on W32, here's a naive implementation
496 * Was somehow removed on OS X ... */ 496 * Was somehow removed on OS X ... */
497void * 497void *
498memrchr (const void *s, int c, size_t n) 498memrchr (const void *s,
499 int c,
500 size_t n)
499{ 501{
500 size_t i; 502 unsigned char *ucs = s;
501 unsigned char *ucs = (unsigned char *) s; 503 ssize_t i;
502 504
503 for (i = n - 1; i >= 0; i--) 505 for (i = n - 1; i >= 0; i--)
504 if (ucs[i] == c) 506 if (c == (int) ucs[i])
505 return (void *) &ucs[i]; 507 return (void *) &ucs[i];
506 return NULL; 508 return NULL;
507} 509}