Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

cfcgi.c File Reference

the implementation of the Classic Forum CGI library More...

#include "config.h"
#include "defines.h"
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "hashlib.h"
#include "utils.h"
#include "cfcgi.h"

Go to the source code of this file.

Functions

int _cf_cgi_parse_params (t_cf_hash *hash, u_char *data)
int _cf_cgi_save_param (t_cf_hash *hash, u_char *name, int namlen, u_char *value)
 this function saves a parsed parameter to the CGI hash.

void cf_cgi_destroy_entry (void *data)
 this function destroys a parameter list.

t_cf_hashcf_cgi_new ()
void cf_cgi_parse_path_info (t_array *ary)
u_char * cf_cgi_url_decode (const u_char *str, size_t len)
u_char * cf_cgi_url_encode (const u_char *str, size_t len)
u_char * cf_cgi_get (t_cf_hash *hash, u_char *name)
void cf_cgi_set (t_cf_hash *hash, const u_char *name, const u_char *value)
t_cf_cgi_paramcf_cgi_get_multiple (t_cf_hash *hash, u_char *param)
void cf_cgi_destroy (t_cf_hash *hash)
u_int32_t path_info_parsed (u_char ***infos)


Detailed Description

the implementation of the Classic Forum CGI library

Author:
Christian Kruse, <cjk@wwwtech.de>
a small (really small!), but hopefully fast cgi-library. It can only parse x-www-form/url-encoded

Definition in file cfcgi.c.


Function Documentation

void cf_cgi_destroy t_cf_hash hash  ) 
 

This function destroys a CGI hash.

Parameters:
hash The CGI hash

Definition at line 397 of file cfcgi.c.

u_char* cf_cgi_get t_cf_hash cgi,
u_char *  name
 

This function gets a single CGI value and returns it as a C string.

Attention:
You may not free this returned value! This will be done when you call cf_cgi_destroy().

Definition at line 340 of file cfcgi.c.

t_cf_cgi_param* cf_cgi_get_multiple t_cf_hash hash,
u_char *  param
 

This function returns a double linked list of parameters with the name the parameter 'param' defines.

Parameters:
hash the CGI hash
param the parameter name
Attention:
You may not free() anything in this list! This is done by the cf_cgi_destroy_entry() function!
Returns:
The linked list if the entry could be found, NULL if the entry was not found.

Definition at line 386 of file cfcgi.c.

t_cf_hash* cf_cgi_new  ) 
 

this function is the constructor for the CGI hash. It reads the CGI data from the environment, parses it and decodes it.

Returns:
It returns NULL on error or the CGI hash on success.

Definition at line 73 of file cfcgi.c.

void cf_cgi_parse_path_info t_array ary  ) 
 

This function parses a query string

Parameters:
ary A pointer to a array structure

Definition at line 116 of file cfcgi.c.

void cf_cgi_set t_cf_hash hash,
const u_char *  name,
const u_char *  value
 

This function sets a CGI param value

Parameters:
hash The CGI object hash
name The parameter name
value The value of the parameter

Definition at line 350 of file cfcgi.c.

u_char* cf_cgi_url_decode const u_char *  str,
size_t  len
 

This function decodes an URL encoded string. This means, <2-digit-hexvalue> will be decoded to the corresponding character

Parameters:
str the URL encoded string as a C string
len the length of the string
Returns:
It returns NULL on failure (e.g. out of memory or something like that) and the decoded string on success.

Definition at line 153 of file cfcgi.c.

u_char* cf_cgi_url_encode const u_char *  str,
size_t  len
 

This function encodes a string to an URL encoded string. This means, all characters < 48, > 122 except '_', '.' and '-' will be encoded to '%<2 digit hexvalue of character>'. Space will be converted to '+'.

Parameters:
str the string as a C string
len the length of the string
Returns:
It returns NULL on failure (e.g. out of memory or something like that) and the decoded string on success.
Attention:
You have to free() the u_char array!

Definition at line 188 of file cfcgi.c.

u_int32_t path_info_parsed u_char ***  infos  ) 
 

This function parses a PATH_INFO string

Definition at line 404 of file cfcgi.c.


Generated on Sun Apr 25 16:37:39 2004 for Classic Forum by doxygen 1.3.5