HTP  0.3
dslib.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (c) 2009-2010, Open Information Security Foundation
3  * Copyright (c) 2009-2012, Qualys, Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  * * Neither the name of the Qualys, Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  ***************************************************************************/
31 
37 #ifndef _DSLIB_H
38 #define _DSLIB_H
39 
40 typedef struct list_t list_t;
41 typedef struct list_array_t list_array_t;
44 typedef struct table_t table_t;
45 
46 #include "bstr.h"
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 // IMPORTANT This library is used internally by the parser and you should
53 // not rely on it in your code. The implementation may change at
54 // any time.
55 
56 // Lists
57 
58 #define list_push(L, E) (L)->push(L, E)
59 #define list_pop(L) (L)->pop(L)
60 #define list_empty(L) (L)->empty(L)
61 #define list_get(L, N) (L)->get((list_t *)L, N)
62 #define list_replace(L, N, E) (L)->replace((list_t *)L, N, E)
63 #define list_add(L, N) (L)->push(L, N)
64 #define list_size(L) (L)->size(L)
65 #define list_iterator_reset(L) (L)->iterator_reset(L)
66 #define list_iterator_next(L) (L)->iterator_next(L)
67 #define list_destroy(L) (*(L))->destroy(L)
68 #define list_shift(L) (L)->shift(L)
69 
70 #define LIST_COMMON \
71  int (*push)(list_t *, void *); \
72  void *(*pop)(list_t *); \
73  int (*empty)(const list_t *); \
74  void *(*get)(const list_t *, size_t index); \
75  int (*replace)(list_t *, size_t index, void *); \
76  size_t (*size)(const list_t *); \
77  void (*iterator_reset)(list_t *); \
78  void *(*iterator_next)(list_t *); \
79  void (*destroy)(list_t **); \
80  void *(*shift)(list_t *)
81 
82 struct list_t {
84 };
85 
87  void *data;
89 };
90 
91 struct list_linked_t {
93 
96 };
97 
98 struct list_array_t {
100 
101  size_t first;
102  size_t last;
103  size_t max_size;
104  size_t current_size;
105  void **elements;
106 
108 };
109 
112 
113 list_t *list_array_create(size_t size);
117 
118 
119 // Table
120 
121 struct table_t {
123 };
124 
125 table_t *table_create(size_t size);
126  int table_add(table_t *, bstr *, void *);
127  int table_addn(table_t *, bstr *, void *);
128  void table_set(table_t *, bstr *, void *);
129  void *table_get(const table_t *, const bstr *);
130  void *table_get_c(const table_t *, const char *);
132  bstr *table_iterator_next(table_t *, void **);
133  size_t table_size(const table_t *t);
134  void table_destroy(table_t **);
135  void table_clear(table_t *);
136 
137 #ifdef __cplusplus
138 }
139 #endif
140 
141 #endif /* _DSLIB_H */
142