-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetQueryParams.h
More file actions
70 lines (60 loc) · 1.59 KB
/
getQueryParams.h
File metadata and controls
70 lines (60 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef STRINGFUNCTIONS_GETQUERYPARAMS
#define STRINGFUNCTIONS_GETQUERYPARAMS
urlQuery* c_StringFunctions::getQueryParams(const mystr str){
size_t str_ind=0;
bool haveQuery=false;
while(str[str_ind]!=STRING_END){
if(str[str_ind]==STRING_QUERY_INITPARAMS){
haveQuery=true;
str_ind++;
break;
}
str_ind++;
}
if(!haveQuery){
return NULL;
}
urlQuery *current,*retBase;
retBase=createUrlQuery();
current=retBase;
int initInd;
while(str[str_ind]!=STRING_END){
initInd=str_ind;
while(str[str_ind]!=STRING_GET_INITVALUE && str[str_ind]!=STRING_END)str_ind++;
if(str_ind-initInd>0)
strAdd(¤t->param,&str[initInd],str_ind-initInd);
if(str[str_ind]==STRING_END)break;
str_ind++;
initInd=str_ind;
while(str[str_ind]!=STRING_GET_CLOSEVALUE && str[str_ind]!=STRING_END)str_ind++;
strAdd(¤t->value,&str[initInd],str_ind-initInd);
if(str[str_ind]==STRING_END)break;
str_ind++;
if(str[str_ind]==STRING_END)break;
current->next=createUrlQuery();
current=current->next;
}
return retBase;
}
void c_StringFunctions::freeUrlQuery(urlQuery* data){
urlQuery *next,*current;
current=data;
while(current!=NULL){
freeStr(¤t->value);
freeStr(¤t->param);
next=current->next;
free(current);
current=next;
}
}
urlQuery* c_StringFunctions::createUrlQuery(){
urlQuery*ret=(urlQuery*)malloc(sizeof(urlQuery));
zeroUrlQueryStruct(ret);
return ret;
}
void c_StringFunctions::zeroUrlQueryStruct(urlQuery* stru){
stru->param=NULL;
stru->value=NULL;
stru->next=NULL;
}
#endif