[BIGMOVE] exploded the monolithic haproxy.c file into multiple files.
The files are now stored under :
- include/haproxy for the generic includes
- include/types.h for the structures needed within prototypes
- include/proto.h for function prototypes and inline functions
- src/*.c for the C files
Most include files are now covered by LGPL. A last move still needs
to be done to put inline functions under GPL and not LGPL.
Version has been set to 1.3.0 in the code but some control still
needs to be done before releasing.
diff --git a/src/chtbl.c b/src/chtbl.c
index 481b3ac..c8e794f 100644
--- a/src/chtbl.c
+++ b/src/chtbl.c
@@ -18,8 +18,8 @@
#include <stdlib.h>
#include <string.h>
-#include <include/list.h>
-#include <include/chtbl.h>
+#include <haproxy/list.h>
+#include <haproxy/chtbl.h>
/*****************************************************************************
* *
@@ -30,47 +30,47 @@
int chtbl_init(CHTbl *htbl, int buckets, int (*h)(const void *key), int
(*match)(const void *key1, const void *key2), void (*destroy)(void*data)) {
- int i;
+ int i;
- /*****************************************************************************
- * *
- * Allocate space for the hash table. *
- * *
- *****************************************************************************/
+ /*****************************************************************************
+ * *
+ * Allocate space for the hash table. *
+ * *
+ *****************************************************************************/
- if ((htbl->table = (List *)malloc(buckets * sizeof(List))) == NULL)
- return -1;
+ if ((htbl->table = (List *)malloc(buckets * sizeof(List))) == NULL)
+ return -1;
- /*****************************************************************************
- * *
- * Initialize the buckets. *
- * *
- *****************************************************************************/
+ /*****************************************************************************
+ * *
+ * Initialize the buckets. *
+ * *
+ *****************************************************************************/
- htbl->buckets = buckets;
+ htbl->buckets = buckets;
- for (i = 0; i < htbl->buckets; i++)
- list_init(&htbl->table[i], destroy);
+ for (i = 0; i < htbl->buckets; i++)
+ list_init(&htbl->table[i], destroy);
- /*****************************************************************************
- * *
- * Encapsulate the functions. *
- * *
- *****************************************************************************/
+ /*****************************************************************************
+ * *
+ * Encapsulate the functions. *
+ * *
+ *****************************************************************************/
- htbl->h = h;
- htbl->match = match;
- htbl->destroy = destroy;
+ htbl->h = h;
+ htbl->match = match;
+ htbl->destroy = destroy;
- /*****************************************************************************
- * *
- * Initialize the number of elements in the table. *
- * *
- *****************************************************************************/
+ /*****************************************************************************
+ * *
+ * Initialize the number of elements in the table. *
+ * *
+ *****************************************************************************/
- htbl->size = 0;
+ htbl->size = 0;
- return 0;
+ return 0;
} /* end chtbl_init () */
/*****************************************************************************
@@ -81,35 +81,35 @@
void chtbl_destroy(CHTbl *htbl) {
- int i;
+ int i;
- /*****************************************************************************
- * *
- * Destroy each bucket. *
- * *
- *****************************************************************************/
+ /*****************************************************************************
+ * *
+ * Destroy each bucket. *
+ * *
+ *****************************************************************************/
- for (i = 0; i < htbl->buckets; i++) {
- list_destroy(&htbl->table[i]);
- } /* end for () */
+ for (i = 0; i < htbl->buckets; i++) {
+ list_destroy(&htbl->table[i]);
+ } /* end for () */
- /*****************************************************************************
- * *
- * Free the storage allocated for the hash table. *
- * *
- *****************************************************************************/
+ /*****************************************************************************
+ * *
+ * Free the storage allocated for the hash table. *
+ * *
+ *****************************************************************************/
- free(htbl->table);
+ free(htbl->table);
- /*****************************************************************************
- * *
- * No operations are allowed now, but clear the structure as a precaution. *
- * *
- *****************************************************************************/
+ /*****************************************************************************
+ * *
+ * No operations are allowed now, but clear the structure as a precaution. *
+ * *
+ *****************************************************************************/
- memset(htbl, 0, sizeof(CHTbl));
+ memset(htbl, 0, sizeof(CHTbl));
- return;
+ return;
} /* end chtbl_destroy() */
/*****************************************************************************
@@ -120,38 +120,38 @@
int chtbl_insert(CHTbl *htbl, const void *data) {
- void *temp;
- int bucket,retval;
+ void *temp;
+ int bucket,retval;
- /*****************************************************************************
- * *
- * Do nothing if the data is already in the table. *
- * *
- *****************************************************************************/
+ /*****************************************************************************
+ * *
+ * Do nothing if the data is already in the table. *
+ * *
+ *****************************************************************************/
- temp = (void *)data;
+ temp = (void *)data;
- if (chtbl_lookup(htbl, &temp) == 0)
- return 1;
+ if (chtbl_lookup(htbl, &temp) == 0)
+ return 1;
- /*****************************************************************************
- * *
- * Hash the key. *
- * *
- *****************************************************************************/
+ /*****************************************************************************
+ * *
+ * Hash the key. *
+ * *
+ *****************************************************************************/
- bucket = htbl->h(data) % htbl->buckets;
+ bucket = htbl->h(data) % htbl->buckets;
- /*****************************************************************************
- * *
- * Insert the data into the bucket. *
- * *
- *****************************************************************************/
+ /*****************************************************************************
+ * *
+ * Insert the data into the bucket. *
+ * *
+ *****************************************************************************/
- if ((retval = list_ins_next(&htbl->table[bucket], NULL, data)) == 0)
- htbl->size++;
+ if ((retval = list_ins_next(&htbl->table[bucket], NULL, data)) == 0)
+ htbl->size++;
- return retval;
+ return retval;
} /* end chtbl_insert() */
/*****************************************************************************
@@ -162,53 +162,54 @@
int chtbl_remove(CHTbl *htbl, void **data) {
- ListElmt *element, *prev;
- int bucket;
+ ListElmt *element, *prev;
+ int bucket;
- /*****************************************************************************
- * *
- * Hash the key. *
- * *
- *****************************************************************************/
+ /*********************************************************************
+ * *
+ * Hash the key. *
+ * *
+ *********************************************************************/
- bucket = htbl->h(*data) % htbl->buckets;
+ bucket = htbl->h(*data) % htbl->buckets;
- /*****************************************************************************
- * *
- * Search for the data in the bucket. *
- * *
- *****************************************************************************/
+ /*********************************************************************
+ * *
+ * Search for the data in the bucket. *
+ * *
+ *********************************************************************/
- prev = NULL;
+ prev = NULL;
- for (element = list_head(&htbl->table[bucket]); element != NULL; element = list_next(element)) {
- if (htbl->match(*data, list_data(element))) {
+ for (element = list_head(&htbl->table[bucket]);
+ element != NULL; element = list_next(element)) {
+ if (htbl->match(*data, list_data(element))) {
- /***********************************************************************
- * *
- * Remove the data from the bucket. *
- * *
- ***********************************************************************/
+ /*****************************************************
+ * *
+ * Remove the data from the bucket. *
+ * *
+ *****************************************************/
- if (list_rem_next(&htbl->table[bucket], prev, data) == 0) {
- htbl->size--;
- return 0;
- } /* end if() */
- else {
- return -1;
- }/* end else */
- }/* end if (htbl->match(*data, list_data(element))) */
+ if (list_rem_next(&htbl->table[bucket], prev, data) == 0) {
+ htbl->size--;
+ return 0;
+ } /* end if() */
+ else {
+ return -1;
+ }/* end else */
+ }/* end if (htbl->match(*data, list_data(element))) */
- prev = element;
- }/* end for() */
+ prev = element;
+ }/* end for() */
- /*****************************************************************************
- * *
- * Return that the data was not found. *
- * *
- *****************************************************************************/
+ /*********************************************************************
+ * *
+ * Return that the data was not found. *
+ * *
+ *********************************************************************/
- return -1;
+ return -1;
} /* end int chtbl_remove(CHTbl *htbl, void **data) */
/*****************************************************************************
@@ -219,42 +220,50 @@
int chtbl_lookup(const CHTbl *htbl, void **data) {
- ListElmt *element;
- int bucket;
+ ListElmt *element;
+ int bucket;
- /*****************************************************************************
- * *
- * Hash the key. *
- * *
- *****************************************************************************/
+ /*********************************************************************
+ * *
+ * Hash the key. *
+ * *
+ *********************************************************************/
- bucket = htbl->h(*data) % htbl->buckets;
+ bucket = htbl->h(*data) % htbl->buckets;
- /*****************************************************************************
- * *
- * Search for the data in the bucket. *
- * *
- *****************************************************************************/
+ /*********************************************************************
+ * *
+ * Search for the data in the bucket. *
+ * *
+ *********************************************************************/
- for (element = list_head(&htbl->table[bucket]); element != NULL; element = list_next(element)) {
- if (htbl->match(*data, list_data(element))) {
+ for (element = list_head(&htbl->table[bucket]);
+ element != NULL; element = list_next(element)) {
+ if (htbl->match(*data, list_data(element))) {
- /***********************************************************************
- * *
- * Pass back the data from the table. *
- * *
- ***********************************************************************/
+ /*****************************************************
+ * *
+ * Pass back the data from the table. *
+ * *
+ *****************************************************/
- *data = list_data(element);
- return 0;
- }/* end if() */
- }/* end for() */
+ *data = list_data(element);
+ return 0;
+ }/* end if() */
+ }/* end for() */
- /*****************************************************************************
- * *
- * Return that the data was not found. *
- * *
- *****************************************************************************/
+ /*********************************************************************
+ * *
+ * Return that the data was not found. *
+ * *
+ *********************************************************************/
- return -1;
+ return -1;
} /* end chtbl_lookup() */
+
+/*
+ * Local variables:
+ * c-indent-level: 8
+ * c-basic-offset: 8
+ * End:
+ */