1#ifndef _discovery_text_record_h 2#define _discovery_text_record_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 34#if defined(__cplusplus) 35extern "C" 36{ 37#endif 38 39#define SW_TEXT_RECORD_MAX_LEN 255 40 41 42struct _sw_text_record; 43typedef struct _sw_text_record * sw_text_record; 44struct _sw_text_record_iterator; 45typedef struct _sw_text_record_iterator * sw_text_record_iterator; 46struct _sw_text_record_string_iterator; 47typedef struct _sw_text_record_string_iterator * sw_text_record_string_iterator; 48 49 50/* 51 * Text record APIs 52 */ 53sw_result HOWL_API 54sw_text_record_init( 55 sw_text_record * self); 56 57 58sw_result HOWL_API 59sw_text_record_fina( 60 sw_text_record self); 61 62 63sw_result HOWL_API 64sw_text_record_add_string( 65 sw_text_record self, 66 sw_const_string string); 67 68 69sw_result HOWL_API 70sw_text_record_add_key_and_string_value( 71 sw_text_record self, 72 sw_const_string key, 73 sw_const_string val); 74 75 76sw_result HOWL_API 77sw_text_record_add_key_and_binary_value( 78 sw_text_record self, 79 sw_const_string key, 80 sw_octets val, 81 sw_uint32 len); 82 83 84sw_octets HOWL_API 85sw_text_record_bytes( 86 sw_text_record self); 87 88 89sw_uint32 HOWL_API 90sw_text_record_len( 91 sw_text_record self); 92 93 94/* 95 * APIs for iterating through raw text records 96 */ 97sw_result HOWL_API 98sw_text_record_iterator_init( 99 sw_text_record_iterator * self, 100 sw_octets text_record, 101 sw_uint32 text_record_len); 102 103 104sw_result HOWL_API 105sw_text_record_iterator_fina( 106 sw_text_record_iterator self); 107 108 109sw_result HOWL_API 110sw_text_record_iterator_next( 111 sw_text_record_iterator self, 112 char key[SW_TEXT_RECORD_MAX_LEN], 113 sw_uint8 val[SW_TEXT_RECORD_MAX_LEN], 114 sw_uint32 * val_len); 115 116 117/* 118 * APIs for iterating through stringified text records 119 */ 120sw_result HOWL_API 121sw_text_record_string_iterator_init( 122 sw_text_record_string_iterator * self, 123 sw_const_string text_record_string); 124 125 126sw_result HOWL_API 127sw_text_record_string_iterator_fina( 128 sw_text_record_string_iterator self); 129 130 131sw_result HOWL_API 132sw_text_record_string_iterator_next( 133 sw_text_record_string_iterator self, 134 char key[SW_TEXT_RECORD_MAX_LEN], 135 char val[SW_TEXT_RECORD_MAX_LEN]); 136 137 138#if defined(__cplusplus) 139} 140#endif 141 142 143#endif 144