-fix
[oweals/gnunet.git] / src / include / gnunet_service_lib.h
index 66e4f0cd961f77afad2e1fd490e513241b0a942f..1641e0f939b3e977e72a0104d4ed5ccfe058c127 100644 (file)
@@ -38,17 +38,43 @@ extern "C"
 #include "gnunet_configuration_lib.h"
 #include "gnunet_server_lib.h"
 
+
+/**
+ * Get the list of addresses that a server for the given service
+ * should bind to.
+ *
+ * @param serviceName name of the service
+ * @param cfg configuration (which specifies the addresses)
+ * @param addrs set (call by reference) to an array of pointers to the
+ *              addresses the server should bind to and listen on; the
+ *              array will be NULL-terminated (on success)
+ * @param addr_lens set (call by reference) to an array of the lengths
+ *              of the respective 'struct sockaddr' struct in the 'addrs'
+ *              array (on success)
+ * @return number of addresses found on success,
+ *              GNUNET_SYSERR if the configuration
+ *              did not specify reasonable finding information or
+ *              if it specified a hostname that could not be resolved;
+ *              GNUNET_NO if the number of addresses configured is
+ *              zero (in this case, '*addrs' and '*addr_lens' will be
+ *              set to NULL).
+ */
+int
+GNUNET_SERVICE_get_server_addresses (const char *serviceName,
+                                     const struct GNUNET_CONFIGURATION_Handle
+                                     *cfg, struct sockaddr ***addrs,
+                                     socklen_t ** addr_lens);
+
+
 /**
  * Function called by the service's run
  * method to run service-specific setup code.
  *
  * @param cls closure
- * @param sched scheduler to use
  * @param server the initialized server
  * @param cfg configuration to use
  */
 typedef void (*GNUNET_SERVICE_Main) (void *cls,
-                                     struct GNUNET_SCHEDULER_Handle * sched,
                                      struct GNUNET_SERVER_Handle * server,
                                      const struct GNUNET_CONFIGURATION_Handle *
                                      cfg);
@@ -58,18 +84,18 @@ typedef void (*GNUNET_SERVICE_Main) (void *cls,
  * Options for the service (bitmask).
  */
 enum GNUNET_SERVICE_Options
-  {
+{
     /**
      * Use defaults.
      */
-    GNUNET_SERVICE_OPTION_NONE = 0,
+  GNUNET_SERVICE_OPTION_NONE = 0,
 
     /**
      * Do not trigger server shutdown on signals, allow for the user
      * to terminate the server explicitly when needed.
      */
-    GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN = 1
-  };
+  GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN = 1
+};
 
 
 /**
@@ -85,12 +111,10 @@ enum GNUNET_SERVICE_Options
  * @return GNUNET_SYSERR on error, GNUNET_OK
  *         if we shutdown nicely
  */
-int GNUNET_SERVICE_run (int argc,
-                        char *const *argv,
-                        const char *serviceName,
-                       enum GNUNET_SERVICE_Options opt,
-                        GNUNET_SERVICE_Main task,
-                        void *task_cls);
+int
+GNUNET_SERVICE_run (int argc, char *const *argv, const char *serviceName,
+                    enum GNUNET_SERVICE_Options opt, GNUNET_SERVICE_Main task,
+                    void *task_cls);
 
 
 struct GNUNET_SERVICE_Context;
@@ -100,17 +124,12 @@ struct GNUNET_SERVICE_Context;
  * initialized system.
  *
  * @param serviceName our service name
- * @param sched scheduler to use
  * @param cfg configuration to use
  * @return NULL on error, service handle
  */
-struct GNUNET_SERVICE_Context *GNUNET_SERVICE_start (const char *serviceName,
-                                                     struct
-                                                     GNUNET_SCHEDULER_Handle
-                                                     *sched,
-                                                     const struct
-                                                     GNUNET_CONFIGURATION_Handle
-                                                     *cfg);
+struct GNUNET_SERVICE_Context *
+GNUNET_SERVICE_start (const char *serviceName,
+                      const struct GNUNET_CONFIGURATION_Handle *cfg);
 
 
 /**
@@ -120,9 +139,8 @@ struct GNUNET_SERVICE_Context *GNUNET_SERVICE_start (const char *serviceName,
  * @param ctx the service context returned from the start function
  * @return handle to the server for this service, NULL if there is none
  */
-struct GNUNET_SERVER_Handle *GNUNET_SERVICE_get_server (struct
-                                                        GNUNET_SERVICE_Context
-                                                        *ctx);
+struct GNUNET_SERVER_Handle *
+GNUNET_SERVICE_get_server (struct GNUNET_SERVICE_Context *ctx);
 
 
 /**
@@ -130,7 +148,8 @@ struct GNUNET_SERVER_Handle *GNUNET_SERVICE_get_server (struct
  *
  * @param sctx the service context returned from the start function
  */
-void GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Context *sctx);
+void
+GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Context *sctx);
 
 
 #if 0                           /* keep Emacsens' auto-indent happy */