From 473597657df72ce78026ab1fe487219fa349e8d2 Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Sat, 21 Jul 2007 17:30:36 +0200 Subject: [PATCH] Parse fragments in URLs. --- common/http.c | 12 +++++++++++- include/http.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/common/http.c b/common/http.c index 923e6d6..9c34a3b 100644 --- a/common/http.c +++ b/common/http.c @@ -38,6 +38,7 @@ void freeurl(struct hturlinfo *ui) free(ui->host); free(ui->path); free(ui->query); + free(ui->fragment); free(ui); } @@ -70,7 +71,15 @@ struct hturlinfo *parseurl(char *url) if(p2 == NULL) { ui->query = sstrdup(""); } else { - ui->query = sstrdup(p2); + p = p2; + if((p2 = strchr(p, '#')) != NULL) + *(p2++) = 0; + ui->query = sstrdup(p); + } + if(p2 == NULL) { + ui->fragment = sstrdup(""); + } else { + ui->fragment = sstrdup(p2); } return(ui); } @@ -84,6 +93,7 @@ static struct hturlinfo *dupurl(struct hturlinfo *ui) new->port = ui->port; new->path = sstrdup(ui->path); new->query = sstrdup(ui->query); + new->fragment = sstrdup(ui->fragment); return(new); } diff --git a/include/http.h b/include/http.h index e6d1020..8223be3 100644 --- a/include/http.h +++ b/include/http.h @@ -27,6 +27,7 @@ struct hturlinfo { int port; char *path; char *query; + char *fragment; }; struct htconn { -- 2.11.0