mod_sofia: Add url encode to a var in the xml output to be valid xml. Also changed switch_url_encode to return the pointer of the string rather than the length, same as switch_amp_encode()

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@17087 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Marc Olivier Chouinard 2010-03-24 19:04:19 +00:00
parent 256274ac33
commit 58819523b6
3 changed files with 17 additions and 22 deletions

View File

@ -591,7 +591,7 @@ SWITCH_DECLARE(switch_status_t) switch_string_match(const char *string, size_t s
SWITCH_DECLARE(char *) switch_util_quote_shell_arg(const char *string); SWITCH_DECLARE(char *) switch_util_quote_shell_arg(const char *string);
#define SWITCH_READ_ACCEPTABLE(status) (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK) #define SWITCH_READ_ACCEPTABLE(status) (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK)
SWITCH_DECLARE(size_t) switch_url_encode(const char *url, char *buf, size_t len); SWITCH_DECLARE(char *) switch_url_encode(const char *url, char *buf, size_t len);
SWITCH_DECLARE(char *) switch_url_decode(char *s); SWITCH_DECLARE(char *) switch_url_decode(char *s);
SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to, SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to,
const char *from, const char *from,

View File

@ -2075,25 +2075,20 @@ static int show_reg_callback_xml(void *pArg, int argc, char **argv, char **colum
switch_strftime_nocheck(exp_buf, &retsize, sizeof(exp_buf), "%Y-%m-%d %T", &tm); switch_strftime_nocheck(exp_buf, &retsize, sizeof(exp_buf), "%Y-%m-%d %T", &tm);
} }
cb->stream->write_function(cb->stream, cb->stream->write_function(cb->stream," <registration>\n");
" <registration>\n" cb->stream->write_function(cb->stream," <call-id>%s</call-id>\n", switch_str_nil(argv[0]));
" <call-id>%s</call-id>\n" cb->stream->write_function(cb->stream," <user>%s@%s</user>\n", switch_str_nil(argv[1]), switch_str_nil(argv[2]));
" <user>%s@%s</user>\n" cb->stream->write_function(cb->stream," <contact>%s</contact>\n", switch_amp_encode(switch_str_nil(argv[3]), xmlbuf, buflen));
" <contact>%s</contact>\n" cb->stream->write_function(cb->stream," <agent>%s</agent>\n", switch_str_nil(argv[7]));
" <agent>%s</agent>\n" cb->stream->write_function(cb->stream," <status>%s(%s) exp(%s)</status>\n", switch_str_nil(argv[4]), switch_str_nil(argv[5]), exp_buf);
" <status>%s(%s) exp(%s)</status>\n" cb->stream->write_function(cb->stream," <host>%s</host>\n", switch_str_nil(argv[11]));
" <host>%s</host>\n" cb->stream->write_function(cb->stream," <network-ip>%s</network-ip>\n", switch_str_nil(argv[12]));
" <network-ip>%s</network-ip>\n" cb->stream->write_function(cb->stream," <network-port>%s</network-port>\n", switch_str_nil(argv[13]));
" <network-port>%s</network-port>\n" cb->stream->write_function(cb->stream," <sip-auth-user>%s</sip-auth-user>\n", switch_url_encode(switch_str_nil(argv[14]), xmlbuf, sizeof(xmlbuf)));
" <sip-auth-user>%s</sip-auth-user>\n" cb->stream->write_function(cb->stream," <sip-auth-realm>%s</sip-auth-realm>\n", switch_str_nil(argv[15]));
" <sip-auth-realm>%s</sip-auth-realm>\n" cb->stream->write_function(cb->stream," <mwi-account>%s@%s</mwi-account>\n", switch_str_nil(argv[16]), switch_str_nil(argv[17]));
" <mwi-account>%s@%s</mwi-account>\n" cb->stream->write_function(cb->stream," </registration>\n");
" </registration>\n",
switch_str_nil(argv[0]), switch_str_nil(argv[1]), switch_str_nil(argv[2]),
switch_amp_encode(switch_str_nil(argv[3]), xmlbuf, buflen),
switch_str_nil(argv[7]), switch_str_nil(argv[4]), switch_str_nil(argv[5]), exp_buf, switch_str_nil(argv[11]),
switch_str_nil(argv[12]), switch_str_nil(argv[13]), switch_str_nil(argv[14]), switch_str_nil(argv[15]),
switch_str_nil(argv[16]), switch_str_nil(argv[17]));
return 0; return 0;
} }

View File

@ -1991,7 +1991,7 @@ SWITCH_DECLARE(int) switch_socket_waitfor(switch_pollfd_t *poll, int ms)
return nsds; return nsds;
} }
SWITCH_DECLARE(size_t) switch_url_encode(const char *url, char *buf, size_t len) SWITCH_DECLARE(char *) switch_url_encode(const char *url, char *buf, size_t len)
{ {
const char *p; const char *p;
size_t x = 0; size_t x = 0;
@ -2025,7 +2025,7 @@ SWITCH_DECLARE(size_t) switch_url_encode(const char *url, char *buf, size_t len)
} }
buf[x] = '\0'; buf[x] = '\0';
return x; return buf;
} }
SWITCH_DECLARE(char *) switch_url_decode(char *s) SWITCH_DECLARE(char *) switch_url_decode(char *s)