20 #include <gwenhywfar/debug.h>
29 int starts_with_drive_letter = 0;
42 if (s && isalpha(s[0]) && s[1] ==
':'
43 && (s[2] ==
'/' || s[2] ==
'\\')) {
44 starts_with_drive_letter = 1;
48 p = starts_with_drive_letter ? s : strchr(s,
':');
50 if (p[1]==
'/' && p[2]==
'/') {
54 buf=(
char*)malloc(p-s+1);
56 memmove(buf, s, p-s+1);
77 upw=(
char*)malloc(p-s+1);
98 if (!starts_with_drive_letter
99 && s && isalpha(s[0]) && s[1] ==
':'
100 && (s[2] ==
'/' || s[2] ==
'\\')) {
101 starts_with_drive_letter = 1;
111 while(!starts_with_drive_letter && *p && *p!=
':' && *p!=
'/' && *p!=
'?')
117 buf=(
char*)malloc(p-s+1);
119 memmove(buf, s, p-s+1);
130 while(*p && *p!=
'?' && *p!=
'/')
137 buf=(
char*)malloc(p-s+1);
139 memmove(buf, s, p-s+1);
141 if (sscanf(buf,
"%d", &port)!=1) {
154 if (strcasecmp(url->protocol,
"http")==0)
156 else if (strcasecmp(url->protocol,
"https")==0)
162 if (starts_with_drive_letter || *s==
'/') {
170 buf=(
char*)malloc(p-s+1);
172 memmove(buf, s, p-s+1);
187 while(*s && *s==
'?') {
195 while(*p && *p!=
'?' && *p!=
'=')
219 url->url=strdup(str);
228 if (!url->_modified && !(url->url==0 || url->url[0]==0)) {
244 snprintf(numbuf,
sizeof(numbuf),
"%d", url->port);
303 buf=(
char*)malloc(p-s+1);
305 memmove(buf, s, p-s+1);
319 while(*s && *s==
'?') {
327 while(*p && *p!=
'?' && *p!=
'=')
351 url->url=strdup(str);