File: clients.h

package info (click to toggle)
muroard 0.1.14-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 420 kB
  • ctags: 424
  • sloc: ansic: 3,645; sh: 505; makefile: 113
file content (95 lines) | stat: -rw-r--r-- 3,535 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//clients.h:

/*
 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2013
 *
 *  This file is part of �RoarD,
 *  a sound server daemon for using the RoarAudio protocol.
 *  See README for details.
 *
 *  This file is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 3
 *  or (at your option) any later version as published by
 *  the Free Software Foundation.
 *
 *  RoarAudio is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this software; see the file COPYING.  If not, write to
 *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
 *  Boston, MA 02110-1301, USA.
 *
 */

#ifndef _MUROARD_CLIENTS_H_
#define _MUROARD_CLIENTS_H_

#define CLIENT_STATE_UNUSED        0
#define CLIENT_STATE_NEW           1
#define CLIENT_STATE_OLD           2
#define CLIENT_STATE_EXECED        3
#define CLIENT_STATE_CLOSING       4
#ifdef MUROARD_FEATURE_INTERNAL_CLIENT
#define CLIENT_STATE_INTERNAL      5
#endif


struct muroard_client {
 int state;
 int stream;
 muroard_handle_t sock;
};

int muroard_client_init(void);
int muroard_client_free(void);
int muroard_client_new(muroard_handle_t sock);
int muroard_client_delete(int id);
int muroard_client_handle(int id);
muroard_handle_t muroard_client_exec(int id);

int muroard_client_handle_new_stream(int id, struct muroard_message * mes);

#ifdef MUROARD_FEATURE_CMD_ATTACH
int muroard_client_handle_attach(int id, struct muroard_message * mes);
#endif
#ifdef MUROARD_FEATURE_CMD_SERVER_OINFO
int muroard_client_handle_server_oinfo(int id, struct muroard_message * mes);
#endif
#ifdef MUROARD_FEATURE_CMD_PASSFH
int muroard_client_handle_passfh(int id, struct muroard_message * mes);
#endif
#ifdef MUROARD_FEATURE_CMD_LIST_CLIENTS
int muroard_client_handle_list_clients(int id, struct muroard_message * mes);
#endif
#ifdef MUROARD_FEATURE_CMD_LIST_STREAMS
int muroard_client_handle_list_streams(int id, struct muroard_message * mes);
#endif
#ifdef MUROARD_FEATURE_CMD_GET_CLIENT
int muroard_client_handle_get_client(int id, struct muroard_message * mes);
#endif
#ifdef MUROARD_FEATURE_CMD_GET_STREAM
int muroard_client_handle_get_stream(int id, struct muroard_message * mes);
#endif
#ifdef MUROARD_FEATURE_CMD_CAPS
int muroard_client_handle_caps(int id, struct muroard_message * mes);
#endif
#ifdef MUROARD_FEATURE_CMD_SERVER_INFO
int muroard_client_handle_server_info(int id, struct muroard_message * mes);
#endif
#ifdef MUROARD_FEATURE_CMD_GETTIMEOFDAY
int muroard_client_handle_gettimeofday(int id, struct muroard_message * mes);
#endif

#define client_get_sock(id)      (muroard_state_member(client)[(id)].state == CLIENT_STATE_UNUSED ? -1 : muroard_state_member(client)[(id)].sock)
#define client_get_stream(id)    (muroard_state_member(client)[(id)].state == CLIENT_STATE_UNUSED ? -1 : muroard_state_member(client)[(id)].stream)
#define client_set_stream_check(id, s) (muroard_state_member(client)[(id)].state == CLIENT_STATE_UNUSED || \
                                        muroard_state_member(client)[(id)].stream != -1 ? -1 : 0)
#define client_set_stream(id, s) (client_set_stream_check((id),(s)) == -1 ? -1 : \
                                  (muroard_state_member(client)[(id)].stream = (s)) && 0)

#endif

//ll