-/**
- * Internal state for a list request with ARM.
- */
-struct ListRequestContext
-{
-
- /**
- * Pointer to our handle with ARM.
- */
- struct GNUNET_ARM_Handle *h;
-
- /**
- * Function to call with a status code for the requested operation.
- */
- GNUNET_ARM_List_Callback callback;
-
- /**
- * Closure for "callback".
- */
- void *cls;
-
- /**
- * Timeout for the operation.
- */
- struct GNUNET_TIME_Absolute timeout;
-};
-
-/**
- * Process a response from ARM for the list request.
- *
- * @param cls the list request context
- * @param msg the response
- */
-static void
-handle_list_response (void *cls, const struct GNUNET_MessageHeader *msg)
-{
- struct ListRequestContext *sc = cls;
- const struct GNUNET_ARM_ListResultMessage *res;
- int success;
-
- if (msg == NULL)
- {
- LOG (GNUNET_ERROR_TYPE_WARNING,
- "Error receiving response to LIST request from ARM\n");
- GNUNET_CLIENT_disconnect (sc->h->client, GNUNET_NO);
- sc->h->client = GNUNET_CLIENT_connect ("arm", sc->h->cfg);
- GNUNET_assert (NULL != sc->h->client);
- if (sc->callback != NULL)
- sc->callback (sc->cls, GNUNET_ARM_PROCESS_COMMUNICATION_ERROR, 0, NULL);
- GNUNET_free (sc);
- return;
- }
-
- if (sc->callback != NULL)
- {
- char **list;
- const char *pos;
- uint16_t size_check;
-
- size_check = 0;
- res = (const struct GNUNET_ARM_ListResultMessage *) msg;
- success = (ntohs (res->header.type)
- == GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT ?
- GNUNET_YES : GNUNET_NO);
- list = GNUNET_malloc (ntohs (res->count) * sizeof (char *));
- pos = (const char *)&res[1];
-
- int i;
- for (i=0; i<ntohs (res->count); i++)
- {
- list[i] = GNUNET_malloc (strlen (pos) + 1);
- memcpy (list[i], pos, strlen (pos) + 1);
- pos += strlen (pos) + 1;
- size_check += strlen (pos) +1;
-
- if (size_check > ntohs (res->header.size))
- {
- GNUNET_free (list);
- GNUNET_free (sc);
- sc->callback (sc->cls, GNUNET_NO, 0, NULL);
- return;
- }
- }
-
- sc->callback (sc->cls, success, ntohs (res->count), (const char**)list);
- }
- GNUNET_free (sc);
-}