aboutsummaryrefslogtreecommitdiffstats
path: root/utils.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2005-12-20 20:20:04 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2005-12-20 20:20:04 +0000
commitcc20111b727a69579dd9e58e05fca9deb75687f7 (patch)
tree028d8f36127b8aefd66e997f6e27e207a85f1e15 /utils.c
parent59d6c7a704380c45bef9313de86f6b2620e80366 (diff)
- move the string join() function to utils.c since it is used in both cli.c and res_agi.c
- reimplement ast_join to be of linear effieciency instead of quadratic - remove some useless checks for "if (e)" - reorder checks for strings starting with '_' to avoid a useless call to ast_join() - check array bounds when parsing arguments to AGI (issue #5868) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@7556 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index f10441050..2432c97ef 100644
--- a/utils.c
+++ b/utils.c
@@ -903,3 +903,22 @@ char *ast_process_quotes_and_slashes(char *start, char find, char replace_with)
*dataPut = 0;
return dataPut;
}
+
+void ast_join(char *s, size_t len, char * const w[])
+{
+ int x, ofs = 0;
+ const char *src;
+
+ /* Join words into a string */
+ if (!s)
+ return;
+ for (x=0; ofs < len && w[x]; x++) {
+ if (x > 0)
+ s[ofs++] = ' ';
+ for (src = w[x]; *src && ofs < len; src++)
+ s[ofs++] = *src;
+ }
+ if (ofs == len)
+ ofs--;
+ s[ofs] = '\0';
+}