mirror of
https://github.com/libretro/RetroArch
synced 2025-02-19 12:41:00 +00:00
(net_http) Refactor
This commit is contained in:
parent
9edd265bf4
commit
d5bdec3f60
@ -89,33 +89,27 @@ struct http_connection_t
|
|||||||
struct http_socket_state_t sock_state;
|
struct http_socket_state_t sock_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* TODO/FIXME - static globals */
|
|
||||||
static char urlencode_lut[256];
|
|
||||||
static bool urlencode_lut_inited = false;
|
|
||||||
|
|
||||||
void urlencode_lut_init(void)
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
|
|
||||||
urlencode_lut_inited = true;
|
|
||||||
|
|
||||||
for (i = 0; i < 256; i++)
|
|
||||||
{
|
|
||||||
urlencode_lut[i] = isalnum(i) || i == '*' || i == '-' || i == '.' || i == '_' || i == '/' ? i : 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* URL Encode a string
|
/* URL Encode a string
|
||||||
caller is responsible for deleting the destination buffer */
|
caller is responsible for deleting the destination buffer */
|
||||||
void net_http_urlencode(char **dest, const char *source)
|
void net_http_urlencode(char **dest, const char *source)
|
||||||
{
|
{
|
||||||
char *enc = NULL;
|
/* TODO/FIXME - static local globals */
|
||||||
|
static char urlencode_lut[256];
|
||||||
|
static bool urlencode_lut_inited = false;
|
||||||
|
|
||||||
|
char *enc = NULL;
|
||||||
/* Assume every character will be encoded, so we need 3 times the space. */
|
/* Assume every character will be encoded, so we need 3 times the space. */
|
||||||
size_t len = strlen(source) * 3 + 1;
|
size_t len = strlen(source) * 3 + 1;
|
||||||
size_t count = len;
|
size_t count = len;
|
||||||
|
|
||||||
if (!urlencode_lut_inited)
|
if (!urlencode_lut_inited)
|
||||||
urlencode_lut_init();
|
{
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
for (i = 0; i < 256; i++)
|
||||||
|
urlencode_lut[i] = isalnum(i) || i == '*' || i == '-' || i == '.' || i == '_' || i == '/' ? i : 0;
|
||||||
|
urlencode_lut_inited = true;
|
||||||
|
}
|
||||||
|
|
||||||
enc = (char*)calloc(1, len);
|
enc = (char*)calloc(1, len);
|
||||||
*dest = enc;
|
*dest = enc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user