#endif
#endif
-#include "gnunet_configuration_lib.h"
-#include "gnunet_scheduler_lib.h"
-#include "gnunet_os_lib.h"
-#include "gnunet_time_lib.h"
+#include "gnunet_util_lib.h"
/**
* Version of the arm API.
GNUNET_ARM_SERVICE_STOPPING = 3
};
+
/**
* Replies to ARM requests
*/
* Function called whenever we connect to or disconnect from ARM.
*
* @param cls closure
- * @param connected GNUNET_YES if connected, GNUNET_NO if disconnected
- * @param error GNUNET_YES if we encountered a permanent error, and there
- * will be no re-connection.
+ * @param connected GNUNET_YES if connected, GNUNET_NO if disconnected,
+ * GNUNET_SYSERR if there was an error.
*/
-typedef void (*GNUNET_ARM_ConnectionStatusCallback) (void *cls, struct GNUNET_ARM_Handle *arm, unsigned char connected, unsigned char error);
+typedef void (*GNUNET_ARM_ConnectionStatusCallback) (void *cls,
+ int connected);
/**
* 'rs' will indicate that, and 'service' and 'result' will be undefined.
*
* @param cls closure
- * @param arm handle to the arm connection
* @param rs status of the request
* @param service service name
* @param result result of the operation
*/
-typedef void (*GNUNET_ARM_ResultCallback) (void *cls, struct GNUNET_ARM_Handle *arm, enum GNUNET_ARM_RequestStatus rs, const char *service, enum GNUNET_ARM_Result result);
+typedef void (*GNUNET_ARM_ResultCallback) (void *cls,
+ enum GNUNET_ARM_RequestStatus rs,
+ const char *service,
+ enum GNUNET_ARM_Result result);
/**
* 'rs' will indicate that, and 'count' and 'list' will be undefined.
*
* @param cls closure
- * @param arm handle to the arm connection
* @param rs status of the request
* @param count number of strings in the list
* @param list list of running services
*/
-typedef void (*GNUNET_ARM_ServiceListCallback) (void *cls, struct GNUNET_ARM_Handle *arm, enum GNUNET_ARM_RequestStatus rs, unsigned int count, const char *const*list);
+typedef void (*GNUNET_ARM_ServiceListCallback) (void *cls,
+ enum GNUNET_ARM_RequestStatus rs,
+ unsigned int count,
+ const char *const*list);
/**
- * Setup a context for communicating with ARM. Note that this
- * can be done even if the ARM service is not yet running.
- * Never fails.
+ * Set up a context for communicating with ARM, then
+ * start connecting to the ARM service using that context.
*
* @param cfg configuration to use (needed to contact ARM;
* the ARM service may internally use a different
* configuration to determine how to start the service).
- * @return context to use for further ARM operations
- */
-struct GNUNET_ARM_Handle *
-GNUNET_ARM_alloc (const struct GNUNET_CONFIGURATION_Handle *cfg);
-
-/**
- * Start connecting to the ARM service using the context.
- * @param conn_status called when we (dis)connect from/to ARM.
- * It's also called on connection errors.
+ * @param conn_status will be called when connecting/disconnecting
* @param cls closure for conn_status
- *
- * @param h ARM handle
+ * @return context to use for further ARM operations, NULL on error.
*/
-void
-GNUNET_ARM_connect (struct GNUNET_ARM_Handle *h,
- GNUNET_ARM_ConnectionStatusCallback conn_status, void *cls);
+struct GNUNET_ARM_Handle *
+GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ GNUNET_ARM_ConnectionStatusCallback conn_status,
+ void *cls);
/**
* Disconnect from the ARM service and destroy the handle.
- * Don't call this from inside an ARM callback!
*
* @param h the handle that was being used
*/
void
-GNUNET_ARM_disconnect (struct GNUNET_ARM_Handle *h);
+GNUNET_ARM_disconnect_and_free (struct GNUNET_ARM_Handle *h);
/**
*/
void
GNUNET_ARM_request_service_list (struct GNUNET_ARM_Handle *h,
- struct GNUNET_TIME_Relative timeout,
- GNUNET_ARM_ServiceListCallback cont, void *cont_cls);
+ struct GNUNET_TIME_Relative timeout,
+ GNUNET_ARM_ServiceListCallback cont, void *cont_cls);
/**
* Stopping arm itself will not invalidate its handle, and
* ARM API will try to restore connection to the ARM service,
* even if ARM connection was lost because you asked for ARM to be stopped.
- * Call GNUNET_ARM_disconnect () to free the handle and prevent
+ * Call GNUNET_ARM_disconnect_and_free () to free the handle and prevent
* further connection attempts.
*
* @param h handle to ARM
*/
void
GNUNET_ARM_request_service_stop (struct GNUNET_ARM_Handle *h,
- const char *service_name, struct GNUNET_TIME_Relative timeout,
- GNUNET_ARM_ResultCallback cont, void *cont_cls);
+ const char *service_name,
+ struct GNUNET_TIME_Relative timeout,
+ GNUNET_ARM_ResultCallback cont, void *cont_cls);
/**
*/
void
GNUNET_ARM_request_service_start (struct GNUNET_ARM_Handle *h,
- const char *service_name, enum GNUNET_OS_InheritStdioFlags std_inheritance,
- struct GNUNET_TIME_Relative timeout, GNUNET_ARM_ResultCallback cont,
- void *cont_cls);
+ const char *service_name,
+ enum GNUNET_OS_InheritStdioFlags std_inheritance,
+ struct GNUNET_TIME_Relative timeout,
+ GNUNET_ARM_ResultCallback cont,
+ void *cont_cls);
/**
* @param service service name
* @param status status of the service
*/
-typedef void (*GNUNET_ARM_ServiceStatusCallback) (void *cls, struct GNUNET_ARM_MonitorHandle *arm, const char *service, enum GNUNET_ARM_ServiceStatus status);
+typedef void (*GNUNET_ARM_ServiceStatusCallback) (void *cls,
+ const char *service,
+ enum GNUNET_ARM_ServiceStatus status);
/**
- * Setup a context for monitoring ARM. Note that this
- * can be done even if the ARM service is not yet running.
- * Never fails.
+ * Setup a context for monitoring ARM, then
+ * start connecting to the ARM service for monitoring using that context.
*
* @param cfg configuration to use (needed to contact ARM;
* the ARM service may internally use a different
* configuration to determine how to start the service).
- * @return context to use for further ARM monitor operations
- */
-struct GNUNET_ARM_MonitorHandle *
-GNUNET_ARM_monitor_alloc (const struct GNUNET_CONFIGURATION_Handle *cfg);
-
-/**
- * Start connecting to the ARM service for monitoring using the context.
- *
- * @param h ARM monitor handle
* @param cont callback to invoke on status updates
* @param cont_cls closure
+ * @return context to use for further ARM monitor operations, NULL on error.
*/
-void
-GNUNET_ARM_monitor (struct GNUNET_ARM_MonitorHandle *h,
- GNUNET_ARM_ServiceStatusCallback cont, void *cont_cls);
+struct GNUNET_ARM_MonitorHandle *
+GNUNET_ARM_monitor (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ GNUNET_ARM_ServiceStatusCallback cont,
+ void *cont_cls);
/**
* Disconnect from the ARM service and destroy the handle.
- * Don't call this from inside an ARM callback!
*
* @param h the handle that was being used
*/
void
-GNUNET_ARM_monitor_disconnect (struct GNUNET_ARM_MonitorHandle *h);
+GNUNET_ARM_monitor_disconnect_and_free (struct GNUNET_ARM_MonitorHandle *h);
#if 0 /* keep Emacsens' auto-indent happy */