]>
code.delx.au - pulseaudio/blob - src/protocol-cli.c
c0c93d981f69535f35b7c5c9a2cb1b81ca391479
4 #include "protocol-cli.h"
9 struct socket_server
*server
;
10 struct idxset
*connections
;
13 static void cli_eof_cb(struct cli
*c
, void*userdata
) {
14 struct protocol_cli
*p
= userdata
;
17 idxset_remove_by_data(p
->connections
, c
, NULL
);
21 static void on_connection(struct socket_server
*s
, struct iochannel
*io
, void *userdata
) {
22 struct protocol_cli
*p
= userdata
;
26 c
= cli_new(p
->core
, io
);
28 cli_set_eof_callback(c
, cli_eof_cb
, p
);
30 idxset_put(p
->connections
, c
, NULL
);
33 struct protocol_cli
* protocol_cli_new(struct core
*core
, struct socket_server
*server
) {
34 struct protocol_cli
* p
;
35 assert(core
&& server
);
37 p
= malloc(sizeof(struct protocol_cli
));
41 p
->connections
= idxset_new(NULL
, NULL
);
43 socket_server_set_callback(p
->server
, on_connection
, p
);
48 static void free_connection(void *p
, void *userdata
) {
53 void protocol_cli_free(struct protocol_cli
*p
) {
56 idxset_free(p
->connections
, free_connection
, NULL
);
57 socket_server_free(p
->server
);