aboutsummaryrefslogtreecommitdiffstats
path: root/main/utils.c
diff options
context:
space:
mode:
authorrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2007-12-19 17:09:01 +0000
committerrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2007-12-19 17:09:01 +0000
commit36be3451e8356d12943b6c768bf30fe85a3fe821 (patch)
tree4957711a711281c258656ef1b4e5fd4474ba68d0 /main/utils.c
parent6016c98c2b4c0493ff5844f5bd79112d3f48850c (diff)
Add a new API function, written at least twice in app_voicemail.c
and likely in other places too. This is quite useful when placing mail/html stuff in config files. /*! \brief Convert some C escape sequences (\b\f\n\r\t) into the equivalent characters. \brief s The string to be converted (will be modified). \return The converted string. */ char *ast_unescape_c(char *s); git-svn-id: http://svn.digium.com/svn/asterisk/trunk@93950 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/utils.c')
-rw-r--r--main/utils.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/main/utils.c b/main/utils.c
index 2c4cef829..6920141b0 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -1020,6 +1020,43 @@ char *ast_unescape_semicolon(char *s)
return s;
}
+/* !\brief unescape some C sequences in place, return pointer to the original string.
+ */
+char *ast_unescape_c(char *src)
+{
+ char c, *ret, *dst;
+
+ if (src == NULL)
+ return NULL;
+ for (ret = dst = src; (c = *src++); *dst++ = c ) {
+ if (c != '\\')
+ continue; /* copy char at the end of the loop */
+ switch ((c = *src++)) {
+ case '\0': /* special, trailing '\' */
+ c = '\\';
+ break;
+ case 'b': /* backspace */
+ c = '\b';
+ break;
+ case 'f': /* form feed */
+ c = '\f';
+ break;
+ case 'n':
+ c = '\n';
+ break;
+ case 'r':
+ c = '\r';
+ break;
+ case 't':
+ c = '\t';
+ break;
+ }
+ /* default, use the char literally */
+ }
+ *dst = '\0';
+ return ret;
+}
+
int ast_build_string_va(char **buffer, size_t *space, const char *fmt, va_list ap)
{
int result;