common.h

Go to the documentation of this file.
00001 // common.h
00002 //
00003 /****************************************************************************
00004    liblscp - LinuxSampler Control Protocol API
00005    Copyright (C) 2004-2005, rncbc aka Rui Nuno Capela. All rights reserved.
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Lesser General Public
00009    License as published by the Free Software Foundation; either
00010    version 2.1 of the License, or (at your option) any later version.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00015    Lesser General Public License for more details.
00016 
00017    You should have received a copy of the GNU Lesser General Public
00018    License along with this library; if not, write to the Free Software
00019    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00020 
00021 *****************************************************************************/
00022 
00023 #ifndef __LSCP_COMMON_H
00024 #define __LSCP_COMMON_H
00025 
00026 #include "lscp/client.h"
00027 #include "lscp/device.h"
00028 
00029 
00030 // Case unsensitive comparison substitutes.
00031 #if defined(WIN32)
00032 #define strcasecmp      stricmp
00033 #define strncasecmp     strnicmp
00034 #endif
00035 
00036 //-------------------------------------------------------------------------
00037 // Client opaque descriptor struct.
00038 
00039 struct _lscp_client_t
00040 {
00041     // Client socket stuff.
00042     lscp_client_proc_t  pfnCallback;
00043     void *              pvData;
00044     lscp_socket_agent_t cmd;
00045     lscp_socket_agent_t evt;
00046     // Subscribed events.
00047     lscp_event_t        events;
00048     // Client struct persistent caches.
00049     char **             audio_drivers;
00050     char **             midi_drivers;
00051     int  *              audio_devices;
00052     int  *              midi_devices;
00053     char **             engines;
00054     int  *              channels;
00055     // Client struct volatile caches.
00056     lscp_driver_info_t  audio_driver_info;
00057     lscp_driver_info_t  midi_driver_info;
00058     lscp_device_info_t  audio_device_info;
00059     lscp_device_info_t  midi_device_info;
00060     lscp_param_info_t   audio_param_info;
00061     lscp_param_info_t   midi_param_info;
00062     lscp_device_port_info_t audio_channel_info;
00063     lscp_device_port_info_t midi_port_info;
00064     lscp_param_info_t   audio_channel_param_info;
00065     lscp_param_info_t   midi_port_param_info;
00066     lscp_server_info_t  server_info;
00067     lscp_engine_info_t  engine_info;
00068     lscp_channel_info_t channel_info;
00069     // Result and error status.
00070     char *              pszResult;
00071     int                 iErrno;
00072     // Stream buffers status.
00073     lscp_buffer_fill_t *buffer_fill;
00074     int                 iStreamCount;
00075     // Transaction call timeout (msecs).
00076     int                 iTimeout;
00077     lscp_mutex_t        mutex;
00078     lscp_cond_t         cond;
00079     // Flag last transaction timedout.
00080     int                 iTimeoutCount;
00081 };
00082 
00083 
00084 //-------------------------------------------------------------------------
00085 // Local client request executive.
00086 
00087 lscp_status_t   lscp_client_recv            (lscp_client_t *pClient, char *pchBuffer, int *pcchBuffer, int iTimeout);
00088 lscp_status_t   lscp_client_call            (lscp_client_t *pClient, const char *pszQuery);
00089 void            lscp_client_set_result      (lscp_client_t *pClient, char *pszResult, int iErrno);
00090 
00091 //-------------------------------------------------------------------------
00092 // General utility function prototypes.
00093 
00094 char *          lscp_strtok                 (char *pchBuffer, const char *pszSeps, char **ppch);
00095 char *          lscp_ltrim                  (char *psz);
00096 char *          lscp_unquote                (char **ppsz, int dup);
00097 void            lscp_unquote_dup            (char **ppszDst, char **ppszSrc);
00098 
00099 char **         lscp_szsplit_create         (const char *pszCsv, const char *pszSeps);
00100 void            lscp_szsplit_destroy        (char **ppszSplit);
00101 #ifdef LSCP_SZSPLIT_COUNT
00102 int             lscp_szsplit_count          (char **ppszSplit);
00103 int             lscp_szsplit_size           (char **ppszSplit);
00104 #endif
00105 
00106 int *           lscp_isplit_create          (const char *pszCsv, const char *pszSeps);
00107 void            lscp_isplit_destroy         (int *piSplit);
00108 #ifdef LSCP_ISPLIT_COUNT
00109 int             lscp_isplit_count           (int *piSplit);
00110 int             lscp_isplit_size            (int *piSplit);
00111 #endif
00112 
00113 lscp_param_t *  lscp_psplit_create          (const char *pszCsv, const char *pszSep1, const char *pszSep2);
00114 void            lscp_psplit_destroy         (lscp_param_t *ppSplit);
00115 #ifdef LSCP_PSPLIT_COUNT
00116 int             lscp_psplit_count           (lscp_param_t *ppSplit);
00117 int             lscp_psplit_size            (lscp_param_t *ppSplit);
00118 #endif
00119 
00120 void            lscp_plist_alloc       (lscp_param_t **ppList);
00121 void            lscp_plist_free        (lscp_param_t **ppList);
00122 void            lscp_plist_append      (lscp_param_t **ppList, const char *pszKey, const char *pszValue);
00123 #ifdef LSCP_PLIST_COUNT
00124 int             lscp_plist_count       (lscp_param_t **ppList);
00125 int             lscp_plist_size        (lscp_param_t **ppList);
00126 #endif
00127 
00128 //-------------------------------------------------------------------------
00129 // Server struct helper functions.
00130 
00131 void            lscp_server_info_init       (lscp_server_info_t *pServerInfo);
00132 void            lscp_server_info_free       (lscp_server_info_t *pServerInfo);
00133 void            lscp_server_info_reset      (lscp_server_info_t *pServerInfo);
00134 
00135 //-------------------------------------------------------------------------
00136 // Engine struct helper functions.
00137 
00138 void            lscp_engine_info_init       (lscp_engine_info_t *pEngineInfo);
00139 void            lscp_engine_info_free       (lscp_engine_info_t *pEngineInfo);
00140 void            lscp_engine_info_reset      (lscp_engine_info_t *pEngineInfo);
00141 
00142 //-------------------------------------------------------------------------
00143 // Channel struct helper functions.
00144 
00145 void            lscp_channel_info_init      (lscp_channel_info_t *pChannelInfo);
00146 void            lscp_channel_info_free      (lscp_channel_info_t *pChannelInfo);
00147 void            lscp_channel_info_reset     (lscp_channel_info_t *pChannelInfo);
00148 
00149 //-------------------------------------------------------------------------
00150 // Driver struct helper functions.
00151 
00152 void            lscp_driver_info_init       (lscp_driver_info_t *pDriverInfo);
00153 void            lscp_driver_info_free       (lscp_driver_info_t *pDriverInfo);
00154 void            lscp_driver_info_reset      (lscp_driver_info_t *pDriverInfo);
00155 
00156 //-------------------------------------------------------------------------
00157 // Device struct helper functions.
00158 
00159 void            lscp_device_info_init       (lscp_device_info_t *pDeviceInfo);
00160 void            lscp_device_info_free       (lscp_device_info_t *pDeviceInfo);
00161 void            lscp_device_info_reset      (lscp_device_info_t *pDeviceInfo);
00162 
00163 //-------------------------------------------------------------------------
00164 // Device channel/port struct helper functions.
00165 
00166 void            lscp_device_port_info_init  (lscp_device_port_info_t *pDevicePortInfo);
00167 void            lscp_device_port_info_free  (lscp_device_port_info_t *pDevicePortInfo);
00168 void            lscp_device_port_info_reset (lscp_device_port_info_t *pDevicePortInfo);
00169 
00170 //-------------------------------------------------------------------------
00171 // Parameter struct helper functions.
00172 
00173 void            lscp_param_info_init        (lscp_param_info_t *pParamInfo);
00174 void            lscp_param_info_free        (lscp_param_info_t *pParamInfo);
00175 void            lscp_param_info_reset       (lscp_param_info_t *pParamInfo);
00176 
00177 //-------------------------------------------------------------------------
00178 // Concatenate a parameter list (key='value'...) into a string.
00179 
00180 int             lscp_param_concat           (char *pszBuffer, int cchMaxBuffer, lscp_param_t *pParams);
00181 
00182 
00183 #endif // __LSCP_COMMON_H
00184 
00185 // end of common.h

Generated on Wed Aug 24 19:14:01 2005 for liblscp by  doxygen 1.4.4