3 * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
29 int client_pmmsg (client_t
*client
, char *buf
, unsigned len
)
31 return net_send (client
->sock
, buf
, len
);
34 int client_msgtoall (char *buf
, unsigned len
)
37 for (c
= client_list
.next
; c
!= &client_list
; c
= c
->next
)
38 net_send (c
->sock
, buf
, len
);
43 int client_msgtoall2 (client_t
*client
, char *buf
, unsigned len
)
46 for (c
= client_list
.next
; c
!= &client_list
; c
= c
->next
)
48 net_send (c
->sock
, buf
, len
);
53 /** Create new client's structure */
54 client_t
*client_new (int sock
)
56 /* alloc and init context */
57 client_t
*client
= (client_t
*) malloc (sizeof (client_t
));
66 client
->next
= &client_list
;
67 client
->prev
= client_list
.prev
;
68 client
->prev
->next
= client
;
69 client
->next
->prev
= client
;
74 /** Delete client's structure */
75 int client_quit (client_t
*client
)
77 client
->next
->prev
= client
->prev
;
78 client
->prev
->next
= client
->next
;
88 /** Client Init function */
91 client_list
.next
= &client_list
;
92 client_list
.prev
= &client_list
;