taskrambler
v0.1.8
Web server and task management solution.
Main Page
Related Pages
Data Structures
Files
File List
Globals
p_post_vars.c
Go to the documentation of this file.
1
/**
2
* \file
3
*
4
* \author Georg Hopp
5
*
6
* \copyright
7
* Copyright © 2012 Georg Hopp
8
*
9
* This program is free software: you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation, either version 3 of the License, or
12
* (at your option) any later version.
13
*
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
18
*
19
* You should have received a copy of the GNU General Public License
20
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21
*/
22
23
#include <string.h>
24
#include <sys/types.h>
25
26
#include "
http/parser.h
"
27
#include "
http/request.h
"
28
#include "hash.h"
29
#include "class.h"
30
31
#include "
utils/http.h
"
32
33
/**
34
* \todo this is very similar to other pair parsing
35
* things... key1=val1<delim>key2=val2<delim>...keyn=valn
36
* Generalize this!!!!
37
*/
38
void
39
httpParserPostVars
(HttpParser
this
)
40
{
41
HttpRequest request = (HttpRequest)this->current;
42
char
* pair = this->current->body;
43
ssize_t togo = this->current->nbody;
44
45
while
(NULL != pair && 0 < togo) {
46
char
* key = pair;
47
char
* eqsign = memchr(key,
'='
, togo);
48
char
* value;
49
size_t
nvalue;
50
51
if
(NULL == eqsign) {
52
return
;
53
}
54
55
togo -= (eqsign - key);
56
pair = memchr(eqsign,
'&'
, togo);
57
58
if
(NULL == pair) {
59
pair = &(this->current->body[this->current->nbody]);
60
}
61
62
nvalue = pair-eqsign-1;
63
value = (0 != nvalue)? eqsign+1 : NULL;
64
nvalue =
urldecode
(value, nvalue);
65
66
hashAdd
(request->post,
67
new
(HashValue, key, eqsign-key, value, nvalue));
68
69
pair++;
70
togo -= (pair - eqsign);
71
}
72
}
73
74
// vim: set ts=4 sw=4:
http.h
parser.h
urldecode
size_t urldecode(char *, size_t)
Definition:
utils/http.c:84
httpParserPostVars
void httpParserPostVars(HttpParser this)
Definition:
p_post_vars.c:39
hashAdd
void * hashAdd(Hash, void *)
Definition:
add.c:48
request.h
src
http
parser
p_post_vars.c
Generated on Wed Apr 13 2016 12:25:16 for taskrambler by
1.8.10