diff options
author | Jaroslav Kysela <perex@perex.cz> | 2022-01-27 18:48:16 +0100 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2022-01-27 18:48:20 +0100 |
commit | 16f9311174abc922e3e67df73d157bc882f64ca9 (patch) | |
tree | 4b56ca273701c802eeb95986b7861ab4a4bbe3fd | |
parent | c47188f25894b10ea9f9abc870ffe9c40d91c85a (diff) | |
download | alsa-utils-16f9311174abc922e3e67df73d157bc882f64ca9.tar.gz |
topology: add support for multiple -D arguments
It may be useful in the makefile rules for example.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
-rw-r--r-- | topology/topology.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/topology/topology.c b/topology/topology.c index 8d65768..026e1a4 100644 --- a/topology/topology.c +++ b/topology/topology.c @@ -387,6 +387,22 @@ static int decode(const char *source_file, const char *output_file, return err; } +#if SND_LIB_VER(1, 2, 5) < SND_LIB_VERSION +static int add_define(char **defs, char *d) +{ + size_t len = (*defs ? strlen(*defs) : 0) + strlen(d) + 2; + char *m = realloc(*defs, len); + if (m) { + if (*defs) + strcat(m, ","); + strcat(m, d); + *defs = m; + return 0; + } + return 1; +} +#endif + int main(int argc, char *argv[]) { static const char short_options[] = "hc:d:n:u:v:o:pP:sgxzV" @@ -417,7 +433,7 @@ int main(int argc, char *argv[]) char *source_file = NULL; char *output_file = NULL; const char *inc_path = NULL; - const char *pre_processor_defs = NULL; + char *pre_processor_defs = NULL; int c, err, op = 'c', cflags = 0, dflags = 0, sflags = 0, option_index; #ifdef ENABLE_NLS @@ -476,7 +492,10 @@ int main(int argc, char *argv[]) break; #if SND_LIB_VER(1, 2, 5) < SND_LIB_VERSION case 'D': - pre_processor_defs = optarg; + if (add_define(&pre_processor_defs, optarg)) { + fprintf(stderr, _("No enough memory")); + return 1; + } break; #endif case 'V': @@ -524,5 +543,6 @@ int main(int argc, char *argv[]) } snd_output_close(log); + free(pre_processor_defs); return err ? 1 : 0; } |