client_manager: add API for async operations
[oweals/gnunet.git] / src / include / gnunet_server_lib.h
index e29be0d56cf0802d68e25d7285dc26d4e7bd3ad2..e273d2291f2aabf24ea6f5386db19f1278955330 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2009-2013 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2009-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
@@ -78,10 +78,10 @@ struct GNUNET_SERVER_TransmitHandle;
  * @param client identification of the client
  * @param message the actual message
  */
-typedef void (*GNUNET_SERVER_MessageCallback) (void *cls,
-                                               struct GNUNET_SERVER_Client *client,
-                                               const struct GNUNET_MessageHeader
-                                               *message);
+typedef void
+(*GNUNET_SERVER_MessageCallback) (void *cls,
+                                  struct GNUNET_SERVER_Client *client,
+                                  const struct GNUNET_MessageHeader *message);
 
 
 /**
@@ -96,7 +96,7 @@ struct GNUNET_SERVER_MessageHandler
   GNUNET_SERVER_MessageCallback callback;
 
   /**
-   * Closure argument for "callback".
+   * Closure argument for @e callback.
    */
   void *callback_cls;
 
@@ -119,8 +119,8 @@ struct GNUNET_SERVER_MessageHandler
 /**
  * Create a new server.
  *
- * @param access function for access control
- * @param access_cls closure for @a access
+ * @param access_cb function for access control
+ * @param access_cb_cls closure for @a access_cb
  * @param lsocks NULL-terminated array of listen sockets
  * @param idle_timeout after how long should we timeout idle connections?
  * @param require_found if #GNUNET_YES, connections sending messages of unknown type
@@ -129,8 +129,8 @@ struct GNUNET_SERVER_MessageHandler
  *         (typically, "port" already in use)
  */
 struct GNUNET_SERVER_Handle *
-GNUNET_SERVER_create_with_sockets (GNUNET_CONNECTION_AccessCheck access,
-                                   void *access_cls,
+GNUNET_SERVER_create_with_sockets (GNUNET_CONNECTION_AccessCheck access_cb,
+                                   void *access_cb_cls,
                                    struct GNUNET_NETWORK_Handle **lsocks,
                                    struct GNUNET_TIME_Relative idle_timeout,
                                    int require_found);
@@ -138,8 +138,8 @@ GNUNET_SERVER_create_with_sockets (GNUNET_CONNECTION_AccessCheck access,
 /**
  * Create a new server.
  *
- * @param access function for access control
- * @param access_cls closure for @a access
+ * @param access_cb function for access control
+ * @param access_cb_cls closure for @a access_cb
  * @param server_addr address toes listen on (including port), NULL terminated array
  * @param socklen lengths of respective @a server_addr
  * @param idle_timeout after how long should we timeout idle connections?
@@ -149,7 +149,8 @@ GNUNET_SERVER_create_with_sockets (GNUNET_CONNECTION_AccessCheck access,
  *         (typically, "port" already in use)
  */
 struct GNUNET_SERVER_Handle *
-GNUNET_SERVER_create (GNUNET_CONNECTION_AccessCheck access, void *access_cls,
+GNUNET_SERVER_create (GNUNET_CONNECTION_AccessCheck access_cb,
+                     void *access_cb_cls,
                       struct sockaddr *const *server_addr,
                       const socklen_t * socklen,
                       struct GNUNET_TIME_Relative idle_timeout,
@@ -210,8 +211,7 @@ GNUNET_SERVER_destroy (struct GNUNET_SERVER_Handle *server);
  */
 void
 GNUNET_SERVER_add_handlers (struct GNUNET_SERVER_Handle *server,
-                            const struct GNUNET_SERVER_MessageHandler
-                            *handlers);
+                            const struct GNUNET_SERVER_MessageHandler *handlers);
 
 
 /**
@@ -233,8 +233,8 @@ struct GNUNET_SERVER_TransmitHandle *
 GNUNET_SERVER_notify_transmit_ready (struct GNUNET_SERVER_Client *client,
                                      size_t size,
                                      struct GNUNET_TIME_Relative timeout,
-                                     GNUNET_CONNECTION_TransmitReadyNotify
-                                     callback, void *callback_cls);
+                                     GNUNET_CONNECTION_TransmitReadyNotify callback,
+                                     void *callback_cls);
 
 
 /**
@@ -394,8 +394,7 @@ GNUNET_SERVER_inject (struct GNUNET_SERVER_Handle *server,
  * @param server the server to use
  * @param connection the connection to manage (client must
  *        stop using this connection from now on)
- * @return the client handle (client should call
- *         #GNUNET_SERVER_client_drop on the return value eventually)
+ * @return the client handle
  */
 struct GNUNET_SERVER_Client *
 GNUNET_SERVER_connect_socket (struct GNUNET_SERVER_Handle *server,
@@ -513,8 +512,8 @@ GNUNET_SERVER_connect_notify (struct GNUNET_SERVER_Handle *server,
  */
 void
 GNUNET_SERVER_disconnect_notify_cancel (struct GNUNET_SERVER_Handle *server,
-                                        GNUNET_SERVER_DisconnectCallback
-                                        callback, void *callback_cls);
+                                        GNUNET_SERVER_DisconnectCallback callback,
+                                        void *callback_cls);
 
 
 /**
@@ -587,8 +586,8 @@ GNUNET_SERVER_transmit_context_create (struct GNUNET_SERVER_Client *client);
  * @param type type of the message
  */
 void
-GNUNET_SERVER_transmit_context_append_data (struct GNUNET_SERVER_TransmitContext
-                                            *tc, const void *data,
+GNUNET_SERVER_transmit_context_append_data (struct GNUNET_SERVER_TransmitContext *tc,
+                                            const void *data,
                                             size_t length, uint16_t type);
 
 
@@ -601,11 +600,8 @@ GNUNET_SERVER_transmit_context_append_data (struct GNUNET_SERVER_TransmitContext
  * @param msg message to append
  */
 void
-GNUNET_SERVER_transmit_context_append_message (struct
-                                               GNUNET_SERVER_TransmitContext
-                                               *tc,
-                                               const struct GNUNET_MessageHeader
-                                               *msg);
+GNUNET_SERVER_transmit_context_append_message (struct GNUNET_SERVER_TransmitContext *tc,
+                                               const struct GNUNET_MessageHeader *msg);
 
 
 /**
@@ -634,8 +630,8 @@ GNUNET_SERVER_transmit_context_run (struct GNUNET_SERVER_TransmitContext *tc,
  *                          serious error)
  */
 void
-GNUNET_SERVER_transmit_context_destroy (struct GNUNET_SERVER_TransmitContext
-                                        *tc, int success);
+GNUNET_SERVER_transmit_context_destroy (struct GNUNET_SERVER_TransmitContext *tc,
+                                        int success);
 
 
 /**
@@ -712,6 +708,16 @@ GNUNET_SERVER_notification_context_broadcast (struct GNUNET_SERVER_NotificationC
                                               int can_drop);
 
 
+/**
+ * Return active number of subscribers in this context.
+ *
+ * @param nc context to query
+ * @return number of current subscribers
+ */
+unsigned int
+GNUNET_SERVER_notification_context_get_size (struct GNUNET_SERVER_NotificationContext *nc);
+
+
 /**
  * Handle to a message stream tokenizer.
  */
@@ -731,9 +737,7 @@ struct GNUNET_SERVER_MessageStreamTokenizer;
  * @return #GNUNET_OK on success, #GNUNET_SYSERR to stop further processing
  */
 typedef int (*GNUNET_SERVER_MessageTokenizerCallback) (void *cls, void *client,
-                                                        const struct
-                                                        GNUNET_MessageHeader *
-                                                        message);
+                                                       const struct GNUNET_MessageHeader *message);
 
 
 /**
@@ -766,7 +770,8 @@ GNUNET_SERVER_mst_create (GNUNET_SERVER_MessageTokenizerCallback cb,
  */
 int
 GNUNET_SERVER_mst_receive (struct GNUNET_SERVER_MessageStreamTokenizer *mst,
-                           void *client_identity, const char *buf, size_t size,
+                           void *client_identity,
+                           const char *buf, size_t size,
                            int purge, int one_shot);
 
 
@@ -782,7 +787,7 @@ GNUNET_SERVER_mst_destroy (struct GNUNET_SERVER_MessageStreamTokenizer *mst);
 /**
  * Signature of a function to create a custom tokenizer.
  *
- * @param cls closure from 'GNUNET_SERVER_set_callbacks'
+ * @param cls closure from #GNUNET_SERVER_set_callbacks
  * @param client handle to client the tokenzier will be used for
  * @return handle to custom tokenizer ('mst')
  */
@@ -793,7 +798,7 @@ typedef void* (*GNUNET_SERVER_MstCreateCallback) (void *cls,
 /**
  * Signature of a function to destroy a custom tokenizer.
  *
- * @param cls closure from 'GNUNET_SERVER_set_callbacks'
+ * @param cls closure from #GNUNET_SERVER_set_callbacks
  * @param mst custom tokenizer handle
  */
 typedef void (*GNUNET_SERVER_MstDestroyCallback) (void *cls, void *mst);