adding number of preferences to allow iterating over preferences
[oweals/gnunet.git] / src / include / gnunet_psyc_util_lib.h
index eea338ba424f48e40858060d558f61908f38ffaa..488edc03b9b7980a672bd89d536acaddb5d532fb 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2012, 2013 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2012, 2013 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -40,6 +40,52 @@ extern "C"
 #include "gnunet_psyc_service.h"
 
 
+/**
+ * Create a PSYC message.
+ *
+ * @param method_name
+ *        PSYC method for the message.
+ * @param env
+ *        Environment for the message.
+ * @param data
+ *        Data payload for the message.
+ * @param data_size
+ *        Size of @a data.
+ *
+ * @return Message header with size information,
+ *         followed by the message parts.
+ */
+struct GNUNET_PSYC_Message *
+GNUNET_PSYC_message_create (const char *method_name,
+                            const struct GNUNET_ENV_Environment *env,
+                            const void *data,
+                            size_t data_size);
+
+/**
+ * Parse PSYC message.
+ *
+ * @param msg
+ *        The PSYC message to parse.
+ * @param env
+ *        The environment for the message with a list of modifiers.
+ * @param[out] method_name
+ *        Pointer to the method name inside @a pmsg.
+ * @param[out] data
+ *        Pointer to data inside @a pmsg.
+ * @param[out] data_size
+ *        Size of @data is written here.
+ *
+ * @return #GNUNET_OK on success,
+ *         #GNUNET_SYSERR on parse error.
+ */
+int
+GNUNET_PSYC_message_parse (const struct GNUNET_PSYC_Message *msg,
+                           const char **method_name,
+                           struct GNUNET_ENV_Environment *env,
+                           const void **data,
+                           uint16_t *data_size);
+
+
 void
 GNUNET_PSYC_log_message (enum GNUNET_ErrorType kind,
                          const struct GNUNET_MessageHeader *msg);
@@ -128,7 +174,7 @@ struct GNUNET_PSYC_ReceiveHandle;
  */
 struct GNUNET_PSYC_ReceiveHandle *
 GNUNET_PSYC_receive_create (GNUNET_PSYC_MessageCallback message_cb,
-                            GNUNET_PSYC_MessageCallback hist_message_cb,
+                            GNUNET_PSYC_MessagePartCallback message_part_cb,
                             void *cb_cls);