terom@219: #ifndef LIBQMSK_SERVICE_H terom@219: #define LIBQMSK_SERVICE_H terom@175: terom@175: /** terom@175: * @file terom@175: * terom@175: * Defines a simple interface for creating services, which listen for connections and create transport_t's. terom@175: */ terom@175: #include "transport.h" terom@175: terom@175: /** terom@175: * Opaque state struct. terom@175: */ terom@175: typedef struct service service_t; terom@175: terom@175: /** terom@175: * User callbacks for services. terom@175: */ terom@175: struct service_callbacks { terom@175: /** terom@175: * The service broke. terom@175: * terom@175: * This is only called for errors which occur when called directly from the event loop, and never for errors that terom@175: * occur inside of calls to service_*. terom@175: */ terom@175: void (*on_error) (service_t *service, const error_t *err, void *arg); terom@175: }; terom@175: terom@175: /** terom@175: * User info required to build a service terom@175: */ terom@175: struct service_info { terom@175: /** Callback table */ terom@175: const struct service_callbacks *cb_tbl; terom@175: terom@175: /** Callback context arg */ terom@175: void *cb_arg; terom@175: terom@175: /** Settings for the service's client transports */ terom@175: struct transport_info trans_info; terom@175: }; terom@175: terom@175: /** terom@175: * Destroy a service to stop accepting any connections and release all resources. terom@175: * terom@175: * Any connected client transports should stay intact (?) terom@175: */ terom@175: void service_destroy (service_t *service); terom@175: terom@219: #endif