common.c File Reference
`#include "common.h"`
`#include <ctype.h>`

## Macros

#define | LSCP_SPLIT_CHUNK1 4
#define | LSCP_SPLIT_CHUNK2 2
#define | LSCP_SPLIT_SIZE(n) ((((n) >> LSCP_SPLIT_CHUNK2) + 1) << LSCP_SPLIT_CHUNK2)

## Functions

void | lscp_client_set_result (lscp_client_t *pClient, char *pszResult, int iErrno)
lscp_status_t | lscp_client_recv (lscp_client_t *pClient, char *pchBuffer, int *pcchBuffer, int iTimeout)
lscp_status_t | lscp_client_call (lscp_client_t *pClient, const char *pszQuery, int iResult)
char * | lscp_ltrim (char *psz)
char * | lscp_unquote (char **ppsz, int dup)
void | lscp_unquote_dup (char **ppszDst, char **ppszSrc)
char * | lscp_strtok (char *pchBuffer, const char *pszSeps, char **ppch)
char ** | lscp_szsplit_create (const char *pszCsv, const char *pszSeps)
void | lscp_szsplit_destroy (char **ppszSplit)
int * | lscp_isplit_create (const char *pszCsv, const char *pszSeps)
void | lscp_isplit_destroy (int *piSplit)
lscp_param_t * | lscp_psplit_create (const char *pszCsv, const char *pszSeps1, const char *pszSeps2)
void | lscp_psplit_destroy (lscp_param_t *ppSplit)
void | lscp_plist_alloc (lscp_param_t **ppList)
void | lscp_plist_free (lscp_param_t **ppList)
void | lscp_plist_append (lscp_param_t **ppList, const char *pszKey, const char *pszValue)
lscp_midi_instrument_t * | lscp_midi_instruments_create (const char *pszCsv)
void | lscp_midi_instruments_destroy (lscp_midi_instrument_t *pInstrs)
void | lscp_server_info_init (lscp_server_info_t *pServerInfo)
void | lscp_server_info_free (lscp_server_info_t *pServerInfo)
void | lscp_server_info_reset (lscp_server_info_t *pServerInfo)
void | lscp_engine_info_init (lscp_engine_info_t *pEngineInfo)
void | lscp_engine_info_free (lscp_engine_info_t *pEngineInfo)
void | lscp_engine_info_reset (lscp_engine_info_t *pEngineInfo)
void | lscp_channel_info_init (lscp_channel_info_t *pChannelInfo)
void | lscp_channel_info_free (lscp_channel_info_t *pChannelInfo)
void | lscp_channel_info_reset (lscp_channel_info_t *pChannelInfo)
void | lscp_driver_info_init (lscp_driver_info_t *pDriverInfo)
void | lscp_driver_info_free (lscp_driver_info_t *pDriverInfo)
void | lscp_driver_info_reset (lscp_driver_info_t *pDriverInfo)
void | lscp_device_info_init (lscp_device_info_t *pDeviceInfo)
void | lscp_device_info_free (lscp_device_info_t *pDeviceInfo)
void | lscp_device_info_reset (lscp_device_info_t *pDeviceInfo)
void | lscp_device_port_info_init (lscp_device_port_info_t *pDevicePortInfo)
void | lscp_device_port_info_free (lscp_device_port_info_t *pDevicePortInfo)
void | lscp_device_port_info_reset (lscp_device_port_info_t *pDevicePortInfo)
void | lscp_param_info_init (lscp_param_info_t *pParamInfo)
void | lscp_param_info_free (lscp_param_info_t *pParamInfo)
void | lscp_param_info_reset (lscp_param_info_t *pParamInfo)
int | lscp_param_concat (char *pszBuffer, int cchMaxBuffer, lscp_param_t *pParams)
void | lscp_fxsend_info_init (lscp_fxsend_info_t *pFxSendInfo)
void | lscp_fxsend_info_free (lscp_fxsend_info_t *pFxSendInfo)
void | lscp_fxsend_info_reset (lscp_fxsend_info_t *pFxSendInfo)
void | lscp_midi_instrument_info_init (lscp_midi_instrument_info_t *pInstrInfo)
void | lscp_midi_instrument_info_free (lscp_midi_instrument_info_t *pInstrInfo)
void | lscp_midi_instrument_info_reset (lscp_midi_instrument_info_t *pInstrInfo)

## Macro Definition Documentation

## LSCP_SPLIT_CHUNK1

#define LSCP_SPLIT_CHUNK1 4

Referenced by lscp_isplit_create(), lscp_midi_instruments_create(), lscp_plist_alloc(), lscp_plist_append(), lscp_psplit_create(), and lscp_szsplit_create().

## LSCP_SPLIT_CHUNK2

#define LSCP_SPLIT_CHUNK2 2

## LSCP_SPLIT_SIZE

#define LSCP_SPLIT_SIZE | ( |  | n | ) | ((((n) >> LSCP_SPLIT_CHUNK2) + 1) << LSCP_SPLIT_CHUNK2)

Referenced by lscp_isplit_destroy(), lscp_midi_instruments_destroy(), lscp_plist_append(), lscp_psplit_destroy(), and lscp_szsplit_destroy().

## Function Documentation

## lscp_channel_info_free()

void lscp_channel_info_free | ( | lscp_channel_info_t * | pChannelInfo | ) |

References _lscp_channel_info_t::audio_routing, _lscp_channel_info_t::engine_name, _lscp_channel_info_t::instrument_file, _lscp_channel_info_t::instrument_name, and lscp_isplit_destroy().

Referenced by lscp_channel_info_reset(), and lscp_client_destroy().

## lscp_channel_info_init()

void lscp_channel_info_init | ( | lscp_channel_info_t * | pChannelInfo | ) |

References _lscp_channel_info_t::audio_channels, _lscp_channel_info_t::audio_device, _lscp_channel_info_t::audio_routing, _lscp_channel_info_t::engine_name, _lscp_channel_info_t::instrument_file, _lscp_channel_info_t::instrument_name, _lscp_channel_info_t::instrument_nr, _lscp_channel_info_t::instrument_status, _lscp_channel_info_t::midi_channel, _lscp_channel_info_t::midi_device, _lscp_channel_info_t::midi_map, _lscp_channel_info_t::midi_port, _lscp_channel_info_t::mute, _lscp_channel_info_t::solo, and _lscp_channel_info_t::volume.

Referenced by lscp_channel_info_reset(), and lscp_client_create().

## lscp_channel_info_reset()

void lscp_channel_info_reset | ( | lscp_channel_info_t * | pChannelInfo | ) |

References lscp_channel_info_free(), and lscp_channel_info_init().

Referenced by lscp_get_channel_info().

## lscp_client_call()

lscp_status_t lscp_client_call | ( | lscp_client_t * | pClient,
|  | const char * | pszQuery,
|  | int | iResult
| ) |  |

References _lscp_client_t::cmd, INVALID_SOCKET, _lscp_client_t::iTimeout, _lscp_client_t::iTimeoutCount, LSCP_BUFSIZ, lscp_client_recv(), lscp_client_set_result(), LSCP_ERROR, LSCP_FAILED, LSCP_OK, LSCP_QUIT, lscp_socket_perror(), lscp_strtok(), LSCP_TIMEOUT, LSCP_WARNING, and _lscp_socket_agent_t::sock.

Referenced by lscp_add_channel(), lscp_add_midi_instrument_map(), lscp_client_query(), lscp_create_audio_device(), lscp_create_fxsend(), lscp_create_midi_device(), lscp_get_audio_devices(), lscp_get_available_audio_drivers(), lscp_get_available_engines(), lscp_get_available_midi_drivers(), lscp_get_channel_buffer_fill(), lscp_get_channel_stream_count(), lscp_get_channel_stream_usage(), lscp_get_channel_voice_count(), lscp_get_channels(), lscp_get_engine_info(), lscp_get_fxsends(), lscp_get_midi_devices(), lscp_get_midi_instrument_map_name(), lscp_get_midi_instrument_maps(), lscp_get_midi_instruments(), lscp_get_server_info(), lscp_get_streams(), lscp_get_total_voice_count(), lscp_get_total_voice_count_max(), lscp_get_voices(), lscp_list_audio_devices(), lscp_list_available_audio_drivers(), lscp_list_available_engines(), lscp_list_available_midi_drivers(), lscp_list_channels(), lscp_list_fxsends(), lscp_list_midi_devices(), lscp_list_midi_instrument_maps(), and lscp_list_midi_instruments().

## lscp_client_recv()

lscp_status_t lscp_client_recv | ( | lscp_client_t * | pClient,
|  | char * | pchBuffer,
|  | int * | pcchBuffer,
|  | int | iTimeout
| ) |  |

References _lscp_client_t::cmd, _lscp_client_t::evt, _lscp_client_t::iTimeout, LSCP_FAILED, LSCP_OK, LSCP_QUIT, lscp_socket_agent_free(), lscp_socket_perror(), LSCP_TIMEOUT, and _lscp_socket_agent_t::sock.

Referenced by lscp_client_call().

## lscp_client_set_result()

void lscp_client_set_result | ( | lscp_client_t * | pClient,
|  | char * | pszResult,
|  | int | iErrno
| ) |  |

References _lscp_client_t::iErrno, lscp_ltrim(), and _lscp_client_t::pszResult.

Referenced by lscp_client_call(), and lscp_client_destroy().

## lscp_device_info_free()

void lscp_device_info_free | ( | lscp_device_info_t * | pDeviceInfo | ) |

References _lscp_device_info_t::driver, lscp_plist_free(), and _lscp_device_info_t::params.

Referenced by lscp_client_destroy(), and lscp_device_info_reset().

## lscp_device_info_init()

void lscp_device_info_init | ( | lscp_device_info_t * | pDeviceInfo | ) |

References _lscp_device_info_t::driver, lscp_plist_alloc(), and _lscp_device_info_t::params.

Referenced by lscp_client_create(), and lscp_device_info_reset().

## lscp_device_info_reset()

void lscp_device_info_reset | ( | lscp_device_info_t * | pDeviceInfo | ) |

References lscp_device_info_free(), and lscp_device_info_init().

## lscp_device_port_info_free()

void lscp_device_port_info_free | ( | lscp_device_port_info_t * | pDevicePortInfo | ) |

References lscp_plist_free(), _lscp_device_port_info_t::name, and _lscp_device_port_info_t::params.

Referenced by lscp_client_destroy(), and lscp_device_port_info_reset().

## lscp_device_port_info_init()

void lscp_device_port_info_init | ( | lscp_device_port_info_t * | pDevicePortInfo | ) |

References lscp_plist_alloc(), _lscp_device_port_info_t::name, and _lscp_device_port_info_t::params.

Referenced by lscp_client_create(), and lscp_device_port_info_reset().

## lscp_device_port_info_reset()

void lscp_device_port_info_reset | ( | lscp_device_port_info_t * | pDevicePortInfo | ) |

References lscp_device_port_info_free(), and lscp_device_port_info_init().

## lscp_driver_info_free()

void lscp_driver_info_free | ( | lscp_driver_info_t * | pDriverInfo | ) |

References _lscp_driver_info_t::description, lscp_szsplit_destroy(), _lscp_driver_info_t::parameters, and _lscp_driver_info_t::version.

Referenced by lscp_client_destroy(), and lscp_driver_info_reset().

## lscp_driver_info_init()

void lscp_driver_info_init | ( | lscp_driver_info_t * | pDriverInfo | ) |

References _lscp_driver_info_t::description, _lscp_driver_info_t::parameters, and _lscp_driver_info_t::version.

Referenced by lscp_client_create(), and lscp_driver_info_reset().

## lscp_driver_info_reset()

void lscp_driver_info_reset | ( | lscp_driver_info_t * | pDriverInfo | ) |

References lscp_driver_info_free(), and lscp_driver_info_init().

## lscp_engine_info_free()

void lscp_engine_info_free | ( | lscp_engine_info_t * | pEngineInfo | ) |

References _lscp_engine_info_t::description, and _lscp_engine_info_t::version.

Referenced by lscp_client_destroy(), and lscp_engine_info_reset().

## lscp_engine_info_init()

void lscp_engine_info_init | ( | lscp_engine_info_t * | pEngineInfo | ) |

References _lscp_engine_info_t::description, and _lscp_engine_info_t::version.

Referenced by lscp_client_create(), and lscp_engine_info_reset().

## lscp_engine_info_reset()

void lscp_engine_info_reset | ( | lscp_engine_info_t * | pEngineInfo | ) |

References lscp_engine_info_free(), and lscp_engine_info_init().

Referenced by lscp_get_engine_info().

## lscp_fxsend_info_free()

void lscp_fxsend_info_free | ( | lscp_fxsend_info_t * | pFxSendInfo | ) |

References _lscp_fxsend_info_t::audio_routing, lscp_isplit_destroy(), and _lscp_fxsend_info_t::name.

Referenced by lscp_client_destroy(), and lscp_fxsend_info_reset().

## lscp_fxsend_info_init()

void lscp_fxsend_info_init | ( | lscp_fxsend_info_t * | pFxSendInfo | ) |

References _lscp_fxsend_info_t::audio_routing, _lscp_fxsend_info_t::level, _lscp_fxsend_info_t::midi_controller, and _lscp_fxsend_info_t::name.

Referenced by lscp_client_create(), and lscp_fxsend_info_reset().

## lscp_fxsend_info_reset()

void lscp_fxsend_info_reset | ( | lscp_fxsend_info_t * | pFxSendInfo | ) |

References lscp_fxsend_info_free(), and lscp_fxsend_info_init().

## lscp_isplit_create()

int* lscp_isplit_create | ( | const char * | pszCsv,
|  | const char * | pszSeps
| ) |  |

References lscp_ltrim(), and LSCP_SPLIT_CHUNK1.

Referenced by lscp_list_audio_devices(), lscp_list_channels(), lscp_list_fxsends(), lscp_list_midi_devices(), and lscp_list_midi_instrument_maps().

## lscp_isplit_destroy()

void lscp_isplit_destroy | ( | int * | piSplit | ) |

References LSCP_SPLIT_SIZE.

Referenced by lscp_channel_info_free(), lscp_client_destroy(), lscp_fxsend_info_free(), lscp_list_audio_devices(), lscp_list_channels(), lscp_list_fxsends(), lscp_list_midi_devices(), and lscp_list_midi_instrument_maps().

## lscp_ltrim()

char* lscp_ltrim | ( | char * | psz | ) |

Referenced by lscp_client_set_result(), lscp_isplit_create(), and lscp_midi_instruments_create().

## lscp_midi_instrument_info_free()

void lscp_midi_instrument_info_free | ( | lscp_midi_instrument_info_t * | pInstrInfo | ) |

References _lscp_midi_instrument_info_t::engine_name, _lscp_midi_instrument_info_t::instrument_file, _lscp_midi_instrument_info_t::instrument_name, and _lscp_midi_instrument_info_t::name.

Referenced by lscp_client_destroy(), and lscp_midi_instrument_info_reset().

## lscp_midi_instrument_info_init()

void lscp_midi_instrument_info_init | ( | lscp_midi_instrument_info_t * | pInstrInfo | ) |

References _lscp_midi_instrument_info_t::engine_name, _lscp_midi_instrument_info_t::instrument_file, _lscp_midi_instrument_info_t::instrument_name, _lscp_midi_instrument_info_t::instrument_nr, _lscp_midi_instrument_info_t::load_mode, LSCP_LOAD_DEFAULT, _lscp_midi_instrument_info_t::name, and _lscp_midi_instrument_info_t::volume.

Referenced by lscp_client_create(), and lscp_midi_instrument_info_reset().

## lscp_midi_instrument_info_reset()

void lscp_midi_instrument_info_reset | ( | lscp_midi_instrument_info_t * | pInstrInfo | ) |

References lscp_midi_instrument_info_free(), and lscp_midi_instrument_info_init().

## lscp_midi_instruments_create()

lscp_midi_instrument_t* lscp_midi_instruments_create | ( | const char * | pszCsv | ) |

References _lscp_midi_instrument_t::bank, lscp_ltrim(), LSCP_SPLIT_CHUNK1, _lscp_midi_instrument_t::map, and _lscp_midi_instrument_t::prog.

Referenced by lscp_list_midi_instruments().

## lscp_midi_instruments_destroy()

void lscp_midi_instruments_destroy | ( | lscp_midi_instrument_t * | pInstrs | ) |

References LSCP_SPLIT_SIZE.

Referenced by lscp_client_destroy(), and lscp_list_midi_instruments().

## lscp_param_concat()

int lscp_param_concat | ( | char * | pszBuffer,
|  | int | cchMaxBuffer,
|  | lscp_param_t * | pParams
| ) |  |

References _lscp_param_t::key, and _lscp_param_t::value.

Referenced by lscp_create_audio_device(), and lscp_create_midi_device().

## lscp_param_info_free()

void lscp_param_info_free | ( | lscp_param_info_t * | pParamInfo | ) |

References _lscp_param_info_t::defaultv, _lscp_param_info_t::depends, _lscp_param_info_t::description, lscp_szsplit_destroy(), _lscp_param_info_t::possibilities, _lscp_param_info_t::range_max, and _lscp_param_info_t::range_min.

Referenced by lscp_client_destroy(), and lscp_param_info_reset().

## lscp_param_info_init()

void lscp_param_info_init | ( | lscp_param_info_t * | pParamInfo | ) |

References _lscp_param_info_t::defaultv, _lscp_param_info_t::depends, _lscp_param_info_t::description, _lscp_param_info_t::fix, LSCP_TYPE_NONE, _lscp_param_info_t::mandatory, _lscp_param_info_t::multiplicity, _lscp_param_info_t::possibilities, _lscp_param_info_t::range_max, _lscp_param_info_t::range_min, and _lscp_param_info_t::type.

Referenced by lscp_client_create(), and lscp_param_info_reset().

## lscp_param_info_reset()

void lscp_param_info_reset | ( | lscp_param_info_t * | pParamInfo | ) |

References lscp_param_info_free(), and lscp_param_info_init().

## lscp_plist_alloc()

void lscp_plist_alloc | ( | lscp_param_t ** | ppList | ) |

References _lscp_param_t::key, LSCP_SPLIT_CHUNK1, and _lscp_param_t::value.

Referenced by lscp_device_info_init(), and lscp_device_port_info_init().

## lscp_plist_append()

void lscp_plist_append | ( | lscp_param_t ** | ppList,
|  | const char * | pszKey,
|  | const char * | pszValue
| ) |  |

References _lscp_param_t::key, LSCP_SPLIT_CHUNK1, LSCP_SPLIT_SIZE, and _lscp_param_t::value.

## lscp_plist_free()

void lscp_plist_free | ( | lscp_param_t ** | ppList | ) |

References _lscp_param_t::key.

Referenced by lscp_device_info_free(), and lscp_device_port_info_free().

## lscp_psplit_create()

lscp_param_t* lscp_psplit_create | ( | const char * | pszCsv,
|  | const char * | pszSeps1,
|  | const char * | pszSeps2
| ) |  |

References _lscp_param_t::key, LSCP_SPLIT_CHUNK1, lscp_unquote(), and _lscp_param_t::value.

## lscp_psplit_destroy()

void lscp_psplit_destroy | ( | lscp_param_t * | ppSplit | ) |

References LSCP_SPLIT_SIZE.

## lscp_server_info_free()

void lscp_server_info_free | ( | lscp_server_info_t * | pServerInfo | ) |

References _lscp_server_info_t::description, _lscp_server_info_t::protocol_version, and _lscp_server_info_t::version.

Referenced by lscp_client_destroy(), and lscp_server_info_reset().

## lscp_server_info_init()

void lscp_server_info_init | ( | lscp_server_info_t * | pServerInfo | ) |

References _lscp_server_info_t::description, _lscp_server_info_t::protocol_version, and _lscp_server_info_t::version.

Referenced by lscp_client_create(), and lscp_server_info_reset().

## lscp_server_info_reset()

void lscp_server_info_reset | ( | lscp_server_info_t * | pServerInfo | ) |

References lscp_server_info_free(), and lscp_server_info_init().

Referenced by lscp_get_server_info().

## lscp_strtok()

char* lscp_strtok | ( | char * | pchBuffer,
|  | const char * | pszSeps,
|  | char ** | ppch
| ) |  |

Referenced by lscp_client_call(), lscp_get_channel_buffer_fill(), lscp_get_channel_stream_usage(), lscp_get_engine_info(), lscp_get_midi_instrument_map_name(), and lscp_get_server_info().

## lscp_szsplit_create()

char** lscp_szsplit_create | ( | const char * | pszCsv,
|  | const char * | pszSeps
| ) |  |

References LSCP_SPLIT_CHUNK1, and lscp_unquote().

Referenced by lscp_list_available_audio_drivers(), lscp_list_available_engines(), and lscp_list_available_midi_drivers().

## lscp_szsplit_destroy()

void lscp_szsplit_destroy | ( | char ** | ppszSplit | ) |

References LSCP_SPLIT_SIZE.

Referenced by lscp_client_destroy(), lscp_driver_info_free(), lscp_list_available_audio_drivers(), lscp_list_available_engines(), lscp_list_available_midi_drivers(), and lscp_param_info_free().

## lscp_unquote()

char* lscp_unquote | ( | char ** | ppsz,
|  | int | dup
| ) |  |

Referenced by lscp_psplit_create(), lscp_szsplit_create(), and lscp_unquote_dup().

## lscp_unquote_dup()

void lscp_unquote_dup | ( | char ** | ppszDst,
|  | char ** | ppszSrc
| ) |  |

References lscp_unquote().

Referenced by lscp_get_engine_info(), lscp_get_midi_instrument_map_name(), and lscp_get_server_info().