]> git.meshlink.io Git - catta/blob - avahi-compat-howl/include/discovery/text_record.h
a5ee802891d1f8f1fcc4060b452c6e4c2e9a3c71
[catta] / avahi-compat-howl / include / discovery / text_record.h
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)
35 extern "C"
36 {
37 #endif
38
39 #define SW_TEXT_RECORD_MAX_LEN 255
40
41
42 struct                                                                                                                  _sw_text_record;
43 typedef struct _sw_text_record                                          *       sw_text_record;
44 struct                                                                                                                  _sw_text_record_iterator;
45 typedef struct _sw_text_record_iterator                 *       sw_text_record_iterator;
46 struct                                                                                                                  _sw_text_record_string_iterator;
47 typedef struct _sw_text_record_string_iterator  *       sw_text_record_string_iterator;
48
49
50 /*
51  * Text record APIs
52  */
53 sw_result HOWL_API
54 sw_text_record_init(
55                                 sw_text_record  *       self);
56
57
58 sw_result HOWL_API
59 sw_text_record_fina(
60                                 sw_text_record          self);
61
62
63 sw_result HOWL_API
64 sw_text_record_add_string(
65                                 sw_text_record          self,
66                                 sw_const_string string);
67
68
69 sw_result HOWL_API
70 sw_text_record_add_key_and_string_value(
71                                 sw_text_record          self,
72                                 sw_const_string key,
73                                 sw_const_string val);
74
75
76 sw_result HOWL_API
77 sw_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
84 sw_octets HOWL_API
85 sw_text_record_bytes(
86                                 sw_text_record          self);
87
88
89 sw_uint32 HOWL_API
90 sw_text_record_len(
91                                 sw_text_record          self);
92
93
94 /*
95  * APIs for iterating through raw text records
96  */
97 sw_result HOWL_API
98 sw_text_record_iterator_init(
99                                 sw_text_record_iterator *       self,
100                                 sw_octets                                               text_record,
101                                 sw_uint32                                               text_record_len);
102
103
104 sw_result HOWL_API
105 sw_text_record_iterator_fina(
106                                 sw_text_record_iterator         self);
107
108
109 sw_result HOWL_API
110 sw_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  */
120 sw_result HOWL_API
121 sw_text_record_string_iterator_init(
122                                 sw_text_record_string_iterator  *       self,
123                                 sw_const_string                                                 text_record_string);
124
125
126 sw_result HOWL_API
127 sw_text_record_string_iterator_fina(
128                                 sw_text_record_string_iterator  self);
129
130
131 sw_result HOWL_API
132 sw_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