diff options
Diffstat (limited to 'avahi-utils/avahi')
-rw-r--r-- | avahi-utils/avahi/__init__.py | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/avahi-utils/avahi/__init__.py b/avahi-utils/avahi/__init__.py index c68e177..90d2b76 100644 --- a/avahi-utils/avahi/__init__.py +++ b/avahi-utils/avahi/__init__.py @@ -18,7 +18,7 @@ # USA. # Some definitions matching those in core.h -import socket +import socket, dbus SERVER_INVALID, SERVER_REGISTERING, SERVER_RUNNING, SERVER_COLLISION = range(-1, 3) @@ -37,3 +37,40 @@ DBUS_INTERFACE_ENTRY_GROUP = DBUS_NAME + ".EntryGroup" DBUS_INTERFACE_DOMAIN_BROWSER = DBUS_NAME + ".DomainBrowser" DBUS_INTERFACE_SERVICE_TYPE_BROWSER = DBUS_NAME + ".ServiceTypeBrowser" DBUS_INTERFACE_SERVICE_BROWSER = DBUS_NAME + ".ServiceBrowser" + +def byte_array_to_string(s): + r = "" + + for c in s: + + if c >= 32 and c < 127: + r += "%c" % c + else: + r += "." + + return r + +def txt_array_to_string_array(t): + l = [] + + for s in t: + l.append(byte_array_to_string(s)) + + return l + + +def string_to_byte_array(s): + r = [] + + for c in s: + r.append(dbus.Byte(ord(c))) + + return r + +def string_array_to_txt_array(t): + l = [] + + for s in t: + l.append(string_to_byte_array(s)) + + return l |