X-Git-Url: http://git.samba.org/?p=samba.git;a=blobdiff_plain;f=source%2Flib%2Futil_strlist.c;h=8efa1f92d2012dc421d2565d5a574fb132bf11ff;hp=d5c4d915850f345584b308c11d56c9a5a5d32d2e;hb=414e5f7f6dc38a8fde3b61d524a664f56f9ea592;hpb=f6cf38d608d727e2065035604b537e07cb88ded9 diff --git a/source/lib/util_strlist.c b/source/lib/util_strlist.c index d5c4d915850..8efa1f92d20 100644 --- a/source/lib/util_strlist.c +++ b/source/lib/util_strlist.c @@ -22,7 +22,7 @@ /* build a null terminated list of strings from a input string and a - separator list. The sepatator list must contain characters less than + separator list. The separator list must contain characters less than or equal to 0x2f for this to work correctly on multi-byte strings */ const char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep) @@ -70,6 +70,25 @@ const char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char * return ret; } +/* join a list back to one string */ +char *str_list_join(TALLOC_CTX *mem_ctx, const char **list, char seperator) +{ + char *ret = NULL; + int i; + + if (list[0] == NULL) + return talloc_strdup(mem_ctx, ""); + + ret = talloc_strdup(mem_ctx, list[0]); + + for (i = 1; list[i]; i++) { + ret = talloc_asprintf_append(ret, "%c%s", seperator, list[i]); + } + + return ret; +} + + /* return the number of elements in a string list */