taskrambler  0.1.9
Web server and task management solution.
p_request_vars.c File Reference
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include "http/parser.h"
#include "http/request.h"
#include "hash.h"
#include "class.h"
#include "utils/memory.h"
+ Include dependency graph for p_request_vars.c:

Go to the source code of this file.

Functions

void httpParserRequestVars (HttpParser this)
 

Detailed Description

Author
Georg Hopp

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file p_request_vars.c.

Function Documentation

void httpParserRequestVars ( HttpParser  this)

Definition at line 35 of file p_request_vars.c.

References hashAdd(), and memMalloc().

Referenced by httpParserParse().

36 {
37  HttpRequest request = (HttpRequest)this->current;
38  char * delim = strchr(request->uri, '?');
39 
40  if (NULL == delim) {
41  delim = request->uri + strlen(request->uri);
42  }
43 
44  request->path = memMalloc(delim - request->uri + 1);
45  request->path[delim - request->uri] = 0;
46  memcpy(request->path, request->uri, delim - request->uri);
47 
48  while(NULL != delim && 0 != *delim) {
49  char * key = delim + 1;
50  char * eqsign = strchr(key, '=');
51  char * value;
52  size_t nvalue;
53 
54  if (NULL == eqsign) {
55  return;
56  }
57 
58  delim = strchr(eqsign, '&');
59 
60  if (NULL == delim) {
61  delim = key + strlen(key);
62  }
63 
64  nvalue = delim-eqsign-1;
65  value = (0 != nvalue)? eqsign+1 : NULL;
66 
67  hashAdd(request->get,
68  new(HashValue, key, eqsign-key, value, nvalue));
69  }
70 }
void * memMalloc(size_t)
Definition: memory.c:783
void * hashAdd(Hash, void *)
Definition: add.c:48

+ Here is the call graph for this function:

+ Here is the caller graph for this function: