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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 623 - (show annotations) (download) (as text)
Thu Jun 9 10:37:19 2005 UTC (18 years, 9 months ago) by capela
File MIME type: text/x-c++hdr
File size: 7871 byte(s)
* [bug #11] Timeout flush idiosyncrasy is now a feature;
  this just tries to flush the receive buffer whenever
  any previous transaction has failed due to a timeout.

1 // common.h
2 //
3 /****************************************************************************
4 liblscp - LinuxSampler Control Protocol API
5 Copyright (C) 2004-2005, 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 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 // Client struct volatile caches.
56 lscp_driver_info_t audio_driver_info;
57 lscp_driver_info_t midi_driver_info;
58 lscp_device_info_t audio_device_info;
59 lscp_device_info_t midi_device_info;
60 lscp_param_info_t audio_param_info;
61 lscp_param_info_t midi_param_info;
62 lscp_device_port_info_t audio_channel_info;
63 lscp_device_port_info_t midi_port_info;
64 lscp_param_info_t audio_channel_param_info;
65 lscp_param_info_t midi_port_param_info;
66 lscp_server_info_t server_info;
67 lscp_engine_info_t engine_info;
68 lscp_channel_info_t channel_info;
69 // Result and error status.
70 char * pszResult;
71 int iErrno;
72 // Stream buffers status.
73 lscp_buffer_fill_t *buffer_fill;
74 int iStreamCount;
75 // Transaction call timeout (msecs).
76 int iTimeout;
77 lscp_mutex_t mutex;
78 lscp_cond_t cond;
79 // Flag last transaction timedout.
80 int iTimeoutCount;
81 };
82
83
84 //-------------------------------------------------------------------------
85 // Local client request executive.
86
87 lscp_status_t lscp_client_recv (lscp_client_t *pClient, char *pchBuffer, int *pcchBuffer, int iTimeout);
88 lscp_status_t lscp_client_call (lscp_client_t *pClient, const char *pszQuery);
89 void lscp_client_set_result (lscp_client_t *pClient, char *pszResult, int iErrno);
90
91 //-------------------------------------------------------------------------
92 // General utility function prototypes.
93
94 char * lscp_strtok (char *pchBuffer, const char *pszSeps, char **ppch);
95 char * lscp_ltrim (char *psz);
96 char * lscp_unquote (char **ppsz, int dup);
97 void lscp_unquote_dup (char **ppszDst, char **ppszSrc);
98
99 char ** lscp_szsplit_create (const char *pszCsv, const char *pszSeps);
100 void lscp_szsplit_destroy (char **ppszSplit);
101 #ifdef LSCP_SZSPLIT_COUNT
102 int lscp_szsplit_count (char **ppszSplit);
103 int lscp_szsplit_size (char **ppszSplit);
104 #endif
105
106 int * lscp_isplit_create (const char *pszCsv, const char *pszSeps);
107 void lscp_isplit_destroy (int *piSplit);
108 #ifdef LSCP_ISPLIT_COUNT
109 int lscp_isplit_count (int *piSplit);
110 int lscp_isplit_size (int *piSplit);
111 #endif
112
113 lscp_param_t * lscp_psplit_create (const char *pszCsv, const char *pszSep1, const char *pszSep2);
114 void lscp_psplit_destroy (lscp_param_t *ppSplit);
115 #ifdef LSCP_PSPLIT_COUNT
116 int lscp_psplit_count (lscp_param_t *ppSplit);
117 int lscp_psplit_size (lscp_param_t *ppSplit);
118 #endif
119
120 void lscp_plist_alloc (lscp_param_t **ppList);
121 void lscp_plist_free (lscp_param_t **ppList);
122 void lscp_plist_append (lscp_param_t **ppList, const char *pszKey, const char *pszValue);
123 #ifdef LSCP_PLIST_COUNT
124 int lscp_plist_count (lscp_param_t **ppList);
125 int lscp_plist_size (lscp_param_t **ppList);
126 #endif
127
128 //-------------------------------------------------------------------------
129 // Server struct helper functions.
130
131 void lscp_server_info_init (lscp_server_info_t *pServerInfo);
132 void lscp_server_info_free (lscp_server_info_t *pServerInfo);
133 void lscp_server_info_reset (lscp_server_info_t *pServerInfo);
134
135 //-------------------------------------------------------------------------
136 // Engine struct helper functions.
137
138 void lscp_engine_info_init (lscp_engine_info_t *pEngineInfo);
139 void lscp_engine_info_free (lscp_engine_info_t *pEngineInfo);
140 void lscp_engine_info_reset (lscp_engine_info_t *pEngineInfo);
141
142 //-------------------------------------------------------------------------
143 // Channel struct helper functions.
144
145 void lscp_channel_info_init (lscp_channel_info_t *pChannelInfo);
146 void lscp_channel_info_free (lscp_channel_info_t *pChannelInfo);
147 void lscp_channel_info_reset (lscp_channel_info_t *pChannelInfo);
148
149 //-------------------------------------------------------------------------
150 // Driver struct helper functions.
151
152 void lscp_driver_info_init (lscp_driver_info_t *pDriverInfo);
153 void lscp_driver_info_free (lscp_driver_info_t *pDriverInfo);
154 void lscp_driver_info_reset (lscp_driver_info_t *pDriverInfo);
155
156 //-------------------------------------------------------------------------
157 // Device struct helper functions.
158
159 void lscp_device_info_init (lscp_device_info_t *pDeviceInfo);
160 void lscp_device_info_free (lscp_device_info_t *pDeviceInfo);
161 void lscp_device_info_reset (lscp_device_info_t *pDeviceInfo);
162
163 //-------------------------------------------------------------------------
164 // Device channel/port struct helper functions.
165
166 void lscp_device_port_info_init (lscp_device_port_info_t *pDevicePortInfo);
167 void lscp_device_port_info_free (lscp_device_port_info_t *pDevicePortInfo);
168 void lscp_device_port_info_reset (lscp_device_port_info_t *pDevicePortInfo);
169
170 //-------------------------------------------------------------------------
171 // Parameter struct helper functions.
172
173 void lscp_param_info_init (lscp_param_info_t *pParamInfo);
174 void lscp_param_info_free (lscp_param_info_t *pParamInfo);
175 void lscp_param_info_reset (lscp_param_info_t *pParamInfo);
176
177 //-------------------------------------------------------------------------
178 // Concatenate a parameter list (key='value'...) into a string.
179
180 int lscp_param_concat (char *pszBuffer, int cchMaxBuffer, lscp_param_t *pParams);
181
182
183 #endif // __LSCP_COMMON_H
184
185 // end of common.h

  ViewVC Help
Powered by ViewVC