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);
294 snprintf(numbuf,
sizeof(numbuf),
"%d", url->port);
328 buf=(
char*)malloc(p-s+1);
330 memmove(buf, s, p-s+1);
344 while(*s && *s==
'?') {
352 while(*p && *p!=
'?' && *p!=
'=')
376 url->url=strdup(str);
void GWEN_Url_free(GWEN_URL *st)
char * GWEN_Buffer_GetStart(const GWEN_BUFFER *bf)
struct GWEN_DB_NODE GWEN_DB_NODE
void GWEN_DB_Group_free(GWEN_DB_NODE *n)
uint32_t GWEN_Buffer_GetUsedBytes(const GWEN_BUFFER *bf)
void GWEN_Url_SetProtocol(GWEN_URL *st, const char *d)
void GWEN_Url_SetServer(GWEN_URL *st, const char *d)
GWEN_BUFFER * GWEN_Buffer_new(char *buffer, uint32_t size, uint32_t used, int take)
GWEN_URL * GWEN_Url_fromCommandString(const char *str)
int GWEN_Url_toCommandString(const GWEN_URL *url, GWEN_BUFFER *buf)
int GWEN_Url_toString(const GWEN_URL *url, GWEN_BUFFER *buf)
GWEN_DB_NODE * GWEN_DB_GetFirstVar(GWEN_DB_NODE *n)
#define DBG_DEBUG(dbg_logger, format, args...)
void GWEN_Url_SetUserName(GWEN_URL *st, const char *d)
void GWEN_Url_SetPassword(GWEN_URL *st, const char *d)
const char * GWEN_DB_VariableName(GWEN_DB_NODE *n)
GWEN_URL * GWEN_Url_new(void)
void GWEN_Url_toUiShortString(const GWEN_URL *url, GWEN_BUFFER *buf)
void GWEN_Buffer_free(GWEN_BUFFER *bf)
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
#define DBG_ERROR(dbg_logger, format, args...)
GWEN_URL * GWEN_Url_fromString(const char *str)
int GWEN_DB_SetCharValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, const char *val)
void GWEN_Url_SetPath(GWEN_URL *st, const char *d)
GWEN_DB_NODE * GWEN_DB_GetFirstValue(GWEN_DB_NODE *n)
GWEN_DB_NODE * GWEN_DB_GetNextVar(GWEN_DB_NODE *n)
int GWEN_Buffer_AppendBytes(GWEN_BUFFER *bf, const char *buffer, uint32_t size)
GWEN_DB_NODE * GWEN_Url_GetVars(const GWEN_URL *st)
void GWEN_Url_SetVars(GWEN_URL *st, GWEN_DB_NODE *d)
GWEN_DB_NODE * GWEN_DB_Group_new(const char *name)
int GWEN_Buffer_AppendString(GWEN_BUFFER *bf, const char *buffer)
#define GWEN_DB_FLAGS_DEFAULT
const char * GWEN_DB_GetCharValueFromNode(const GWEN_DB_NODE *n)