return 0;
}
+
+AvahiStringList *avahi_string_list_get_next(AvahiStringList *l) {
+ assert(l);
+ return l->next;
+}
+
+const uint8_t *avahi_string_list_get_text(AvahiStringList *l) {
+ assert(l);
+ return l->text;
+}
+
+size_t avahi_string_list_get_size(AvahiStringList *l) {
+ assert(l);
+ return l->size;
+}
/** Same as avahi_string_list_add_pair() but allow strings containing NUL bytes in *value. */
AvahiStringList *avahi_string_list_add_pair_arbitrary(AvahiStringList *l, const char *key, const uint8_t *value, size_t size);
+/** Returns the next item in the string list */
+AvahiStringList *avahi_string_list_get_next(AvahiStringList *l);
+
+/** Returns the text for the current item */
+const uint8_t *avahi_string_list_get_text(AvahiStringList *l);
+
+/** Returns the size of the current text */
+size_t avahi_string_list_get_size(AvahiStringList *l);
+
AVAHI_C_DECL_END
#endif
***/
using System;
+using System.Text;
using System.Net;
using Gtk;
using Avahi;
private static void OnServiceResolved (object o, ServiceInfo info)
{
Console.WriteLine ("Service '{0}' at {1}:{2}", info.Name, info.Host, info.Port);
+ foreach (byte[] bytes in info.Text) {
+ Console.WriteLine ("Text: " + Encoding.UTF8.GetString (bytes));
+ }
AddressResolver ar = new AddressResolver (client, info.Address);
ar.Found += OnAddressResolved;
}
Protocol aproto, ServiceResolverCallback cb,
IntPtr userdata);
+ [DllImport ("avahi-common")]
+ private static extern IntPtr avahi_string_list_get_next (IntPtr list);
+
+ [DllImport ("avahi-common")]
+ private static extern IntPtr avahi_string_list_get_text (IntPtr list);
+
+ [DllImport ("avahi-common")]
+ private static extern int avahi_string_list_get_size (IntPtr list);
+
[DllImport ("avahi-client")]
private static extern void avahi_service_resolver_free (IntPtr handle);
info.Host = Utility.PtrToString (host);
info.Address = Utility.PtrToAddress (address);
info.Port = port;
- info.Text = null;
+ ArrayList txtlist = new ArrayList ();
+ for (IntPtr l = txt; l != IntPtr.Zero; l = avahi_string_list_get_next (l)) {
+ IntPtr buf = avahi_string_list_get_text (l);
+ int len = avahi_string_list_get_size (l);
+
+ byte[] txtbuf = new byte[len];
+ Marshal.Copy (buf, txtbuf, 0, len);
+ txtlist.Add (txtbuf);
+ }
+
+ info.Text = (byte[][]) txtlist.ToArray (typeof (byte[]));
+
if (revent == ResolverEvent.Found) {
currentInfo = info;