|
| iMatix home page | << | < | > | >> |
SFLVersion 2.11 |
#include "sflhttp.h"
char *
http_escape_hex (
const char *string,
char *result,
size_t outmax)
Works as http escape(), but converts spaces to %20 instead of '+'. This encoding is standard for filenames and URL requests.
{
char
*target; /* Where we store the result */
size_t
length; /* of escaped character */
ASSERT (string);
if (outmax == 0) /* If no fixed length, get total len*/
outmax = http escape size (string);
if (result == NULL)
if ((result = mem_alloc (outmax)) == NULL)
return (NULL); /* Could not allocate a block */
if (outmax > 1)
outmax -= 1; /* Leave space for NULL terminator */
else
if (outmax == 1) /* Only room for terminator */
{
*result = '\0';
return (result);
}
target = result;
while (*string)
{
length = http_escape_char (*string, target, outmax, TRUE);
if (length == 0)
break;
target += length;
outmax -= length;
if (*string == '\n' || *string == '\r')
{
if ((string [1] == '\n' || string [1] == '\r')
&& (string [1] != *string))
string++;
}
string++;
}
*target = '\0'; /* Terminate target string */
return (result);
}
| | << | < | > | >> |
|