| 15 | static unsigned char enc_tab[] = "0123456789ABCDEF"; |
| 16 | |
| 17 | char *acl_url_encode(const char *str, ACL_DBUF_POOL *dbuf) |
| 18 | { |
| 19 | int i, j, len, tmp_len; |
| 20 | unsigned char *tmp; |
| 21 | |
| 22 | len = (int) strlen(str); |
| 23 | tmp_len = len; |
| 24 | |
| 25 | if (dbuf != NULL) |
| 26 | tmp = (unsigned char*) acl_dbuf_pool_alloc(dbuf, len + 1); |
| 27 | else |
| 28 | tmp = (unsigned char*) acl_mymalloc(len + 1); |
| 29 | |
| 30 | for (i = 0, j = 0; i < len; i++, j++) { |
| 31 | tmp[j] = (unsigned char) str[i]; |
| 32 | /* if (tmp[j] == ' ') |
| 33 | tmp[j] = '+'; |
| 34 | else */ |
| 35 | if (!isalnum(tmp[j]) && strchr("_-.", tmp[j]) == NULL) { |
| 36 | tmp_len += 3; |
| 37 | if (dbuf != NULL) { |
| 38 | unsigned char *t = (unsigned char*) |
| 39 | acl_dbuf_pool_alloc(dbuf, tmp_len); |
| 40 | if (j > 0) |
| 41 | memcpy(t, tmp, j); |
| 42 | tmp = t; |
| 43 | } else |
| 44 | tmp = acl_myrealloc(tmp, tmp_len); |
| 45 | |
| 46 | tmp[j++] = '%'; |
| 47 | tmp[j++] = enc_tab[(unsigned char)str[i] >> 4]; |
| 48 | tmp[j] = enc_tab[(unsigned char)str[i] & 0x0F]; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | tmp[j] = '\0'; |
| 53 | return (char*) tmp; |
| 54 | } |
| 55 | |
| 56 | static unsigned char dec_tab[256] = { |
| 57 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
searching dependent graphs…