+ GNUNET_MESSAGE_TYPE_ARM_STOP);
+}
+
+
+/**
+ * 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;
+ const char *pos;
+ uint16_t size_check;
+ uint16_t rcount;
+ uint16_t msize;
+
+ if (NULL == msg)
+ {
+ GNUNET_break (0);
+ GNUNET_CLIENT_disconnect (sc->h->client);
+ 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 (NULL == sc->callback)
+ {
+ GNUNET_break (0);
+ GNUNET_free (sc);
+ return;
+ }
+ msize = ntohs (msg->size);
+ if ( (msize < sizeof ( struct GNUNET_ARM_ListResultMessage)) ||
+ (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT) )
+ {
+ GNUNET_break (0);
+ sc->callback (sc->cls, GNUNET_NO, 0, NULL);
+ GNUNET_free (sc);
+ return;
+ }
+ size_check = 0;
+ res = (const struct GNUNET_ARM_ListResultMessage *) msg;
+ rcount = ntohs (res->count);
+ {
+ const char *list[rcount];
+ unsigned int i;
+
+ pos = (const char *)&res[1];
+ for (i=0; i<rcount; i++)
+ {
+ const char *end = memchr (pos, 0, msize - size_check);
+ if (NULL == end)
+ {
+ GNUNET_break (0);
+ sc->callback (sc->cls, GNUNET_NO, 0, NULL);
+ GNUNET_free (sc);
+ return;
+ }
+ list[i] = pos;
+ size_check += (end - pos) + 1;
+ pos = end + 1;
+ }
+ sc->callback (sc->cls, GNUNET_YES, rcount, list);
+ }
+ GNUNET_free (sc);