mirror of
https://github.com/libretro/libretro-common.git
synced 2024-11-27 10:20:53 +00:00
Resync
This commit is contained in:
parent
b69a133156
commit
fd934be932
@ -104,6 +104,9 @@ bool string_split_noalloc(struct string_list *list,
|
||||
*/
|
||||
struct string_list *string_separate(char *str, const char *delim);
|
||||
|
||||
bool string_separate_noalloc(struct string_list *list,
|
||||
char *str, const char *delim);
|
||||
|
||||
bool string_list_deinitialize(struct string_list *list);
|
||||
|
||||
bool string_list_initialize(struct string_list *list);
|
||||
|
@ -411,6 +411,39 @@ error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool string_separate_noalloc(
|
||||
struct string_list *list,
|
||||
char *str, const char *delim)
|
||||
{
|
||||
char *token = NULL;
|
||||
char **str_ptr = NULL;
|
||||
|
||||
/* Sanity check */
|
||||
if (!str || string_is_empty(delim) || !list)
|
||||
return false;
|
||||
|
||||
str_ptr = &str;
|
||||
token = string_tokenize(str_ptr, delim);
|
||||
|
||||
while (token)
|
||||
{
|
||||
union string_list_elem_attr attr;
|
||||
|
||||
attr.i = 0;
|
||||
|
||||
if (!string_list_append(list, token, attr))
|
||||
{
|
||||
free(token);
|
||||
return false;
|
||||
}
|
||||
|
||||
free(token);
|
||||
token = string_tokenize(str_ptr, delim);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* string_list_find_elem:
|
||||
* @list : pointer to string list
|
||||
|
279
net/net_http.c
279
net/net_http.c
@ -91,32 +91,277 @@ struct http_connection_t
|
||||
caller is responsible for deleting the destination buffer */
|
||||
void net_http_urlencode(char **dest, const char *source)
|
||||
{
|
||||
/* TODO/FIXME - static local globals */
|
||||
static char urlencode_lut[256];
|
||||
static bool urlencode_lut_inited = false;
|
||||
static const char urlencode_lut[256] =
|
||||
{
|
||||
0, /* 0 */
|
||||
0, /* 1 */
|
||||
0, /* 2 */
|
||||
0, /* 3 */
|
||||
0, /* 4 */
|
||||
0, /* 5 */
|
||||
0, /* 6 */
|
||||
0, /* 7 */
|
||||
0, /* 8 */
|
||||
0, /* 9 */
|
||||
0, /* 10 */
|
||||
0, /* 11 */
|
||||
0, /* 12 */
|
||||
0, /* 13 */
|
||||
0, /* 14 */
|
||||
0, /* 15 */
|
||||
0, /* 16 */
|
||||
0, /* 17 */
|
||||
0, /* 18 */
|
||||
0, /* 19 */
|
||||
0, /* 20 */
|
||||
0, /* 21 */
|
||||
0, /* 22 */
|
||||
0, /* 23 */
|
||||
0, /* 24 */
|
||||
0, /* 25 */
|
||||
0, /* 26 */
|
||||
0, /* 27 */
|
||||
0, /* 28 */
|
||||
0, /* 29 */
|
||||
0, /* 30 */
|
||||
0, /* 31 */
|
||||
0, /* 32 */
|
||||
0, /* 33 */
|
||||
0, /* 34 */
|
||||
0, /* 35 */
|
||||
0, /* 36 */
|
||||
0, /* 37 */
|
||||
0, /* 38 */
|
||||
0, /* 39 */
|
||||
0, /* 40 */
|
||||
0, /* 41 */
|
||||
'*', /* 42 */
|
||||
0, /* 43 */
|
||||
0, /* 44 */
|
||||
'-', /* 45 */
|
||||
'.', /* 46 */
|
||||
'/', /* 47 */
|
||||
'0', /* 48 */
|
||||
'1', /* 49 */
|
||||
'2', /* 50 */
|
||||
'3', /* 51 */
|
||||
'4', /* 52 */
|
||||
'5', /* 53 */
|
||||
'6', /* 54 */
|
||||
'7', /* 55 */
|
||||
'8', /* 56 */
|
||||
'9', /* 57 */
|
||||
0, /* 58 */
|
||||
0, /* 59 */
|
||||
0, /* 60 */
|
||||
0, /* 61 */
|
||||
0, /* 62 */
|
||||
0, /* 63 */
|
||||
0, /* 64 */
|
||||
'A', /* 65 */
|
||||
'B', /* 66 */
|
||||
'C', /* 67 */
|
||||
'D', /* 68 */
|
||||
'E', /* 69 */
|
||||
'F', /* 70 */
|
||||
'G', /* 71 */
|
||||
'H', /* 72 */
|
||||
'I', /* 73 */
|
||||
'J', /* 74 */
|
||||
'K', /* 75 */
|
||||
'L', /* 76 */
|
||||
'M', /* 77 */
|
||||
'N', /* 78 */
|
||||
'O', /* 79 */
|
||||
'P', /* 80 */
|
||||
'Q', /* 81 */
|
||||
'R', /* 82 */
|
||||
'S', /* 83 */
|
||||
'T', /* 84 */
|
||||
'U', /* 85 */
|
||||
'V', /* 86 */
|
||||
'W', /* 87 */
|
||||
'X', /* 88 */
|
||||
'Y', /* 89 */
|
||||
'Z', /* 90 */
|
||||
0, /* 91 */
|
||||
0, /* 92 */
|
||||
0, /* 93 */
|
||||
0, /* 94 */
|
||||
'_', /* 95 */
|
||||
0, /* 96 */
|
||||
'a', /* 97 */
|
||||
'b', /* 98 */
|
||||
'c', /* 99 */
|
||||
'd', /* 100 */
|
||||
'e', /* 101 */
|
||||
'f', /* 102 */
|
||||
'g', /* 103 */
|
||||
'h', /* 104 */
|
||||
'i', /* 105 */
|
||||
'j', /* 106 */
|
||||
'k', /* 107 */
|
||||
'l', /* 108 */
|
||||
'm', /* 109 */
|
||||
'n', /* 110 */
|
||||
'o', /* 111 */
|
||||
'p', /* 112 */
|
||||
'q', /* 113 */
|
||||
'r', /* 114 */
|
||||
's', /* 115 */
|
||||
't', /* 116 */
|
||||
'u', /* 117 */
|
||||
'v', /* 118 */
|
||||
'w', /* 119 */
|
||||
'x', /* 120 */
|
||||
'y', /* 121 */
|
||||
'z', /* 122 */
|
||||
0, /* 123 */
|
||||
0, /* 124 */
|
||||
0, /* 125 */
|
||||
0, /* 126 */
|
||||
0, /* 127 */
|
||||
0, /* 128 */
|
||||
0, /* 129 */
|
||||
0, /* 130 */
|
||||
0, /* 131 */
|
||||
0, /* 132 */
|
||||
0, /* 133 */
|
||||
0, /* 134 */
|
||||
0, /* 135 */
|
||||
0, /* 136 */
|
||||
0, /* 137 */
|
||||
0, /* 138 */
|
||||
0, /* 139 */
|
||||
0, /* 140 */
|
||||
0, /* 141 */
|
||||
0, /* 142 */
|
||||
0, /* 143 */
|
||||
0, /* 144 */
|
||||
0, /* 145 */
|
||||
0, /* 146 */
|
||||
0, /* 147 */
|
||||
0, /* 148 */
|
||||
0, /* 149 */
|
||||
0, /* 150 */
|
||||
0, /* 151 */
|
||||
0, /* 152 */
|
||||
0, /* 153 */
|
||||
0, /* 154 */
|
||||
0, /* 155 */
|
||||
0, /* 156 */
|
||||
0, /* 157 */
|
||||
0, /* 158 */
|
||||
0, /* 159 */
|
||||
0, /* 160 */
|
||||
0, /* 161 */
|
||||
0, /* 162 */
|
||||
0, /* 163 */
|
||||
0, /* 164 */
|
||||
0, /* 165 */
|
||||
0, /* 166 */
|
||||
0, /* 167 */
|
||||
0, /* 168 */
|
||||
0, /* 169 */
|
||||
0, /* 170 */
|
||||
0, /* 171 */
|
||||
0, /* 172 */
|
||||
0, /* 173 */
|
||||
0, /* 174 */
|
||||
0, /* 175 */
|
||||
0, /* 176 */
|
||||
0, /* 177 */
|
||||
0, /* 178 */
|
||||
0, /* 179 */
|
||||
0, /* 180 */
|
||||
0, /* 181 */
|
||||
0, /* 182 */
|
||||
0, /* 183 */
|
||||
0, /* 184 */
|
||||
0, /* 185 */
|
||||
0, /* 186 */
|
||||
0, /* 187 */
|
||||
0, /* 188 */
|
||||
0, /* 189 */
|
||||
0, /* 190 */
|
||||
0, /* 191 */
|
||||
0, /* 192 */
|
||||
0, /* 193 */
|
||||
0, /* 194 */
|
||||
0, /* 195 */
|
||||
0, /* 196 */
|
||||
0, /* 197 */
|
||||
0, /* 198 */
|
||||
0, /* 199 */
|
||||
0, /* 200 */
|
||||
0, /* 201 */
|
||||
0, /* 202 */
|
||||
0, /* 203 */
|
||||
0, /* 204 */
|
||||
0, /* 205 */
|
||||
0, /* 206 */
|
||||
0, /* 207 */
|
||||
0, /* 208 */
|
||||
0, /* 209 */
|
||||
0, /* 210 */
|
||||
0, /* 211 */
|
||||
0, /* 212 */
|
||||
0, /* 213 */
|
||||
0, /* 214 */
|
||||
0, /* 215 */
|
||||
0, /* 216 */
|
||||
0, /* 217 */
|
||||
0, /* 218 */
|
||||
0, /* 219 */
|
||||
0, /* 220 */
|
||||
0, /* 221 */
|
||||
0, /* 222 */
|
||||
0, /* 223 */
|
||||
0, /* 224 */
|
||||
0, /* 225 */
|
||||
0, /* 226 */
|
||||
0, /* 227 */
|
||||
0, /* 228 */
|
||||
0, /* 229 */
|
||||
0, /* 230 */
|
||||
0, /* 231 */
|
||||
0, /* 232 */
|
||||
0, /* 233 */
|
||||
0, /* 234 */
|
||||
0, /* 235 */
|
||||
0, /* 236 */
|
||||
0, /* 237 */
|
||||
0, /* 238 */
|
||||
0, /* 239 */
|
||||
0, /* 240 */
|
||||
0, /* 241 */
|
||||
0, /* 242 */
|
||||
0, /* 243 */
|
||||
0, /* 244 */
|
||||
0, /* 245 */
|
||||
0, /* 246 */
|
||||
0, /* 247 */
|
||||
0, /* 248 */
|
||||
0, /* 249 */
|
||||
0, /* 250 */
|
||||
0, /* 251 */
|
||||
0, /* 252 */
|
||||
0, /* 253 */
|
||||
0, /* 254 */
|
||||
0 /* 255 */
|
||||
};
|
||||
|
||||
char *enc = NULL;
|
||||
/* Assume every character will be encoded, so we need 3 times the space. */
|
||||
size_t len = strlen(source) * 3 + 1;
|
||||
size_t count = len;
|
||||
|
||||
if (!urlencode_lut_inited)
|
||||
{
|
||||
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);
|
||||
*dest = enc;
|
||||
char *enc = (char*)calloc(1, len);
|
||||
*dest = enc;
|
||||
|
||||
for (; *source; source++)
|
||||
{
|
||||
int written = 0;
|
||||
|
||||
/* any non-ascii character will just be encoded without question */
|
||||
/* any non-ASCII character will just be encoded without question */
|
||||
if ((unsigned)*source < sizeof(urlencode_lut) && urlencode_lut[(unsigned)*source])
|
||||
written = snprintf(enc, count, "%c", urlencode_lut[(unsigned)*source]);
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user