diff --git a/src/features.c b/src/features.c new file mode 100644 index 00000000..9f49249e --- /dev/null +++ b/src/features.c @@ -0,0 +1,22 @@ +#include "features.h" + +void feature_array_add(char_array *features, int num_args, ...) { + if (num_args <= 0) { + return; + } + + va_list args; + va_start(args, num_args); + + for (int i = 0; i < num_args - 1; i++) { + char *arg = va_arg(args, char *); + contiguous_string_array_add_string_unterminated(features, arg); + contiguous_string_array_add_string_unterminated(features, FEATURE_SEPARATOR_CHAR); + } + + char *arg = va_arg(args, char *); + contiguous_string_array_add_string(features, arg); + + va_end(args); + +} \ No newline at end of file diff --git a/src/features.h b/src/features.h new file mode 100644 index 00000000..ec58bb49 --- /dev/null +++ b/src/features.h @@ -0,0 +1,22 @@ +#ifndef FEATURES_H +#define FEATURES_H + + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "string_utils.h" + +#define FEATURE_SEPARATOR_CHAR "|" + +void feature_array_add(char_array *features, int num_args, ...); + + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file