mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-12-22 22:06:31 +01:00
topology: pre-processor: Add a helper function to concat strings
The pre-processor needs to concatinate strings separated by '.' for building object names from constructor attribute values and searching for configs with ID's containing strings separate by '.'. Add a helper function to concat strings in the specified input format. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
94eaca13ce
commit
eb514c6bd7
2 changed files with 29 additions and 0 deletions
|
@ -71,6 +71,33 @@ int tplg_config_make_add(snd_config_t **config, const char *id, snd_config_type_
|
|||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* The pre-processor will need to concat multiple strings separate by '.' to construct the object
|
||||
* name and search for configs with ID's separated by '.'.
|
||||
* This function helps concat input strings in the specified input format
|
||||
*/
|
||||
char *tplg_snprintf(char *fmt, ...)
|
||||
{
|
||||
char *string;
|
||||
int len = 1;
|
||||
|
||||
va_list va;
|
||||
|
||||
va_start(va, fmt);
|
||||
len += vsnprintf(NULL, 0, fmt, va);
|
||||
va_end(va);
|
||||
|
||||
string = calloc(1, len);
|
||||
if (!string)
|
||||
return NULL;
|
||||
|
||||
va_start(va, fmt);
|
||||
vsnprintf(string, len, fmt, va);
|
||||
va_end(va);
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
#ifdef TPLG_DEBUG
|
||||
void tplg_pp_debug(char *fmt, ...)
|
||||
{
|
||||
|
|
|
@ -30,4 +30,6 @@ void tplg_pp_config_debug(struct tplg_pre_processor *tplg_pp, snd_config_t *cfg)
|
|||
snd_config_t *tplg_find_config(snd_config_t *config, const char *name);
|
||||
int tplg_config_make_add(snd_config_t **config, const char *id, snd_config_type_t type,
|
||||
snd_config_t *parent);
|
||||
|
||||
char *tplg_snprintf(char *fmt, ...);
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue