1 |
capela |
103 |
// common.h |
2 |
|
|
// |
3 |
|
|
/**************************************************************************** |
4 |
|
|
liblscp - LinuxSampler Control Protocol API |
5 |
|
|
Copyright (C) 2004, rncbc aka Rui Nuno Capela. All rights reserved. |
6 |
|
|
|
7 |
|
|
This library is free software; you can redistribute it and/or |
8 |
|
|
modify it under the terms of the GNU Lesser General Public |
9 |
|
|
License as published by the Free Software Foundation; either |
10 |
|
|
version 2.1 of the License, or (at your option) any later version. |
11 |
|
|
|
12 |
|
|
This library is distributed in the hope that it will be useful, |
13 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 |
|
|
Lesser General Public License for more details. |
16 |
|
|
|
17 |
|
|
You should have received a copy of the GNU Lesser General Public |
18 |
|
|
License along with this library; if not, write to the Free Software |
19 |
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 |
|
|
|
21 |
|
|
*****************************************************************************/ |
22 |
|
|
|
23 |
|
|
#ifndef __LSCP_COMMON_H |
24 |
|
|
#define __LSCP_COMMON_H |
25 |
|
|
|
26 |
|
|
#include "lscp/client.h" |
27 |
|
|
#include "lscp/device.h" |
28 |
|
|
|
29 |
|
|
|
30 |
|
|
// Case unsensitive comparison substitutes. |
31 |
|
|
#if defined(WIN32) |
32 |
|
|
#define strcasecmp stricmp |
33 |
|
|
#define strncasecmp strnicmp |
34 |
|
|
#endif |
35 |
|
|
|
36 |
|
|
//------------------------------------------------------------------------- |
37 |
|
|
// Client opaque descriptor struct. |
38 |
|
|
|
39 |
|
|
struct _lscp_client_t |
40 |
|
|
{ |
41 |
|
|
// Client socket stuff. |
42 |
|
|
lscp_client_proc_t pfnCallback; |
43 |
|
|
void * pvData; |
44 |
capela |
132 |
lscp_socket_agent_t cmd; |
45 |
|
|
lscp_socket_agent_t evt; |
46 |
capela |
103 |
// Session identifier. |
47 |
|
|
char * sessid; |
48 |
|
|
// Client struct persistent caches. |
49 |
|
|
char ** audio_drivers; |
50 |
|
|
char ** midi_drivers; |
51 |
capela |
125 |
int * audio_devices; |
52 |
|
|
int * midi_devices; |
53 |
capela |
103 |
char ** engines; |
54 |
capela |
125 |
int * channels; |
55 |
capela |
103 |
// Client struct volatile caches. |
56 |
|
|
lscp_driver_info_t audio_info; |
57 |
|
|
lscp_driver_info_t midi_info; |
58 |
|
|
lscp_engine_info_t engine_info; |
59 |
|
|
lscp_channel_info_t channel_info; |
60 |
|
|
// Result and error status. |
61 |
|
|
char * pszResult; |
62 |
|
|
int iErrno; |
63 |
|
|
// Stream buffers status. |
64 |
|
|
lscp_buffer_fill_t *buffer_fill; |
65 |
|
|
int iStreamCount; |
66 |
|
|
// Transaction call timeout (msecs). |
67 |
|
|
int iTimeout; |
68 |
|
|
lscp_mutex_t mutex; |
69 |
|
|
}; |
70 |
|
|
|
71 |
|
|
|
72 |
|
|
//------------------------------------------------------------------------- |
73 |
capela |
132 |
// Local client request executive. |
74 |
|
|
|
75 |
|
|
lscp_status_t lscp_client_call (lscp_client_t *pClient, const char *pszQuery); |
76 |
|
|
void lscp_client_set_result (lscp_client_t *pClient, char *pszResult, int iErrno); |
77 |
|
|
|
78 |
|
|
//------------------------------------------------------------------------- |
79 |
capela |
103 |
// General utility function prototypes. |
80 |
|
|
|
81 |
capela |
132 |
char * lscp_strtok (char *pchBuffer, const char *pszSeps, char **ppch); |
82 |
|
|
char * lscp_ltrim (char *psz); |
83 |
|
|
char * lscp_unquote (char **ppsz, int dup); |
84 |
capela |
103 |
|
85 |
capela |
132 |
char ** lscp_szsplit_create (const char *pszCsv, const char *pszSeps); |
86 |
|
|
void lscp_szsplit_destroy (char **ppszSplit); |
87 |
capela |
103 |
#ifdef LSCP_SZSPLIT_COUNT |
88 |
capela |
132 |
int lscp_szsplit_count (char **ppszSplit); |
89 |
|
|
int lscp_szsplit_size (char **ppszSplit); |
90 |
capela |
103 |
#endif |
91 |
|
|
|
92 |
capela |
132 |
int * lscp_isplit_create (const char *pszCsv, const char *pszSeps); |
93 |
|
|
void lscp_isplit_destroy (int *ppiSplit); |
94 |
capela |
125 |
#ifdef LSCP_ISPLIT_COUNT |
95 |
capela |
132 |
int lscp_isplit_count (int *ppiSplit); |
96 |
|
|
int lscp_isplit_size (int *ppiSplit); |
97 |
capela |
125 |
#endif |
98 |
capela |
103 |
|
99 |
|
|
//------------------------------------------------------------------------- |
100 |
|
|
// Engine struct helper functions. |
101 |
|
|
|
102 |
capela |
132 |
void lscp_engine_info_init (lscp_engine_info_t *pEngineInfo); |
103 |
|
|
void lscp_engine_info_reset (lscp_engine_info_t *pEngineInfo); |
104 |
capela |
103 |
|
105 |
|
|
//------------------------------------------------------------------------- |
106 |
|
|
// Channel struct helper functions. |
107 |
|
|
|
108 |
capela |
132 |
void lscp_channel_info_init (lscp_channel_info_t *pChannelInfo); |
109 |
|
|
void lscp_channel_info_reset (lscp_channel_info_t *pChannelInfo); |
110 |
capela |
103 |
|
111 |
|
|
//------------------------------------------------------------------------- |
112 |
|
|
// Driver struct helper functions. |
113 |
|
|
|
114 |
capela |
132 |
void lscp_driver_info_init (lscp_driver_info_t *pDriverInfo); |
115 |
|
|
void lscp_driver_info_reset (lscp_driver_info_t *pDriverInfo); |
116 |
capela |
103 |
|
117 |
|
|
|
118 |
|
|
#endif // __LSCP_COMMON_H |
119 |
|
|
|
120 |
|
|
// end of common.h |