diff options
Diffstat (limited to 'main/utils.c')
-rw-r--r-- | main/utils.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/main/utils.c b/main/utils.c index 40818c37a..3a095ca7b 100644 --- a/main/utils.c +++ b/main/utils.c @@ -484,6 +484,37 @@ char *ast_escape_quoted(const char *string, char *outbuf, int buflen) return outbuf; } +char *ast_escape_semicolons(const char *string, char *outbuf, int buflen) +{ + const char *ptr = string; + char *out = outbuf; + + if (string == NULL || outbuf == NULL) { + ast_assert(string != NULL && outbuf != NULL); + return NULL; + } + + while (*ptr && out - outbuf < buflen - 1) { + if (*ptr == ';') { + if (out - outbuf >= buflen - 2) { + break; + } + strcpy(out, "\\;"); + out += 2; + } else { + *out = *ptr; + out++; + } + ptr++; + } + + if (buflen) { + *out = '\0'; + } + + return outbuf; +} + void ast_unescape_quoted(char *quote_str) { int esc_pos; |