mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-21 04:03:28 +00:00
document xml_copy_escape() and add an extra function, namely
replace non-alphanum chars with underscore. This is useful when building field names in xml formatting. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45325 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -240,9 +240,19 @@ static char *complete_show_mancmd(const char *line, const char *word, int pos, i
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xml_copy_escape(char **dst, size_t *maxlen, const char *src, int lower)
|
/*
|
||||||
|
* convert to xml with various conversion:
|
||||||
|
* mode & 1 -> lowercase;
|
||||||
|
* mode & 2 -> replace non-alphanumeric chars with underscore
|
||||||
|
*/
|
||||||
|
static void xml_copy_escape(char **dst, size_t *maxlen, const char *src, int mode)
|
||||||
{
|
{
|
||||||
while (*src && (*maxlen > 6)) {
|
for ( ; *src && *maxlen > 6; src++) {
|
||||||
|
if ( (mode & 2) && !isalnum(*src)) {
|
||||||
|
*(*dst)++ = '_';
|
||||||
|
(*maxlen)--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
switch (*src) {
|
switch (*src) {
|
||||||
case '<':
|
case '<':
|
||||||
strcpy(*dst, "<");
|
strcpy(*dst, "<");
|
||||||
@@ -269,11 +279,11 @@ static void xml_copy_escape(char **dst, size_t *maxlen, const char *src, int low
|
|||||||
(*dst) += 5;
|
(*dst) += 5;
|
||||||
*maxlen -= 5;
|
*maxlen -= 5;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
*(*dst)++ = lower ? tolower(*src) : *src;
|
*(*dst)++ = mode ? tolower(*src) : *src;
|
||||||
(*maxlen)--;
|
(*maxlen)--;
|
||||||
}
|
}
|
||||||
src++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user