<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/7871">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">vector: Additional string vector definitions.<br><br>ast_ast_vector_string_create:<br>This function will add items to an ast_vector_string by splitting values<br>of a string buffer.  Items are appended to the vector in the order they<br>are found.  Ignoring duplicates is supported.<br><br>ast_vector_const_string:<br>A vector of 'const char *'.<br><br>Change-Id: I1bf02a1efeb2baeea11c59c557d39dd1197494d7<br>---<br>M include/asterisk/vector.h<br>M main/strings.c<br>2 files changed, 48 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/71/7871/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/include/asterisk/vector.h b/include/asterisk/vector.h<br>index 8bd1cef..f13b31c 100644<br>--- a/include/asterisk/vector.h<br>+++ b/include/asterisk/vector.h<br>@@ -51,8 +51,21 @@<br> /*! \brief Integer vector definition */<br> AST_VECTOR(ast_vector_int, int);<br> <br>-/*! \brief String vector definition */<br>+/*! \brief String vector definitions */<br> AST_VECTOR(ast_vector_string, char *);<br>+AST_VECTOR(ast_vector_const_string, const char *);<br>+<br>+/*!<br>+ * \brief Create a string vector by splitting a string.<br>+ *<br>+ * \param dest Pointer to an initialized vector.<br>+ * \param input String buffer to split.<br>+ * \param delim String delimeter passed to strsep.<br>+ * \param ignore_dups Set non-zero to ignore all duplicate strings.<br>+ */<br>+int ast_vector_string_create(struct ast_vector_string *dest,<br>+      const char *input, const char *delim,<br>+        int (*ignore_cmp)(const char *s1, const char *s2));<br> <br> /*!<br>  * \brief Define a vector structure with a read/write lock<br>diff --git a/main/strings.c b/main/strings.c<br>index 82e315a..2bed9b2 100644<br>--- a/main/strings.c<br>+++ b/main/strings.c<br>@@ -40,6 +40,7 @@<br> #include <regex.h><br> #include "asterisk/strings.h"<br> #include "asterisk/pbx.h"<br>+#include "asterisk/vector.h"<br> <br> /*!<br>  * core handler for dynamic strings.<br>@@ -389,3 +390,36 @@<br> <br>    return start;<br> }<br>+<br>+int ast_vector_string_create(struct ast_vector_string *dest,<br>+  const char *input, const char *delim,<br>+        int (*ignore_cmp)(const char *s1, const char *s2))<br>+{<br>+       char *buf;<br>+   char *cur;<br>+<br>+        if (ast_strlen_zero(input)) {<br>+                return 0;<br>+    }<br>+<br>+ buf = ast_strdupa(input);<br>+<br>+ ast_assert(dest != NULL);<br>+    ast_assert(buf != NULL);<br>+     ast_assert(!ast_strlen_zero(delim));<br>+<br>+      while ((cur = strsep(&buf, delim))) {<br>+            if (ignore_cmp && AST_VECTOR_GET_CMP(dest, cur, !ignore_cmp)) {<br>+                      continue;<br>+            }<br>+<br>+         cur = ast_strdup(cur);<br>+               if (!cur || AST_VECTOR_APPEND(dest, cur)) {<br>+                  ast_free(cur);<br>+<br>+                    return -1;<br>+           }<br>+    }<br>+<br>+ return 0;<br>+}<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7871">change 7871</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/7871"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I1bf02a1efeb2baeea11c59c557d39dd1197494d7 </div>
<div style="display:none"> Gerrit-Change-Number: 7871 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>