/[svn]/liblscp/trunk/src/common.h
ViewVC logotype

Contents of /liblscp/trunk/src/common.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 952 - (show annotations) (download) (as text)
Tue Nov 28 22:46:32 2006 UTC (17 years, 4 months ago) by capela
File MIME type: text/x-c++hdr
File size: 8539 byte(s)
Code cleanup; preparations for 0.4.1 release (hopefully).

1 // common.h
2 //
3 /****************************************************************************
4 liblscp - LinuxSampler Control Protocol API
5 Copyright (C) 2004-2006, 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 General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 lscp_socket_agent_t cmd;
45 lscp_socket_agent_t evt;
46 // Subscribed events.
47 lscp_event_t events;
48 // Client struct persistent caches.
49 char ** audio_drivers;
50 char ** midi_drivers;
51 int * audio_devices;
52 int * midi_devices;
53 char ** engines;
54 int * channels;
55 lscp_midi_instrument_t *midi_instruments;
56 // Client struct volatile caches.
57 lscp_driver_info_t audio_driver_info;
58 lscp_driver_info_t midi_driver_info;
59 lscp_device_info_t audio_device_info;
60 lscp_device_info_t midi_device_info;
61 lscp_param_info_t audio_param_info;
62 lscp_param_info_t midi_param_info;
63 lscp_device_port_info_t audio_channel_info;
64 lscp_device_port_info_t midi_port_info;
65 lscp_param_info_t audio_channel_param_info;
66 lscp_param_info_t midi_port_param_info;
67 lscp_server_info_t server_info;
68 lscp_engine_info_t engine_info;
69 lscp_channel_info_t channel_info;
70 lscp_midi_instrument_info_t midi_instrument_info;
71 // Result and error status.
72 char * pszResult;
73 int iErrno;
74 // Stream buffers status.
75 lscp_buffer_fill_t *buffer_fill;
76 int iStreamCount;
77 // Transaction call timeout (msecs).
78 int iTimeout;
79 lscp_mutex_t mutex;
80 lscp_cond_t cond;
81 // Flag last transaction timedout.
82 int iTimeoutCount;
83 };
84
85
86 //-------------------------------------------------------------------------
87 // Local client request executive.
88
89 lscp_status_t lscp_client_recv (lscp_client_t *pClient, char *pchBuffer, int *pcchBuffer, int iTimeout);
90 lscp_status_t lscp_client_call (lscp_client_t *pClient, const char *pszQuery, int iResult);
91 void lscp_client_set_result (lscp_client_t *pClient, char *pszResult, int iErrno);
92
93 //-------------------------------------------------------------------------
94 // General utility function prototypes.
95
96 char * lscp_strtok (char *pchBuffer, const char *pszSeps, char **ppch);
97 char * lscp_ltrim (char *psz);
98 char * lscp_unquote (char **ppsz, int dup);
99 void lscp_unquote_dup (char **ppszDst, char **ppszSrc);
100
101 char ** lscp_szsplit_create (const char *pszCsv, const char *pszSeps);
102 void lscp_szsplit_destroy (char **ppszSplit);
103 #ifdef LSCP_SZSPLIT_COUNT
104 int lscp_szsplit_count (char **ppszSplit);
105 int lscp_szsplit_size (char **ppszSplit);
106 #endif
107
108 int * lscp_isplit_create (const char *pszCsv, const char *pszSeps);
109 void lscp_isplit_destroy (int *piSplit);
110 #ifdef LSCP_ISPLIT_COUNT
111 int lscp_isplit_count (int *piSplit);
112 int lscp_isplit_size (int *piSplit);
113 #endif
114
115 lscp_param_t * lscp_psplit_create (const char *pszCsv, const char *pszSep1, const char *pszSep2);
116 void lscp_psplit_destroy (lscp_param_t *ppSplit);
117 #ifdef LSCP_PSPLIT_COUNT
118 int lscp_psplit_count (lscp_param_t *ppSplit);
119 int lscp_psplit_size (lscp_param_t *ppSplit);
120 #endif
121
122 void lscp_plist_alloc (lscp_param_t **ppList);
123 void lscp_plist_free (lscp_param_t **ppList);
124 void lscp_plist_append (lscp_param_t **ppList, const char *pszKey, const char *pszValue);
125 #ifdef LSCP_PLIST_COUNT
126 int lscp_plist_count (lscp_param_t **ppList);
127 int lscp_plist_size (lscp_param_t **ppList);
128 #endif
129
130 lscp_midi_instrument_t *lscp_midi_instruments_create (const char *pszCsv);
131 void lscp_midi_instruments_destroy (lscp_midi_instrument_t *pInstrs);
132 #ifdef LSCP_MIDI_INSTRUMENTS_COUNT
133 int lscp_midi_instruments_count (lscp_midi_instrument_t *pInstrs);
134 int lscp_midi_instruments_size (lscp_midi_instrument_t *pInstrs);
135 #endif
136
137
138 //-------------------------------------------------------------------------
139 // Server struct helper functions.
140
141 void lscp_server_info_init (lscp_server_info_t *pServerInfo);
142 void lscp_server_info_free (lscp_server_info_t *pServerInfo);
143 void lscp_server_info_reset (lscp_server_info_t *pServerInfo);
144
145 //-------------------------------------------------------------------------
146 // Engine struct helper functions.
147
148 void lscp_engine_info_init (lscp_engine_info_t *pEngineInfo);
149 void lscp_engine_info_free (lscp_engine_info_t *pEngineInfo);
150 void lscp_engine_info_reset (lscp_engine_info_t *pEngineInfo);
151
152 //-------------------------------------------------------------------------
153 // Channel struct helper functions.
154
155 void lscp_channel_info_init (lscp_channel_info_t *pChannelInfo);
156 void lscp_channel_info_free (lscp_channel_info_t *pChannelInfo);
157 void lscp_channel_info_reset (lscp_channel_info_t *pChannelInfo);
158
159 //-------------------------------------------------------------------------
160 // Driver struct helper functions.
161
162 void lscp_driver_info_init (lscp_driver_info_t *pDriverInfo);
163 void lscp_driver_info_free (lscp_driver_info_t *pDriverInfo);
164 void lscp_driver_info_reset (lscp_driver_info_t *pDriverInfo);
165
166 //-------------------------------------------------------------------------
167 // Device struct helper functions.
168
169 void lscp_device_info_init (lscp_device_info_t *pDeviceInfo);
170 void lscp_device_info_free (lscp_device_info_t *pDeviceInfo);
171 void lscp_device_info_reset (lscp_device_info_t *pDeviceInfo);
172
173 //-------------------------------------------------------------------------
174 // Device channel/port struct helper functions.
175
176 void lscp_device_port_info_init (lscp_device_port_info_t *pDevicePortInfo);
177 void lscp_device_port_info_free (lscp_device_port_info_t *pDevicePortInfo);
178 void lscp_device_port_info_reset (lscp_device_port_info_t *pDevicePortInfo);
179
180 //-------------------------------------------------------------------------
181 // Parameter struct helper functions.
182
183 void lscp_param_info_init (lscp_param_info_t *pParamInfo);
184 void lscp_param_info_free (lscp_param_info_t *pParamInfo);
185 void lscp_param_info_reset (lscp_param_info_t *pParamInfo);
186
187 //-------------------------------------------------------------------------
188 // Concatenate a parameter list (key='value'...) into a string.
189
190 int lscp_param_concat (char *pszBuffer, int cchMaxBuffer, lscp_param_t *pParams);
191
192 //-------------------------------------------------------------------------
193 // MIDI instrument info struct helper functions.
194
195 void lscp_midi_instrument_info_init (lscp_midi_instrument_info_t *pInstrInfo);
196 void lscp_midi_instrument_info_free (lscp_midi_instrument_info_t *pInstrInfo);
197 void lscp_midi_instrument_info_reset (lscp_midi_instrument_info_t *pInstrInfo);
198
199
200 #endif // __LSCP_COMMON_H
201
202 // end of common.h

  ViewVC Help
Powered by ViewVC