Willy Tarreau | 51041c7 | 2007-09-09 21:56:53 +0200 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <common/sessionhash.h> |
| 3 | |
| 4 | int main(int argc, char *argv[]) |
| 5 | { |
| 6 | appsess *a, *b, *c, *d, *tmp; |
| 7 | struct appsession_hash h; |
| 8 | int i; |
| 9 | |
| 10 | a = malloc(sizeof(appsess)); |
| 11 | b = malloc(sizeof(appsess)); |
| 12 | c = malloc(sizeof(appsess)); |
| 13 | d = malloc(sizeof(appsess)); |
| 14 | |
| 15 | a->sessid = "abcdefg"; |
| 16 | b->sessid = "2c"; |
| 17 | c->sessid = "pe"; |
| 18 | d->sessid = "abbbbbccccb"; |
| 19 | |
| 20 | appsession_hash_init(&h, (void (*)())free); |
| 21 | appsession_hash_dump(&h); |
| 22 | appsession_hash_insert(&h, a); |
| 23 | appsession_hash_insert(&h, b); |
| 24 | appsession_hash_insert(&h, c); |
| 25 | appsession_hash_insert(&h, d); |
| 26 | |
| 27 | appsession_hash_dump(&h); |
| 28 | |
| 29 | printf("a: %p\n", a); |
| 30 | printf("b: %p\n", b); |
| 31 | printf("c: %p\n", c); |
| 32 | printf("d: %p\n", d); |
| 33 | printf("-------------\n"); |
| 34 | printf("a: %p\n", appsession_hash_lookup(&h, "abcdefg")); |
| 35 | printf("b: %p\n", appsession_hash_lookup(&h, "2c")); |
| 36 | printf("c: %p\n", appsession_hash_lookup(&h, "pe")); |
| 37 | printf("d: %p\n", appsession_hash_lookup(&h, "abbbbbccccb")); |
| 38 | printf("null: %p\n", appsession_hash_lookup(&h, "non existant")); |
| 39 | |
| 40 | |
| 41 | appsession_hash_remove(&h, c); |
| 42 | appsession_hash_remove(&h, d); |
| 43 | |
| 44 | appsession_hash_dump(&h); |
| 45 | |
| 46 | printf("-- remove c,d\n"); |
| 47 | printf("a: %p\n", appsession_hash_lookup(&h, "abcdefg")); |
| 48 | printf("b: %p\n", appsession_hash_lookup(&h, "2c")); |
| 49 | printf("c: %p\n", appsession_hash_lookup(&h, "pe")); |
| 50 | printf("d: %p\n", appsession_hash_lookup(&h, "abbbbbccccb")); |
| 51 | printf("null: %p\n", appsession_hash_lookup(&h, "non existant")); |
| 52 | |
| 53 | appsession_hash_destroy(&h); |
| 54 | } |