20 #include <gwenhywfar/debug.h> 30 int starts_with_drive_letter = 0;
43 if (s && isalpha(s[0]) && s[1] ==
':' 44 && (s[2] ==
'/' || s[2] ==
'\\')) {
45 starts_with_drive_letter = 1;
49 p = starts_with_drive_letter ? s : strchr(s,
':');
51 if (p[1]==
'/' && p[2]==
'/') {
55 buf=(
char *)malloc(p-s+1);
57 memmove(buf, s, p-s+1);
78 upw=(
char *)malloc(p-s+1);
99 if (!starts_with_drive_letter
100 && s && isalpha(s[0]) && s[1] ==
':' 101 && (s[2] ==
'/' || s[2] ==
'\\')) {
102 starts_with_drive_letter = 1;
112 while (!starts_with_drive_letter && *p && *p!=
':' && *p!=
'/' && *p!=
'?')
118 buf=(
char *)malloc(p-s+1);
120 memmove(buf, s, p-s+1);
131 while (*p && *p!=
'?' && *p!=
'/')
138 buf=(
char *)malloc(p-s+1);
140 memmove(buf, s, p-s+1);
142 if (sscanf(buf,
"%d", &port)!=1) {
155 if (strcasecmp(url->protocol,
"http")==0)
157 else if (strcasecmp(url->protocol,
"https")==0)
163 if (starts_with_drive_letter || *s==
'/') {
165 while (*p && *p!=
'?')
171 buf=(
char *)malloc(p-s+1);
173 memmove(buf, s, p-s+1);
188 while (*s && *s==
'?') {
196 while (*p && *p!=
'?' && *p!=
'=')
204 while (*p && *p!=
'?')
220 url->url=strdup(str);
230 if (!url->_modified && !(url->url==0 || url->url[0]==0)) {
246 snprintf(numbuf,
sizeof(numbuf),
"%d", url->port);
297 snprintf(numbuf,
sizeof(numbuf),
"%d", url->port);
326 while (*p && *p!=
'?')
332 buf=(
char *)malloc(p-s+1);
334 memmove(buf, s, p-s+1);
348 while (*s && *s==
'?') {
356 while (*p && *p!=
'?' && *p!=
'=')
364 while (*p && *p!=
'?')
380 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)