]>
code.delx.au - pulseaudio/blob - src/client.c
9 struct client
*client_new(struct core
*core
, const char *protocol_name
, char *name
) {
14 c
= malloc(sizeof(struct client
));
16 c
->name
= name
? strdup(name
) : NULL
;
18 c
->protocol_name
= protocol_name
;
23 r
= idxset_put(core
->clients
, c
, &c
->index
);
24 assert(c
->index
!= IDXSET_INVALID
&& r
>= 0);
26 fprintf(stderr
, "client: created %u \"%s\"\n", c
->index
, c
->name
);
31 void client_free(struct client
*c
) {
34 idxset_remove_by_data(c
->core
->clients
, c
, NULL
);
35 fprintf(stderr
, "client: freed %u \"%s\"\n", c
->index
, c
->name
);
40 void client_kill(struct client
*c
) {
46 char *client_list_to_string(struct core
*c
) {
48 struct client
*client
;
49 uint32_t index
= IDXSET_INVALID
;
55 strbuf_printf(s
, "%u client(s).\n", idxset_ncontents(c
->clients
));
57 for (client
= idxset_first(c
->clients
, &index
); client
; client
= idxset_next(c
->clients
, &index
))
58 strbuf_printf(s
, " index: %u, name: <%s>, protocol_name: <%s>\n", client
->index
, client
->name
, client
->protocol_name
);
60 return strbuf_tostring_free(s
);
64 void client_rename(struct client
*c
, const char *name
) {
67 c
->name
= name
? strdup(name
) : NULL
;