equal
deleted
inserted
replaced
|
1 #ifndef LIBQMSK_SERVICE_H |
|
2 #define LIBQMSK_SERVICE_H |
|
3 |
|
4 /** |
|
5 * @file |
|
6 * |
|
7 * Defines a simple interface for creating services, which listen for connections and create transport_t's. |
|
8 */ |
|
9 #include "transport.h" |
|
10 |
|
11 /** |
|
12 * Opaque state struct. |
|
13 */ |
|
14 typedef struct service service_t; |
|
15 |
|
16 /** |
|
17 * User callbacks for services. |
|
18 */ |
|
19 struct service_callbacks { |
|
20 /** |
|
21 * The service broke. |
|
22 * |
|
23 * This is only called for errors which occur when called directly from the event loop, and never for errors that |
|
24 * occur inside of calls to service_*. |
|
25 */ |
|
26 void (*on_error) (service_t *service, const error_t *err, void *arg); |
|
27 }; |
|
28 |
|
29 /** |
|
30 * User info required to build a service |
|
31 */ |
|
32 struct service_info { |
|
33 /** Callback table */ |
|
34 const struct service_callbacks *cb_tbl; |
|
35 |
|
36 /** Callback context arg */ |
|
37 void *cb_arg; |
|
38 |
|
39 /** Settings for the service's client transports */ |
|
40 struct transport_info trans_info; |
|
41 }; |
|
42 |
|
43 /** |
|
44 * Destroy a service to stop accepting any connections and release all resources. |
|
45 * |
|
46 * Any connected client transports should stay intact (?) |
|
47 */ |
|
48 void service_destroy (service_t *service); |
|
49 |
|
50 #endif |