diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-03-07 15:50:44 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-03-07 15:50:44 +0000 |
commit | 375e1b742172911b41b1dd04c8c4efdb65caf408 (patch) | |
tree | be457da2d75736d27bdaaa7f4707d50855fd56cf /src/gns/gns_api.c | |
parent | ab0702f90884738babca7948eb5310f633c612bc (diff) | |
download | gnunet-375e1b742172911b41b1dd04c8c4efdb65caf408.tar.gz gnunet-375e1b742172911b41b1dd04c8c4efdb65caf408.zip |
-shortening in cli app (in progress)
Diffstat (limited to 'src/gns/gns_api.c')
-rw-r--r-- | src/gns/gns_api.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c index a1cd190de..104423c32 100644 --- a/src/gns/gns_api.c +++ b/src/gns/gns_api.c | |||
@@ -496,7 +496,7 @@ process_shorten_reply (void *cls, const GNUNET_HashCode * key, void *value) | |||
496 | { | 496 | { |
497 | const struct GNUNET_GNS_ClientShortenResultMessage *gns_msg = cls; | 497 | const struct GNUNET_GNS_ClientShortenResultMessage *gns_msg = cls; |
498 | struct GNUNET_GNS_ShortenHandle *shorten_handle = value; | 498 | struct GNUNET_GNS_ShortenHandle *shorten_handle = value; |
499 | const char *name = (const char*) &shorten_handle[1]; | 499 | const char *name = (const char*)&((struct GNUNET_GNS_ClientShortenMessage *) &((shorten_handle->message)[1]))[1]; //FIXME |
500 | const char *short_name; | 500 | const char *short_name; |
501 | 501 | ||
502 | if (ntohs (((struct GNUNET_MessageHeader*)gns_msg)->size) < | 502 | if (ntohs (((struct GNUNET_MessageHeader*)gns_msg)->size) < |
@@ -599,7 +599,9 @@ message_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
599 | struct GNUNET_GNS_Handle *handle = cls; | 599 | struct GNUNET_GNS_Handle *handle = cls; |
600 | const struct GNUNET_GNS_ClientLookupResultMessage *lookup_msg; | 600 | const struct GNUNET_GNS_ClientLookupResultMessage *lookup_msg; |
601 | const struct GNUNET_GNS_ClientShortenResultMessage *shorten_msg; | 601 | const struct GNUNET_GNS_ClientShortenResultMessage *shorten_msg; |
602 | 602 | ||
603 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
604 | "Got message\n"); | ||
603 | if (msg == NULL) | 605 | if (msg == NULL) |
604 | { | 606 | { |
605 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 607 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -610,6 +612,8 @@ message_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
610 | 612 | ||
611 | if (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT) | 613 | if (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT) |
612 | { | 614 | { |
615 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
616 | "Got lookup msg\n"); | ||
613 | lookup_msg = (const struct GNUNET_GNS_ClientLookupResultMessage *) msg; | 617 | lookup_msg = (const struct GNUNET_GNS_ClientLookupResultMessage *) msg; |
614 | GNUNET_CONTAINER_multihashmap_get_multiple (handle->active_lookup_requests, | 618 | GNUNET_CONTAINER_multihashmap_get_multiple (handle->active_lookup_requests, |
615 | &lookup_msg->key, | 619 | &lookup_msg->key, |
@@ -618,6 +622,8 @@ message_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
618 | } | 622 | } |
619 | else if (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_GNS_SHORTEN_RESULT) | 623 | else if (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_GNS_SHORTEN_RESULT) |
620 | { | 624 | { |
625 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
626 | "Got shorten msg\n"); | ||
621 | shorten_msg = (const struct GNUNET_GNS_ClientShortenResultMessage *) msg; | 627 | shorten_msg = (const struct GNUNET_GNS_ClientShortenResultMessage *) msg; |
622 | GNUNET_CONTAINER_multihashmap_get_multiple (handle->active_shorten_requests, | 628 | GNUNET_CONTAINER_multihashmap_get_multiple (handle->active_shorten_requests, |
623 | &shorten_msg->key, | 629 | &shorten_msg->key, |
@@ -642,8 +648,7 @@ message_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
642 | * @return handle to the GNS service, or NULL on error | 648 | * @return handle to the GNS service, or NULL on error |
643 | */ | 649 | */ |
644 | struct GNUNET_GNS_Handle * | 650 | struct GNUNET_GNS_Handle * |
645 | GNUNET_GNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | 651 | GNUNET_GNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) |
646 | unsigned int ht_len) | ||
647 | { | 652 | { |
648 | struct GNUNET_GNS_Handle *handle; | 653 | struct GNUNET_GNS_Handle *handle; |
649 | 654 | ||
@@ -652,9 +657,9 @@ GNUNET_GNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
652 | handle->uid_gen = | 657 | handle->uid_gen = |
653 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); | 658 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); |
654 | handle->active_lookup_requests = | 659 | handle->active_lookup_requests = |
655 | GNUNET_CONTAINER_multihashmap_create (ht_len); | 660 | GNUNET_CONTAINER_multihashmap_create (5); |
656 | handle->active_shorten_requests = | 661 | handle->active_shorten_requests = |
657 | GNUNET_CONTAINER_multihashmap_create (ht_len); | 662 | GNUNET_CONTAINER_multihashmap_create (5); |
658 | if (GNUNET_NO == try_connect (handle)) | 663 | if (GNUNET_NO == try_connect (handle)) |
659 | { | 664 | { |
660 | GNUNET_GNS_disconnect (handle); | 665 | GNUNET_GNS_disconnect (handle); |
@@ -790,7 +795,7 @@ GNUNET_GNS_shorten (struct GNUNET_GNS_Handle *handle, | |||
790 | GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail, | 795 | GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail, |
791 | pending); | 796 | pending); |
792 | pending->in_pending_queue = GNUNET_YES; | 797 | pending->in_pending_queue = GNUNET_YES; |
793 | shorten_handle = GNUNET_malloc (sizeof (struct GNUNET_GNS_LookupHandle)); | 798 | shorten_handle = GNUNET_malloc (sizeof (struct GNUNET_GNS_ShortenHandle)); |
794 | shorten_handle->proc = proc; | 799 | shorten_handle->proc = proc; |
795 | shorten_handle->proc_cls = proc_cls; | 800 | shorten_handle->proc_cls = proc_cls; |
796 | shorten_handle->message = pending; | 801 | shorten_handle->message = pending; |