Willy Tarreau | b7eba10 | 2006-12-04 02:20:02 +0100 | [diff] [blame] | 1 | /* |
| 2 | include/proto/hdr_idx.h |
| 3 | This file defines function prototypes for fast header indexation. |
| 4 | |
| 5 | Copyright (C) 2000-2006 Willy Tarreau - w@1wt.eu |
| 6 | |
| 7 | This library is free software; you can redistribute it and/or |
| 8 | modify it under the terms of the GNU Lesser General Public |
| 9 | License as published by the Free Software Foundation, version 2.1 |
| 10 | exclusively. |
| 11 | |
| 12 | This library is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | Lesser General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU Lesser General Public |
| 18 | License along with this library; if not, write to the Free Software |
| 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
| 21 | |
| 22 | #ifndef _PROTO_HDR_IDX_H |
| 23 | #define _PROTO_HDR_IDX_H |
| 24 | |
| 25 | #include <common/config.h> |
| 26 | #include <types/hdr_idx.h> |
| 27 | |
| 28 | /* |
| 29 | * Initialize the list pointers. |
| 30 | * list->size must already be set. If list->size is set and list->v is |
| 31 | * non-null, list->v is also initialized.. |
| 32 | */ |
| 33 | static inline void hdr_idx_init(struct hdr_idx *list) |
| 34 | { |
| 35 | if (list->size && list->v) { |
| 36 | register struct hdr_idx_elem e = { .len=0, .cr=0, .next=0}; |
| 37 | list->v[0] = e; |
| 38 | } |
| 39 | list->tail = 0; |
| 40 | list->used = list->last = 1; |
| 41 | } |
| 42 | |
| 43 | /* |
| 44 | * Add a header entry to <list> after element <after>. <after> is ignored when |
| 45 | * the list is empty or full. Common usage is to set <after> to list->tail. |
| 46 | * |
| 47 | * Returns the position of the new entry in the list (from 1 to size-1), or 0 |
| 48 | * if the array is already full. An effort is made to fill the array linearly, |
| 49 | * but once the last entry has been used, we have to search for unused blocks, |
| 50 | * which takes much more time. For this reason, it's important to size is |
| 51 | * appropriately. |
| 52 | */ |
| 53 | int hdr_idx_add(int len, int cr, struct hdr_idx *list, int after); |
| 54 | |
| 55 | #endif /* _PROTO_HDR_IDX_H */ |
| 56 | |
| 57 | /* |
| 58 | * Local variables: |
| 59 | * c-indent-level: 8 |
| 60 | * c-basic-offset: 8 |
| 61 | * End: |
| 62 | */ |