]>
code.delx.au - pulseaudio/blob - src/protocol-cli.c
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
;
16 idxset_remove_by_data(p
->connections
, c
, NULL
);
20 static void on_connection(struct socket_server
*s
, struct iochannel
*io
, void *userdata
) {
21 struct protocol_cli
*p
= userdata
;
25 c
= cli_new(p
->core
, io
);
27 cli_set_eof_callback(c
, cli_eof_cb
, p
);
29 idxset_put(p
->connections
, c
, NULL
);
32 struct protocol_cli
* protocol_cli_new(struct core
*core
, struct socket_server
*server
) {
33 struct protocol_cli
* p
;
34 assert(core
&& server
);
36 p
= malloc(sizeof(struct protocol_cli
));
40 p
->connections
= idxset_new(NULL
, NULL
);
42 socket_server_set_callback(p
->server
, on_connection
, p
);
47 static void free_connection(void *p
, void *userdata
) {
52 void protocol_cli_free(struct protocol_cli
*p
) {
55 idxset_free(p
->connections
, free_connection
, NULL
);
56 socket_server_free(p
->server
);