60 |
static size_t default_socket_timeout = 6; |
static size_t default_socket_timeout = 6; |
61 |
|
|
62 |
|
|
63 |
|
/* Remove %AB sequences from the input buffer @in |
64 |
|
and store the raw data in @out. */ |
65 |
|
void |
66 |
|
unhexify_buffer (const char *in, char **r_out) |
67 |
|
{ |
68 |
|
char temp[3], *out; |
69 |
|
size_t len, pos, i=0; |
70 |
|
|
71 |
|
len = strlen (in); |
72 |
|
out = new char[len+1]; |
73 |
|
if (!out) |
74 |
|
BUG (0); |
75 |
|
memset (out, 0, len+1); |
76 |
|
for (pos = 0; pos < len; pos++) { |
77 |
|
if (in[pos] == '%' && in[pos+1] == '%') |
78 |
|
out[i++] = '%'; |
79 |
|
else if (in[pos] == '%') { |
80 |
|
temp[0] = in[++pos]; |
81 |
|
temp[1] = in[++pos]; |
82 |
|
temp[2] = 0; |
83 |
|
out[i++] = (char)strtoul (temp, NULL, 16); |
84 |
|
} |
85 |
|
else |
86 |
|
out[i++] = in[pos]; |
87 |
|
} |
88 |
|
out[i] = 0; |
89 |
|
*r_out = out; |
90 |
|
} |
91 |
|
|
92 |
|
|
93 |
/* Wrapper for safe memory allocation. */ |
/* Wrapper for safe memory allocation. */ |
94 |
static char* |
static char* |
95 |
safe_alloc (DWORD n) |
safe_alloc (DWORD n) |