add function http_parse_url_params
parent
a6d00af752
commit
372a02d9d4
3
HISTORY
3
HISTORY
|
|
@ -1,9 +1,10 @@
|
||||||
|
|
||||||
Version 1.28 2016-05-19
|
Version 1.28 2016-06-06
|
||||||
* id generator support extra bits
|
* id generator support extra bits
|
||||||
* change inet_aton to inet_pton
|
* change inet_aton to inet_pton
|
||||||
* connect by ip and connection pool support ipv6
|
* connect by ip and connection pool support ipv6
|
||||||
* id generator in php extension support multi instance
|
* id generator in php extension support multi instance
|
||||||
|
* add function http_parse_url_params
|
||||||
|
|
||||||
Version 1.27 2016-04-15
|
Version 1.27 2016-04-15
|
||||||
* add function fd_set_cloexec
|
* add function fd_set_cloexec
|
||||||
|
|
|
||||||
|
|
@ -339,30 +339,20 @@ int http_parse_query(char *url, KeyValuePair *params, const int max_count)
|
||||||
return pCurrent - params;
|
return pCurrent - params;
|
||||||
}
|
}
|
||||||
|
|
||||||
int http_parse_query_ex(char *url, const int url_len,
|
int http_parse_url_params(char *param_str, const int param_len,
|
||||||
int *uri_len, KeyValuePairEx *params, const int max_count)
|
KeyValuePairEx *params, const int max_count)
|
||||||
{
|
{
|
||||||
KeyValuePairEx *pCurrent;
|
KeyValuePairEx *pCurrent;
|
||||||
KeyValuePairEx *pEnd;
|
KeyValuePairEx *pEnd;
|
||||||
char *pParamStart;
|
|
||||||
char *p;
|
char *p;
|
||||||
char *pStrEnd;
|
char *pStrEnd;
|
||||||
char *pKeyEnd;
|
char *pKeyEnd;
|
||||||
char *pValueEnd;
|
char *pValueEnd;
|
||||||
|
|
||||||
pParamStart = (char *)memchr(url, '?', url_len);
|
pStrEnd = param_str + param_len;
|
||||||
if (pParamStart == NULL)
|
|
||||||
{
|
|
||||||
*uri_len = url_len;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
*uri_len = pParamStart - url;
|
|
||||||
pStrEnd = url + url_len;
|
|
||||||
|
|
||||||
pEnd = params + max_count;
|
pEnd = params + max_count;
|
||||||
pCurrent = params;
|
pCurrent = params;
|
||||||
p = pParamStart + 1;
|
p = param_str;
|
||||||
while (p < pStrEnd)
|
while (p < pStrEnd)
|
||||||
{
|
{
|
||||||
if (pCurrent >= pEnd)
|
if (pCurrent >= pEnd)
|
||||||
|
|
@ -405,3 +395,22 @@ int http_parse_query_ex(char *url, const int url_len,
|
||||||
return pCurrent - params;
|
return pCurrent - params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int http_parse_query_ex(char *url, const int url_len,
|
||||||
|
int *uri_len, KeyValuePairEx *params, const int max_count)
|
||||||
|
{
|
||||||
|
char *pParamStart;
|
||||||
|
int param_len;
|
||||||
|
|
||||||
|
pParamStart = (char *)memchr(url, '?', url_len);
|
||||||
|
if (pParamStart == NULL)
|
||||||
|
{
|
||||||
|
*uri_len = url_len;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
*uri_len = pParamStart - url;
|
||||||
|
param_len = url_len - (*uri_len + 1);
|
||||||
|
return http_parse_url_params(pParamStart + 1, param_len,
|
||||||
|
params, max_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,18 @@ return: param count
|
||||||
int http_parse_query_ex(char *url, const int url_len,
|
int http_parse_query_ex(char *url, const int url_len,
|
||||||
int *uri_len, KeyValuePairEx *params, const int max_count);
|
int *uri_len, KeyValuePairEx *params, const int max_count);
|
||||||
|
|
||||||
|
/**
|
||||||
|
parse url params
|
||||||
|
params:
|
||||||
|
param_str: the url params to parse, the params be modified after parse
|
||||||
|
param_len: the length of url params
|
||||||
|
params: params array to store param and it's value
|
||||||
|
max_count: max param count
|
||||||
|
return: param count
|
||||||
|
**/
|
||||||
|
int http_parse_url_params(char *param_str, const int param_len,
|
||||||
|
KeyValuePairEx *params, const int max_count);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue