convert fs publish to MQ
[oweals/gnunet.git] / src / include / gnunet_curl_lib.h
index db04f12331b815819d44511452b584d51114e0d5..ec52299cbc9fe8acfad729d73407484a9fd20bfc 100644 (file)
  */
 #ifndef GNUNET_CURL_LIB_H
 #define GNUNET_CURL_LIB_H
+#if HAVE_CURL_CURL_H
 #include <curl/curl.h>
+#elif HAVE_GNURL_CURL_H
+#include <gnurl/curl.h>
+#else
+#error "needs curl or gnurl"
+#endif
 #include <jansson.h>
-#include <gnunet/gnunet_util_lib.h>
+#include "gnunet_util_lib.h"
+
+
+/**
+ * Function called by the context to ask for the event loop to be
+ * rescheduled, that is the application should call
+ * #GNUNET_CURL_get_select_info() as the set of sockets we care about
+ * just changed.
+ *
+ * @param cls closure
+ */
+typedef void
+(*GNUNET_CURL_RescheduleCallback)(void *cls);
 
 
 /**
  * Initialise this library.  This function should be called before using any of
  * the following functions.
  *
+ * @param cb function to call when rescheduling is required
+ * @param cb_cls closure for @a cb
  * @return library context
  */
 struct GNUNET_CURL_Context *
-GNUNET_CURL_init (void);
+GNUNET_CURL_init (GNUNET_CURL_RescheduleCallback cb,
+                  void *cb_cls);
 
 
 /**
  * Obtain the information for a select() call to wait until
- * #GNUNET_CURL_perform() is ready again.  Note that calling
- * any other TALER_EXCHANGE-API may also imply that the library
- * is again ready for #GNUNET_CURL_perform().
+ * #GNUNET_CURL_perform() is ready again.
  *
  * Basically, a client should use this API to prepare for select(),
  * then block on select(), then call #GNUNET_CURL_perform() and then
@@ -79,7 +98,7 @@ GNUNET_CURL_get_select_info (struct GNUNET_CURL_Context *ctx,
 
 
 /**
- * Run the main event loop for the Taler interaction.
+ * Run the main event loop for the CURL interaction.
  *
  * @param ctx the library context
  */
@@ -149,6 +168,47 @@ GNUNET_CURL_job_add (struct GNUNET_CURL_Context *ctx,
 void
 GNUNET_CURL_job_cancel (struct GNUNET_CURL_Job *job);
 
+
+/* ******* GNUnet SCHEDULER integration ************ */
+
+
+/**
+ * Closure for #GNUNET_CURL_gnunet_scheduler_reschedule().
+ */
+struct GNUNET_CURL_RescheduleContext;
+
+
+/**
+ * Initialize reschedule context.
+ *
+ * @param ctx context to manage
+ * @return closure for #GNUNET_CURL_gnunet_scheduler_reschedule().
+ */
+struct GNUNET_CURL_RescheduleContext *
+GNUNET_CURL_gnunet_rc_create (struct GNUNET_CURL_Context *ctx);
+
+/**
+ * Destroy reschedule context.
+ *
+ * @param rc context to destroy
+ */
+void
+GNUNET_CURL_gnunet_rc_destroy (struct GNUNET_CURL_RescheduleContext *rc);
+
+
+/**
+ * Implementation of the #GNUNET_CURL_RescheduleCallback for GNUnet's
+ * scheduler.  Will run the CURL context using GNUnet's scheduler.
+ * Note that you MUST immediately destroy the reschedule context after
+ * calling #GNUNET_CURL_fini().
+ *
+ * @param cls must point to a `struct GNUNET_CURL_RescheduleContext *`
+ *           (pointer to a pointer!)
+ */
+void
+GNUNET_CURL_gnunet_scheduler_reschedule (void *cls);
+
+
 #endif
 /** @} */  /* end of group */