59 static size_t bufsize = 0;
62 unsigned int i, do_escape;
64 if (buf ==
NULL || strlen(url) * 3 > bufsize) {
66 bufsize = strlen(url) * 3 + 1;
67 buf = (
char*)
xcalloc(bufsize, 1);
69 for (src = url, dst = buf; *src !=
'\0' && dst < (buf + bufsize - 1); src++, dst++) {
72 if ((*src >=
'a' && *src <=
'z') || (*src >=
'A' && *src <=
'Z') || (*src >=
'0' && *src <=
'9')) {
105 if ((
unsigned char) *src <= (
unsigned char) 0x1F)
108 else if (*src == (
char) 0x7F)
111 else if (((
unsigned char) *src >= (
unsigned char) 0x80))
115 if (do_escape == 1) {
116 (void) snprintf(dst, (bufsize-(dst-buf)),
"%%%02X", (
unsigned char) *src);
117 dst +=
sizeof(char) * 2;
132 if (ch >=
'0' && ch <=
'9')
134 if (ch >=
'a' && ch <=
'f')
135 return ch -
'a' + 10;
136 if (ch >=
'A' && ch <=
'F')
137 return ch -
'A' + 10;
149 for (i = j = 0; s[j]; i++, j++) {
153 }
else if (s[j + 1] ==
'%') {
165 if (x > 0 && x <= 255) {
static char rfc1738_unsafe_chars[]
static char rfc1738_reserved_chars[]
void rfc1738_unescape(char *s)
char * rfc1738_do_escape(const char *url, int flags)
static int fromhex(char ch)
#define RFC1738_ESCAPE_UNSAFE
#define RFC1738_ESCAPE_CTRLS
#define RFC1738_ESCAPE_NOSPACE
#define RFC1738_ESCAPE_RESERVED
#define RFC1738_ESCAPE_NOPERCENT
void * xcalloc(size_t n, size_t sz)