1
0
Fork 0

Update: Added "igloo_" to all #defines and types

This commit is contained in:
Philipp Schafft 2018-10-12 11:27:17 +00:00
parent 5cc52a7b3d
commit 2f7226c8bd
15 changed files with 519 additions and 519 deletions

122
avl/avl.c
View File

@ -27,7 +27,7 @@
/*
* This is a fairly straightfoward translation of a prototype
* written in python, 'avl_tree.py'. Read that file first.
* written in python, 'igloo_avl_tree.py'. Read that file first.
*/
#ifdef HAVE_CONFIG_H
@ -39,11 +39,11 @@
#include "avl.h"
avl_node *
igloo_avl_node *
igloo_avl_node_new (void * key,
avl_node * parent)
igloo_avl_node * parent)
{
avl_node * node = (avl_node *) malloc (sizeof (avl_node));
igloo_avl_node * node = (igloo_avl_node *) malloc (sizeof (igloo_avl_node));
if (!node) {
return NULL;
@ -62,16 +62,16 @@ igloo_avl_node_new (void * key,
}
}
avl_tree *
igloo_avl_tree_new (avl_key_compare_fun_type compare_fun,
igloo_avl_tree *
igloo_avl_tree_new (igloo_avl_key_compare_fun_type compare_fun,
void * compare_arg)
{
avl_tree * t = (avl_tree *) malloc (sizeof (avl_tree));
igloo_avl_tree * t = (igloo_avl_tree *) malloc (sizeof (igloo_avl_tree));
if (!t) {
return NULL;
} else {
avl_node * root = igloo_avl_node_new((void *)NULL, (avl_node *) NULL);
igloo_avl_node * root = igloo_avl_node_new((void *)NULL, (igloo_avl_node *) NULL);
if (!root) {
free (t);
return NULL;
@ -88,7 +88,7 @@ igloo_avl_tree_new (avl_key_compare_fun_type compare_fun,
}
static void
igloo_avl_tree_free_helper (avl_node * node, avl_free_key_fun_type free_key_fun)
igloo_avl_tree_free_helper (igloo_avl_node * node, igloo_avl_free_key_fun_type free_key_fun)
{
if (node->left) {
igloo_avl_tree_free_helper (node->left, free_key_fun);
@ -105,7 +105,7 @@ igloo_avl_tree_free_helper (avl_node * node, avl_free_key_fun_type free_key_fun)
}
void
igloo_avl_tree_free (avl_tree * tree, avl_free_key_fun_type free_key_fun)
igloo_avl_tree_free (igloo_avl_tree * tree, igloo_avl_free_key_fun_type free_key_fun)
{
if (tree->length) {
igloo_avl_tree_free_helper (tree->root->right, free_key_fun);
@ -121,11 +121,11 @@ igloo_avl_tree_free (avl_tree * tree, avl_free_key_fun_type free_key_fun)
}
int
igloo_avl_insert (avl_tree * ob,
igloo_avl_insert (igloo_avl_tree * ob,
void * key)
{
if (!(ob->root->right)) {
avl_node * node = igloo_avl_node_new (key, ob->root);
igloo_avl_node * node = igloo_avl_node_new (key, ob->root);
if (!node) {
return -1;
} else {
@ -134,7 +134,7 @@ igloo_avl_insert (avl_tree * ob,
return 0;
}
} else { /* not self.right == None */
avl_node *t, *p, *s, *q, *r;
igloo_avl_node *t, *p, *s, *q, *r;
int a;
t = ob->root;
@ -147,7 +147,7 @@ igloo_avl_insert (avl_tree * ob,
q = p->left;
if (!q) {
/* insert */
avl_node * q_node = igloo_avl_node_new (key, p);
igloo_avl_node * q_node = igloo_avl_node_new (key, p);
if (!q_node) {
return (-1);
} else {
@ -165,7 +165,7 @@ igloo_avl_insert (avl_tree * ob,
q = p->right;
if (!q) {
/* insert */
avl_node * q_node = igloo_avl_node_new (key, p);
igloo_avl_node * q_node = igloo_avl_node_new (key, p);
if (!q_node) {
return -1;
} else {
@ -297,11 +297,11 @@ igloo_avl_insert (avl_tree * ob,
}
int
igloo_avl_get_by_index (avl_tree * tree,
igloo_avl_get_by_index (igloo_avl_tree * tree,
unsigned long index,
void ** value_address)
{
avl_node * p = tree->root->right;
igloo_avl_node * p = tree->root->right;
unsigned long m = index + 1;
while (1) {
if (!p) {
@ -320,11 +320,11 @@ igloo_avl_get_by_index (avl_tree * tree,
}
int
igloo_avl_get_by_key (avl_tree * tree,
igloo_avl_get_by_key (igloo_avl_tree * tree,
void * key,
void **value_address)
{
avl_node * x = tree->root->right;
igloo_avl_node * x = tree->root->right;
if (!x) {
return -1;
}
@ -349,9 +349,9 @@ igloo_avl_get_by_key (avl_tree * tree,
}
}
int igloo_avl_delete(avl_tree *tree, void *key, avl_free_key_fun_type free_key_fun)
int igloo_avl_delete(igloo_avl_tree *tree, void *key, igloo_avl_free_key_fun_type free_key_fun)
{
avl_node *x, *y, *p, *q, *r, *top, *x_child;
igloo_avl_node *x, *y, *p, *q, *r, *top, *x_child;
int shortened_side, shorter;
x = tree->root->right;
@ -625,8 +625,8 @@ int igloo_avl_delete(avl_tree *tree, void *key, avl_free_key_fun_type free_key_f
}
static int
igloo_avl_iterate_inorder_helper (avl_node * node,
avl_iter_fun_type iter_fun,
igloo_avl_iterate_inorder_helper (igloo_avl_node * node,
igloo_avl_iter_fun_type iter_fun,
void * iter_arg)
{
int result;
@ -650,8 +650,8 @@ igloo_avl_iterate_inorder_helper (avl_node * node,
}
int
igloo_avl_iterate_inorder (avl_tree * tree,
avl_iter_fun_type iter_fun,
igloo_avl_iterate_inorder (igloo_avl_tree * tree,
igloo_avl_iter_fun_type iter_fun,
void * iter_arg)
{
int result;
@ -664,9 +664,9 @@ igloo_avl_iterate_inorder (avl_tree * tree,
}
}
avl_node *igloo_avl_get_first(avl_tree *tree)
igloo_avl_node *igloo_avl_get_first(igloo_avl_tree *tree)
{
avl_node *node;
igloo_avl_node *node;
node = tree->root->right;
if (node == NULL || node->key == NULL) return NULL;
@ -677,7 +677,7 @@ avl_node *igloo_avl_get_first(avl_tree *tree)
return node;
}
avl_node *igloo_avl_get_prev(avl_node *node)
igloo_avl_node *igloo_avl_get_prev(igloo_avl_node *node)
{
if (node->left) {
node = node->left;
@ -687,7 +687,7 @@ avl_node *igloo_avl_get_prev(avl_node *node)
return node;
} else {
avl_node *child = node;
igloo_avl_node *child = node;
while (node->parent && node->parent->key) {
node = node->parent;
if (child == node->right) {
@ -700,7 +700,7 @@ avl_node *igloo_avl_get_prev(avl_node *node)
}
}
avl_node *igloo_avl_get_next(avl_node *node)
igloo_avl_node *igloo_avl_get_next(igloo_avl_node *node)
{
if (node->right) {
node = node->right;
@ -710,7 +710,7 @@ avl_node *igloo_avl_get_next(avl_node *node)
return node;
} else {
avl_node *child = node;
igloo_avl_node *child = node;
while (node->parent && node->parent->key) {
node = node->parent;
if (child == node->left) {
@ -726,15 +726,15 @@ avl_node *igloo_avl_get_next(avl_node *node)
/* iterate a function over a range of indices, using get_predecessor */
int
igloo_avl_iterate_index_range (avl_tree * tree,
avl_iter_index_fun_type iter_fun,
igloo_avl_iterate_index_range (igloo_avl_tree * tree,
igloo_avl_iter_index_fun_type iter_fun,
unsigned long low,
unsigned long high,
void * iter_arg)
{
unsigned long m;
unsigned long num_left;
avl_node * node;
igloo_avl_node * node;
if (high > tree->length) {
return -1;
@ -769,12 +769,12 @@ igloo_avl_iterate_index_range (avl_tree * tree,
* representing the closest preceding value.
*/
static avl_node *
igloo_avl_get_index_by_key (avl_tree * tree,
static igloo_avl_node *
igloo_avl_get_index_by_key (igloo_avl_tree * tree,
void * key,
unsigned long * index)
{
avl_node * x = tree->root->right;
igloo_avl_node * x = tree->root->right;
unsigned long m;
if (!x) {
@ -811,13 +811,13 @@ igloo_avl_get_index_by_key (avl_tree * tree,
/* return the (low index, high index) pair that spans the given key */
int
igloo_avl_get_span_by_key (avl_tree * tree,
igloo_avl_get_span_by_key (igloo_avl_tree * tree,
void * key,
unsigned long * low,
unsigned long * high)
{
unsigned long m, i, j;
avl_node * node;
igloo_avl_node * node;
node = igloo_avl_get_index_by_key (tree, key, &m);
@ -827,7 +827,7 @@ igloo_avl_get_span_by_key (avl_tree * tree,
* the arrangement of like keys.
*/
if (node) {
avl_node * left, * right;
igloo_avl_node * left, * right;
/* search left */
left = igloo_avl_get_prev (node);
i = m;
@ -854,14 +854,14 @@ igloo_avl_get_span_by_key (avl_tree * tree,
/* return the (low index, high index) pair that spans the given key */
int
igloo_avl_get_span_by_two_keys (avl_tree * tree,
igloo_avl_get_span_by_two_keys (igloo_avl_tree * tree,
void * low_key,
void * high_key,
unsigned long * low,
unsigned long * high)
{
unsigned long i, j;
avl_node * low_node, * high_node;
igloo_avl_node * low_node, * high_node;
int order;
/* we may need to swap them */
@ -876,7 +876,7 @@ igloo_avl_get_span_by_two_keys (avl_tree * tree,
high_node = igloo_avl_get_index_by_key (tree, high_key, &j);
if (low_node) {
avl_node * left;
igloo_avl_node * left;
/* search left */
left = igloo_avl_get_prev (low_node);
while (left && (i > 0) && (tree->compare_fun (tree->compare_arg, low_key, left->key) == 0)) {
@ -887,7 +887,7 @@ igloo_avl_get_span_by_two_keys (avl_tree * tree,
i = i + 1;
}
if (high_node) {
avl_node * right;
igloo_avl_node * right;
/* search right */
right = igloo_avl_get_next (high_node);
while (right && (j <= tree->length) && (tree->compare_fun (tree->compare_arg, high_key, right->key) == 0)) {
@ -905,11 +905,11 @@ igloo_avl_get_span_by_two_keys (avl_tree * tree,
int
igloo_avl_get_item_by_key_most (avl_tree * tree,
igloo_avl_get_item_by_key_most (igloo_avl_tree * tree,
void * key,
void **value_address)
{
avl_node * x = tree->root->right;
igloo_avl_node * x = tree->root->right;
*value_address = NULL;
if (!x) {
@ -949,11 +949,11 @@ igloo_avl_get_item_by_key_most (avl_tree * tree,
}
int
igloo_avl_get_item_by_key_least (avl_tree * tree,
igloo_avl_get_item_by_key_least (igloo_avl_tree * tree,
void * key,
void **value_address)
{
avl_node * x = tree->root->right;
igloo_avl_node * x = tree->root->right;
*value_address = NULL;
if (!x) {
@ -993,7 +993,7 @@ igloo_avl_get_item_by_key_least (avl_tree * tree,
#define AVL_MAX(X, Y) ((X) > (Y) ? (X) : (Y))
static long
igloo_avl_verify_balance (avl_node * node)
igloo_avl_verify_balance (igloo_avl_node * node)
{
if (!node) {
return 0;
@ -1011,7 +1011,7 @@ igloo_avl_verify_balance (avl_node * node)
}
static void
igloo_avl_verify_parent (avl_node * node, avl_node * parent)
igloo_avl_verify_parent (igloo_avl_node * node, igloo_avl_node * parent)
{
if (node->parent != parent) {
return;
@ -1025,7 +1025,7 @@ igloo_avl_verify_parent (avl_node * node, avl_node * parent)
}
static long
igloo_avl_verify_rank (avl_node * node)
igloo_avl_verify_rank (igloo_avl_node * node)
{
if (!node) {
return 0;
@ -1048,7 +1048,7 @@ igloo_avl_verify_rank (avl_node * node)
/* sanity-check the tree */
int
igloo_avl_verify (avl_tree * tree)
igloo_avl_verify (igloo_avl_tree * tree)
{
if (tree->length) {
igloo_avl_verify_balance (tree->root->right);
@ -1113,8 +1113,8 @@ igloo_print_connectors (link_node * link)
*/
static void
igloo_print_node (avl_key_printer_fun_type key_printer,
avl_node * node,
igloo_print_node (igloo_avl_key_printer_fun_type key_printer,
igloo_avl_node * node,
link_node * link)
{
char buffer[AVL_KEY_PRINTER_BUFLEN];
@ -1148,7 +1148,7 @@ igloo_print_node (avl_key_printer_fun_type key_printer,
}
void
igloo_avl_print_tree (avl_tree * tree, avl_key_printer_fun_type key_printer)
igloo_avl_print_tree (igloo_avl_tree * tree, igloo_avl_key_printer_fun_type key_printer)
{
link_node top = {NULL, 0, 0};
if (!key_printer) {
@ -1162,33 +1162,33 @@ igloo_avl_print_tree (avl_tree * tree, avl_key_printer_fun_type key_printer)
}
void igloo_avl_tree_rlock(avl_tree *tree)
void igloo_avl_tree_rlock(igloo_avl_tree *tree)
{
thread_rwlock_rlock(&tree->rwlock);
}
void igloo_avl_tree_wlock(avl_tree *tree)
void igloo_avl_tree_wlock(igloo_avl_tree *tree)
{
thread_rwlock_wlock(&tree->rwlock);
}
void igloo_avl_tree_unlock(avl_tree *tree)
void igloo_avl_tree_unlock(igloo_avl_tree *tree)
{
thread_rwlock_unlock(&tree->rwlock);
}
#ifdef HAVE_AVL_NODE_LOCK
void avl_node_rlock(avl_node *node)
void avl_node_rlock(igloo_avl_node *node)
{
thread_rwlock_rlock(&node->rwlock);
}
void avl_node_wlock(avl_node *node)
void avl_node_wlock(igloo_avl_node *node)
{
thread_rwlock_wlock(&node->rwlock);
}
void avl_node_unlock(avl_node *node)
void avl_node_unlock(igloo_avl_node *node)
{
thread_rwlock_unlock(&node->rwlock);
}

View File

@ -24,11 +24,11 @@ extern "C" {
#define thread_rwlock_unlock(x) do{}while(0)
#endif
typedef struct avl_node_tag {
typedef struct igloo_avl_node_tag {
void * key;
struct avl_node_tag * left;
struct avl_node_tag * right;
struct avl_node_tag * parent;
struct igloo_avl_node_tag * left;
struct igloo_avl_node_tag * right;
struct igloo_avl_node_tag * parent;
/*
* The lower 2 bits of <rank_and_balance> specify the balance
* factor: 00==-1, 01==0, 10==+1.
@ -36,9 +36,9 @@ typedef struct avl_node_tag {
*/
unsigned int rank_and_balance;
#if !defined(NO_THREAD) && defined(HAVE_AVL_NODE_LOCK)
rwlock_t rwlock;
igloo_rwlock_t rwlock;
#endif
} avl_node;
} igloo_avl_node;
#define AVL_GET_BALANCE(n) ((int)(((n)->rank_and_balance & 3) - 1))
@ -52,124 +52,124 @@ typedef struct avl_node_tag {
((n)->rank_and_balance) = \
(((n)->rank_and_balance & 3) | (r << 2))
struct _avl_tree;
struct igloo__avl_tree;
typedef int (*avl_key_compare_fun_type) (void * compare_arg, void * a, void * b);
typedef int (*avl_iter_fun_type) (void * key, void * iter_arg);
typedef int (*avl_iter_index_fun_type) (unsigned long index, void * key, void * iter_arg);
typedef int (*avl_free_key_fun_type) (void * key);
typedef int (*avl_key_printer_fun_type) (char *, void *);
typedef int (*igloo_avl_key_compare_fun_type) (void * compare_arg, void * a, void * b);
typedef int (*igloo_avl_iter_fun_type) (void * key, void * iter_arg);
typedef int (*igloo_avl_iter_index_fun_type) (unsigned long index, void * key, void * iter_arg);
typedef int (*igloo_avl_free_key_fun_type) (void * key);
typedef int (*igloo_avl_key_printer_fun_type) (char *, void *);
/*
* <compare_fun> and <compare_arg> let us associate a particular compare
* function with each tree, separately.
*/
typedef struct _avl_tree {
avl_node * root;
typedef struct igloo__avl_tree {
igloo_avl_node * root;
unsigned int height;
unsigned int length;
avl_key_compare_fun_type compare_fun;
igloo_avl_key_compare_fun_type compare_fun;
void * compare_arg;
#ifndef NO_THREAD
rwlock_t rwlock;
igloo_rwlock_t rwlock;
#endif
} avl_tree;
} igloo_avl_tree;
avl_tree * igloo_avl_tree_new (avl_key_compare_fun_type compare_fun, void * compare_arg);
avl_node * igloo_avl_node_new (void * key, avl_node * parent);
igloo_avl_tree * igloo_avl_tree_new (igloo_avl_key_compare_fun_type compare_fun, void * compare_arg);
igloo_avl_node * igloo_avl_node_new (void * key, igloo_avl_node * parent);
void igloo_avl_tree_free (
avl_tree * tree,
avl_free_key_fun_type free_key_fun
igloo_avl_tree * tree,
igloo_avl_free_key_fun_type free_key_fun
);
int igloo_avl_insert (
avl_tree * ob,
igloo_avl_tree * ob,
void * key
);
int igloo_avl_delete (
avl_tree * tree,
igloo_avl_tree * tree,
void * key,
avl_free_key_fun_type free_key_fun
igloo_avl_free_key_fun_type free_key_fun
);
int igloo_avl_get_by_index (
avl_tree * tree,
igloo_avl_tree * tree,
unsigned long index,
void ** value_address
);
int igloo_avl_get_by_key (
avl_tree * tree,
igloo_avl_tree * tree,
void * key,
void ** value_address
);
int igloo_avl_iterate_inorder (
avl_tree * tree,
avl_iter_fun_type iter_fun,
igloo_avl_tree * tree,
igloo_avl_iter_fun_type iter_fun,
void * iter_arg
);
int igloo_avl_iterate_index_range (
avl_tree * tree,
avl_iter_index_fun_type iter_fun,
igloo_avl_tree * tree,
igloo_avl_iter_index_fun_type iter_fun,
unsigned long low,
unsigned long high,
void * iter_arg
);
int igloo_avl_get_span_by_key (
avl_tree * tree,
igloo_avl_tree * tree,
void * key,
unsigned long * low,
unsigned long * high
);
int igloo_avl_get_span_by_two_keys (
avl_tree * tree,
igloo_avl_tree * tree,
void * key_a,
void * key_b,
unsigned long * low,
unsigned long * high
);
int igloo_avl_verify (avl_tree * tree);
int igloo_avl_verify (igloo_avl_tree * tree);
void igloo_avl_print_tree (
avl_tree * tree,
avl_key_printer_fun_type key_printer
igloo_avl_tree * tree,
igloo_avl_key_printer_fun_type key_printer
);
avl_node *igloo_avl_get_first(avl_tree *tree);
igloo_avl_node *igloo_avl_get_first(igloo_avl_tree *tree);
avl_node *igloo_avl_get_prev(avl_node * node);
igloo_avl_node *igloo_avl_get_prev(igloo_avl_node * node);
avl_node *igloo_avl_get_next(avl_node * node);
igloo_avl_node *igloo_avl_get_next(igloo_avl_node * node);
/* These two are from David Ascher <david_ascher@brown.edu> */
int igloo_avl_get_item_by_key_most (
avl_tree * tree,
igloo_avl_tree * tree,
void * key,
void ** value_address
);
int igloo_avl_get_item_by_key_least (
avl_tree * tree,
igloo_avl_tree * tree,
void * key,
void ** value_address
);
/* optional locking stuff */
void igloo_avl_tree_rlock(avl_tree *tree);
void igloo_avl_tree_wlock(avl_tree *tree);
void igloo_avl_tree_unlock(avl_tree *tree);
void avl_node_rlock(avl_node *node);
void avl_node_wlock(avl_node *node);
void avl_node_unlock(avl_node *node);
void igloo_avl_tree_rlock(igloo_avl_tree *tree);
void igloo_avl_tree_wlock(igloo_avl_tree *tree);
void igloo_avl_tree_unlock(igloo_avl_tree *tree);
void avl_node_rlock(igloo_avl_node *node);
void avl_node_wlock(igloo_avl_node *node);
void avl_node_unlock(igloo_avl_node *node);
#ifdef __cplusplus
}

View File

@ -12,8 +12,8 @@ int _printer(char *buff, void *key);
int main(int argc, char **argv)
{
int i, max_nodes;
avl_tree *tree;
avl_node *node;
igloo_avl_tree *tree;
igloo_avl_node *node;
max_nodes = 25;

View File

@ -34,11 +34,11 @@
#include "encoding.h"
struct httpp_encoding_tag {
struct igloo_httpp_encoding_tag {
size_t refc;
ssize_t (*process_read)(httpp_encoding_t *self, void *buf, size_t len, ssize_t (*cb)(void*, void*, size_t), void *userdata);
ssize_t (*process_write)(httpp_encoding_t *self, const void *buf, size_t len, ssize_t (*cb)(void*, const void*, size_t), void *userdata);
ssize_t (*process_read)(igloo_httpp_encoding_t *self, void *buf, size_t len, ssize_t (*cb)(void*, void*, size_t), void *userdata);
ssize_t (*process_write)(igloo_httpp_encoding_t *self, const void *buf, size_t len, ssize_t (*cb)(void*, const void*, size_t), void *userdata);
httpp_meta_t *meta_read;
httpp_meta_t *meta_write;
@ -62,10 +62,10 @@ struct httpp_encoding_tag {
/* Handlers, at end of file */
static ssize_t igloo___enc_identity_read(httpp_encoding_t *self, void *buf, size_t len, ssize_t (*cb)(void*, void*, size_t), void *userdata);
static ssize_t igloo___enc_identity_write(httpp_encoding_t *self, const void *buf, size_t len, ssize_t (*cb)(void*, const void*, size_t), void *userdata);
static ssize_t igloo___enc_chunked_read(httpp_encoding_t *self, void *buf, size_t len, ssize_t (*cb)(void*, void*, size_t), void *userdata);
static ssize_t igloo___enc_chunked_write(httpp_encoding_t *self, const void *buf, size_t len, ssize_t (*cb)(void*, const void*, size_t), void *userdata);
static ssize_t igloo___enc_identity_read(igloo_httpp_encoding_t *self, void *buf, size_t len, ssize_t (*cb)(void*, void*, size_t), void *userdata);
static ssize_t igloo___enc_identity_write(igloo_httpp_encoding_t *self, const void *buf, size_t len, ssize_t (*cb)(void*, const void*, size_t), void *userdata);
static ssize_t igloo___enc_chunked_read(igloo_httpp_encoding_t *self, void *buf, size_t len, ssize_t (*cb)(void*, void*, size_t), void *userdata);
static ssize_t igloo___enc_chunked_write(igloo_httpp_encoding_t *self, const void *buf, size_t len, ssize_t (*cb)(void*, const void*, size_t), void *userdata);
/* function to move some data out of our buffers */
ssize_t igloo___copy_buffer(void *dst, void **src, size_t *boffset, size_t *blen, size_t len)
@ -100,7 +100,7 @@ ssize_t igloo___copy_buffer(void *dst, void **src, size_t *boffset, size_t *blen
}
/* try to flush output buffers */
static inline void __flush_output(httpp_encoding_t *self, ssize_t (*cb)(void*, const void*, size_t), void *userdata)
static inline void __flush_output(igloo_httpp_encoding_t *self, ssize_t (*cb)(void*, const void*, size_t), void *userdata)
{
if (cb && self->buf_write_encoded) {
ssize_t ret = cb(userdata,
@ -177,18 +177,18 @@ int igloo_httpp_encoding_meta_append(httpp_meta_t **dst, httpp_met
}
/* General setup */
httpp_encoding_t *igloo_httpp_encoding_new(const char *encoding) {
httpp_encoding_t *ret = calloc(1, sizeof(httpp_encoding_t));
igloo_httpp_encoding_t *igloo_httpp_encoding_new(const char *encoding) {
igloo_httpp_encoding_t *ret = calloc(1, sizeof(igloo_httpp_encoding_t));
if (!ret)
return NULL;
ret->refc = 1;
ret->bytes_till_eof = -1;
if (strcasecmp(encoding, HTTPP_ENCODING_IDENTITY) == 0) {
if (strcasecmp(encoding, igloo_HTTPP_ENCODING_IDENTITY) == 0) {
ret->process_read = igloo___enc_identity_read;
ret->process_write = igloo___enc_identity_write;
} else if (strcasecmp(encoding, HTTPP_ENCODING_CHUNKED) == 0) {
} else if (strcasecmp(encoding, igloo_HTTPP_ENCODING_CHUNKED) == 0) {
ret->process_read = igloo___enc_chunked_read;
ret->process_write = igloo___enc_chunked_write;
} else {
@ -202,7 +202,7 @@ fail:
return NULL;
}
int igloo_httpp_encoding_addref(httpp_encoding_t *self)
int igloo_httpp_encoding_addref(igloo_httpp_encoding_t *self)
{
if (!self)
return -1;
@ -210,7 +210,7 @@ int igloo_httpp_encoding_addref(httpp_encoding_t *self)
return 0;
}
int igloo_httpp_encoding_release(httpp_encoding_t *self)
int igloo_httpp_encoding_release(igloo_httpp_encoding_t *self)
{
if (!self)
return -1;
@ -237,7 +237,7 @@ int igloo_httpp_encoding_release(httpp_encoding_t *self)
/* Read data from backend.
* if cb is NULL this will read from the internal buffer.
*/
ssize_t igloo_httpp_encoding_read(httpp_encoding_t *self, void *buf, size_t len, ssize_t (*cb)(void*, void*, size_t), void *userdata)
ssize_t igloo_httpp_encoding_read(igloo_httpp_encoding_t *self, void *buf, size_t len, ssize_t (*cb)(void*, void*, size_t), void *userdata)
{
ssize_t done = 0;
ssize_t ret;
@ -281,7 +281,7 @@ ssize_t igloo_httpp_encoding_read(httpp_encoding_t *self, void *buf, s
return done;
}
int igloo_httpp_encoding_eof(httpp_encoding_t *self, int (*cb)(void*), void *userdata)
int igloo_httpp_encoding_eof(igloo_httpp_encoding_t *self, int (*cb)(void*), void *userdata)
{
if (!self)
return -1;
@ -302,7 +302,7 @@ int igloo_httpp_encoding_eof(httpp_encoding_t *self, int (*cb)(voi
* After a call to this function the meta data is released from the
* encoding object and the caller is responsible to free it.
*/
httpp_meta_t *igloo_httpp_encoding_get_meta(httpp_encoding_t *self)
httpp_meta_t *igloo_httpp_encoding_get_meta(igloo_httpp_encoding_t *self)
{
httpp_meta_t *ret;
@ -319,7 +319,7 @@ httpp_meta_t *igloo_httpp_encoding_get_meta(httpp_encoding_t *self)
* Depending on encoding flushing buffers may not be safe if not
* at end of stream.
*/
ssize_t igloo_httpp_encoding_write(httpp_encoding_t *self, const void *buf, size_t len, ssize_t (*cb)(void*, const void*, size_t), void *userdata)
ssize_t igloo_httpp_encoding_write(igloo_httpp_encoding_t *self, const void *buf, size_t len, ssize_t (*cb)(void*, const void*, size_t), void *userdata)
{
ssize_t ret;
@ -339,7 +339,7 @@ ssize_t igloo_httpp_encoding_write(httpp_encoding_t *self, const void
}
/* Check if we have something to flush. */
ssize_t igloo_httpp_encoding_pending(httpp_encoding_t *self)
ssize_t igloo_httpp_encoding_pending(igloo_httpp_encoding_t *self)
{
if (!self)
return -1;
@ -351,7 +351,7 @@ ssize_t igloo_httpp_encoding_pending(httpp_encoding_t *self)
/* Attach meta data to the stream.
* this is to be written out as soon as the encoding supports.
*/
int igloo_httpp_encoding_append_meta(httpp_encoding_t *self, httpp_meta_t *meta)
int igloo_httpp_encoding_append_meta(igloo_httpp_encoding_t *self, httpp_meta_t *meta)
{
if (!self)
return -1;
@ -359,7 +359,7 @@ int igloo_httpp_encoding_append_meta(httpp_encoding_t *self, httpp
}
/* handlers for encodings */
static ssize_t igloo___enc_identity_read(httpp_encoding_t *self, void *buf, size_t len, ssize_t (*cb)(void*, void*, size_t), void *userdata)
static ssize_t igloo___enc_identity_read(igloo_httpp_encoding_t *self, void *buf, size_t len, ssize_t (*cb)(void*, void*, size_t), void *userdata)
{
(void)self;
if (!cb)
@ -367,7 +367,7 @@ static ssize_t igloo___enc_identity_read(httpp_encoding_t *self, void *buf, size
return cb(userdata, buf, len);
}
static ssize_t igloo___enc_identity_write(httpp_encoding_t *self, const void *buf, size_t len, ssize_t (*cb)(void*, const void*, size_t), void *userdata)
static ssize_t igloo___enc_identity_write(igloo_httpp_encoding_t *self, const void *buf, size_t len, ssize_t (*cb)(void*, const void*, size_t), void *userdata)
{
(void)self;
if (!cb)
@ -388,7 +388,7 @@ static ssize_t igloo___enc_identity_write(httpp_encoding_t *self, const void *bu
*
*/
static void __enc_chunked_read_extentions(httpp_encoding_t *self, char *p, size_t len)
static void __enc_chunked_read_extentions(igloo_httpp_encoding_t *self, char *p, size_t len)
{
/* ok. If you want to ruin your day... go ahead and try to understand this. */
httpp_meta_t **parent;
@ -482,7 +482,7 @@ static void __enc_chunked_read_extentions(httpp_encoding_t *self, char *p, size_
}
}
static ssize_t igloo___enc_chunked_read(httpp_encoding_t *self, void *buf, size_t len, ssize_t (*cb)(void*, void*, size_t), void *userdata)
static ssize_t igloo___enc_chunked_read(igloo_httpp_encoding_t *self, void *buf, size_t len, ssize_t (*cb)(void*, void*, size_t), void *userdata)
{
ssize_t ret;
size_t buflen;
@ -718,7 +718,7 @@ static size_t __enc_chunked_write_extensions_valuelen(httpp_meta_t *cur)
return ret;
}
static char *__enc_chunked_write_extensions(httpp_encoding_t *self)
static char *__enc_chunked_write_extensions(igloo_httpp_encoding_t *self)
{
size_t buflen;
void *buf;
@ -785,7 +785,7 @@ static char *__enc_chunked_write_extensions(httpp_encoding_t *self)
return buf;
}
static ssize_t igloo___enc_chunked_write(httpp_encoding_t *self, const void *buf, size_t len, ssize_t (*cb)(void*, const void*, size_t), void *userdata)
static ssize_t igloo___enc_chunked_write(igloo_httpp_encoding_t *self, const void *buf, size_t len, ssize_t (*cb)(void*, const void*, size_t), void *userdata)
{
char encoded_length[32];
char *extensions = NULL;

View File

@ -28,13 +28,13 @@
#include <sys/types.h>
/* known encodings */
#define HTTPP_ENCODING_IDENTITY "identity" /* RFC2616 */
#define HTTPP_ENCODING_CHUNKED "chunked" /* RFC2616 */
#define HTTPP_ENCODING_GZIP "gzip" /* RFC1952 */
#define HTTPP_ENCODING_COMPRESS "compress" /* ??? */
#define HTTPP_ENCODING_DEFLATE "deflate" /* RFC1950, RFC1951 */
#define igloo_HTTPP_ENCODING_IDENTITY "identity" /* RFC2616 */
#define igloo_HTTPP_ENCODING_CHUNKED "chunked" /* RFC2616 */
#define igloo_HTTPP_ENCODING_GZIP "gzip" /* RFC1952 */
#define igloo_HTTPP_ENCODING_COMPRESS "compress" /* ??? */
#define igloo_HTTPP_ENCODING_DEFLATE "deflate" /* RFC1950, RFC1951 */
typedef struct httpp_encoding_tag httpp_encoding_t;
typedef struct igloo_httpp_encoding_tag igloo_httpp_encoding_t;
typedef struct httpp_meta_tag httpp_meta_t;
struct httpp_meta_tag {
@ -51,39 +51,39 @@ int igloo_httpp_encoding_meta_free(httpp_meta_t *self);
int igloo_httpp_encoding_meta_append(httpp_meta_t **dst, httpp_meta_t *next);
/* General setup */
httpp_encoding_t *igloo_httpp_encoding_new(const char *encoding);
int igloo_httpp_encoding_addref(httpp_encoding_t *self);
int igloo_httpp_encoding_release(httpp_encoding_t *self);
igloo_httpp_encoding_t *igloo_httpp_encoding_new(const char *encoding);
int igloo_httpp_encoding_addref(igloo_httpp_encoding_t *self);
int igloo_httpp_encoding_release(igloo_httpp_encoding_t *self);
/* Read data from backend.
* if cb is NULL this will read from the internal buffer.
*/
ssize_t igloo_httpp_encoding_read(httpp_encoding_t *self, void *buf, size_t len, ssize_t (*cb)(void*, void*, size_t), void *userdata);
ssize_t igloo_httpp_encoding_read(igloo_httpp_encoding_t *self, void *buf, size_t len, ssize_t (*cb)(void*, void*, size_t), void *userdata);
/* Check if EOF is reached.
* If cb is not NULL this also considers backend state.
*/
int igloo_httpp_encoding_eof(httpp_encoding_t *self, int (*cb)(void*), void *userdata);
int igloo_httpp_encoding_eof(igloo_httpp_encoding_t *self, int (*cb)(void*), void *userdata);
/* Read any meta data that is in buffer.
* After a call to this function the meta data is released from the
* encoding object and the caller is responsible to free it.
*/
httpp_meta_t *igloo_httpp_encoding_get_meta(httpp_encoding_t *self);
httpp_meta_t *igloo_httpp_encoding_get_meta(igloo_httpp_encoding_t *self);
/* Write data to backend.
* If buf is NULL this will flush buffers.
* Depending on encoding flushing buffers may not be safe if not
* at end of stream.
*/
ssize_t igloo_httpp_encoding_write(httpp_encoding_t *self, const void *buf, size_t len, ssize_t (*cb)(void*, const void*, size_t), void *userdata);
ssize_t igloo_httpp_encoding_write(igloo_httpp_encoding_t *self, const void *buf, size_t len, ssize_t (*cb)(void*, const void*, size_t), void *userdata);
/* Check if we have something to flush. */
ssize_t igloo_httpp_encoding_pending(httpp_encoding_t *self);
ssize_t igloo_httpp_encoding_pending(igloo_httpp_encoding_t *self);
/* Attach meta data to the stream.
* this is to be written out as soon as the encoding supports.
*/
int igloo_httpp_encoding_append_meta(httpp_encoding_t *self, httpp_meta_t *meta);
int igloo_httpp_encoding_append_meta(igloo_httpp_encoding_t *self, httpp_meta_t *meta);
#endif

View File

@ -53,72 +53,72 @@ static int igloo__compare_vars(void *compare_arg, void *a, void *b);
static int igloo__free_vars(void *key);
/* For avl tree manipulation */
static void parse_query(avl_tree *tree, const char *query, size_t len);
static const char *_httpp_get_param(avl_tree *tree, const char *name);
static void _httpp_set_param_nocopy(avl_tree *tree, char *name, char *value, int replace);
static void _httpp_set_param(avl_tree *tree, const char *name, const char *value);
static http_var_t *igloo__httpp_get_param_var(avl_tree *tree, const char *name);
static void parse_query(igloo_avl_tree *tree, const char *query, size_t len);
static const char *_httpp_get_param(igloo_avl_tree *tree, const char *name);
static void _httpp_set_param_nocopy(igloo_avl_tree *tree, char *name, char *value, int replace);
static void _httpp_set_param(igloo_avl_tree *tree, const char *name, const char *value);
static igloo_http_var_t *igloo__httpp_get_param_var(igloo_avl_tree *tree, const char *name);
httpp_request_info_t igloo_httpp_request_info(httpp_request_type_e req)
igloo_httpp_request_info_t igloo_httpp_request_info(igloo_httpp_request_type_e req)
{
#if 0
#define HTTPP_REQUEST_IS_SAFE ((httpp_request_info_t)0x0001U)
#define HTTPP_REQUEST_IS_IDEMPOTENT ((httpp_request_info_t)0x0002U)
#define HTTPP_REQUEST_IS_CACHEABLE ((httpp_request_info_t)0x0004U)
#define HTTPP_REQUEST_HAS_RESPONSE_BODY ((httpp_request_info_t)0x0010U)
#define HTTPP_REQUEST_HAS_REQUEST_BODY ((httpp_request_info_t)0x0100U)
#define HTTPP_REQUEST_HAS_OPTIONAL_REQUEST_BODY ((httpp_request_info_t)0x0200U)
#define igloo_HTTPP_REQUEST_IS_SAFE ((igloo_httpp_request_info_t)0x0001U)
#define igloo_HTTPP_REQUEST_IS_IDEMPOTENT ((igloo_httpp_request_info_t)0x0002U)
#define igloo_HTTPP_REQUEST_IS_CACHEABLE ((igloo_httpp_request_info_t)0x0004U)
#define igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY ((igloo_httpp_request_info_t)0x0010U)
#define igloo_HTTPP_REQUEST_HAS_REQUEST_BODY ((igloo_httpp_request_info_t)0x0100U)
#define igloo_HTTPP_REQUEST_HAS_OPTIONAL_REQUEST_BODY ((igloo_httpp_request_info_t)0x0200U)
#endif
switch (req) {
/* offical methods */
case httpp_req_get:
return HTTPP_REQUEST_IS_SAFE|HTTPP_REQUEST_IS_IDEMPOTENT|HTTPP_REQUEST_IS_CACHEABLE|HTTPP_REQUEST_HAS_RESPONSE_BODY|HTTPP_REQUEST_HAS_OPTIONAL_REQUEST_BODY;
return igloo_HTTPP_REQUEST_IS_SAFE|igloo_HTTPP_REQUEST_IS_IDEMPOTENT|igloo_HTTPP_REQUEST_IS_CACHEABLE|igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_OPTIONAL_REQUEST_BODY;
break;
case httpp_req_post:
return HTTPP_REQUEST_IS_CACHEABLE|HTTPP_REQUEST_HAS_RESPONSE_BODY|HTTPP_REQUEST_HAS_REQUEST_BODY;
return igloo_HTTPP_REQUEST_IS_CACHEABLE|igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_REQUEST_BODY;
break;
case httpp_req_put:
return HTTPP_REQUEST_IS_IDEMPOTENT|HTTPP_REQUEST_HAS_RESPONSE_BODY|HTTPP_REQUEST_HAS_REQUEST_BODY;
return igloo_HTTPP_REQUEST_IS_IDEMPOTENT|igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_REQUEST_BODY;
break;
case httpp_req_head:
return HTTPP_REQUEST_IS_SAFE|HTTPP_REQUEST_IS_IDEMPOTENT|HTTPP_REQUEST_IS_CACHEABLE;
return igloo_HTTPP_REQUEST_IS_SAFE|igloo_HTTPP_REQUEST_IS_IDEMPOTENT|igloo_HTTPP_REQUEST_IS_CACHEABLE;
break;
case httpp_req_options:
return HTTPP_REQUEST_IS_SAFE|HTTPP_REQUEST_IS_IDEMPOTENT|HTTPP_REQUEST_HAS_RESPONSE_BODY|HTTPP_REQUEST_HAS_OPTIONAL_REQUEST_BODY;
return igloo_HTTPP_REQUEST_IS_SAFE|igloo_HTTPP_REQUEST_IS_IDEMPOTENT|igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_OPTIONAL_REQUEST_BODY;
break;
case httpp_req_delete:
return HTTPP_REQUEST_IS_IDEMPOTENT|HTTPP_REQUEST_HAS_RESPONSE_BODY;
return igloo_HTTPP_REQUEST_IS_IDEMPOTENT|igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY;
break;
case httpp_req_trace:
return HTTPP_REQUEST_IS_SAFE|HTTPP_REQUEST_IS_IDEMPOTENT|HTTPP_REQUEST_HAS_RESPONSE_BODY;
return igloo_HTTPP_REQUEST_IS_SAFE|igloo_HTTPP_REQUEST_IS_IDEMPOTENT|igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY;
break;
case httpp_req_connect:
return HTTPP_REQUEST_HAS_RESPONSE_BODY|HTTPP_REQUEST_HAS_REQUEST_BODY;
return igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_REQUEST_BODY;
break;
/* Icecast specific methods */
case httpp_req_source:
return HTTPP_REQUEST_HAS_RESPONSE_BODY|HTTPP_REQUEST_HAS_REQUEST_BODY;
return igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_REQUEST_BODY;
break;
case httpp_req_play:
return HTTPP_REQUEST_IS_SAFE|HTTPP_REQUEST_HAS_RESPONSE_BODY|HTTPP_REQUEST_HAS_OPTIONAL_REQUEST_BODY;
return igloo_HTTPP_REQUEST_IS_SAFE|igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_OPTIONAL_REQUEST_BODY;
break;
case httpp_req_stats:
return HTTPP_REQUEST_IS_SAFE|HTTPP_REQUEST_HAS_RESPONSE_BODY|HTTPP_REQUEST_HAS_OPTIONAL_REQUEST_BODY;
return igloo_HTTPP_REQUEST_IS_SAFE|igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_OPTIONAL_REQUEST_BODY;
break;
/* Virtual and other methods */
case httpp_req_none:
case httpp_req_unknown:
default:
return HTTPP_REQUEST_HAS_RESPONSE_BODY|HTTPP_REQUEST_HAS_OPTIONAL_REQUEST_BODY;
return igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_OPTIONAL_REQUEST_BODY;
break;
}
}
http_parser_t *igloo_httpp_create_parser(void)
igloo_http_parser_t *igloo_httpp_create_parser(void)
{
http_parser_t *parser = calloc(1, sizeof(http_parser_t));
igloo_http_parser_t *parser = calloc(1, sizeof(igloo_http_parser_t));
parser->refc = 1;
parser->req_type = httpp_req_none;
@ -130,9 +130,9 @@ http_parser_t *igloo_httpp_create_parser(void)
return parser;
}
void igloo_httpp_initialize(http_parser_t *parser, http_varlist_t *defaults)
void igloo_httpp_initialize(igloo_http_parser_t *parser, igloo_http_varlist_t *defaults)
{
http_varlist_t *list;
igloo_http_varlist_t *list;
/* now insert the default variables */
list = defaults;
@ -177,7 +177,7 @@ static int igloo_split_headers(char *data, unsigned long len, char **line)
return lines;
}
static void igloo_parse_headers(http_parser_t *parser, char **line, int lines)
static void igloo_parse_headers(igloo_http_parser_t *parser, char **line, int lines)
{
int i, l;
int whitespace, slen;
@ -216,7 +216,7 @@ static void igloo_parse_headers(http_parser_t *parser, char **line, int lines)
}
}
int igloo_httpp_parse_response(http_parser_t *parser, const char *http_data, unsigned long len, const char *uri)
int igloo_httpp_parse_response(igloo_http_parser_t *parser, const char *http_data, unsigned long len, const char *uri)
{
char *data;
char *line[MAX_HEADERS];
@ -260,14 +260,14 @@ int igloo_httpp_parse_response(http_parser_t *parser, const char *http_data, uns
return 0;
}
igloo_httpp_setvar(parser, HTTPP_VAR_ERROR_CODE, resp_code);
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_ERROR_CODE, resp_code);
code = atoi(resp_code);
if(code < 200 || code >= 300) {
igloo_httpp_setvar(parser, HTTPP_VAR_ERROR_MESSAGE, message);
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_ERROR_MESSAGE, message);
}
igloo_httpp_setvar(parser, HTTPP_VAR_URI, uri);
igloo_httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "NONE");
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_URI, uri);
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "NONE");
igloo_parse_headers(parser, line, lines);
@ -276,7 +276,7 @@ int igloo_httpp_parse_response(http_parser_t *parser, const char *http_data, uns
return 1;
}
int igloo_httpp_parse_postdata(http_parser_t *parser, const char *body_data, size_t len)
int igloo_httpp_parse_postdata(igloo_http_parser_t *parser, const char *body_data, size_t len)
{
const char *header = igloo_httpp_getvar(parser, "content-type");
@ -350,7 +350,7 @@ static char *igloo_url_unescape(const char *src, size_t len)
return (char *)decoded;
}
static void parse_query_element(avl_tree *tree, const char *start, const char *mid, const char *end)
static void parse_query_element(igloo_avl_tree *tree, const char *start, const char *mid, const char *end)
{
size_t keylen;
char *key;
@ -379,7 +379,7 @@ static void parse_query_element(avl_tree *tree, const char *start, const char *m
_httpp_set_param_nocopy(tree, key, value, 0);
}
static void parse_query(avl_tree *tree, const char *query, size_t len)
static void parse_query(igloo_avl_tree *tree, const char *query, size_t len)
{
const char *start = query;
const char *mid = NULL;
@ -404,7 +404,7 @@ static void parse_query(avl_tree *tree, const char *query, size_t len)
parse_query_element(tree, start, mid, &(query[i]));
}
int igloo_httpp_parse(http_parser_t *parser, const char *http_data, unsigned long len)
int igloo_httpp_parse(igloo_http_parser_t *parser, const char *http_data, unsigned long len)
{
char *data, *tmp;
char *line[MAX_HEADERS]; /* limited to 32 lines, should be more than enough */
@ -467,8 +467,8 @@ int igloo_httpp_parse(http_parser_t *parser, const char *http_data, unsigned lon
if (uri != NULL && strlen(uri) > 0) {
char *query;
if((query = strchr(uri, '?')) != NULL) {
igloo_httpp_setvar(parser, HTTPP_VAR_RAWURI, uri);
igloo_httpp_setvar(parser, HTTPP_VAR_QUERYARGS, query);
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_RAWURI, uri);
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_QUERYARGS, query);
*query = 0;
query++;
parse_query(parser->queryvars, query, strlen(query));
@ -483,8 +483,8 @@ int igloo_httpp_parse(http_parser_t *parser, const char *http_data, unsigned lon
if ((version != NULL) && ((tmp = strchr(version, '/')) != NULL)) {
tmp[0] = '\0';
if ((strlen(version) > 0) && (strlen(&tmp[1]) > 0)) {
igloo_httpp_setvar(parser, HTTPP_VAR_PROTOCOL, version);
igloo_httpp_setvar(parser, HTTPP_VAR_VERSION, &tmp[1]);
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_PROTOCOL, version);
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_VERSION, &tmp[1]);
} else {
free(data);
return 0;
@ -497,37 +497,37 @@ int igloo_httpp_parse(http_parser_t *parser, const char *http_data, unsigned lon
if (parser->req_type != httpp_req_none && parser->req_type != httpp_req_unknown) {
switch (parser->req_type) {
case httpp_req_get:
igloo_httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "GET");
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "GET");
break;
case httpp_req_post:
igloo_httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "POST");
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "POST");
break;
case httpp_req_put:
igloo_httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "PUT");
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "PUT");
break;
case httpp_req_head:
igloo_httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "HEAD");
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "HEAD");
break;
case httpp_req_options:
igloo_httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "OPTIONS");
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "OPTIONS");
break;
case httpp_req_delete:
igloo_httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "DELETE");
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "DELETE");
break;
case httpp_req_trace:
igloo_httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "TRACE");
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "TRACE");
break;
case httpp_req_connect:
igloo_httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "CONNECT");
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "CONNECT");
break;
case httpp_req_source:
igloo_httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "SOURCE");
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "SOURCE");
break;
case httpp_req_play:
igloo_httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "PLAY");
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "PLAY");
break;
case httpp_req_stats:
igloo_httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "STATS");
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "STATS");
break;
default:
break;
@ -538,7 +538,7 @@ int igloo_httpp_parse(http_parser_t *parser, const char *http_data, unsigned lon
}
if (parser->uri != NULL) {
igloo_httpp_setvar(parser, HTTPP_VAR_URI, parser->uri);
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_URI, parser->uri);
} else {
free(data);
return 0;
@ -551,9 +551,9 @@ int igloo_httpp_parse(http_parser_t *parser, const char *http_data, unsigned lon
return 1;
}
void igloo_httpp_deletevar(http_parser_t *parser, const char *name)
void igloo_httpp_deletevar(igloo_http_parser_t *parser, const char *name)
{
http_var_t var;
igloo_http_var_t var;
if (parser == NULL || name == NULL)
return;
@ -564,14 +564,14 @@ void igloo_httpp_deletevar(http_parser_t *parser, const char *name)
igloo_avl_delete(parser->vars, (void *)&var, igloo__free_vars);
}
void igloo_httpp_setvar(http_parser_t *parser, const char *name, const char *value)
void igloo_httpp_setvar(igloo_http_parser_t *parser, const char *name, const char *value)
{
http_var_t *var;
igloo_http_var_t *var;
if (name == NULL || value == NULL)
return;
var = (http_var_t *)calloc(1, sizeof(http_var_t));
var = (igloo_http_var_t *)calloc(1, sizeof(igloo_http_var_t));
if (var == NULL) return;
var->value = calloc(1, sizeof(*var->value));
@ -592,10 +592,10 @@ void igloo_httpp_setvar(http_parser_t *parser, const char *name, const char *val
}
}
const char *igloo_httpp_getvar(http_parser_t *parser, const char *name)
const char *igloo_httpp_getvar(igloo_http_parser_t *parser, const char *name)
{
http_var_t var;
http_var_t *found;
igloo_http_var_t var;
igloo_http_var_t *found;
void *fp;
if (parser == NULL || name == NULL)
@ -614,9 +614,9 @@ const char *igloo_httpp_getvar(http_parser_t *parser, const char *name)
}
}
static void _httpp_set_param_nocopy(avl_tree *tree, char *name, char *value, int replace)
static void _httpp_set_param_nocopy(igloo_avl_tree *tree, char *name, char *value, int replace)
{
http_var_t *var, *found;
igloo_http_var_t *var, *found;
char **n;
if (name == NULL || value == NULL)
@ -625,7 +625,7 @@ static void _httpp_set_param_nocopy(avl_tree *tree, char *name, char *value, int
found = igloo__httpp_get_param_var(tree, name);
if (replace || !found) {
var = (http_var_t *)calloc(1, sizeof(http_var_t));
var = (igloo_http_var_t *)calloc(1, sizeof(igloo_http_var_t));
if (var == NULL) {
free(name);
free(value);
@ -659,7 +659,7 @@ static void _httpp_set_param_nocopy(avl_tree *tree, char *name, char *value, int
}
}
static void _httpp_set_param(avl_tree *tree, const char *name, const char *value)
static void _httpp_set_param(igloo_avl_tree *tree, const char *name, const char *value)
{
if (name == NULL || value == NULL)
return;
@ -667,10 +667,10 @@ static void _httpp_set_param(avl_tree *tree, const char *name, const char *value
_httpp_set_param_nocopy(tree, strdup(name), igloo_url_unescape(value, strlen(value)), 1);
}
static http_var_t *igloo__httpp_get_param_var(avl_tree *tree, const char *name)
static igloo_http_var_t *igloo__httpp_get_param_var(igloo_avl_tree *tree, const char *name)
{
http_var_t var;
http_var_t *found;
igloo_http_var_t var;
igloo_http_var_t *found;
void *fp;
fp = &found;
@ -682,9 +682,9 @@ static http_var_t *igloo__httpp_get_param_var(avl_tree *tree, const char *name)
else
return NULL;
}
static const char *_httpp_get_param(avl_tree *tree, const char *name)
static const char *_httpp_get_param(igloo_avl_tree *tree, const char *name)
{
http_var_t *res = igloo__httpp_get_param_var(tree, name);
igloo_http_var_t *res = igloo__httpp_get_param_var(tree, name);
if (!res)
return NULL;
@ -695,29 +695,29 @@ static const char *_httpp_get_param(avl_tree *tree, const char *name)
return res->value[0];
}
void igloo_httpp_set_query_param(http_parser_t *parser, const char *name, const char *value)
void igloo_httpp_set_query_param(igloo_http_parser_t *parser, const char *name, const char *value)
{
return _httpp_set_param(parser->queryvars, name, value);
}
const char *igloo_httpp_get_query_param(http_parser_t *parser, const char *name)
const char *igloo_httpp_get_query_param(igloo_http_parser_t *parser, const char *name)
<