55 |
} |
} |
56 |
else /* Find the end of the token. */ |
else /* Find the end of the token. */ |
57 |
end = strpbrk (begin, delim); |
end = strpbrk (begin, delim); |
58 |
if ( end ){ |
if (end) { |
59 |
/* Terminate the token and set *STRINGP past NUL character. */ |
/* Terminate the token and set *STRINGP past NUL character. */ |
60 |
*end++ = '\0'; |
*end++ = '\0'; |
61 |
*stringp = end; |
*stringp = end; |
132 |
p[pos] = '\0'; |
p[pos] = '\0'; |
133 |
return p; |
return p; |
134 |
} |
} |
135 |
|
|
136 |
|
|
137 |
|
/* Remove %AB sequences from the input buffer @in |
138 |
|
and store the raw data in @out. */ |
139 |
|
void |
140 |
|
unhexify_buffer (const char *in, char **out) |
141 |
|
{ |
142 |
|
char temp[3]; |
143 |
|
size_t pos, i=0; |
144 |
|
|
145 |
|
*out = (char*)calloc (1, strlen (in)+1); |
146 |
|
if (!*out) |
147 |
|
abort (); |
148 |
|
for (pos = 0; pos < strlen (in); pos++) { |
149 |
|
if (in[pos] == '%' && in[pos+1] == '%') |
150 |
|
(*out)[i++] = '%'; |
151 |
|
else if (in[pos] == '%') { |
152 |
|
temp[0] = in[++pos]; |
153 |
|
temp[1] = in[++pos]; |
154 |
|
temp[2] = 0; |
155 |
|
(*out)[i++] = (char)strtoul (temp, NULL, 16); |
156 |
|
} |
157 |
|
else |
158 |
|
(*out)[i++] = in[pos]; |
159 |
|
} |
160 |
|
(*out)[i] = 0; |
161 |
|
} |