-
-/**
- * Send shorten response back to client
- *
- * @param cls the closure containing a client shorten handle
- * @param name the shortened name result or NULL if cannot be shortened
- */
-static void
-send_shorten_response (void* cls, const char* name)
-{
- struct ClientShortenHandle *csh = cls;
- struct GNUNET_GNS_ClientShortenResultMessage *rmsg;
- size_t name_len;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending `%s' message with %s\n",
- "SHORTEN_RESULT", name);
- if (NULL == name)
- name_len = 0;
- else
- name_len = strlen (name) + 1;
- GNUNET_STATISTICS_update (statistics,
- "Name shorten results", 1, GNUNET_NO);
-
- rmsg = GNUNET_malloc (sizeof (struct GNUNET_GNS_ClientShortenResultMessage) +
- name_len);
-
- rmsg->id = csh->request_id;
- rmsg->header.type = htons(GNUNET_MESSAGE_TYPE_GNS_SHORTEN_RESULT);
- rmsg->header.size =
- htons(sizeof(struct GNUNET_GNS_ClientShortenResultMessage) +
- name_len);
- memcpy (&rmsg[1], name, name_len);
- GNUNET_SERVER_notification_context_unicast (nc, csh->client,
- &rmsg->header,
- GNUNET_NO);
- if (NULL != csh->namestore_task)
- GNUNET_NAMESTORE_cancel (csh->namestore_task);
- GNUNET_free (rmsg);
- GNUNET_free (csh);
-}
-
-
-/**
- * Lookup the zone infos and shorten name
- *
- * @param cls the client shorten handle
- * @param key key of the zone
- * @param expiration expiration of record
- * @param name name found or null if no result
- * @param rd_count number of records found
- * @param rd record data
- * @param signature
- *
- */
-static void
-process_shorten_in_private_zone_lookup (void *cls,
- const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *key,
- struct GNUNET_TIME_Absolute expiration,
- const char *name,
- unsigned int rd_count,
- const struct GNUNET_NAMESTORE_RecordData *rd,
- const struct GNUNET_CRYPTO_EccSignature *signature)
-{
- struct ClientShortenHandle *csh = cls;
- struct GNUNET_CRYPTO_ShortHashCode *szone = &csh->shorten_zone;
- struct GNUNET_CRYPTO_ShortHashCode *pzone = &csh->private_zone;
-
- csh->namestore_task = NULL;
- if (0 == strcmp (csh->private_zone_id, ""))
- pzone = NULL;
- if (0 == rd_count)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "No shorten zone in private zone!\n");
- strcpy (csh->shorten_zone_id, "");
- szone = NULL;
- }
- else
- {
- GNUNET_break (1 == rd_count);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Shorten zone %s found in private zone %s\n",
- name, csh->private_zone_id);
-
- sprintf (csh->shorten_zone_id, "%s.%s", name, csh->private_zone_id);
- }
- GNUNET_CONTAINER_DLL_remove (csh_head, csh_tail, csh);
- gns_resolver_shorten_name (&csh->root_zone,
- pzone,
- szone,
- csh->name,
- csh->private_zone_id,
- csh->shorten_zone_id,
- &send_shorten_response, csh);
-
-}
-
-
-/**
- * Lookup the zone infos and shorten name
- *
- * @param cls the shorten handle
- * @param key key of the zone
- * @param expiration expiration of record
- * @param name name found or null if no result
- * @param rd_count number of records found
- * @param rd record data
- * @param signature
- *
- */
-static void
-process_shorten_in_root_zone_lookup (void *cls,
- const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *key,
- struct GNUNET_TIME_Absolute expiration,
- const char *name,
- unsigned int rd_count,
- const struct GNUNET_NAMESTORE_RecordData *rd,
- const struct GNUNET_CRYPTO_EccSignature *signature)
-{
- struct ClientShortenHandle *csh = cls;
- struct GNUNET_CRYPTO_ShortHashCode *szone = &csh->shorten_zone;
- struct GNUNET_CRYPTO_ShortHashCode *pzone = &csh->private_zone;
-
- csh->namestore_task = NULL;
- if (0 == strcmp (csh->private_zone_id, ""))
- pzone = NULL;
- if (0 == rd_count)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "No shorten zone in zone and no private zone!\n");
-
- strcpy (csh->shorten_zone_id, "");
- GNUNET_CONTAINER_DLL_remove (csh_head, csh_tail, csh);
- szone = NULL;
- gns_resolver_shorten_name (&csh->root_zone,
- pzone,
- szone,
- csh->name,
- csh->private_zone_id,
- csh->shorten_zone_id,
- &send_shorten_response, csh);
- return;
- }
- GNUNET_break (rd_count == 1);