3 * Copyright (C) 2009 Sebastian Noack
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 * As a special exception, if you use inline functions from this file, this
20 * file does not by itself cause the resulting executable to be covered by
21 * the GNU Lesser General Public License.
24 * Sebastian Noack <sebastian.noack@gmail.com>
27 [CCode(cprefix="Ga", lower_case_cprefix="ga_")]
29 /* Network addresses */
32 [CCode(cheader_filename="avahi-common/address.h", cname="AvahiProtocol", cprefix="AVAHI_PROTO_", lower_case_cprefix="avahi_proto_", has_type_id = false)]
33 public enum Protocol {
38 [CCode(cname="avahi_af_to_proto")]
39 public static Protocol from_af(int af);
41 public unowned string to_string();
44 [CCode(cname="AVAHI_PROTO_VALID")]
45 public bool is_valid();
49 [CCode(cheader_filename="avahi-common/address.h", cname="AvahiIfIndex", has_type_id = false)]
50 public struct Interface {
51 [CCode(cname="AVAHI_IF_UNSPEC")]
52 public static Interface UNSPEC;
54 [CCode(cname="AVAHI_IF_VALID")]
55 public bool is_valid();
58 [CCode(cheader_filename="avahi-common/address.h", cname="AvahiAddress", cprefix="avahi_address_", has_type_id = false)]
59 public struct Address {
60 public Protocol proto;
62 [CCode(cname="AVAHI_ADDRESS_STR_MAX")]
63 public static size_t STR_MAX;
65 [CCode(cname="avahi_address_parse", instance_pos=-1)]
66 public Address.parse(string s, Protocol proto=Protocol.UNSPEC);
68 [CCode(cname="avahi_address_snprint", instance_pos=-1)]
69 public unowned string to_string(char[] dest=new char[STR_MAX]);
70 public int cmp(Address other);
74 /* Linked list of strings used for DNS TXT record data */
76 [CCode(cheader_filename="avahi-common/defs.h", cname="AVAHI_SERVICE_COOKIE_INVALID")]
77 public const uint32 SERVICE_COOKIE_INVALID;
80 [CCode(cheader_filename="avahi-common/strlst.h", cname="AvahiStringList", cprefix="avahi_string_list_", dup_function="avahi_string_list_copy", free_function="avahi_string_list_free")]
81 public class StringList {
82 public StringList next;
83 [CCode(array_length_cname="size")]
86 public StringList(string? txt=null, ...);
87 public StringList.from_array(string[] array);
89 [ReturnsModifiedPointer()]
90 public void add(string text);
91 [ReturnsModifiedPointer()]
93 public void add_printf(string format, ...);
94 [ReturnsModifiedPointer()]
95 public void add_arbitrary(char[] text);
96 [ReturnsModifiedPointer()]
97 public void add_anonymous(size_t size);
98 [ReturnsModifiedPointer()]
99 public void add_many(...);
101 public string to_string();
102 public int equal(StringList other);
103 public StringList copy();
104 [ReturnsModifiedPointer()]
105 public void reverse();
106 public uint length();
108 public unowned StringList find(string key);
109 public bool get_pair(out string key, out char[] value);
110 [ReturnsModifiedPointer()]
111 public void add_pair(string key, string? value);
112 [ReturnsModifiedPointer()]
113 public void add_pair_arbitrary(string key, char[] value);
114 public uint32 get_service_cookie();
116 [CCode(cname="avahi_string_list_serialize")]
117 private size_t _serialize(char[] dest);
118 [CCode(cname="avahi_string_list_serialize_dup")]
119 public char[] serialize() {
120 char[] dest = new char[this.length() * 256];
121 dest.length = (int) _serialize(dest);
125 [CCode(cname="avahi_string_list_parse")]
126 public static int deserialize (char[] data, out StringList dest);
130 /* Domain name utility functions */
132 [CCode(cheader_filename="avahi-common/domain.h", lower_case_cprefix="avahi_")]
134 public const size_t DOMAIN_NAME_MAX;
135 public const size_t LABEL_MAX;
137 [CCode(cname="avahi_normalize_name_strdup")]
138 public string normalize_name(string s);
139 [CCode(cname="avahi_domain_equal")]
140 public bool equal(string a, string b);
141 [CCode(cname="avahi_domain_hash")]
142 public uint hash(string name);
143 public unowned string? get_type_from_subtype(string s);
144 public unowned string? unescape_label(ref unowned string name, char[] dest=new char[LABEL_MAX]);
146 [CCode (cname="avahi_escape_label")]
147 private string? _escape_label(char* src, size_t src_len, ref char* dest, ref size_t dest_len);
148 [CCode (cname = "_vala_avahi_escape_label")]
149 public string? escape_label(string s) {
150 size_t len = LABEL_MAX * 4;
151 char* dest = new char[len];
152 return _escape_label(s, s.length, ref dest, ref len);
155 [CCode (cname = "avahi_service_name_join")]
156 public int _service_name_join ([CCode (array_length_type = "size_t")] uint8[] dest, string name, string type, string domain);
157 [CCode (cname = "_avahi_service_name_join")]
158 public int join_service_name (out string? dest, string name, string type, string domain) {
159 uint8[] dest_data = new uint8[DOMAIN_NAME_MAX];
160 int errno = _service_name_join (dest_data, name, type, domain);
161 dest = (errno >= 0) ? (string) dest_data : null;
165 [CCode (cname = "avahi_service_name_split")]
166 public int _service_name_split(string src, [CCode (array_length_type = "size_t")] uint8[] name, [CCode (array_length_type = "size_t")] uint8[] type, [CCode (array_length_type = "size_t")] uint8[] domain);
168 [CCode(cname = "_vala_avahi_service_name_split")]
169 public int split_service_name (string src, out string name, out string type, out string domain) {
170 uint8[] name_data = new uint8[LABEL_MAX];
171 uint8[] type_data = new uint8[DOMAIN_NAME_MAX];
172 uint8[] domain_data = new uint8[DOMAIN_NAME_MAX];
174 int errno = _service_name_split (src, name_data, type_data, domain_data);
177 name = (string) name_data;
178 type = (string) type_data;
179 domain = (string) domain_data;
185 public bool is_valid_service_type_generic(string s);
186 public bool is_valid_service_type_strict(string s);
187 public bool is_valid_service_subtype(string s);
188 public bool is_valid_domain_name(string s);
189 public bool is_valid_service_name(string s);
190 public bool is_valid_host_name(string s);
191 public bool is_valid_fqdn(string s);
193 [CCode(cheader_filename="avahi-common/address.h")]
194 public unowned string reverse_lookup_name(Address addr, char[] dest=new char[DOMAIN_NAME_MAX]);
197 [CCode(cheader_filename="avahi-common/alternative.h", lower_case_cprefix="avahi_alternative_")]
198 namespace Alternative {
199 public string host_name(string s);
200 public string service_name(string s);
207 [CCode(cheader_filename="avahi-common/defs.h", cname="AvahiPublishFlags", cprefix="AVAHI_PUBLISH_", has_type_id = false)]
208 public enum PublishFlags {