diff options
| author | Lars Hjemli | 2008-04-08 21:11:36 +0200 |
|---|---|---|
| committer | Lars Hjemli | 2008-04-08 21:11:36 +0200 |
| commit | e87e89633383b8b75c68c98be3e0c14212109de2 (patch) | |
| tree | f57e131ab854b58023387aee8efc0e4ee54653b5 /parsing.c | |
| parent | 20a33548b9a87a6eb23162ee5d137daa46d78613 (diff) | |
| download | cgit-e87e89633383b8b75c68c98be3e0c14212109de2.tar.gz cgit-e87e89633383b8b75c68c98be3e0c14212109de2.tar.bz2 cgit-e87e89633383b8b75c68c98be3e0c14212109de2.zip | |
Move cgit_parse_query() from parsing.c to html.c as http_parse_querystring()
This is a generic http-function.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'parsing.c')
| -rw-r--r-- | parsing.c | 49 |
1 files changed, 0 insertions, 49 deletions
| @@ -8,55 +8,6 @@ | |||
| 8 | 8 | ||
| 9 | #include "cgit.h" | 9 | #include "cgit.h" |
| 10 | 10 | ||
| 11 | char *convert_query_hexchar(char *txt) | ||
| 12 | { | ||
| 13 | int d1, d2; | ||
| 14 | if (strlen(txt) < 3) { | ||
| 15 | *txt = '\0'; | ||
| 16 | return txt-1; | ||
| 17 | } | ||
| 18 | d1 = hextoint(*(txt+1)); | ||
| 19 | d2 = hextoint(*(txt+2)); | ||
| 20 | if (d1<0 || d2<0) { | ||
| 21 | strcpy(txt, txt+3); | ||
| 22 | return txt-1; | ||
| 23 | } else { | ||
| 24 | *txt = d1 * 16 + d2; | ||
| 25 | strcpy(txt+1, txt+3); | ||
| 26 | return txt; | ||
| 27 | } | ||
| 28 | } | ||
| 29 | |||
| 30 | int cgit_parse_query(char *txt, configfn fn) | ||
| 31 | { | ||
| 32 | char *t, *value = NULL, c; | ||
| 33 | |||
| 34 | if (!txt) | ||
| 35 | return 0; | ||
| 36 | |||
| 37 | t = txt = xstrdup(txt); | ||
| 38 | |||
| 39 | while((c=*t) != '\0') { | ||
| 40 | if (c=='=') { | ||
| 41 | *t = '\0'; | ||
| 42 | value = t+1; | ||
| 43 | } else if (c=='+') { | ||
| 44 | *t = ' '; | ||
| 45 | } else if (c=='%') { | ||
| 46 | t = convert_query_hexchar(t); | ||
| 47 | } else if (c=='&') { | ||
| 48 | *t = '\0'; | ||
| 49 | (*fn)(txt, value); | ||
| 50 | txt = t+1; | ||
| 51 | value = NULL; | ||
| 52 | } | ||
| 53 | t++; | ||
| 54 | } | ||
| 55 | if (t!=txt) | ||
| 56 | (*fn)(txt, value); | ||
| 57 | return 0; | ||
| 58 | } | ||
| 59 | |||
| 60 | /* | 11 | /* |
| 61 | * url syntax: [repo ['/' cmd [ '/' path]]] | 12 | * url syntax: [repo ['/' cmd [ '/' path]]] |
| 62 | * repo: any valid repo url, may contain '/' | 13 | * repo: any valid repo url, may contain '/' |
