1 |
capela |
146 |
// event.c |
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 |
|
|
#include "lscp/event.h" |
24 |
|
|
|
25 |
|
|
// Case unsensitive comparison substitutes. |
26 |
|
|
#if defined(WIN32) |
27 |
|
|
#define strcasecmp stricmp |
28 |
|
|
#define strncasecmp strnicmp |
29 |
|
|
#endif |
30 |
|
|
|
31 |
|
|
|
32 |
|
|
//------------------------------------------------------------------------- |
33 |
|
|
// Simple event helper functions. |
34 |
|
|
|
35 |
|
|
|
36 |
|
|
/** |
37 |
|
|
* Getting the text string representation of a single event. |
38 |
|
|
* |
39 |
|
|
* @param event Event to convert to text string. |
40 |
|
|
* |
41 |
|
|
* @returns The text string representation of the event. |
42 |
|
|
*/ |
43 |
|
|
const char *lscp_event_to_text ( lscp_event_t event ) |
44 |
|
|
{ |
45 |
|
|
const char *pszText = NULL; |
46 |
capela |
562 |
|
47 |
capela |
146 |
switch (event) { |
48 |
capela |
562 |
case LSCP_EVENT_CHANNEL_COUNT: |
49 |
|
|
pszText = "CHANNEL_COUNT"; |
50 |
capela |
146 |
break; |
51 |
|
|
case LSCP_EVENT_VOICE_COUNT: |
52 |
|
|
pszText = "VOICE_COUNT"; |
53 |
|
|
break; |
54 |
|
|
case LSCP_EVENT_STREAM_COUNT: |
55 |
|
|
pszText = "STREAM_COUNT"; |
56 |
|
|
break; |
57 |
|
|
case LSCP_EVENT_BUFFER_FILL: |
58 |
|
|
pszText = "BUFFER_FILL"; |
59 |
|
|
break; |
60 |
|
|
case LSCP_EVENT_CHANNEL_INFO: |
61 |
|
|
pszText = "CHANNEL_INFO"; |
62 |
|
|
break; |
63 |
|
|
case LSCP_EVENT_MISCELLANEOUS: |
64 |
|
|
pszText = "MISCELLANEOUS"; |
65 |
|
|
break; |
66 |
capela |
148 |
case LSCP_EVENT_NONE: |
67 |
|
|
default: |
68 |
|
|
break; |
69 |
capela |
146 |
} |
70 |
|
|
|
71 |
|
|
return pszText; |
72 |
|
|
} |
73 |
|
|
|
74 |
|
|
|
75 |
|
|
/** |
76 |
|
|
* Getting an event from a text string. |
77 |
|
|
* |
78 |
|
|
* @param pszText Text string to convert to event. |
79 |
|
|
* |
80 |
|
|
* @returns The event correponding to the text string. |
81 |
|
|
*/ |
82 |
|
|
lscp_event_t lscp_event_from_text ( const char *pszText ) |
83 |
|
|
{ |
84 |
|
|
lscp_event_t event = LSCP_EVENT_NONE; |
85 |
|
|
|
86 |
|
|
if (pszText) { |
87 |
capela |
562 |
if (strcasecmp(pszText, "CHANNEL_COUNT") == 0) |
88 |
|
|
event = LSCP_EVENT_CHANNEL_COUNT; |
89 |
capela |
146 |
else if (strcasecmp(pszText, "VOICE_COUNT") == 0) |
90 |
|
|
event = LSCP_EVENT_VOICE_COUNT; |
91 |
|
|
else if (strcasecmp(pszText, "STREAM_COUNT") == 0) |
92 |
|
|
event = LSCP_EVENT_STREAM_COUNT; |
93 |
|
|
else if (strcasecmp(pszText, "BUFFER_FILL") == 0) |
94 |
|
|
event = LSCP_EVENT_BUFFER_FILL; |
95 |
|
|
else if (strcasecmp(pszText, "CHANNEL_INFO") == 0) |
96 |
|
|
event = LSCP_EVENT_CHANNEL_INFO; |
97 |
|
|
else if (strcasecmp(pszText, "MISCELLANEOUS") == 0) |
98 |
|
|
event = LSCP_EVENT_MISCELLANEOUS; |
99 |
|
|
} |
100 |
|
|
|
101 |
|
|
return event; |
102 |
|
|
} |
103 |
|
|
|
104 |
|
|
|
105 |
|
|
// end of event.c |