X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=common%2Fhttp.c;fp=common%2Fhttp.c;h=3342a603a318a06e2b33b42d086c887f9449eee5;hb=95c14b735e08d5350a43722b4b02889c4f0c6c2a;hp=0924367e20066ff91a2905cc957da5b5d6963813;hpb=672dbb8f2fe881723f08bba084acd54703411342;p=doldaconnect.git diff --git a/common/http.c b/common/http.c index 0924367..3342a60 100644 --- a/common/http.c +++ b/common/http.c @@ -20,9 +20,43 @@ #include #include #include +#include #include #ifdef HAVE_CONFIG_H #include #endif +#include +#include +struct hturlinfo *parseurl(char *url) +{ + char *p, *p2, *p3; + struct hturlinfo *ui; + + if(strncmp(url, "http://", 7)) + return(NULL); + ui = memset(smalloc(sizeof(*ui)), 0, sizeof(*ui)); + p = url + 7; + if((p2 = strchr(p, '/')) != NULL) + *(p2++) = 0; + if((p3 = strrchr(p, ':')) != NULL) { + *(p3++) = 0; + ui->port = atoi(p3); + } + ui->host = sstrdup(p); + if(p2 == NULL) { + ui->path = sstrdup("/"); + } else { + p = p2; + if((p2 = strchr(p, '?')) != NULL) + *(p2++) = 0; + ui->path = sstrdup(p); + } + if(p2 == NULL) { + ui->query = sstrdup(""); + } else { + ui->query = sstrdup(p2); + } + return(ui); +}