1 #ifndef _sw_corby_buffer_h 2 #define _sw_corby_buffer_h 3 4 /* 5 * Copyright 2003, 2004 Porchdog Software. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without modification, 8 * are permitted provided that the following conditions are met: 9 * 10 * 1. Redistributions of source code must retain the above copyright notice, 11 * this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright notice, 13 * this list of conditions and the following disclaimer in the documentation 14 * and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 24 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 25 * OF THE POSSIBILITY OF SUCH DAMAGE. 26 * 27 * The views and conclusions contained in the software and documentation are those 28 * of the authors and should not be interpreted as representing official policies, 29 * either expressed or implied, of Porchdog Software. 30 */ 31 32 #include <salt/salt.h> 33 #include <corby/corby.h> 34 35 36 #ifdef __cplusplus 37 extern "C" 38 { 39 #endif 40 41 42 struct _sw_corby_buffer; 43 typedef struct _sw_corby_buffer * sw_corby_buffer; 44 struct _sw_corby_object; 45 typedef sw_opaque sw_corby_buffer_delegate; 46 typedef sw_opaque sw_corby_buffer_observer; 47 48 49 typedef enum _sw_corby_buffer_pad 50 { 51 SW_CORBY_BUFFER_PAD_NONE, 52 SW_CORBY_BUFFER_PAD_ALIGN_2, 53 SW_CORBY_BUFFER_PAD_ALIGN_4, 54 SW_CORBY_BUFFER_PAD_ALIGN_8, 55 SW_CORBY_BUFFER_PAD_ALIGN_16, 56 SW_CORBY_BUFFER_PAD_ALIGN_32 57 } sw_corby_buffer_pad; 58 59 60 typedef sw_result 61 (HOWL_API* sw_corby_buffer_written_func)( 62 sw_corby_buffer_observer observer, 63 sw_corby_buffer buffer, 64 sw_result result, 65 sw_size_t bytesWritten, 66 sw_opaque_t extra); 67 68 69 typedef sw_result 70 (HOWL_API* sw_corby_buffer_overflow_func)( 71 sw_corby_buffer_delegate delegate, 72 sw_corby_buffer buffer, 73 sw_uint8 octet, 74 sw_uint8 ** base, 75 sw_uint8 ** bptr, 76 sw_uint8 ** eptr, 77 sw_uint8 ** end, 78 sw_opaque_t extra); 79 80 81 typedef sw_result 82 (HOWL_API* sw_corby_buffer_underflow_func)( 83 sw_corby_buffer_delegate delegate, 84 sw_corby_buffer buffer, 85 sw_uint8 * octet, 86 sw_uint8 ** base, 87 sw_uint8 ** bptr, 88 sw_uint8 ** eptr, 89 sw_uint8 ** end, 90 sw_opaque_t extra); 91 92 93 sw_result HOWL_API 94 sw_corby_buffer_init( 95 sw_corby_buffer * self); 96 97 98 sw_result HOWL_API 99 sw_corby_buffer_init_with_size( 100 sw_corby_buffer * self, 101 sw_size_t size); 102 103 104 sw_result HOWL_API 105 sw_corby_buffer_init_with_delegate( 106 sw_corby_buffer * self, 107 sw_corby_buffer_delegate delegate, 108 sw_corby_buffer_overflow_func overflow, 109 sw_corby_buffer_underflow_func underflow, 110 sw_opaque_t extra); 111 112 113 sw_result HOWL_API 114 sw_corby_buffer_init_with_size_and_delegate( 115 sw_corby_buffer * self, 116 sw_size_t size, 117 sw_corby_buffer_delegate delegate, 118 sw_corby_buffer_overflow_func overflow, 119 sw_corby_buffer_underflow_func underflow, 120 sw_opaque_t extra); 121 122 123 sw_result HOWL_API 124 sw_corby_buffer_fina( 125 sw_corby_buffer self); 126 127 128 void HOWL_API 129 sw_corby_buffer_reset( 130 sw_corby_buffer self); 131 132 133 sw_result HOWL_API 134 sw_corby_buffer_set_octets( 135 sw_corby_buffer self, 136 sw_octets octets, 137 sw_size_t size); 138 139 140 sw_octets HOWL_API 141 sw_corby_buffer_octets( 142 sw_corby_buffer self); 143 144 145 sw_size_t HOWL_API 146 sw_corby_buffer_bytes_used( 147 sw_corby_buffer self); 148 149 150 sw_size_t HOWL_API 151 sw_corby_buffer_size( 152 sw_corby_buffer self); 153 154 155 sw_result HOWL_API 156 sw_corby_buffer_put_int8( 157 sw_corby_buffer self, 158 sw_int8 val); 159 160 161 sw_result HOWL_API 162 sw_corby_buffer_put_uint8( 163 sw_corby_buffer self, 164 sw_uint8 val); 165 166 167 sw_result HOWL_API 168 sw_corby_buffer_put_int16( 169 sw_corby_buffer self, 170 sw_int16 val); 171 172 173 sw_result HOWL_API 174 sw_corby_buffer_put_uint16( 175 sw_corby_buffer self, 176 sw_uint16 val); 177 178 179 sw_result HOWL_API 180 sw_corby_buffer_put_int32( 181 sw_corby_buffer self, 182 sw_int32 val); 183 184 185 sw_result HOWL_API 186 sw_corby_buffer_put_uint32( 187 sw_corby_buffer self, 188 sw_uint32 val); 189 190 191 sw_result HOWL_API 192 sw_corby_buffer_put_octets( 193 sw_corby_buffer self, 194 sw_const_octets val, 195 sw_size_t size); 196 197 198 sw_result HOWL_API 199 sw_corby_buffer_put_sized_octets( 200 sw_corby_buffer self, 201 sw_const_octets val, 202 sw_uint32 len); 203 204 205 sw_result HOWL_API 206 sw_corby_buffer_put_cstring( 207 sw_corby_buffer self, 208 sw_const_string val); 209 210 211 sw_result HOWL_API 212 sw_corby_buffer_put_object( 213 sw_corby_buffer self, 214 const struct _sw_corby_object * object); 215 216 217 sw_result HOWL_API 218 sw_corby_buffer_put_pad( 219 sw_corby_buffer self, 220 sw_corby_buffer_pad pad); 221 222 223 sw_result HOWL_API 224 sw_corby_buffer_get_int8( 225 sw_corby_buffer self, 226 sw_int8 * val); 227 228 229 sw_result HOWL_API 230 sw_corby_buffer_get_uint8( 231 sw_corby_buffer self, 232 sw_uint8 * val); 233 234 235 sw_result HOWL_API 236 sw_corby_buffer_get_int16( 237 sw_corby_buffer self, 238 sw_int16 * val, 239 sw_uint8 endian); 240 241 242 sw_result HOWL_API 243 sw_corby_buffer_get_uint16( 244 sw_corby_buffer self, 245 sw_uint16 * val, 246 sw_uint8 endian); 247 248 249 sw_result HOWL_API 250 sw_corby_buffer_get_int32( 251 sw_corby_buffer self, 252 sw_int32 * val, 253 sw_uint8 endian); 254 255 256 sw_result HOWL_API 257 sw_corby_buffer_get_uint32( 258 sw_corby_buffer self, 259 sw_uint32 * val, 260 sw_uint8 endian); 261 262 263 sw_result HOWL_API 264 sw_corby_buffer_get_octets( 265 sw_corby_buffer self, 266 sw_octets octets, 267 sw_size_t size); 268 269 270 sw_result HOWL_API 271 sw_corby_buffer_allocate_and_get_sized_octets( 272 sw_corby_buffer self, 273 sw_octets * val, 274 sw_uint32 * size, 275 sw_uint8 endian); 276 277 278 sw_result HOWL_API 279 sw_corby_buffer_get_zerocopy_sized_octets( 280 sw_corby_buffer self, 281 sw_octets * val, 282 sw_uint32 * size, 283 sw_uint8 endian); 284 285 286 sw_result HOWL_API 287 sw_corby_buffer_get_sized_octets( 288 sw_corby_buffer self, 289 sw_octets val, 290 sw_uint32 * len, 291 sw_uint8 endian); 292 293 294 sw_result HOWL_API 295 sw_corby_buffer_allocate_and_get_cstring( 296 sw_corby_buffer self, 297 sw_string * val, 298 sw_uint32 * len, 299 sw_uint8 endian); 300 301 302 sw_result HOWL_API 303 sw_corby_buffer_get_zerocopy_cstring( 304 sw_corby_buffer self, 305 sw_string * val, 306 sw_uint32 * len, 307 sw_uint8 endian); 308 309 310 sw_result HOWL_API 311 sw_corby_buffer_get_cstring( 312 sw_corby_buffer self, 313 sw_string val, 314 sw_uint32 * len, 315 sw_uint8 endian); 316 317 318 sw_result HOWL_API 319 sw_corby_buffer_get_object( 320 sw_corby_buffer self, 321 struct _sw_corby_object ** object, 322 sw_uint8 endian); 323 324 325 #ifdef __cplusplus 326 } 327 #endif 328 329 330 #endif 331