+ struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
+ int res = GNUNET_OK;
+
+ if (ntohs (msg->op_result) == GNUNET_OK)
+ {
+ res = GNUNET_OK;
+ if (qe->cont != NULL)
+ {
+ qe->cont (qe->cont_cls, res, _("Namestore added record successfully"));
+ }
+
+ }
+ else if (ntohs (msg->op_result) == GNUNET_NO)
+ {
+ res = GNUNET_SYSERR;
+ if (qe->cont != NULL)
+ {
+ qe->cont (qe->cont_cls, res, _("Namestore failed to add record"));
+ }
+ }
+ else
+ {
+ GNUNET_break_op (0);
+ return;
+ }
+
+ /* Operation done, remove */
+ GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
+
+ GNUNET_free (qe);
+}
+
+
+static void
+handle_record_remove_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
+ struct RecordRemoveResponseMessage* msg,
+ size_t size)
+{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
+ "RECORD_REMOVE_RESPONSE");
+
+ struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
+ int res = ntohs (msg->op_result);
+
+ /**
+ * result:
+ * 0 : successful
+ * 1 : No records for entry
+ * 2 : Could not find record to remove
+ * 3 : Failed to create new signature
+ * 4 : Failed to put new set of records in database
+ */
+ switch (res) {
+ case 0:
+ if (qe->cont != NULL)
+ {
+ qe->cont (qe->cont_cls, GNUNET_YES, _("Namestore removed record successfully"));
+ }
+
+ break;
+ case 1:
+ if (qe->cont != NULL)
+ {
+ qe->cont (qe->cont_cls, GNUNET_NO, _("No records for entry"));
+ }
+
+ break;
+ case 2:
+ if (qe->cont != NULL)
+ {
+ qe->cont (qe->cont_cls, GNUNET_NO, _("Could not find record to remove"));
+ }
+
+ break;
+ case 3:
+ if (qe->cont != NULL)
+ {
+ qe->cont (qe->cont_cls, GNUNET_SYSERR, _("Failed to create new signature"));
+ }
+
+ break;
+ case 4:
+ if (qe->cont != NULL)
+ {
+ qe->cont (qe->cont_cls, GNUNET_SYSERR, _("Failed to put new set of records in database"));
+ }
+ break;
+ default:
+ GNUNET_break_op (0);
+ break;
+ }
+
+ /* Operation done, remove */
+ GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
+
+ GNUNET_free (qe);
+}
+
+
+static void
+manage_record_operations (struct GNUNET_NAMESTORE_QueueEntry *qe,
+ const struct GNUNET_MessageHeader *msg,
+ int type, size_t size)
+{
+
+ /* handle different message type */
+ switch (type) {
+ case GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE:
+ if (size < sizeof (struct LookupNameResponseMessage))
+ {
+ GNUNET_break_op (0);
+ break;
+ }
+ handle_lookup_name_response (qe, (struct LookupNameResponseMessage *) msg, size);
+ break;
+ case GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE:
+ if (size != sizeof (struct RecordPutResponseMessage))
+ {
+ GNUNET_break_op (0);
+ break;
+ }
+ handle_record_put_response (qe, (struct RecordPutResponseMessage *) msg, size);
+ break;
+ case GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE:
+ if (size != sizeof (struct RecordCreateResponseMessage))
+ {
+ GNUNET_break_op (0);
+ break;
+ }
+ handle_record_create_response (qe, (struct RecordCreateResponseMessage *) msg, size);
+ break;
+ case GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE:
+ if (size != sizeof (struct RecordRemoveResponseMessage))
+ {
+ GNUNET_break_op (0);
+ break;
+ }
+ handle_record_remove_response (qe, (struct RecordRemoveResponseMessage *) msg, size);
+ break;
+ default:
+ GNUNET_break_op (0);
+ break;
+ }
+}
+
+static void
+handle_zone_iteration_response (struct GNUNET_NAMESTORE_ZoneIterator *ze,
+ struct ZoneIterationResponseMessage *msg,
+ size_t size)
+{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
+ "ZONE_ITERATION_RESPONSE");
+
+
+ if (ze->proc != NULL)
+ {
+ // FIXME
+ ze->proc(ze->proc_cls, NULL, GNUNET_TIME_absolute_get_forever(), "dummy", 0, NULL, NULL);
+ }
+}
+
+
+static void
+manage_zone_operations (struct GNUNET_NAMESTORE_ZoneIterator *ze,
+ const struct GNUNET_MessageHeader *msg,
+ int type, size_t size)
+{
+
+ /* handle different message type */
+ switch (type) {
+ case GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE:
+ if (size < sizeof (struct ZoneIterationResponseMessage))
+ {
+ GNUNET_break_op (0);
+ break;
+ }
+ handle_zone_iteration_response (ze, (struct ZoneIterationResponseMessage *) msg, size);
+ break;
+ default:
+ GNUNET_break_op (0);
+ break;
+ }
+}