diff --git a/avahi-client/browser.c b/avahi-client/browser.c index fa4a9a8..c978d94 100644 --- a/avahi-client/browser.c +++ b/avahi-client/browser.c @@ -72,8 +72,6 @@ static void parse_domain_file(AvahiDomainBrowser *b) { if (avahi_normalize_name(buf, domain, sizeof(domain))) b->static_browse_domains = avahi_string_list_add(b->static_browse_domains, domain); } - - fclose(f); } static void domain_browser_ref(AvahiDomainBrowser *db) { diff --git a/avahi-daemon/chroot.c b/avahi-daemon/chroot.c index 871b3b3..ccd56be 100644 --- a/avahi-daemon/chroot.c +++ b/avahi-daemon/chroot.c @@ -188,8 +188,8 @@ static int recv_fd(int fd) { return -1; } - assert(h->cmsg_len == CMSG_LEN(sizeof(int))); - assert(h->cmsg_level == SOL_SOCKET); + assert(h->cmsg_len = CMSG_LEN(sizeof(int))); + assert(h->cmsg_level = SOL_SOCKET); assert(h->cmsg_type == SCM_RIGHTS); return *((int*)CMSG_DATA(h)); diff --git a/avahi-python/avahi-discover/Makefile.am b/avahi-python/avahi-discover/Makefile.am index bb4d717..5fc4b25 100644 --- a/avahi-python/avahi-discover/Makefile.am +++ b/avahi-python/avahi-discover/Makefile.am @@ -18,6 +18,7 @@ AM_CFLAGS=-I$(top_srcdir) EXTRA_DIST = \ + __init__.py \ avahi-discover.py \ avahi-discover.desktop.in.in @@ -30,11 +31,15 @@ pythonscripts = desktopdir = $(datadir)/applications desktop_DATA = +avahi_discoverdir = $(pythondir)/avahi_discover +avahi_discover_PYTHON = + if HAVE_GDBM pythonscripts += \ avahi-discover desktop_DATA += avahi-discover.desktop @INTLTOOL_DESKTOP_RULE@ +avahi_discover_PYTHON += __init__.py endif if HAVE_DBM @@ -42,6 +47,7 @@ pythonscripts += \ avahi-discover desktop_DATA += avahi-discover.desktop @INTLTOOL_DESKTOP_RULE@ +avahi_discover_PYTHON += __init__.py endif avahi-discover.desktop.in: avahi-discover.desktop.in.in diff --git a/avahi-python/avahi-discover/__init__.py b/avahi-python/avahi-discover/__init__.py new file mode 100755 index 0000000..6f3ec7f --- /dev/null +++ b/avahi-python/avahi-discover/__init__.py @@ -0,0 +1,18 @@ +#!@PYTHON@ +# -*-python-*- +# This file is part of avahi. +# +# avahi is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# avahi is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with avahi; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. diff --git a/avahi-python/avahi/Makefile.am b/avahi-python/avahi/Makefile.am index c906b9b..3eb67d0 100644 --- a/avahi-python/avahi/Makefile.am +++ b/avahi-python/avahi/Makefile.am @@ -25,16 +25,29 @@ avahidir = $(pythondir)/avahi if HAVE_GDBM nodist_avahi_SCRIPTS = ServiceTypeDatabase.py + +ServiceTypeDatabase.py: ServiceTypeDatabase.py.in + $(AM_V_GEN)sed -e 's,@PYTHON\@,$(PYTHON),g' \ + -e 's,@DBM\@,gdbm,g' \ + -e 's,@FIRST_KEY\@,key = self.db.firstkey(),g' \ + -e 's,@CHECK_KEY\@,while key is not None:,g' \ + -e 's,@NEXT_KEY\@,key = self.db.nextkey(key),g' \ + -e 's,@pkglibdatadir\@,$(pkglibdatadir),g' $< > $@ && \ + chmod +x $@ endif if HAVE_DBM nodist_avahi_SCRIPTS = ServiceTypeDatabase.py -endif ServiceTypeDatabase.py: ServiceTypeDatabase.py.in $(AM_V_GEN)sed -e 's,@PYTHON\@,$(PYTHON),g' \ + -e 's,@DBM\@,dbm,g' \ + -e 's,@FIRST_KEY\@,keys = self.db.keys(),g' \ + -e 's,@CHECK_KEY\@,for key in keys:,g' \ + -e 's,@NEXT_KEY\@,,g' \ -e 's,@pkglibdatadir\@,$(pkglibdatadir),g' $< > $@ && \ chmod +x $@ +endif avahi_PYTHON = $(avahi_SCRIPTS) diff --git a/avahi-python/avahi/ServiceTypeDatabase.py.in b/avahi-python/avahi/ServiceTypeDatabase.py.in index d7f9969..4ddd654 100644 --- a/avahi-python/avahi/ServiceTypeDatabase.py.in +++ b/avahi-python/avahi/ServiceTypeDatabase.py.in @@ -17,11 +17,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA. -try: - import anydbm as dbm -except ImportError: - import dbm - +import @DBM@ import locale import re @@ -32,7 +28,7 @@ class ServiceTypeDatabase: def __init__(self, filename = "@pkglibdatadir@/service-types.db"): - self.db = dbm.open(filename, "r") + self.db = @DBM@.open(filename, "r") l = locale.getlocale(locale.LC_MESSAGES) @@ -94,24 +90,13 @@ class ServiceTypeDatabase: def __iter__(self): - def want_key(key): - if not re.search('_[a-zA-Z0-9-]+\._[a-zA-Z0-9-]+', key): - return False - if re.search('_[a-zA-Z0-9-]+\._[a-zA-Z0-9-]+\[.*\]', key): - return False - return True - - try: - key = self.db.firstkey() - except AttributeError: - for key in self.db.keys(): - if want_key(key): - yield key - else: - while key is not None: - if want_key(key): - yield key - key = self.db.nextkey(key) + @FIRST_KEY@ + @CHECK_KEY@ + + if re.search('_[a-zA-Z0-9-]+\._[a-zA-Z0-9-]+', key) and not re.search('_[a-zA-Z0-9-]+\._[a-zA-Z0-9-]+\[.*\]', key): + yield key + + @NEXT_KEY@ def __len__(self): diff --git a/avahi-python/avahi/__init__.py b/avahi-python/avahi/__init__.py index 02305b0..7b45029 100644 --- a/avahi-python/avahi/__init__.py +++ b/avahi-python/avahi/__init__.py @@ -17,8 +17,6 @@ # Some definitions matching those in avahi-common/defs.h -import sys - import dbus SERVER_INVALID, SERVER_REGISTERING, SERVER_RUNNING, SERVER_COLLISION, SERVER_FAILURE = range(0, 5) @@ -68,9 +66,6 @@ DBUS_INTERFACE_HOST_NAME_RESOLVER = DBUS_NAME + ".HostNameResolver" DBUS_INTERFACE_SERVICE_RESOLVER = DBUS_NAME + ".ServiceResolver" DBUS_INTERFACE_RECORD_BROWSER = DBUS_NAME + ".RecordBrowser" -if sys.version_info[0] >= 3: - unicode = str - def byte_array_to_string(s): r = "" @@ -91,19 +86,12 @@ def txt_array_to_string_array(t): return l -def string_to_byte_array(s): - if isinstance(s, unicode): - s = s.encode('utf-8') +def string_to_byte_array(s): r = [] for c in s: - if isinstance(c, int): - # Python 3: iterating over bytes yields ints - r.append(dbus.Byte(c)) - else: - # Python 2: iterating over str yields str - r.append(dbus.Byte(ord(c))) + r.append(dbus.Byte(ord(c))) return r @@ -119,12 +107,6 @@ def dict_to_txt_array(txt_dict): l = [] for k,v in txt_dict.items(): - if isinstance(k, unicode): - k = k.encode('utf-8') - - if isinstance(v, unicode): - v = v.encode('utf-8') - - l.append(string_to_byte_array(b"%s=%s" % (k,v))) + l.append(string_to_byte_array("%s=%s" % (k,v))) return l diff --git a/avahi-sharp.pc.in b/avahi-sharp.pc.in index a604d93..3cc78b6 100644 --- a/avahi-sharp.pc.in +++ b/avahi-sharp.pc.in @@ -5,4 +5,4 @@ libdir=@libdir@ Name: avahi-sharp Description: Mono bindings for the Avahi mDNS/DNS-SD stack Version: @PACKAGE_VERSION@ -Libs: -r:${prefix}/lib/mono/avahi-sharp/avahi-sharp.dll +Libs: -r:${libdir}/mono/avahi-sharp/avahi-sharp.dll diff --git a/avahi-sharp/Makefile.am b/avahi-sharp/Makefile.am index 55dd912..1fdb1ca 100644 --- a/avahi-sharp/Makefile.am +++ b/avahi-sharp/Makefile.am @@ -73,10 +73,10 @@ monodoc_DATA = avahi-sharp-docs.zip avahi-sharp-docs.tree avahi-sharp-docs.sourc endif install-data-hook: $(ASSEMBLY) - $(AM_V_GEN)MONO_SHARED_DIR=. $(GACUTIL) /i $(ASSEMBLY) /package avahi-sharp /gacdir $(prefix)/lib /root $(DESTDIR)$(prefix)/lib + $(AM_V_GEN)MONO_SHARED_DIR=. $(GACUTIL) /i $(ASSEMBLY) /package avahi-sharp /gacdir $(libdir) /root $(DESTDIR)$(libdir) uninstall-hook: $(ASSEMBLY) - $(AM_V_GEN)MONO_SHARED_DIR=. $(GACUTIL) /u avahi-sharp /package avahi-sharp /gacdir $(prefix)/lib /root $(DESTDIR)$(prefix)/lib + $(AM_V_GEN)MONO_SHARED_DIR=. $(GACUTIL) /u avahi-sharp /package avahi-sharp /gacdir $(libdir) /root $(DESTDIR)$(libdir) endif endif diff --git a/avahi-ui-sharp.pc.in b/avahi-ui-sharp.pc.in index f73d049..cdc35e0 100644 --- a/avahi-ui-sharp.pc.in +++ b/avahi-ui-sharp.pc.in @@ -6,4 +6,4 @@ Name: avahi-ui-sharp Description: Mono bindings for the Avahi mDNS/DNS-SD stack Version: @PACKAGE_VERSION@ Requires: gtk-sharp-2.0 -Libs: -r:${prefix}/lib/mono/avahi-ui-sharp/avahi-ui-sharp.dll +Libs: -r:${libdir}/mono/avahi-ui-sharp/avahi-ui-sharp.dll diff --git a/avahi-ui-sharp/Makefile.am b/avahi-ui-sharp/Makefile.am index c7e2765..28ea64f 100644 --- a/avahi-ui-sharp/Makefile.am +++ b/avahi-ui-sharp/Makefile.am @@ -60,10 +60,10 @@ monodoc_DATA = avahi-ui-sharp-docs.zip avahi-ui-sharp-docs.tree avahi-ui-sharp-d endif install-data-hook: $(ASSEMBLY) - $(GACUTIL) /i $(ASSEMBLY) /package avahi-ui-sharp /gacdir $(prefix)/lib /root $(DESTDIR)$(prefix)/lib + $(GACUTIL) /i $(ASSEMBLY) /package avahi-ui-sharp /gacdir $(libdir) /root $(DESTDIR)$(libdir) uninstall-hook: $(ASSEMBLY) - $(GACUTIL) /u avahi-ui-sharp /package avahi-ui-sharp /gacdir $(prefix)/lib /root $(DESTDIR)$(prefix)/lib + $(GACUTIL) /u avahi-ui-sharp /package avahi-ui-sharp /gacdir $(libdir) /root $(DESTDIR)$(libdir) endif endif diff --git a/configure.ac b/configure.ac index fbbf7cf..6678971 100644 --- a/configure.ac +++ b/configure.ac @@ -824,10 +824,11 @@ if test "x$HAVE_PYTHON" = "xyes" ; then fi AM_CHECK_PYMOD(socket,,,[AC_MSG_ERROR(Could not find Python module socket)]) - if test "x$HAVE_GDBM" = "xyes" || test "x$HAVE_DBM" = "xyes"; then - AM_CHECK_PYMOD(anydbm,,,[ - AM_CHECK_PYMOD(dbm,,,[AC_MSG_ERROR(Could not find Python module dbm)]) - ]) + if test "x$HAVE_GDBM" = "xyes"; then + AM_CHECK_PYMOD(gdbm,,,[AC_MSG_ERROR(Could not find Python module gdbm)]) + fi + if test "x$HAVE_DBM" = "xyes"; then + AM_CHECK_PYMOD(dbm,,,[AC_MSG_ERROR(Could not find Python module dbm)]) fi fi fi diff --git a/service-type-database/Makefile.am b/service-type-database/Makefile.am index f9fa082..d184fde 100644 --- a/service-type-database/Makefile.am +++ b/service-type-database/Makefile.am @@ -15,7 +15,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA. -EXTRA_DIST=service-types +EXTRA_DIST=build-db.in service-types pkglibdatadir=$(libdir)/avahi @@ -27,11 +27,16 @@ if HAVE_GDBM noinst_SCRIPTS=build-db pkglibdata_DATA+=service-types.db -service-types.db: service-types +build-db: build-db.in + $(AM_V_GEN)sed -e 's,@PYTHON\@,$(PYTHON),g' \ + -e 's,@DBM\@,gdbm,g' $< > $@ && \ + chmod +x $@ + +service-types.db: service-types build-db $(AM_V_GEN)$(PYTHON) build-db $< $@.coming && \ mv $@.coming $@ -CLEANFILES = service-types.db +CLEANFILES = service-types.db build-db endif if HAVE_DBM @@ -39,6 +44,11 @@ if HAVE_DBM noinst_SCRIPTS=build-db pkglibdata_DATA+=service-types.db.pag service-types.db.dir +build-db: build-db.in + $(AM_V_GEN)sed -e 's,@PYTHON\@,$(PYTHON),g' \ + -e 's,@DBM\@,dbm,g' $< > $@ && \ + chmod +x $@ + service-types.db.pag: service-types.db $(AM_V_GEN)mv service-types.db.coming.pag service-types.db.pag service-types.db.dir: service-types.db @@ -47,7 +57,7 @@ service-types.db: service-types build-db $(AM_V_GEN)$(PYTHON) build-db $< $@.coming && \ if test -f "$@.coming"; then mv $@.coming $@; fi -CLEANFILES = service-types.db* +CLEANFILES = service-types.db* build-db endif endif diff --git a/service-type-database/build-db b/service-type-database/build-db deleted file mode 100755 index 78ee892..0000000 --- a/service-type-database/build-db +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python -# -*-python-*- -# This file is part of avahi. -# -# avahi is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# avahi is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. - -try: - import anydbm as dbm -except ImportError: - import dbm - -import sys - -if len(sys.argv) > 1: - infn = sys.argv[1] -else: - infn = "service-types" - -if len(sys.argv) > 2: - outfn = sys.argv[2] -else: - outfn = infn + ".db" - -db = dbm.open(outfn, "n") - -for ln in open(infn, "r"): - ln = ln.strip(" \r\n\t") - - if ln == "" or ln.startswith("#"): - continue - - t, n = ln.split(":", 1) - - db[t.strip()] = n.strip() - -db.close() diff --git a/service-type-database/build-db.in b/service-type-database/build-db.in new file mode 100755 index 0000000..4cda425 --- /dev/null +++ b/service-type-database/build-db.in @@ -0,0 +1,44 @@ +#!@PYTHON@ +# -*-python-*- +# This file is part of avahi. +# +# avahi is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# avahi is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with avahi; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. + +import @DBM@, sys + +if len(sys.argv) > 1: + infn = sys.argv[1] +else: + infn = "service-types" + +if len(sys.argv) > 2: + outfn = sys.argv[2] +else: + outfn = infn + ".db" + +db = @DBM@.open(outfn, "n") + +for ln in file(infn, "r"): + ln = ln.strip(" \r\n\t") + + if ln == "" or ln.startswith("#"): + continue + + t, n = ln.split(":", 1) + + db[t.strip()] = n.strip() + +db.close()