/usr/include/c_icap/header.h is in libicapapi-dev 1:0.4.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | /*
* Copyright (C) 2004-2008 Christos Tsantilas
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA.
*/
#ifndef __HEADERS_H
#define __HEADERS_H
#include "c-icap.h"
#ifdef __cplusplus
extern "C"
{
#endif
/**
\defgroup HEADERS Headers related API
\ingroup API
* Headers manipulation related API.
*/
enum ci_request_headers { ICAP_AUTHORIZATION, ICAP_ALLOW,
ICAP_FROM, ICAP_HOST, ICAP_REFERER,
ICAP_USERAGENT,ICAP_PREVIEW
};
extern const char *ci_common_headers[];
extern const char *ci_request_headers[];
extern const char *ci_responce_headers[];
extern const char *ci_options_headers[];
enum ci_encapsulated_entities {ICAP_REQ_HDR, ICAP_RES_HDR,
ICAP_REQ_BODY, ICAP_RES_BODY,
ICAP_NULL_BODY,ICAP_OPT_BODY };
CI_DECLARE_DATA extern const char *ci_encaps_entities[];
#ifdef __CYGWIN__
const char *ci_encaps_entity_string(int e);
#else
#define ci_encaps_entity_string(e) (e<=ICAP_OPT_BODY&&e>=ICAP_REQ_HDR?ci_encaps_entities[e]:"UNKNOWN")
#endif
/**
\typedef ci_headers_list_t
\ingroup HEADERS
* This is a struct which can store a set of headers.
* The developers should not touch ci_headers_list_t objects directly but better use the
* documented macros and functions
*/
typedef struct ci_headers_list{
int size;
int used;
char **headers;
int bufsize;
int bufused;
char *buf;
int packed;
} ci_headers_list_t;
typedef struct ci_encaps_entity{
int start;
int type;
void *entity;
} ci_encaps_entity_t;
#define BUFSIZE 4096
#define HEADERSTARTSIZE 64
#define HEADSBUFSIZE BUFSIZE
#define MAX_HEADER_SIZE 1023
#define ci_headers_not_empty(h) ((h)->used)
#define ci_headers_is_empty(h) ((h)->used==0)
/**
* Allocate memory for a ci_headers_list_t object and initialize it.
\ingroup HEADERS
\return the allocated object on success, NULL otherwise.
*
*/
CI_DECLARE_FUNC(ci_headers_list_t *) ci_headers_create();
/**
* Destroy a ci_headers_list_t object
\ingroup HEADERS
\param heads is a pointer to the ci_headers_list_t object to be destroyed
*
*/
CI_DECLARE_FUNC(void) ci_headers_destroy(ci_headers_list_t *heads);
/**
* Resets and initialize a ci_headers_list_t object
\ingroup HEADERS
\param heads pointer to the ci_headers_list_t object to be reset
*
*/
CI_DECLARE_FUNC(void) ci_headers_reset(ci_headers_list_t *heads);
CI_DECLARE_FUNC(int) ci_headers_setsize(ci_headers_list_t *heads, int size);
/**
* Add a header to a ci_headers_list_t object
\ingroup HEADERS
\param heads is a pointer to the ci_headers_list_t object in which the header will be added
\param header is the header to be added
\return Pointer to the newly add header on success, NULL otherwise
*
*example usage:
\code
ci_headers_add(heads,"Content-Length: 1025")
\endcode
*
*/
CI_DECLARE_FUNC(const char *) ci_headers_add(ci_headers_list_t *heads, const char *header);
/**
* Append a headers list object to an other headers list
\ingroup HEADERS
\param heads is a pointer to the ci_headers_list_t object in which the headers will be added
\param someheaders is a ci_headers_list_t object which contains the headers will be added to the heads
\return non zero on success zero otherwise
*/
CI_DECLARE_FUNC(int) ci_headers_addheaders(ci_headers_list_t *heads,const ci_headers_list_t *someheaders);
/**
* Removes a header from a header list
\ingroup HEADERS
\param heads is a pointer to the ci_headers_list_t object
\param header is the name of the header to be removed
\return non zero on success, zero otherwise
*
*example usage:
\code
ci_headers_remove(heads,"Content-Length")
\endcode
*
*/
CI_DECLARE_FUNC(int) ci_headers_remove(ci_headers_list_t *heads, const char *header);
/**
* Search for a header in a header list
\ingroup HEADERS
\param heads is a pointer to the ci_headers_list_t object
\param header is the name of the header
\return a pointer to the start of the first occurrence of the header on success, NULL otherwise
*
*example usage:
\code
char *head;
head=ci_headers_search(heads,"Content-Length")
\endcode
* In this example on success the head pointer will point to a \em "Content-Lenght: 1025" string
*
*/
CI_DECLARE_FUNC(const char *) ci_headers_search(ci_headers_list_t *heads, const char *header);
/**
* Search for a header in a header list and return the value of the first occurrence of this header
\ingroup HEADERS
\param heads is a pointer to the ci_headers_list_t object
\param header is the name of the header
\return a pointer to the start of the header on success, NULL otherwise
*
*example usage:
\code
char *headval;
int content_length;
headval = ci_headers_value(heads,"Content-Length");
content_length = strtol(headval,NULL,10);
\endcode
*
*/
CI_DECLARE_FUNC(const char *) ci_headers_value(ci_headers_list_t *heads, const char *header);
/**
* Search for a header in a header list and copy the value to a buffer if exist
\ingroup HEADERS
\param heads is a pointer to the ci_headers_list_t object
\param header is the name of the header
\param buf is the buffer to store header value
\param len is the size of the buffer buf
\return a pointer to the buf on success, NULL otherwise
*
*example usage:
\code
char *headval;
char buf[1024];
int content_length;
headval = ci_headers_copy_value(heads, "Content-Length", buf, sizeof(buf));
if (headval)
printf("Content-Length: %s\n", buf);
\endcode
*
*/
CI_DECLARE_FUNC(const char *) ci_headers_copy_value(ci_headers_list_t *heads, const char *header, char *buf, size_t len);
/**
* Run the given function for each header name/value pair
\ingroup HEADERS
\param heads is a pointer to the ci_headers_list_t object
\param data is a pointer to data which will passed as first argument to the fn function
\param fn is a pointer to a function which will run for each header name/value pair.
\return non zero on success, zero otherwise
*/
CI_DECLARE_FUNC(int) ci_headers_iterate(ci_headers_list_t *heads, void *data, void (*fn)(void *data, const char *header_name, const char *header_value));
/*The following headers are only used internally */
CI_DECLARE_FUNC(void) ci_headers_pack(ci_headers_list_t *heads);
CI_DECLARE_FUNC(int) ci_headers_unpack(ci_headers_list_t *heads);
CI_DECLARE_FUNC(int) sizeofheader(ci_headers_list_t *heads);
CI_DECLARE_FUNC(ci_encaps_entity_t) *mk_encaps_entity(int type,int val);
CI_DECLARE_FUNC(void) destroy_encaps_entity(ci_encaps_entity_t *e);
CI_DECLARE_FUNC(int) get_encaps_type(const char *buf,int *val,char **endpoint);
CI_DECLARE_FUNC(int) sizeofencaps(ci_encaps_entity_t *e);
#ifdef __CI_COMPAT
#define ci_headers_make ci_header_create
#endif
#ifdef __cplusplus
}
#endif
#endif
|