diff options
author | Gerasimos Dimitriadis <dimeg@intracom.gr> | 2010-01-26 18:21:17 +0000 |
---|---|---|
committer | Gerasimos Dimitriadis <dimeg@intracom.gr> | 2010-01-26 18:21:17 +0000 |
commit | c08fa6f3cf2ded7ff34393739c7b26c953f74ddb (patch) | |
tree | 8e6dfadc33670265be83256ef3eb7139de8e3b02 /epan/strutil.c | |
parent | 293ea61af2e8ff0fb166f1450df610ce8e483b21 (diff) | |
download | wireshark-c08fa6f3cf2ded7ff34393739c7b26c953f74ddb.tar.gz |
Move underscore escaping/unscaping function to strutil.c;
Update decoding of IS-801 Request GPS Acquisition Assistance
svn path=/trunk/; revision=31685
Diffstat (limited to 'epan/strutil.c')
-rw-r--r-- | epan/strutil.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/epan/strutil.c b/epan/strutil.c index b2a77f54c7..f6b9b9e4d7 100644 --- a/epan/strutil.c +++ b/epan/strutil.c @@ -1077,3 +1077,59 @@ IA5_7BIT_decode(unsigned char * dest, const unsigned char* src, int len) return; } +/* + * This function takes a string and copies it, inserting an underscore before + * every underscore in it. + */ +gchar* +ws_strdup_escape_underscore (const gchar *str) +{ + gchar *p, *q, *new_str; + + if(!str) + return NULL; + + p = (gchar *)str; + /* Worst case: A string that is full of underscores */ + q = new_str = g_malloc (strlen(str) * 2 + 1); + + while(*p != 0) + { + if(*p == '_') + *q++ = '_'; + + *q++ = *p++; + } + *q++ = '\0'; + + return new_str; +} + +/* + * This function takes a string and copies it, removing any occurences of double + * underscores with a single underscore. + */ +gchar* +ws_strdup_unescape_underscore (const gchar *str) +{ + gchar *p, *q, *new_str; + + if(!str) + return NULL; + + p = (gchar *)str; + /* Worst case: A string that contains no underscores */ + q = new_str = g_malloc (strlen(str) + 1); + + while(*p != 0) + { + *q++ = *p; + if ((*p == '_') && (*(p+1) == '_')) + p += 2; + else + p++; + } + *q++ = '\0'; + + return new_str; +} |