1 /* 2 * Copyright (C) 2004-2008 Christos Tsantilas 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this library; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 17 * MA 02110-1301 USA. 18 */ 19 20 21 #ifndef __C_ICAP_H 22 #define __C_ICAP_H 23 24 25 #if defined (_MSC_VER) 26 #include "c-icap-conf-w32.h" 27 #else 28 #include "c-icap-conf.h" 29 #endif 30 31 #ifdef __SYS_TYPES_H_EXISTS 32 #include <sys/types.h> 33 #endif 34 35 #ifdef __INTTYPES_H_EXISTS 36 #include <inttypes.h> 37 #endif 38 39 /*some defines */ 40 #ifdef _WIN32 41 # define CI_FILENAME_LEN _MAX_PATH 42 # define CI_MAX_PATH _MAX_PATH 43 #else 44 # if defined(MAXPATHLEN) 45 # define CI_MAX_PATH MAXPATHLEN 46 # elif defined(PATH_MAX) 47 # define CI_MAX_PATH PATH_MAX 48 # else 49 # define CI_MAX_PATH 4096 50 # endif 51 # define CI_FILENAME_LEN CI_MAX_PATH 52 #endif 53 54 55 #ifdef _WIN32 56 # if defined(CI_BUILD_LIB) 57 58 # define CI_DECLARE_FUNC(type) __declspec(dllexport) type 59 # define CI_DECLARE_DATA __declspec(dllexport) 60 61 # else 62 63 # define CI_DECLARE_FUNC(type) __declspec(dllimport) type 64 # define CI_DECLARE_DATA __declspec(dllimport) 65 66 # endif 67 68 # if defined (CI_BUILD_MODULE) 69 # define CI_DECLARE_MOD_DATA __declspec(dllexport) 70 # define CI_DECLARE_MOD_FUNC(type) __declspec(dllexport) type 71 # endif 72 73 #else 74 75 /* 76 77 */ 78 #if defined (USE_VISIBILITY_ATTRIBUTE) 79 #define CI_DECLARE_FUNC(type) __attribute__ ((visibility ("default"))) type 80 #define CI_DECLARE_DATA __attribute__ ((visibility ("default"))) 81 #define CI_DECLARE_MOD_DATA __attribute__ ((visibility ("default"))) 82 #else 83 #define CI_DECLARE_FUNC(type) type 84 #define CI_DECLARE_DATA 85 #define CI_DECLARE_MOD_DATA 86 #endif 87 #endif 88 89 /* 90 Here we are define the ci_off_t type to support large files. 91 92 -A comment about lfs: 93 In Solaris and Linux to have lfs support, if you are using 94 only lseek and open function, you are using off_t type for offsets 95 and compile the program with -D_FILE_OFFSET_BITS=64. This flag 96 forces the compiler to typedefs the off_t type as an 64bit integer, 97 uses open64, lseek64, mkstemp64 and fopen64 functions. 98 99 Instead for fseek and ftell the functions fseeko and ftello must be used. 100 This functions uses off_t argument's instead of long. 101 Currently we are not using fseek and ftell in c-icap. 102 103 The open's manual page says that the flag O_LARGEFILE must be used. Looks that 104 it does not actually needed for linux and solaris (version 10) (but must be checked again......) 105 106 The off_t type in my linux system is a signed integer, but I am not 107 sure if it is true for all operating systems 108 109 */ 110 typedef off_t ci_off_t; 111 #if CI_SIZEOF_OFF_T > 4 112 # define PRINTF_OFF_T "lld" 113 # define CAST_OFF_T long long int 114 # define ci_strto_off_t strtoll 115 # define CI_STRTO_OFF_T_MAX LLONG_MAX 116 # define CI_STRTO_OFF_T_MIN LLONG_MIN 117 #else 118 # define PRINTF_OFF_T "ld" 119 # define CAST_OFF_T long int 120 # define ci_strto_off_t strtol 121 # define CI_STRTO_OFF_T_MAX LONG_MAX 122 # define CI_STRTO_OFF_T_MIN LONG_MIN 123 #endif 124 125 /* 126 Detect n-bytes alignment. 127 Old 8 bytes alignment macro: 128 #define _CI_ALIGN(val) ((val+7)&~7) 129 */ 130 struct _ci_align_test {char n[1]; double d;}; 131 #define _CI_NBYTES_ALIGNMENT ((size_t) &(((struct _ci_align_test *)0)[0].d)) 132 #define _CI_ALIGN(val) ((val+(_CI_NBYTES_ALIGNMENT - 1))&~(_CI_NBYTES_ALIGNMENT - 1)) 133 134 #define ICAP_OPTIONS 0x01 135 #define ICAP_REQMOD 0x02 136 #define ICAP_RESPMOD 0x04 137 138 CI_DECLARE_DATA extern const char *ci_methods[]; 139 140 #define ci_method_support(METHOD, METHOD_DEF) (METHOD&METHOD_DEF) 141 #define ci_method_string(method) (method<=ICAP_RESPMOD && method>=ICAP_OPTIONS ?ci_methods[method]:"UNKNOWN") 142 143 144 enum ci_error_codes { EC_100, EC_200, EC_204, EC_206, EC_400, 145 EC_401, EC_403, 146 EC_404, EC_405, EC_407, EC_408, 147 EC_500, EC_501, EC_502, 148 EC_503, EC_505, 149 EC_MAX 150 }; 151 152 typedef struct ci_error_code { 153 int code; 154 char *str; 155 } ci_error_code_t; 156 157 CI_DECLARE_DATA extern const struct ci_error_code ci_error_codes[]; 158 #define ci_error_code(ec) (ec>=EC_100&&ec<EC_MAX?ci_error_codes[ec].code:1000) 159 #define ci_error_code_string(ec) (ec>=EC_100&&ec<EC_MAX?ci_error_codes[ec].str:"UNKNOWN ERROR CODE") 160 161 162 #define ICAP_EOL "\r\n" 163 #define ICAP_EOF "0\r\n\r\n" 164 #define ICAP_IEOF "0; ieof\r\n\r\n" 165 #define ISTAG "CI0001" /*Always length of 6 chars*/ 166 #define ISTAG_SIZE 32 167 168 /*The following block defines the base doxygen group (API group)*/ 169 /** 170 \defgroup API API Documentation 171 * Functions, typedefs and structures for use with modules and services 172 * 173 */ 174 175 #endif 176