00001 /*************************************************************************** 00002 * Copyright (c) 2009-2010 Open Information Security Foundation 00003 * Copyright (c) 2010-2013 Qualys, Inc. 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions are 00008 * met: 00009 * 00010 * - Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 00013 * - Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in the 00015 * documentation and/or other materials provided with the distribution. 00016 00017 * - Neither the name of the Qualys, Inc. nor the names of its 00018 * contributors may be used to endorse or promote products derived from 00019 * this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00024 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00025 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00026 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00027 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00028 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00029 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00030 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00031 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00032 ***************************************************************************/ 00033 00039 #ifndef HTP_LIST_H 00040 #define HTP_LIST_H 00041 00042 #ifdef __cplusplus 00043 extern "C" { 00044 #endif 00045 00046 // The default list implementation is array-based. The 00047 // linked list version is not fully implemented yet. 00048 #define htp_list_t htp_list_array_t 00049 #define htp_list_add htp_list_array_push 00050 #define htp_list_create htp_list_array_create 00051 #define htp_list_clear htp_list_array_clear 00052 #define htp_list_destroy htp_list_array_destroy 00053 #define htp_list_get htp_list_array_get 00054 #define htp_list_pop htp_list_array_pop 00055 #define htp_list_push htp_list_array_push 00056 #define htp_list_replace htp_list_array_replace 00057 #define htp_list_size htp_list_array_size 00058 #define htp_list_shift htp_list_array_shift 00059 00060 // Data structures 00061 00062 typedef struct htp_list_array_t htp_list_array_t; 00063 typedef struct htp_list_linked_t htp_list_linked_t; 00064 00065 #include "htp_core.h" 00066 #include "bstr.h" 00067 00068 // Functions 00069 00076 htp_list_array_t *htp_list_array_create(size_t size); 00077 00085 void htp_list_array_clear(htp_list_array_t *l); 00086 00093 void htp_list_array_destroy(htp_list_array_t *l); 00094 00103 void *htp_list_array_get(const htp_list_array_t *l, size_t idx); 00104 00111 void *htp_list_array_pop(htp_list_array_t *l); 00112 00121 htp_status_t htp_list_array_push(htp_list_array_t *l, void *e); 00122 00133 htp_status_t htp_list_array_replace(htp_list_array_t *l, size_t idx, void *e); 00134 00141 size_t htp_list_array_size(const htp_list_array_t *l); 00142 00149 void *htp_list_array_shift(htp_list_array_t *l); 00150 00151 00152 // Linked list 00153 00159 htp_list_linked_t *htp_list_linked_create(void); 00160 00167 void htp_list_linked_destroy(htp_list_linked_t *l); 00168 00175 int htp_list_linked_empty(const htp_list_linked_t *l); 00176 00183 void *htp_list_linked_pop(htp_list_linked_t *l); 00184 00192 htp_status_t htp_list_linked_push(htp_list_linked_t *l, void *e); 00193 00200 void *htp_list_linked_shift(htp_list_linked_t *l); 00201 00202 #ifdef __cplusplus 00203 } 00204 #endif 00205 00206 #endif /* HTP_LIST_H */ 00207