/[svn]/liblscp/trunk/examples/example_client.c
ViewVC logotype

Contents of /liblscp/trunk/examples/example_client.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 189 - (show annotations) (download)
Thu Jul 8 16:31:47 2004 UTC (19 years, 9 months ago) by capela
File MIME type: text/plain
File size: 21337 byte(s)
- fixes underway; example_client/server are better crash test dummies now.

1 // example_client.c
2 //
3 /****************************************************************************
4 Copyright (C) 2004, rncbc aka Rui Nuno Capela. All rights reserved.
5
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 *****************************************************************************/
21
22 #include "lscp/client.h"
23 #include "lscp/device.h"
24
25 #include <time.h>
26
27 #define SERVER_PORT 8888
28
29 #if defined(WIN32)
30 static WSADATA _wsaData;
31 #endif
32
33 ////////////////////////////////////////////////////////////////////////
34
35 lscp_status_t client_callback ( lscp_client_t *pClient, lscp_event_t event, const char *pchData, int cchData, void *pvData )
36 {
37 lscp_status_t ret = LSCP_FAILED;
38
39 char *pszData = (char *) malloc(cchData + 1);
40 if (pszData) {
41 memcpy(pszData, pchData, cchData);
42 pszData[cchData] = (char) 0;
43 printf("client_callback: event=%s (0x%04x) [%s]\n", lscp_event_to_text(event), (int) event, pszData);
44 free(pszData);
45 ret = LSCP_OK;
46 }
47
48 return ret;
49 }
50
51 ////////////////////////////////////////////////////////////////////////
52
53 int client_test_int ( int i )
54 {
55 printf("%d\n", i);
56 return (i >= 0 ? 0 : 1);
57 }
58
59
60 int client_test_status ( lscp_status_t s )
61 {
62 const char *pszStatus;
63
64 switch (s) {
65 case LSCP_OK: pszStatus = "OK"; break;
66 case LSCP_FAILED: pszStatus = "FAILED"; break;
67 case LSCP_ERROR: pszStatus = "ERROR"; break;
68 case LSCP_WARNING: pszStatus = "WARNING"; break;
69 case LSCP_TIMEOUT: pszStatus = "TIMEOUT"; break;
70 case LSCP_QUIT: pszStatus = "QUIT"; break;
71 default: pszStatus = "NONE"; break;
72 }
73 printf("%s\n", pszStatus);
74 return (s == LSCP_OK ? 0 : 1);
75 }
76
77
78 int client_test_isplit ( int *piSplit )
79 {
80 int i;
81
82 printf("{");
83 for (i = 0; piSplit && piSplit[i] >= 0; i++) {
84 if (i > 0)
85 printf(",");
86 printf(" %d", piSplit[i]);
87 }
88 printf(" }\n");
89 return 0;
90 }
91
92
93 int client_test_szsplit ( char **ppszSplit )
94 {
95 int i;
96
97 printf("{");
98 for (i = 0; ppszSplit && ppszSplit[i]; i++) {
99 if (i > 0)
100 printf(",");
101 printf(" %s", ppszSplit[i]);
102 }
103 printf(" }\n");
104 return 0;
105 }
106
107
108 int client_test_params ( lscp_param_t *pParams )
109 {
110 int i;
111
112 printf("{");
113 for (i = 0; pParams && pParams[i].key; i++) {
114 if (i > 0)
115 printf(",");
116 printf(" %s='%s'", pParams[i].key, pParams[i].value);
117 }
118 printf(" }\n");
119 return 0;
120 }
121
122
123 int client_test_param_info ( lscp_param_info_t *pParamInfo )
124 {
125 const char *pszType;
126
127 if (pParamInfo == NULL) {
128 printf("(nil)\n");
129 return 1;
130 }
131 switch (pParamInfo->type) {
132 case LSCP_TYPE_BOOL: pszType = "BOOL"; break;
133 case LSCP_TYPE_INT: pszType = "INT"; break;
134 case LSCP_TYPE_FLOAT: pszType = "FLOAT"; break;
135 case LSCP_TYPE_STRING: pszType = "STRING"; break;
136 default: pszType = "NONE"; break;
137 }
138 printf("{\n");
139 printf(" param_info.type = %d (%s)\n", (int) pParamInfo->type, pszType);
140 printf(" param_info.description = %s\n", pParamInfo->description);
141 printf(" param_info.mandatory = %d\n", pParamInfo->mandatory);
142 printf(" param_info.fix = %d\n", pParamInfo->fix);
143 printf(" param_info.multiplicity = %d\n", pParamInfo->multiplicity);
144 printf(" param_info.depends = "); client_test_szsplit(pParamInfo->depends);
145 printf(" param_info.defaultv = %s\n", pParamInfo->defaultv);
146 printf(" param_info.range_min = %s\n", pParamInfo->range_min);
147 printf(" param_info.range_max = %s\n", pParamInfo->range_max);
148 printf(" param_info.possibilities = "); client_test_szsplit(pParamInfo->possibilities);
149 printf(" }\n");
150 return 0;
151 }
152
153
154 int client_test_driver_info ( lscp_driver_info_t *pDriverInfo )
155 {
156 if (pDriverInfo == NULL) {
157 printf("(nil)\n");
158 return 1;
159 }
160 printf("{\n");
161 printf(" driver_info.description = %s\n", pDriverInfo->description);
162 printf(" driver_info.version = %s\n", pDriverInfo->version);
163 printf(" driver_info.parameters = "); client_test_szsplit(pDriverInfo->parameters);
164 printf(" }\n");
165 return 0;
166 }
167
168
169 int client_test_device_info ( lscp_device_info_t *pDeviceInfo )
170 {
171 if (pDeviceInfo == NULL) {
172 printf("(nil)\n");
173 return 1;
174 }
175 printf("{\n");
176 printf(" device_info.driver = %s\n", pDeviceInfo->driver);
177 printf(" device_info.params = "); client_test_params(pDeviceInfo->params);
178 printf(" }\n");
179 return 0;
180 }
181
182
183 int client_test_device_port_info ( lscp_device_port_info_t *pDevicePortInfo )
184 {
185 if (pDevicePortInfo == NULL) {
186 printf("(nil)\n");
187 return 1;
188 }
189 printf("{\n");
190 printf(" device_port_info.name = %s\n", pDevicePortInfo->name);
191 printf(" device_port_info.params = "); client_test_params(pDevicePortInfo->params);
192 printf(" }\n");
193 return 0;
194 }
195
196
197 int client_test_engine_info ( lscp_engine_info_t *pEngineInfo )
198 {
199 if (pEngineInfo == NULL) {
200 printf("(nil)\n");
201 return 1;
202 }
203 printf("{\n");
204 printf(" engine_info.description = %s\n", pEngineInfo->description);
205 printf(" engine_info.version = %s\n", pEngineInfo->version);
206 printf(" }\n");
207 return 0;
208 }
209
210
211 int client_test_channel_info ( lscp_channel_info_t *pChannelInfo )
212 {
213 if (pChannelInfo == NULL) {
214 printf("(nil)\n");
215 return 1;
216 }
217 printf("{\n");
218 printf(" channel_info.engine_name = %s\n", pChannelInfo->engine_name);
219 printf(" channel_info.audio_device = %d\n", pChannelInfo->audio_device);
220 printf(" channel_info.audio_channels = %d\n", pChannelInfo->audio_channels);
221 printf(" channel_info.audio_routing = "); client_test_szsplit(pChannelInfo->audio_routing);
222 printf(" channel_info.instrument_file = %s\n", pChannelInfo->instrument_file);
223 printf(" channel_info.instrument_nr = %d\n", pChannelInfo->instrument_nr);
224 printf(" channel_info.instrument_status = %d\n", pChannelInfo->instrument_status);
225 printf(" channel_info.midi_device = %d\n", pChannelInfo->midi_device);
226 printf(" channel_info.midi_port = %d\n", pChannelInfo->midi_port);
227 printf(" channel_info.midi_channel = %d\n", pChannelInfo->midi_channel);
228 printf(" channel_info.volume = %g\n", pChannelInfo->volume);
229 printf(" }\n");
230 return 0;
231 }
232
233
234 int client_test_buffer_fill ( lscp_buffer_fill_t *pBufferFill )
235 {
236 if (pBufferFill == NULL) {
237 printf("(nil)\n");
238 return 1;
239 }
240 printf("{ <%p> }\n", pBufferFill);
241 return 0;
242 }
243
244
245 ////////////////////////////////////////////////////////////////////////
246
247 static int g_test_step = 0;
248 static int g_test_count = 0;
249 static int g_test_fails = 0;
250
251
252 void client_test_start ( clock_t *pclk ) { *pclk = clock(); }
253 float client_test_elapsed ( clock_t *pclk ) { return (float) ((long) clock() - *pclk) / (float) CLOCKS_PER_SEC; }
254
255 typedef int * isplit;
256 typedef char ** szsplit;
257 typedef lscp_status_t status;
258 typedef lscp_driver_info_t * driver_info;
259 typedef lscp_device_info_t * device_info;
260 typedef lscp_device_port_info_t * device_port_info;
261 typedef lscp_param_info_t * param_info;
262 typedef lscp_engine_info_t * engine_info;
263 typedef lscp_channel_info_t * channel_info;
264 typedef lscp_buffer_fill_t * buffer_fill;
265
266 #define CLIENT_TEST(p, t, x) { clock_t c; void *v; g_test_count++; \
267 printf("\n" #x ":\n"); client_test_start(&c); v = (void *) (x); \
268 printf(" elapsed=%gs errno=%d result='%s...' ret=", \
269 client_test_elapsed(&c), \
270 lscp_client_get_errno(p), \
271 lscp_client_get_result(p)); \
272 if (client_test_##t((t)(v))) { g_test_fails++; getchar(); } \
273 else if (g_test_step) getchar(); }
274
275
276 void client_test_engine ( lscp_client_t *pClient, const char *pszEngine, const char *pszAudioDriver, int iAudioDevice, const char *pszMidiDriver, int iMidiDevice )
277 {
278 int iSamplerChannel;
279
280 printf("\n--- pszEngine=\"%s\" pszAudioDevice=\"%s\" iAudioDevice=%d pszMidiDevice=\"%s\" iMidiDevice=%d ---\n", pszEngine, pszAudioDriver, iAudioDevice, pszMidiDriver, iMidiDevice);
281 CLIENT_TEST(pClient, engine_info, lscp_get_engine_info(pClient, pszEngine));
282 CLIENT_TEST(pClient, int, lscp_get_channels(pClient));
283 CLIENT_TEST(pClient, isplit, lscp_list_channels(pClient));
284 CLIENT_TEST(pClient, int, iSamplerChannel = lscp_add_channel(pClient));
285 printf("\n--- iSamplerChannel=%d ---\n", iSamplerChannel);
286 CLIENT_TEST(pClient, channel_info, lscp_get_channel_info(pClient, iSamplerChannel));
287 CLIENT_TEST(pClient, status, lscp_load_engine(pClient, pszEngine, iSamplerChannel));
288 CLIENT_TEST(pClient, status, lscp_load_instrument(pClient, "DefaultInstrument.gig", 0, iSamplerChannel));
289 CLIENT_TEST(pClient, int, lscp_get_channel_voice_count(pClient, iSamplerChannel));
290 CLIENT_TEST(pClient, int, lscp_get_channel_stream_count(pClient, iSamplerChannel));
291 CLIENT_TEST(pClient, int, lscp_get_channel_stream_usage(pClient, iSamplerChannel));
292 CLIENT_TEST(pClient, buffer_fill, lscp_get_channel_buffer_fill(pClient, LSCP_USAGE_BYTES, iSamplerChannel));
293 CLIENT_TEST(pClient, buffer_fill, lscp_get_channel_buffer_fill(pClient, LSCP_USAGE_PERCENTAGE, iSamplerChannel));
294 CLIENT_TEST(pClient, status, lscp_set_channel_audio_type(pClient, iSamplerChannel, pszAudioDriver));
295 CLIENT_TEST(pClient, status, lscp_set_channel_audio_device(pClient, iSamplerChannel, 0));
296 CLIENT_TEST(pClient, status, lscp_set_channel_audio_channel(pClient, iSamplerChannel, 0, 1));
297 CLIENT_TEST(pClient, status, lscp_set_channel_midi_type(pClient, iSamplerChannel, pszMidiDriver));
298 CLIENT_TEST(pClient, status, lscp_set_channel_midi_device(pClient, iSamplerChannel, 0));
299 CLIENT_TEST(pClient, status, lscp_set_channel_midi_channel(pClient, iSamplerChannel, 0));
300 CLIENT_TEST(pClient, status, lscp_set_channel_midi_port(pClient, iSamplerChannel, 0));
301 CLIENT_TEST(pClient, status, lscp_set_channel_volume(pClient, iSamplerChannel, 0.5));
302 CLIENT_TEST(pClient, channel_info, lscp_get_channel_info(pClient, iSamplerChannel));
303 CLIENT_TEST(pClient, status, lscp_reset_channel(pClient, iSamplerChannel));
304 CLIENT_TEST(pClient, status, lscp_remove_channel(pClient, iSamplerChannel));
305 }
306
307
308 void client_test_midi_port ( lscp_client_t *pClient, int iMidiDevice, int iMidiPort )
309 {
310 lscp_device_port_info_t *pMidiPortInfo;
311 const char *pszParam;
312 int i;
313
314 printf("\n--- iMidiDevice=%d iMidiPort=%d ---\n", iMidiDevice, iMidiPort);
315 CLIENT_TEST(pClient, device_port_info, pMidiPortInfo = lscp_get_midi_port_info(pClient, iMidiDevice, iMidiPort));
316 if (pMidiPortInfo && pMidiPortInfo->params) {
317 for (i = 0; pMidiPortInfo->params[i].key; i++) {
318 pszParam = pMidiPortInfo->params[i].key;
319 printf("\n--- iMidiDevice=%d iMidiPort=%d pszParam=\"%s\" ---\n", iMidiDevice, iMidiPort, pszParam);
320 CLIENT_TEST(pClient, param_info, lscp_get_midi_port_param_info(pClient, iMidiDevice, iMidiPort, pszParam));
321 }
322 }
323 }
324
325
326 void client_test_audio_channel ( lscp_client_t *pClient, int iAudioDevice, int iAudioChannel )
327 {
328 lscp_device_port_info_t *pAudioChannelInfo;
329 const char *pszParam;
330 int i;
331
332 printf("\n--- iAudioDevice=%d iAudioChannel=%d ---\n", iAudioDevice, iAudioChannel);
333 CLIENT_TEST(pClient, device_port_info, pAudioChannelInfo = lscp_get_audio_channel_info(pClient, iAudioDevice, iAudioChannel));
334 if (pAudioChannelInfo && pAudioChannelInfo->params) {
335 for (i = 0; pAudioChannelInfo->params[i].key; i++) {
336 pszParam = pAudioChannelInfo->params[i].key;
337 printf("\n--- iAudioDevice=%d iAudioChannel=%d pszParam=\"%s\" ---\n", iAudioDevice, iAudioChannel, pszParam);
338 CLIENT_TEST(pClient, param_info, lscp_get_audio_channel_param_info(pClient, iAudioDevice, iAudioChannel, pszParam));
339 }
340 }
341 }
342
343
344 void client_test_midi_device ( lscp_client_t *pClient, int iMidiDevice )
345 {
346 lscp_device_info_t *pDeviceInfo;
347 const char *pszValue;
348 int iMidiPort, iMidiPorts;
349
350 printf("\n--- iMidiDevice=%d ---\n", iMidiDevice);
351 CLIENT_TEST(pClient, device_info, pDeviceInfo = lscp_get_midi_device_info(pClient, iMidiDevice));
352 if (pDeviceInfo && pDeviceInfo->params) {
353 pszValue = lscp_get_param_value(pDeviceInfo->params, "ports");
354 if (pszValue) {
355 iMidiPorts = atoi(pszValue);
356 for (iMidiPort = 0; iMidiPort < iMidiPorts; iMidiPort++)
357 client_test_midi_port(pClient, iMidiDevice, iMidiPort);
358 }
359 }
360 }
361
362
363 void client_test_audio_device ( lscp_client_t *pClient, int iAudioDevice )
364 {
365 lscp_device_info_t *pDeviceInfo;
366 const char *pszValue;
367 int iAudioChannel, iAudioChannels;
368
369 printf("\n--- iAudioDevice=%d ---\n", iAudioDevice);
370 CLIENT_TEST(pClient, device_info, pDeviceInfo = lscp_get_audio_device_info(pClient, iAudioDevice));
371 if (pDeviceInfo && pDeviceInfo->params) {
372 pszValue = lscp_get_param_value(pDeviceInfo->params, "channels");
373 if (pszValue) {
374 iAudioChannels = atoi(pszValue);
375 for (iAudioChannel = 0; iAudioChannel < iAudioChannels; iAudioChannel++)
376 client_test_audio_channel(pClient, iAudioDevice, iAudioChannel);
377 }
378 }
379 }
380
381
382 void client_test_midi_driver ( lscp_client_t *pClient, const char *pszMidiDriver )
383 {
384 lscp_driver_info_t *pDriverInfo;
385 const char *pszParam;
386 int i;
387
388 printf("\n--- pszMidiDriver=\"%s\" ---\n", pszMidiDriver);
389 CLIENT_TEST(pClient, driver_info, pDriverInfo = lscp_get_midi_driver_info(pClient, pszMidiDriver));
390 if (pDriverInfo && pDriverInfo->parameters) {
391 for (i = 0; pDriverInfo->parameters[i]; i++) {
392 pszParam = pDriverInfo->parameters[i];
393 printf("\n--- pszMidiDriver=\"%s\" pszParam=\"%s\" ---\n", pszMidiDriver, pszParam);
394 CLIENT_TEST(pClient, param_info, lscp_get_midi_driver_param_info(pClient, pszMidiDriver, pszParam, NULL));
395 }
396 }
397 }
398
399
400 void client_test_audio_driver ( lscp_client_t *pClient, const char *pszAudioDriver )
401 {
402 lscp_driver_info_t *pDriverInfo;
403 const char *pszParam;
404 int i;
405
406 printf("\n--- pszAudioDriver=\"%s\" ---\n", pszAudioDriver);
407 CLIENT_TEST(pClient, driver_info, pDriverInfo = lscp_get_audio_driver_info(pClient, pszAudioDriver));
408 if (pDriverInfo && pDriverInfo->parameters) {
409 for (i = 0; pDriverInfo->parameters[i]; i++) {
410 pszParam = pDriverInfo->parameters[i];
411 printf("\n--- pszAudioDriver=\"%s\" pszParam=\"%s\" ---\n", pszAudioDriver, pszParam);
412 CLIENT_TEST(pClient, param_info, lscp_get_audio_driver_param_info(pClient, pszAudioDriver, pszParam, NULL));
413 }
414 }
415 }
416
417
418 void client_test_all ( lscp_client_t *pClient )
419 {
420 const char **ppszAudioDrivers, **ppszMidiDrivers, **ppszEngines;
421 const char *pszAudioDriver, *pszMidiDriver, *pszEngine;
422 int iAudioDriver, iMidiDriver, iEngine;
423 int iAudio, iAudioDevice, iMidi, iMidiDevice;
424 int iNewAudioDevice, iNewMidiDevice;
425 int *piAudioDevices, *piMidiDevices;
426
427 g_test_count = 0;
428 g_test_fails = 0;
429
430 CLIENT_TEST(pClient, szsplit, ppszAudioDrivers = lscp_get_available_audio_drivers(pClient));
431 if (ppszAudioDrivers == NULL) {
432 fprintf(stderr, "client_test: No audio drivers available.\n");
433 return;
434 }
435
436 CLIENT_TEST(pClient, szsplit, ppszMidiDrivers = lscp_get_available_midi_drivers(pClient));
437 if (ppszMidiDrivers == NULL) {
438 fprintf(stderr, "client_test: No MIDI drivers available.\n");
439 return;
440 }
441
442 CLIENT_TEST(pClient, szsplit, ppszEngines = lscp_get_available_engines(pClient));
443 if (ppszEngines == NULL) {
444 fprintf(stderr, "client_test: No engines available.\n");
445 return;
446 }
447
448 for (iAudioDriver = 0; ppszAudioDrivers[iAudioDriver]; iAudioDriver++) {
449 pszAudioDriver = ppszAudioDrivers[iAudioDriver];
450 client_test_audio_driver(pClient, pszAudioDriver);
451 CLIENT_TEST(pClient, int, iNewAudioDevice = lscp_create_audio_device(pClient, pszAudioDriver, NULL));
452 CLIENT_TEST(pClient, int, lscp_get_audio_devices(pClient));
453 CLIENT_TEST(pClient, isplit, piAudioDevices = lscp_list_audio_devices(pClient));
454 for (iAudio = 0; piAudioDevices && piAudioDevices[iAudio] >= 0; iAudio++) {
455 iAudioDevice = piAudioDevices[iAudio];
456 client_test_audio_device(pClient, iAudioDevice);
457 for (iMidiDriver = 0; ppszMidiDrivers[iMidiDriver]; iMidiDriver++) {
458 pszMidiDriver = ppszMidiDrivers[iMidiDriver];
459 client_test_midi_driver(pClient, pszMidiDriver);
460 CLIENT_TEST(pClient, int, iNewMidiDevice = lscp_create_midi_device(pClient, pszMidiDriver, NULL));
461 CLIENT_TEST(pClient, int, lscp_get_midi_devices(pClient));
462 CLIENT_TEST(pClient, isplit, piMidiDevices = lscp_list_midi_devices(pClient));
463 for (iMidi = 0; piMidiDevices && piMidiDevices[iMidi] >= 0; iMidi++) {
464 iMidiDevice = piMidiDevices[iMidi];
465 client_test_midi_device(pClient, iMidiDevice);
466 for (iEngine = 0; ppszEngines[iEngine]; iEngine++) {
467 pszEngine = ppszEngines[iEngine];
468 client_test_engine(pClient, pszEngine, pszAudioDriver, iAudioDevice, pszMidiDriver, iMidiDevice);
469 }
470 }
471 CLIENT_TEST(pClient, status, lscp_destroy_midi_device(pClient, iNewMidiDevice));
472 }
473 }
474 CLIENT_TEST(pClient, status, lscp_destroy_audio_device(pClient, iNewAudioDevice));
475 }
476 printf("\n\n");
477 printf(" Total: %d tests, %d failed.\n\n", g_test_count, g_test_fails);
478 }
479
480
481 ////////////////////////////////////////////////////////////////////////
482
483 void client_usage (void)
484 {
485 printf("\n %s %s (Build: %s)\n", lscp_client_package(), lscp_client_version(), lscp_client_build());
486
487 fputs("\n Available commands: help, test[step], exit, quit, subscribe, unsubscribe", stdout);
488 fputs("\n (all else are sent verbatim to server)\n\n", stdout);
489
490 }
491
492 void client_prompt (void)
493 {
494 fputs("lscp_client> ", stdout);
495 }
496
497 int main (int argc, char *argv[] )
498 {
499 lscp_client_t *pClient;
500 char *pszHost = "localhost";
501 char szLine[1024];
502 int cchLine;
503 lscp_status_t ret;
504
505 #if defined(WIN32)
506 if (WSAStartup(MAKEWORD(1, 1), &_wsaData) != 0) {
507 fprintf(stderr, "lscp_client: WSAStartup failed.\n");
508 return -1;
509 }
510 #endif
511
512 if (argc > 1)
513 pszHost = argv[1];
514
515 pClient = lscp_client_create(pszHost, SERVER_PORT, client_callback, NULL);
516 if (pClient == NULL)
517 return -1;
518
519 client_usage();
520 client_prompt();
521
522 while (fgets(szLine, sizeof(szLine) - 3, stdin)) {
523
524 cchLine = strlen(szLine);
525 while (cchLine > 0 && (szLine[cchLine - 1] == '\n' || szLine[cchLine - 1] == '\r'))
526 cchLine--;
527 szLine[cchLine] = '\0';
528
529 if (strcmp(szLine, "exit") == 0 || strcmp(szLine, "quit") == 0)
530 break;
531 else
532 if (strcmp(szLine, "subscribe") == 0)
533 lscp_client_subscribe(pClient, LSCP_EVENT_MISCELLANEOUS);
534 else
535 if (strcmp(szLine, "unsubscribe") == 0)
536 lscp_client_unsubscribe(pClient, LSCP_EVENT_MISCELLANEOUS);
537 else
538 if (strcmp(szLine, "test") == 0)
539 client_test_all(pClient);
540 else
541 if (strcmp(szLine, "teststep") == 0 || strcmp(szLine, "test step") == 0) {
542 g_test_step = 1;
543 client_test_all(pClient);
544 g_test_step = 0;
545 }
546 else
547 if (cchLine > 0 && strcmp(szLine, "help") != 0) {
548 szLine[cchLine++] = '\r';
549 szLine[cchLine++] = '\n';
550 szLine[cchLine] = '\0';
551 ret = lscp_client_query(pClient, szLine);
552 printf("%s\n(errno = %d)\n", lscp_client_get_result(pClient), lscp_client_get_errno(pClient));
553 if (ret == LSCP_QUIT)
554 break;
555 }
556 else client_usage();
557
558 client_prompt();
559 }
560
561 lscp_client_destroy(pClient);
562
563 #if defined(WIN32)
564 WSACleanup();
565 #endif
566
567 return 0;
568 }
569
570 // end of example_client.c

  ViewVC Help
Powered by ViewVC