From a22197b0ff85b98d3183cc644c867394db16ca5b Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 10 Mar 2023 18:32:52 +1000 Subject: [PATCH] Updated third_party & libgamestream Contains the latest versions of third_party including: h265bitstream, ilclient, libsec, moonlight-common-c. Contains the latest versions of libgamestream including: avahi-client, avahi-common, uuid. Contains .elf & .rpx compiled from updated libraries. Tested with GFE 3.27.0.112 --- cmake/FindAmlogic.cmake | 16 +- libgamestream/avahi-client/Makefile.am | 83 + libgamestream/avahi-client/Makefile.in | 1152 ++++++++++++ libgamestream/avahi-client/browser.c | 1025 +++++++++++ libgamestream/avahi-client/check-nss-test.c | 31 + libgamestream/avahi-client/check-nss.c | 55 + libgamestream/avahi-client/client-test.c | 328 ++++ libgamestream/avahi-client/client.c | 958 ++++++++++ libgamestream/avahi-client/client.h | 117 ++ libgamestream/avahi-client/entrygroup.c | 890 ++++++++++ libgamestream/avahi-client/internal.h | 172 ++ libgamestream/avahi-client/lookup.h | 324 ++++ libgamestream/avahi-client/publish.h | 172 ++ libgamestream/avahi-client/resolver.c | 778 +++++++++ libgamestream/avahi-client/rr-test.c | 111 ++ libgamestream/avahi-client/srv-test.c | 76 + libgamestream/avahi-client/xdg-config-test.c | 38 + libgamestream/avahi-client/xdg-config.c | 68 + libgamestream/avahi-client/xdg-config.h | 27 + libgamestream/avahi-common/Makefile.am | 129 ++ libgamestream/avahi-common/Makefile.in | 1551 +++++++++++++++++ libgamestream/avahi-common/address.c | 155 ++ libgamestream/avahi-common/address.h | 119 ++ libgamestream/avahi-common/alternative-test.c | 90 + libgamestream/avahi-common/alternative.c | 182 ++ libgamestream/avahi-common/alternative.h | 43 + libgamestream/avahi-common/cdecl.h | 38 + libgamestream/avahi-common/dbus-watch-glue.c | 357 ++++ libgamestream/avahi-common/dbus-watch-glue.h | 33 + libgamestream/avahi-common/dbus.c | 138 ++ libgamestream/avahi-common/dbus.h | 121 ++ libgamestream/avahi-common/defs.h | 356 ++++ libgamestream/avahi-common/domain-test.c | 123 ++ libgamestream/avahi-common/domain.c | 609 +++++++ libgamestream/avahi-common/domain.h | 129 ++ libgamestream/avahi-common/error.c | 97 ++ libgamestream/avahi-common/error.h | 107 ++ libgamestream/avahi-common/gccmacro.h | 74 + libgamestream/avahi-common/i18n.c | 38 + libgamestream/avahi-common/i18n.h | 53 + libgamestream/avahi-common/llist.h | 75 + libgamestream/avahi-common/malloc.c | 257 +++ libgamestream/avahi-common/malloc.h | 96 + libgamestream/avahi-common/rlist.c | 62 + libgamestream/avahi-common/rlist.h | 49 + libgamestream/avahi-common/simple-watch.c | 649 +++++++ libgamestream/avahi-common/simple-watch.h | 85 + libgamestream/avahi-common/strlst-test.c | 128 ++ libgamestream/avahi-common/strlst.c | 565 ++++++ libgamestream/avahi-common/strlst.h | 180 ++ libgamestream/avahi-common/thread-watch.c | 186 ++ libgamestream/avahi-common/thread-watch.h | 80 + libgamestream/avahi-common/timeval-test.c | 43 + libgamestream/avahi-common/timeval.c | 123 ++ libgamestream/avahi-common/timeval.h | 54 + libgamestream/avahi-common/utf8-test.c | 37 + libgamestream/avahi-common/utf8.c | 110 ++ libgamestream/avahi-common/utf8.h | 33 + libgamestream/avahi-common/watch-test.c | 115 ++ libgamestream/avahi-common/watch.h | 97 ++ libgamestream/client.c | 83 +- libgamestream/client.h | 1 + libgamestream/discover.c | 4 - libgamestream/http.c | 3 - libgamestream/uuid/COPYING | 5 + libgamestream/uuid/all-io.h | 82 + libgamestream/uuid/c.h | 318 ++++ libgamestream/uuid/clear.c | 43 + libgamestream/uuid/compare.c | 55 + libgamestream/uuid/config.h | 153 ++ libgamestream/uuid/copy.c | 45 + libgamestream/uuid/gen_uuid.c | 599 +++++++ libgamestream/uuid/isnull.c | 48 + libgamestream/uuid/pack.c | 69 + libgamestream/uuid/parse.c | 79 + libgamestream/uuid/randutils.c | 131 ++ libgamestream/uuid/randutils.h | 12 + libgamestream/uuid/unpack.c | 63 + libgamestream/uuid/unparse.c | 76 + libgamestream/uuid/uuid.h | 104 ++ libgamestream/uuid/uuidP.h | 61 + libgamestream/uuid/uuidd.h | 54 + libgamestream/xml.c | 2 - src/wiiu/wiiu.h | 2 +- third_party/h264bitstream/h264_stream.c | 896 +--------- 85 files changed, 15998 insertions(+), 977 deletions(-) create mode 100644 libgamestream/avahi-client/Makefile.am create mode 100644 libgamestream/avahi-client/Makefile.in create mode 100644 libgamestream/avahi-client/browser.c create mode 100644 libgamestream/avahi-client/check-nss-test.c create mode 100644 libgamestream/avahi-client/check-nss.c create mode 100644 libgamestream/avahi-client/client-test.c create mode 100644 libgamestream/avahi-client/client.c create mode 100644 libgamestream/avahi-client/client.h create mode 100644 libgamestream/avahi-client/entrygroup.c create mode 100644 libgamestream/avahi-client/internal.h create mode 100644 libgamestream/avahi-client/lookup.h create mode 100644 libgamestream/avahi-client/publish.h create mode 100644 libgamestream/avahi-client/resolver.c create mode 100644 libgamestream/avahi-client/rr-test.c create mode 100644 libgamestream/avahi-client/srv-test.c create mode 100644 libgamestream/avahi-client/xdg-config-test.c create mode 100644 libgamestream/avahi-client/xdg-config.c create mode 100644 libgamestream/avahi-client/xdg-config.h create mode 100644 libgamestream/avahi-common/Makefile.am create mode 100644 libgamestream/avahi-common/Makefile.in create mode 100644 libgamestream/avahi-common/address.c create mode 100644 libgamestream/avahi-common/address.h create mode 100644 libgamestream/avahi-common/alternative-test.c create mode 100644 libgamestream/avahi-common/alternative.c create mode 100644 libgamestream/avahi-common/alternative.h create mode 100644 libgamestream/avahi-common/cdecl.h create mode 100644 libgamestream/avahi-common/dbus-watch-glue.c create mode 100644 libgamestream/avahi-common/dbus-watch-glue.h create mode 100644 libgamestream/avahi-common/dbus.c create mode 100644 libgamestream/avahi-common/dbus.h create mode 100644 libgamestream/avahi-common/defs.h create mode 100644 libgamestream/avahi-common/domain-test.c create mode 100644 libgamestream/avahi-common/domain.c create mode 100644 libgamestream/avahi-common/domain.h create mode 100644 libgamestream/avahi-common/error.c create mode 100644 libgamestream/avahi-common/error.h create mode 100644 libgamestream/avahi-common/gccmacro.h create mode 100644 libgamestream/avahi-common/i18n.c create mode 100644 libgamestream/avahi-common/i18n.h create mode 100644 libgamestream/avahi-common/llist.h create mode 100644 libgamestream/avahi-common/malloc.c create mode 100644 libgamestream/avahi-common/malloc.h create mode 100644 libgamestream/avahi-common/rlist.c create mode 100644 libgamestream/avahi-common/rlist.h create mode 100644 libgamestream/avahi-common/simple-watch.c create mode 100644 libgamestream/avahi-common/simple-watch.h create mode 100644 libgamestream/avahi-common/strlst-test.c create mode 100644 libgamestream/avahi-common/strlst.c create mode 100644 libgamestream/avahi-common/strlst.h create mode 100644 libgamestream/avahi-common/thread-watch.c create mode 100644 libgamestream/avahi-common/thread-watch.h create mode 100644 libgamestream/avahi-common/timeval-test.c create mode 100644 libgamestream/avahi-common/timeval.c create mode 100644 libgamestream/avahi-common/timeval.h create mode 100644 libgamestream/avahi-common/utf8-test.c create mode 100644 libgamestream/avahi-common/utf8.c create mode 100644 libgamestream/avahi-common/utf8.h create mode 100644 libgamestream/avahi-common/watch-test.c create mode 100644 libgamestream/avahi-common/watch.h create mode 100644 libgamestream/uuid/COPYING create mode 100644 libgamestream/uuid/all-io.h create mode 100644 libgamestream/uuid/c.h create mode 100644 libgamestream/uuid/clear.c create mode 100644 libgamestream/uuid/compare.c create mode 100644 libgamestream/uuid/config.h create mode 100644 libgamestream/uuid/copy.c create mode 100644 libgamestream/uuid/gen_uuid.c create mode 100644 libgamestream/uuid/isnull.c create mode 100644 libgamestream/uuid/pack.c create mode 100644 libgamestream/uuid/parse.c create mode 100644 libgamestream/uuid/randutils.c create mode 100644 libgamestream/uuid/randutils.h create mode 100644 libgamestream/uuid/unpack.c create mode 100644 libgamestream/uuid/unparse.c create mode 100644 libgamestream/uuid/uuid.h create mode 100644 libgamestream/uuid/uuidP.h create mode 100644 libgamestream/uuid/uuidd.h diff --git a/cmake/FindAmlogic.cmake b/cmake/FindAmlogic.cmake index df8bda42..0f731f03 100644 --- a/cmake/FindAmlogic.cmake +++ b/cmake/FindAmlogic.cmake @@ -4,18 +4,6 @@ find_path(AMLOGIC_INCLUDE_DIR PATHS /usr/local/include/amcodec /usr/osmc/include/amcodec /usr/include/amcodec /usr/include/) mark_as_advanced(AMLOGIC_INCLUDE_DIR) -find_library(AMAVUTILS_LIBRARY - NAMES libamavutils.so - DOC "Path to Amlogic Audio Video Utils Library" - PATHS /usr/lib/aml_libs /usr/osmc/lib /usr/local/lib /usr/lib) -mark_as_advanced(AMAVUTILS_LIBRARY) - -find_library(AMADEC_LIBRARY - NAMES libamadec.so - DOC "Path to Amlogic Audio Decoder Library" - PATHS /usr/lib/aml_libs /usr/osmc/lib /usr/local/lib /usr/lib) -mark_as_advanced(AMADEC_LIBRARY) - find_library(AMCODEC_LIBRARY NAMES libamcodec.so DOC "Path to Amlogic Video Codec Library" @@ -23,7 +11,7 @@ find_library(AMCODEC_LIBRARY mark_as_advanced(AMCODEC_LIBRARY) include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Amlogic DEFAULT_MSG AMLOGIC_INCLUDE_DIR AMCODEC_LIBRARY AMADEC_LIBRARY AMAVUTILS_LIBRARY) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Amlogic DEFAULT_MSG AMLOGIC_INCLUDE_DIR AMCODEC_LIBRARY) -set(AMLOGIC_LIBRARIES ${AMCODEC_LIBRARY} ${AMADEC_LIBRARY} ${AMAVUTILS_LIBRARY}) +set(AMLOGIC_LIBRARIES ${AMCODEC_LIBRARY}) set(AMLOGIC_INCLUDE_DIRS ${AMLOGIC_INCLUDE_DIR}) diff --git a/libgamestream/avahi-client/Makefile.am b/libgamestream/avahi-client/Makefile.am new file mode 100644 index 00000000..f11b11d7 --- /dev/null +++ b/libgamestream/avahi-client/Makefile.am @@ -0,0 +1,83 @@ +# 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. + +AM_CFLAGS=-I$(top_srcdir) + +# This cool debug trap works on i386/gcc only +AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")' + +if HAVE_DBUS + +avahi_clientincludedir=$(includedir)/avahi-client +avahi_clientinclude_HEADERS = client.h lookup.h publish.h + +noinst_HEADERS = internal.h + +if ENABLE_TESTS + +noinst_PROGRAMS = \ + client-test \ + srv-test \ + xdg-config-test \ + rr-test \ + check-nss-test + +endif + +lib_LTLIBRARIES = libavahi-client.la + +libavahi_client_la_SOURCES = \ + client.c client.h \ + entrygroup.c \ + browser.c \ + resolver.c \ + publish.h lookup.h \ + xdg-config.c xdg-config.h \ + check-nss.c \ + ../avahi-common/dbus.c ../avahi-common/dbus.h \ + ../avahi-common/dbus-watch-glue.c ../avahi-common/dbus-watch-glue.h + +libavahi_client_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS) -DDBUS_SYSTEM_BUS_DEFAULT_ADDRESS=\"$(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS)\" +libavahi_client_la_LIBADD = $(AM_LDADD) $(DBUS_LIBS) ../avahi-common/libavahi-common.la +libavahi_client_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBAVAHI_CLIENT_VERSION_INFO) + +client_test_SOURCES = client-test.c +client_test_CFLAGS = $(AM_CFLAGS) +client_test_LDADD = $(AM_LDADD) libavahi-client.la ../avahi-common/libavahi-common.la + +srv_test_SOURCES = srv-test.c +srv_test_CFLAGS = $(AM_CFLAGS) +srv_test_LDADD = $(AM_LDADD) libavahi-client.la ../avahi-common/libavahi-common.la + +rr_test_SOURCES = rr-test.c +rr_test_CFLAGS = $(AM_CFLAGS) +rr_test_LDADD = $(AM_LDADD) libavahi-client.la ../avahi-common/libavahi-common.la + +xdg_config_test_SOURCES = xdg-config-test.c xdg-config.c xdg-config.h +xdg_config_test_CFLAGS = $(AM_CFLAGS) +xdg_config_test_LDADD = $(AM_LDADD) + +check_nss_test_SOURCES = check-nss.c check-nss-test.c client.h +check_nss_test_CFLAGS = $(AM_CFLAGS) +check_nss_test_LDADD = $(AM_LDADD) + +if HAVE_DLOPEN +check_nss_test_LDADD += -ldl +libavahi_client_la_LIBADD += -ldl +endif + +endif diff --git a/libgamestream/avahi-client/Makefile.in b/libgamestream/avahi-client/Makefile.in new file mode 100644 index 00000000..42d991f9 --- /dev/null +++ b/libgamestream/avahi-client/Makefile.in @@ -0,0 +1,1152 @@ +# Makefile.in generated by automake 1.15.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2017 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# 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. + + + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +@ENABLE_TESTS_TRUE@@HAVE_DBUS_TRUE@noinst_PROGRAMS = \ +@ENABLE_TESTS_TRUE@@HAVE_DBUS_TRUE@ client-test$(EXEEXT) \ +@ENABLE_TESTS_TRUE@@HAVE_DBUS_TRUE@ srv-test$(EXEEXT) \ +@ENABLE_TESTS_TRUE@@HAVE_DBUS_TRUE@ xdg-config-test$(EXEEXT) \ +@ENABLE_TESTS_TRUE@@HAVE_DBUS_TRUE@ rr-test$(EXEEXT) \ +@ENABLE_TESTS_TRUE@@HAVE_DBUS_TRUE@ check-nss-test$(EXEEXT) +@HAVE_DBUS_TRUE@@HAVE_DLOPEN_TRUE@am__append_1 = -ldl +@HAVE_DBUS_TRUE@@HAVE_DLOPEN_TRUE@am__append_2 = -ldl +subdir = avahi-client +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/common/acx_pthread.m4 \ + $(top_srcdir)/common/gcc_stack_protect.m4 \ + $(top_srcdir)/common/gcc_visibility.m4 \ + $(top_srcdir)/common/gettext.m4 $(top_srcdir)/common/iconv.m4 \ + $(top_srcdir)/common/introspection.m4 \ + $(top_srcdir)/common/lib-ld.m4 \ + $(top_srcdir)/common/lib-link.m4 \ + $(top_srcdir)/common/lib-prefix.m4 \ + $(top_srcdir)/common/libtool.m4 \ + $(top_srcdir)/common/ltoptions.m4 \ + $(top_srcdir)/common/ltsugar.m4 \ + $(top_srcdir)/common/ltversion.m4 \ + $(top_srcdir)/common/lt~obsolete.m4 \ + $(top_srcdir)/common/nls.m4 $(top_srcdir)/common/po.m4 \ + $(top_srcdir)/common/progtest.m4 \ + $(top_srcdir)/common/python.m4 $(top_srcdir)/common/qt5-pie.m4 \ + $(top_srcdir)/acinclude.m4 $(top_srcdir)/common/doxygen.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am \ + $(am__avahi_clientinclude_HEADERS_DIST) \ + $(am__noinst_HEADERS_DIST) $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(libdir)" \ + "$(DESTDIR)$(avahi_clientincludedir)" +LTLIBRARIES = $(lib_LTLIBRARIES) +am__DEPENDENCIES_1 = +@HAVE_DBUS_TRUE@libavahi_client_la_DEPENDENCIES = \ +@HAVE_DBUS_TRUE@ $(am__DEPENDENCIES_1) \ +@HAVE_DBUS_TRUE@ ../avahi-common/libavahi-common.la \ +@HAVE_DBUS_TRUE@ $(am__DEPENDENCIES_1) +am__libavahi_client_la_SOURCES_DIST = client.c client.h entrygroup.c \ + browser.c resolver.c publish.h lookup.h xdg-config.c \ + xdg-config.h check-nss.c ../avahi-common/dbus.c \ + ../avahi-common/dbus.h ../avahi-common/dbus-watch-glue.c \ + ../avahi-common/dbus-watch-glue.h +@HAVE_DBUS_TRUE@am_libavahi_client_la_OBJECTS = \ +@HAVE_DBUS_TRUE@ libavahi_client_la-client.lo \ +@HAVE_DBUS_TRUE@ libavahi_client_la-entrygroup.lo \ +@HAVE_DBUS_TRUE@ libavahi_client_la-browser.lo \ +@HAVE_DBUS_TRUE@ libavahi_client_la-resolver.lo \ +@HAVE_DBUS_TRUE@ libavahi_client_la-xdg-config.lo \ +@HAVE_DBUS_TRUE@ libavahi_client_la-check-nss.lo \ +@HAVE_DBUS_TRUE@ libavahi_client_la-dbus.lo \ +@HAVE_DBUS_TRUE@ libavahi_client_la-dbus-watch-glue.lo +libavahi_client_la_OBJECTS = $(am_libavahi_client_la_OBJECTS) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +libavahi_client_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(libavahi_client_la_CFLAGS) $(CFLAGS) \ + $(libavahi_client_la_LDFLAGS) $(LDFLAGS) -o $@ +@HAVE_DBUS_TRUE@am_libavahi_client_la_rpath = -rpath $(libdir) +PROGRAMS = $(noinst_PROGRAMS) +am__check_nss_test_SOURCES_DIST = check-nss.c check-nss-test.c \ + client.h +@HAVE_DBUS_TRUE@am_check_nss_test_OBJECTS = \ +@HAVE_DBUS_TRUE@ check_nss_test-check-nss.$(OBJEXT) \ +@HAVE_DBUS_TRUE@ check_nss_test-check-nss-test.$(OBJEXT) +check_nss_test_OBJECTS = $(am_check_nss_test_OBJECTS) +@HAVE_DBUS_TRUE@check_nss_test_DEPENDENCIES = $(am__DEPENDENCIES_1) +check_nss_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(check_nss_test_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o \ + $@ +am__client_test_SOURCES_DIST = client-test.c +@HAVE_DBUS_TRUE@am_client_test_OBJECTS = \ +@HAVE_DBUS_TRUE@ client_test-client-test.$(OBJEXT) +client_test_OBJECTS = $(am_client_test_OBJECTS) +@HAVE_DBUS_TRUE@client_test_DEPENDENCIES = libavahi-client.la \ +@HAVE_DBUS_TRUE@ ../avahi-common/libavahi-common.la +client_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(client_test_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +am__rr_test_SOURCES_DIST = rr-test.c +@HAVE_DBUS_TRUE@am_rr_test_OBJECTS = rr_test-rr-test.$(OBJEXT) +rr_test_OBJECTS = $(am_rr_test_OBJECTS) +@HAVE_DBUS_TRUE@rr_test_DEPENDENCIES = libavahi-client.la \ +@HAVE_DBUS_TRUE@ ../avahi-common/libavahi-common.la +rr_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(rr_test_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +am__srv_test_SOURCES_DIST = srv-test.c +@HAVE_DBUS_TRUE@am_srv_test_OBJECTS = srv_test-srv-test.$(OBJEXT) +srv_test_OBJECTS = $(am_srv_test_OBJECTS) +@HAVE_DBUS_TRUE@srv_test_DEPENDENCIES = libavahi-client.la \ +@HAVE_DBUS_TRUE@ ../avahi-common/libavahi-common.la +srv_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(srv_test_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +am__xdg_config_test_SOURCES_DIST = xdg-config-test.c xdg-config.c \ + xdg-config.h +@HAVE_DBUS_TRUE@am_xdg_config_test_OBJECTS = \ +@HAVE_DBUS_TRUE@ xdg_config_test-xdg-config-test.$(OBJEXT) \ +@HAVE_DBUS_TRUE@ xdg_config_test-xdg-config.$(OBJEXT) +xdg_config_test_OBJECTS = $(am_xdg_config_test_OBJECTS) +xdg_config_test_DEPENDENCIES = +xdg_config_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(xdg_config_test_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(libavahi_client_la_SOURCES) $(check_nss_test_SOURCES) \ + $(client_test_SOURCES) $(rr_test_SOURCES) $(srv_test_SOURCES) \ + $(xdg_config_test_SOURCES) +DIST_SOURCES = $(am__libavahi_client_la_SOURCES_DIST) \ + $(am__check_nss_test_SOURCES_DIST) \ + $(am__client_test_SOURCES_DIST) $(am__rr_test_SOURCES_DIST) \ + $(am__srv_test_SOURCES_DIST) \ + $(am__xdg_config_test_SOURCES_DIST) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__avahi_clientinclude_HEADERS_DIST = client.h lookup.h publish.h +am__noinst_HEADERS_DIST = internal.h +HEADERS = $(avahi_clientinclude_HEADERS) $(noinst_HEADERS) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AVAHI_AUTOIPD_GROUP = @AVAHI_AUTOIPD_GROUP@ +AVAHI_AUTOIPD_USER = @AVAHI_AUTOIPD_USER@ +AVAHI_GROUP = @AVAHI_GROUP@ +AVAHI_PRIV_ACCESS_GROUP = @AVAHI_PRIV_ACCESS_GROUP@ +AVAHI_USER = @AVAHI_USER@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DBUS_SYSTEM_BUS_DEFAULT_ADDRESS = @DBUS_SYSTEM_BUS_DEFAULT_ADDRESS@ +DBUS_SYS_DIR = @DBUS_SYS_DIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +DX_CONFIG = @DX_CONFIG@ +DX_DOCDIR = @DX_DOCDIR@ +DX_DOT = @DX_DOT@ +DX_DOXYGEN = @DX_DOXYGEN@ +DX_DVIPS = @DX_DVIPS@ +DX_EGREP = @DX_EGREP@ +DX_ENV = @DX_ENV@ +DX_FLAG_chi = @DX_FLAG_chi@ +DX_FLAG_chm = @DX_FLAG_chm@ +DX_FLAG_doc = @DX_FLAG_doc@ +DX_FLAG_dot = @DX_FLAG_dot@ +DX_FLAG_html = @DX_FLAG_html@ +DX_FLAG_man = @DX_FLAG_man@ +DX_FLAG_pdf = @DX_FLAG_pdf@ +DX_FLAG_ps = @DX_FLAG_ps@ +DX_FLAG_rtf = @DX_FLAG_rtf@ +DX_FLAG_xml = @DX_FLAG_xml@ +DX_HHC = @DX_HHC@ +DX_LATEX = @DX_LATEX@ +DX_MAKEINDEX = @DX_MAKEINDEX@ +DX_PDFLATEX = @DX_PDFLATEX@ +DX_PERL = @DX_PERL@ +DX_PROJECT = @DX_PROJECT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GACUTIL = @GACUTIL@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GLIB20_CFLAGS = @GLIB20_CFLAGS@ +GLIB20_LIBS = @GLIB20_LIBS@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ +GOBJECT_LIBS = @GOBJECT_LIBS@ +GREP = @GREP@ +GTK20_CFLAGS = @GTK20_CFLAGS@ +GTK20_LIBS = @GTK20_LIBS@ +GTK30_CFLAGS = @GTK30_CFLAGS@ +GTK30_LIBS = @GTK30_LIBS@ +HOWL_COMPAT_VERSION = @HOWL_COMPAT_VERSION@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ +INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ +INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ +INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ +INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ +INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ +INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ +INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBAVAHI_CLIENT_VERSION_INFO = @LIBAVAHI_CLIENT_VERSION_INFO@ +LIBAVAHI_COMMON_VERSION_INFO = @LIBAVAHI_COMMON_VERSION_INFO@ +LIBAVAHI_COMPAT_HOWL_VERSION_INFO = @LIBAVAHI_COMPAT_HOWL_VERSION_INFO@ +LIBAVAHI_COMPAT_LIBDNS_SD_VERSION_INFO = @LIBAVAHI_COMPAT_LIBDNS_SD_VERSION_INFO@ +LIBAVAHI_CORE_VERSION_INFO = @LIBAVAHI_CORE_VERSION_INFO@ +LIBAVAHI_GLIB_VERSION_INFO = @LIBAVAHI_GLIB_VERSION_INFO@ +LIBAVAHI_GOBJECT_VERSION_INFO = @LIBAVAHI_GOBJECT_VERSION_INFO@ +LIBAVAHI_LIBEVENT_VERSION_INFO = @LIBAVAHI_LIBEVENT_VERSION_INFO@ +LIBAVAHI_QT3_VERSION_INFO = @LIBAVAHI_QT3_VERSION_INFO@ +LIBAVAHI_QT4_VERSION_INFO = @LIBAVAHI_QT4_VERSION_INFO@ +LIBAVAHI_QT5_VERSION_INFO = @LIBAVAHI_QT5_VERSION_INFO@ +LIBAVAHI_UI_VERSION_INFO = @LIBAVAHI_UI_VERSION_INFO@ +LIBDAEMON_CFLAGS = @LIBDAEMON_CFLAGS@ +LIBDAEMON_LIBS = @LIBDAEMON_LIBS@ +LIBEVENT_CFLAGS = @LIBEVENT_CFLAGS@ +LIBEVENT_LIBS = @LIBEVENT_LIBS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MCS = @MCS@ +MDASSEMBLER = @MDASSEMBLER@ +MKDIR_P = @MKDIR_P@ +MOC_QT3 = @MOC_QT3@ +MOC_QT4 = @MOC_QT4@ +MOC_QT5 = @MOC_QT5@ +MONODOCER = @MONODOCER@ +MONODOC_CFLAGS = @MONODOC_CFLAGS@ +MONODOC_DIR = @MONODOC_DIR@ +MONODOC_LIBS = @MONODOC_LIBS@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +POSUB = @POSUB@ +PTHREAD_CC = @PTHREAD_CC@ +PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ +PTHREAD_LIBS = @PTHREAD_LIBS@ +PYGOBJECT_CFLAGS = @PYGOBJECT_CFLAGS@ +PYGOBJECT_LIBS = @PYGOBJECT_LIBS@ +PYTHON = @PYTHON@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ +QT3_CFLAGS = @QT3_CFLAGS@ +QT3_LIBS = @QT3_LIBS@ +QT4_CFLAGS = @QT4_CFLAGS@ +QT4_LIBS = @QT4_LIBS@ +QT5_CFLAGS = @QT5_CFLAGS@ +QT5_LIBS = @QT5_LIBS@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STOW = @STOW@ +STRIP = @STRIP@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +VISIBILITY_HIDDEN_CFLAGS = @VISIBILITY_HIDDEN_CFLAGS@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +XML_CFLAGS = @XML_CFLAGS@ +XML_LIBS = @XML_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +acx_pthread_config = @acx_pthread_config@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +avahi_runtime_dir = @avahi_runtime_dir@ +avahi_socket = @avahi_socket@ +avahilocaledir = @avahilocaledir@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +have_pkg_config = @have_pkg_config@ +have_xmltoman = @have_xmltoman@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +interfacesdir = @interfacesdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +systemdsystemunitdir = @systemdsystemunitdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ + +# This cool debug trap works on i386/gcc only +AM_CFLAGS = -I$(top_srcdir) '-DDEBUG_TRAP=__asm__("int $$3")' +@HAVE_DBUS_TRUE@avahi_clientincludedir = $(includedir)/avahi-client +@HAVE_DBUS_TRUE@avahi_clientinclude_HEADERS = client.h lookup.h publish.h +@HAVE_DBUS_TRUE@noinst_HEADERS = internal.h +@HAVE_DBUS_TRUE@lib_LTLIBRARIES = libavahi-client.la +@HAVE_DBUS_TRUE@libavahi_client_la_SOURCES = \ +@HAVE_DBUS_TRUE@ client.c client.h \ +@HAVE_DBUS_TRUE@ entrygroup.c \ +@HAVE_DBUS_TRUE@ browser.c \ +@HAVE_DBUS_TRUE@ resolver.c \ +@HAVE_DBUS_TRUE@ publish.h lookup.h \ +@HAVE_DBUS_TRUE@ xdg-config.c xdg-config.h \ +@HAVE_DBUS_TRUE@ check-nss.c \ +@HAVE_DBUS_TRUE@ ../avahi-common/dbus.c ../avahi-common/dbus.h \ +@HAVE_DBUS_TRUE@ ../avahi-common/dbus-watch-glue.c ../avahi-common/dbus-watch-glue.h + +@HAVE_DBUS_TRUE@libavahi_client_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS) -DDBUS_SYSTEM_BUS_DEFAULT_ADDRESS=\"$(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS)\" +@HAVE_DBUS_TRUE@libavahi_client_la_LIBADD = $(AM_LDADD) $(DBUS_LIBS) \ +@HAVE_DBUS_TRUE@ ../avahi-common/libavahi-common.la \ +@HAVE_DBUS_TRUE@ $(am__append_2) +@HAVE_DBUS_TRUE@libavahi_client_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBAVAHI_CLIENT_VERSION_INFO) +@HAVE_DBUS_TRUE@client_test_SOURCES = client-test.c +@HAVE_DBUS_TRUE@client_test_CFLAGS = $(AM_CFLAGS) +@HAVE_DBUS_TRUE@client_test_LDADD = $(AM_LDADD) libavahi-client.la ../avahi-common/libavahi-common.la +@HAVE_DBUS_TRUE@srv_test_SOURCES = srv-test.c +@HAVE_DBUS_TRUE@srv_test_CFLAGS = $(AM_CFLAGS) +@HAVE_DBUS_TRUE@srv_test_LDADD = $(AM_LDADD) libavahi-client.la ../avahi-common/libavahi-common.la +@HAVE_DBUS_TRUE@rr_test_SOURCES = rr-test.c +@HAVE_DBUS_TRUE@rr_test_CFLAGS = $(AM_CFLAGS) +@HAVE_DBUS_TRUE@rr_test_LDADD = $(AM_LDADD) libavahi-client.la ../avahi-common/libavahi-common.la +@HAVE_DBUS_TRUE@xdg_config_test_SOURCES = xdg-config-test.c xdg-config.c xdg-config.h +@HAVE_DBUS_TRUE@xdg_config_test_CFLAGS = $(AM_CFLAGS) +@HAVE_DBUS_TRUE@xdg_config_test_LDADD = $(AM_LDADD) +@HAVE_DBUS_TRUE@check_nss_test_SOURCES = check-nss.c check-nss-test.c client.h +@HAVE_DBUS_TRUE@check_nss_test_CFLAGS = $(AM_CFLAGS) +@HAVE_DBUS_TRUE@check_nss_test_LDADD = $(AM_LDADD) $(am__append_1) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign avahi-client/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign avahi-client/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ + } + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +libavahi-client.la: $(libavahi_client_la_OBJECTS) $(libavahi_client_la_DEPENDENCIES) $(EXTRA_libavahi_client_la_DEPENDENCIES) + $(AM_V_CCLD)$(libavahi_client_la_LINK) $(am_libavahi_client_la_rpath) $(libavahi_client_la_OBJECTS) $(libavahi_client_la_LIBADD) $(LIBS) + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +check-nss-test$(EXEEXT): $(check_nss_test_OBJECTS) $(check_nss_test_DEPENDENCIES) $(EXTRA_check_nss_test_DEPENDENCIES) + @rm -f check-nss-test$(EXEEXT) + $(AM_V_CCLD)$(check_nss_test_LINK) $(check_nss_test_OBJECTS) $(check_nss_test_LDADD) $(LIBS) + +client-test$(EXEEXT): $(client_test_OBJECTS) $(client_test_DEPENDENCIES) $(EXTRA_client_test_DEPENDENCIES) + @rm -f client-test$(EXEEXT) + $(AM_V_CCLD)$(client_test_LINK) $(client_test_OBJECTS) $(client_test_LDADD) $(LIBS) + +rr-test$(EXEEXT): $(rr_test_OBJECTS) $(rr_test_DEPENDENCIES) $(EXTRA_rr_test_DEPENDENCIES) + @rm -f rr-test$(EXEEXT) + $(AM_V_CCLD)$(rr_test_LINK) $(rr_test_OBJECTS) $(rr_test_LDADD) $(LIBS) + +srv-test$(EXEEXT): $(srv_test_OBJECTS) $(srv_test_DEPENDENCIES) $(EXTRA_srv_test_DEPENDENCIES) + @rm -f srv-test$(EXEEXT) + $(AM_V_CCLD)$(srv_test_LINK) $(srv_test_OBJECTS) $(srv_test_LDADD) $(LIBS) + +xdg-config-test$(EXEEXT): $(xdg_config_test_OBJECTS) $(xdg_config_test_DEPENDENCIES) $(EXTRA_xdg_config_test_DEPENDENCIES) + @rm -f xdg-config-test$(EXEEXT) + $(AM_V_CCLD)$(xdg_config_test_LINK) $(xdg_config_test_OBJECTS) $(xdg_config_test_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_nss_test-check-nss-test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_nss_test-check-nss.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/client_test-client-test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavahi_client_la-browser.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavahi_client_la-check-nss.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavahi_client_la-client.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavahi_client_la-dbus-watch-glue.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavahi_client_la-dbus.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavahi_client_la-entrygroup.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavahi_client_la-resolver.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavahi_client_la-xdg-config.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rr_test-rr-test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/srv_test-srv-test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xdg_config_test-xdg-config-test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xdg_config_test-xdg-config.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +libavahi_client_la-client.lo: client.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_client_la_CFLAGS) $(CFLAGS) -MT libavahi_client_la-client.lo -MD -MP -MF $(DEPDIR)/libavahi_client_la-client.Tpo -c -o libavahi_client_la-client.lo `test -f 'client.c' || echo '$(srcdir)/'`client.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavahi_client_la-client.Tpo $(DEPDIR)/libavahi_client_la-client.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='client.c' object='libavahi_client_la-client.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_client_la_CFLAGS) $(CFLAGS) -c -o libavahi_client_la-client.lo `test -f 'client.c' || echo '$(srcdir)/'`client.c + +libavahi_client_la-entrygroup.lo: entrygroup.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_client_la_CFLAGS) $(CFLAGS) -MT libavahi_client_la-entrygroup.lo -MD -MP -MF $(DEPDIR)/libavahi_client_la-entrygroup.Tpo -c -o libavahi_client_la-entrygroup.lo `test -f 'entrygroup.c' || echo '$(srcdir)/'`entrygroup.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavahi_client_la-entrygroup.Tpo $(DEPDIR)/libavahi_client_la-entrygroup.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='entrygroup.c' object='libavahi_client_la-entrygroup.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_client_la_CFLAGS) $(CFLAGS) -c -o libavahi_client_la-entrygroup.lo `test -f 'entrygroup.c' || echo '$(srcdir)/'`entrygroup.c + +libavahi_client_la-browser.lo: browser.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_client_la_CFLAGS) $(CFLAGS) -MT libavahi_client_la-browser.lo -MD -MP -MF $(DEPDIR)/libavahi_client_la-browser.Tpo -c -o libavahi_client_la-browser.lo `test -f 'browser.c' || echo '$(srcdir)/'`browser.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavahi_client_la-browser.Tpo $(DEPDIR)/libavahi_client_la-browser.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='browser.c' object='libavahi_client_la-browser.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_client_la_CFLAGS) $(CFLAGS) -c -o libavahi_client_la-browser.lo `test -f 'browser.c' || echo '$(srcdir)/'`browser.c + +libavahi_client_la-resolver.lo: resolver.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_client_la_CFLAGS) $(CFLAGS) -MT libavahi_client_la-resolver.lo -MD -MP -MF $(DEPDIR)/libavahi_client_la-resolver.Tpo -c -o libavahi_client_la-resolver.lo `test -f 'resolver.c' || echo '$(srcdir)/'`resolver.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavahi_client_la-resolver.Tpo $(DEPDIR)/libavahi_client_la-resolver.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='resolver.c' object='libavahi_client_la-resolver.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_client_la_CFLAGS) $(CFLAGS) -c -o libavahi_client_la-resolver.lo `test -f 'resolver.c' || echo '$(srcdir)/'`resolver.c + +libavahi_client_la-xdg-config.lo: xdg-config.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_client_la_CFLAGS) $(CFLAGS) -MT libavahi_client_la-xdg-config.lo -MD -MP -MF $(DEPDIR)/libavahi_client_la-xdg-config.Tpo -c -o libavahi_client_la-xdg-config.lo `test -f 'xdg-config.c' || echo '$(srcdir)/'`xdg-config.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavahi_client_la-xdg-config.Tpo $(DEPDIR)/libavahi_client_la-xdg-config.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='xdg-config.c' object='libavahi_client_la-xdg-config.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_client_la_CFLAGS) $(CFLAGS) -c -o libavahi_client_la-xdg-config.lo `test -f 'xdg-config.c' || echo '$(srcdir)/'`xdg-config.c + +libavahi_client_la-check-nss.lo: check-nss.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_client_la_CFLAGS) $(CFLAGS) -MT libavahi_client_la-check-nss.lo -MD -MP -MF $(DEPDIR)/libavahi_client_la-check-nss.Tpo -c -o libavahi_client_la-check-nss.lo `test -f 'check-nss.c' || echo '$(srcdir)/'`check-nss.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavahi_client_la-check-nss.Tpo $(DEPDIR)/libavahi_client_la-check-nss.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='check-nss.c' object='libavahi_client_la-check-nss.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_client_la_CFLAGS) $(CFLAGS) -c -o libavahi_client_la-check-nss.lo `test -f 'check-nss.c' || echo '$(srcdir)/'`check-nss.c + +libavahi_client_la-dbus.lo: ../avahi-common/dbus.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_client_la_CFLAGS) $(CFLAGS) -MT libavahi_client_la-dbus.lo -MD -MP -MF $(DEPDIR)/libavahi_client_la-dbus.Tpo -c -o libavahi_client_la-dbus.lo `test -f '../avahi-common/dbus.c' || echo '$(srcdir)/'`../avahi-common/dbus.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavahi_client_la-dbus.Tpo $(DEPDIR)/libavahi_client_la-dbus.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../avahi-common/dbus.c' object='libavahi_client_la-dbus.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_client_la_CFLAGS) $(CFLAGS) -c -o libavahi_client_la-dbus.lo `test -f '../avahi-common/dbus.c' || echo '$(srcdir)/'`../avahi-common/dbus.c + +libavahi_client_la-dbus-watch-glue.lo: ../avahi-common/dbus-watch-glue.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_client_la_CFLAGS) $(CFLAGS) -MT libavahi_client_la-dbus-watch-glue.lo -MD -MP -MF $(DEPDIR)/libavahi_client_la-dbus-watch-glue.Tpo -c -o libavahi_client_la-dbus-watch-glue.lo `test -f '../avahi-common/dbus-watch-glue.c' || echo '$(srcdir)/'`../avahi-common/dbus-watch-glue.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavahi_client_la-dbus-watch-glue.Tpo $(DEPDIR)/libavahi_client_la-dbus-watch-glue.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../avahi-common/dbus-watch-glue.c' object='libavahi_client_la-dbus-watch-glue.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_client_la_CFLAGS) $(CFLAGS) -c -o libavahi_client_la-dbus-watch-glue.lo `test -f '../avahi-common/dbus-watch-glue.c' || echo '$(srcdir)/'`../avahi-common/dbus-watch-glue.c + +check_nss_test-check-nss.o: check-nss.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_nss_test_CFLAGS) $(CFLAGS) -MT check_nss_test-check-nss.o -MD -MP -MF $(DEPDIR)/check_nss_test-check-nss.Tpo -c -o check_nss_test-check-nss.o `test -f 'check-nss.c' || echo '$(srcdir)/'`check-nss.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/check_nss_test-check-nss.Tpo $(DEPDIR)/check_nss_test-check-nss.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='check-nss.c' object='check_nss_test-check-nss.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_nss_test_CFLAGS) $(CFLAGS) -c -o check_nss_test-check-nss.o `test -f 'check-nss.c' || echo '$(srcdir)/'`check-nss.c + +check_nss_test-check-nss.obj: check-nss.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_nss_test_CFLAGS) $(CFLAGS) -MT check_nss_test-check-nss.obj -MD -MP -MF $(DEPDIR)/check_nss_test-check-nss.Tpo -c -o check_nss_test-check-nss.obj `if test -f 'check-nss.c'; then $(CYGPATH_W) 'check-nss.c'; else $(CYGPATH_W) '$(srcdir)/check-nss.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/check_nss_test-check-nss.Tpo $(DEPDIR)/check_nss_test-check-nss.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='check-nss.c' object='check_nss_test-check-nss.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_nss_test_CFLAGS) $(CFLAGS) -c -o check_nss_test-check-nss.obj `if test -f 'check-nss.c'; then $(CYGPATH_W) 'check-nss.c'; else $(CYGPATH_W) '$(srcdir)/check-nss.c'; fi` + +check_nss_test-check-nss-test.o: check-nss-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_nss_test_CFLAGS) $(CFLAGS) -MT check_nss_test-check-nss-test.o -MD -MP -MF $(DEPDIR)/check_nss_test-check-nss-test.Tpo -c -o check_nss_test-check-nss-test.o `test -f 'check-nss-test.c' || echo '$(srcdir)/'`check-nss-test.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/check_nss_test-check-nss-test.Tpo $(DEPDIR)/check_nss_test-check-nss-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='check-nss-test.c' object='check_nss_test-check-nss-test.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_nss_test_CFLAGS) $(CFLAGS) -c -o check_nss_test-check-nss-test.o `test -f 'check-nss-test.c' || echo '$(srcdir)/'`check-nss-test.c + +check_nss_test-check-nss-test.obj: check-nss-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_nss_test_CFLAGS) $(CFLAGS) -MT check_nss_test-check-nss-test.obj -MD -MP -MF $(DEPDIR)/check_nss_test-check-nss-test.Tpo -c -o check_nss_test-check-nss-test.obj `if test -f 'check-nss-test.c'; then $(CYGPATH_W) 'check-nss-test.c'; else $(CYGPATH_W) '$(srcdir)/check-nss-test.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/check_nss_test-check-nss-test.Tpo $(DEPDIR)/check_nss_test-check-nss-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='check-nss-test.c' object='check_nss_test-check-nss-test.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_nss_test_CFLAGS) $(CFLAGS) -c -o check_nss_test-check-nss-test.obj `if test -f 'check-nss-test.c'; then $(CYGPATH_W) 'check-nss-test.c'; else $(CYGPATH_W) '$(srcdir)/check-nss-test.c'; fi` + +client_test-client-test.o: client-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(client_test_CFLAGS) $(CFLAGS) -MT client_test-client-test.o -MD -MP -MF $(DEPDIR)/client_test-client-test.Tpo -c -o client_test-client-test.o `test -f 'client-test.c' || echo '$(srcdir)/'`client-test.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/client_test-client-test.Tpo $(DEPDIR)/client_test-client-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='client-test.c' object='client_test-client-test.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(client_test_CFLAGS) $(CFLAGS) -c -o client_test-client-test.o `test -f 'client-test.c' || echo '$(srcdir)/'`client-test.c + +client_test-client-test.obj: client-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(client_test_CFLAGS) $(CFLAGS) -MT client_test-client-test.obj -MD -MP -MF $(DEPDIR)/client_test-client-test.Tpo -c -o client_test-client-test.obj `if test -f 'client-test.c'; then $(CYGPATH_W) 'client-test.c'; else $(CYGPATH_W) '$(srcdir)/client-test.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/client_test-client-test.Tpo $(DEPDIR)/client_test-client-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='client-test.c' object='client_test-client-test.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(client_test_CFLAGS) $(CFLAGS) -c -o client_test-client-test.obj `if test -f 'client-test.c'; then $(CYGPATH_W) 'client-test.c'; else $(CYGPATH_W) '$(srcdir)/client-test.c'; fi` + +rr_test-rr-test.o: rr-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rr_test_CFLAGS) $(CFLAGS) -MT rr_test-rr-test.o -MD -MP -MF $(DEPDIR)/rr_test-rr-test.Tpo -c -o rr_test-rr-test.o `test -f 'rr-test.c' || echo '$(srcdir)/'`rr-test.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/rr_test-rr-test.Tpo $(DEPDIR)/rr_test-rr-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rr-test.c' object='rr_test-rr-test.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rr_test_CFLAGS) $(CFLAGS) -c -o rr_test-rr-test.o `test -f 'rr-test.c' || echo '$(srcdir)/'`rr-test.c + +rr_test-rr-test.obj: rr-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rr_test_CFLAGS) $(CFLAGS) -MT rr_test-rr-test.obj -MD -MP -MF $(DEPDIR)/rr_test-rr-test.Tpo -c -o rr_test-rr-test.obj `if test -f 'rr-test.c'; then $(CYGPATH_W) 'rr-test.c'; else $(CYGPATH_W) '$(srcdir)/rr-test.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/rr_test-rr-test.Tpo $(DEPDIR)/rr_test-rr-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rr-test.c' object='rr_test-rr-test.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rr_test_CFLAGS) $(CFLAGS) -c -o rr_test-rr-test.obj `if test -f 'rr-test.c'; then $(CYGPATH_W) 'rr-test.c'; else $(CYGPATH_W) '$(srcdir)/rr-test.c'; fi` + +srv_test-srv-test.o: srv-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(srv_test_CFLAGS) $(CFLAGS) -MT srv_test-srv-test.o -MD -MP -MF $(DEPDIR)/srv_test-srv-test.Tpo -c -o srv_test-srv-test.o `test -f 'srv-test.c' || echo '$(srcdir)/'`srv-test.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/srv_test-srv-test.Tpo $(DEPDIR)/srv_test-srv-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='srv-test.c' object='srv_test-srv-test.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(srv_test_CFLAGS) $(CFLAGS) -c -o srv_test-srv-test.o `test -f 'srv-test.c' || echo '$(srcdir)/'`srv-test.c + +srv_test-srv-test.obj: srv-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(srv_test_CFLAGS) $(CFLAGS) -MT srv_test-srv-test.obj -MD -MP -MF $(DEPDIR)/srv_test-srv-test.Tpo -c -o srv_test-srv-test.obj `if test -f 'srv-test.c'; then $(CYGPATH_W) 'srv-test.c'; else $(CYGPATH_W) '$(srcdir)/srv-test.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/srv_test-srv-test.Tpo $(DEPDIR)/srv_test-srv-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='srv-test.c' object='srv_test-srv-test.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(srv_test_CFLAGS) $(CFLAGS) -c -o srv_test-srv-test.obj `if test -f 'srv-test.c'; then $(CYGPATH_W) 'srv-test.c'; else $(CYGPATH_W) '$(srcdir)/srv-test.c'; fi` + +xdg_config_test-xdg-config-test.o: xdg-config-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xdg_config_test_CFLAGS) $(CFLAGS) -MT xdg_config_test-xdg-config-test.o -MD -MP -MF $(DEPDIR)/xdg_config_test-xdg-config-test.Tpo -c -o xdg_config_test-xdg-config-test.o `test -f 'xdg-config-test.c' || echo '$(srcdir)/'`xdg-config-test.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/xdg_config_test-xdg-config-test.Tpo $(DEPDIR)/xdg_config_test-xdg-config-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='xdg-config-test.c' object='xdg_config_test-xdg-config-test.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xdg_config_test_CFLAGS) $(CFLAGS) -c -o xdg_config_test-xdg-config-test.o `test -f 'xdg-config-test.c' || echo '$(srcdir)/'`xdg-config-test.c + +xdg_config_test-xdg-config-test.obj: xdg-config-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xdg_config_test_CFLAGS) $(CFLAGS) -MT xdg_config_test-xdg-config-test.obj -MD -MP -MF $(DEPDIR)/xdg_config_test-xdg-config-test.Tpo -c -o xdg_config_test-xdg-config-test.obj `if test -f 'xdg-config-test.c'; then $(CYGPATH_W) 'xdg-config-test.c'; else $(CYGPATH_W) '$(srcdir)/xdg-config-test.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/xdg_config_test-xdg-config-test.Tpo $(DEPDIR)/xdg_config_test-xdg-config-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='xdg-config-test.c' object='xdg_config_test-xdg-config-test.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xdg_config_test_CFLAGS) $(CFLAGS) -c -o xdg_config_test-xdg-config-test.obj `if test -f 'xdg-config-test.c'; then $(CYGPATH_W) 'xdg-config-test.c'; else $(CYGPATH_W) '$(srcdir)/xdg-config-test.c'; fi` + +xdg_config_test-xdg-config.o: xdg-config.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xdg_config_test_CFLAGS) $(CFLAGS) -MT xdg_config_test-xdg-config.o -MD -MP -MF $(DEPDIR)/xdg_config_test-xdg-config.Tpo -c -o xdg_config_test-xdg-config.o `test -f 'xdg-config.c' || echo '$(srcdir)/'`xdg-config.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/xdg_config_test-xdg-config.Tpo $(DEPDIR)/xdg_config_test-xdg-config.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='xdg-config.c' object='xdg_config_test-xdg-config.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xdg_config_test_CFLAGS) $(CFLAGS) -c -o xdg_config_test-xdg-config.o `test -f 'xdg-config.c' || echo '$(srcdir)/'`xdg-config.c + +xdg_config_test-xdg-config.obj: xdg-config.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xdg_config_test_CFLAGS) $(CFLAGS) -MT xdg_config_test-xdg-config.obj -MD -MP -MF $(DEPDIR)/xdg_config_test-xdg-config.Tpo -c -o xdg_config_test-xdg-config.obj `if test -f 'xdg-config.c'; then $(CYGPATH_W) 'xdg-config.c'; else $(CYGPATH_W) '$(srcdir)/xdg-config.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/xdg_config_test-xdg-config.Tpo $(DEPDIR)/xdg_config_test-xdg-config.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='xdg-config.c' object='xdg_config_test-xdg-config.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xdg_config_test_CFLAGS) $(CFLAGS) -c -o xdg_config_test-xdg-config.obj `if test -f 'xdg-config.c'; then $(CYGPATH_W) 'xdg-config.c'; else $(CYGPATH_W) '$(srcdir)/xdg-config.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-avahi_clientincludeHEADERS: $(avahi_clientinclude_HEADERS) + @$(NORMAL_INSTALL) + @list='$(avahi_clientinclude_HEADERS)'; test -n "$(avahi_clientincludedir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(avahi_clientincludedir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(avahi_clientincludedir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(avahi_clientincludedir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(avahi_clientincludedir)" || exit $$?; \ + done + +uninstall-avahi_clientincludeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(avahi_clientinclude_HEADERS)'; test -n "$(avahi_clientincludedir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(avahi_clientincludedir)'; $(am__uninstall_files_from_dir) + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(avahi_clientincludedir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ + clean-noinstPROGRAMS mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-avahi_clientincludeHEADERS + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-libLTLIBRARIES + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-avahi_clientincludeHEADERS \ + uninstall-libLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ + clean-libLTLIBRARIES clean-libtool clean-noinstPROGRAMS \ + cscopelist-am ctags ctags-am distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-avahi_clientincludeHEADERS install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-libLTLIBRARIES install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am \ + uninstall-avahi_clientincludeHEADERS uninstall-libLTLIBRARIES + +.PRECIOUS: Makefile + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libgamestream/avahi-client/browser.c b/libgamestream/avahi-client/browser.c new file mode 100644 index 00000000..c978d942 --- /dev/null +++ b/libgamestream/avahi-client/browser.c @@ -0,0 +1,1025 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include "client.h" +#include "internal.h" +#include "xdg-config.h" + +static void parse_environment(AvahiDomainBrowser *b) { + char buf[AVAHI_DOMAIN_NAME_MAX*3], *e, *t, *p; + + assert(b); + + if (!(e = getenv("AVAHI_BROWSE_DOMAINS"))) + return; + + snprintf(buf, sizeof(buf), "%s", e); + + for (t = strtok_r(buf, ":", &p); t; t = strtok_r(NULL, ":", &p)) { + char domain[AVAHI_DOMAIN_NAME_MAX]; + if (avahi_normalize_name(t, domain, sizeof(domain))) + b->static_browse_domains = avahi_string_list_add(b->static_browse_domains, domain); + } +} + +static void parse_domain_file(AvahiDomainBrowser *b) { + FILE *f; + char buf[AVAHI_DOMAIN_NAME_MAX]; + + assert(b); + + if (!(f = avahi_xdg_config_open("avahi/browse-domains"))) + return; + + + while (fgets(buf, sizeof(buf)-1, f)) { + char domain[AVAHI_DOMAIN_NAME_MAX]; + buf[strcspn(buf, "\n\r")] = 0; + + if (avahi_normalize_name(buf, domain, sizeof(domain))) + b->static_browse_domains = avahi_string_list_add(b->static_browse_domains, domain); + } +} + +static void domain_browser_ref(AvahiDomainBrowser *db) { + assert(db); + assert(db->ref >= 1); + db->ref++; +} + +static void defer_timeout_callback(AvahiTimeout *t, void *userdata) { + AvahiDomainBrowser *db = userdata; + AvahiStringList *l; + assert(t); + + db->client->poll_api->timeout_free(db->defer_timeout); + db->defer_timeout = NULL; + + domain_browser_ref(db); + + for (l = db->static_browse_domains; l; l = l->next) { + + if (db->ref <= 1) + break; + + db->callback(db, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_BROWSER_NEW, (char*) l->text, AVAHI_LOOKUP_RESULT_STATIC, db->userdata); + } + + avahi_domain_browser_free(db); +} + +AvahiDomainBrowser* avahi_domain_browser_new( + AvahiClient *client, + AvahiIfIndex interface, + AvahiProtocol protocol, + const char *domain, + AvahiDomainBrowserType btype, + AvahiLookupFlags flags, + AvahiDomainBrowserCallback callback, + void *userdata) { + + AvahiDomainBrowser *db = NULL; + DBusMessage *message = NULL, *reply = NULL; + DBusError error; + char *path; + int32_t i_interface, i_protocol, bt; + uint32_t u_flags; + + assert(client); + assert(callback); + + dbus_error_init (&error); + + if (!avahi_client_is_connected(client)) { + avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); + goto fail; + } + + if (!domain) + domain = ""; + + if (!(db = avahi_new (AvahiDomainBrowser, 1))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + db->ref = 1; + db->client = client; + db->callback = callback; + db->userdata = userdata; + db->path = NULL; + db->interface = interface; + db->protocol = protocol; + db->static_browse_domains = NULL; + db->defer_timeout = NULL; + + AVAHI_LLIST_PREPEND(AvahiDomainBrowser, domain_browsers, client->domain_browsers, db); + + if (!(client->flags & AVAHI_CLIENT_IGNORE_USER_CONFIG)) { + parse_environment(db); + parse_domain_file(db); + } + + db->static_browse_domains = avahi_string_list_reverse(db->static_browse_domains); + + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "DomainBrowserNew"))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + i_interface = (int32_t) interface; + i_protocol = (int32_t) protocol; + u_flags = (uint32_t) flags; + bt = btype; + + if (!(dbus_message_append_args( + message, + DBUS_TYPE_INT32, &i_interface, + DBUS_TYPE_INT32, &i_protocol, + DBUS_TYPE_STRING, &domain, + DBUS_TYPE_INT32, &bt, + DBUS_TYPE_UINT32, &u_flags, + DBUS_TYPE_INVALID))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (!(reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error)) || + dbus_error_is_set(&error)) { + avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!dbus_message_get_args (reply, &error, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID) || + dbus_error_is_set(&error) || + !path) { + avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!(db->path = avahi_strdup(path))) { + + /* FIXME: We don't remove the object on the server side */ + + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (db->static_browse_domains && btype == AVAHI_DOMAIN_BROWSER_BROWSE) { + struct timeval tv = { 0, 0 }; + + if (!(db->defer_timeout = client->poll_api->timeout_new(client->poll_api, &tv, defer_timeout_callback, db))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + } + + dbus_message_unref(message); + dbus_message_unref(reply); + + return db; + +fail: + + if (dbus_error_is_set(&error)) { + avahi_client_set_dbus_error(client, &error); + dbus_error_free(&error); + } + + if (db) + avahi_domain_browser_free(db); + + if (message) + dbus_message_unref(message); + + if (reply) + dbus_message_unref(reply); + + return NULL; +} + +AvahiClient* avahi_domain_browser_get_client (AvahiDomainBrowser *b) { + assert(b); + return b->client; +} + +int avahi_domain_browser_free (AvahiDomainBrowser *b) { + AvahiClient *client; + int r = AVAHI_OK; + + assert(b); + assert(b->ref >= 1); + + if (--(b->ref) >= 1) + return AVAHI_OK; + + client = b->client; + + if (b->path && avahi_client_is_connected(b->client)) + r = avahi_client_simple_method_call(client, b->path, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "Free"); + + AVAHI_LLIST_REMOVE(AvahiDomainBrowser, domain_browsers, client->domain_browsers, b); + + if (b->defer_timeout) + b->client->poll_api->timeout_free(b->defer_timeout); + + avahi_string_list_free(b->static_browse_domains); + avahi_free(b->path); + avahi_free(b); + + return r; +} + +DBusHandlerResult avahi_domain_browser_event (AvahiClient *client, AvahiBrowserEvent event, DBusMessage *message) { + AvahiDomainBrowser *db = NULL; + DBusError error; + const char *path; + char *domain = NULL; + int32_t interface, protocol; + uint32_t flags = 0; + AvahiStringList *l; + + assert(client); + assert(message); + + dbus_error_init (&error); + + if (!(path = dbus_message_get_path(message))) + goto fail; + + for (db = client->domain_browsers; db; db = db->domain_browsers_next) + if (strcmp (db->path, path) == 0) + break; + + if (!db) + goto fail; + + interface = db->interface; + protocol = db->protocol; + + switch (event) { + case AVAHI_BROWSER_NEW: + case AVAHI_BROWSER_REMOVE: + + if (!dbus_message_get_args( + message, &error, + DBUS_TYPE_INT32, &interface, + DBUS_TYPE_INT32, &protocol, + DBUS_TYPE_STRING, &domain, + DBUS_TYPE_UINT32, &flags, + DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) { + fprintf(stderr, "Failed to parse browser event.\n"); + goto fail; + } + + break; + + case AVAHI_BROWSER_CACHE_EXHAUSTED: + case AVAHI_BROWSER_ALL_FOR_NOW: + break; + + case AVAHI_BROWSER_FAILURE: { + char *etxt; + + if (!dbus_message_get_args( + message, &error, + DBUS_TYPE_STRING, &etxt, + DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) { + fprintf(stderr, "Failed to parse browser event.\n"); + goto fail; + } + + avahi_client_set_errno(db->client, avahi_error_dbus_to_number(etxt)); + break; + } + } + + if (domain) + for (l = db->static_browse_domains; l; l = l->next) + if (avahi_domain_equal((char*) l->text, domain)) { + /* We had this entry already in the static entries */ + return DBUS_HANDLER_RESULT_HANDLED; + } + + db->callback(db, (AvahiIfIndex) interface, (AvahiProtocol) protocol, event, domain, (AvahiLookupResultFlags) flags, db->userdata); + + return DBUS_HANDLER_RESULT_HANDLED; + +fail: + dbus_error_free (&error); + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +/* AvahiServiceTypeBrowser */ + +AvahiServiceTypeBrowser* avahi_service_type_browser_new( + AvahiClient *client, + AvahiIfIndex interface, + AvahiProtocol protocol, + const char *domain, + AvahiLookupFlags flags, + AvahiServiceTypeBrowserCallback callback, + void *userdata) { + + AvahiServiceTypeBrowser *b = NULL; + DBusMessage *message = NULL, *reply = NULL; + DBusError error; + char *path; + int32_t i_interface, i_protocol; + uint32_t u_flags; + + assert(client); + assert(callback); + + dbus_error_init(&error); + + if (!avahi_client_is_connected(client)) { + avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); + goto fail; + } + + if (!domain) + domain = ""; + + if (!(b = avahi_new(AvahiServiceTypeBrowser, 1))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + b->client = client; + b->callback = callback; + b->userdata = userdata; + b->path = NULL; + b->domain = NULL; + b->interface = interface; + b->protocol = protocol; + + AVAHI_LLIST_PREPEND(AvahiServiceTypeBrowser, service_type_browsers, client->service_type_browsers, b); + + if (domain[0]) + if (!(b->domain = avahi_strdup(domain))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "ServiceTypeBrowserNew"))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + i_interface = (int32_t) interface; + i_protocol = (int32_t) protocol; + u_flags = (uint32_t) flags; + + if (!dbus_message_append_args( + message, + DBUS_TYPE_INT32, &i_interface, + DBUS_TYPE_INT32, &i_protocol, + DBUS_TYPE_STRING, &domain, + DBUS_TYPE_UINT32, &u_flags, + DBUS_TYPE_INVALID)) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (!(reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error)) || + dbus_error_is_set(&error)) { + avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!dbus_message_get_args (reply, &error, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID) || + dbus_error_is_set(&error) || + !path) { + avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!(b->path = avahi_strdup(path))) { + + /* FIXME: We don't remove the object on the server side */ + + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + dbus_message_unref(message); + dbus_message_unref(reply); + + return b; + +fail: + + if (dbus_error_is_set(&error)) { + avahi_client_set_dbus_error(client, &error); + dbus_error_free(&error); + } + + if (b) + avahi_service_type_browser_free(b); + + if (message) + dbus_message_unref(message); + + if (reply) + dbus_message_unref(reply); + + return NULL; +} + +AvahiClient* avahi_service_type_browser_get_client (AvahiServiceTypeBrowser *b) { + assert(b); + return b->client; +} + +int avahi_service_type_browser_free (AvahiServiceTypeBrowser *b) { + AvahiClient *client; + int r = AVAHI_OK; + + assert(b); + client = b->client; + + if (b->path && avahi_client_is_connected(b->client)) + r = avahi_client_simple_method_call(client, b->path, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "Free"); + + AVAHI_LLIST_REMOVE(AvahiServiceTypeBrowser, service_type_browsers, b->client->service_type_browsers, b); + + avahi_free(b->path); + avahi_free(b->domain); + avahi_free(b); + return r; +} + +DBusHandlerResult avahi_service_type_browser_event (AvahiClient *client, AvahiBrowserEvent event, DBusMessage *message) { + AvahiServiceTypeBrowser *b = NULL; + DBusError error; + const char *path; + char *domain, *type = NULL; + int32_t interface, protocol; + uint32_t flags = 0; + + assert(client); + assert(message); + + dbus_error_init (&error); + + if (!(path = dbus_message_get_path(message))) + goto fail; + + for (b = client->service_type_browsers; b; b = b->service_type_browsers_next) + if (strcmp (b->path, path) == 0) + break; + + if (!b) + goto fail; + + domain = b->domain; + interface = b->interface; + protocol = b->protocol; + + switch (event) { + case AVAHI_BROWSER_NEW: + case AVAHI_BROWSER_REMOVE: + if (!dbus_message_get_args( + message, &error, + DBUS_TYPE_INT32, &interface, + DBUS_TYPE_INT32, &protocol, + DBUS_TYPE_STRING, &type, + DBUS_TYPE_STRING, &domain, + DBUS_TYPE_UINT32, &flags, + DBUS_TYPE_INVALID) || + dbus_error_is_set(&error)) { + fprintf(stderr, "Failed to parse browser event.\n"); + goto fail; + } + break; + + case AVAHI_BROWSER_CACHE_EXHAUSTED: + case AVAHI_BROWSER_ALL_FOR_NOW: + break; + + case AVAHI_BROWSER_FAILURE: { + char *etxt; + + if (!dbus_message_get_args( + message, &error, + DBUS_TYPE_STRING, &etxt, + DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) { + fprintf(stderr, "Failed to parse browser event.\n"); + goto fail; + } + + avahi_client_set_errno(b->client, avahi_error_dbus_to_number(etxt)); + break; + } + } + + b->callback(b, (AvahiIfIndex) interface, (AvahiProtocol) protocol, event, type, domain, (AvahiLookupResultFlags) flags, b->userdata); + + return DBUS_HANDLER_RESULT_HANDLED; + +fail: + dbus_error_free (&error); + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +/* AvahiServiceBrowser */ + +AvahiServiceBrowser* avahi_service_browser_new( + AvahiClient *client, + AvahiIfIndex interface, + AvahiProtocol protocol, + const char *type, + const char *domain, + AvahiLookupFlags flags, + AvahiServiceBrowserCallback callback, + void *userdata) { + + AvahiServiceBrowser *b = NULL; + DBusMessage *message = NULL, *reply = NULL; + DBusError error; + char *path; + int32_t i_protocol, i_interface; + uint32_t u_flags; + + assert(client); + assert(type); + assert(callback); + + dbus_error_init(&error); + + if (!avahi_client_is_connected(client)) { + avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); + goto fail; + } + + if (!domain) + domain = ""; + + if (!(b = avahi_new(AvahiServiceBrowser, 1))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + b->client = client; + b->callback = callback; + b->userdata = userdata; + b->path = NULL; + b->type = b->domain = NULL; + b->interface = interface; + b->protocol = protocol; + + AVAHI_LLIST_PREPEND(AvahiServiceBrowser, service_browsers, client->service_browsers, b); + + if (!(b->type = avahi_strdup(type))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (domain && domain[0]) + if (!(b->domain = avahi_strdup(domain))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "ServiceBrowserNew"))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + i_interface = (int32_t) interface; + i_protocol = (int32_t) protocol; + u_flags = (uint32_t) flags; + + if (!dbus_message_append_args( + message, + DBUS_TYPE_INT32, &i_interface, + DBUS_TYPE_INT32, &i_protocol, + DBUS_TYPE_STRING, &type, + DBUS_TYPE_STRING, &domain, + DBUS_TYPE_UINT32, &u_flags, + DBUS_TYPE_INVALID)) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (!(reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error)) || + dbus_error_is_set(&error)) { + avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!dbus_message_get_args (reply, &error, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID) || + dbus_error_is_set(&error) || + !path) { + avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!(b->path = avahi_strdup(path))) { + + /* FIXME: We don't remove the object on the server side */ + + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + dbus_message_unref(message); + dbus_message_unref(reply); + + return b; + +fail: + if (dbus_error_is_set(&error)) { + avahi_client_set_dbus_error(client, &error); + dbus_error_free(&error); + } + + if (b) + avahi_service_browser_free(b); + + if (message) + dbus_message_unref(message); + + if (reply) + dbus_message_unref(reply); + + return NULL; +} + +AvahiClient* avahi_service_browser_get_client (AvahiServiceBrowser *b) { + assert(b); + return b->client; +} + +int avahi_service_browser_free (AvahiServiceBrowser *b) { + AvahiClient *client; + int r = AVAHI_OK; + + assert(b); + client = b->client; + + if (b->path && avahi_client_is_connected(b->client)) + r = avahi_client_simple_method_call(client, b->path, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "Free"); + + AVAHI_LLIST_REMOVE(AvahiServiceBrowser, service_browsers, b->client->service_browsers, b); + + avahi_free(b->path); + avahi_free(b->type); + avahi_free(b->domain); + avahi_free(b); + return r; +} + +DBusHandlerResult avahi_service_browser_event(AvahiClient *client, AvahiBrowserEvent event, DBusMessage *message) { + AvahiServiceBrowser *b = NULL; + DBusError error; + const char *path; + char *name = NULL, *type, *domain; + int32_t interface, protocol; + uint32_t flags = 0; + + dbus_error_init (&error); + + if (!(path = dbus_message_get_path(message))) + goto fail; + + for (b = client->service_browsers; b; b = b->service_browsers_next) + if (strcmp (b->path, path) == 0) + break; + + if (!b) + goto fail; + + type = b->type; + domain = b->domain; + interface = b->interface; + protocol = b->protocol; + + switch (event) { + case AVAHI_BROWSER_NEW: + case AVAHI_BROWSER_REMOVE: + + if (!dbus_message_get_args ( + message, &error, + DBUS_TYPE_INT32, &interface, + DBUS_TYPE_INT32, &protocol, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_STRING, &type, + DBUS_TYPE_STRING, &domain, + DBUS_TYPE_UINT32, &flags, + DBUS_TYPE_INVALID) || + dbus_error_is_set(&error)) { + fprintf(stderr, "Failed to parse browser event.\n"); + goto fail; + } + break; + + case AVAHI_BROWSER_CACHE_EXHAUSTED: + case AVAHI_BROWSER_ALL_FOR_NOW: + break; + + case AVAHI_BROWSER_FAILURE: { + char *etxt; + + if (!dbus_message_get_args( + message, &error, + DBUS_TYPE_STRING, &etxt, + DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) { + fprintf(stderr, "Failed to parse browser event.\n"); + goto fail; + } + + avahi_client_set_errno(b->client, avahi_error_dbus_to_number(etxt)); + break; + } + } + + b->callback(b, (AvahiIfIndex) interface, (AvahiProtocol) protocol, event, name, type, domain, (AvahiLookupResultFlags) flags, b->userdata); + + return DBUS_HANDLER_RESULT_HANDLED; + +fail: + dbus_error_free (&error); + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +/* AvahiRecordBrowser */ + +AvahiRecordBrowser* avahi_record_browser_new( + AvahiClient *client, + AvahiIfIndex interface, + AvahiProtocol protocol, + const char *name, + uint16_t clazz, + uint16_t type, + AvahiLookupFlags flags, + AvahiRecordBrowserCallback callback, + void *userdata) { + + AvahiRecordBrowser *b = NULL; + DBusMessage *message = NULL, *reply = NULL; + DBusError error; + char *path; + int32_t i_protocol, i_interface; + uint32_t u_flags; + + assert(client); + assert(name); + assert(callback); + + dbus_error_init(&error); + + if (!avahi_client_is_connected(client)) { + avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); + goto fail; + } + + if (!(b = avahi_new(AvahiRecordBrowser, 1))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + b->client = client; + b->callback = callback; + b->userdata = userdata; + b->path = NULL; + b->name = NULL; + b->clazz = clazz; + b->type = type; + b->interface = interface; + b->protocol = protocol; + + AVAHI_LLIST_PREPEND(AvahiRecordBrowser, record_browsers, client->record_browsers, b); + + if (!(b->name = avahi_strdup(name))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "RecordBrowserNew"))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + i_interface = (int32_t) interface; + i_protocol = (int32_t) protocol; + u_flags = (uint32_t) flags; + + if (!dbus_message_append_args( + message, + DBUS_TYPE_INT32, &i_interface, + DBUS_TYPE_INT32, &i_protocol, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_UINT16, &clazz, + DBUS_TYPE_UINT16, &type, + DBUS_TYPE_UINT32, &u_flags, + DBUS_TYPE_INVALID)) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (!(reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error)) || + dbus_error_is_set(&error)) { + avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!dbus_message_get_args (reply, &error, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID) || + dbus_error_is_set(&error) || + !path) { + avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!(b->path = avahi_strdup(path))) { + + /* FIXME: We don't remove the object on the server side */ + + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + dbus_message_unref(message); + dbus_message_unref(reply); + + return b; + +fail: + if (dbus_error_is_set(&error)) { + avahi_client_set_dbus_error(client, &error); + dbus_error_free(&error); + } + + if (b) + avahi_record_browser_free(b); + + if (message) + dbus_message_unref(message); + + if (reply) + dbus_message_unref(reply); + + return NULL; +} + +AvahiClient* avahi_record_browser_get_client (AvahiRecordBrowser *b) { + assert(b); + return b->client; +} + +int avahi_record_browser_free (AvahiRecordBrowser *b) { + AvahiClient *client; + int r = AVAHI_OK; + + assert(b); + client = b->client; + + if (b->path && avahi_client_is_connected(b->client)) + r = avahi_client_simple_method_call(client, b->path, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "Free"); + + AVAHI_LLIST_REMOVE(AvahiRecordBrowser, record_browsers, b->client->record_browsers, b); + + avahi_free(b->path); + avahi_free(b->name); + avahi_free(b); + return r; +} + +DBusHandlerResult avahi_record_browser_event(AvahiClient *client, AvahiBrowserEvent event, DBusMessage *message) { + AvahiRecordBrowser *b = NULL; + DBusError error; + const char *path; + char *name; + int32_t interface, protocol; + uint32_t flags = 0; + uint16_t clazz, type; + void *rdata = NULL; + int rdata_size = 0; + + dbus_error_init (&error); + + if (!(path = dbus_message_get_path(message))) + goto fail; + + for (b = client->record_browsers; b; b = b->record_browsers_next) + if (strcmp (b->path, path) == 0) + break; + + if (!b) + goto fail; + + interface = b->interface; + protocol = b->protocol; + clazz = b->clazz; + type = b->type; + name = b->name; + + switch (event) { + case AVAHI_BROWSER_NEW: + case AVAHI_BROWSER_REMOVE: { + DBusMessageIter iter, sub; + int j; + + if (!dbus_message_get_args ( + message, &error, + DBUS_TYPE_INT32, &interface, + DBUS_TYPE_INT32, &protocol, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_UINT16, &clazz, + DBUS_TYPE_UINT16, &type, + DBUS_TYPE_INVALID) || + dbus_error_is_set(&error)) { + fprintf(stderr, "Failed to parse browser event.\n"); + goto fail; + } + + + dbus_message_iter_init(message, &iter); + + for (j = 0; j < 5; j++) + dbus_message_iter_next(&iter); + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY || + dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_BYTE) + goto fail; + + dbus_message_iter_recurse(&iter, &sub); + dbus_message_iter_get_fixed_array(&sub, &rdata, &rdata_size); + + dbus_message_iter_next(&iter); + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT32) + goto fail; + + dbus_message_iter_get_basic(&iter, &flags); + + break; + } + + case AVAHI_BROWSER_CACHE_EXHAUSTED: + case AVAHI_BROWSER_ALL_FOR_NOW: + break; + + case AVAHI_BROWSER_FAILURE: { + char *etxt; + + if (!dbus_message_get_args( + message, &error, + DBUS_TYPE_STRING, &etxt, + DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) { + fprintf(stderr, "Failed to parse browser event.\n"); + goto fail; + } + + avahi_client_set_errno(b->client, avahi_error_dbus_to_number(etxt)); + break; + } + } + + b->callback(b, (AvahiIfIndex) interface, (AvahiProtocol) protocol, event, name, clazz, type, rdata, (size_t) rdata_size, (AvahiLookupResultFlags) flags, b->userdata); + + return DBUS_HANDLER_RESULT_HANDLED; + +fail: + dbus_error_free (&error); + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} diff --git a/libgamestream/avahi-client/check-nss-test.c b/libgamestream/avahi-client/check-nss-test.c new file mode 100644 index 00000000..7c155002 --- /dev/null +++ b/libgamestream/avahi-client/check-nss-test.c @@ -0,0 +1,31 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include + +int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { + printf("NSS Support available: %s\n", avahi_nss_support() ? "yes" : "no"); + return 0; +} diff --git a/libgamestream/avahi-client/check-nss.c b/libgamestream/avahi-client/check-nss.c new file mode 100644 index 00000000..ea266c4d --- /dev/null +++ b/libgamestream/avahi-client/check-nss.c @@ -0,0 +1,55 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef HAVE_DLOPEN +#include +#endif +#include + +#include "client.h" + +int avahi_nss_support(void) { + int b = 0; + +#ifdef HAVE_DLOPEN + static const char * const libs[] = { + "libnss_mdns.so.2", + "libnss_mdns4.so.2", + "libnss_mdns6.so.2", + NULL }; + + const char * const *l; + + for (l = libs; *l; l++) { + void *dl; + + if ((dl = dlopen(*l, RTLD_LAZY))) { + b = 1; + dlclose(dl); + break; + } + } +#endif + + return b; +} diff --git a/libgamestream/avahi-client/client-test.c b/libgamestream/avahi-client/client-test.c new file mode 100644 index 00000000..7d04a6a2 --- /dev/null +++ b/libgamestream/avahi-client/client-test.c @@ -0,0 +1,328 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +static const AvahiPoll *poll_api = NULL; +static AvahiSimplePoll *simple_poll = NULL; + +static void avahi_client_callback (AvahiClient *c, AvahiClientState state, void *userdata) { + printf ("CLIENT: Callback on %p, state -> %d, data -> %s\n", (void*) c, state, (char*)userdata); +} + +static void avahi_entry_group_callback (AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata) { + printf ("ENTRY-GROUP: Callback on %p, state -> %d, data -> %s\n", (void*) g, state, (char*)userdata); +} + +static void avahi_entry_group2_callback (AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata) { + printf ("ENTRY-GROUP2: Callback on %p, state -> %d, data -> %s\n", (void*) g, state, (char*)userdata); +} + +static void avahi_domain_browser_callback( + AvahiDomainBrowser *b, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiBrowserEvent event, + const char *domain, + AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, + void *userdata) { + + printf ("DOMAIN-BROWSER: Callback on %p, interface (%d), protocol (%d), event (%d), domain (%s), data (%s)\n", (void*) b, interface, protocol, event, domain ? domain : "NULL", (char*)userdata); +} + +static void avahi_service_resolver_callback( + AvahiServiceResolver *r, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiResolverEvent event, + const char *name, + const char *type, + const char *domain, + const char *host_name, + const AvahiAddress *a, + uint16_t port, + AvahiStringList *txt, + AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, + void *userdata) { + + char addr[64]; + char *txtr; + if (event == AVAHI_RESOLVER_FAILURE) { + printf ("SERVICE-RESOLVER: ServiceResolver %p timed out (%s %s)\n", (void*) r, name, type); + return; + } + avahi_address_snprint (addr, sizeof (addr), a); + txtr = avahi_string_list_to_string (txt); + printf ("SERVICE-RESOLVER: Callback on ServiceResolver, interface (%d), protocol (%d), event (%d), name (%s), type (%s), domain (%s), host_name (%s), address (%s), port (%d), txtdata (%s), data(%s)\n", interface, protocol, event, name, type, domain, host_name, addr, port, txtr, (char*)userdata); + avahi_free(txtr); +} + +static void avahi_service_browser_callback ( + AvahiServiceBrowser *b, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiBrowserEvent event, + const char *name, + const char *type, + const char *domain, + AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, + void *userdata) { + + AvahiServiceResolver *sr; + + printf ("SERVICE-BROWSER: Callback on %p, interface (%d), protocol (%d), event (%d), name (%s), type (%s), domain (%s), data (%s)\n", (void*) b, interface, protocol, event, name ? name : "NULL", type, domain ? domain : "NULL", (char*)userdata); + + if (b && name) + { + sr = avahi_service_resolver_new (avahi_service_browser_get_client (b), interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, 0, avahi_service_resolver_callback, (char*) "xxXXxx"); + printf("New service resolver %p\n", (void*) sr); + } +} + +static void avahi_service_type_browser_callback ( + AvahiServiceTypeBrowser *b, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiBrowserEvent event, + const char *type, + const char *domain, + AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, + void *userdata) { + + printf ("SERVICE-TYPE-BROWSER: Callback on %p, interface (%d), protocol (%d), event (%d), type (%s), domain (%s), data (%s)\n", (void*) b, interface, protocol, event, type ? type : "NULL", domain ? domain : "NULL", (char*)userdata); +} + +static void avahi_address_resolver_callback ( + AVAHI_GCC_UNUSED AvahiAddressResolver *r, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiResolverEvent event, + const AvahiAddress *address, + const char *name, + AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, + void *userdata) { + + char addr[64]; + if (event == AVAHI_RESOLVER_FAILURE) { + printf ("ADDRESS-RESOLVER: Callback on AddressResolver, timed out.\n"); + return; + } + avahi_address_snprint (addr, sizeof (addr), address); + printf ("ADDRESS-RESOLVER: Callback on AddressResolver, interface (%d), protocol (%d), even (%d), address (%s), name (%s), data(%s)\n", interface, protocol, event, addr, name, (char*) userdata); +} + +static void avahi_host_name_resolver_callback ( + AvahiHostNameResolver *r, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiResolverEvent event, + const char *name, + const AvahiAddress *a, + AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, + void *userdata) { + + AvahiClient *client; + AvahiAddressResolver *ar; + char addr[64]; + + if (event == AVAHI_RESOLVER_FAILURE) { + printf ("HOST-NAME-RESOLVER: Callback on HostNameResolver, timed out.\n"); + return; + } + client = avahi_host_name_resolver_get_client (r); +ar = avahi_address_resolver_new(client, interface, protocol, a, 0, avahi_address_resolver_callback, (char*) "omghai6u"); + if (ar) + { + printf ("Succesfully created address resolver object\n"); + } else { + printf ("Failed to create AddressResolver\n"); + } + avahi_address_snprint (addr, sizeof (addr), a); + printf ("HOST-NAME-RESOLVER: Callback on HostNameResolver, interface (%d), protocol (%d), event (%d), name (%s), address (%s), data (%s)\n", interface, protocol, event, name, addr, (char*)userdata); +} +static void test_free_domain_browser(AVAHI_GCC_UNUSED AvahiTimeout *timeout, void* userdata) +{ + AvahiServiceBrowser *b = userdata; + printf ("Freeing domain browser\n"); + avahi_service_browser_free (b); +} + +static void test_free_entry_group (AVAHI_GCC_UNUSED AvahiTimeout *timeout, void* userdata) +{ + AvahiEntryGroup *g = userdata; + printf ("Freeing entry group\n"); + avahi_entry_group_free (g); +} + +static void test_entry_group_reset (AVAHI_GCC_UNUSED AvahiTimeout *timeout, void* userdata) +{ + AvahiEntryGroup *g = userdata; + + printf ("Resetting entry group\n"); + avahi_entry_group_reset (g); + + avahi_entry_group_add_service (g, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "Lathiat's Site", "_http._tcp", NULL, NULL, 80, "foo=bar2", NULL); + + avahi_entry_group_commit (g); +} + +static void test_entry_group_update(AVAHI_GCC_UNUSED AvahiTimeout *timeout, void* userdata) { + AvahiEntryGroup *g = userdata; + + printf ("Updating entry group\n"); + + avahi_entry_group_update_service_txt(g, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "Lathiat's Site", "_http._tcp", NULL, "foo=bar3", NULL); +} + +static void terminate(AVAHI_GCC_UNUSED AvahiTimeout *timeout, AVAHI_GCC_UNUSED void *userdata) { + + avahi_simple_poll_quit(simple_poll); +} + +int main (AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { + AvahiClient *avahi; + AvahiEntryGroup *group, *group2; + AvahiDomainBrowser *domain; + AvahiServiceBrowser *sb; + AvahiServiceTypeBrowser *st; + AvahiHostNameResolver *hnr; + AvahiAddress *aar; + const char *ret; + int error; + uint32_t cookie; + struct timeval tv; + AvahiAddress a; + + simple_poll = avahi_simple_poll_new(); + poll_api = avahi_simple_poll_get(simple_poll); + + if (!(avahi = avahi_client_new(poll_api, 0, avahi_client_callback, (char*) "omghai2u", &error))) { + fprintf(stderr, "Client failed: %s\n", avahi_strerror(error)); + goto fail; + } + + printf("State: %i\n", avahi_client_get_state(avahi)); + + ret = avahi_client_get_version_string (avahi); + printf("Avahi Server Version: %s (Error Return: %s)\n", ret, ret ? "OK" : avahi_strerror(avahi_client_errno(avahi))); + + ret = avahi_client_get_host_name (avahi); + printf("Host Name: %s (Error Return: %s)\n", ret, ret ? "OK" : avahi_strerror(avahi_client_errno(avahi))); + + ret = avahi_client_get_domain_name (avahi); + printf("Domain Name: %s (Error Return: %s)\n", ret, ret ? "OK" : avahi_strerror(avahi_client_errno(avahi))); + + ret = avahi_client_get_host_name_fqdn (avahi); + printf("FQDN: %s (Error Return: %s)\n", ret, ret ? "OK" : avahi_strerror(avahi_client_errno(avahi))); + + cookie = avahi_client_get_local_service_cookie(avahi); + printf("Local service cookie: %u (Error Return: %s)\n", cookie, cookie != AVAHI_SERVICE_COOKIE_INVALID ? "OK" : avahi_strerror(avahi_client_errno(avahi))); + + group = avahi_entry_group_new(avahi, avahi_entry_group_callback, (char*) "omghai"); + printf("Creating entry group: %s\n", group ? "OK" : avahi_strerror(avahi_client_errno (avahi))); + + assert(group); + + printf("Sucessfully created entry group %p\n", (void*) group); + + printf("%s\n", avahi_strerror(avahi_entry_group_add_service (group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "Lathiat's Site", "_http._tcp", NULL, NULL, 80, "foo=bar", NULL))); + printf("add_record: %d\n", avahi_entry_group_add_record (group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "TestX", 0x01, 0x10, 120, "\5booya", 6)); + + avahi_entry_group_commit (group); + + domain = avahi_domain_browser_new (avahi, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DOMAIN_BROWSER_BROWSE, 0, avahi_domain_browser_callback, (char*) "omghai3u"); + + if (domain == NULL) + printf ("Failed to create domain browser object\n"); + else + printf ("Sucessfully created domain browser %p\n", (void*) domain); + + st = avahi_service_type_browser_new (avahi, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, 0, avahi_service_type_browser_callback, (char*) "omghai3u"); + if (st == NULL) + printf ("Failed to create service type browser object\n"); + else + printf ("Sucessfully created service type browser %p\n", (void*) st); + + sb = avahi_service_browser_new (avahi, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_http._tcp", NULL, 0, avahi_service_browser_callback, (char*) "omghai3u"); + if (sb == NULL) + printf ("Failed to create service browser object\n"); + else + printf ("Sucessfully created service browser %p\n", (void*) sb); + + hnr = avahi_host_name_resolver_new (avahi, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "ecstasy.local", AVAHI_PROTO_UNSPEC, 0, avahi_host_name_resolver_callback, (char*) "omghai4u"); + if (hnr == NULL) + printf ("Failed to create hostname resolver object\n"); + else + printf ("Successfully created hostname resolver object\n"); + + aar = avahi_address_parse ("224.0.0.251", AVAHI_PROTO_UNSPEC, &a); + if (aar == NULL) { + printf ("failed to create address object\n"); + } else { + group2 = avahi_entry_group_new (avahi, avahi_entry_group2_callback, (char*) "omghai222"); + if ((error = avahi_entry_group_add_address (group2, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "test-mdns.local.", aar)) < 0) + { + printf ("*** failed to add address to entry group: %s\n", avahi_strerror (error)); + avahi_entry_group_free (group2); + } else { + printf ("*** success, added address\n"); + avahi_entry_group_commit (group2); + } + } + + avahi_elapse_time(&tv, 8000, 0); + poll_api->timeout_new(poll_api, &tv, test_entry_group_reset, group); + avahi_elapse_time(&tv, 15000, 0); + poll_api->timeout_new(poll_api, &tv, test_entry_group_update, group); + avahi_elapse_time(&tv, 20000, 0); + poll_api->timeout_new(poll_api, &tv, test_free_entry_group, group); + avahi_elapse_time(&tv, 25000, 0); + poll_api->timeout_new(poll_api, &tv, test_free_domain_browser, sb); + + avahi_elapse_time(&tv, 30000, 0); + poll_api->timeout_new(poll_api, &tv, terminate, NULL); + + avahi_simple_poll_loop(simple_poll); + + printf("terminating...\n"); + +fail: + + if (avahi) + avahi_client_free (avahi); + + if (simple_poll) + avahi_simple_poll_free(simple_poll); + + return 0; +} diff --git a/libgamestream/avahi-client/client.c b/libgamestream/avahi-client/client.c new file mode 100644 index 00000000..70cc35d9 --- /dev/null +++ b/libgamestream/avahi-client/client.c @@ -0,0 +1,958 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "client.h" +#include "internal.h" + +#define AVAHI_CLIENT_DBUS_API_SUPPORTED ((uint32_t) 0x0201) + +static int init_server(AvahiClient *client, int *ret_error); + +int avahi_client_set_errno (AvahiClient *client, int error) { + assert(client); + + return client->error = error; +} + +int avahi_client_set_dbus_error(AvahiClient *client, DBusError *error) { + assert(client); + assert(error); + + return avahi_client_set_errno(client, avahi_error_dbus_to_number(error->name)); +} + +static void client_set_state(AvahiClient *client, AvahiClientState state) { + assert(client); + + if (client->state == state) + return; + + client->state = state; + + switch (client->state) { + case AVAHI_CLIENT_FAILURE: + if (client->bus) { +#ifdef HAVE_DBUS_CONNECTION_CLOSE + dbus_connection_close(client->bus); +#else + dbus_connection_disconnect(client->bus); +#endif + dbus_connection_unref(client->bus); + client->bus = NULL; + } + + /* Fall through */ + + case AVAHI_CLIENT_S_COLLISION: + case AVAHI_CLIENT_S_REGISTERING: + + /* Clear cached strings */ + avahi_free(client->host_name); + avahi_free(client->host_name_fqdn); + avahi_free(client->domain_name); + + client->host_name = NULL; + client->host_name_fqdn = NULL; + client->domain_name = NULL; + break; + + case AVAHI_CLIENT_S_RUNNING: + case AVAHI_CLIENT_CONNECTING: + break; + + } + + if (client->callback) + client->callback (client, state, client->userdata); +} + +static DBusHandlerResult filter_func(DBusConnection *bus, DBusMessage *message, void *userdata) { + AvahiClient *client = userdata; + DBusError error; + + assert(bus); + assert(message); + + dbus_error_init(&error); + +/* fprintf(stderr, "dbus: interface=%s, path=%s, member=%s\n", */ +/* dbus_message_get_interface (message), */ +/* dbus_message_get_path (message), */ +/* dbus_message_get_member (message)); */ + + if (dbus_message_is_signal(message, DBUS_INTERFACE_LOCAL, "Disconnected")) { + + /* The DBUS server died or kicked us */ + avahi_client_set_errno(client, AVAHI_ERR_DISCONNECTED); + goto fail; + + } else if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS, "NameAcquired")) { + + /* Ignore this message */ + + } else if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) { + char *name, *old, *new; + + if (!dbus_message_get_args( + message, &error, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_STRING, &old, + DBUS_TYPE_STRING, &new, + DBUS_TYPE_INVALID) || dbus_error_is_set(&error)) { + + fprintf(stderr, "WARNING: Failed to parse NameOwnerChanged signal: %s\n", error.message); + avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (strcmp(name, AVAHI_DBUS_NAME) == 0) { + + if (old[0] && + avahi_client_is_connected(client)) { + + /* Regardless if the server lost its name or + * if the name was transfered: our services are no longer + * available, so we disconnect ourselves */ + avahi_client_set_errno(client, AVAHI_ERR_DISCONNECTED); + goto fail; + + } else if (client->state == AVAHI_CLIENT_CONNECTING && (!old || *old == 0)) { + int ret; + + /* Server appeared */ + + if ((ret = init_server(client, NULL)) < 0) { + avahi_client_set_errno(client, ret); + goto fail; + } + } + } + + } else if (!avahi_client_is_connected(client)) { + + /* Ignore messages we get in unconnected state */ + + } else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_SERVER, "StateChanged")) { + int32_t state; + char *e = NULL; + int c; + + if (!dbus_message_get_args( + message, &error, + DBUS_TYPE_INT32, &state, + DBUS_TYPE_STRING, &e, + DBUS_TYPE_INVALID) || dbus_error_is_set (&error)) { + + fprintf(stderr, "WARNING: Failed to parse Server.StateChanged signal: %s\n", error.message); + avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if ((c = avahi_error_dbus_to_number(e)) != AVAHI_OK) + avahi_client_set_errno(client, c); + + client_set_state(client, (AvahiClientState) state); + + } else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "StateChanged")) { + const char *path; + AvahiEntryGroup *g; + path = dbus_message_get_path(message); + + for (g = client->groups; g; g = g->groups_next) + if (strcmp(g->path, path) == 0) + break; + + if (g) { + int32_t state; + char *e; + int c; + + if (!dbus_message_get_args( + message, &error, + DBUS_TYPE_INT32, &state, + DBUS_TYPE_STRING, &e, + DBUS_TYPE_INVALID) || + dbus_error_is_set(&error)) { + + fprintf(stderr, "WARNING: Failed to parse EntryGroup.StateChanged signal: %s\n", error.message); + avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if ((c = avahi_error_dbus_to_number(e)) != AVAHI_OK) + avahi_client_set_errno(client, c); + + avahi_entry_group_set_state(g, state); + } + + } else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "ItemNew")) + return avahi_domain_browser_event(client, AVAHI_BROWSER_NEW, message); + else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "ItemRemove")) + return avahi_domain_browser_event(client, AVAHI_BROWSER_REMOVE, message); + else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "CacheExhausted")) + return avahi_domain_browser_event(client, AVAHI_BROWSER_CACHE_EXHAUSTED, message); + else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "AllForNow")) + return avahi_domain_browser_event(client, AVAHI_BROWSER_ALL_FOR_NOW, message); + else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "Failure")) + return avahi_domain_browser_event(client, AVAHI_BROWSER_FAILURE, message); + + else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "ItemNew")) + return avahi_service_type_browser_event (client, AVAHI_BROWSER_NEW, message); + else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "ItemRemove")) + return avahi_service_type_browser_event (client, AVAHI_BROWSER_REMOVE, message); + else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "CacheExhausted")) + return avahi_service_type_browser_event (client, AVAHI_BROWSER_CACHE_EXHAUSTED, message); + else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "AllForNow")) + return avahi_service_type_browser_event (client, AVAHI_BROWSER_ALL_FOR_NOW, message); + else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "Failure")) + return avahi_service_type_browser_event (client, AVAHI_BROWSER_FAILURE, message); + + else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "ItemNew")) + return avahi_service_browser_event (client, AVAHI_BROWSER_NEW, message); + else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "ItemRemove")) + return avahi_service_browser_event (client, AVAHI_BROWSER_REMOVE, message); + else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "CacheExhausted")) + return avahi_service_browser_event (client, AVAHI_BROWSER_CACHE_EXHAUSTED, message); + else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "AllForNow")) + return avahi_service_browser_event (client, AVAHI_BROWSER_ALL_FOR_NOW, message); + else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "Failure")) + return avahi_service_browser_event (client, AVAHI_BROWSER_FAILURE, message); + + else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Found")) + return avahi_service_resolver_event (client, AVAHI_RESOLVER_FOUND, message); + else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Failure")) + return avahi_service_resolver_event (client, AVAHI_RESOLVER_FAILURE, message); + + else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Found")) + return avahi_host_name_resolver_event (client, AVAHI_RESOLVER_FOUND, message); + else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Failure")) + return avahi_host_name_resolver_event (client, AVAHI_RESOLVER_FAILURE, message); + + else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Found")) + return avahi_address_resolver_event (client, AVAHI_RESOLVER_FOUND, message); + else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Failure")) + return avahi_address_resolver_event (client, AVAHI_RESOLVER_FAILURE, message); + + else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "ItemNew")) + return avahi_record_browser_event (client, AVAHI_BROWSER_NEW, message); + else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "ItemRemove")) + return avahi_record_browser_event (client, AVAHI_BROWSER_REMOVE, message); + else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "CacheExhausted")) + return avahi_record_browser_event (client, AVAHI_BROWSER_CACHE_EXHAUSTED, message); + else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "AllForNow")) + return avahi_record_browser_event (client, AVAHI_BROWSER_ALL_FOR_NOW, message); + else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "Failure")) + return avahi_record_browser_event (client, AVAHI_BROWSER_FAILURE, message); + + else { + + fprintf(stderr, "WARNING: Unhandled message: interface=%s, path=%s, member=%s\n", + dbus_message_get_interface(message), + dbus_message_get_path(message), + dbus_message_get_member(message)); + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + + return DBUS_HANDLER_RESULT_HANDLED; + +fail: + + if (dbus_error_is_set(&error)) { + avahi_client_set_errno(client, avahi_error_dbus_to_number(error.name)); + dbus_error_free(&error); + } + + client_set_state(client, AVAHI_CLIENT_FAILURE); + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +static int get_server_state(AvahiClient *client, int *ret_error) { + DBusMessage *message = NULL, *reply = NULL; + DBusError error; + int32_t state; + int e = AVAHI_ERR_NO_MEMORY; + + assert(client); + + dbus_error_init(&error); + + if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "GetState"))) + goto fail; + + reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error); + + if (!reply || dbus_error_is_set (&error)) + goto fail; + + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INT32, &state, DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) + goto fail; + + client_set_state(client, (AvahiClientState) state); + + dbus_message_unref(message); + dbus_message_unref(reply); + + return AVAHI_OK; + +fail: + if (dbus_error_is_set(&error)) { + e = avahi_error_dbus_to_number (error.name); + dbus_error_free(&error); + } + + if (ret_error) + *ret_error = e; + + if (message) + dbus_message_unref(message); + if (reply) + dbus_message_unref(reply); + + return e; +} + +static int check_version(AvahiClient *client, int *ret_error) { + DBusMessage *message = NULL, *reply = NULL; + DBusError error; + uint32_t version; + int e = AVAHI_ERR_NO_MEMORY; + + assert(client); + + dbus_error_init(&error); + + if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "GetAPIVersion"))) + goto fail; + + reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error); + + if (!reply || dbus_error_is_set (&error)) { + char *version_str; + + if (!dbus_error_is_set(&error) || strcmp(error.name, DBUS_ERROR_UNKNOWN_METHOD)) + goto fail; + + /* If the method GetAPIVersion is not known, we look if + * GetVersionString matches "avahi 0.6" which is the only + * version we support which doesn't have GetAPIVersion() .*/ + + dbus_message_unref(message); + if (reply) dbus_message_unref(reply); + dbus_error_free(&error); + + if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "GetVersionString"))) + goto fail; + + reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error); + + if (!reply || dbus_error_is_set (&error)) + goto fail; + + if (!dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &version_str, DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) + goto fail; + + version = strcmp(version_str, "avahi 0.6") == 0 ? 0x0201 : 0x0000; + + } else { + + if (!dbus_message_get_args (reply, &error, DBUS_TYPE_UINT32, &version, DBUS_TYPE_INVALID) || + dbus_error_is_set(&error)) + goto fail; + } + + /*fprintf(stderr, "API Version 0x%04x\n", version);*/ + + if ((version & 0xFF00) != (AVAHI_CLIENT_DBUS_API_SUPPORTED & 0xFF00) || + (version & 0x00FF) < (AVAHI_CLIENT_DBUS_API_SUPPORTED & 0x00FF)) { + e = AVAHI_ERR_VERSION_MISMATCH; + goto fail; + } + + dbus_message_unref(message); + dbus_message_unref(reply); + + return AVAHI_OK; + +fail: + if (dbus_error_is_set(&error)) { + e = avahi_error_dbus_to_number (error.name); + dbus_error_free(&error); + } + + if (ret_error) + *ret_error = e; + + if (message) + dbus_message_unref(message); + if (reply) + dbus_message_unref(reply); + + return e; +} + +static int init_server(AvahiClient *client, int *ret_error) { + int r; + + if ((r = check_version(client, ret_error)) < 0) + return r; + + if ((r = get_server_state(client, ret_error)) < 0) + return r; + + return AVAHI_OK; +} + +/* This function acts like dbus_bus_get but creates a private + * connection instead. */ +static DBusConnection* avahi_dbus_bus_get(DBusError *error) { + DBusConnection *c; + +#ifdef HAVE_DBUS_BUS_GET_PRIVATE + if (!(c = dbus_bus_get_private(DBUS_BUS_SYSTEM, error))) + return NULL; + + dbus_connection_set_exit_on_disconnect(c, FALSE); +#else + const char *a; + + if (!(a = getenv("DBUS_SYSTEM_BUS_ADDRESS")) || !*a) + a = DBUS_SYSTEM_BUS_DEFAULT_ADDRESS; + + if (!(c = dbus_connection_open_private(a, error))) + return NULL; + + dbus_connection_set_exit_on_disconnect(c, FALSE); + + if (!dbus_bus_register(c, error)) { +#ifdef HAVE_DBUS_CONNECTION_CLOSE + dbus_connection_close(c); +#else + dbus_connection_disconnect(c); +#endif + dbus_connection_unref(c); + return NULL; + } +#endif + + return c; +} + +AvahiClient *avahi_client_new(const AvahiPoll *poll_api, AvahiClientFlags flags, AvahiClientCallback callback, void *userdata, int *ret_error) { + AvahiClient *client = NULL; + DBusError error; + DBusMessage *message = NULL, *reply = NULL; + + avahi_init_i18n(); + + dbus_error_init(&error); + + if (!(client = avahi_new(AvahiClient, 1))) { + if (ret_error) + *ret_error = AVAHI_ERR_NO_MEMORY; + goto fail; + } + + client->poll_api = poll_api; + client->error = AVAHI_OK; + client->callback = callback; + client->userdata = userdata; + client->state = (AvahiClientState) -1; + client->flags = flags; + + client->host_name = NULL; + client->host_name_fqdn = NULL; + client->domain_name = NULL; + client->version_string = NULL; + client->local_service_cookie_valid = 0; + + AVAHI_LLIST_HEAD_INIT(AvahiEntryGroup, client->groups); + AVAHI_LLIST_HEAD_INIT(AvahiDomainBrowser, client->domain_browsers); + AVAHI_LLIST_HEAD_INIT(AvahiServiceBrowser, client->service_browsers); + AVAHI_LLIST_HEAD_INIT(AvahiServiceTypeBrowser, client->service_type_browsers); + AVAHI_LLIST_HEAD_INIT(AvahiServiceResolver, client->service_resolvers); + AVAHI_LLIST_HEAD_INIT(AvahiHostNameResolver, client->host_name_resolvers); + AVAHI_LLIST_HEAD_INIT(AvahiAddressResolver, client->address_resolvers); + AVAHI_LLIST_HEAD_INIT(AvahiRecordBrowser, client->record_browsers); + + if (!(client->bus = avahi_dbus_bus_get(&error)) || dbus_error_is_set(&error)) { + if (ret_error) + *ret_error = AVAHI_ERR_DBUS_ERROR; + goto fail; + } + + if (avahi_dbus_connection_glue(client->bus, poll_api) < 0) { + if (ret_error) + *ret_error = AVAHI_ERR_NO_MEMORY; /* Not optimal */ + goto fail; + } + + if (!dbus_connection_add_filter(client->bus, filter_func, client, NULL)) { + if (ret_error) + *ret_error = AVAHI_ERR_NO_MEMORY; + goto fail; + } + + dbus_bus_add_match( + client->bus, + "type='signal', " + "interface='" AVAHI_DBUS_INTERFACE_SERVER "', " + "sender='" AVAHI_DBUS_NAME "', " + "path='" AVAHI_DBUS_PATH_SERVER "'", + &error); + + if (dbus_error_is_set(&error)) + goto fail; + + dbus_bus_add_match ( + client->bus, + "type='signal', " + "interface='" DBUS_INTERFACE_DBUS "', " + "sender='" DBUS_SERVICE_DBUS "', " + "path='" DBUS_PATH_DBUS "'", + &error); + + if (dbus_error_is_set(&error)) + goto fail; + + dbus_bus_add_match( + client->bus, + "type='signal', " + "interface='" DBUS_INTERFACE_LOCAL "'", + &error); + + if (dbus_error_is_set(&error)) + goto fail; + + if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, "org.freedesktop.DBus.Peer", "Ping"))) + goto fail; + + reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error); + + if (!reply || dbus_error_is_set (&error)) { + /* We free the error so its not set, that way the fail target + * will return the NO_DAEMON error rather than a DBUS error */ + dbus_error_free(&error); + + if (!(flags & AVAHI_CLIENT_NO_FAIL)) { + + if (ret_error) + *ret_error = AVAHI_ERR_NO_DAEMON; + + goto fail; + } + + /* The user doesn't want this call to fail if the daemon is not + * available, so let's return succesfully */ + client_set_state(client, AVAHI_CLIENT_CONNECTING); + + } else { + + if (init_server(client, ret_error) < 0) + goto fail; + } + + dbus_message_unref(message); + + if (reply) + dbus_message_unref(reply); + + return client; + +fail: + + if (message) + dbus_message_unref(message); + if (reply) + dbus_message_unref(reply); + + if (client) + avahi_client_free(client); + + if (dbus_error_is_set(&error)) { + + if (ret_error) { + if (strcmp(error.name, DBUS_ERROR_FILE_NOT_FOUND) == 0) + /* DBUS returns this error when the DBUS daemon is not running */ + *ret_error = AVAHI_ERR_NO_DAEMON; + else + *ret_error = avahi_error_dbus_to_number(error.name); + } + + dbus_error_free(&error); + } + + return NULL; +} + +void avahi_client_free(AvahiClient *client) { + assert(client); + + if (client->bus) + /* Disconnect in advance, so that the free() functions won't + * issue needless server calls */ +#ifdef HAVE_DBUS_CONNECTION_CLOSE + dbus_connection_close(client->bus); +#else + dbus_connection_disconnect(client->bus); +#endif + + while (client->groups) + avahi_entry_group_free(client->groups); + + while (client->domain_browsers) + avahi_domain_browser_free(client->domain_browsers); + + while (client->service_browsers) + avahi_service_browser_free(client->service_browsers); + + while (client->service_type_browsers) + avahi_service_type_browser_free(client->service_type_browsers); + + while (client->service_resolvers) + avahi_service_resolver_free(client->service_resolvers); + + while (client->host_name_resolvers) + avahi_host_name_resolver_free(client->host_name_resolvers); + + while (client->address_resolvers) + avahi_address_resolver_free(client->address_resolvers); + + while (client->record_browsers) + avahi_record_browser_free(client->record_browsers); + + if (client->bus) + dbus_connection_unref(client->bus); + + avahi_free(client->version_string); + avahi_free(client->host_name); + avahi_free(client->host_name_fqdn); + avahi_free(client->domain_name); + + avahi_free(client); +} + +static char* avahi_client_get_string_reply_and_block (AvahiClient *client, const char *method, const char *param) { + DBusMessage *message = NULL, *reply = NULL; + DBusError error; + char *ret, *n; + + assert(client); + assert(method); + + dbus_error_init (&error); + + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, method))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (param) { + if (!dbus_message_append_args (message, DBUS_TYPE_STRING, ¶m, DBUS_TYPE_INVALID)) { + avahi_client_set_errno (client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + } + + reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error); + + if (!reply || dbus_error_is_set (&error)) + goto fail; + + if (!dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &ret, DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) + goto fail; + + if (!(n = avahi_strdup(ret))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + dbus_message_unref(message); + dbus_message_unref(reply); + + return n; + +fail: + + if (message) + dbus_message_unref(message); + if (reply) + dbus_message_unref(reply); + + if (dbus_error_is_set(&error)) { + avahi_client_set_dbus_error(client, &error); + dbus_error_free(&error); + } + + return NULL; +} + +const char* avahi_client_get_version_string(AvahiClient *client) { + assert(client); + + if (!avahi_client_is_connected(client)) { + avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); + return NULL; + } + + if (!client->version_string) + client->version_string = avahi_client_get_string_reply_and_block(client, "GetVersionString", NULL); + + return client->version_string; +} + +const char* avahi_client_get_domain_name(AvahiClient *client) { + assert(client); + + if (!avahi_client_is_connected(client)) { + avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); + return NULL; + } + + if (!client->domain_name) + client->domain_name = avahi_client_get_string_reply_and_block(client, "GetDomainName", NULL); + + return client->domain_name; +} + +const char* avahi_client_get_host_name(AvahiClient *client) { + assert(client); + + if (!avahi_client_is_connected(client)) { + avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); + return NULL; + } + + if (!client->host_name) + client->host_name = avahi_client_get_string_reply_and_block(client, "GetHostName", NULL); + + return client->host_name; +} + +const char* avahi_client_get_host_name_fqdn (AvahiClient *client) { + assert(client); + + if (!avahi_client_is_connected(client)) { + avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); + return NULL; + } + + if (!client->host_name_fqdn) + client->host_name_fqdn = avahi_client_get_string_reply_and_block(client, "GetHostNameFqdn", NULL); + + return client->host_name_fqdn; +} + +AvahiClientState avahi_client_get_state(AvahiClient *client) { + assert(client); + + return client->state; +} + +int avahi_client_errno(AvahiClient *client) { + assert(client); + + return client->error; +} + +/* Just for internal use */ +int avahi_client_simple_method_call(AvahiClient *client, const char *path, const char *interface, const char *method) { + DBusMessage *message = NULL, *reply = NULL; + DBusError error; + int r = AVAHI_OK; + + dbus_error_init(&error); + + assert(client); + assert(path); + assert(interface); + assert(method); + + if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, path, interface, method))) { + r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || + dbus_error_is_set (&error)) { + r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) { + r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + dbus_message_unref(message); + dbus_message_unref(reply); + + return AVAHI_OK; + +fail: + if (dbus_error_is_set(&error)) { + r = avahi_client_set_dbus_error(client, &error); + dbus_error_free(&error); + } + + if (message) + dbus_message_unref(message); + + if (reply) + dbus_message_unref(reply); + + return r; +} + +uint32_t avahi_client_get_local_service_cookie(AvahiClient *client) { + DBusMessage *message = NULL, *reply = NULL; + DBusError error; + assert(client); + + if (!avahi_client_is_connected(client)) { + avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); + return AVAHI_SERVICE_COOKIE_INVALID; + } + + if (client->local_service_cookie_valid) + return client->local_service_cookie; + + dbus_error_init (&error); + + if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "GetLocalServiceCookie"))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error); + + if (!reply || dbus_error_is_set (&error)) + goto fail; + + if (!dbus_message_get_args (reply, &error, DBUS_TYPE_UINT32, &client->local_service_cookie, DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) + goto fail; + + dbus_message_unref(message); + dbus_message_unref(reply); + + client->local_service_cookie_valid = 1; + return client->local_service_cookie; + +fail: + + if (message) + dbus_message_unref(message); + if (reply) + dbus_message_unref(reply); + + if (dbus_error_is_set(&error)) { + avahi_client_set_dbus_error(client, &error); + dbus_error_free(&error); + } + + return AVAHI_SERVICE_COOKIE_INVALID; +} + +int avahi_client_is_connected(AvahiClient *client) { + assert(client); + + return + client->bus && + dbus_connection_get_is_connected(client->bus) && + (client->state == AVAHI_CLIENT_S_RUNNING || client->state == AVAHI_CLIENT_S_REGISTERING || client->state == AVAHI_CLIENT_S_COLLISION); +} + +int avahi_client_set_host_name(AvahiClient* client, const char *name) { + DBusMessage *message = NULL, *reply = NULL; + DBusError error; + + assert(client); + + if (!avahi_client_is_connected(client)) + return avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); + + dbus_error_init (&error); + + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "SetHostName"))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (!dbus_message_append_args (message, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID)) { + avahi_client_set_errno (client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error); + + if (!reply || dbus_error_is_set (&error)) + goto fail; + + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) + goto fail; + + dbus_message_unref(message); + dbus_message_unref(reply); + + avahi_free(client->host_name); + client->host_name = NULL; + avahi_free(client->host_name_fqdn); + client->host_name_fqdn = NULL; + + return 0; + +fail: + + if (message) + dbus_message_unref(message); + if (reply) + dbus_message_unref(reply); + + if (dbus_error_is_set(&error)) { + avahi_client_set_dbus_error(client, &error); + dbus_error_free(&error); + } + + return client->error; +} diff --git a/libgamestream/avahi-client/client.h b/libgamestream/avahi-client/client.h new file mode 100644 index 00000000..1039da57 --- /dev/null +++ b/libgamestream/avahi-client/client.h @@ -0,0 +1,117 @@ +#ifndef fooclienthfoo +#define fooclienthfoo + +/*** + 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.1 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 Lesser 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. +***/ + +#include + +#include +#include +#include +#include +#include +#include + +/** \file client.h Definitions and functions for the client API over D-Bus */ + +AVAHI_C_DECL_BEGIN + +/** A connection context */ +typedef struct AvahiClient AvahiClient; + +/** States of a client object, a superset of AvahiServerState */ +typedef enum { + AVAHI_CLIENT_S_REGISTERING = AVAHI_SERVER_REGISTERING, /**< Server state: REGISTERING */ + AVAHI_CLIENT_S_RUNNING = AVAHI_SERVER_RUNNING, /**< Server state: RUNNING */ + AVAHI_CLIENT_S_COLLISION = AVAHI_SERVER_COLLISION, /**< Server state: COLLISION */ + AVAHI_CLIENT_FAILURE = 100, /**< Some kind of error happened on the client side */ + AVAHI_CLIENT_CONNECTING = 101 /**< We're still connecting. This state is only entered when AVAHI_CLIENT_NO_FAIL has been passed to avahi_client_new() and the daemon is not yet available. */ +} AvahiClientState; + +typedef enum { + AVAHI_CLIENT_IGNORE_USER_CONFIG = 1, /**< Don't read user configuration */ + AVAHI_CLIENT_NO_FAIL = 2 /**< Don't fail if the daemon is not available when avahi_client_new() is called, instead enter AVAHI_CLIENT_CONNECTING state and wait for the daemon to appear */ +} AvahiClientFlags; + +/** The function prototype for the callback of an AvahiClient */ +typedef void (*AvahiClientCallback) ( + AvahiClient *s, + AvahiClientState state /**< The new state of the client */, + void* userdata /**< The user data that was passed to avahi_client_new() */); + +/** @{ \name Construction and destruction */ + +/** Creates a new client instance */ +AvahiClient* avahi_client_new ( + const AvahiPoll *poll_api /**< The abstract event loop API to use */, + AvahiClientFlags flags /**< Some flags to modify the behaviour of the client library */, + AvahiClientCallback callback /**< A callback that is called whenever the state of the client changes. This may be NULL. Please note that this function is called for the first time from within the avahi_client_new() context! Thus, in the callback you should not make use of global variables that are initialized only after your call to avahi_client_new(). A common mistake is to store the AvahiClient pointer returned by avahi_client_new() in a global variable and assume that this global variable already contains the valid pointer when the callback is called for the first time. A work-around for this is to always use the AvahiClient pointer passed to the callback function instead of the global pointer. */, + void *userdata /**< Some arbitrary user data pointer that will be passed to the callback function */, + int *error /**< If creation of the client fails, this integer will contain the error cause. May be NULL if you aren't interested in the reason why avahi_client_new() failed. */); + +/** Free a client instance. This will automatically free all + * associated browser, resolve and entry group objects. All pointers + * to such objects become invalid! */ +void avahi_client_free(AvahiClient *client); + +/** @} */ + +/** @{ \name Properties */ + +/** Get the version of the server */ +const char* avahi_client_get_version_string (AvahiClient*); + +/** Get host name */ +const char* avahi_client_get_host_name (AvahiClient*); + +/** Set host name. \since 0.6.13 */ +int avahi_client_set_host_name(AvahiClient*, const char *name); + +/** Get domain name */ +const char* avahi_client_get_domain_name (AvahiClient*); + +/** Get FQDN domain name */ +const char* avahi_client_get_host_name_fqdn (AvahiClient*); + +/** Get state */ +AvahiClientState avahi_client_get_state(AvahiClient *client); + +/** @{ \name Error Handling */ + +/** Get the last error number. See avahi_strerror() for converting this error code into a human readable string. */ +int avahi_client_errno (AvahiClient*); + +/** @} */ + +/** \cond fulldocs */ +/** Return the local service cookie. returns AVAHI_SERVICE_COOKIE_INVALID on failure. */ +uint32_t avahi_client_get_local_service_cookie(AvahiClient *client); +/** \endcond */ + +/** @{ \name Libc NSS Support */ + +/** Return 1 if gethostbyname() supports mDNS lookups, 0 otherwise. \since 0.6.5 */ +int avahi_nss_support(void); + +/** @} */ + +AVAHI_C_DECL_END + +#endif diff --git a/libgamestream/avahi-client/entrygroup.c b/libgamestream/avahi-client/entrygroup.c new file mode 100644 index 00000000..d809d604 --- /dev/null +++ b/libgamestream/avahi-client/entrygroup.c @@ -0,0 +1,890 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include "client.h" +#include "internal.h" + +void avahi_entry_group_set_state(AvahiEntryGroup *group, AvahiEntryGroupState state) { + assert(group); + + if (group->state_valid && group->state == state) + return; + + group->state = state; + group->state_valid = 1; + + if (group->callback) + group->callback(group, state, group->userdata); +} + +static int retrieve_state(AvahiEntryGroup *group) { + DBusMessage *message = NULL, *reply = NULL; + DBusError error; + int r = AVAHI_OK; + int32_t state; + AvahiClient *client; + + dbus_error_init(&error); + + assert(group); + client = group->client; + + if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "GetState"))) { + r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || + dbus_error_is_set (&error)) { + r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INT32, &state, DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) { + r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + dbus_message_unref(message); + dbus_message_unref(reply); + + return state; + +fail: + if (dbus_error_is_set(&error)) { + r = avahi_client_set_dbus_error(client, &error); + dbus_error_free(&error); + } + + if (message) + dbus_message_unref(message); + + if (reply) + dbus_message_unref(reply); + + return r; +} + +AvahiEntryGroup* avahi_entry_group_new (AvahiClient *client, AvahiEntryGroupCallback callback, void *userdata) { + AvahiEntryGroup *group = NULL; + DBusMessage *message = NULL, *reply = NULL; + DBusError error; + char *path; + int state; + + assert(client); + + dbus_error_init (&error); + + if (!avahi_client_is_connected(client)) { + avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); + goto fail; + } + + if (!(group = avahi_new(AvahiEntryGroup, 1))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + group->client = client; + group->callback = callback; + group->userdata = userdata; + group->state_valid = 0; + group->path = NULL; + AVAHI_LLIST_PREPEND(AvahiEntryGroup, groups, client->groups, group); + + if (!(message = dbus_message_new_method_call( + AVAHI_DBUS_NAME, + AVAHI_DBUS_PATH_SERVER, + AVAHI_DBUS_INTERFACE_SERVER, + "EntryGroupNew"))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (!(reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error)) || + dbus_error_is_set (&error)) { + avahi_client_set_errno (client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) { + avahi_client_set_errno (client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!(group->path = avahi_strdup (path))) { + + /* FIXME: We don't remove the object on the server side */ + + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if ((state = retrieve_state(group)) < 0) { + avahi_client_set_errno(client, state); + goto fail; + } + + avahi_entry_group_set_state(group, (AvahiEntryGroupState) state); + + dbus_message_unref(message); + dbus_message_unref(reply); + + return group; + +fail: + if (dbus_error_is_set(&error)) { + avahi_client_set_dbus_error(client, &error); + dbus_error_free(&error); + } + + if (group) + avahi_entry_group_free(group); + + if (message) + dbus_message_unref(message); + + if (reply) + dbus_message_unref(reply); + + return NULL; +} + +static int entry_group_simple_method_call(AvahiEntryGroup *group, const char *method) { + DBusMessage *message = NULL, *reply = NULL; + DBusError error; + int r = AVAHI_OK; + AvahiClient *client; + + dbus_error_init(&error); + + assert(group); + client = group->client; + + if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, method))) { + r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || + dbus_error_is_set (&error)) { + r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) { + r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + dbus_message_unref(message); + dbus_message_unref(reply); + + return AVAHI_OK; + +fail: + if (dbus_error_is_set(&error)) { + r = avahi_client_set_dbus_error(client, &error); + dbus_error_free(&error); + } + + if (message) + dbus_message_unref(message); + + if (reply) + dbus_message_unref(reply); + + return r; +} + +int avahi_entry_group_free(AvahiEntryGroup *group) { + AvahiClient *client = group->client; + int r = AVAHI_OK; + + assert(group); + + if (group->path && avahi_client_is_connected(client)) + r = entry_group_simple_method_call(group, "Free"); + + AVAHI_LLIST_REMOVE(AvahiEntryGroup, groups, client->groups, group); + + avahi_free(group->path); + avahi_free(group); + + return r; +} + +int avahi_entry_group_commit(AvahiEntryGroup *group) { + int ret; + assert(group); + + if (!group->path || !avahi_client_is_connected(group->client)) + return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); + + if ((ret = entry_group_simple_method_call(group, "Commit")) < 0) + return ret; + + group->state_valid = 0; + return ret; +} + +int avahi_entry_group_reset(AvahiEntryGroup *group) { + int ret; + assert(group); + + if (!group->path || !avahi_client_is_connected(group->client)) + return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); + + if ((ret = entry_group_simple_method_call(group, "Reset")) < 0) + return ret; + + group->state_valid = 0; + return ret; +} + +int avahi_entry_group_get_state (AvahiEntryGroup *group) { + assert (group); + + if (group->state_valid) + return group->state; + + return retrieve_state(group); +} + +AvahiClient* avahi_entry_group_get_client (AvahiEntryGroup *group) { + assert(group); + + return group->client; +} + +int avahi_entry_group_is_empty (AvahiEntryGroup *group) { + DBusMessage *message = NULL, *reply = NULL; + DBusError error; + int r = AVAHI_OK; + int b; + AvahiClient *client; + + assert(group); + client = group->client; + + if (!group->path || !avahi_client_is_connected(group->client)) + return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); + + dbus_error_init(&error); + + if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "IsEmpty"))) { + r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || + dbus_error_is_set (&error)) { + r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_BOOLEAN, &b, DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) { + r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + dbus_message_unref(message); + dbus_message_unref(reply); + + return !!b; + +fail: + if (dbus_error_is_set(&error)) { + r = avahi_client_set_dbus_error(client, &error); + dbus_error_free(&error); + } + + if (message) + dbus_message_unref(message); + + if (reply) + dbus_message_unref(reply); + + return r; +} + +static int append_rdata(DBusMessage *message, const void *rdata, size_t size) { + DBusMessageIter iter, sub; + + assert(message); + + dbus_message_iter_init_append(message, &iter); + + if (!(dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &sub)) || + !(dbus_message_iter_append_fixed_array(&sub, DBUS_TYPE_BYTE, &rdata, size)) || + !(dbus_message_iter_close_container(&iter, &sub))) + return -1; + + return 0; +} + +static int append_string_list(DBusMessage *message, AvahiStringList *txt) { + DBusMessageIter iter, sub; + int r = -1; + AvahiStringList *p; + + assert(message); + + dbus_message_iter_init_append(message, &iter); + + /* Reverse the string list, so that we can pass it in-order to the server */ + txt = avahi_string_list_reverse(txt); + + if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "ay", &sub)) + goto fail; + + /* Assemble the AvahiStringList into an Array of Array of Bytes to send over dbus */ + for (p = txt; p != NULL; p = p->next) { + DBusMessageIter sub2; + const uint8_t *data = p->text; + + if (!(dbus_message_iter_open_container(&sub, DBUS_TYPE_ARRAY, "y", &sub2)) || + !(dbus_message_iter_append_fixed_array(&sub2, DBUS_TYPE_BYTE, &data, p->size)) || + !(dbus_message_iter_close_container(&sub, &sub2))) + goto fail; + } + + if (!dbus_message_iter_close_container(&iter, &sub)) + goto fail; + + r = 0; + +fail: + + /* Reverse the string list to the original state */ + txt = avahi_string_list_reverse(txt); + + return r; +} + +int avahi_entry_group_add_service_strlst( + AvahiEntryGroup *group, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiPublishFlags flags, + const char *name, + const char *type, + const char *domain, + const char *host, + uint16_t port, + AvahiStringList *txt) { + + DBusMessage *message = NULL, *reply = NULL; + int r = AVAHI_OK; + DBusError error; + AvahiClient *client; + int32_t i_interface, i_protocol; + uint32_t u_flags; + + assert(group); + assert(name); + assert(type); + + client = group->client; + + if (!group->path || !avahi_client_is_connected(group->client)) + return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); + + if (!domain) + domain = ""; + + if (!host) + host = ""; + + dbus_error_init(&error); + + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddService"))) { + r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + i_interface = (int32_t) interface; + i_protocol = (int32_t) protocol; + u_flags = (uint32_t) flags; + + if (!dbus_message_append_args( + message, + DBUS_TYPE_INT32, &i_interface, + DBUS_TYPE_INT32, &i_protocol, + DBUS_TYPE_UINT32, &u_flags, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_STRING, &type, + DBUS_TYPE_STRING, &domain, + DBUS_TYPE_STRING, &host, + DBUS_TYPE_UINT16, &port, + DBUS_TYPE_INVALID) || + append_string_list(message, txt) < 0) { + r = avahi_client_set_errno(group->client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || + dbus_error_is_set (&error)) { + r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) { + r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + dbus_message_unref(message); + dbus_message_unref(reply); + + return AVAHI_OK; + +fail: + + if (dbus_error_is_set(&error)) { + r = avahi_client_set_dbus_error(client, &error); + dbus_error_free(&error); + } + + if (message) + dbus_message_unref(message); + + if (reply) + dbus_message_unref(reply); + + return r; +} + +int avahi_entry_group_add_service( + AvahiEntryGroup *group, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiPublishFlags flags, + const char *name, + const char *type, + const char *domain, + const char *host, + uint16_t port, + ...) { + + va_list va; + int r; + AvahiStringList *txt; + + assert(group); + + va_start(va, port); + txt = avahi_string_list_new_va(va); + r = avahi_entry_group_add_service_strlst(group, interface, protocol, flags, name, type, domain, host, port, txt); + avahi_string_list_free(txt); + va_end(va); + return r; +} + +int avahi_entry_group_add_service_subtype( + AvahiEntryGroup *group, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiPublishFlags flags, + const char *name, + const char *type, + const char *domain, + const char *subtype) { + + DBusMessage *message = NULL, *reply = NULL; + int r = AVAHI_OK; + DBusError error; + AvahiClient *client; + int32_t i_interface, i_protocol; + uint32_t u_flags; + + assert(group); + assert(name); + assert(type); + assert(subtype); + + client = group->client; + + if (!group->path || !avahi_client_is_connected(group->client)) + return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); + + if (!domain) + domain = ""; + + dbus_error_init(&error); + + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddServiceSubtype"))) { + r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + i_interface = (int32_t) interface; + i_protocol = (int32_t) protocol; + u_flags = (uint32_t) flags; + + if (!dbus_message_append_args( + message, + DBUS_TYPE_INT32, &i_interface, + DBUS_TYPE_INT32, &i_protocol, + DBUS_TYPE_UINT32, &u_flags, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_STRING, &type, + DBUS_TYPE_STRING, &domain, + DBUS_TYPE_STRING, &subtype, + DBUS_TYPE_INVALID)) { + r = avahi_client_set_errno(group->client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || + dbus_error_is_set (&error)) { + r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) { + r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + dbus_message_unref(message); + dbus_message_unref(reply); + + return AVAHI_OK; + +fail: + + if (dbus_error_is_set(&error)) { + r = avahi_client_set_dbus_error(client, &error); + dbus_error_free(&error); + } + + if (message) + dbus_message_unref(message); + + if (reply) + dbus_message_unref(reply); + + return r; + +} + +int avahi_entry_group_update_service_txt( + AvahiEntryGroup *group, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiPublishFlags flags, + const char *name, + const char *type, + const char *domain, + ...) { + + va_list va; + int r; + AvahiStringList *txt; + + va_start(va, domain); + txt = avahi_string_list_new_va(va); + r = avahi_entry_group_update_service_txt_strlst(group, interface, protocol, flags, name, type, domain, txt); + avahi_string_list_free(txt); + va_end(va); + return r; +} + +int avahi_entry_group_update_service_txt_strlst( + AvahiEntryGroup *group, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiPublishFlags flags, + const char *name, + const char *type, + const char *domain, + AvahiStringList *txt) { + + DBusMessage *message = NULL, *reply = NULL; + int r = AVAHI_OK; + DBusError error; + AvahiClient *client; + int32_t i_interface, i_protocol; + uint32_t u_flags; + + assert(group); + assert(name); + assert(type); + + client = group->client; + + if (!group->path || !avahi_client_is_connected(group->client)) + return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); + + if (!domain) + domain = ""; + + dbus_error_init(&error); + + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "UpdateServiceTxt"))) { + r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + i_interface = (int32_t) interface; + i_protocol = (int32_t) protocol; + u_flags = (uint32_t) flags; + + if (!dbus_message_append_args( + message, + DBUS_TYPE_INT32, &i_interface, + DBUS_TYPE_INT32, &i_protocol, + DBUS_TYPE_UINT32, &u_flags, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_STRING, &type, + DBUS_TYPE_STRING, &domain, + DBUS_TYPE_INVALID) || + append_string_list(message, txt) < 0) { + r = avahi_client_set_errno(group->client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || + dbus_error_is_set (&error)) { + r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) { + r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + dbus_message_unref(message); + dbus_message_unref(reply); + + return AVAHI_OK; + +fail: + + if (dbus_error_is_set(&error)) { + r = avahi_client_set_dbus_error(client, &error); + dbus_error_free(&error); + } + + if (message) + dbus_message_unref(message); + + if (reply) + dbus_message_unref(reply); + + return r; +} + +/** Add a host/address pair */ +int avahi_entry_group_add_address( + AvahiEntryGroup *group, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiPublishFlags flags, + const char *name, + const AvahiAddress *a) { + + DBusMessage *message = NULL, *reply = NULL; + int r = AVAHI_OK; + DBusError error; + AvahiClient *client; + int32_t i_interface, i_protocol; + uint32_t u_flags; + char s_address[AVAHI_ADDRESS_STR_MAX]; + char *p_address = s_address; + + assert(name); + + client = group->client; + + if (!group->path || !avahi_client_is_connected(group->client)) + return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); + + dbus_error_init(&error); + + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddAddress"))) { + r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + i_interface = (int32_t) interface; + i_protocol = (int32_t) protocol; + u_flags = (uint32_t) flags; + + if (!avahi_address_snprint (s_address, sizeof (s_address), a)) + { + r = avahi_client_set_errno(client, AVAHI_ERR_INVALID_ADDRESS); + goto fail; + } + + if (!dbus_message_append_args( + message, + DBUS_TYPE_INT32, &i_interface, + DBUS_TYPE_INT32, &i_protocol, + DBUS_TYPE_UINT32, &u_flags, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_STRING, &p_address, + DBUS_TYPE_INVALID)) { + r = avahi_client_set_errno(group->client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || + dbus_error_is_set (&error)) { + r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) { + r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + dbus_message_unref(message); + dbus_message_unref(reply); + + return AVAHI_OK; + +fail: + + if (dbus_error_is_set(&error)) { + r = avahi_client_set_dbus_error(client, &error); + dbus_error_free(&error); + } + + if (message) + dbus_message_unref(message); + + if (reply) + dbus_message_unref(reply); + + return r; +} + +/** Add an arbitrary record */ +int avahi_entry_group_add_record( + AvahiEntryGroup *group, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiPublishFlags flags, + const char *name, + uint16_t clazz, + uint16_t type, + uint32_t ttl, + const void *rdata, + size_t size) { + + DBusMessage *message = NULL, *reply = NULL; + int r = AVAHI_OK; + DBusError error; + AvahiClient *client; + int32_t i_interface, i_protocol; + uint32_t u_flags; + + assert(name); + + client = group->client; + + if (!group->path || !avahi_client_is_connected(group->client)) + return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); + + dbus_error_init(&error); + + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddRecord"))) { + r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + i_interface = (int32_t) interface; + i_protocol = (int32_t) protocol; + u_flags = (uint32_t) flags; + + if (!dbus_message_append_args( + message, + DBUS_TYPE_INT32, &i_interface, + DBUS_TYPE_INT32, &i_protocol, + DBUS_TYPE_UINT32, &u_flags, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_UINT16, &clazz, + DBUS_TYPE_UINT16, &type, + DBUS_TYPE_UINT32, &ttl, + DBUS_TYPE_INVALID) || append_rdata(message, rdata, size) < 0) { + r = avahi_client_set_errno(group->client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || + dbus_error_is_set (&error)) { + r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) { + r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + dbus_message_unref(message); + dbus_message_unref(reply); + + return AVAHI_OK; + +fail: + + if (dbus_error_is_set(&error)) { + r = avahi_client_set_dbus_error(client, &error); + dbus_error_free(&error); + } + + if (message) + dbus_message_unref(message); + + if (reply) + dbus_message_unref(reply); + + return r; +} diff --git a/libgamestream/avahi-client/internal.h b/libgamestream/avahi-client/internal.h new file mode 100644 index 00000000..e5f3beb3 --- /dev/null +++ b/libgamestream/avahi-client/internal.h @@ -0,0 +1,172 @@ +#ifndef foointernalhfoo +#define foointernalhfoo + +/*** + 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.1 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 Lesser 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. +***/ + +#include + +#include "client.h" +#include "lookup.h" +#include "publish.h" + +struct AvahiClient { + const AvahiPoll *poll_api; + DBusConnection *bus; + int error; + AvahiClientState state; + AvahiClientFlags flags; + + /* Cache for some seldom changing server data */ + char *version_string, *host_name, *host_name_fqdn, *domain_name; + uint32_t local_service_cookie; + int local_service_cookie_valid; + + AvahiClientCallback callback; + void *userdata; + + AVAHI_LLIST_HEAD(AvahiEntryGroup, groups); + AVAHI_LLIST_HEAD(AvahiDomainBrowser, domain_browsers); + AVAHI_LLIST_HEAD(AvahiServiceBrowser, service_browsers); + AVAHI_LLIST_HEAD(AvahiServiceTypeBrowser, service_type_browsers); + AVAHI_LLIST_HEAD(AvahiServiceResolver, service_resolvers); + AVAHI_LLIST_HEAD(AvahiHostNameResolver, host_name_resolvers); + AVAHI_LLIST_HEAD(AvahiAddressResolver, address_resolvers); + AVAHI_LLIST_HEAD(AvahiRecordBrowser, record_browsers); +}; + +struct AvahiEntryGroup { + char *path; + AvahiEntryGroupState state; + int state_valid; + AvahiClient *client; + AvahiEntryGroupCallback callback; + void *userdata; + AVAHI_LLIST_FIELDS(AvahiEntryGroup, groups); +}; + +struct AvahiDomainBrowser { + int ref; + + char *path; + AvahiClient *client; + AvahiDomainBrowserCallback callback; + void *userdata; + AVAHI_LLIST_FIELDS(AvahiDomainBrowser, domain_browsers); + + AvahiIfIndex interface; + AvahiProtocol protocol; + + AvahiTimeout *defer_timeout; + + AvahiStringList *static_browse_domains; +}; + +struct AvahiServiceBrowser { + char *path; + AvahiClient *client; + AvahiServiceBrowserCallback callback; + void *userdata; + AVAHI_LLIST_FIELDS(AvahiServiceBrowser, service_browsers); + + char *type, *domain; + AvahiIfIndex interface; + AvahiProtocol protocol; +}; + +struct AvahiServiceTypeBrowser { + char *path; + AvahiClient *client; + AvahiServiceTypeBrowserCallback callback; + void *userdata; + AVAHI_LLIST_FIELDS(AvahiServiceTypeBrowser, service_type_browsers); + + char *domain; + AvahiIfIndex interface; + AvahiProtocol protocol; +}; + +struct AvahiServiceResolver { + char *path; + AvahiClient *client; + AvahiServiceResolverCallback callback; + void *userdata; + AVAHI_LLIST_FIELDS(AvahiServiceResolver, service_resolvers); + + char *name, *type, *domain; + AvahiIfIndex interface; + AvahiProtocol protocol; +}; + +struct AvahiHostNameResolver { + char *path; + AvahiClient *client; + AvahiHostNameResolverCallback callback; + void *userdata; + AVAHI_LLIST_FIELDS(AvahiHostNameResolver, host_name_resolvers); + + char *host_name; + AvahiIfIndex interface; + AvahiProtocol protocol; +}; + +struct AvahiAddressResolver { + char *path; + AvahiClient *client; + AvahiAddressResolverCallback callback; + void *userdata; + AVAHI_LLIST_FIELDS(AvahiAddressResolver, address_resolvers); + + AvahiAddress address; + AvahiIfIndex interface; + AvahiProtocol protocol; +}; + +struct AvahiRecordBrowser { + char *path; + AvahiClient *client; + AvahiRecordBrowserCallback callback; + void *userdata; + AVAHI_LLIST_FIELDS(AvahiRecordBrowser, record_browsers); + + char *name; + uint16_t clazz, type; + AvahiIfIndex interface; + AvahiProtocol protocol; +}; + +int avahi_client_set_errno (AvahiClient *client, int error); +int avahi_client_set_dbus_error(AvahiClient *client, DBusError *error); + +void avahi_entry_group_set_state(AvahiEntryGroup *group, AvahiEntryGroupState state); + +DBusHandlerResult avahi_domain_browser_event (AvahiClient *client, AvahiBrowserEvent event, DBusMessage *message); +DBusHandlerResult avahi_service_type_browser_event (AvahiClient *client, AvahiBrowserEvent event, DBusMessage *message); +DBusHandlerResult avahi_service_browser_event (AvahiClient *client, AvahiBrowserEvent event, DBusMessage *message); +DBusHandlerResult avahi_record_browser_event(AvahiClient *client, AvahiBrowserEvent event, DBusMessage *message); + +DBusHandlerResult avahi_service_resolver_event (AvahiClient *client, AvahiResolverEvent event, DBusMessage *message); +DBusHandlerResult avahi_host_name_resolver_event (AvahiClient *client, AvahiResolverEvent event, DBusMessage *message); +DBusHandlerResult avahi_address_resolver_event (AvahiClient *client, AvahiResolverEvent event, DBusMessage *message); + +int avahi_client_simple_method_call(AvahiClient *client, const char *path, const char *interface, const char *method); + +int avahi_client_is_connected(AvahiClient *client); + +#endif diff --git a/libgamestream/avahi-client/lookup.h b/libgamestream/avahi-client/lookup.h new file mode 100644 index 00000000..1a30d085 --- /dev/null +++ b/libgamestream/avahi-client/lookup.h @@ -0,0 +1,324 @@ +#ifndef fooclientlookuphfoo +#define fooclientlookuphfoo + +/*** + 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.1 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 Lesser 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. +***/ + +#include + +#include +#include +#include +#include +#include +#include + +#include + +/** \file avahi-client/lookup.h Lookup Client API */ + +/** \example client-browse-services.c Example how to browse for DNS-SD + * services using the client interface to avahi-daemon. */ + +AVAHI_C_DECL_BEGIN + +/** @{ \name Domain Browser */ + +/** A domain browser object */ +typedef struct AvahiDomainBrowser AvahiDomainBrowser; + +/** The function prototype for the callback of an AvahiDomainBrowser */ +typedef void (*AvahiDomainBrowserCallback) ( + AvahiDomainBrowser *b, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiBrowserEvent event, + const char *domain, + AvahiLookupResultFlags flags, + void *userdata); + +/** Browse for domains on the local network */ +AvahiDomainBrowser* avahi_domain_browser_new ( + AvahiClient *client, + AvahiIfIndex interface, + AvahiProtocol protocol, + const char *domain, + AvahiDomainBrowserType btype, + AvahiLookupFlags flags, + AvahiDomainBrowserCallback callback, + void *userdata); + +/** Get the parent client of an AvahiDomainBrowser object */ +AvahiClient* avahi_domain_browser_get_client (AvahiDomainBrowser *); + +/** Cleans up and frees an AvahiDomainBrowser object */ +int avahi_domain_browser_free (AvahiDomainBrowser *); + +/** @} */ + +/** @{ \name Service Browser */ + +/** A service browser object */ +typedef struct AvahiServiceBrowser AvahiServiceBrowser; + +/** The function prototype for the callback of an AvahiServiceBrowser */ +typedef void (*AvahiServiceBrowserCallback) ( + AvahiServiceBrowser *b, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiBrowserEvent event, + const char *name, + const char *type, + const char *domain, + AvahiLookupResultFlags flags, + void *userdata); + +/** Browse for services of a type on the network. In most cases you + * probably want to pass AVAHI_IF_UNSPEC and AVAHI_PROTO_UNSPED in + * interface, resp. protocol to browse on all local networks. The + * specified callback will be called whenever a new service appears + * or is removed from the network. Please note that events may be + * collapsed to minimize traffic (i.e. a REMOVED followed by a NEW for + * the same service data is dropped because redundant). If you want to + * subscribe to service data changes, you should use + * avahi_service_resolver_new() and keep it open, in which case you + * will be notified via AVAHI_RESOLVE_FOUND everytime the service data + * changes. */ +AvahiServiceBrowser* avahi_service_browser_new ( + AvahiClient *client, + AvahiIfIndex interface, /**< In most cases pass AVAHI_IF_UNSPEC here */ + AvahiProtocol protocol, /**< In most cases pass AVAHI_PROTO_UNSPEC here */ + const char *type, /**< A service type such as "_http._tcp" */ + const char *domain, /**< A domain to browse in. In most cases you want to pass NULL here for the default domain (usually ".local") */ + AvahiLookupFlags flags, + AvahiServiceBrowserCallback callback, + void *userdata); + +/** Get the parent client of an AvahiServiceBrowser object */ +AvahiClient* avahi_service_browser_get_client (AvahiServiceBrowser *); + +/** Cleans up and frees an AvahiServiceBrowser object */ +int avahi_service_browser_free (AvahiServiceBrowser *); + +/** @} */ + +/** \cond fulldocs */ +/** A service type browser object */ +typedef struct AvahiServiceTypeBrowser AvahiServiceTypeBrowser; + +/** The function prototype for the callback of an AvahiServiceTypeBrowser */ +typedef void (*AvahiServiceTypeBrowserCallback) ( + AvahiServiceTypeBrowser *b, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiBrowserEvent event, + const char *type, + const char *domain, + AvahiLookupResultFlags flags, + void *userdata); + +/** Browse for service types on the local network */ +AvahiServiceTypeBrowser* avahi_service_type_browser_new ( + AvahiClient *client, + AvahiIfIndex interface, + AvahiProtocol protocol, + const char *domain, + AvahiLookupFlags flags, + AvahiServiceTypeBrowserCallback callback, + void *userdata); + +/** Get the parent client of an AvahiServiceTypeBrowser object */ +AvahiClient* avahi_service_type_browser_get_client (AvahiServiceTypeBrowser *); + +/** Cleans up and frees an AvahiServiceTypeBrowser object */ +int avahi_service_type_browser_free (AvahiServiceTypeBrowser *); + +/** \endcond */ + +/** @{ \name Service Resolver */ + +/** A service resolver object */ +typedef struct AvahiServiceResolver AvahiServiceResolver; + +/** The function prototype for the callback of an AvahiServiceResolver */ +typedef void (*AvahiServiceResolverCallback) ( + AvahiServiceResolver *r, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiResolverEvent event, + const char *name, + const char *type, + const char *domain, + const char *host_name, + const AvahiAddress *a, + uint16_t port, + AvahiStringList *txt, + AvahiLookupResultFlags flags, + void *userdata); + +/** Create a new service resolver object. Please make sure to pass all the + * service data you received via avahi_service_browser_new()'s callback + * function, especially interface and protocol. The protocol argument specifies + * the protocol (IPv4 or IPv6) to use as transport for the queries which are + * sent out by this resolver. The aprotocol argument specifies the adress + * family (IPv4 or IPv6) of the address of the service we are looking for. + * Generally, on "protocol" you should only pass what was supplied to you as + * parameter to your AvahiServiceBrowserCallback. In "aprotocol" you should + * pass what your application code can deal with when connecting to the + * service. Or, more technically speaking: protocol specifies if the mDNS + * queries should be sent as UDP/IPv4 resp. UDP/IPv6 packets. aprotocol + * specifies whether the query is for a A resp. AAAA resource record. + * + * Avahi browser and resolver callbacks only receive a concrete protocol; + * always AVAHI_PROTO_INET or AVAHI_PROTO_INET6 and never AVAHI_PROTO_UNSPEC. A + * new browser given UNSPEC will receive both (separate) INET and INET6 events. + * A new resolver given a query protocol of UNSPEC will default to querying + * with INET6. A new resolver given an address protocol of UNSPEC will always + * resolve a service to an address matching the query protocol. So a resolver + * with UNSPEC/UNSPEC is equivalent to INET6/INET6. By default the avahi daemon + * publishes AAAA (IPv6) records over IPv4, but not A (IPv4) records over IPv6 + * (see 'publish-aaaa-on-ipv4' and 'publish-a-on-ipv6' in 'avahi-daemon.conf'). + * That's why, given most daemons, all four combinations of concrete query and + * address protocols resolve except INET addresses via INET6 queries. */ +AvahiServiceResolver * avahi_service_resolver_new( + AvahiClient *client, + AvahiIfIndex interface, /**< Pass the interface argument you received in AvahiServiceBrowserCallback here. */ + AvahiProtocol protocol, /**< Pass the protocol argument you received in AvahiServiceBrowserCallback here. */ + const char *name, /**< Pass the name argument you received in AvahiServiceBrowserCallback here. */ + const char *type, /**< Pass the type argument you received in AvahiServiceBrowserCallback here. */ + const char *domain, /**< Pass the domain argument you received in AvahiServiceBrowserCallback here. */ + AvahiProtocol aprotocol, /**< The desired address family of the service address to resolve. AVAHI_PROTO_UNSPEC if your application can deal with both IPv4 and IPv6 */ + AvahiLookupFlags flags, + AvahiServiceResolverCallback callback, + void *userdata); + +/** Get the parent client of an AvahiServiceResolver object */ +AvahiClient* avahi_service_resolver_get_client (AvahiServiceResolver *); + +/** Free a service resolver object */ +int avahi_service_resolver_free(AvahiServiceResolver *r); + +/** @} */ + +/** \cond fulldocs */ +/** A service resolver object */ +typedef struct AvahiHostNameResolver AvahiHostNameResolver; + +/** The function prototype for the callback of an AvahiHostNameResolver */ +typedef void (*AvahiHostNameResolverCallback) ( + AvahiHostNameResolver *r, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiResolverEvent event, + const char *name, + const AvahiAddress *a, + AvahiLookupResultFlags flags, + void *userdata); + +/** Create a new hostname resolver object */ +AvahiHostNameResolver * avahi_host_name_resolver_new( + AvahiClient *client, + AvahiIfIndex interface, + AvahiProtocol protocol, + const char *name, + AvahiProtocol aprotocol, + AvahiLookupFlags flags, + AvahiHostNameResolverCallback callback, + void *userdata); + +/** Get the parent client of an AvahiHostNameResolver object */ +AvahiClient* avahi_host_name_resolver_get_client (AvahiHostNameResolver *); + +/** Free a hostname resolver object */ +int avahi_host_name_resolver_free(AvahiHostNameResolver *r); + +/** An address resolver object */ +typedef struct AvahiAddressResolver AvahiAddressResolver; + +/** The function prototype for the callback of an AvahiAddressResolver */ +typedef void (*AvahiAddressResolverCallback) ( + AvahiAddressResolver *r, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiResolverEvent event, + const AvahiAddress *a, + const char *name, + AvahiLookupResultFlags flags, + void *userdata); + +/** Create a new address resolver object from an AvahiAddress object */ +AvahiAddressResolver* avahi_address_resolver_new( + AvahiClient *client, + AvahiIfIndex interface, + AvahiProtocol protocol, + const AvahiAddress *a, + AvahiLookupFlags flags, + AvahiAddressResolverCallback callback, + void *userdata); + +/** Get the parent client of an AvahiAddressResolver object */ +AvahiClient* avahi_address_resolver_get_client (AvahiAddressResolver *); + +/** Free a AvahiAddressResolver resolver object */ +int avahi_address_resolver_free(AvahiAddressResolver *r); + +/** \endcond */ + +/** @{ \name Record Browser */ + +/** A record browser object */ +typedef struct AvahiRecordBrowser AvahiRecordBrowser; + +/** The function prototype for the callback of an AvahiRecordBrowser */ +typedef void (*AvahiRecordBrowserCallback) ( + AvahiRecordBrowser *b, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiBrowserEvent event, + const char *name, + uint16_t clazz, + uint16_t type, + const void *rdata, + size_t size, + AvahiLookupResultFlags flags, + void *userdata); + +/** Browse for records of a type on the local network */ +AvahiRecordBrowser* avahi_record_browser_new( + AvahiClient *client, + AvahiIfIndex interface, + AvahiProtocol protocol, + const char *name, + uint16_t clazz, + uint16_t type, + AvahiLookupFlags flags, + AvahiRecordBrowserCallback callback, + void *userdata); + +/** Get the parent client of an AvahiRecordBrowser object */ +AvahiClient* avahi_record_browser_get_client(AvahiRecordBrowser *); + +/** Cleans up and frees an AvahiRecordBrowser object */ +int avahi_record_browser_free(AvahiRecordBrowser *); + +/** @} */ + +AVAHI_C_DECL_END + +#endif diff --git a/libgamestream/avahi-client/publish.h b/libgamestream/avahi-client/publish.h new file mode 100644 index 00000000..ea731f2c --- /dev/null +++ b/libgamestream/avahi-client/publish.h @@ -0,0 +1,172 @@ +#ifndef fooclientpublishhfoo +#define fooclientpublishhfoo + +/*** + 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.1 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 Lesser 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. +***/ + +#include + +#include +#include +#include +#include +#include +#include + +#include + +/** \file avahi-client/publish.h Publishing Client API */ + +/** \example client-publish-service.c Example how to register a DNS-SD + * service using the client interface to avahi-daemon. It behaves like a network + * printer registering both an IPP and a BSD LPR service. */ + +AVAHI_C_DECL_BEGIN + +/** An entry group object */ +typedef struct AvahiEntryGroup AvahiEntryGroup; + +/** The function prototype for the callback of an AvahiEntryGroup */ +typedef void (*AvahiEntryGroupCallback) ( + AvahiEntryGroup *g, + AvahiEntryGroupState state /**< The new state of the entry group */, + void* userdata /* The arbitrary user data pointer originally passed to avahi_entry_group_new()*/); + +/** @{ \name Construction and destruction */ + +/** Create a new AvahiEntryGroup object */ +AvahiEntryGroup* avahi_entry_group_new( + AvahiClient* c, + AvahiEntryGroupCallback callback /**< This callback is called whenever the state of this entry group changes. May not be NULL. Please note that this function is called for the first time from within the avahi_entry_group_new() context! Thus, in the callback you should not make use of global variables that are initialized only after your call to avahi_entry_group_new(). A common mistake is to store the AvahiEntryGroup pointer returned by avahi_entry_group_new() in a global variable and assume that this global variable already contains the valid pointer when the callback is called for the first time. A work-around for this is to always use the AvahiEntryGroup pointer passed to the callback function instead of the global pointer. */, + void *userdata /**< This arbitrary user data pointer will be passed to the callback functon */); + +/** Clean up and free an AvahiEntryGroup object */ +int avahi_entry_group_free (AvahiEntryGroup *); + +/** @} */ + +/** @{ \name State */ + +/** Commit an AvahiEntryGroup. The entries in the entry group are now registered on the network. Commiting empty entry groups is considered an error. */ +int avahi_entry_group_commit (AvahiEntryGroup*); + +/** Reset an AvahiEntryGroup. This takes effect immediately. */ +int avahi_entry_group_reset (AvahiEntryGroup*); + +/** Get an AvahiEntryGroup's state */ +int avahi_entry_group_get_state (AvahiEntryGroup*); + +/** Check if an AvahiEntryGroup is empty */ +int avahi_entry_group_is_empty (AvahiEntryGroup*); + +/** Get an AvahiEntryGroup's owning client instance */ +AvahiClient* avahi_entry_group_get_client (AvahiEntryGroup*); + +/** @} */ + +/** @{ \name Adding and updating entries */ + +/** Add a service. Takes a variable NULL terminated list of TXT record strings as last arguments. Please note that this service is not announced on the network before avahi_entry_group_commit() is called. */ +int avahi_entry_group_add_service( + AvahiEntryGroup *group, + AvahiIfIndex interface /**< The interface this service shall be announced on. We recommend to pass AVAHI_IF_UNSPEC here, to announce on all interfaces. */, + AvahiProtocol protocol /**< The protocol this service shall be announced with, i.e. MDNS over IPV4 or MDNS over IPV6. We recommend to pass AVAHI_PROTO_UNSPEC here, to announce this service on all protocols the daemon supports. */, + AvahiPublishFlags flags /**< Usually 0, unless you know what you do */, + const char *name /**< The name for the new service. Must be valid service name. i.e. a string shorter than 63 characters and valid UTF-8. May not be NULL. */, + const char *type /**< The service type for the new service, such as _http._tcp. May not be NULL. */, + const char *domain /**< The domain to register this domain in. We recommend to pass NULL here, to let the daemon decide */, + const char *host /**< The host this services is residing on. We recommend to pass NULL here, the daemon will than automatically insert the local host name in that case */, + uint16_t port /**< The IP port number of this service */, + ...) AVAHI_GCC_SENTINEL; + +/** Add a service, takes an AvahiStringList for TXT records. Arguments have the same meaning as for avahi_entry_group_add_service(). */ +int avahi_entry_group_add_service_strlst( + AvahiEntryGroup *group, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiPublishFlags flags, + const char *name, + const char *type, + const char *domain, + const char *host, + uint16_t port, + AvahiStringList *txt /**< The TXT data for this service. You may free this object after calling this function, it is not referenced any further */); + +/** Add a subtype for a service. The service should already be existent in the entry group. You may add as many subtypes for a service as you wish. */ +int avahi_entry_group_add_service_subtype( + AvahiEntryGroup *group, + AvahiIfIndex interface /**< The interface this subtype shall be announced on. This should match the value passed for the original avahi_entry_group_add_service() call. */, + AvahiProtocol protocol /**< The protocol this subtype shall be announced with. This should match the value passed for the original avahi_entry_group_add_service() call. */, + AvahiPublishFlags flags /**< Only != 0 if you really know what you do */, + const char *name /**< The name of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */, + const char *type /**< The type of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */, + const char *domain /**< The domain this service resides is, as passed to avahi_entry_group_add_service(). May be NULL. */, + const char *subtype /**< The new subtype to register for the specified service. May not be NULL. */); + +/** Update a TXT record for an existing service. The service should already be existent in the entry group. */ +int avahi_entry_group_update_service_txt( + AvahiEntryGroup *g, + AvahiIfIndex interface /**< The interface this service is announced on. This should match the value passed to the original avahi_entry_group_add_service() call. */, + AvahiProtocol protocol /**< The protocol this service is announced with. This should match the value passed to the original avahi_entry_group_add_service() call. */, + AvahiPublishFlags flags /**< Only != 0 if you really know what you do */, + const char *name /**< The name of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */, + const char *type /**< The type of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */, + const char *domain /**< The domain this service resides is, as passed to avahi_entry_group_add_service(). May be NULL. */, + ...) AVAHI_GCC_SENTINEL; + +/** Update a TXT record for an existing service. Similar to avahi_entry_group_update_service_txt() but takes an AvahiStringList for the TXT strings, instead of a NULL terminated list of arguments. */ +int avahi_entry_group_update_service_txt_strlst( + AvahiEntryGroup *g, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiPublishFlags flags, + const char *name, + const char *type, + const char *domain, + AvahiStringList *strlst); + +/** \cond fulldocs */ +/** Add a host/address pair */ +int avahi_entry_group_add_address( + AvahiEntryGroup *group, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiPublishFlags flags, + const char *name /**< The FDQN of the new hostname to register */, + const AvahiAddress *a /**< The address this host name shall map to */); +/** \endcond */ + +/** Add an arbitrary record. I hope you know what you do. */ +int avahi_entry_group_add_record( + AvahiEntryGroup *group, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiPublishFlags flags, + const char *name, + uint16_t clazz, + uint16_t type, + uint32_t ttl, + const void *rdata, + size_t size); + +/** @} */ + +AVAHI_C_DECL_END + +#endif diff --git a/libgamestream/avahi-client/resolver.c b/libgamestream/avahi-client/resolver.c new file mode 100644 index 00000000..6ee15e93 --- /dev/null +++ b/libgamestream/avahi-client/resolver.c @@ -0,0 +1,778 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include "client.h" +#include "internal.h" + +/* AvahiServiceResolver implementation */ + +DBusHandlerResult avahi_service_resolver_event (AvahiClient *client, AvahiResolverEvent event, DBusMessage *message) { + AvahiServiceResolver *r = NULL; + DBusError error; + const char *path; + AvahiStringList *strlst = NULL; + + assert(client); + assert(message); + + dbus_error_init (&error); + + if (!(path = dbus_message_get_path(message))) + goto fail; + + for (r = client->service_resolvers; r; r = r->service_resolvers_next) + if (strcmp (r->path, path) == 0) + break; + + if (!r) + goto fail; + + switch (event) { + case AVAHI_RESOLVER_FOUND: { + int j; + int32_t interface, protocol, aprotocol; + uint32_t flags; + char *name, *type, *domain, *host, *address; + uint16_t port; + DBusMessageIter iter, sub; + AvahiAddress a; + + if (!dbus_message_get_args( + message, &error, + DBUS_TYPE_INT32, &interface, + DBUS_TYPE_INT32, &protocol, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_STRING, &type, + DBUS_TYPE_STRING, &domain, + DBUS_TYPE_STRING, &host, + DBUS_TYPE_INT32, &aprotocol, + DBUS_TYPE_STRING, &address, + DBUS_TYPE_UINT16, &port, + DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) { + + fprintf(stderr, "Failed to parse resolver event.\n"); + goto fail; + } + + dbus_message_iter_init(message, &iter); + + for (j = 0; j < 9; j++) + dbus_message_iter_next(&iter); + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY || + dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_ARRAY) { + fprintf(stderr, "Error parsing service resolving message\n"); + goto fail; + } + + strlst = NULL; + dbus_message_iter_recurse(&iter, &sub); + + for (;;) { + DBusMessageIter sub2; + int at; + const uint8_t *k; + int n; + + if ((at = dbus_message_iter_get_arg_type(&sub)) == DBUS_TYPE_INVALID) + break; + + assert(at == DBUS_TYPE_ARRAY); + + if (dbus_message_iter_get_element_type(&sub) != DBUS_TYPE_BYTE) { + fprintf(stderr, "Error parsing service resolving message\n"); + goto fail; + } + + dbus_message_iter_recurse(&sub, &sub2); + + k = NULL; n = 0; + dbus_message_iter_get_fixed_array(&sub2, &k, &n); + if (k && n > 0) + strlst = avahi_string_list_add_arbitrary(strlst, k, n); + + dbus_message_iter_next(&sub); + } + + dbus_message_iter_next(&iter); + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT32) { + fprintf(stderr, "Failed to parse resolver event.\n"); + goto fail; + } + + dbus_message_iter_get_basic(&iter, &flags); + + assert(address); + + if (address[0] == 0) + address = NULL; + else + avahi_address_parse(address, (AvahiProtocol) aprotocol, &a); + + r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, name, type, domain, host, address ? &a : NULL, port, strlst, (AvahiLookupResultFlags) flags, r->userdata); + + avahi_string_list_free(strlst); + break; + } + + case AVAHI_RESOLVER_FAILURE: { + char *etxt; + + if (!dbus_message_get_args( + message, &error, + DBUS_TYPE_STRING, &etxt, + DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) { + fprintf(stderr, "Failed to parse resolver event.\n"); + goto fail; + } + + avahi_client_set_errno(r->client, avahi_error_dbus_to_number(etxt)); + r->callback(r, r->interface, r->protocol, event, r->name, r->type, r->domain, NULL, NULL, 0, NULL, 0, r->userdata); + break; + } + } + + return DBUS_HANDLER_RESULT_HANDLED; + + +fail: + dbus_error_free (&error); + avahi_string_list_free(strlst); + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +AvahiServiceResolver * avahi_service_resolver_new( + AvahiClient *client, + AvahiIfIndex interface, + AvahiProtocol protocol, + const char *name, + const char *type, + const char *domain, + AvahiProtocol aprotocol, + AvahiLookupFlags flags, + AvahiServiceResolverCallback callback, + void *userdata) { + + DBusError error; + AvahiServiceResolver *r = NULL; + DBusMessage *message = NULL, *reply = NULL; + int32_t i_interface, i_protocol, i_aprotocol; + uint32_t u_flags; + char *path; + + assert(client); + assert(type); + + if (!domain) + domain = ""; + + if (!name) + name = ""; + + dbus_error_init (&error); + + if (!avahi_client_is_connected(client)) { + avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); + goto fail; + } + + if (!(r = avahi_new(AvahiServiceResolver, 1))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + r->client = client; + r->callback = callback; + r->userdata = userdata; + r->path = NULL; + r->name = r->type = r->domain = NULL; + r->interface = interface; + r->protocol = protocol; + + AVAHI_LLIST_PREPEND(AvahiServiceResolver, service_resolvers, client->service_resolvers, r); + + if (name && name[0]) + if (!(r->name = avahi_strdup(name))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (!(r->type = avahi_strdup(type))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (domain && domain[0]) + if (!(r->domain = avahi_strdup(domain))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + + if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "ServiceResolverNew"))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + i_interface = (int32_t) interface; + i_protocol = (int32_t) protocol; + i_aprotocol = (int32_t) aprotocol; + u_flags = (uint32_t) flags; + + if (!(dbus_message_append_args( + message, + DBUS_TYPE_INT32, &i_interface, + DBUS_TYPE_INT32, &i_protocol, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_STRING, &type, + DBUS_TYPE_STRING, &domain, + DBUS_TYPE_INT32, &i_aprotocol, + DBUS_TYPE_UINT32, &u_flags, + DBUS_TYPE_INVALID))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || + dbus_error_is_set(&error)) { + avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!dbus_message_get_args (reply, &error, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID) || + dbus_error_is_set(&error) || + !path) { + avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!(r->path = avahi_strdup(path))) { + + /* FIXME: We don't remove the object on the server side */ + + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + + dbus_message_unref(message); + dbus_message_unref(reply); + + return r; + +fail: + + if (dbus_error_is_set(&error)) { + avahi_client_set_dbus_error(client, &error); + dbus_error_free(&error); + } + + if (r) + avahi_service_resolver_free(r); + + if (message) + dbus_message_unref(message); + + if (reply) + dbus_message_unref(reply); + + return NULL; + +} + +AvahiClient* avahi_service_resolver_get_client (AvahiServiceResolver *r) { + assert (r); + + return r->client; +} + +int avahi_service_resolver_free(AvahiServiceResolver *r) { + AvahiClient *client; + int ret = AVAHI_OK; + + assert(r); + client = r->client; + + if (r->path && avahi_client_is_connected(client)) + ret = avahi_client_simple_method_call(client, r->path, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Free"); + + AVAHI_LLIST_REMOVE(AvahiServiceResolver, service_resolvers, client->service_resolvers, r); + + avahi_free(r->path); + avahi_free(r->name); + avahi_free(r->type); + avahi_free(r->domain); + avahi_free(r); + + return ret; +} + +/* AvahiHostNameResolver implementation */ + +DBusHandlerResult avahi_host_name_resolver_event (AvahiClient *client, AvahiResolverEvent event, DBusMessage *message) { + AvahiHostNameResolver *r = NULL; + DBusError error; + const char *path; + + assert(client); + assert(message); + + dbus_error_init (&error); + + if (!(path = dbus_message_get_path(message))) + goto fail; + + for (r = client->host_name_resolvers; r; r = r->host_name_resolvers_next) + if (strcmp (r->path, path) == 0) + break; + + if (!r) + goto fail; + + switch (event) { + case AVAHI_RESOLVER_FOUND: { + int32_t interface, protocol, aprotocol; + uint32_t flags; + char *name, *address; + AvahiAddress a; + + if (!dbus_message_get_args( + message, &error, + DBUS_TYPE_INT32, &interface, + DBUS_TYPE_INT32, &protocol, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_INT32, &aprotocol, + DBUS_TYPE_STRING, &address, + DBUS_TYPE_UINT32, &flags, + DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) { + fprintf(stderr, "Failed to parse resolver event.\n"); + goto fail; + } + + assert(address); + if (!avahi_address_parse(address, (AvahiProtocol) aprotocol, &a)) { + fprintf(stderr, "Failed to parse address\n"); + goto fail; + } + + r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, name, &a, (AvahiLookupResultFlags) flags, r->userdata); + break; + } + + case AVAHI_RESOLVER_FAILURE: { + char *etxt; + + if (!dbus_message_get_args( + message, &error, + DBUS_TYPE_STRING, &etxt, + DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) { + fprintf(stderr, "Failed to parse resolver event.\n"); + goto fail; + } + + avahi_client_set_errno(r->client, avahi_error_dbus_to_number(etxt)); + r->callback(r, r->interface, r->protocol, event, r->host_name, NULL, 0, r->userdata); + break; + } + } + + return DBUS_HANDLER_RESULT_HANDLED; + +fail: + dbus_error_free (&error); + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + + +AvahiHostNameResolver * avahi_host_name_resolver_new( + AvahiClient *client, + AvahiIfIndex interface, + AvahiProtocol protocol, + const char *name, + AvahiProtocol aprotocol, + AvahiLookupFlags flags, + AvahiHostNameResolverCallback callback, + void *userdata) { + + DBusError error; + AvahiHostNameResolver *r = NULL; + DBusMessage *message = NULL, *reply = NULL; + int32_t i_interface, i_protocol, i_aprotocol; + uint32_t u_flags; + char *path; + + assert(client); + assert(name); + + dbus_error_init (&error); + + if (!avahi_client_is_connected(client)) { + avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); + goto fail; + } + + if (!(r = avahi_new(AvahiHostNameResolver, 1))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + r->client = client; + r->callback = callback; + r->userdata = userdata; + r->path = NULL; + r->interface = interface; + r->protocol = protocol; + r->host_name = NULL; + + AVAHI_LLIST_PREPEND(AvahiHostNameResolver, host_name_resolvers, client->host_name_resolvers, r); + + if (!(r->host_name = avahi_strdup(name))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "HostNameResolverNew"))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + i_interface = (int32_t) interface; + i_protocol = (int32_t) protocol; + i_aprotocol = (int32_t) aprotocol; + u_flags = (uint32_t) flags; + + if (!(dbus_message_append_args( + message, + DBUS_TYPE_INT32, &i_interface, + DBUS_TYPE_INT32, &i_protocol, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_INT32, &i_aprotocol, + DBUS_TYPE_UINT32, &u_flags, + DBUS_TYPE_INVALID))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || + dbus_error_is_set(&error)) { + avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!dbus_message_get_args (reply, &error, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID) || + dbus_error_is_set(&error) || + !path) { + avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!(r->path = avahi_strdup(path))) { + + /* FIXME: We don't remove the object on the server side */ + + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + dbus_message_unref(message); + dbus_message_unref(reply); + + return r; + +fail: + + if (dbus_error_is_set(&error)) { + avahi_client_set_dbus_error(client, &error); + dbus_error_free(&error); + } + + if (r) + avahi_host_name_resolver_free(r); + + if (message) + dbus_message_unref(message); + + if (reply) + dbus_message_unref(reply); + + return NULL; + +} + +int avahi_host_name_resolver_free(AvahiHostNameResolver *r) { + int ret = AVAHI_OK; + AvahiClient *client; + + assert(r); + client = r->client; + + if (r->path && avahi_client_is_connected(client)) + ret = avahi_client_simple_method_call(client, r->path, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Free"); + + AVAHI_LLIST_REMOVE(AvahiHostNameResolver, host_name_resolvers, client->host_name_resolvers, r); + + avahi_free(r->path); + avahi_free(r->host_name); + avahi_free(r); + + return ret; +} + +AvahiClient* avahi_host_name_resolver_get_client (AvahiHostNameResolver *r) { + assert (r); + + return r->client; +} + +/* AvahiAddressResolver implementation */ + +DBusHandlerResult avahi_address_resolver_event (AvahiClient *client, AvahiResolverEvent event, DBusMessage *message) { + AvahiAddressResolver *r = NULL; + DBusError error; + const char *path; + + assert(client); + assert(message); + + dbus_error_init (&error); + + if (!(path = dbus_message_get_path(message))) + goto fail; + + for (r = client->address_resolvers; r; r = r->address_resolvers_next) + if (strcmp (r->path, path) == 0) + break; + + if (!r) + goto fail; + + switch (event) { + case AVAHI_RESOLVER_FOUND: { + int32_t interface, protocol, aprotocol; + uint32_t flags; + char *name, *address; + AvahiAddress a; + + if (!dbus_message_get_args( + message, &error, + DBUS_TYPE_INT32, &interface, + DBUS_TYPE_INT32, &protocol, + DBUS_TYPE_INT32, &aprotocol, + DBUS_TYPE_STRING, &address, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_UINT32, &flags, + DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) { + fprintf(stderr, "Failed to parse resolver event.\n"); + goto fail; + } + + assert(address); + if (!avahi_address_parse(address, (AvahiProtocol) aprotocol, &a)) { + fprintf(stderr, "Failed to parse address\n"); + goto fail; + } + + r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, &a, name, (AvahiLookupResultFlags) flags, r->userdata); + break; + } + + case AVAHI_RESOLVER_FAILURE: { + char *etxt; + + if (!dbus_message_get_args( + message, &error, + DBUS_TYPE_STRING, &etxt, + DBUS_TYPE_INVALID) || + dbus_error_is_set (&error)) { + fprintf(stderr, "Failed to parse resolver event.\n"); + goto fail; + } + + avahi_client_set_errno(r->client, avahi_error_dbus_to_number(etxt)); + r->callback(r, r->interface, r->protocol, event, &r->address, NULL, 0, r->userdata); + break; + } + } + + return DBUS_HANDLER_RESULT_HANDLED; + +fail: + dbus_error_free (&error); + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +AvahiAddressResolver * avahi_address_resolver_new( + AvahiClient *client, + AvahiIfIndex interface, + AvahiProtocol protocol, + const AvahiAddress *a, + AvahiLookupFlags flags, + AvahiAddressResolverCallback callback, + void *userdata) { + + DBusError error; + AvahiAddressResolver *r = NULL; + DBusMessage *message = NULL, *reply = NULL; + int32_t i_interface, i_protocol; + uint32_t u_flags; + char *path; + char addr[AVAHI_ADDRESS_STR_MAX], *address = addr; + + assert(client); + assert(a); + + dbus_error_init (&error); + + if (!avahi_address_snprint (addr, sizeof(addr), a)) { + avahi_client_set_errno(client, AVAHI_ERR_INVALID_ADDRESS); + return NULL; + } + + if (!avahi_client_is_connected(client)) { + avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); + goto fail; + } + + if (!(r = avahi_new(AvahiAddressResolver, 1))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + r->client = client; + r->callback = callback; + r->userdata = userdata; + r->path = NULL; + r->interface = interface; + r->protocol = protocol; + r->address = *a; + + AVAHI_LLIST_PREPEND(AvahiAddressResolver, address_resolvers, client->address_resolvers, r); + + if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "AddressResolverNew"))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + i_interface = (int32_t) interface; + i_protocol = (int32_t) protocol; + u_flags = (uint32_t) flags; + + if (!(dbus_message_append_args( + message, + DBUS_TYPE_INT32, &i_interface, + DBUS_TYPE_INT32, &i_protocol, + DBUS_TYPE_STRING, &address, + DBUS_TYPE_UINT32, &u_flags, + DBUS_TYPE_INVALID))) { + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || + dbus_error_is_set(&error)) { + avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!dbus_message_get_args (reply, &error, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID) || + dbus_error_is_set(&error) || + !path) { + avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); + goto fail; + } + + if (!(r->path = avahi_strdup(path))) { + + /* FIXME: We don't remove the object on the server side */ + + avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); + goto fail; + } + + dbus_message_unref(message); + dbus_message_unref(reply); + + return r; + +fail: + + if (dbus_error_is_set(&error)) { + avahi_client_set_dbus_error(client, &error); + dbus_error_free(&error); + } + + if (r) + avahi_address_resolver_free(r); + + if (message) + dbus_message_unref(message); + + if (reply) + dbus_message_unref(reply); + + return NULL; + +} + +AvahiClient* avahi_address_resolver_get_client (AvahiAddressResolver *r) { + assert (r); + + return r->client; +} + +int avahi_address_resolver_free(AvahiAddressResolver *r) { + AvahiClient *client; + int ret = AVAHI_OK; + + assert(r); + client = r->client; + + if (r->path && avahi_client_is_connected(client)) + ret = avahi_client_simple_method_call(client, r->path, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Free"); + + AVAHI_LLIST_REMOVE(AvahiAddressResolver, address_resolvers, client->address_resolvers, r); + + avahi_free(r->path); + avahi_free(r); + + return ret; +} + diff --git a/libgamestream/avahi-client/rr-test.c b/libgamestream/avahi-client/rr-test.c new file mode 100644 index 00000000..0402585a --- /dev/null +++ b/libgamestream/avahi-client/rr-test.c @@ -0,0 +1,111 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include +#include +#include +#include +#include + +static void hexdump(const void* p, size_t size) { + const uint8_t *c = p; + assert(p); + + printf("Dumping %lu bytes from %p:\n", (unsigned long) size, p); + + while (size > 0) { + unsigned i; + + for (i = 0; i < 16; i++) { + if (i < size) + printf("%02x ", c[i]); + else + printf(" "); + } + + for (i = 0; i < 16; i++) { + if (i < size) + printf("%c", c[i] >= 32 && c[i] < 127 ? c[i] : '.'); + else + printf(" "); + } + + printf("\n"); + + c += 16; + + if (size <= 16) + break; + + size -= 16; + } +} + +static void callback( + AVAHI_GCC_UNUSED AvahiRecordBrowser *r, + AVAHI_GCC_UNUSED AvahiIfIndex interface, + AVAHI_GCC_UNUSED AvahiProtocol protocol, + AvahiBrowserEvent event, + const char *name, + uint16_t clazz, + uint16_t type, + const void *rdata, + size_t rdata_size, + AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, + AVAHI_GCC_UNUSED void *userdata) { + + fprintf(stderr, "%i name=%s class=%u type=%u\n", event, name, clazz, type); + + if (rdata) + hexdump(rdata, rdata_size); +} + +int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { + + AvahiSimplePoll *simple_poll; + const AvahiPoll *poll_api; + AvahiClient *client; + AvahiRecordBrowser *r; + + simple_poll = avahi_simple_poll_new(); + assert(simple_poll); + + poll_api = avahi_simple_poll_get(simple_poll); + assert(poll_api); + + client = avahi_client_new(poll_api, 0, NULL, NULL, NULL); + assert(client); + + r = avahi_record_browser_new(client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "ecstasy.local", AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_HINFO, 0, callback, simple_poll); + assert(r); + + avahi_simple_poll_loop(simple_poll); + + avahi_client_free(client); + avahi_simple_poll_free(simple_poll); + + return 0; +} diff --git a/libgamestream/avahi-client/srv-test.c b/libgamestream/avahi-client/srv-test.c new file mode 100644 index 00000000..650bd775 --- /dev/null +++ b/libgamestream/avahi-client/srv-test.c @@ -0,0 +1,76 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include +#include +#include +#include +#include + +static void callback( + AVAHI_GCC_UNUSED AvahiServiceResolver *r, + AVAHI_GCC_UNUSED AvahiIfIndex interface, + AVAHI_GCC_UNUSED AvahiProtocol protocol, + AvahiResolverEvent event, + const char *name, + const char *type, + const char *domain, + const char *host_name, + AVAHI_GCC_UNUSED const AvahiAddress *a, + AVAHI_GCC_UNUSED uint16_t port, + AVAHI_GCC_UNUSED AvahiStringList *txt, + AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, + AVAHI_GCC_UNUSED void *userdata) { + + fprintf(stderr, "%i name=%s type=%s domain=%s host=%s\n", event, name, type, domain, host_name); +} + +int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { + + AvahiSimplePoll *simple_poll; + const AvahiPoll *poll_api; + AvahiClient *client; + AvahiServiceResolver *r; + + simple_poll = avahi_simple_poll_new(); + assert(simple_poll); + + poll_api = avahi_simple_poll_get(simple_poll); + assert(poll_api); + + client = avahi_client_new(poll_api, 0, NULL, NULL, NULL); + assert(client); + + r = avahi_service_resolver_new(client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, "_domain._udp", "0pointer.de", AVAHI_PROTO_UNSPEC, AVAHI_LOOKUP_NO_TXT, callback, simple_poll); + assert(r); + + avahi_simple_poll_loop(simple_poll); + + avahi_client_free(client); + avahi_simple_poll_free(simple_poll); + + return 0; +} diff --git a/libgamestream/avahi-client/xdg-config-test.c b/libgamestream/avahi-client/xdg-config-test.c new file mode 100644 index 00000000..a7ee63e4 --- /dev/null +++ b/libgamestream/avahi-client/xdg-config-test.c @@ -0,0 +1,38 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "xdg-config.h" + +int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { + + FILE *f; + + f = avahi_xdg_config_open("foo"); + + if (f) + fclose(f); + + return 0; +} diff --git a/libgamestream/avahi-client/xdg-config.c b/libgamestream/avahi-client/xdg-config.c new file mode 100644 index 00000000..fc650168 --- /dev/null +++ b/libgamestream/avahi-client/xdg-config.c @@ -0,0 +1,68 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include + +#include "xdg-config.h" + +#ifndef PATH_MAX +#define PATH_MAX 4096 +#endif + +FILE *avahi_xdg_config_open(const char *filename) { + FILE *f; + const char *e, *d; + char fn[PATH_MAX], *p = NULL, buf[2048], *s = NULL; + + assert(filename); + + if ((e = getenv("XDG_CONFIG_HOME")) && *e) + snprintf(p = fn, sizeof(fn), "%s/%s", e, filename); + else if ((e = getenv("HOME")) && *e) + snprintf(p = fn, sizeof(fn), "%s/.config/%s", e, filename); + + if (p) { + if ((f = fopen(p, "r"))) + return f; + else if (errno != ENOENT) + return NULL; + } + + if (!(d = getenv("XDG_CONFIG_DIRS")) || !*d) + d = "/etc/xdg"; + + snprintf(buf, sizeof(buf), "%s", d); + + for (e = strtok_r(buf, ":", &s); e; e = strtok_r(NULL, ":", &s)) { + snprintf(fn, sizeof(fn), "%s/%s", e, filename); + + if ((f = fopen(fn, "r"))) + return f; + } + + return NULL; +} diff --git a/libgamestream/avahi-client/xdg-config.h b/libgamestream/avahi-client/xdg-config.h new file mode 100644 index 00000000..6c855abe --- /dev/null +++ b/libgamestream/avahi-client/xdg-config.h @@ -0,0 +1,27 @@ +#ifndef fooxdgconfighfoo +#define fooxdgconfighfoo + +/*** + 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.1 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 Lesser 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. +***/ + +#include + +FILE *avahi_xdg_config_open(const char *filename); + +#endif diff --git a/libgamestream/avahi-common/Makefile.am b/libgamestream/avahi-common/Makefile.am new file mode 100644 index 00000000..79d062f6 --- /dev/null +++ b/libgamestream/avahi-common/Makefile.am @@ -0,0 +1,129 @@ +# 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. + +AM_CFLAGS=-I$(top_srcdir) + +# This cool debug trap works on i386/gcc only +AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")' + +avahi_commonincludedir=$(includedir)/avahi-common + +avahi_commoninclude_HEADERS = \ + strlst.h \ + address.h \ + alternative.h \ + domain.h \ + cdecl.h \ + defs.h \ + malloc.h \ + watch.h \ + timeval.h \ + simple-watch.h \ + thread-watch.h \ + gccmacro.h \ + error.h \ + llist.h \ + rlist.h + +if ENABLE_TESTS +noinst_PROGRAMS = \ + strlst-test \ + domain-test \ + alternative-test \ + timeval-test \ + watch-test \ + watch-test-thread \ + utf8-test +endif + +lib_LTLIBRARIES = \ + libavahi-common.la + +libavahi_common_la_SOURCES = \ + malloc.c malloc.h \ + address.c address.h \ + alternative.c alternative.h \ + error.c error.h \ + strlst.c strlst.h \ + domain.c domain.h \ + timeval.c timeval.h \ + simple-watch.c simple-watch.h \ + thread-watch.c thread-watch.h \ + watch.h gccmacro.h \ + rlist.h rlist.c \ + utf8.c utf8.h \ + i18n.c i18n.h + +libavahi_common_la_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -DAVAHI_LOCALEDIR=\"$(avahilocaledir)\" +libavahi_common_la_LIBADD = $(AM_LDADD) $(PTHREAD_CFLAGS) $(PTHREAD_LIBS) $(INTLLIBS) +libavahi_common_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBAVAHI_COMMON_VERSION_INFO) + +strlst_test_SOURCES = \ + strlst.c strlst.h \ + malloc.c malloc.h \ + strlst-test.c +strlst_test_CFLAGS = $(AM_CFLAGS) + +alternative_test_SOURCES = \ + alternative.c alternative.h \ + malloc.c malloc.h \ + domain.c domain.h \ + address.c address.h \ + alternative-test.c \ + utf8.c utf8.h +alternative_test_CFLAGS = $(AM_CFLAGS) + +domain_test_SOURCES = \ + domain.c domain.h \ + malloc.c malloc.h \ + address.c address.h \ + domain-test.c \ + utf8.c utf8.h +domain_test_CFLAGS = $(AM_CFLAGS) + +watch_test_SOURCES = \ + timeval.c timeval.h \ + simple-watch.c simple-watch.h \ + watch.h \ + malloc.c malloc.h \ + watch-test.c +watch_test_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) +watch_test_LDADD = $(AM_LDADD) $(PTHREAD_LIBS) $(PTHREAD_CFLAGS) + +watch_test_thread_SOURCES = $(watch_test_SOURCES) thread-watch.c thread-watch.h +watch_test_thread_CFLAGS = $(watch_test_CFLAGS) -DUSE_THREAD +watch_test_thread_LDADD = $(watch_test_LDADD) + +timeval_test_SOURCES = \ + timeval.c timeval.h \ + timeval-test.c +timeval_test_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) +timeval_test_LDADD = $(AM_LDADD) $(PTHREAD_LIBS) $(PTHREAD_CFLAGS) + +utf8_test_SOURCES = \ + utf8-test.c \ + utf8.c utf8.h +utf8_test_CFLAGS = $(AM_CFLAGS) +utf8_test_LDADD = $(AM_LDADD) + +if HAVE_DBUS + +noinst_HEADERS = \ + dbus.h \ + dbus-watch-glue.h + +endif diff --git a/libgamestream/avahi-common/Makefile.in b/libgamestream/avahi-common/Makefile.in new file mode 100644 index 00000000..63b4d4a3 --- /dev/null +++ b/libgamestream/avahi-common/Makefile.in @@ -0,0 +1,1551 @@ +# Makefile.in generated by automake 1.15.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2017 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# 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. + + + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +@ENABLE_TESTS_TRUE@noinst_PROGRAMS = strlst-test$(EXEEXT) \ +@ENABLE_TESTS_TRUE@ domain-test$(EXEEXT) \ +@ENABLE_TESTS_TRUE@ alternative-test$(EXEEXT) \ +@ENABLE_TESTS_TRUE@ timeval-test$(EXEEXT) watch-test$(EXEEXT) \ +@ENABLE_TESTS_TRUE@ watch-test-thread$(EXEEXT) \ +@ENABLE_TESTS_TRUE@ utf8-test$(EXEEXT) +subdir = avahi-common +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/common/acx_pthread.m4 \ + $(top_srcdir)/common/gcc_stack_protect.m4 \ + $(top_srcdir)/common/gcc_visibility.m4 \ + $(top_srcdir)/common/gettext.m4 $(top_srcdir)/common/iconv.m4 \ + $(top_srcdir)/common/introspection.m4 \ + $(top_srcdir)/common/lib-ld.m4 \ + $(top_srcdir)/common/lib-link.m4 \ + $(top_srcdir)/common/lib-prefix.m4 \ + $(top_srcdir)/common/libtool.m4 \ + $(top_srcdir)/common/ltoptions.m4 \ + $(top_srcdir)/common/ltsugar.m4 \ + $(top_srcdir)/common/ltversion.m4 \ + $(top_srcdir)/common/lt~obsolete.m4 \ + $(top_srcdir)/common/nls.m4 $(top_srcdir)/common/po.m4 \ + $(top_srcdir)/common/progtest.m4 \ + $(top_srcdir)/common/python.m4 $(top_srcdir)/common/qt5-pie.m4 \ + $(top_srcdir)/acinclude.m4 $(top_srcdir)/common/doxygen.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(avahi_commoninclude_HEADERS) \ + $(am__noinst_HEADERS_DIST) $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(libdir)" \ + "$(DESTDIR)$(avahi_commonincludedir)" +LTLIBRARIES = $(lib_LTLIBRARIES) +am__DEPENDENCIES_1 = +libavahi_common_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +am_libavahi_common_la_OBJECTS = libavahi_common_la-malloc.lo \ + libavahi_common_la-address.lo \ + libavahi_common_la-alternative.lo libavahi_common_la-error.lo \ + libavahi_common_la-strlst.lo libavahi_common_la-domain.lo \ + libavahi_common_la-timeval.lo \ + libavahi_common_la-simple-watch.lo \ + libavahi_common_la-thread-watch.lo libavahi_common_la-rlist.lo \ + libavahi_common_la-utf8.lo libavahi_common_la-i18n.lo +libavahi_common_la_OBJECTS = $(am_libavahi_common_la_OBJECTS) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +libavahi_common_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(libavahi_common_la_CFLAGS) $(CFLAGS) \ + $(libavahi_common_la_LDFLAGS) $(LDFLAGS) -o $@ +PROGRAMS = $(noinst_PROGRAMS) +am_alternative_test_OBJECTS = alternative_test-alternative.$(OBJEXT) \ + alternative_test-malloc.$(OBJEXT) \ + alternative_test-domain.$(OBJEXT) \ + alternative_test-address.$(OBJEXT) \ + alternative_test-alternative-test.$(OBJEXT) \ + alternative_test-utf8.$(OBJEXT) +alternative_test_OBJECTS = $(am_alternative_test_OBJECTS) +alternative_test_LDADD = $(LDADD) +alternative_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(alternative_test_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +am_domain_test_OBJECTS = domain_test-domain.$(OBJEXT) \ + domain_test-malloc.$(OBJEXT) domain_test-address.$(OBJEXT) \ + domain_test-domain-test.$(OBJEXT) domain_test-utf8.$(OBJEXT) +domain_test_OBJECTS = $(am_domain_test_OBJECTS) +domain_test_LDADD = $(LDADD) +domain_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(domain_test_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +am_strlst_test_OBJECTS = strlst_test-strlst.$(OBJEXT) \ + strlst_test-malloc.$(OBJEXT) strlst_test-strlst-test.$(OBJEXT) +strlst_test_OBJECTS = $(am_strlst_test_OBJECTS) +strlst_test_LDADD = $(LDADD) +strlst_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(strlst_test_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +am_timeval_test_OBJECTS = timeval_test-timeval.$(OBJEXT) \ + timeval_test-timeval-test.$(OBJEXT) +timeval_test_OBJECTS = $(am_timeval_test_OBJECTS) +timeval_test_DEPENDENCIES = $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +timeval_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(timeval_test_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +am_utf8_test_OBJECTS = utf8_test-utf8-test.$(OBJEXT) \ + utf8_test-utf8.$(OBJEXT) +utf8_test_OBJECTS = $(am_utf8_test_OBJECTS) +utf8_test_DEPENDENCIES = +utf8_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(utf8_test_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +am_watch_test_OBJECTS = watch_test-timeval.$(OBJEXT) \ + watch_test-simple-watch.$(OBJEXT) watch_test-malloc.$(OBJEXT) \ + watch_test-watch-test.$(OBJEXT) +watch_test_OBJECTS = $(am_watch_test_OBJECTS) +watch_test_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +watch_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(watch_test_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +am__objects_1 = watch_test_thread-timeval.$(OBJEXT) \ + watch_test_thread-simple-watch.$(OBJEXT) \ + watch_test_thread-malloc.$(OBJEXT) \ + watch_test_thread-watch-test.$(OBJEXT) +am_watch_test_thread_OBJECTS = $(am__objects_1) \ + watch_test_thread-thread-watch.$(OBJEXT) +watch_test_thread_OBJECTS = $(am_watch_test_thread_OBJECTS) +am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +watch_test_thread_DEPENDENCIES = $(am__DEPENDENCIES_2) +watch_test_thread_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(watch_test_thread_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(libavahi_common_la_SOURCES) $(alternative_test_SOURCES) \ + $(domain_test_SOURCES) $(strlst_test_SOURCES) \ + $(timeval_test_SOURCES) $(utf8_test_SOURCES) \ + $(watch_test_SOURCES) $(watch_test_thread_SOURCES) +DIST_SOURCES = $(libavahi_common_la_SOURCES) \ + $(alternative_test_SOURCES) $(domain_test_SOURCES) \ + $(strlst_test_SOURCES) $(timeval_test_SOURCES) \ + $(utf8_test_SOURCES) $(watch_test_SOURCES) \ + $(watch_test_thread_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__noinst_HEADERS_DIST = dbus.h dbus-watch-glue.h +HEADERS = $(avahi_commoninclude_HEADERS) $(noinst_HEADERS) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AVAHI_AUTOIPD_GROUP = @AVAHI_AUTOIPD_GROUP@ +AVAHI_AUTOIPD_USER = @AVAHI_AUTOIPD_USER@ +AVAHI_GROUP = @AVAHI_GROUP@ +AVAHI_PRIV_ACCESS_GROUP = @AVAHI_PRIV_ACCESS_GROUP@ +AVAHI_USER = @AVAHI_USER@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DBUS_SYSTEM_BUS_DEFAULT_ADDRESS = @DBUS_SYSTEM_BUS_DEFAULT_ADDRESS@ +DBUS_SYS_DIR = @DBUS_SYS_DIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +DX_CONFIG = @DX_CONFIG@ +DX_DOCDIR = @DX_DOCDIR@ +DX_DOT = @DX_DOT@ +DX_DOXYGEN = @DX_DOXYGEN@ +DX_DVIPS = @DX_DVIPS@ +DX_EGREP = @DX_EGREP@ +DX_ENV = @DX_ENV@ +DX_FLAG_chi = @DX_FLAG_chi@ +DX_FLAG_chm = @DX_FLAG_chm@ +DX_FLAG_doc = @DX_FLAG_doc@ +DX_FLAG_dot = @DX_FLAG_dot@ +DX_FLAG_html = @DX_FLAG_html@ +DX_FLAG_man = @DX_FLAG_man@ +DX_FLAG_pdf = @DX_FLAG_pdf@ +DX_FLAG_ps = @DX_FLAG_ps@ +DX_FLAG_rtf = @DX_FLAG_rtf@ +DX_FLAG_xml = @DX_FLAG_xml@ +DX_HHC = @DX_HHC@ +DX_LATEX = @DX_LATEX@ +DX_MAKEINDEX = @DX_MAKEINDEX@ +DX_PDFLATEX = @DX_PDFLATEX@ +DX_PERL = @DX_PERL@ +DX_PROJECT = @DX_PROJECT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GACUTIL = @GACUTIL@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GLIB20_CFLAGS = @GLIB20_CFLAGS@ +GLIB20_LIBS = @GLIB20_LIBS@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ +GOBJECT_LIBS = @GOBJECT_LIBS@ +GREP = @GREP@ +GTK20_CFLAGS = @GTK20_CFLAGS@ +GTK20_LIBS = @GTK20_LIBS@ +GTK30_CFLAGS = @GTK30_CFLAGS@ +GTK30_LIBS = @GTK30_LIBS@ +HOWL_COMPAT_VERSION = @HOWL_COMPAT_VERSION@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ +INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ +INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ +INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ +INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ +INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ +INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ +INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBAVAHI_CLIENT_VERSION_INFO = @LIBAVAHI_CLIENT_VERSION_INFO@ +LIBAVAHI_COMMON_VERSION_INFO = @LIBAVAHI_COMMON_VERSION_INFO@ +LIBAVAHI_COMPAT_HOWL_VERSION_INFO = @LIBAVAHI_COMPAT_HOWL_VERSION_INFO@ +LIBAVAHI_COMPAT_LIBDNS_SD_VERSION_INFO = @LIBAVAHI_COMPAT_LIBDNS_SD_VERSION_INFO@ +LIBAVAHI_CORE_VERSION_INFO = @LIBAVAHI_CORE_VERSION_INFO@ +LIBAVAHI_GLIB_VERSION_INFO = @LIBAVAHI_GLIB_VERSION_INFO@ +LIBAVAHI_GOBJECT_VERSION_INFO = @LIBAVAHI_GOBJECT_VERSION_INFO@ +LIBAVAHI_LIBEVENT_VERSION_INFO = @LIBAVAHI_LIBEVENT_VERSION_INFO@ +LIBAVAHI_QT3_VERSION_INFO = @LIBAVAHI_QT3_VERSION_INFO@ +LIBAVAHI_QT4_VERSION_INFO = @LIBAVAHI_QT4_VERSION_INFO@ +LIBAVAHI_QT5_VERSION_INFO = @LIBAVAHI_QT5_VERSION_INFO@ +LIBAVAHI_UI_VERSION_INFO = @LIBAVAHI_UI_VERSION_INFO@ +LIBDAEMON_CFLAGS = @LIBDAEMON_CFLAGS@ +LIBDAEMON_LIBS = @LIBDAEMON_LIBS@ +LIBEVENT_CFLAGS = @LIBEVENT_CFLAGS@ +LIBEVENT_LIBS = @LIBEVENT_LIBS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MCS = @MCS@ +MDASSEMBLER = @MDASSEMBLER@ +MKDIR_P = @MKDIR_P@ +MOC_QT3 = @MOC_QT3@ +MOC_QT4 = @MOC_QT4@ +MOC_QT5 = @MOC_QT5@ +MONODOCER = @MONODOCER@ +MONODOC_CFLAGS = @MONODOC_CFLAGS@ +MONODOC_DIR = @MONODOC_DIR@ +MONODOC_LIBS = @MONODOC_LIBS@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +POSUB = @POSUB@ +PTHREAD_CC = @PTHREAD_CC@ +PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ +PTHREAD_LIBS = @PTHREAD_LIBS@ +PYGOBJECT_CFLAGS = @PYGOBJECT_CFLAGS@ +PYGOBJECT_LIBS = @PYGOBJECT_LIBS@ +PYTHON = @PYTHON@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ +QT3_CFLAGS = @QT3_CFLAGS@ +QT3_LIBS = @QT3_LIBS@ +QT4_CFLAGS = @QT4_CFLAGS@ +QT4_LIBS = @QT4_LIBS@ +QT5_CFLAGS = @QT5_CFLAGS@ +QT5_LIBS = @QT5_LIBS@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STOW = @STOW@ +STRIP = @STRIP@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +VISIBILITY_HIDDEN_CFLAGS = @VISIBILITY_HIDDEN_CFLAGS@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +XML_CFLAGS = @XML_CFLAGS@ +XML_LIBS = @XML_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +acx_pthread_config = @acx_pthread_config@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +avahi_runtime_dir = @avahi_runtime_dir@ +avahi_socket = @avahi_socket@ +avahilocaledir = @avahilocaledir@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +have_pkg_config = @have_pkg_config@ +have_xmltoman = @have_xmltoman@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +interfacesdir = @interfacesdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +systemdsystemunitdir = @systemdsystemunitdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ + +# This cool debug trap works on i386/gcc only +AM_CFLAGS = -I$(top_srcdir) '-DDEBUG_TRAP=__asm__("int $$3")' +avahi_commonincludedir = $(includedir)/avahi-common +avahi_commoninclude_HEADERS = \ + strlst.h \ + address.h \ + alternative.h \ + domain.h \ + cdecl.h \ + defs.h \ + malloc.h \ + watch.h \ + timeval.h \ + simple-watch.h \ + thread-watch.h \ + gccmacro.h \ + error.h \ + llist.h \ + rlist.h + +lib_LTLIBRARIES = \ + libavahi-common.la + +libavahi_common_la_SOURCES = \ + malloc.c malloc.h \ + address.c address.h \ + alternative.c alternative.h \ + error.c error.h \ + strlst.c strlst.h \ + domain.c domain.h \ + timeval.c timeval.h \ + simple-watch.c simple-watch.h \ + thread-watch.c thread-watch.h \ + watch.h gccmacro.h \ + rlist.h rlist.c \ + utf8.c utf8.h \ + i18n.c i18n.h + +libavahi_common_la_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -DAVAHI_LOCALEDIR=\"$(avahilocaledir)\" +libavahi_common_la_LIBADD = $(AM_LDADD) $(PTHREAD_CFLAGS) $(PTHREAD_LIBS) $(INTLLIBS) +libavahi_common_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBAVAHI_COMMON_VERSION_INFO) +strlst_test_SOURCES = \ + strlst.c strlst.h \ + malloc.c malloc.h \ + strlst-test.c + +strlst_test_CFLAGS = $(AM_CFLAGS) +alternative_test_SOURCES = \ + alternative.c alternative.h \ + malloc.c malloc.h \ + domain.c domain.h \ + address.c address.h \ + alternative-test.c \ + utf8.c utf8.h + +alternative_test_CFLAGS = $(AM_CFLAGS) +domain_test_SOURCES = \ + domain.c domain.h \ + malloc.c malloc.h \ + address.c address.h \ + domain-test.c \ + utf8.c utf8.h + +domain_test_CFLAGS = $(AM_CFLAGS) +watch_test_SOURCES = \ + timeval.c timeval.h \ + simple-watch.c simple-watch.h \ + watch.h \ + malloc.c malloc.h \ + watch-test.c + +watch_test_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) +watch_test_LDADD = $(AM_LDADD) $(PTHREAD_LIBS) $(PTHREAD_CFLAGS) +watch_test_thread_SOURCES = $(watch_test_SOURCES) thread-watch.c thread-watch.h +watch_test_thread_CFLAGS = $(watch_test_CFLAGS) -DUSE_THREAD +watch_test_thread_LDADD = $(watch_test_LDADD) +timeval_test_SOURCES = \ + timeval.c timeval.h \ + timeval-test.c + +timeval_test_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) +timeval_test_LDADD = $(AM_LDADD) $(PTHREAD_LIBS) $(PTHREAD_CFLAGS) +utf8_test_SOURCES = \ + utf8-test.c \ + utf8.c utf8.h + +utf8_test_CFLAGS = $(AM_CFLAGS) +utf8_test_LDADD = $(AM_LDADD) +@HAVE_DBUS_TRUE@noinst_HEADERS = \ +@HAVE_DBUS_TRUE@ dbus.h \ +@HAVE_DBUS_TRUE@ dbus-watch-glue.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign avahi-common/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign avahi-common/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ + } + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +libavahi-common.la: $(libavahi_common_la_OBJECTS) $(libavahi_common_la_DEPENDENCIES) $(EXTRA_libavahi_common_la_DEPENDENCIES) + $(AM_V_CCLD)$(libavahi_common_la_LINK) -rpath $(libdir) $(libavahi_common_la_OBJECTS) $(libavahi_common_la_LIBADD) $(LIBS) + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +alternative-test$(EXEEXT): $(alternative_test_OBJECTS) $(alternative_test_DEPENDENCIES) $(EXTRA_alternative_test_DEPENDENCIES) + @rm -f alternative-test$(EXEEXT) + $(AM_V_CCLD)$(alternative_test_LINK) $(alternative_test_OBJECTS) $(alternative_test_LDADD) $(LIBS) + +domain-test$(EXEEXT): $(domain_test_OBJECTS) $(domain_test_DEPENDENCIES) $(EXTRA_domain_test_DEPENDENCIES) + @rm -f domain-test$(EXEEXT) + $(AM_V_CCLD)$(domain_test_LINK) $(domain_test_OBJECTS) $(domain_test_LDADD) $(LIBS) + +strlst-test$(EXEEXT): $(strlst_test_OBJECTS) $(strlst_test_DEPENDENCIES) $(EXTRA_strlst_test_DEPENDENCIES) + @rm -f strlst-test$(EXEEXT) + $(AM_V_CCLD)$(strlst_test_LINK) $(strlst_test_OBJECTS) $(strlst_test_LDADD) $(LIBS) + +timeval-test$(EXEEXT): $(timeval_test_OBJECTS) $(timeval_test_DEPENDENCIES) $(EXTRA_timeval_test_DEPENDENCIES) + @rm -f timeval-test$(EXEEXT) + $(AM_V_CCLD)$(timeval_test_LINK) $(timeval_test_OBJECTS) $(timeval_test_LDADD) $(LIBS) + +utf8-test$(EXEEXT): $(utf8_test_OBJECTS) $(utf8_test_DEPENDENCIES) $(EXTRA_utf8_test_DEPENDENCIES) + @rm -f utf8-test$(EXEEXT) + $(AM_V_CCLD)$(utf8_test_LINK) $(utf8_test_OBJECTS) $(utf8_test_LDADD) $(LIBS) + +watch-test$(EXEEXT): $(watch_test_OBJECTS) $(watch_test_DEPENDENCIES) $(EXTRA_watch_test_DEPENDENCIES) + @rm -f watch-test$(EXEEXT) + $(AM_V_CCLD)$(watch_test_LINK) $(watch_test_OBJECTS) $(watch_test_LDADD) $(LIBS) + +watch-test-thread$(EXEEXT): $(watch_test_thread_OBJECTS) $(watch_test_thread_DEPENDENCIES) $(EXTRA_watch_test_thread_DEPENDENCIES) + @rm -f watch-test-thread$(EXEEXT) + $(AM_V_CCLD)$(watch_test_thread_LINK) $(watch_test_thread_OBJECTS) $(watch_test_thread_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alternative_test-address.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alternative_test-alternative-test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alternative_test-alternative.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alternative_test-domain.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alternative_test-malloc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alternative_test-utf8.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/domain_test-address.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/domain_test-domain-test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/domain_test-domain.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/domain_test-malloc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/domain_test-utf8.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavahi_common_la-address.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavahi_common_la-alternative.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavahi_common_la-domain.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavahi_common_la-error.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavahi_common_la-i18n.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavahi_common_la-malloc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavahi_common_la-rlist.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavahi_common_la-simple-watch.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavahi_common_la-strlst.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavahi_common_la-thread-watch.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavahi_common_la-timeval.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavahi_common_la-utf8.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strlst_test-malloc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strlst_test-strlst-test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strlst_test-strlst.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timeval_test-timeval-test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timeval_test-timeval.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utf8_test-utf8-test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utf8_test-utf8.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/watch_test-malloc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/watch_test-simple-watch.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/watch_test-timeval.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/watch_test-watch-test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/watch_test_thread-malloc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/watch_test_thread-simple-watch.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/watch_test_thread-thread-watch.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/watch_test_thread-timeval.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/watch_test_thread-watch-test.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +libavahi_common_la-malloc.lo: malloc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_common_la_CFLAGS) $(CFLAGS) -MT libavahi_common_la-malloc.lo -MD -MP -MF $(DEPDIR)/libavahi_common_la-malloc.Tpo -c -o libavahi_common_la-malloc.lo `test -f 'malloc.c' || echo '$(srcdir)/'`malloc.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavahi_common_la-malloc.Tpo $(DEPDIR)/libavahi_common_la-malloc.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='malloc.c' object='libavahi_common_la-malloc.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_common_la_CFLAGS) $(CFLAGS) -c -o libavahi_common_la-malloc.lo `test -f 'malloc.c' || echo '$(srcdir)/'`malloc.c + +libavahi_common_la-address.lo: address.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_common_la_CFLAGS) $(CFLAGS) -MT libavahi_common_la-address.lo -MD -MP -MF $(DEPDIR)/libavahi_common_la-address.Tpo -c -o libavahi_common_la-address.lo `test -f 'address.c' || echo '$(srcdir)/'`address.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavahi_common_la-address.Tpo $(DEPDIR)/libavahi_common_la-address.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='address.c' object='libavahi_common_la-address.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_common_la_CFLAGS) $(CFLAGS) -c -o libavahi_common_la-address.lo `test -f 'address.c' || echo '$(srcdir)/'`address.c + +libavahi_common_la-alternative.lo: alternative.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_common_la_CFLAGS) $(CFLAGS) -MT libavahi_common_la-alternative.lo -MD -MP -MF $(DEPDIR)/libavahi_common_la-alternative.Tpo -c -o libavahi_common_la-alternative.lo `test -f 'alternative.c' || echo '$(srcdir)/'`alternative.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavahi_common_la-alternative.Tpo $(DEPDIR)/libavahi_common_la-alternative.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='alternative.c' object='libavahi_common_la-alternative.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_common_la_CFLAGS) $(CFLAGS) -c -o libavahi_common_la-alternative.lo `test -f 'alternative.c' || echo '$(srcdir)/'`alternative.c + +libavahi_common_la-error.lo: error.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_common_la_CFLAGS) $(CFLAGS) -MT libavahi_common_la-error.lo -MD -MP -MF $(DEPDIR)/libavahi_common_la-error.Tpo -c -o libavahi_common_la-error.lo `test -f 'error.c' || echo '$(srcdir)/'`error.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavahi_common_la-error.Tpo $(DEPDIR)/libavahi_common_la-error.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='error.c' object='libavahi_common_la-error.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_common_la_CFLAGS) $(CFLAGS) -c -o libavahi_common_la-error.lo `test -f 'error.c' || echo '$(srcdir)/'`error.c + +libavahi_common_la-strlst.lo: strlst.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_common_la_CFLAGS) $(CFLAGS) -MT libavahi_common_la-strlst.lo -MD -MP -MF $(DEPDIR)/libavahi_common_la-strlst.Tpo -c -o libavahi_common_la-strlst.lo `test -f 'strlst.c' || echo '$(srcdir)/'`strlst.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavahi_common_la-strlst.Tpo $(DEPDIR)/libavahi_common_la-strlst.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='strlst.c' object='libavahi_common_la-strlst.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_common_la_CFLAGS) $(CFLAGS) -c -o libavahi_common_la-strlst.lo `test -f 'strlst.c' || echo '$(srcdir)/'`strlst.c + +libavahi_common_la-domain.lo: domain.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_common_la_CFLAGS) $(CFLAGS) -MT libavahi_common_la-domain.lo -MD -MP -MF $(DEPDIR)/libavahi_common_la-domain.Tpo -c -o libavahi_common_la-domain.lo `test -f 'domain.c' || echo '$(srcdir)/'`domain.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavahi_common_la-domain.Tpo $(DEPDIR)/libavahi_common_la-domain.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='domain.c' object='libavahi_common_la-domain.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_common_la_CFLAGS) $(CFLAGS) -c -o libavahi_common_la-domain.lo `test -f 'domain.c' || echo '$(srcdir)/'`domain.c + +libavahi_common_la-timeval.lo: timeval.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_common_la_CFLAGS) $(CFLAGS) -MT libavahi_common_la-timeval.lo -MD -MP -MF $(DEPDIR)/libavahi_common_la-timeval.Tpo -c -o libavahi_common_la-timeval.lo `test -f 'timeval.c' || echo '$(srcdir)/'`timeval.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavahi_common_la-timeval.Tpo $(DEPDIR)/libavahi_common_la-timeval.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='timeval.c' object='libavahi_common_la-timeval.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_common_la_CFLAGS) $(CFLAGS) -c -o libavahi_common_la-timeval.lo `test -f 'timeval.c' || echo '$(srcdir)/'`timeval.c + +libavahi_common_la-simple-watch.lo: simple-watch.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_common_la_CFLAGS) $(CFLAGS) -MT libavahi_common_la-simple-watch.lo -MD -MP -MF $(DEPDIR)/libavahi_common_la-simple-watch.Tpo -c -o libavahi_common_la-simple-watch.lo `test -f 'simple-watch.c' || echo '$(srcdir)/'`simple-watch.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavahi_common_la-simple-watch.Tpo $(DEPDIR)/libavahi_common_la-simple-watch.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='simple-watch.c' object='libavahi_common_la-simple-watch.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_common_la_CFLAGS) $(CFLAGS) -c -o libavahi_common_la-simple-watch.lo `test -f 'simple-watch.c' || echo '$(srcdir)/'`simple-watch.c + +libavahi_common_la-thread-watch.lo: thread-watch.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_common_la_CFLAGS) $(CFLAGS) -MT libavahi_common_la-thread-watch.lo -MD -MP -MF $(DEPDIR)/libavahi_common_la-thread-watch.Tpo -c -o libavahi_common_la-thread-watch.lo `test -f 'thread-watch.c' || echo '$(srcdir)/'`thread-watch.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavahi_common_la-thread-watch.Tpo $(DEPDIR)/libavahi_common_la-thread-watch.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='thread-watch.c' object='libavahi_common_la-thread-watch.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_common_la_CFLAGS) $(CFLAGS) -c -o libavahi_common_la-thread-watch.lo `test -f 'thread-watch.c' || echo '$(srcdir)/'`thread-watch.c + +libavahi_common_la-rlist.lo: rlist.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_common_la_CFLAGS) $(CFLAGS) -MT libavahi_common_la-rlist.lo -MD -MP -MF $(DEPDIR)/libavahi_common_la-rlist.Tpo -c -o libavahi_common_la-rlist.lo `test -f 'rlist.c' || echo '$(srcdir)/'`rlist.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavahi_common_la-rlist.Tpo $(DEPDIR)/libavahi_common_la-rlist.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rlist.c' object='libavahi_common_la-rlist.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_common_la_CFLAGS) $(CFLAGS) -c -o libavahi_common_la-rlist.lo `test -f 'rlist.c' || echo '$(srcdir)/'`rlist.c + +libavahi_common_la-utf8.lo: utf8.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_common_la_CFLAGS) $(CFLAGS) -MT libavahi_common_la-utf8.lo -MD -MP -MF $(DEPDIR)/libavahi_common_la-utf8.Tpo -c -o libavahi_common_la-utf8.lo `test -f 'utf8.c' || echo '$(srcdir)/'`utf8.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavahi_common_la-utf8.Tpo $(DEPDIR)/libavahi_common_la-utf8.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='utf8.c' object='libavahi_common_la-utf8.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_common_la_CFLAGS) $(CFLAGS) -c -o libavahi_common_la-utf8.lo `test -f 'utf8.c' || echo '$(srcdir)/'`utf8.c + +libavahi_common_la-i18n.lo: i18n.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_common_la_CFLAGS) $(CFLAGS) -MT libavahi_common_la-i18n.lo -MD -MP -MF $(DEPDIR)/libavahi_common_la-i18n.Tpo -c -o libavahi_common_la-i18n.lo `test -f 'i18n.c' || echo '$(srcdir)/'`i18n.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavahi_common_la-i18n.Tpo $(DEPDIR)/libavahi_common_la-i18n.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='i18n.c' object='libavahi_common_la-i18n.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libavahi_common_la_CFLAGS) $(CFLAGS) -c -o libavahi_common_la-i18n.lo `test -f 'i18n.c' || echo '$(srcdir)/'`i18n.c + +alternative_test-alternative.o: alternative.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(alternative_test_CFLAGS) $(CFLAGS) -MT alternative_test-alternative.o -MD -MP -MF $(DEPDIR)/alternative_test-alternative.Tpo -c -o alternative_test-alternative.o `test -f 'alternative.c' || echo '$(srcdir)/'`alternative.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/alternative_test-alternative.Tpo $(DEPDIR)/alternative_test-alternative.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='alternative.c' object='alternative_test-alternative.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(alternative_test_CFLAGS) $(CFLAGS) -c -o alternative_test-alternative.o `test -f 'alternative.c' || echo '$(srcdir)/'`alternative.c + +alternative_test-alternative.obj: alternative.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(alternative_test_CFLAGS) $(CFLAGS) -MT alternative_test-alternative.obj -MD -MP -MF $(DEPDIR)/alternative_test-alternative.Tpo -c -o alternative_test-alternative.obj `if test -f 'alternative.c'; then $(CYGPATH_W) 'alternative.c'; else $(CYGPATH_W) '$(srcdir)/alternative.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/alternative_test-alternative.Tpo $(DEPDIR)/alternative_test-alternative.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='alternative.c' object='alternative_test-alternative.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(alternative_test_CFLAGS) $(CFLAGS) -c -o alternative_test-alternative.obj `if test -f 'alternative.c'; then $(CYGPATH_W) 'alternative.c'; else $(CYGPATH_W) '$(srcdir)/alternative.c'; fi` + +alternative_test-malloc.o: malloc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(alternative_test_CFLAGS) $(CFLAGS) -MT alternative_test-malloc.o -MD -MP -MF $(DEPDIR)/alternative_test-malloc.Tpo -c -o alternative_test-malloc.o `test -f 'malloc.c' || echo '$(srcdir)/'`malloc.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/alternative_test-malloc.Tpo $(DEPDIR)/alternative_test-malloc.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='malloc.c' object='alternative_test-malloc.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(alternative_test_CFLAGS) $(CFLAGS) -c -o alternative_test-malloc.o `test -f 'malloc.c' || echo '$(srcdir)/'`malloc.c + +alternative_test-malloc.obj: malloc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(alternative_test_CFLAGS) $(CFLAGS) -MT alternative_test-malloc.obj -MD -MP -MF $(DEPDIR)/alternative_test-malloc.Tpo -c -o alternative_test-malloc.obj `if test -f 'malloc.c'; then $(CYGPATH_W) 'malloc.c'; else $(CYGPATH_W) '$(srcdir)/malloc.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/alternative_test-malloc.Tpo $(DEPDIR)/alternative_test-malloc.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='malloc.c' object='alternative_test-malloc.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(alternative_test_CFLAGS) $(CFLAGS) -c -o alternative_test-malloc.obj `if test -f 'malloc.c'; then $(CYGPATH_W) 'malloc.c'; else $(CYGPATH_W) '$(srcdir)/malloc.c'; fi` + +alternative_test-domain.o: domain.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(alternative_test_CFLAGS) $(CFLAGS) -MT alternative_test-domain.o -MD -MP -MF $(DEPDIR)/alternative_test-domain.Tpo -c -o alternative_test-domain.o `test -f 'domain.c' || echo '$(srcdir)/'`domain.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/alternative_test-domain.Tpo $(DEPDIR)/alternative_test-domain.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='domain.c' object='alternative_test-domain.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(alternative_test_CFLAGS) $(CFLAGS) -c -o alternative_test-domain.o `test -f 'domain.c' || echo '$(srcdir)/'`domain.c + +alternative_test-domain.obj: domain.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(alternative_test_CFLAGS) $(CFLAGS) -MT alternative_test-domain.obj -MD -MP -MF $(DEPDIR)/alternative_test-domain.Tpo -c -o alternative_test-domain.obj `if test -f 'domain.c'; then $(CYGPATH_W) 'domain.c'; else $(CYGPATH_W) '$(srcdir)/domain.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/alternative_test-domain.Tpo $(DEPDIR)/alternative_test-domain.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='domain.c' object='alternative_test-domain.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(alternative_test_CFLAGS) $(CFLAGS) -c -o alternative_test-domain.obj `if test -f 'domain.c'; then $(CYGPATH_W) 'domain.c'; else $(CYGPATH_W) '$(srcdir)/domain.c'; fi` + +alternative_test-address.o: address.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(alternative_test_CFLAGS) $(CFLAGS) -MT alternative_test-address.o -MD -MP -MF $(DEPDIR)/alternative_test-address.Tpo -c -o alternative_test-address.o `test -f 'address.c' || echo '$(srcdir)/'`address.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/alternative_test-address.Tpo $(DEPDIR)/alternative_test-address.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='address.c' object='alternative_test-address.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(alternative_test_CFLAGS) $(CFLAGS) -c -o alternative_test-address.o `test -f 'address.c' || echo '$(srcdir)/'`address.c + +alternative_test-address.obj: address.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(alternative_test_CFLAGS) $(CFLAGS) -MT alternative_test-address.obj -MD -MP -MF $(DEPDIR)/alternative_test-address.Tpo -c -o alternative_test-address.obj `if test -f 'address.c'; then $(CYGPATH_W) 'address.c'; else $(CYGPATH_W) '$(srcdir)/address.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/alternative_test-address.Tpo $(DEPDIR)/alternative_test-address.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='address.c' object='alternative_test-address.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(alternative_test_CFLAGS) $(CFLAGS) -c -o alternative_test-address.obj `if test -f 'address.c'; then $(CYGPATH_W) 'address.c'; else $(CYGPATH_W) '$(srcdir)/address.c'; fi` + +alternative_test-alternative-test.o: alternative-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(alternative_test_CFLAGS) $(CFLAGS) -MT alternative_test-alternative-test.o -MD -MP -MF $(DEPDIR)/alternative_test-alternative-test.Tpo -c -o alternative_test-alternative-test.o `test -f 'alternative-test.c' || echo '$(srcdir)/'`alternative-test.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/alternative_test-alternative-test.Tpo $(DEPDIR)/alternative_test-alternative-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='alternative-test.c' object='alternative_test-alternative-test.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(alternative_test_CFLAGS) $(CFLAGS) -c -o alternative_test-alternative-test.o `test -f 'alternative-test.c' || echo '$(srcdir)/'`alternative-test.c + +alternative_test-alternative-test.obj: alternative-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(alternative_test_CFLAGS) $(CFLAGS) -MT alternative_test-alternative-test.obj -MD -MP -MF $(DEPDIR)/alternative_test-alternative-test.Tpo -c -o alternative_test-alternative-test.obj `if test -f 'alternative-test.c'; then $(CYGPATH_W) 'alternative-test.c'; else $(CYGPATH_W) '$(srcdir)/alternative-test.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/alternative_test-alternative-test.Tpo $(DEPDIR)/alternative_test-alternative-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='alternative-test.c' object='alternative_test-alternative-test.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(alternative_test_CFLAGS) $(CFLAGS) -c -o alternative_test-alternative-test.obj `if test -f 'alternative-test.c'; then $(CYGPATH_W) 'alternative-test.c'; else $(CYGPATH_W) '$(srcdir)/alternative-test.c'; fi` + +alternative_test-utf8.o: utf8.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(alternative_test_CFLAGS) $(CFLAGS) -MT alternative_test-utf8.o -MD -MP -MF $(DEPDIR)/alternative_test-utf8.Tpo -c -o alternative_test-utf8.o `test -f 'utf8.c' || echo '$(srcdir)/'`utf8.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/alternative_test-utf8.Tpo $(DEPDIR)/alternative_test-utf8.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='utf8.c' object='alternative_test-utf8.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(alternative_test_CFLAGS) $(CFLAGS) -c -o alternative_test-utf8.o `test -f 'utf8.c' || echo '$(srcdir)/'`utf8.c + +alternative_test-utf8.obj: utf8.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(alternative_test_CFLAGS) $(CFLAGS) -MT alternative_test-utf8.obj -MD -MP -MF $(DEPDIR)/alternative_test-utf8.Tpo -c -o alternative_test-utf8.obj `if test -f 'utf8.c'; then $(CYGPATH_W) 'utf8.c'; else $(CYGPATH_W) '$(srcdir)/utf8.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/alternative_test-utf8.Tpo $(DEPDIR)/alternative_test-utf8.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='utf8.c' object='alternative_test-utf8.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(alternative_test_CFLAGS) $(CFLAGS) -c -o alternative_test-utf8.obj `if test -f 'utf8.c'; then $(CYGPATH_W) 'utf8.c'; else $(CYGPATH_W) '$(srcdir)/utf8.c'; fi` + +domain_test-domain.o: domain.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(domain_test_CFLAGS) $(CFLAGS) -MT domain_test-domain.o -MD -MP -MF $(DEPDIR)/domain_test-domain.Tpo -c -o domain_test-domain.o `test -f 'domain.c' || echo '$(srcdir)/'`domain.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/domain_test-domain.Tpo $(DEPDIR)/domain_test-domain.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='domain.c' object='domain_test-domain.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(domain_test_CFLAGS) $(CFLAGS) -c -o domain_test-domain.o `test -f 'domain.c' || echo '$(srcdir)/'`domain.c + +domain_test-domain.obj: domain.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(domain_test_CFLAGS) $(CFLAGS) -MT domain_test-domain.obj -MD -MP -MF $(DEPDIR)/domain_test-domain.Tpo -c -o domain_test-domain.obj `if test -f 'domain.c'; then $(CYGPATH_W) 'domain.c'; else $(CYGPATH_W) '$(srcdir)/domain.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/domain_test-domain.Tpo $(DEPDIR)/domain_test-domain.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='domain.c' object='domain_test-domain.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(domain_test_CFLAGS) $(CFLAGS) -c -o domain_test-domain.obj `if test -f 'domain.c'; then $(CYGPATH_W) 'domain.c'; else $(CYGPATH_W) '$(srcdir)/domain.c'; fi` + +domain_test-malloc.o: malloc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(domain_test_CFLAGS) $(CFLAGS) -MT domain_test-malloc.o -MD -MP -MF $(DEPDIR)/domain_test-malloc.Tpo -c -o domain_test-malloc.o `test -f 'malloc.c' || echo '$(srcdir)/'`malloc.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/domain_test-malloc.Tpo $(DEPDIR)/domain_test-malloc.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='malloc.c' object='domain_test-malloc.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(domain_test_CFLAGS) $(CFLAGS) -c -o domain_test-malloc.o `test -f 'malloc.c' || echo '$(srcdir)/'`malloc.c + +domain_test-malloc.obj: malloc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(domain_test_CFLAGS) $(CFLAGS) -MT domain_test-malloc.obj -MD -MP -MF $(DEPDIR)/domain_test-malloc.Tpo -c -o domain_test-malloc.obj `if test -f 'malloc.c'; then $(CYGPATH_W) 'malloc.c'; else $(CYGPATH_W) '$(srcdir)/malloc.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/domain_test-malloc.Tpo $(DEPDIR)/domain_test-malloc.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='malloc.c' object='domain_test-malloc.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(domain_test_CFLAGS) $(CFLAGS) -c -o domain_test-malloc.obj `if test -f 'malloc.c'; then $(CYGPATH_W) 'malloc.c'; else $(CYGPATH_W) '$(srcdir)/malloc.c'; fi` + +domain_test-address.o: address.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(domain_test_CFLAGS) $(CFLAGS) -MT domain_test-address.o -MD -MP -MF $(DEPDIR)/domain_test-address.Tpo -c -o domain_test-address.o `test -f 'address.c' || echo '$(srcdir)/'`address.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/domain_test-address.Tpo $(DEPDIR)/domain_test-address.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='address.c' object='domain_test-address.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(domain_test_CFLAGS) $(CFLAGS) -c -o domain_test-address.o `test -f 'address.c' || echo '$(srcdir)/'`address.c + +domain_test-address.obj: address.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(domain_test_CFLAGS) $(CFLAGS) -MT domain_test-address.obj -MD -MP -MF $(DEPDIR)/domain_test-address.Tpo -c -o domain_test-address.obj `if test -f 'address.c'; then $(CYGPATH_W) 'address.c'; else $(CYGPATH_W) '$(srcdir)/address.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/domain_test-address.Tpo $(DEPDIR)/domain_test-address.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='address.c' object='domain_test-address.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(domain_test_CFLAGS) $(CFLAGS) -c -o domain_test-address.obj `if test -f 'address.c'; then $(CYGPATH_W) 'address.c'; else $(CYGPATH_W) '$(srcdir)/address.c'; fi` + +domain_test-domain-test.o: domain-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(domain_test_CFLAGS) $(CFLAGS) -MT domain_test-domain-test.o -MD -MP -MF $(DEPDIR)/domain_test-domain-test.Tpo -c -o domain_test-domain-test.o `test -f 'domain-test.c' || echo '$(srcdir)/'`domain-test.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/domain_test-domain-test.Tpo $(DEPDIR)/domain_test-domain-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='domain-test.c' object='domain_test-domain-test.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(domain_test_CFLAGS) $(CFLAGS) -c -o domain_test-domain-test.o `test -f 'domain-test.c' || echo '$(srcdir)/'`domain-test.c + +domain_test-domain-test.obj: domain-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(domain_test_CFLAGS) $(CFLAGS) -MT domain_test-domain-test.obj -MD -MP -MF $(DEPDIR)/domain_test-domain-test.Tpo -c -o domain_test-domain-test.obj `if test -f 'domain-test.c'; then $(CYGPATH_W) 'domain-test.c'; else $(CYGPATH_W) '$(srcdir)/domain-test.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/domain_test-domain-test.Tpo $(DEPDIR)/domain_test-domain-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='domain-test.c' object='domain_test-domain-test.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(domain_test_CFLAGS) $(CFLAGS) -c -o domain_test-domain-test.obj `if test -f 'domain-test.c'; then $(CYGPATH_W) 'domain-test.c'; else $(CYGPATH_W) '$(srcdir)/domain-test.c'; fi` + +domain_test-utf8.o: utf8.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(domain_test_CFLAGS) $(CFLAGS) -MT domain_test-utf8.o -MD -MP -MF $(DEPDIR)/domain_test-utf8.Tpo -c -o domain_test-utf8.o `test -f 'utf8.c' || echo '$(srcdir)/'`utf8.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/domain_test-utf8.Tpo $(DEPDIR)/domain_test-utf8.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='utf8.c' object='domain_test-utf8.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(domain_test_CFLAGS) $(CFLAGS) -c -o domain_test-utf8.o `test -f 'utf8.c' || echo '$(srcdir)/'`utf8.c + +domain_test-utf8.obj: utf8.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(domain_test_CFLAGS) $(CFLAGS) -MT domain_test-utf8.obj -MD -MP -MF $(DEPDIR)/domain_test-utf8.Tpo -c -o domain_test-utf8.obj `if test -f 'utf8.c'; then $(CYGPATH_W) 'utf8.c'; else $(CYGPATH_W) '$(srcdir)/utf8.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/domain_test-utf8.Tpo $(DEPDIR)/domain_test-utf8.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='utf8.c' object='domain_test-utf8.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(domain_test_CFLAGS) $(CFLAGS) -c -o domain_test-utf8.obj `if test -f 'utf8.c'; then $(CYGPATH_W) 'utf8.c'; else $(CYGPATH_W) '$(srcdir)/utf8.c'; fi` + +strlst_test-strlst.o: strlst.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(strlst_test_CFLAGS) $(CFLAGS) -MT strlst_test-strlst.o -MD -MP -MF $(DEPDIR)/strlst_test-strlst.Tpo -c -o strlst_test-strlst.o `test -f 'strlst.c' || echo '$(srcdir)/'`strlst.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/strlst_test-strlst.Tpo $(DEPDIR)/strlst_test-strlst.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='strlst.c' object='strlst_test-strlst.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(strlst_test_CFLAGS) $(CFLAGS) -c -o strlst_test-strlst.o `test -f 'strlst.c' || echo '$(srcdir)/'`strlst.c + +strlst_test-strlst.obj: strlst.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(strlst_test_CFLAGS) $(CFLAGS) -MT strlst_test-strlst.obj -MD -MP -MF $(DEPDIR)/strlst_test-strlst.Tpo -c -o strlst_test-strlst.obj `if test -f 'strlst.c'; then $(CYGPATH_W) 'strlst.c'; else $(CYGPATH_W) '$(srcdir)/strlst.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/strlst_test-strlst.Tpo $(DEPDIR)/strlst_test-strlst.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='strlst.c' object='strlst_test-strlst.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(strlst_test_CFLAGS) $(CFLAGS) -c -o strlst_test-strlst.obj `if test -f 'strlst.c'; then $(CYGPATH_W) 'strlst.c'; else $(CYGPATH_W) '$(srcdir)/strlst.c'; fi` + +strlst_test-malloc.o: malloc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(strlst_test_CFLAGS) $(CFLAGS) -MT strlst_test-malloc.o -MD -MP -MF $(DEPDIR)/strlst_test-malloc.Tpo -c -o strlst_test-malloc.o `test -f 'malloc.c' || echo '$(srcdir)/'`malloc.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/strlst_test-malloc.Tpo $(DEPDIR)/strlst_test-malloc.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='malloc.c' object='strlst_test-malloc.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(strlst_test_CFLAGS) $(CFLAGS) -c -o strlst_test-malloc.o `test -f 'malloc.c' || echo '$(srcdir)/'`malloc.c + +strlst_test-malloc.obj: malloc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(strlst_test_CFLAGS) $(CFLAGS) -MT strlst_test-malloc.obj -MD -MP -MF $(DEPDIR)/strlst_test-malloc.Tpo -c -o strlst_test-malloc.obj `if test -f 'malloc.c'; then $(CYGPATH_W) 'malloc.c'; else $(CYGPATH_W) '$(srcdir)/malloc.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/strlst_test-malloc.Tpo $(DEPDIR)/strlst_test-malloc.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='malloc.c' object='strlst_test-malloc.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(strlst_test_CFLAGS) $(CFLAGS) -c -o strlst_test-malloc.obj `if test -f 'malloc.c'; then $(CYGPATH_W) 'malloc.c'; else $(CYGPATH_W) '$(srcdir)/malloc.c'; fi` + +strlst_test-strlst-test.o: strlst-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(strlst_test_CFLAGS) $(CFLAGS) -MT strlst_test-strlst-test.o -MD -MP -MF $(DEPDIR)/strlst_test-strlst-test.Tpo -c -o strlst_test-strlst-test.o `test -f 'strlst-test.c' || echo '$(srcdir)/'`strlst-test.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/strlst_test-strlst-test.Tpo $(DEPDIR)/strlst_test-strlst-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='strlst-test.c' object='strlst_test-strlst-test.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(strlst_test_CFLAGS) $(CFLAGS) -c -o strlst_test-strlst-test.o `test -f 'strlst-test.c' || echo '$(srcdir)/'`strlst-test.c + +strlst_test-strlst-test.obj: strlst-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(strlst_test_CFLAGS) $(CFLAGS) -MT strlst_test-strlst-test.obj -MD -MP -MF $(DEPDIR)/strlst_test-strlst-test.Tpo -c -o strlst_test-strlst-test.obj `if test -f 'strlst-test.c'; then $(CYGPATH_W) 'strlst-test.c'; else $(CYGPATH_W) '$(srcdir)/strlst-test.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/strlst_test-strlst-test.Tpo $(DEPDIR)/strlst_test-strlst-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='strlst-test.c' object='strlst_test-strlst-test.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(strlst_test_CFLAGS) $(CFLAGS) -c -o strlst_test-strlst-test.obj `if test -f 'strlst-test.c'; then $(CYGPATH_W) 'strlst-test.c'; else $(CYGPATH_W) '$(srcdir)/strlst-test.c'; fi` + +timeval_test-timeval.o: timeval.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(timeval_test_CFLAGS) $(CFLAGS) -MT timeval_test-timeval.o -MD -MP -MF $(DEPDIR)/timeval_test-timeval.Tpo -c -o timeval_test-timeval.o `test -f 'timeval.c' || echo '$(srcdir)/'`timeval.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/timeval_test-timeval.Tpo $(DEPDIR)/timeval_test-timeval.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='timeval.c' object='timeval_test-timeval.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(timeval_test_CFLAGS) $(CFLAGS) -c -o timeval_test-timeval.o `test -f 'timeval.c' || echo '$(srcdir)/'`timeval.c + +timeval_test-timeval.obj: timeval.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(timeval_test_CFLAGS) $(CFLAGS) -MT timeval_test-timeval.obj -MD -MP -MF $(DEPDIR)/timeval_test-timeval.Tpo -c -o timeval_test-timeval.obj `if test -f 'timeval.c'; then $(CYGPATH_W) 'timeval.c'; else $(CYGPATH_W) '$(srcdir)/timeval.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/timeval_test-timeval.Tpo $(DEPDIR)/timeval_test-timeval.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='timeval.c' object='timeval_test-timeval.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(timeval_test_CFLAGS) $(CFLAGS) -c -o timeval_test-timeval.obj `if test -f 'timeval.c'; then $(CYGPATH_W) 'timeval.c'; else $(CYGPATH_W) '$(srcdir)/timeval.c'; fi` + +timeval_test-timeval-test.o: timeval-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(timeval_test_CFLAGS) $(CFLAGS) -MT timeval_test-timeval-test.o -MD -MP -MF $(DEPDIR)/timeval_test-timeval-test.Tpo -c -o timeval_test-timeval-test.o `test -f 'timeval-test.c' || echo '$(srcdir)/'`timeval-test.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/timeval_test-timeval-test.Tpo $(DEPDIR)/timeval_test-timeval-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='timeval-test.c' object='timeval_test-timeval-test.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(timeval_test_CFLAGS) $(CFLAGS) -c -o timeval_test-timeval-test.o `test -f 'timeval-test.c' || echo '$(srcdir)/'`timeval-test.c + +timeval_test-timeval-test.obj: timeval-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(timeval_test_CFLAGS) $(CFLAGS) -MT timeval_test-timeval-test.obj -MD -MP -MF $(DEPDIR)/timeval_test-timeval-test.Tpo -c -o timeval_test-timeval-test.obj `if test -f 'timeval-test.c'; then $(CYGPATH_W) 'timeval-test.c'; else $(CYGPATH_W) '$(srcdir)/timeval-test.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/timeval_test-timeval-test.Tpo $(DEPDIR)/timeval_test-timeval-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='timeval-test.c' object='timeval_test-timeval-test.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(timeval_test_CFLAGS) $(CFLAGS) -c -o timeval_test-timeval-test.obj `if test -f 'timeval-test.c'; then $(CYGPATH_W) 'timeval-test.c'; else $(CYGPATH_W) '$(srcdir)/timeval-test.c'; fi` + +utf8_test-utf8-test.o: utf8-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(utf8_test_CFLAGS) $(CFLAGS) -MT utf8_test-utf8-test.o -MD -MP -MF $(DEPDIR)/utf8_test-utf8-test.Tpo -c -o utf8_test-utf8-test.o `test -f 'utf8-test.c' || echo '$(srcdir)/'`utf8-test.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/utf8_test-utf8-test.Tpo $(DEPDIR)/utf8_test-utf8-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='utf8-test.c' object='utf8_test-utf8-test.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(utf8_test_CFLAGS) $(CFLAGS) -c -o utf8_test-utf8-test.o `test -f 'utf8-test.c' || echo '$(srcdir)/'`utf8-test.c + +utf8_test-utf8-test.obj: utf8-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(utf8_test_CFLAGS) $(CFLAGS) -MT utf8_test-utf8-test.obj -MD -MP -MF $(DEPDIR)/utf8_test-utf8-test.Tpo -c -o utf8_test-utf8-test.obj `if test -f 'utf8-test.c'; then $(CYGPATH_W) 'utf8-test.c'; else $(CYGPATH_W) '$(srcdir)/utf8-test.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/utf8_test-utf8-test.Tpo $(DEPDIR)/utf8_test-utf8-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='utf8-test.c' object='utf8_test-utf8-test.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(utf8_test_CFLAGS) $(CFLAGS) -c -o utf8_test-utf8-test.obj `if test -f 'utf8-test.c'; then $(CYGPATH_W) 'utf8-test.c'; else $(CYGPATH_W) '$(srcdir)/utf8-test.c'; fi` + +utf8_test-utf8.o: utf8.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(utf8_test_CFLAGS) $(CFLAGS) -MT utf8_test-utf8.o -MD -MP -MF $(DEPDIR)/utf8_test-utf8.Tpo -c -o utf8_test-utf8.o `test -f 'utf8.c' || echo '$(srcdir)/'`utf8.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/utf8_test-utf8.Tpo $(DEPDIR)/utf8_test-utf8.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='utf8.c' object='utf8_test-utf8.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(utf8_test_CFLAGS) $(CFLAGS) -c -o utf8_test-utf8.o `test -f 'utf8.c' || echo '$(srcdir)/'`utf8.c + +utf8_test-utf8.obj: utf8.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(utf8_test_CFLAGS) $(CFLAGS) -MT utf8_test-utf8.obj -MD -MP -MF $(DEPDIR)/utf8_test-utf8.Tpo -c -o utf8_test-utf8.obj `if test -f 'utf8.c'; then $(CYGPATH_W) 'utf8.c'; else $(CYGPATH_W) '$(srcdir)/utf8.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/utf8_test-utf8.Tpo $(DEPDIR)/utf8_test-utf8.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='utf8.c' object='utf8_test-utf8.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(utf8_test_CFLAGS) $(CFLAGS) -c -o utf8_test-utf8.obj `if test -f 'utf8.c'; then $(CYGPATH_W) 'utf8.c'; else $(CYGPATH_W) '$(srcdir)/utf8.c'; fi` + +watch_test-timeval.o: timeval.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_CFLAGS) $(CFLAGS) -MT watch_test-timeval.o -MD -MP -MF $(DEPDIR)/watch_test-timeval.Tpo -c -o watch_test-timeval.o `test -f 'timeval.c' || echo '$(srcdir)/'`timeval.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/watch_test-timeval.Tpo $(DEPDIR)/watch_test-timeval.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='timeval.c' object='watch_test-timeval.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_CFLAGS) $(CFLAGS) -c -o watch_test-timeval.o `test -f 'timeval.c' || echo '$(srcdir)/'`timeval.c + +watch_test-timeval.obj: timeval.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_CFLAGS) $(CFLAGS) -MT watch_test-timeval.obj -MD -MP -MF $(DEPDIR)/watch_test-timeval.Tpo -c -o watch_test-timeval.obj `if test -f 'timeval.c'; then $(CYGPATH_W) 'timeval.c'; else $(CYGPATH_W) '$(srcdir)/timeval.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/watch_test-timeval.Tpo $(DEPDIR)/watch_test-timeval.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='timeval.c' object='watch_test-timeval.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_CFLAGS) $(CFLAGS) -c -o watch_test-timeval.obj `if test -f 'timeval.c'; then $(CYGPATH_W) 'timeval.c'; else $(CYGPATH_W) '$(srcdir)/timeval.c'; fi` + +watch_test-simple-watch.o: simple-watch.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_CFLAGS) $(CFLAGS) -MT watch_test-simple-watch.o -MD -MP -MF $(DEPDIR)/watch_test-simple-watch.Tpo -c -o watch_test-simple-watch.o `test -f 'simple-watch.c' || echo '$(srcdir)/'`simple-watch.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/watch_test-simple-watch.Tpo $(DEPDIR)/watch_test-simple-watch.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='simple-watch.c' object='watch_test-simple-watch.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_CFLAGS) $(CFLAGS) -c -o watch_test-simple-watch.o `test -f 'simple-watch.c' || echo '$(srcdir)/'`simple-watch.c + +watch_test-simple-watch.obj: simple-watch.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_CFLAGS) $(CFLAGS) -MT watch_test-simple-watch.obj -MD -MP -MF $(DEPDIR)/watch_test-simple-watch.Tpo -c -o watch_test-simple-watch.obj `if test -f 'simple-watch.c'; then $(CYGPATH_W) 'simple-watch.c'; else $(CYGPATH_W) '$(srcdir)/simple-watch.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/watch_test-simple-watch.Tpo $(DEPDIR)/watch_test-simple-watch.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='simple-watch.c' object='watch_test-simple-watch.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_CFLAGS) $(CFLAGS) -c -o watch_test-simple-watch.obj `if test -f 'simple-watch.c'; then $(CYGPATH_W) 'simple-watch.c'; else $(CYGPATH_W) '$(srcdir)/simple-watch.c'; fi` + +watch_test-malloc.o: malloc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_CFLAGS) $(CFLAGS) -MT watch_test-malloc.o -MD -MP -MF $(DEPDIR)/watch_test-malloc.Tpo -c -o watch_test-malloc.o `test -f 'malloc.c' || echo '$(srcdir)/'`malloc.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/watch_test-malloc.Tpo $(DEPDIR)/watch_test-malloc.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='malloc.c' object='watch_test-malloc.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_CFLAGS) $(CFLAGS) -c -o watch_test-malloc.o `test -f 'malloc.c' || echo '$(srcdir)/'`malloc.c + +watch_test-malloc.obj: malloc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_CFLAGS) $(CFLAGS) -MT watch_test-malloc.obj -MD -MP -MF $(DEPDIR)/watch_test-malloc.Tpo -c -o watch_test-malloc.obj `if test -f 'malloc.c'; then $(CYGPATH_W) 'malloc.c'; else $(CYGPATH_W) '$(srcdir)/malloc.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/watch_test-malloc.Tpo $(DEPDIR)/watch_test-malloc.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='malloc.c' object='watch_test-malloc.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_CFLAGS) $(CFLAGS) -c -o watch_test-malloc.obj `if test -f 'malloc.c'; then $(CYGPATH_W) 'malloc.c'; else $(CYGPATH_W) '$(srcdir)/malloc.c'; fi` + +watch_test-watch-test.o: watch-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_CFLAGS) $(CFLAGS) -MT watch_test-watch-test.o -MD -MP -MF $(DEPDIR)/watch_test-watch-test.Tpo -c -o watch_test-watch-test.o `test -f 'watch-test.c' || echo '$(srcdir)/'`watch-test.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/watch_test-watch-test.Tpo $(DEPDIR)/watch_test-watch-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='watch-test.c' object='watch_test-watch-test.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_CFLAGS) $(CFLAGS) -c -o watch_test-watch-test.o `test -f 'watch-test.c' || echo '$(srcdir)/'`watch-test.c + +watch_test-watch-test.obj: watch-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_CFLAGS) $(CFLAGS) -MT watch_test-watch-test.obj -MD -MP -MF $(DEPDIR)/watch_test-watch-test.Tpo -c -o watch_test-watch-test.obj `if test -f 'watch-test.c'; then $(CYGPATH_W) 'watch-test.c'; else $(CYGPATH_W) '$(srcdir)/watch-test.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/watch_test-watch-test.Tpo $(DEPDIR)/watch_test-watch-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='watch-test.c' object='watch_test-watch-test.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_CFLAGS) $(CFLAGS) -c -o watch_test-watch-test.obj `if test -f 'watch-test.c'; then $(CYGPATH_W) 'watch-test.c'; else $(CYGPATH_W) '$(srcdir)/watch-test.c'; fi` + +watch_test_thread-timeval.o: timeval.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_thread_CFLAGS) $(CFLAGS) -MT watch_test_thread-timeval.o -MD -MP -MF $(DEPDIR)/watch_test_thread-timeval.Tpo -c -o watch_test_thread-timeval.o `test -f 'timeval.c' || echo '$(srcdir)/'`timeval.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/watch_test_thread-timeval.Tpo $(DEPDIR)/watch_test_thread-timeval.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='timeval.c' object='watch_test_thread-timeval.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_thread_CFLAGS) $(CFLAGS) -c -o watch_test_thread-timeval.o `test -f 'timeval.c' || echo '$(srcdir)/'`timeval.c + +watch_test_thread-timeval.obj: timeval.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_thread_CFLAGS) $(CFLAGS) -MT watch_test_thread-timeval.obj -MD -MP -MF $(DEPDIR)/watch_test_thread-timeval.Tpo -c -o watch_test_thread-timeval.obj `if test -f 'timeval.c'; then $(CYGPATH_W) 'timeval.c'; else $(CYGPATH_W) '$(srcdir)/timeval.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/watch_test_thread-timeval.Tpo $(DEPDIR)/watch_test_thread-timeval.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='timeval.c' object='watch_test_thread-timeval.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_thread_CFLAGS) $(CFLAGS) -c -o watch_test_thread-timeval.obj `if test -f 'timeval.c'; then $(CYGPATH_W) 'timeval.c'; else $(CYGPATH_W) '$(srcdir)/timeval.c'; fi` + +watch_test_thread-simple-watch.o: simple-watch.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_thread_CFLAGS) $(CFLAGS) -MT watch_test_thread-simple-watch.o -MD -MP -MF $(DEPDIR)/watch_test_thread-simple-watch.Tpo -c -o watch_test_thread-simple-watch.o `test -f 'simple-watch.c' || echo '$(srcdir)/'`simple-watch.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/watch_test_thread-simple-watch.Tpo $(DEPDIR)/watch_test_thread-simple-watch.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='simple-watch.c' object='watch_test_thread-simple-watch.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_thread_CFLAGS) $(CFLAGS) -c -o watch_test_thread-simple-watch.o `test -f 'simple-watch.c' || echo '$(srcdir)/'`simple-watch.c + +watch_test_thread-simple-watch.obj: simple-watch.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_thread_CFLAGS) $(CFLAGS) -MT watch_test_thread-simple-watch.obj -MD -MP -MF $(DEPDIR)/watch_test_thread-simple-watch.Tpo -c -o watch_test_thread-simple-watch.obj `if test -f 'simple-watch.c'; then $(CYGPATH_W) 'simple-watch.c'; else $(CYGPATH_W) '$(srcdir)/simple-watch.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/watch_test_thread-simple-watch.Tpo $(DEPDIR)/watch_test_thread-simple-watch.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='simple-watch.c' object='watch_test_thread-simple-watch.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_thread_CFLAGS) $(CFLAGS) -c -o watch_test_thread-simple-watch.obj `if test -f 'simple-watch.c'; then $(CYGPATH_W) 'simple-watch.c'; else $(CYGPATH_W) '$(srcdir)/simple-watch.c'; fi` + +watch_test_thread-malloc.o: malloc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_thread_CFLAGS) $(CFLAGS) -MT watch_test_thread-malloc.o -MD -MP -MF $(DEPDIR)/watch_test_thread-malloc.Tpo -c -o watch_test_thread-malloc.o `test -f 'malloc.c' || echo '$(srcdir)/'`malloc.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/watch_test_thread-malloc.Tpo $(DEPDIR)/watch_test_thread-malloc.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='malloc.c' object='watch_test_thread-malloc.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_thread_CFLAGS) $(CFLAGS) -c -o watch_test_thread-malloc.o `test -f 'malloc.c' || echo '$(srcdir)/'`malloc.c + +watch_test_thread-malloc.obj: malloc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_thread_CFLAGS) $(CFLAGS) -MT watch_test_thread-malloc.obj -MD -MP -MF $(DEPDIR)/watch_test_thread-malloc.Tpo -c -o watch_test_thread-malloc.obj `if test -f 'malloc.c'; then $(CYGPATH_W) 'malloc.c'; else $(CYGPATH_W) '$(srcdir)/malloc.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/watch_test_thread-malloc.Tpo $(DEPDIR)/watch_test_thread-malloc.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='malloc.c' object='watch_test_thread-malloc.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_thread_CFLAGS) $(CFLAGS) -c -o watch_test_thread-malloc.obj `if test -f 'malloc.c'; then $(CYGPATH_W) 'malloc.c'; else $(CYGPATH_W) '$(srcdir)/malloc.c'; fi` + +watch_test_thread-watch-test.o: watch-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_thread_CFLAGS) $(CFLAGS) -MT watch_test_thread-watch-test.o -MD -MP -MF $(DEPDIR)/watch_test_thread-watch-test.Tpo -c -o watch_test_thread-watch-test.o `test -f 'watch-test.c' || echo '$(srcdir)/'`watch-test.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/watch_test_thread-watch-test.Tpo $(DEPDIR)/watch_test_thread-watch-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='watch-test.c' object='watch_test_thread-watch-test.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_thread_CFLAGS) $(CFLAGS) -c -o watch_test_thread-watch-test.o `test -f 'watch-test.c' || echo '$(srcdir)/'`watch-test.c + +watch_test_thread-watch-test.obj: watch-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_thread_CFLAGS) $(CFLAGS) -MT watch_test_thread-watch-test.obj -MD -MP -MF $(DEPDIR)/watch_test_thread-watch-test.Tpo -c -o watch_test_thread-watch-test.obj `if test -f 'watch-test.c'; then $(CYGPATH_W) 'watch-test.c'; else $(CYGPATH_W) '$(srcdir)/watch-test.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/watch_test_thread-watch-test.Tpo $(DEPDIR)/watch_test_thread-watch-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='watch-test.c' object='watch_test_thread-watch-test.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_thread_CFLAGS) $(CFLAGS) -c -o watch_test_thread-watch-test.obj `if test -f 'watch-test.c'; then $(CYGPATH_W) 'watch-test.c'; else $(CYGPATH_W) '$(srcdir)/watch-test.c'; fi` + +watch_test_thread-thread-watch.o: thread-watch.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_thread_CFLAGS) $(CFLAGS) -MT watch_test_thread-thread-watch.o -MD -MP -MF $(DEPDIR)/watch_test_thread-thread-watch.Tpo -c -o watch_test_thread-thread-watch.o `test -f 'thread-watch.c' || echo '$(srcdir)/'`thread-watch.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/watch_test_thread-thread-watch.Tpo $(DEPDIR)/watch_test_thread-thread-watch.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='thread-watch.c' object='watch_test_thread-thread-watch.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_thread_CFLAGS) $(CFLAGS) -c -o watch_test_thread-thread-watch.o `test -f 'thread-watch.c' || echo '$(srcdir)/'`thread-watch.c + +watch_test_thread-thread-watch.obj: thread-watch.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_thread_CFLAGS) $(CFLAGS) -MT watch_test_thread-thread-watch.obj -MD -MP -MF $(DEPDIR)/watch_test_thread-thread-watch.Tpo -c -o watch_test_thread-thread-watch.obj `if test -f 'thread-watch.c'; then $(CYGPATH_W) 'thread-watch.c'; else $(CYGPATH_W) '$(srcdir)/thread-watch.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/watch_test_thread-thread-watch.Tpo $(DEPDIR)/watch_test_thread-thread-watch.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='thread-watch.c' object='watch_test_thread-thread-watch.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(watch_test_thread_CFLAGS) $(CFLAGS) -c -o watch_test_thread-thread-watch.obj `if test -f 'thread-watch.c'; then $(CYGPATH_W) 'thread-watch.c'; else $(CYGPATH_W) '$(srcdir)/thread-watch.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-avahi_commonincludeHEADERS: $(avahi_commoninclude_HEADERS) + @$(NORMAL_INSTALL) + @list='$(avahi_commoninclude_HEADERS)'; test -n "$(avahi_commonincludedir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(avahi_commonincludedir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(avahi_commonincludedir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(avahi_commonincludedir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(avahi_commonincludedir)" || exit $$?; \ + done + +uninstall-avahi_commonincludeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(avahi_commoninclude_HEADERS)'; test -n "$(avahi_commonincludedir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(avahi_commonincludedir)'; $(am__uninstall_files_from_dir) + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(avahi_commonincludedir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ + clean-noinstPROGRAMS mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-avahi_commonincludeHEADERS + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-libLTLIBRARIES + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-avahi_commonincludeHEADERS \ + uninstall-libLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ + clean-libLTLIBRARIES clean-libtool clean-noinstPROGRAMS \ + cscopelist-am ctags ctags-am distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-avahi_commonincludeHEADERS install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-libLTLIBRARIES install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am \ + uninstall-avahi_commonincludeHEADERS uninstall-libLTLIBRARIES + +.PRECIOUS: Makefile + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libgamestream/avahi-common/address.c b/libgamestream/avahi-common/address.c new file mode 100644 index 00000000..e8f61489 --- /dev/null +++ b/libgamestream/avahi-common/address.c @@ -0,0 +1,155 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include + +#include "address.h" +#include "malloc.h" + +static size_t address_get_size(const AvahiAddress *a) { + assert(a); + + if (a->proto == AVAHI_PROTO_INET) + return 4; + else if (a->proto == AVAHI_PROTO_INET6) + return 16; + + return 0; +} + +int avahi_address_cmp(const AvahiAddress *a, const AvahiAddress *b) { + assert(a); + assert(b); + + if (a->proto != b->proto) + return -1; + + return memcmp(a->data.data, b->data.data, address_get_size(a)); +} + +char *avahi_address_snprint(char *s, size_t length, const AvahiAddress *a) { + assert(s); + assert(length); + assert(a); + + if (!(inet_ntop(avahi_proto_to_af(a->proto), a->data.data, s, length))) + return NULL; + + return s; +} + +char* avahi_reverse_lookup_name(const AvahiAddress *a, char *ret_s, size_t length) { + assert(ret_s); + assert(length > 0); + assert(a); + + if (a->proto == AVAHI_PROTO_INET) { + uint32_t n = ntohl(a->data.ipv4.address); + snprintf( + ret_s, length, + "%u.%u.%u.%u.in-addr.arpa", + n & 0xFF, (n >> 8) & 0xFF, (n >> 16) & 0xFF, n >> 24); + } else { + assert(a->proto == AVAHI_PROTO_INET6); + + snprintf( + ret_s, length, + "%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.ip6.arpa", + a->data.ipv6.address[15] & 0xF, a->data.ipv6.address[15] >> 4, + a->data.ipv6.address[14] & 0xF, a->data.ipv6.address[14] >> 4, + a->data.ipv6.address[13] & 0xF, a->data.ipv6.address[13] >> 4, + a->data.ipv6.address[12] & 0xF, a->data.ipv6.address[12] >> 4, + a->data.ipv6.address[11] & 0xF, a->data.ipv6.address[11] >> 4, + a->data.ipv6.address[10] & 0xF, a->data.ipv6.address[10] >> 4, + a->data.ipv6.address[ 9] & 0xF, a->data.ipv6.address[ 9] >> 4, + a->data.ipv6.address[ 8] & 0xF, a->data.ipv6.address[ 8] >> 4, + a->data.ipv6.address[ 7] & 0xF, a->data.ipv6.address[ 7] >> 4, + a->data.ipv6.address[ 6] & 0xF, a->data.ipv6.address[ 6] >> 4, + a->data.ipv6.address[ 5] & 0xF, a->data.ipv6.address[ 5] >> 4, + a->data.ipv6.address[ 4] & 0xF, a->data.ipv6.address[ 4] >> 4, + a->data.ipv6.address[ 3] & 0xF, a->data.ipv6.address[ 3] >> 4, + a->data.ipv6.address[ 2] & 0xF, a->data.ipv6.address[ 2] >> 4, + a->data.ipv6.address[ 1] & 0xF, a->data.ipv6.address[ 1] >> 4, + a->data.ipv6.address[ 0] & 0xF, a->data.ipv6.address[ 0] >> 4); + } + + return ret_s; +} + +AvahiAddress *avahi_address_parse(const char *s, AvahiProtocol proto, AvahiAddress *ret_addr) { + assert(ret_addr); + assert(s); + + if (proto == AVAHI_PROTO_UNSPEC) { + if (inet_pton(AF_INET, s, ret_addr->data.data) <= 0) { + if (inet_pton(AF_INET6, s, ret_addr->data.data) <= 0) + return NULL; + else + ret_addr->proto = AVAHI_PROTO_INET6; + } else + ret_addr->proto = AVAHI_PROTO_INET; + } else { + if (inet_pton(avahi_proto_to_af(proto), s, ret_addr->data.data) <= 0) + return NULL; + + ret_addr->proto = proto; + } + + return ret_addr; +} + +int avahi_proto_to_af(AvahiProtocol proto) { + if (proto == AVAHI_PROTO_INET) + return AF_INET; + if (proto == AVAHI_PROTO_INET6) + return AF_INET6; + + assert(proto == AVAHI_PROTO_UNSPEC); + return AF_UNSPEC; +} + +AvahiProtocol avahi_af_to_proto(int af) { + if (af == AF_INET) + return AVAHI_PROTO_INET; + if (af == AF_INET6) + return AVAHI_PROTO_INET6; + + assert(af == AF_UNSPEC); + return AVAHI_PROTO_UNSPEC; +} + +const char* avahi_proto_to_string(AvahiProtocol proto) { + if (proto == AVAHI_PROTO_INET) + return "IPv4"; + if (proto == AVAHI_PROTO_INET6) + return "IPv6"; + + assert(proto == AVAHI_PROTO_UNSPEC); + return "UNSPEC"; +} diff --git a/libgamestream/avahi-common/address.h b/libgamestream/avahi-common/address.h new file mode 100644 index 00000000..a14104fa --- /dev/null +++ b/libgamestream/avahi-common/address.h @@ -0,0 +1,119 @@ +#ifndef fooaddresshfoo +#define fooaddresshfoo + +/*** + 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.1 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 Lesser 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. +***/ + +/** \file address.h Definitions and functions to manipulate IP addresses. */ + +#include +#include + +#include + +AVAHI_C_DECL_BEGIN + +/** Protocol family specification, takes the values AVAHI_PROTO_INET, AVAHI_PROTO_INET6, AVAHI_PROTO_UNSPEC */ +typedef int AvahiProtocol; + +/** Numeric network interface index. Takes OS dependent values and the special constant AVAHI_IF_UNSPEC */ +typedef int AvahiIfIndex; + +/** Values for AvahiProtocol */ +enum { + AVAHI_PROTO_INET = 0, /**< IPv4 */ + AVAHI_PROTO_INET6 = 1, /**< IPv6 */ + AVAHI_PROTO_UNSPEC = -1 /**< Unspecified/all protocol(s) */ +}; + +/** Special values for AvahiIfIndex */ +enum { + AVAHI_IF_UNSPEC = -1 /**< Unspecified/all interface(s) */ +}; + +/** Maximum size of an address in string form */ +#define AVAHI_ADDRESS_STR_MAX 40 /* IPv6 Max = 4*8 + 7 + 1 for NUL */ + +/** Return TRUE if the specified interface index is valid */ +#define AVAHI_IF_VALID(ifindex) (((ifindex) >= 0) || ((ifindex) == AVAHI_IF_UNSPEC)) + +/** Return TRUE if the specified protocol is valid */ +#define AVAHI_PROTO_VALID(protocol) (((protocol) == AVAHI_PROTO_INET) || ((protocol) == AVAHI_PROTO_INET6) || ((protocol) == AVAHI_PROTO_UNSPEC)) + +/** An IPv4 address */ +typedef struct AvahiIPv4Address { + uint32_t address; /**< Address data in network byte order. */ +} AvahiIPv4Address; + +/** An IPv6 address */ +typedef struct AvahiIPv6Address { + uint8_t address[16]; /**< Address data */ +} AvahiIPv6Address; + +/** Protocol (address family) independent address structure */ +typedef struct AvahiAddress { + AvahiProtocol proto; /**< Address family */ + + union { + AvahiIPv6Address ipv6; /**< Address when IPv6 */ + AvahiIPv4Address ipv4; /**< Address when IPv4 */ + uint8_t data[1]; /**< Type-independent data field */ + } data; +} AvahiAddress; + +/** @{ \name Comparison */ + +/** Compare two addresses. Returns 0 when equal, a negative value when a < b, a positive value when a > b. */ +int avahi_address_cmp(const AvahiAddress *a, const AvahiAddress *b); + +/** @} */ + +/** @{ \name String conversion */ + +/** Convert the specified address *a to a human readable character string, use AVAHI_ADDRESS_STR_MAX to allocate an array of the right size */ +char *avahi_address_snprint(char *ret_s, size_t length, const AvahiAddress *a); + +/** Convert the specified human readable character string to an + * address structure. Set af to AVAHI_UNSPEC for automatic address + * family detection. */ +AvahiAddress *avahi_address_parse(const char *s, AvahiProtocol af, AvahiAddress *ret_addr); + +/** @} */ + +/** \cond fulldocs */ +/** Generate the DNS reverse lookup name for an IPv4 or IPv6 address. */ +char* avahi_reverse_lookup_name(const AvahiAddress *a, char *ret_s, size_t length); +/** \endcond */ + +/** @{ \name Protocol/address family handling */ + +/** Map AVAHI_PROTO_xxx constants to Unix AF_xxx constants */ +int avahi_proto_to_af(AvahiProtocol proto); + +/** Map Unix AF_xxx constants to AVAHI_PROTO_xxx constants */ +AvahiProtocol avahi_af_to_proto(int af); + +/** Return a textual representation of the specified protocol number. i.e. "IPv4", "IPv6" or "UNSPEC" */ +const char* avahi_proto_to_string(AvahiProtocol proto); + +/** @} */ + +AVAHI_C_DECL_END + +#endif diff --git a/libgamestream/avahi-common/alternative-test.c b/libgamestream/avahi-common/alternative-test.c new file mode 100644 index 00000000..9255435e --- /dev/null +++ b/libgamestream/avahi-common/alternative-test.c @@ -0,0 +1,90 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "alternative.h" +#include "malloc.h" +#include "domain.h" + +int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { + const char* const test_strings[] = { + "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXüüüüüüü", + "gurke", + "-", + " #", + "1", + "#0", + " #0", + " #1", + "#-1", + " #-1", + "-0", + "--0", + "-1", + "--1", + "-2", + "gurke1", + "gurke0", + "gurke-2", + "gurke #0", + "gurke #1", + "gurke #", + "gurke#1", + "gurke-", + "gurke---", + "gurke #", + "gurke ###", + NULL + }; + + char *r = NULL; + int i, j, k; + + for (k = 0; test_strings[k]; k++) { + + printf(">>>>>%s<<<<\n", test_strings[k]); + + for (j = 0; j < 2; j++) { + + for (i = 0; i <= 100; i++) { + char *n; + + n = i == 0 ? avahi_strdup(test_strings[k]) : (j ? avahi_alternative_service_name(r) : avahi_alternative_host_name(r)); + avahi_free(r); + r = n; + + if (j) + assert(avahi_is_valid_service_name(n)); + else + assert(avahi_is_valid_host_name(n)); + + printf("%s\n", r); + } + } + } + + avahi_free(r); + return 0; +} diff --git a/libgamestream/avahi-common/alternative.c b/libgamestream/avahi-common/alternative.c new file mode 100644 index 00000000..b3d39f0e --- /dev/null +++ b/libgamestream/avahi-common/alternative.c @@ -0,0 +1,182 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include + +#include "alternative.h" +#include "malloc.h" +#include "domain.h" +#include "utf8.h" + +static void drop_incomplete_utf8(char *c) { + char *e; + + e = strchr(c, 0) - 1; + + while (e >= c) { + + if (avahi_utf8_valid(c)) + break; + + assert(*e & 128); + *e = 0; + + e--; + } +} + +char *avahi_alternative_host_name(const char *s) { + const char *e; + char *r; + + assert(s); + + if (!avahi_is_valid_host_name(s)) + return NULL; + + if ((e = strrchr(s, '-'))) { + const char *p; + + e++; + + for (p = e; *p; p++) + if (!isdigit(*p)) { + e = NULL; + break; + } + + if (e && (*e == '0' || *e == 0)) + e = NULL; + } + + if (e) { + char *c, *m; + size_t l; + int n; + + n = atoi(e)+1; + if (!(m = avahi_strdup_printf("%i", n))) + return NULL; + + l = e-s-1; + + if (l >= AVAHI_LABEL_MAX-1-strlen(m)-1) + l = AVAHI_LABEL_MAX-1-strlen(m)-1; + + if (!(c = avahi_strndup(s, l))) { + avahi_free(m); + return NULL; + } + + drop_incomplete_utf8(c); + + r = avahi_strdup_printf("%s-%s", c, m); + avahi_free(c); + avahi_free(m); + + } else { + char *c; + + if (!(c = avahi_strndup(s, AVAHI_LABEL_MAX-1-2))) + return NULL; + + drop_incomplete_utf8(c); + + r = avahi_strdup_printf("%s-2", c); + avahi_free(c); + } + + assert(avahi_is_valid_host_name(r)); + + return r; +} + +char *avahi_alternative_service_name(const char *s) { + const char *e; + char *r; + + assert(s); + + if (!avahi_is_valid_service_name(s)) + return NULL; + + if ((e = strstr(s, " #"))) { + const char *n, *p; + e += 2; + + while ((n = strstr(e, " #"))) + e = n + 2; + + for (p = e; *p; p++) + if (!isdigit(*p)) { + e = NULL; + break; + } + + if (e && (*e == '0' || *e == 0)) + e = NULL; + } + + if (e) { + char *c, *m; + size_t l; + int n; + + n = atoi(e)+1; + if (!(m = avahi_strdup_printf("%i", n))) + return NULL; + + l = e-s-2; + + if (l >= AVAHI_LABEL_MAX-1-strlen(m)-2) + l = AVAHI_LABEL_MAX-1-strlen(m)-2; + + if (!(c = avahi_strndup(s, l))) { + avahi_free(m); + return NULL; + } + + drop_incomplete_utf8(c); + + r = avahi_strdup_printf("%s #%s", c, m); + avahi_free(c); + avahi_free(m); + } else { + char *c; + + if (!(c = avahi_strndup(s, AVAHI_LABEL_MAX-1-3))) + return NULL; + + drop_incomplete_utf8(c); + + r = avahi_strdup_printf("%s #2", c); + avahi_free(c); + } + + assert(avahi_is_valid_service_name(r)); + + return r; +} diff --git a/libgamestream/avahi-common/alternative.h b/libgamestream/avahi-common/alternative.h new file mode 100644 index 00000000..9b044de5 --- /dev/null +++ b/libgamestream/avahi-common/alternative.h @@ -0,0 +1,43 @@ +#ifndef fooalternativehfoo +#define fooalternativehfoo + +/*** + 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.1 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 Lesser 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. +***/ + +/** \file alternative.h Functions to find alternative names for hosts and services in the case of name collision */ + +#include + +AVAHI_C_DECL_BEGIN + +/** Find an alternative for the specified host name. If called with an + * original host name, "-2" is appended, afterwards the number is + * increased on each call. (i.e. "foo" becomes "foo-2" becomes "foo-3" + * and so on.) avahi_free() the result. */ +char *avahi_alternative_host_name(const char *s); + +/** Find an alternative for the specified service name. If called with + * an original service name, " #2" is appended. Afterwards the number + * is increased on each call (i.e. "foo" becomes "foo #2" becomes "foo + * #3" and so on.) avahi_free() the result. */ +char *avahi_alternative_service_name(const char *s); + +AVAHI_C_DECL_END + +#endif diff --git a/libgamestream/avahi-common/cdecl.h b/libgamestream/avahi-common/cdecl.h new file mode 100644 index 00000000..aef6aba0 --- /dev/null +++ b/libgamestream/avahi-common/cdecl.h @@ -0,0 +1,38 @@ +#ifndef foocdeclhfoo +#define foocdeclhfoo + +/*** + 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.1 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 Lesser 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. +***/ + +/** \file cdecl.h C++ compatibility */ +#ifdef __cplusplus +/** If using C++ this macro enables C mode, otherwise does nothing */ +#define AVAHI_C_DECL_BEGIN extern "C" { +/** If using C++ this macro switches back to C++ mode, otherwise does nothing */ +#define AVAHI_C_DECL_END } + +#else +/** If using C++ this macro enables C mode, otherwise does nothing */ +#define AVAHI_C_DECL_BEGIN +/** If using C++ this macro switches back to C++ mode, otherwise does nothing */ +#define AVAHI_C_DECL_END + +#endif + +#endif diff --git a/libgamestream/avahi-common/dbus-watch-glue.c b/libgamestream/avahi-common/dbus-watch-glue.c new file mode 100644 index 00000000..2749f53d --- /dev/null +++ b/libgamestream/avahi-common/dbus-watch-glue.c @@ -0,0 +1,357 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include "malloc.h" +#include "timeval.h" +#include "dbus-watch-glue.h" + +static AvahiWatchEvent translate_dbus_to_avahi(unsigned int f) { + AvahiWatchEvent e = 0; + + if (f & DBUS_WATCH_READABLE) + e |= AVAHI_WATCH_IN; + if (f & DBUS_WATCH_WRITABLE) + e |= AVAHI_WATCH_OUT; + if (f & DBUS_WATCH_ERROR) + e |= AVAHI_WATCH_ERR; + if (f & DBUS_WATCH_HANGUP) + e |= AVAHI_WATCH_HUP; + + return e; +} + +static unsigned int translate_avahi_to_dbus(AvahiWatchEvent e) { + unsigned int f = 0; + + if (e & AVAHI_WATCH_IN) + f |= DBUS_WATCH_READABLE; + if (e & AVAHI_WATCH_OUT) + f |= DBUS_WATCH_WRITABLE; + if (e & AVAHI_WATCH_ERR) + f |= DBUS_WATCH_ERROR; + if (e & AVAHI_WATCH_HUP) + f |= DBUS_WATCH_HANGUP; + + return f; +} + +typedef struct { + DBusConnection *connection; + const AvahiPoll *poll_api; + AvahiTimeout *dispatch_timeout; + int ref; +} ConnectionData; + +static ConnectionData *connection_data_ref(ConnectionData *d) { + assert(d); + assert(d->ref >= 1); + + d->ref++; + return d; +} + +static void connection_data_unref(ConnectionData *d) { + assert(d); + assert(d->ref >= 1); + + if (--d->ref <= 0) { + d->poll_api->timeout_free(d->dispatch_timeout); + avahi_free(d); + } +} + +static void request_dispatch(ConnectionData *d, int enable) { + static const struct timeval tv = { 0, 0 }; + assert(d); + + if (enable) { + assert(dbus_connection_get_dispatch_status(d->connection) == DBUS_DISPATCH_DATA_REMAINS); + d->poll_api->timeout_update(d->dispatch_timeout, &tv); + } else + d->poll_api->timeout_update(d->dispatch_timeout, NULL); +} + +static void dispatch_timeout_callback(AvahiTimeout *t, void *userdata) { + ConnectionData *d = userdata; + assert(t); + assert(d); + + connection_data_ref(d); + dbus_connection_ref(d->connection); + + if (dbus_connection_dispatch(d->connection) == DBUS_DISPATCH_DATA_REMAINS) + /* If there's still data, request that this handler is called again */ + request_dispatch(d, 1); + else + request_dispatch(d, 0); + + dbus_connection_unref(d->connection); + connection_data_unref(d); +} + +static void watch_callback(AvahiWatch *avahi_watch, AVAHI_GCC_UNUSED int fd, AvahiWatchEvent events, void *userdata) { + DBusWatch *dbus_watch = userdata; + + assert(avahi_watch); + assert(dbus_watch); + + dbus_watch_handle(dbus_watch, translate_avahi_to_dbus(events)); + /* Ignore the return value */ +} + +static dbus_bool_t update_watch(const AvahiPoll *poll_api, DBusWatch *dbus_watch) { + AvahiWatch *avahi_watch; + dbus_bool_t b; + + assert(dbus_watch); + + avahi_watch = dbus_watch_get_data(dbus_watch); + + b = dbus_watch_get_enabled(dbus_watch); + + if (b && !avahi_watch) { + + if (!(avahi_watch = poll_api->watch_new( + poll_api, +#if (DBUS_VERSION_MAJOR == 1 && DBUS_VERSION_MINOR == 1 && DBUS_VERSION_MICRO >= 1) || (DBUS_VERSION_MAJOR == 1 && DBUS_VERSION_MINOR > 1) || (DBUS_VERSION_MAJOR > 1) + dbus_watch_get_unix_fd(dbus_watch), +#else + dbus_watch_get_fd(dbus_watch), +#endif + translate_dbus_to_avahi(dbus_watch_get_flags(dbus_watch)), + watch_callback, + dbus_watch))) + return FALSE; + + dbus_watch_set_data(dbus_watch, avahi_watch, NULL); + + } else if (!b && avahi_watch) { + + poll_api->watch_free(avahi_watch); + dbus_watch_set_data(dbus_watch, NULL, NULL); + + } else if (avahi_watch) { + + /* Update flags */ + poll_api->watch_update(avahi_watch, dbus_watch_get_flags(dbus_watch)); + } + + return TRUE; +} + +static dbus_bool_t add_watch(DBusWatch *dbus_watch, void *userdata) { + ConnectionData *d = userdata; + + assert(dbus_watch); + assert(d); + + return update_watch(d->poll_api, dbus_watch); +} + +static void remove_watch(DBusWatch *dbus_watch, void *userdata) { + ConnectionData *d = userdata; + AvahiWatch *avahi_watch; + + assert(dbus_watch); + assert(d); + + if ((avahi_watch = dbus_watch_get_data(dbus_watch))) { + d->poll_api->watch_free(avahi_watch); + dbus_watch_set_data(dbus_watch, NULL, NULL); + } +} + +static void watch_toggled(DBusWatch *dbus_watch, void *userdata) { + ConnectionData *d = userdata; + + assert(dbus_watch); + assert(d); + + update_watch(d->poll_api, dbus_watch); +} + +typedef struct TimeoutData { + const AvahiPoll *poll_api; + AvahiTimeout *avahi_timeout; + DBusTimeout *dbus_timeout; + int ref; +} TimeoutData; + +static TimeoutData* timeout_data_ref(TimeoutData *t) { + assert(t); + assert(t->ref >= 1); + + t->ref++; + return t; +} + +static void timeout_data_unref(TimeoutData *t) { + assert(t); + assert(t->ref >= 1); + + if (--t->ref <= 0) { + if (t->avahi_timeout) + t->poll_api->timeout_free(t->avahi_timeout); + + avahi_free(t); + } +} + +static void update_timeout(TimeoutData *timeout) { + assert(timeout); + assert(timeout->ref >= 1); + + if (dbus_timeout_get_enabled(timeout->dbus_timeout)) { + struct timeval tv; + avahi_elapse_time(&tv, dbus_timeout_get_interval(timeout->dbus_timeout), 0); + timeout->poll_api->timeout_update(timeout-> + avahi_timeout, &tv); + } else + timeout->poll_api->timeout_update(timeout->avahi_timeout, NULL); + +} + +static void timeout_callback(AvahiTimeout *avahi_timeout, void *userdata) { + TimeoutData *timeout = userdata; + + assert(avahi_timeout); + assert(timeout); + + timeout_data_ref(timeout); + + dbus_timeout_handle(timeout->dbus_timeout); + /* Ignore the return value */ + + if (timeout->avahi_timeout) + update_timeout(timeout); + + timeout_data_unref(timeout); +} + +static dbus_bool_t add_timeout(DBusTimeout *dbus_timeout, void *userdata) { + TimeoutData *timeout; + ConnectionData *d = userdata; + struct timeval tv; + dbus_bool_t b; + + assert(dbus_timeout); + assert(d); + + if (!(timeout = avahi_new(TimeoutData, 1))) + return FALSE; + + timeout->dbus_timeout = dbus_timeout; + timeout->poll_api = d->poll_api; + timeout->ref = 1; + + if ((b = dbus_timeout_get_enabled(dbus_timeout))) + avahi_elapse_time(&tv, dbus_timeout_get_interval(dbus_timeout), 0); + + if (!(timeout->avahi_timeout = d->poll_api->timeout_new( + d->poll_api, + b ? &tv : NULL, + timeout_callback, + timeout))) { + avahi_free(timeout); + return FALSE; + } + + dbus_timeout_set_data(dbus_timeout, timeout, (DBusFreeFunction) timeout_data_unref); + return TRUE; +} + +static void remove_timeout(DBusTimeout *dbus_timeout, void *userdata) { + ConnectionData *d = userdata; + TimeoutData *timeout; + + assert(dbus_timeout); + assert(d); + + timeout = dbus_timeout_get_data(dbus_timeout); + assert(timeout); + + d->poll_api->timeout_free(timeout->avahi_timeout); + timeout->avahi_timeout = NULL; +} + +static void timeout_toggled(DBusTimeout *dbus_timeout, AVAHI_GCC_UNUSED void *userdata) { + TimeoutData *timeout; + + assert(dbus_timeout); + timeout = dbus_timeout_get_data(dbus_timeout); + assert(timeout); + + update_timeout(timeout); +} + +static void dispatch_status(AVAHI_GCC_UNUSED DBusConnection *connection, DBusDispatchStatus new_status, void *userdata) { + ConnectionData *d = userdata; + + if (new_status == DBUS_DISPATCH_DATA_REMAINS) + request_dispatch(d, 1); + } + +int avahi_dbus_connection_glue(DBusConnection *c, const AvahiPoll *poll_api) { + ConnectionData *d = NULL; + + assert(c); + assert(poll_api); + + if (!(d = avahi_new(ConnectionData, 1))) + goto fail; + + d->poll_api = poll_api; + d->connection = c; + d->ref = 1; + + if (!(d->dispatch_timeout = poll_api->timeout_new(poll_api, NULL, dispatch_timeout_callback, d))) + goto fail; + + if (!(dbus_connection_set_watch_functions(c, add_watch, remove_watch, watch_toggled, connection_data_ref(d), (DBusFreeFunction)connection_data_unref))) + goto fail; + + if (!(dbus_connection_set_timeout_functions(c, add_timeout, remove_timeout, timeout_toggled, connection_data_ref(d), (DBusFreeFunction)connection_data_unref))) + goto fail; + + dbus_connection_set_dispatch_status_function(c, dispatch_status, connection_data_ref(d), (DBusFreeFunction)connection_data_unref); + + if (dbus_connection_get_dispatch_status(c) == DBUS_DISPATCH_DATA_REMAINS) + request_dispatch(d, 1); + + connection_data_unref(d); + + return 0; + +fail: + + if (d) { + d->poll_api->timeout_free(d->dispatch_timeout); + + avahi_free(d); + } + + return -1; +} diff --git a/libgamestream/avahi-common/dbus-watch-glue.h b/libgamestream/avahi-common/dbus-watch-glue.h new file mode 100644 index 00000000..138ea97a --- /dev/null +++ b/libgamestream/avahi-common/dbus-watch-glue.h @@ -0,0 +1,33 @@ +#ifndef foodbuswatchgluehfoo +#define foodbuswatchgluehfoo + +/*** + 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.1 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 Lesser 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. +***/ + +#include + +#include + +AVAHI_C_DECL_BEGIN + +int avahi_dbus_connection_glue(DBusConnection *c, const AvahiPoll *poll_api); + +AVAHI_C_DECL_END + +#endif diff --git a/libgamestream/avahi-common/dbus.c b/libgamestream/avahi-common/dbus.c new file mode 100644 index 00000000..f19c77c5 --- /dev/null +++ b/libgamestream/avahi-common/dbus.c @@ -0,0 +1,138 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include + +#include +#include + +static const char * const table[- AVAHI_ERR_MAX] = { + AVAHI_DBUS_ERR_OK, + AVAHI_DBUS_ERR_FAILURE, + AVAHI_DBUS_ERR_BAD_STATE, + AVAHI_DBUS_ERR_INVALID_HOST_NAME, + AVAHI_DBUS_ERR_INVALID_DOMAIN_NAME, + AVAHI_DBUS_ERR_NO_NETWORK, + AVAHI_DBUS_ERR_INVALID_TTL, + AVAHI_DBUS_ERR_IS_PATTERN, + AVAHI_DBUS_ERR_COLLISION, + AVAHI_DBUS_ERR_INVALID_RECORD, + + AVAHI_DBUS_ERR_INVALID_SERVICE_NAME, + AVAHI_DBUS_ERR_INVALID_SERVICE_TYPE, + AVAHI_DBUS_ERR_INVALID_PORT, + AVAHI_DBUS_ERR_INVALID_KEY, + AVAHI_DBUS_ERR_INVALID_ADDRESS, + AVAHI_DBUS_ERR_TIMEOUT, + AVAHI_DBUS_ERR_TOO_MANY_CLIENTS, + AVAHI_DBUS_ERR_TOO_MANY_OBJECTS, + AVAHI_DBUS_ERR_TOO_MANY_ENTRIES, + AVAHI_DBUS_ERR_OS, + + AVAHI_DBUS_ERR_ACCESS_DENIED, + AVAHI_DBUS_ERR_INVALID_OPERATION, + AVAHI_DBUS_ERR_DBUS_ERROR, + AVAHI_DBUS_ERR_DISCONNECTED, + AVAHI_DBUS_ERR_NO_MEMORY, + AVAHI_DBUS_ERR_INVALID_OBJECT, + AVAHI_DBUS_ERR_NO_DAEMON, + AVAHI_DBUS_ERR_INVALID_INTERFACE, + AVAHI_DBUS_ERR_INVALID_PROTOCOL, + AVAHI_DBUS_ERR_INVALID_FLAGS, + + AVAHI_DBUS_ERR_NOT_FOUND, + AVAHI_DBUS_ERR_INVALID_CONFIG, + AVAHI_DBUS_ERR_VERSION_MISMATCH, + AVAHI_DBUS_ERR_INVALID_SERVICE_SUBTYPE, + AVAHI_DBUS_ERR_INVALID_PACKET, + AVAHI_DBUS_ERR_INVALID_DNS_ERROR, + AVAHI_DBUS_ERR_DNS_FORMERR, + AVAHI_DBUS_ERR_DNS_SERVFAIL, + AVAHI_DBUS_ERR_DNS_NXDOMAIN, + AVAHI_DBUS_ERR_DNS_NOTIMP, + + AVAHI_DBUS_ERR_DNS_REFUSED, + AVAHI_DBUS_ERR_DNS_YXDOMAIN, + AVAHI_DBUS_ERR_DNS_YXRRSET, + AVAHI_DBUS_ERR_DNS_NXRRSET, + AVAHI_DBUS_ERR_DNS_NOTAUTH, + AVAHI_DBUS_ERR_DNS_NOTZONE, + AVAHI_DBUS_ERR_INVALID_RDATA, + AVAHI_DBUS_ERR_INVALID_DNS_CLASS, + AVAHI_DBUS_ERR_INVALID_DNS_TYPE, + AVAHI_DBUS_ERR_NOT_SUPPORTED, + + AVAHI_DBUS_ERR_NOT_PERMITTED, + AVAHI_DBUS_ERR_INVALID_ARGUMENT, + AVAHI_DBUS_ERR_IS_EMPTY, + AVAHI_DBUS_ERR_NO_CHANGE +}; + +struct error_map { + const char *dbus_error; + int avahi_error; +}; + +static struct error_map error_map[] = { + { DBUS_ERROR_FAILED, AVAHI_ERR_FAILURE }, + { DBUS_ERROR_NO_MEMORY, AVAHI_ERR_NO_MEMORY }, + { DBUS_ERROR_SERVICE_UNKNOWN, AVAHI_ERR_NO_DAEMON }, + { DBUS_ERROR_BAD_ADDRESS, AVAHI_ERR_NO_DAEMON }, + { DBUS_ERROR_NOT_SUPPORTED, AVAHI_ERR_NOT_SUPPORTED }, + { DBUS_ERROR_LIMITS_EXCEEDED, AVAHI_ERR_TOO_MANY_OBJECTS }, + { DBUS_ERROR_ACCESS_DENIED, AVAHI_ERR_ACCESS_DENIED }, + { DBUS_ERROR_AUTH_FAILED, AVAHI_ERR_ACCESS_DENIED }, + { DBUS_ERROR_NO_SERVER, AVAHI_ERR_NO_DAEMON }, + { DBUS_ERROR_TIMEOUT, AVAHI_ERR_TIMEOUT }, + { DBUS_ERROR_NO_NETWORK, AVAHI_ERR_NO_NETWORK }, + { DBUS_ERROR_DISCONNECTED, AVAHI_ERR_DISCONNECTED }, + { DBUS_ERROR_INVALID_ARGS, AVAHI_ERR_INVALID_ARGUMENT }, + { DBUS_ERROR_TIMED_OUT, AVAHI_ERR_TIMEOUT }, + { NULL, 0 } +}; + +int avahi_error_dbus_to_number(const char *s) { + int e; + const struct error_map *m; + + assert(s); + + for (e = -1; e > AVAHI_ERR_MAX; e--) + if (strcmp(s, table[-e]) == 0) + return e; + + for (m = error_map; m->dbus_error; m++) + if (strcmp(m->dbus_error, s) == 0) + return m->avahi_error; + + return AVAHI_ERR_DBUS_ERROR; +} + +const char *avahi_error_number_to_dbus(int error) { + assert(error > AVAHI_ERR_MAX); + assert(error < 1); + + return table[-error]; +} diff --git a/libgamestream/avahi-common/dbus.h b/libgamestream/avahi-common/dbus.h new file mode 100644 index 00000000..63319b03 --- /dev/null +++ b/libgamestream/avahi-common/dbus.h @@ -0,0 +1,121 @@ +#ifndef foodbushfoo +#define foodbushfoo + +/*** + 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.1 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 Lesser 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. +***/ + +/** \file dbus.h Some definitions for the D-Bus interface */ + +#include +#include + +AVAHI_C_DECL_BEGIN + +#define AVAHI_DBUS_NAME "org.freedesktop.Avahi" +#define AVAHI_DBUS_INTERFACE_SERVER AVAHI_DBUS_NAME".Server" +#define AVAHI_DBUS_INTERFACE_SERVER2 AVAHI_DBUS_NAME".Server2" +#define AVAHI_DBUS_PATH_SERVER "/" +#define AVAHI_DBUS_INTERFACE_ENTRY_GROUP AVAHI_DBUS_NAME".EntryGroup" +#define AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER AVAHI_DBUS_NAME".DomainBrowser" +#define AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER AVAHI_DBUS_NAME".ServiceTypeBrowser" +#define AVAHI_DBUS_INTERFACE_SERVICE_BROWSER AVAHI_DBUS_NAME".ServiceBrowser" +#define AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER AVAHI_DBUS_NAME".AddressResolver" +#define AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER AVAHI_DBUS_NAME".HostNameResolver" +#define AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER AVAHI_DBUS_NAME".ServiceResolver" +#define AVAHI_DBUS_INTERFACE_RECORD_BROWSER AVAHI_DBUS_NAME".RecordBrowser" + +/** The D-Bus API version identifier. The first byte specifies the API +release, the second byte specifies the revision. If the revision +number is increased the API has been extended but is downwards +compatible. If the release changes compatibility is lost. + +Avahi 0.6 implements API version 0x0201; +Avahi 0.6.1 implements API version 0x0202 +Avahi 0.7 implements API version 0x0203 */ +#define AVAHI_DBUS_API_VERSION ((uint32_t) 0x0204) + +#define AVAHI_DBUS_ERR_OK "org.freedesktop.Avahi.Success" +#define AVAHI_DBUS_ERR_FAILURE "org.freedesktop.Avahi.Failure" +#define AVAHI_DBUS_ERR_BAD_STATE "org.freedesktop.Avahi.BadStateError" +#define AVAHI_DBUS_ERR_INVALID_HOST_NAME "org.freedesktop.Avahi.InvalidHostNameError" +#define AVAHI_DBUS_ERR_INVALID_DOMAIN_NAME "org.freedesktop.Avahi.InvalidDomainNameError" +#define AVAHI_DBUS_ERR_NO_NETWORK "org.freedesktop.Avahi.NoNetworkError" +#define AVAHI_DBUS_ERR_INVALID_TTL "org.freedesktop.Avahi.InvalidTTLError" +#define AVAHI_DBUS_ERR_IS_PATTERN "org.freedesktop.Avahi.IsPatternError" +#define AVAHI_DBUS_ERR_COLLISION "org.freedesktop.Avahi.CollisionError" +#define AVAHI_DBUS_ERR_INVALID_RECORD "org.freedesktop.Avahi.InvalidRecordError" + +#define AVAHI_DBUS_ERR_INVALID_SERVICE_NAME "org.freedesktop.Avahi.InvalidServiceNameError" +#define AVAHI_DBUS_ERR_INVALID_SERVICE_TYPE "org.freedesktop.Avahi.InvalidServiceTypeError" +#define AVAHI_DBUS_ERR_INVALID_PORT "org.freedesktop.Avahi.InvalidPortError" +#define AVAHI_DBUS_ERR_INVALID_KEY "org.freedesktop.Avahi.InvalidKeyError" +#define AVAHI_DBUS_ERR_INVALID_ADDRESS "org.freedesktop.Avahi.InvalidAddressError" +#define AVAHI_DBUS_ERR_TIMEOUT "org.freedesktop.Avahi.TimeoutError" +#define AVAHI_DBUS_ERR_TOO_MANY_CLIENTS "org.freedesktop.Avahi.TooManyClientsError" +#define AVAHI_DBUS_ERR_TOO_MANY_OBJECTS "org.freedesktop.Avahi.TooManyObjectsError" +#define AVAHI_DBUS_ERR_TOO_MANY_ENTRIES "org.freedesktop.Avahi.TooManyEntriesError" +#define AVAHI_DBUS_ERR_OS "org.freedesktop.Avahi.OSError" + +#define AVAHI_DBUS_ERR_ACCESS_DENIED DBUS_ERROR_ACCESS_DENIED +#define AVAHI_DBUS_ERR_INVALID_OPERATION "org.freedesktop.Avahi.InvalidOperationError" +#define AVAHI_DBUS_ERR_DBUS_ERROR "org.freedesktop.Avahi.DBusError" +#define AVAHI_DBUS_ERR_DISCONNECTED "org.freedesktop.Avahi.DisconnectedError" +#define AVAHI_DBUS_ERR_NO_MEMORY "org.freedesktop.Avahi.NoMemoryError" +#define AVAHI_DBUS_ERR_INVALID_OBJECT "org.freedesktop.Avahi.InvalidObjectError" +#define AVAHI_DBUS_ERR_NO_DAEMON "org.freedesktop.Avahi.NoDaemonError" +#define AVAHI_DBUS_ERR_INVALID_INTERFACE "org.freedesktop.Avahi.InvalidInterfaceError" +#define AVAHI_DBUS_ERR_INVALID_PROTOCOL "org.freedesktop.Avahi.InvalidInterfaceProtocolError" +#define AVAHI_DBUS_ERR_INVALID_FLAGS "org.freedesktop.Avahi.InvalidFlagsError" + +#define AVAHI_DBUS_ERR_NOT_FOUND "org.freedesktop.Avahi.NotFoundError" +#define AVAHI_DBUS_ERR_INVALID_CONFIG "org.freedesktop.Avahi.InvalidConfigurationError" +#define AVAHI_DBUS_ERR_VERSION_MISMATCH "org.freedesktop.Avahi.VersionMismatchError" +#define AVAHI_DBUS_ERR_INVALID_SERVICE_SUBTYPE "org.freedesktop.Avahi.InvalidServiceSubtypeError" +#define AVAHI_DBUS_ERR_INVALID_PACKET "org.freedesktop.Avahi.InvalidPacketError" +#define AVAHI_DBUS_ERR_INVALID_DNS_ERROR "org.freedesktop.Avahi.InvalidDNSErrorError" +#define AVAHI_DBUS_ERR_DNS_FORMERR "org.freedesktop.Avahi.DNSFORMERR" +#define AVAHI_DBUS_ERR_DNS_SERVFAIL "org.freedesktop.Avahi.DNSSERVFAIL" +#define AVAHI_DBUS_ERR_DNS_NXDOMAIN "org.freedesktop.Avahi.DNSNXDOMAIN" +#define AVAHI_DBUS_ERR_DNS_NOTIMP "org.freedesktop.Avahi.DNSNOTIMP" + +#define AVAHI_DBUS_ERR_DNS_REFUSED "org.freedesktop.Avahi.DNSREFUSED" +#define AVAHI_DBUS_ERR_DNS_YXDOMAIN "org.freedesktop.Avahi.DNSYXDOMAIN" +#define AVAHI_DBUS_ERR_DNS_YXRRSET "org.freedesktop.Avahi.DNSYXRRSET" +#define AVAHI_DBUS_ERR_DNS_NXRRSET "org.freedesktop.Avahi.DNSNXRRSET" +#define AVAHI_DBUS_ERR_DNS_NOTAUTH "org.freedesktop.Avahi.DNSNOTAUTH" +#define AVAHI_DBUS_ERR_DNS_NOTZONE "org.freedesktop.Avahi.DNSNOTZONE" +#define AVAHI_DBUS_ERR_INVALID_RDATA "org.freedesktop.Avahi.InvalidRDataError" +#define AVAHI_DBUS_ERR_INVALID_DNS_CLASS "org.freedesktop.Avahi.InvalidDNSClassError" +#define AVAHI_DBUS_ERR_INVALID_DNS_TYPE "org.freedesktop.Avahi.InvalidDNSTypeError" +#define AVAHI_DBUS_ERR_NOT_SUPPORTED "org.freedesktop.Avahi.NotSupportedError" + +#define AVAHI_DBUS_ERR_NOT_PERMITTED "org.freedesktop.Avahi.NotPermittedError" +#define AVAHI_DBUS_ERR_INVALID_ARGUMENT "org.freedesktop.Avahi.InvalidArgumentError" +#define AVAHI_DBUS_ERR_IS_EMPTY "org.freedesktop.Avahi.IsEmptyError" +#define AVAHI_DBUS_ERR_NO_CHANGE "org.freedesktop.Avahi.NoChangeError" + +/** Convert a DBus error string into an Avahi error number */ +int avahi_error_dbus_to_number(const char *s); + +/** Convert an Avahi error number into a DBus error string. Result should not be freed */ +const char * avahi_error_number_to_dbus(int error); + +AVAHI_C_DECL_END + +#endif diff --git a/libgamestream/avahi-common/defs.h b/libgamestream/avahi-common/defs.h new file mode 100644 index 00000000..bb73a9df --- /dev/null +++ b/libgamestream/avahi-common/defs.h @@ -0,0 +1,356 @@ +#ifndef foodefshfoo +#define foodefshfoo + +/*** + 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.1 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 Lesser 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. +***/ + +/** \file defs.h Some common definitions */ + +#include + +/** \mainpage + * + * \section choose_api Choosing an API + * + * Avahi provides three programming APIs for integration of + * mDNS/DNS-SD features into your C progams: + * + * \li avahi-core: an API for embedding a complete mDNS/DNS-SD stack + * into your software. This is intended for developers of embedded + * appliances only. We dissuade from using this API in normal desktop + * applications since it is not a good idea to run multiple mDNS + * stacks simultaneously on the same host. + * \li the D-Bus API: an extensive D-Bus interface for browsing and + * registering mDNS/DNS-SD services using avahi-daemon. We recommend + * using this API for software written in any language other than + * C (e.g. Python). + * \li avahi-client: a simplifying C wrapper around the D-Bus API. We + * recommend using this API in C or C++ progams. The D-Bus internals + * are hidden completely. + * \li avahi-gobject: an object-oriented C wrapper based on + * GLib's GObject. We recommd using this API for GNOME/Gtk programs. + * + * All three APIs are very similar, however avahi-core is the most powerful. + * + * In addition to the three APIs described above Avahi supports two + * compatibility libraries: + * + * \li avahi-compat-libdns_sd: the original Bonjour API as documented + * in the header file "dns_sd.h" by Apple Computer, Inc. + * + * \li avahi-compat-howl: the HOWL API as released with HOWL 0.9.8 by + * Porchdog Software. + * + * Please note that these compatibility layers are incomplete and + * generally a waste of resources. We strongly encourage everyone to + * use our native APIs for newly written programs and to port older + * programs to avahi-client! + * + * The native APIs (avahi-client and avahi-core) can be integrated + * into external event loops. We provide adapters for the following + * event loop implementations: + * + * \li avahi-glib: The GLIB main loop as used by GTk+/GNOME + * + * \li avahi-qt: The Qt main loop as used by Qt/KDE + * + * Finally, we provide a high-level Gtk+ GUI dialog called + * avahi-ui for user-friendly browsing for services. + * + * The doxygen-generated API documentation covers avahi-client + * (including its auxiliary APIs), the event loop adapters and + * avahi-ui. For the other APIs please consult the original + * documentation (for the compatibility APIs) or the header files. + * + * Please note that the doxygen-generated API documentation of the + * native Avahi API is not complete. A few definitions that are part + * of the Avahi API have been removed from this documentation, either + * because they are only relevant in a very few low-level applications + * or because they are considered obsolete. Please consult the C header + * files for all definitions that are part of the Avahi API. Please + * note that these hidden definitions are considered part of the Avahi + * API and will stay available in the API in the future. + * + * \section error_reporting Error Reporting + * + * Some notes on the Avahi error handling: + * + * - Error codes are negative integers and defined as AVAHI_ERR_xx + * - If a function returns some kind of non-negative integer value on + * success, a failure is indicated by returning the error code + * directly. + * - If a function returns a pointer of some kind on success, a + * failure is indicated by returning NULL + * - The last error number may be retrieved by calling + * avahi_client_errno() + * - Just like the libc errno variable the Avahi errno is NOT reset to + * AVAHI_OK if a function call succeeds. + * - You may convert a numeric error code into a human readable string + * using avahi_strerror() + * - The constructor function avahi_client_new() returns the error + * code in a call-by-reference argument + * + * \section event_loop Event Loop Abstraction + * + * Avahi uses a simple event loop abstraction layer. A table AvahiPoll + * which contains function pointers for user defined timeout and I/O + * condition event source implementations needs to be passed to + * avahi_client_new(). An adapter for this abstraction layer is + * available for the GLib main loop in the object AvahiGLibPoll. A + * simple stand-alone implementation is available under the name + * AvahiSimplePoll. An adpater for the Qt main loop is available from + * avahi_qt_poll_get(). + * + * \section good_publish How to Register Services + * + * - Subscribe to server state changes. Pass a callback function + * pointer to avahi_client_new(). It will be called + * whenever the server state changes. + * - Only register your services when the server is in state + * AVAHI_SERVER_RUNNING. If you register your services in other server + * states they might not be accessible since the local host name might not necessarily + * be established. + * - Remove your services when the server enters + * AVAHI_SERVER_COLLISION or AVAHI_SERVER_REGISTERING state. Your + * services may not be reachable anymore since the local host name is + * no longer established or is currently in the process of being + * established. + * - When registering services, use the following algorithm: + * - Create a new entry group (i.e. avahi_entry_group_new()) + * - Add your service(s)/additional RRs/subtypes (e.g. avahi_entry_group_add_service()) + * - Commit the entry group (i.e. avahi_entry_group_commit()) + * - Subscribe to entry group state changes. + * - If the entry group enters AVAHI_ENTRY_GROUP_COLLISION state the + * services of the entry group are automatically removed from the + * server. You may immediately add your services back to the entry + * group (but with new names, perhaps using + * avahi_alternative_service_name()) and commit again. Please do not + * free the entry group and create a new one. This would inhibit some + * traffic limiting algorithms in mDNS. + * - When you need to modify your services (i.e. change the TXT data + * or the port number), use the AVAHI_PUBLISH_UPDATE flag. Please do + * not free the entry group and create a new one. This would inhibit + * some traffic limiting algorithms in mDNS. When changing just the + * TXT data avahi_entry_group_update_txt() is a shortcut for + * AVAHI_PUBLISH_UPDATE. Please note that you cannot use + * AVAHI_PUBLISH_UPDATE when changing the service name! Renaming a + * DNS-SD service is identical to deleting and creating a new one, and + * that's exactly what you should do in that case. First call + * avahi_entry_group_reset() to remove it and then read it normally. + * + * \section good_browse How to Browse for Services + * + * - For normal applications you need to call avahi_service_browser_new() + * for the service type you want to browse for. Use + * avahi_service_resolver_new() to acquire service data for a service + * name. + * - You can use avahi_domain_browser_new() to get a list of announced + * browsing domains. Please note that not all domains whith services + * on the LAN are mandatorily announced. + * - There is no need to subscribe to server state changes. + * + * \section daemon_dies How to Write a Client That Can Deal with Daemon Restarts + * + * With Avahi it is possible to write client applications that can + * deal with Avahi daemon restarts. To accomplish that make sure to + * pass AVAHI_CLIENT_NO_FAIL to avahi_client_new()'s flags + * parameter. That way avahi_client_new() will succeed even when the + * daemon is not running. In that case the object will enter + * AVAHI_CLIENT_CONNECTING state. As soon as the daemon becomes + * available the object will enter one of the AVAHI_CLIENT_S_xxx + * states. Make sure to not create browsers or entry groups before the + * client object has entered one of those states. As usual you will be + * informed about state changes with the callback function supplied to + * avahi_client_new(). If the client is forced to disconnect from the + * server it will enter AVAHI_CLIENT_FAILURE state with + * avahi_client_errno() == AVAHI_ERR_DISCONNECTED. Free the + * AvahiClient object in that case (and all its associated objects + * such as entry groups and browser objects prior to that) and + * reconnect to the server anew - again with passing + * AVAHI_CLIENT_NO_FAIL to avahi_client_new(). + * + * We encourage implementing this in all software where service + * discovery is not an integral part of application. e.g. use it in + * all kinds of background daemons, but not necessarily in software + * like iChat compatible IM software. + * + * For now AVAHI_CLIENT_NO_FAIL cannot deal with D-Bus daemon restarts. + * + * \section domains How to Deal Properly with Browsing Domains + * + * Due to the introduction of wide-area DNS-SD the correct handling of + * domains becomes more important for Avahi enabled applications. All + * applications that offer the user a list of services discovered with + * Avahi should offer some kind of editable drop down box where the + * user can either enter his own domain or select one of those offered + * by AvahiDomainBrowser. The default domain to browse should be the + * one returned by avahi_client_get_domain_name(). The list of domains + * returned by AvahiDomainBrowser is assembled by the browsing domains + * configured in the daemon's configuration file, the domains + * announced inside the default domain, the domains set with the + * environment variable $AVAHI_BROWSE_DOMAINS (colon-seperated) on the + * client side and the domains set in the XDG configuration file + * ~/.config/avahi/browse-domains on the client side (seperated by + * newlines). File managers offering some kind of "Network + * Neighborhood" folder should show the entries of the default domain + * right inside that and offer subfolders for the browsing domains + * returned by AvahiDomainBrowser. + */ + +AVAHI_C_DECL_BEGIN + +/** @{ \name States */ + +/** States of a server object */ +typedef enum { + AVAHI_SERVER_INVALID, /**< Invalid state (initial) */ + AVAHI_SERVER_REGISTERING, /**< Host RRs are being registered */ + AVAHI_SERVER_RUNNING, /**< All host RRs have been established */ + AVAHI_SERVER_COLLISION, /**< There is a collision with a host RR. All host RRs have been withdrawn, the user should set a new host name via avahi_server_set_host_name() */ + AVAHI_SERVER_FAILURE /**< Some fatal failure happened, the server is unable to proceed */ +} AvahiServerState; + +/** States of an entry group object */ +typedef enum { + AVAHI_ENTRY_GROUP_UNCOMMITED, /**< The group has not yet been commited, the user must still call avahi_entry_group_commit() */ + AVAHI_ENTRY_GROUP_REGISTERING, /**< The entries of the group are currently being registered */ + AVAHI_ENTRY_GROUP_ESTABLISHED, /**< The entries have successfully been established */ + AVAHI_ENTRY_GROUP_COLLISION, /**< A name collision for one of the entries in the group has been detected, the entries have been withdrawn */ + AVAHI_ENTRY_GROUP_FAILURE /**< Some kind of failure happened, the entries have been withdrawn */ +} AvahiEntryGroupState; + +/** @} */ + +/** @{ \name Flags */ + +/** Some flags for publishing functions */ +typedef enum { + AVAHI_PUBLISH_UNIQUE = 1, /**< For raw records: The RRset is intended to be unique */ + AVAHI_PUBLISH_NO_PROBE = 2, /**< For raw records: Though the RRset is intended to be unique no probes shall be sent */ + AVAHI_PUBLISH_NO_ANNOUNCE = 4, /**< For raw records: Do not announce this RR to other hosts */ + AVAHI_PUBLISH_ALLOW_MULTIPLE = 8, /**< For raw records: Allow multiple local records of this type, even if they are intended to be unique */ +/** \cond fulldocs */ + AVAHI_PUBLISH_NO_REVERSE = 16, /**< For address records: don't create a reverse (PTR) entry */ + AVAHI_PUBLISH_NO_COOKIE = 32, /**< For service records: do not implicitly add the local service cookie to TXT data */ +/** \endcond */ + AVAHI_PUBLISH_UPDATE = 64, /**< Update existing records instead of adding new ones */ +/** \cond fulldocs */ + AVAHI_PUBLISH_USE_WIDE_AREA = 128, /**< Register the record using wide area DNS (i.e. unicast DNS update) */ + AVAHI_PUBLISH_USE_MULTICAST = 256 /**< Register the record using multicast DNS */ +/** \endcond */ +} AvahiPublishFlags; + +/** Some flags for lookup functions */ +typedef enum { +/** \cond fulldocs */ + AVAHI_LOOKUP_USE_WIDE_AREA = 1, /**< Force lookup via wide area DNS */ + AVAHI_LOOKUP_USE_MULTICAST = 2, /**< Force lookup via multicast DNS */ +/** \endcond */ + AVAHI_LOOKUP_NO_TXT = 4, /**< When doing service resolving, don't lookup TXT record */ + AVAHI_LOOKUP_NO_ADDRESS = 8 /**< When doing service resolving, don't lookup A/AAAA record */ +} AvahiLookupFlags; + +/** Some flags for lookup callback functions */ +typedef enum { + AVAHI_LOOKUP_RESULT_CACHED = 1, /**< This response originates from the cache */ + AVAHI_LOOKUP_RESULT_WIDE_AREA = 2, /**< This response originates from wide area DNS */ + AVAHI_LOOKUP_RESULT_MULTICAST = 4, /**< This response originates from multicast DNS */ + AVAHI_LOOKUP_RESULT_LOCAL = 8, /**< This record/service resides on and was announced by the local host. Only available in service and record browsers and only on AVAHI_BROWSER_NEW. */ + AVAHI_LOOKUP_RESULT_OUR_OWN = 16, /**< This service belongs to the same local client as the browser object. Only available in avahi-client, and only for service browsers and only on AVAHI_BROWSER_NEW. */ + AVAHI_LOOKUP_RESULT_STATIC = 32 /**< The returned data has been defined statically by some configuration option */ +} AvahiLookupResultFlags; + +/** @} */ + +/** @{ \name Events */ + +/** Type of callback event when browsing */ +typedef enum { + AVAHI_BROWSER_NEW, /**< The object is new on the network */ + AVAHI_BROWSER_REMOVE, /**< The object has been removed from the network */ + AVAHI_BROWSER_CACHE_EXHAUSTED, /**< One-time event, to notify the user that all entries from the caches have been sent */ + AVAHI_BROWSER_ALL_FOR_NOW, /**< One-time event, to notify the user that more records will probably not show up in the near future, i.e. all cache entries have been read and all static servers been queried */ + AVAHI_BROWSER_FAILURE /**< Browsing failed due to some reason which can be retrieved using avahi_server_errno()/avahi_client_errno() */ +} AvahiBrowserEvent; + +/** Type of callback event when resolving */ +typedef enum { + AVAHI_RESOLVER_FOUND, /**< RR found, resolving successful */ + AVAHI_RESOLVER_FAILURE /**< Resolving failed due to some reason which can be retrieved using avahi_server_errno()/avahi_client_errno() */ +} AvahiResolverEvent; + +/** @} */ + +/** @{ \name Other definitions */ + +/** The type of domain to browse for */ +typedef enum { + AVAHI_DOMAIN_BROWSER_BROWSE, /**< Browse for a list of available browsing domains */ + AVAHI_DOMAIN_BROWSER_BROWSE_DEFAULT, /**< Browse for the default browsing domain */ + AVAHI_DOMAIN_BROWSER_REGISTER, /**< Browse for a list of available registering domains */ + AVAHI_DOMAIN_BROWSER_REGISTER_DEFAULT, /**< Browse for the default registering domain */ + AVAHI_DOMAIN_BROWSER_BROWSE_LEGACY, /**< Legacy browse domain - see DNS-SD spec for more information */ + AVAHI_DOMAIN_BROWSER_MAX +} AvahiDomainBrowserType; + +/** @} */ + +/** \cond fulldocs */ +/** For every service a special TXT item is implicitly added, which + * contains a random cookie which is private to the local daemon. This + * can be used by clients to determine if two services on two + * different subnets are effectively the same. */ +#define AVAHI_SERVICE_COOKIE "org.freedesktop.Avahi.cookie" + +/** In invalid cookie as special value */ +#define AVAHI_SERVICE_COOKIE_INVALID (0) +/** \endcond fulldocs */ + +/** @{ \name DNS RR definitions */ + +/** DNS record types, see RFC 1035 */ +enum { + AVAHI_DNS_TYPE_A = 0x01, + AVAHI_DNS_TYPE_NS = 0x02, + AVAHI_DNS_TYPE_CNAME = 0x05, + AVAHI_DNS_TYPE_SOA = 0x06, + AVAHI_DNS_TYPE_PTR = 0x0C, + AVAHI_DNS_TYPE_HINFO = 0x0D, + AVAHI_DNS_TYPE_MX = 0x0F, + AVAHI_DNS_TYPE_TXT = 0x10, + AVAHI_DNS_TYPE_AAAA = 0x1C, + AVAHI_DNS_TYPE_SRV = 0x21 +}; + +/** DNS record classes, see RFC 1035 */ +enum { + AVAHI_DNS_CLASS_IN = 0x01 /**< Probably the only class we will ever use */ +}; + +/** @} */ + +/** The default TTL for RRs which contain a host name of some kind. */ +#define AVAHI_DEFAULT_TTL_HOST_NAME (120) + +/** The default TTL for all other records. */ +#define AVAHI_DEFAULT_TTL (75*60) + +AVAHI_C_DECL_END + +#endif diff --git a/libgamestream/avahi-common/domain-test.c b/libgamestream/avahi-common/domain-test.c new file mode 100644 index 00000000..cf763eca --- /dev/null +++ b/libgamestream/avahi-common/domain-test.c @@ -0,0 +1,123 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include + +#include "domain.h" +#include "malloc.h" + +int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { + char *s; + char t[256], r[256]; + const char *p; + size_t size; + char name[64], type[AVAHI_DOMAIN_NAME_MAX], domain[AVAHI_DOMAIN_NAME_MAX]; + + printf("%s\n", s = avahi_normalize_name_strdup("foo.foo\\046.")); + avahi_free(s); + + printf("%s\n", s = avahi_normalize_name_strdup("foo.foo\\.foo.")); + avahi_free(s); + + + printf("%s\n", s = avahi_normalize_name_strdup("fo\\\\o\\..f oo.")); + avahi_free(s); + + printf("%i\n", avahi_domain_equal("\\065aa bbb\\.\\046cc.cc\\\\.dee.fff.", "Aaa BBB\\.\\.cc.cc\\\\.dee.fff")); + printf("%i\n", avahi_domain_equal("A", "a")); + + printf("%i\n", avahi_domain_equal("a", "aaa")); + + printf("%u = %u\n", avahi_domain_hash("ccc\\065aa.aa\\.b\\\\."), avahi_domain_hash("cccAaa.aa\\.b\\\\")); + + + avahi_service_name_join(t, sizeof(t), "foo.foo.foo \\.", "_http._tcp", "test.local"); + printf("<%s>\n", t); + + avahi_service_name_split(t, name, sizeof(name), type, sizeof(type), domain, sizeof(domain)); + printf("name: <%s>; type: <%s>; domain <%s>\n", name, type, domain); + + avahi_service_name_join(t, sizeof(t), NULL, "_http._tcp", "one.two\\. .local"); + printf("<%s>\n", t); + + avahi_service_name_split(t, NULL, 0, type, sizeof(type), domain, sizeof(domain)); + printf("name: <>; type: <%s>; domain <%s>\n", type, domain); + + + p = "--:---\\\\\\123\\065_äöü\\064\\.\\\\sjöödfhh.sdfjhskjdf"; + printf("unescaped: <%s>, rest: %s\n", avahi_unescape_label(&p, t, sizeof(t)), p); + + size = sizeof(r); + s = r; + + printf("escaped: <%s>\n", avahi_escape_label(t, strlen(t), &s, &size)); + + p = r; + printf("unescaped: <%s>\n", avahi_unescape_label(&p, t, sizeof(t))); + + assert(avahi_is_valid_service_type_generic("_foo._bar._waldo")); + assert(!avahi_is_valid_service_type_strict("_foo._bar._waldo")); + assert(!avahi_is_valid_service_subtype("_foo._bar._waldo")); + + assert(avahi_is_valid_service_type_generic("_foo._tcp")); + assert(avahi_is_valid_service_type_strict("_foo._tcp")); + assert(!avahi_is_valid_service_subtype("_foo._tcp")); + + assert(!avahi_is_valid_service_type_generic("_foo._bar.waldo")); + assert(!avahi_is_valid_service_type_strict("_foo._bar.waldo")); + assert(!avahi_is_valid_service_subtype("_foo._bar.waldo")); + + assert(!avahi_is_valid_service_type_generic("")); + assert(!avahi_is_valid_service_type_strict("")); + assert(!avahi_is_valid_service_subtype("")); + + assert(avahi_is_valid_service_type_generic("_foo._sub._bar._tcp")); + assert(!avahi_is_valid_service_type_strict("_foo._sub._bar._tcp")); + assert(avahi_is_valid_service_subtype("_foo._sub._bar._tcp")); + + printf("%s\n", avahi_get_type_from_subtype("_foo._sub._bar._tcp")); + + assert(!avahi_is_valid_host_name("sf.ooo.")); + assert(avahi_is_valid_host_name("sfooo.")); + assert(avahi_is_valid_host_name("sfooo")); + + assert(avahi_is_valid_domain_name(".")); + assert(avahi_is_valid_domain_name("")); + + assert(avahi_normalize_name(".", t, sizeof(t))); + assert(avahi_normalize_name("", t, sizeof(t))); + + assert(!avahi_is_valid_fqdn(".")); + assert(!avahi_is_valid_fqdn("")); + assert(!avahi_is_valid_fqdn("foo")); + assert(avahi_is_valid_fqdn("foo.bar")); + assert(avahi_is_valid_fqdn("foo.bar.")); + assert(avahi_is_valid_fqdn("gnurz.foo.bar.")); + assert(!avahi_is_valid_fqdn("192.168.50.1")); + assert(!avahi_is_valid_fqdn("::1")); + assert(!avahi_is_valid_fqdn(".192.168.50.1.")); + + return 0; +} diff --git a/libgamestream/avahi-common/domain.c b/libgamestream/avahi-common/domain.c new file mode 100644 index 00000000..3b1ab683 --- /dev/null +++ b/libgamestream/avahi-common/domain.c @@ -0,0 +1,609 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "domain.h" +#include "malloc.h" +#include "error.h" +#include "address.h" +#include "utf8.h" + +/* Read the first label from string *name, unescape "\" and write it to dest */ +char *avahi_unescape_label(const char **name, char *dest, size_t size) { + unsigned i = 0; + char *d; + + assert(dest); + assert(size > 0); + assert(name); + + d = dest; + + for (;;) { + if (i >= size) + return NULL; + + if (**name == '.') { + (*name)++; + break; + } + + if (**name == 0) + break; + + if (**name == '\\') { + /* Escaped character */ + + (*name) ++; + + if (**name == 0) + /* Ending NUL */ + return NULL; + + else if (**name == '\\' || **name == '.') { + /* Escaped backslash or dot */ + *(d++) = *((*name) ++); + i++; + } else if (isdigit(**name)) { + int n; + + /* Escaped literal ASCII character */ + + if (!isdigit(*(*name+1)) || !isdigit(*(*name+2))) + return NULL; + + n = ((uint8_t) (**name - '0') * 100) + ((uint8_t) (*(*name+1) - '0') * 10) + ((uint8_t) (*(*name +2) - '0')); + + if (n > 255 || n == 0) + return NULL; + + *(d++) = (char) n; + i++; + + (*name) += 3; + } else + return NULL; + + } else { + + /* Normal character */ + + *(d++) = *((*name) ++); + i++; + } + } + + assert(i < size); + + *d = 0; + + if (!avahi_utf8_valid(dest)) + return NULL; + + return dest; +} + +/* Escape "\" and ".", append \0 */ +char *avahi_escape_label(const char* src, size_t src_length, char **ret_name, size_t *ret_size) { + char *r; + + assert(src); + assert(ret_name); + assert(*ret_name); + assert(ret_size); + assert(*ret_size > 0); + + r = *ret_name; + + while (src_length > 0) { + if (*src == '.' || *src == '\\') { + + /* Dot or backslash */ + + if (*ret_size < 3) + return NULL; + + *((*ret_name) ++) = '\\'; + *((*ret_name) ++) = *src; + (*ret_size) -= 2; + + } else if ( + *src == '_' || + *src == '-' || + (*src >= '0' && *src <= '9') || + (*src >= 'a' && *src <= 'z') || + (*src >= 'A' && *src <= 'Z')) { + + /* Proper character */ + + if (*ret_size < 2) + return NULL; + + *((*ret_name)++) = *src; + (*ret_size) --; + + } else { + + /* Everything else */ + + if (*ret_size < 5) + return NULL; + + *((*ret_name) ++) = '\\'; + *((*ret_name) ++) = '0' + (char) ((uint8_t) *src / 100); + *((*ret_name) ++) = '0' + (char) (((uint8_t) *src / 10) % 10); + *((*ret_name) ++) = '0' + (char) ((uint8_t) *src % 10); + + (*ret_size) -= 4; + } + + src_length --; + src++; + } + + **ret_name = 0; + + return r; +} + +char *avahi_normalize_name(const char *s, char *ret_s, size_t size) { + int empty = 1; + char *r; + + assert(s); + assert(ret_s); + assert(size > 0); + + r = ret_s; + *ret_s = 0; + + while (*s) { + char label[AVAHI_LABEL_MAX]; + + if (!(avahi_unescape_label(&s, label, sizeof(label)))) + return NULL; + + if (label[0] == 0) { + + if (*s == 0 && empty) + return ret_s; + + return NULL; + } + + if (!empty) { + if (size < 1) + return NULL; + + *(r++) = '.'; + size--; + + } else + empty = 0; + + avahi_escape_label(label, strlen(label), &r, &size); + } + + return ret_s; +} + +char *avahi_normalize_name_strdup(const char *s) { + char t[AVAHI_DOMAIN_NAME_MAX]; + assert(s); + + if (!(avahi_normalize_name(s, t, sizeof(t)))) + return NULL; + + return avahi_strdup(t); +} + +int avahi_domain_equal(const char *a, const char *b) { + assert(a); + assert(b); + + if (a == b) + return 1; + + for (;;) { + char ca[AVAHI_LABEL_MAX], cb[AVAHI_LABEL_MAX], *r; + + r = avahi_unescape_label(&a, ca, sizeof(ca)); + assert(r); + r = avahi_unescape_label(&b, cb, sizeof(cb)); + assert(r); + + if (strcasecmp(ca, cb)) + return 0; + + if (!*a && !*b) + return 1; + } + + return 1; +} + +int avahi_is_valid_service_type_generic(const char *t) { + assert(t); + + if (strlen(t) >= AVAHI_DOMAIN_NAME_MAX || !*t) + return 0; + + do { + char label[AVAHI_LABEL_MAX]; + + if (!(avahi_unescape_label(&t, label, sizeof(label)))) + return 0; + + if (strlen(label) <= 2 || label[0] != '_') + return 0; + + } while (*t); + + return 1; +} + +int avahi_is_valid_service_type_strict(const char *t) { + char label[AVAHI_LABEL_MAX]; + assert(t); + + if (strlen(t) >= AVAHI_DOMAIN_NAME_MAX || !*t) + return 0; + + /* Application name */ + + if (!(avahi_unescape_label(&t, label, sizeof(label)))) + return 0; + + if (strlen(label) <= 2 || label[0] != '_') + return 0; + + if (!*t) + return 0; + + /* _tcp or _udp boilerplate */ + + if (!(avahi_unescape_label(&t, label, sizeof(label)))) + return 0; + + if (strcasecmp(label, "_tcp") && strcasecmp(label, "_udp")) + return 0; + + if (*t) + return 0; + + return 1; +} + +const char *avahi_get_type_from_subtype(const char *t) { + char label[AVAHI_LABEL_MAX]; + const char *ret; + assert(t); + + if (strlen(t) >= AVAHI_DOMAIN_NAME_MAX || !*t) + return NULL; + + /* Subtype name */ + + if (!(avahi_unescape_label(&t, label, sizeof(label)))) + return NULL; + + if (strlen(label) <= 2 || label[0] != '_') + return NULL; + + if (!*t) + return NULL; + + /* String "_sub" */ + + if (!(avahi_unescape_label(&t, label, sizeof(label)))) + return NULL; + + if (strcasecmp(label, "_sub")) + return NULL; + + if (!*t) + return NULL; + + ret = t; + + /* Application name */ + + if (!(avahi_unescape_label(&t, label, sizeof(label)))) + return NULL; + + if (strlen(label) <= 2 || label[0] != '_') + return NULL; + + if (!*t) + return NULL; + + /* _tcp or _udp boilerplate */ + + if (!(avahi_unescape_label(&t, label, sizeof(label)))) + return NULL; + + if (strcasecmp(label, "_tcp") && strcasecmp(label, "_udp")) + return NULL; + + if (*t) + return NULL; + + return ret; +} + +int avahi_is_valid_service_subtype(const char *t) { + assert(t); + + return !!avahi_get_type_from_subtype(t); +} + +int avahi_is_valid_domain_name(const char *t) { + int is_first = 1; + assert(t); + + if (strlen(t) >= AVAHI_DOMAIN_NAME_MAX) + return 0; + + do { + char label[AVAHI_LABEL_MAX]; + + if (!(avahi_unescape_label(&t, label, sizeof(label)))) + return 0; + + /* Explicitly allow the root domain name */ + if (is_first && label[0] == 0 && *t == 0) + return 1; + + is_first = 0; + + if (label[0] == 0) + return 0; + + } while (*t); + + return 1; +} + +int avahi_is_valid_service_name(const char *t) { + assert(t); + + if (strlen(t) >= AVAHI_LABEL_MAX || !*t) + return 0; + + return 1; +} + +int avahi_is_valid_host_name(const char *t) { + char label[AVAHI_LABEL_MAX]; + assert(t); + + if (strlen(t) >= AVAHI_DOMAIN_NAME_MAX || !*t) + return 0; + + if (!(avahi_unescape_label(&t, label, sizeof(label)))) + return 0; + + if (strlen(label) < 1) + return 0; + + if (*t) + return 0; + + return 1; +} + +unsigned avahi_domain_hash(const char *s) { + unsigned hash = 0; + + while (*s) { + char c[AVAHI_LABEL_MAX], *p, *r; + + r = avahi_unescape_label(&s, c, sizeof(c)); + assert(r); + + for (p = c; *p; p++) + hash = 31 * hash + tolower(*p); + } + + return hash; +} + +int avahi_service_name_join(char *p, size_t size, const char *name, const char *type, const char *domain) { + char escaped_name[AVAHI_LABEL_MAX*4]; + char normalized_type[AVAHI_DOMAIN_NAME_MAX]; + char normalized_domain[AVAHI_DOMAIN_NAME_MAX]; + + assert(p); + + /* Validity checks */ + + if ((name && !avahi_is_valid_service_name(name))) + return AVAHI_ERR_INVALID_SERVICE_NAME; + + if (!avahi_is_valid_service_type_generic(type)) + return AVAHI_ERR_INVALID_SERVICE_TYPE; + + if (!avahi_is_valid_domain_name(domain)) + return AVAHI_ERR_INVALID_DOMAIN_NAME; + + /* Preparation */ + + if (name) { + size_t l = sizeof(escaped_name); + char *e = escaped_name, *r; + r = avahi_escape_label(name, strlen(name), &e, &l); + assert(r); + } + + if (!(avahi_normalize_name(type, normalized_type, sizeof(normalized_type)))) + return AVAHI_ERR_INVALID_SERVICE_TYPE; + + if (!(avahi_normalize_name(domain, normalized_domain, sizeof(normalized_domain)))) + return AVAHI_ERR_INVALID_DOMAIN_NAME; + + /* Concatenation */ + + snprintf(p, size, "%s%s%s.%s", name ? escaped_name : "", name ? "." : "", normalized_type, normalized_domain); + + return AVAHI_OK; +} + +#ifndef HAVE_STRLCPY + +static size_t strlcpy(char *dest, const char *src, size_t n) { + assert(dest); + assert(src); + + if (n > 0) { + strncpy(dest, src, n-1); + dest[n-1] = 0; + } + + return strlen(src); +} + +#endif + +int avahi_service_name_split(const char *p, char *name, size_t name_size, char *type, size_t type_size, char *domain, size_t domain_size) { + enum { + NAME, + TYPE, + DOMAIN + } state; + int type_empty = 1, domain_empty = 1; + + assert(p); + assert(type); + assert(type_size > 0); + assert(domain); + assert(domain_size > 0); + + if (name) { + assert(name_size > 0); + *name = 0; + state = NAME; + } else + state = TYPE; + + *type = *domain = 0; + + while (*p) { + char buf[64]; + + if (!(avahi_unescape_label(&p, buf, sizeof(buf)))) + return -1; + + switch (state) { + case NAME: + strlcpy(name, buf, name_size); + state = TYPE; + break; + + case TYPE: + + if (buf[0] == '_') { + + if (!type_empty) { + if (!type_size) + return AVAHI_ERR_NO_MEMORY; + + *(type++) = '.'; + type_size --; + + } else + type_empty = 0; + + if (!(avahi_escape_label(buf, strlen(buf), &type, &type_size))) + return AVAHI_ERR_NO_MEMORY; + + break; + } + + state = DOMAIN; + /* fall through */ + + case DOMAIN: + + if (!domain_empty) { + if (!domain_size) + return AVAHI_ERR_NO_MEMORY; + + *(domain++) = '.'; + domain_size --; + } else + domain_empty = 0; + + if (!(avahi_escape_label(buf, strlen(buf), &domain, &domain_size))) + return AVAHI_ERR_NO_MEMORY; + + break; + } + } + + return 0; +} + +int avahi_is_valid_fqdn(const char *t) { + char label[AVAHI_LABEL_MAX]; + char normalized[AVAHI_DOMAIN_NAME_MAX]; + const char *k = t; + AvahiAddress a; + assert(t); + + if (strlen(t) >= AVAHI_DOMAIN_NAME_MAX) + return 0; + + if (!avahi_is_valid_domain_name(t)) + return 0; + + /* Check if there are at least two labels*/ + if (!(avahi_unescape_label(&k, label, sizeof(label)))) + return 0; + + if (label[0] == 0 || !k) + return 0; + + if (!(avahi_unescape_label(&k, label, sizeof(label)))) + return 0; + + if (label[0] == 0 || !k) + return 0; + + /* Make sure that the name is not an IP address */ + if (!(avahi_normalize_name(t, normalized, sizeof(normalized)))) + return 0; + + if (avahi_address_parse(normalized, AVAHI_PROTO_UNSPEC, &a)) + return 0; + + return 1; +} diff --git a/libgamestream/avahi-common/domain.h b/libgamestream/avahi-common/domain.h new file mode 100644 index 00000000..a0dcd0fa --- /dev/null +++ b/libgamestream/avahi-common/domain.h @@ -0,0 +1,129 @@ +#ifndef foodomainhfoo +#define foodomainhfoo + +/*** + 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.1 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 Lesser 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. +***/ + +/** \file domain.h Domain name handling functions */ + +#include +#include + +#include + +AVAHI_C_DECL_BEGIN + +/** The maximum length of a a fully escaped domain name C string. This + * is calculated like this: RFC1034 mandates maximum length of FQDNs + * is 255. The maximum label length is 63. To minimize the number of + * (non-escaped) dots, we comprise our maximum-length domain name of + * four labels á 63 characters plus three inner dots. Escaping the + * four labels quadruples their length at maximum. An escaped domain + * name has the therefore the maximum length of 63*4*4+3=1011. A + * trailing NUL and perhaps two unnecessary dots leading and trailing + * the string brings us to 1014. */ +#define AVAHI_DOMAIN_NAME_MAX 1014 + +/** Maximum size of an unescaped label */ +#define AVAHI_LABEL_MAX 64 + +/** @{ \name Normalization */ + +/** Normalize a domain name into canonical form. This drops trailing + * dots and removes useless backslash escapes. */ +char *avahi_normalize_name(const char *s, char *ret_s, size_t size); + +/** Normalize a domain name into canonical form. This drops trailing + * dots and removes useless backslash escapes. avahi_free() the + * result! */ +char *avahi_normalize_name_strdup(const char *s); + +/** @} */ + +/** @{ \name Comparison */ + +/** Return 1 when the specified domain names are equal, 0 otherwise */ +int avahi_domain_equal(const char *a, const char *b); + +/** Return some kind of hash value for the domain, useful for using domains as hash table keys. */ +unsigned avahi_domain_hash(const char *name); + +/** @} */ + +/** @{ \name Escaping */ + +/** Read the first label from the textual domain name *name, unescape + * it and write it to dest, *name is changed to point to the next label*/ +char *avahi_unescape_label(const char **name, char *dest, size_t size); + +/** Escape the domain name in *src and write it to *ret_name */ +char *avahi_escape_label(const char* src, size_t src_length, char **ret_name, size_t *ret_size); + +/** @} */ + +/** @{ \name Validity Checks */ + +/** Return 1 when the specified string contains a valid generic DNS-SD + * service type (i.e. a series of words starting with "_"), 0 + * otherwise */ +int avahi_is_valid_service_type_generic(const char *t); + +/** Return 1 when the specified string contains a valid strict DNS-SD + * service type (i.e. consisting of only two words, the latter being + * either _udp or _tcp), 0 otherwise */ +int avahi_is_valid_service_type_strict(const char *t); + +/** Return 1 when the specified string contains a valid DNS-SD service + * subtype, 0 otherwise */ +int avahi_is_valid_service_subtype(const char *t); + +/** Return 1 when the specified string contains a valid domain name, 0 otherwise */ +int avahi_is_valid_domain_name(const char *t); + +/** Return 1 when the specified string contains a valid DNS-SD service name, 0 otherwise */ +int avahi_is_valid_service_name(const char *t); + +/** Return 1 when the specified string contains a valid non-FQDN host name (i.e. without dots), 0 otherwise */ +int avahi_is_valid_host_name(const char *t); + +/** Return 1 when the specified string contains a valid FQDN host name (i.e. with more than one label and non-numerical), 0 otherwise. \since 0.6.9 */ +int avahi_is_valid_fqdn(const char *t); + +/** @} */ + +/** @{ \name DNS-SD service name handling */ + +/** Construct a valid complete DNS-SD service name from a name, a type and a domain */ +int avahi_service_name_join(char *p, size_t size, const char *name, const char *type, const char *domain); + +/** Split a full service name into name, type and domain */ +int avahi_service_name_split(const char *p, char *name, size_t name_size, char *type, size_t type_size, char *domain, size_t domain_size); + +/** @} */ + +/** @{ \name DNS-SD Subtype handling */ + +/** Return a pointer to the type section of a subtype i.e. _foo._sub._bar._tcp => _bar._tcp */ +const char *avahi_get_type_from_subtype(const char *t); + +/** @} */ + +AVAHI_C_DECL_END + +#endif diff --git a/libgamestream/avahi-common/error.c b/libgamestream/avahi-common/error.c new file mode 100644 index 00000000..63c50331 --- /dev/null +++ b/libgamestream/avahi-common/error.c @@ -0,0 +1,97 @@ +/*** + 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.1 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 Lesser 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. + ***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "error.h" +#include "i18n.h" + +const char *avahi_strerror(int error) { + + const char * const msg[- AVAHI_ERR_MAX] = { + N_("OK"), + N_("Operation failed"), + N_("Bad state"), + N_("Invalid host name"), + N_("Invalid domain name"), + N_("No suitable network protocol available"), + N_("Invalid DNS TTL"), + N_("Resource record key is pattern"), + N_("Local name collision"), + N_("Invalid record"), + + N_("Invalid service name"), + N_("Invalid service type"), + N_("Invalid port number"), + N_("Invalid record key"), + N_("Invalid address"), + N_("Timeout reached"), + N_("Too many clients"), + N_("Too many objects"), + N_("Too many entries"), + N_("OS Error"), + + N_("Access denied"), + N_("Invalid operation"), + N_("An unexpected D-Bus error occurred"), + N_("Daemon connection failed"), + N_("Memory exhausted"), + N_("The object passed in was not valid"), + N_("Daemon not running"), + N_("Invalid interface index"), + N_("Invalid protocol specification"), + N_("Invalid flags"), + + N_("Not found"), + N_("Invalid configuration"), + N_("Version mismatch"), + N_("Invalid service subtype"), + N_("Invalid packet"), + N_("Invalid DNS return code"), + N_("DNS failure: FORMERR"), + N_("DNS failure: SERVFAIL"), + N_("DNS failure: NXDOMAIN"), + N_("DNS failure: NOTIMP"), + + N_("DNS failure: REFUSED"), + N_("DNS failure: YXDOMAIN"), + N_("DNS failure: YXRRSET"), + N_("DNS failure: NXRRSET"), + N_("DNS failure: NOTAUTH"), + N_("DNS failure: NOTZONE"), + N_("Invalid RDATA"), + N_("Invalid DNS type"), + N_("Invalid DNS class"), + N_("Not supported"), + + N_("Not permitted"), + N_("Invalid argument"), + N_("Is empty"), + N_("The requested operation is invalid because redundant") + }; + + avahi_init_i18n(); + + if (-error < 0 || -error >= -AVAHI_ERR_MAX) + return _("Invalid Error Code"); + + return _(msg[-error]); +} diff --git a/libgamestream/avahi-common/error.h b/libgamestream/avahi-common/error.h new file mode 100644 index 00000000..94511c92 --- /dev/null +++ b/libgamestream/avahi-common/error.h @@ -0,0 +1,107 @@ +#ifndef fooerrorhfoo +#define fooerrorhfoo + +/*** + 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.1 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 Lesser 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. +***/ + +/** \file error.h Error codes and auxiliary functions */ + +#include + +AVAHI_C_DECL_BEGIN + +/** Error codes used by avahi */ +enum { + AVAHI_OK = 0, /**< OK */ + AVAHI_ERR_FAILURE = -1, /**< Generic error code */ + AVAHI_ERR_BAD_STATE = -2, /**< Object was in a bad state */ + AVAHI_ERR_INVALID_HOST_NAME = -3, /**< Invalid host name */ + AVAHI_ERR_INVALID_DOMAIN_NAME = -4, /**< Invalid domain name */ + AVAHI_ERR_NO_NETWORK = -5, /**< No suitable network protocol available */ + AVAHI_ERR_INVALID_TTL = -6, /**< Invalid DNS TTL */ + AVAHI_ERR_IS_PATTERN = -7, /**< RR key is pattern */ + AVAHI_ERR_COLLISION = -8, /**< Name collision */ + AVAHI_ERR_INVALID_RECORD = -9, /**< Invalid RR */ + + AVAHI_ERR_INVALID_SERVICE_NAME = -10, /**< Invalid service name */ + AVAHI_ERR_INVALID_SERVICE_TYPE = -11, /**< Invalid service type */ + AVAHI_ERR_INVALID_PORT = -12, /**< Invalid port number */ + AVAHI_ERR_INVALID_KEY = -13, /**< Invalid key */ + AVAHI_ERR_INVALID_ADDRESS = -14, /**< Invalid address */ + AVAHI_ERR_TIMEOUT = -15, /**< Timeout reached */ + AVAHI_ERR_TOO_MANY_CLIENTS = -16, /**< Too many clients */ + AVAHI_ERR_TOO_MANY_OBJECTS = -17, /**< Too many objects */ + AVAHI_ERR_TOO_MANY_ENTRIES = -18, /**< Too many entries */ + AVAHI_ERR_OS = -19, /**< OS error */ + + AVAHI_ERR_ACCESS_DENIED = -20, /**< Access denied */ + AVAHI_ERR_INVALID_OPERATION = -21, /**< Invalid operation */ + AVAHI_ERR_DBUS_ERROR = -22, /**< An unexpected D-Bus error occurred */ + AVAHI_ERR_DISCONNECTED = -23, /**< Daemon connection failed */ + AVAHI_ERR_NO_MEMORY = -24, /**< Memory exhausted */ + AVAHI_ERR_INVALID_OBJECT = -25, /**< The object passed to this function was invalid */ + AVAHI_ERR_NO_DAEMON = -26, /**< Daemon not running */ + AVAHI_ERR_INVALID_INTERFACE = -27, /**< Invalid interface */ + AVAHI_ERR_INVALID_PROTOCOL = -28, /**< Invalid protocol */ + AVAHI_ERR_INVALID_FLAGS = -29, /**< Invalid flags */ + + AVAHI_ERR_NOT_FOUND = -30, /**< Not found */ + AVAHI_ERR_INVALID_CONFIG = -31, /**< Configuration error */ + AVAHI_ERR_VERSION_MISMATCH = -32, /**< Verson mismatch */ + AVAHI_ERR_INVALID_SERVICE_SUBTYPE = -33, /**< Invalid service subtype */ + AVAHI_ERR_INVALID_PACKET = -34, /**< Invalid packet */ + AVAHI_ERR_INVALID_DNS_ERROR = -35, /**< Invlaid DNS return code */ + AVAHI_ERR_DNS_FORMERR = -36, /**< DNS Error: Form error */ + AVAHI_ERR_DNS_SERVFAIL = -37, /**< DNS Error: Server Failure */ + AVAHI_ERR_DNS_NXDOMAIN = -38, /**< DNS Error: No such domain */ + AVAHI_ERR_DNS_NOTIMP = -39, /**< DNS Error: Not implemented */ + + AVAHI_ERR_DNS_REFUSED = -40, /**< DNS Error: Operation refused */ + AVAHI_ERR_DNS_YXDOMAIN = -41, + AVAHI_ERR_DNS_YXRRSET = -42, + AVAHI_ERR_DNS_NXRRSET = -43, + AVAHI_ERR_DNS_NOTAUTH = -44, /**< DNS Error: Not authorized */ + AVAHI_ERR_DNS_NOTZONE = -45, + AVAHI_ERR_INVALID_RDATA = -46, /**< Invalid RDATA */ + AVAHI_ERR_INVALID_DNS_CLASS = -47, /**< Invalid DNS class */ + AVAHI_ERR_INVALID_DNS_TYPE = -48, /**< Invalid DNS type */ + AVAHI_ERR_NOT_SUPPORTED = -49, /**< Not supported */ + + AVAHI_ERR_NOT_PERMITTED = -50, /**< Operation not permitted */ + AVAHI_ERR_INVALID_ARGUMENT = -51, /**< Invalid argument */ + AVAHI_ERR_IS_EMPTY = -52, /**< Is empty */ + AVAHI_ERR_NO_CHANGE = -53, /**< The requested operation is invalid because it is redundant */ + + /**** + **** IF YOU ADD A NEW ERROR CODE HERE, PLEASE DON'T FORGET TO ADD + **** IT TO THE STRING ARRAY IN avahi_strerror() IN error.c AND + **** TO THE ARRAY IN dbus.c AND FINALLY TO dbus.h! + **** + **** Also remember to update the MAX value below. + ****/ + + AVAHI_ERR_MAX = -54 +}; + +/** Return a human readable error string for the specified error code */ +const char *avahi_strerror(int error); + +AVAHI_C_DECL_END + +#endif diff --git a/libgamestream/avahi-common/gccmacro.h b/libgamestream/avahi-common/gccmacro.h new file mode 100644 index 00000000..4c97111a --- /dev/null +++ b/libgamestream/avahi-common/gccmacro.h @@ -0,0 +1,74 @@ +#ifndef foogccmacrohfoo +#define foogccmacrohfoo + +/*** + 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.1 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 Lesser 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. +***/ + +/** \file gccmacro.h Defines some macros for GCC extensions */ + +#include + +AVAHI_C_DECL_BEGIN + +#if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3) +#define AVAHI_GCC_ALLOC_SIZE(x) __attribute__ ((__alloc_size__(x))) +#define AVAHI_GCC_ALLOC_SIZE2(x,y) __attribute__ ((__alloc_size__(x,y))) +#else +/** Macro for usage of GCC's alloc_size attribute */ +#define AVAHI_GCC_ALLOC_SIZE(x) +#define AVAHI_GCC_ALLOC_SIZE2(x,y) +#endif + +#if defined(__GNUC__) && (__GNUC__ >= 4) +#define AVAHI_GCC_SENTINEL __attribute__ ((sentinel)) +#else +/** Macro for usage of GCC's sentinel compilation warnings */ +#define AVAHI_GCC_SENTINEL +#endif + +#ifdef __GNUC__ +#define AVAHI_GCC_PRINTF_ATTR(a,b) __attribute__ ((format (printf, a, b))) +#else +/** Macro for usage of GCC's printf compilation warnings */ +#define AVAHI_GCC_PRINTF_ATTR(a,b) +#endif + +/** Same as AVAHI_GCC_PRINTF_ATTR but hard coded to arguments 1 and 2 */ +#define AVAHI_GCC_PRINTF_ATTR12 AVAHI_GCC_PRINTF_ATTR(1,2) + +/** Same as AVAHI_GCC_PRINTF_ATTR but hard coded to arguments 2 and 3 */ +#define AVAHI_GCC_PRINTF_ATTR23 AVAHI_GCC_PRINTF_ATTR(2,3) + +#ifdef __GNUC__ +#define AVAHI_GCC_NORETURN __attribute__((noreturn)) +#else +/** Macro for no-return functions */ +#define AVAHI_GCC_NORETURN +#endif + +#ifdef __GNUC__ +#define AVAHI_GCC_UNUSED __attribute__ ((unused)) +#else +/** Macro for not used parameter */ +#define AVAHI_GCC_UNUSED +#endif + +AVAHI_C_DECL_END + +#endif diff --git a/libgamestream/avahi-common/i18n.c b/libgamestream/avahi-common/i18n.c new file mode 100644 index 00000000..51c93e4e --- /dev/null +++ b/libgamestream/avahi-common/i18n.c @@ -0,0 +1,38 @@ +/*** + 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.1 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 Lesser 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. + ***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "i18n.h" + +void avahi_init_i18n(void) { + + /* Not really thread safe, but this doesn't matter much since + * bindtextdomain is supposed to be idempotent anyway. */ + + static int done = 0; + + if (!done) { + bindtextdomain(GETTEXT_PACKAGE, AVAHI_LOCALEDIR); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); + done = 1; + } +} diff --git a/libgamestream/avahi-common/i18n.h b/libgamestream/avahi-common/i18n.h new file mode 100644 index 00000000..2a613e58 --- /dev/null +++ b/libgamestream/avahi-common/i18n.h @@ -0,0 +1,53 @@ +#ifndef fooi18nhfoo +#define fooi18nhfoo + +/*** + 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.1 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 Lesser 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. +***/ + +#if !defined(GETTEXT_PACKAGE) +#error "Something is very wrong here, config.h needs to be included first" +#endif + +#ifdef ENABLE_NLS + +#include + +#define _(String) dgettext(GETTEXT_PACKAGE, String) +#ifdef gettext_noop +#define N_(String) gettext_noop(String) +#else +#define N_(String) (String) +#endif + +#else /* NLS is disabled */ + +#define _(String) (String) +#define N_(String) (String) +#define textdomain(String) (String) +#define gettext(String) (String) +#define dgettext(Domain,String) (String) +#define dcgettext(Domain,String,Type) (String) +#define bindtextdomain(Domain,Directory) (Domain) +#define bind_textdomain_codeset(Domain,Codeset) (Codeset) + +#endif /* ENABLE_NLS */ + +void avahi_init_i18n(void); + +#endif diff --git a/libgamestream/avahi-common/llist.h b/libgamestream/avahi-common/llist.h new file mode 100644 index 00000000..e37056d9 --- /dev/null +++ b/libgamestream/avahi-common/llist.h @@ -0,0 +1,75 @@ +#ifndef foollistfoo +#define foollistfoo + +/*** + 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.1 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 Lesser 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. +***/ + +/** \file llist.h A simple macro based linked list implementation */ + +#include + +#include + +AVAHI_C_DECL_BEGIN + +/** The head of the linked list. Use this in the structure that shall + * contain the head of the linked list */ +#define AVAHI_LLIST_HEAD(t,name) t *name + +/** The pointers in the linked list's items. Use this in the item structure */ +#define AVAHI_LLIST_FIELDS(t,name) t *name##_next, *name##_prev + +/** Initialize the list's head */ +#define AVAHI_LLIST_HEAD_INIT(t,head) do { (head) = NULL; } while(0) + +/** Initialize a list item */ +#define AVAHI_LLIST_INIT(t,name,item) do { \ + t *_item = (item); \ + assert(_item); \ + _item->name##_prev = _item->name##_next = NULL; \ + } while(0) + +/** Prepend an item to the list */ +#define AVAHI_LLIST_PREPEND(t,name,head,item) do { \ + t **_head = &(head), *_item = (item); \ + assert(_item); \ + if ((_item->name##_next = *_head)) \ + _item->name##_next->name##_prev = _item; \ + _item->name##_prev = NULL; \ + *_head = _item; \ + } while (0) + +/** Remove an item from the list */ +#define AVAHI_LLIST_REMOVE(t,name,head,item) do { \ + t **_head = &(head), *_item = (item); \ + assert(_item); \ + if (_item->name##_next) \ + _item->name##_next->name##_prev = _item->name##_prev; \ + if (_item->name##_prev) \ + _item->name##_prev->name##_next = _item->name##_next; \ + else {\ + assert(*_head == _item); \ + *_head = _item->name##_next; \ + } \ + _item->name##_next = _item->name##_prev = NULL; \ + } while(0) + +AVAHI_C_DECL_END + +#endif diff --git a/libgamestream/avahi-common/malloc.c b/libgamestream/avahi-common/malloc.c new file mode 100644 index 00000000..23b13a93 --- /dev/null +++ b/libgamestream/avahi-common/malloc.c @@ -0,0 +1,257 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include + +#include "malloc.h" + +#ifndef va_copy +#ifdef __va_copy +#define va_copy(DEST,SRC) __va_copy((DEST),(SRC)) +#else +#define va_copy(DEST,SRC) memcpy(&(DEST), &(SRC), sizeof(va_list)) +#endif +#endif + +static const AvahiAllocator *allocator = NULL; + +static void oom(void) AVAHI_GCC_NORETURN; + +static void oom(void) { + + static const char msg[] = "Out of memory, aborting ...\n"; + const char *n = msg; + + while (strlen(n) > 0) { + ssize_t r; + + if ((r = write(2, n, strlen(n))) < 0) + break; + + n += r; + } + + abort(); +} + +/* Default implementation for avahi_malloc() */ +static void* xmalloc(size_t size) { + void *p; + + if (size == 0) + return NULL; + + if (!(p = malloc(size))) + oom(); + + return p; +} + +/* Default implementation for avahi_realloc() */ +static void *xrealloc(void *p, size_t size) { + + if (size == 0) { + free(p); + return NULL; + } + + if (!(p = realloc(p, size))) + oom(); + + return p; +} + +/* Default implementation for avahi_calloc() */ +static void *xcalloc(size_t nmemb, size_t size) { + void *p; + + if (size == 0 || nmemb == 0) + return NULL; + + if (!(p = calloc(nmemb, size))) + oom(); + + return p; +} + +void *avahi_malloc(size_t size) { + + if (size <= 0) + return NULL; + + if (!allocator) + return xmalloc(size); + + assert(allocator->malloc); + return allocator->malloc(size); +} + +void *avahi_malloc0(size_t size) { + void *p; + + if (size <= 0) + return NULL; + + if (!allocator) + return xcalloc(1, size); + + if (allocator->calloc) + return allocator->calloc(1, size); + + assert(allocator->malloc); + if ((p = allocator->malloc(size))) + memset(p, 0, size); + + return p; +} + +void avahi_free(void *p) { + + if (!p) + return; + + if (!allocator) { + free(p); + return; + } + + assert(allocator->free); + allocator->free(p); +} + +void *avahi_realloc(void *p, size_t size) { + + if (size == 0) { + avahi_free(p); + return NULL; + } + + if (!allocator) + return xrealloc(p, size); + + assert(allocator->realloc); + return allocator->realloc(p, size); +} + +char *avahi_strdup(const char *s) { + char *r; + size_t size; + + if (!s) + return NULL; + + size = strlen(s); + if (!(r = avahi_malloc(size+1))) + return NULL; + + memcpy(r, s, size+1); + return r; +} + +char *avahi_strndup(const char *s, size_t max) { + char *r; + size_t size; + const char *p; + + if (!s) + return NULL; + + for (p = s, size = 0; + size < max && *p; + p++, size++); + + if (!(r = avahi_new(char, size+1))) + return NULL; + + memcpy(r, s, size); + r[size] = 0; + return r; +} + +/* Change the allocator */ +void avahi_set_allocator(const AvahiAllocator *a) { + allocator = a; +} + +char *avahi_strdup_vprintf(const char *fmt, va_list ap) { + size_t len = 80; + char *buf; + + assert(fmt); + + if (!(buf = avahi_malloc(len))) + return NULL; + + for (;;) { + int n; + char *nbuf; + va_list ap2; + + va_copy (ap2, ap); + n = vsnprintf(buf, len, fmt, ap2); + va_end (ap2); + + if (n >= 0 && n < (int) len) + return buf; + + if (n >= 0) + len = n+1; + else + len *= 2; + + if (!(nbuf = avahi_realloc(buf, len))) { + avahi_free(buf); + return NULL; + } + + buf = nbuf; + } +} + +char *avahi_strdup_printf(const char *fmt, ... ) { + char *s; + va_list ap; + + assert(fmt); + + va_start(ap, fmt); + s = avahi_strdup_vprintf(fmt, ap); + va_end(ap); + + return s; +} + +void *avahi_memdup(const void *s, size_t l) { + void *p; + assert(s); + + if (!(p = avahi_malloc(l))) + return NULL; + + memcpy(p, s, l); + return p; +} diff --git a/libgamestream/avahi-common/malloc.h b/libgamestream/avahi-common/malloc.h new file mode 100644 index 00000000..ffaac3f3 --- /dev/null +++ b/libgamestream/avahi-common/malloc.h @@ -0,0 +1,96 @@ +#ifndef foomallochfoo +#define foomallochfoo + +/*** + 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.1 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 Lesser 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. +***/ + +/** \file malloc.h Memory allocation */ + +#include +#include +#include +#include + +#include +#include + +AVAHI_C_DECL_BEGIN + +/** Allocate some memory, just like the libc malloc() */ +void *avahi_malloc(size_t size) AVAHI_GCC_ALLOC_SIZE(1); + +/** Similar to avahi_malloc() but set the memory to zero */ +void *avahi_malloc0(size_t size) AVAHI_GCC_ALLOC_SIZE(1); + +/** Free some memory */ +void avahi_free(void *p); + +/** Similar to libc's realloc() */ +void *avahi_realloc(void *p, size_t size) AVAHI_GCC_ALLOC_SIZE(2); + +/** Internal helper for avahi_new() */ +static inline void* AVAHI_GCC_ALLOC_SIZE2(1,2) avahi_new_internal(unsigned n, size_t k) { + assert(n < INT_MAX/k); + return avahi_malloc(n*k); +} + +/** Allocate n new structures of the specified type. */ +#define avahi_new(type, n) ((type*) avahi_new_internal((n), sizeof(type))) + +/** Internal helper for avahi_new0() */ +static inline void* AVAHI_GCC_ALLOC_SIZE2(1,2) avahi_new0_internal(unsigned n, size_t k) { + assert(n < INT_MAX/k); + return avahi_malloc0(n*k); +} + +/** Same as avahi_new() but set the memory to zero */ +#define avahi_new0(type, n) ((type*) avahi_new0_internal((n), sizeof(type))) + +/** Just like libc's strdup() */ +char *avahi_strdup(const char *s); + +/** Just like libc's strndup() */ +char *avahi_strndup(const char *s, size_t l); + +/** Duplicate the given memory block into a new one allocated with avahi_malloc() */ +void *avahi_memdup(const void *s, size_t l) AVAHI_GCC_ALLOC_SIZE(2); + +/** Wraps allocator functions */ +typedef struct AvahiAllocator { + void* (*malloc)(size_t size) AVAHI_GCC_ALLOC_SIZE(1); + void (*free)(void *p); + void* (*realloc)(void *p, size_t size) AVAHI_GCC_ALLOC_SIZE(2); + void* (*calloc)(size_t nmemb, size_t size) AVAHI_GCC_ALLOC_SIZE2(1,2); /**< May be NULL */ +} AvahiAllocator; + +/** Change the allocator. May be NULL to return to default (libc) + * allocators. The structure is not copied! */ +void avahi_set_allocator(const AvahiAllocator *a); + +/** Like sprintf() but store the result in a freshly allocated buffer. Free this with avahi_free() */ +char *avahi_strdup_printf(const char *fmt, ... ) AVAHI_GCC_PRINTF_ATTR12; + +/** \cond fulldocs */ +/** Same as avahi_strdup_printf() but take a va_list instead of varargs */ +char *avahi_strdup_vprintf(const char *fmt, va_list ap); +/** \endcond */ + +AVAHI_C_DECL_END + +#endif diff --git a/libgamestream/avahi-common/rlist.c b/libgamestream/avahi-common/rlist.c new file mode 100644 index 00000000..17dcb24a --- /dev/null +++ b/libgamestream/avahi-common/rlist.c @@ -0,0 +1,62 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "rlist.h" +#include "malloc.h" + +AvahiRList* avahi_rlist_prepend(AvahiRList *r, void *data) { + AvahiRList *n; + + if (!(n = avahi_new(AvahiRList, 1))) + return NULL; + + n->data = data; + + AVAHI_LLIST_PREPEND(AvahiRList, rlist, r, n); + return r; +} + +AvahiRList* avahi_rlist_remove(AvahiRList *r, void *data) { + AvahiRList *n; + + for (n = r; n; n = n->rlist_next) + + if (n->data == data) { + AVAHI_LLIST_REMOVE(AvahiRList, rlist, r, n); + avahi_free(n); + break; + } + + return r; +} + +AvahiRList* avahi_rlist_remove_by_link(AvahiRList *r, AvahiRList *n) { + assert(n); + + AVAHI_LLIST_REMOVE(AvahiRList, rlist, r, n); + avahi_free(n); + + return r; +} diff --git a/libgamestream/avahi-common/rlist.h b/libgamestream/avahi-common/rlist.h new file mode 100644 index 00000000..9bcc1d58 --- /dev/null +++ b/libgamestream/avahi-common/rlist.h @@ -0,0 +1,49 @@ +#ifndef foorlistfoo +#define foorlistfoo + +/*** + 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.1 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 Lesser 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. +***/ + +/** \file rlist.h A simple linked list implementation */ + +#include "llist.h" + +AVAHI_C_DECL_BEGIN + +/** A doubly linked list type */ +typedef struct AvahiRList AvahiRList; + +/** A doubly linked list type */ +struct AvahiRList { + AVAHI_LLIST_FIELDS(AvahiRList, rlist); + void *data; +}; + +/** Prepend a new item to the beginning of the list and return the new beginning */ +AvahiRList* avahi_rlist_prepend(AvahiRList *r, void *data); + +/** Remove the first occurence of the specified item from the list and return the new beginning */ +AvahiRList* avahi_rlist_remove(AvahiRList *r, void *data); + +/** Remove the specified item from the list and return the new beginning */ +AvahiRList* avahi_rlist_remove_by_link(AvahiRList *r, AvahiRList *n); + +AVAHI_C_DECL_END + +#endif diff --git a/libgamestream/avahi-common/simple-watch.c b/libgamestream/avahi-common/simple-watch.c new file mode 100644 index 00000000..08d8090c --- /dev/null +++ b/libgamestream/avahi-common/simple-watch.c @@ -0,0 +1,649 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include + +#include "llist.h" +#include "malloc.h" +#include "timeval.h" +#include "simple-watch.h" + +struct AvahiWatch { + AvahiSimplePoll *simple_poll; + int dead; + + int idx; + struct pollfd pollfd; + + AvahiWatchCallback callback; + void *userdata; + + AVAHI_LLIST_FIELDS(AvahiWatch, watches); +}; + +struct AvahiTimeout { + AvahiSimplePoll *simple_poll; + int dead; + + int enabled; + struct timeval expiry; + + AvahiTimeoutCallback callback; + void *userdata; + + AVAHI_LLIST_FIELDS(AvahiTimeout, timeouts); +}; + +struct AvahiSimplePoll { + AvahiPoll api; + AvahiPollFunc poll_func; + void *poll_func_userdata; + + struct pollfd* pollfds; + int n_pollfds, max_pollfds, rebuild_pollfds; + + int watch_req_cleanup, timeout_req_cleanup; + int quit; + int events_valid; + + int n_watches; + AVAHI_LLIST_HEAD(AvahiWatch, watches); + AVAHI_LLIST_HEAD(AvahiTimeout, timeouts); + + int wakeup_pipe[2]; + int wakeup_issued; + + int prepared_timeout; + + enum { + STATE_INIT, + STATE_PREPARING, + STATE_PREPARED, + STATE_RUNNING, + STATE_RAN, + STATE_DISPATCHING, + STATE_DISPATCHED, + STATE_QUIT, + STATE_FAILURE + } state; +}; + +void avahi_simple_poll_wakeup(AvahiSimplePoll *s) { + char c = 'W'; + assert(s); + + write(s->wakeup_pipe[1], &c, sizeof(c)); + s->wakeup_issued = 1; +} + +static void clear_wakeup(AvahiSimplePoll *s) { + char c[10]; /* Read ten at a time */ + + if (!s->wakeup_issued) + return; + + s->wakeup_issued = 0; + + for(;;) + if (read(s->wakeup_pipe[0], &c, sizeof(c)) != sizeof(c)) + break; +} + +static int set_nonblock(int fd) { + int n; + + assert(fd >= 0); + + if ((n = fcntl(fd, F_GETFL)) < 0) + return -1; + + if (n & O_NONBLOCK) + return 0; + + return fcntl(fd, F_SETFL, n|O_NONBLOCK); +} + +static AvahiWatch* watch_new(const AvahiPoll *api, int fd, AvahiWatchEvent event, AvahiWatchCallback callback, void *userdata) { + AvahiWatch *w; + AvahiSimplePoll *s; + + assert(api); + assert(fd >= 0); + assert(callback); + + s = api->userdata; + assert(s); + + if (!(w = avahi_new(AvahiWatch, 1))) + return NULL; + + /* If there is a background thread running the poll() for us, tell it to exit the poll() */ + avahi_simple_poll_wakeup(s); + + w->simple_poll = s; + w->dead = 0; + + w->pollfd.fd = fd; + w->pollfd.events = event; + w->pollfd.revents = 0; + + w->callback = callback; + w->userdata = userdata; + + w->idx = -1; + s->rebuild_pollfds = 1; + + AVAHI_LLIST_PREPEND(AvahiWatch, watches, s->watches, w); + s->n_watches++; + + return w; +} + +static void watch_update(AvahiWatch *w, AvahiWatchEvent events) { + assert(w); + assert(!w->dead); + + /* If there is a background thread running the poll() for us, tell it to exit the poll() */ + avahi_simple_poll_wakeup(w->simple_poll); + + w->pollfd.events = events; + + if (w->idx != -1) { + assert(w->simple_poll); + w->simple_poll->pollfds[w->idx] = w->pollfd; + } else + w->simple_poll->rebuild_pollfds = 1; +} + +static AvahiWatchEvent watch_get_events(AvahiWatch *w) { + assert(w); + assert(!w->dead); + + if (w->idx != -1 && w->simple_poll->events_valid) + return w->simple_poll->pollfds[w->idx].revents; + + return 0; +} + +static void remove_pollfd(AvahiWatch *w) { + assert(w); + + if (w->idx == -1) + return; + + w->simple_poll->rebuild_pollfds = 1; +} + +static void watch_free(AvahiWatch *w) { + assert(w); + + assert(!w->dead); + + /* If there is a background thread running the poll() for us, tell it to exit the poll() */ + avahi_simple_poll_wakeup(w->simple_poll); + + remove_pollfd(w); + + w->dead = 1; + w->simple_poll->n_watches --; + w->simple_poll->watch_req_cleanup = 1; +} + +static void destroy_watch(AvahiWatch *w) { + assert(w); + + remove_pollfd(w); + AVAHI_LLIST_REMOVE(AvahiWatch, watches, w->simple_poll->watches, w); + + if (!w->dead) + w->simple_poll->n_watches --; + + avahi_free(w); +} + +static void cleanup_watches(AvahiSimplePoll *s, int all) { + AvahiWatch *w, *next; + assert(s); + + for (w = s->watches; w; w = next) { + next = w->watches_next; + + if (all || w->dead) + destroy_watch(w); + } + + s->timeout_req_cleanup = 0; +} + +static AvahiTimeout* timeout_new(const AvahiPoll *api, const struct timeval *tv, AvahiTimeoutCallback callback, void *userdata) { + AvahiTimeout *t; + AvahiSimplePoll *s; + + assert(api); + assert(callback); + + s = api->userdata; + assert(s); + + if (!(t = avahi_new(AvahiTimeout, 1))) + return NULL; + + /* If there is a background thread running the poll() for us, tell it to exit the poll() */ + avahi_simple_poll_wakeup(s); + + t->simple_poll = s; + t->dead = 0; + + if ((t->enabled = !!tv)) + t->expiry = *tv; + + t->callback = callback; + t->userdata = userdata; + + AVAHI_LLIST_PREPEND(AvahiTimeout, timeouts, s->timeouts, t); + return t; +} + +static void timeout_update(AvahiTimeout *t, const struct timeval *tv) { + assert(t); + assert(!t->dead); + + /* If there is a background thread running the poll() for us, tell it to exit the poll() */ + avahi_simple_poll_wakeup(t->simple_poll); + + if ((t->enabled = !!tv)) + t->expiry = *tv; +} + +static void timeout_free(AvahiTimeout *t) { + assert(t); + assert(!t->dead); + + /* If there is a background thread running the poll() for us, tell it to exit the poll() */ + avahi_simple_poll_wakeup(t->simple_poll); + + t->dead = 1; + t->simple_poll->timeout_req_cleanup = 1; +} + + +static void destroy_timeout(AvahiTimeout *t) { + assert(t); + + AVAHI_LLIST_REMOVE(AvahiTimeout, timeouts, t->simple_poll->timeouts, t); + + avahi_free(t); +} + +static void cleanup_timeouts(AvahiSimplePoll *s, int all) { + AvahiTimeout *t, *next; + assert(s); + + for (t = s->timeouts; t; t = next) { + next = t->timeouts_next; + + if (all || t->dead) + destroy_timeout(t); + } + + s->timeout_req_cleanup = 0; +} + +AvahiSimplePoll *avahi_simple_poll_new(void) { + AvahiSimplePoll *s; + + if (!(s = avahi_new(AvahiSimplePoll, 1))) + return NULL; + + if (pipe(s->wakeup_pipe) < 0) { + avahi_free(s); + return NULL; + } + + set_nonblock(s->wakeup_pipe[0]); + set_nonblock(s->wakeup_pipe[1]); + + s->api.userdata = s; + + s->api.watch_new = watch_new; + s->api.watch_free = watch_free; + s->api.watch_update = watch_update; + s->api.watch_get_events = watch_get_events; + + s->api.timeout_new = timeout_new; + s->api.timeout_free = timeout_free; + s->api.timeout_update = timeout_update; + + s->pollfds = NULL; + s->max_pollfds = s->n_pollfds = 0; + s->rebuild_pollfds = 1; + s->quit = 0; + s->n_watches = 0; + s->events_valid = 0; + + s->watch_req_cleanup = 0; + s->timeout_req_cleanup = 0; + + s->prepared_timeout = 0; + + s->state = STATE_INIT; + + s->wakeup_issued = 0; + + avahi_simple_poll_set_func(s, NULL, NULL); + + AVAHI_LLIST_HEAD_INIT(AvahiWatch, s->watches); + AVAHI_LLIST_HEAD_INIT(AvahiTimeout, s->timeouts); + + return s; +} + +void avahi_simple_poll_free(AvahiSimplePoll *s) { + assert(s); + + cleanup_timeouts(s, 1); + cleanup_watches(s, 1); + assert(s->n_watches == 0); + + avahi_free(s->pollfds); + + if (s->wakeup_pipe[0] >= 0) + close(s->wakeup_pipe[0]); + + if (s->wakeup_pipe[1] >= 0) + close(s->wakeup_pipe[1]); + + avahi_free(s); +} + +static int rebuild(AvahiSimplePoll *s) { + AvahiWatch *w; + int idx; + + assert(s); + + if (s->n_watches+1 > s->max_pollfds) { + struct pollfd *n; + + s->max_pollfds = s->n_watches + 10; + + if (!(n = avahi_realloc(s->pollfds, sizeof(struct pollfd) * s->max_pollfds))) + return -1; + + s->pollfds = n; + } + + + s->pollfds[0].fd = s->wakeup_pipe[0]; + s->pollfds[0].events = POLLIN; + s->pollfds[0].revents = 0; + + idx = 1; + + for (w = s->watches; w; w = w->watches_next) { + + if(w->dead) + continue; + + assert(w->idx < s->max_pollfds); + s->pollfds[w->idx = idx++] = w->pollfd; + } + + s->n_pollfds = idx; + s->events_valid = 0; + s->rebuild_pollfds = 0; + + return 0; +} + +static AvahiTimeout* find_next_timeout(AvahiSimplePoll *s) { + AvahiTimeout *t, *n = NULL; + assert(s); + + for (t = s->timeouts; t; t = t->timeouts_next) { + + if (t->dead || !t->enabled) + continue; + + if (!n || avahi_timeval_compare(&t->expiry, &n->expiry) < 0) + n = t; + } + + return n; +} + +static void timeout_callback(AvahiTimeout *t) { + assert(t); + assert(!t->dead); + assert(t->enabled); + + t->enabled = 0; + t->callback(t, t->userdata); +} + +int avahi_simple_poll_prepare(AvahiSimplePoll *s, int timeout) { + AvahiTimeout *next_timeout; + + assert(s); + assert(s->state == STATE_INIT || s->state == STATE_DISPATCHED || s->state == STATE_FAILURE); + s->state = STATE_PREPARING; + + /* Clear pending wakeup requests */ + clear_wakeup(s); + + /* Cleanup things first */ + if (s->watch_req_cleanup) + cleanup_watches(s, 0); + + if (s->timeout_req_cleanup) + cleanup_timeouts(s, 0); + + /* Check whether a quit was requested */ + if (s->quit) { + s->state = STATE_QUIT; + return 1; + } + + /* Do we need to rebuild our array of pollfds? */ + if (s->rebuild_pollfds) + if (rebuild(s) < 0) { + s->state = STATE_FAILURE; + return -1; + } + + /* Calculate the wakeup time */ + if ((next_timeout = find_next_timeout(s))) { + struct timeval now; + int t; + AvahiUsec usec; + + if (next_timeout->expiry.tv_sec == 0 && + next_timeout->expiry.tv_usec == 0) { + + /* Just a shortcut so that we don't need to call gettimeofday() */ + timeout = 0; + goto finish; + } + + gettimeofday(&now, NULL); + usec = avahi_timeval_diff(&next_timeout->expiry, &now); + + if (usec <= 0) { + /* Timeout elapsed */ + + timeout = 0; + goto finish; + } + + /* Calculate sleep time. We add 1ms because otherwise we'd + * wake up too early most of the time */ + t = (int) (usec / 1000) + 1; + + if (timeout < 0 || timeout > t) + timeout = t; + } + +finish: + s->prepared_timeout = timeout; + s->state = STATE_PREPARED; + return 0; +} + +int avahi_simple_poll_run(AvahiSimplePoll *s) { + assert(s); + assert(s->state == STATE_PREPARED || s->state == STATE_FAILURE); + + s->state = STATE_RUNNING; + + for (;;) { + errno = 0; + + if (s->poll_func(s->pollfds, s->n_pollfds, s->prepared_timeout, s->poll_func_userdata) < 0) { + + if (errno == EINTR) + continue; + + s->state = STATE_FAILURE; + return -1; + } + + break; + } + + /* The poll events are now valid again */ + s->events_valid = 1; + + /* Update state */ + s->state = STATE_RAN; + return 0; +} + +int avahi_simple_poll_dispatch(AvahiSimplePoll *s) { + AvahiTimeout *next_timeout; + AvahiWatch *w; + + assert(s); + assert(s->state == STATE_RAN); + s->state = STATE_DISPATCHING; + + /* We execute only on callback in every iteration */ + + /* Check whether the wakeup time has been reached now */ + if ((next_timeout = find_next_timeout(s))) { + + if (next_timeout->expiry.tv_sec == 0 && next_timeout->expiry.tv_usec == 0) { + + /* Just a shortcut so that we don't need to call gettimeofday() */ + timeout_callback(next_timeout); + goto finish; + } + + if (avahi_age(&next_timeout->expiry) >= 0) { + + /* Timeout elapsed */ + timeout_callback(next_timeout); + goto finish; + } + } + + /* Look for some kind of I/O event */ + for (w = s->watches; w; w = w->watches_next) { + + if (w->dead) + continue; + + assert(w->idx >= 0); + assert(w->idx < s->n_pollfds); + + if (s->pollfds[w->idx].revents != 0) { + w->callback(w, w->pollfd.fd, s->pollfds[w->idx].revents, w->userdata); + goto finish; + } + } + +finish: + + s->state = STATE_DISPATCHED; + return 0; +} + +int avahi_simple_poll_iterate(AvahiSimplePoll *s, int timeout) { + int r; + + if ((r = avahi_simple_poll_prepare(s, timeout)) != 0) + return r; + + if ((r = avahi_simple_poll_run(s)) != 0) + return r; + + if ((r = avahi_simple_poll_dispatch(s)) != 0) + return r; + + return 0; +} + +void avahi_simple_poll_quit(AvahiSimplePoll *s) { + assert(s); + + s->quit = 1; + + /* If there is a background thread running the poll() for us, tell it to exit the poll() */ + avahi_simple_poll_wakeup(s); +} + +const AvahiPoll* avahi_simple_poll_get(AvahiSimplePoll *s) { + assert(s); + + return &s->api; +} + +static int system_poll(struct pollfd *ufds, unsigned int nfds, int timeout, AVAHI_GCC_UNUSED void *userdata) { + return poll(ufds, nfds, timeout); +} + +void avahi_simple_poll_set_func(AvahiSimplePoll *s, AvahiPollFunc func, void *userdata) { + assert(s); + + s->poll_func = func ? func : system_poll; + s->poll_func_userdata = func ? userdata : NULL; + + /* If there is a background thread running the poll() for us, tell it to exit the poll() */ + avahi_simple_poll_wakeup(s); +} + +int avahi_simple_poll_loop(AvahiSimplePoll *s) { + int r; + + assert(s); + + for (;;) + if ((r = avahi_simple_poll_iterate(s, -1)) != 0) + if (r >= 0 || errno != EINTR) + return r; +} diff --git a/libgamestream/avahi-common/simple-watch.h b/libgamestream/avahi-common/simple-watch.h new file mode 100644 index 00000000..db871228 --- /dev/null +++ b/libgamestream/avahi-common/simple-watch.h @@ -0,0 +1,85 @@ +#ifndef foosimplewatchhfoo +#define foosimplewatchhfoo + +/*** + 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.1 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 Lesser 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. +***/ + +/** \file simple-watch.h Simple poll() based main loop implementation */ + +#include +#include +#include + +AVAHI_C_DECL_BEGIN + +/** A main loop object. Main loops of this type aren't very flexible + * since they only support a single wakeup type. Nevertheless it + * should suffice for small test and example applications. */ +typedef struct AvahiSimplePoll AvahiSimplePoll; + +/** Create a new main loop object */ +AvahiSimplePoll *avahi_simple_poll_new(void); + +/** Free a main loop object */ +void avahi_simple_poll_free(AvahiSimplePoll *s); + +/** Return the abstracted poll API object for this main loop + * object. The is will return the same pointer each time it is + * called. */ +const AvahiPoll* avahi_simple_poll_get(AvahiSimplePoll *s); + +/** Run a single main loop iteration of this main loop. If sleep_time +is < 0 this will block until any of the registered events happens, +then it will execute the attached callback function. If sleep_time is +0 the routine just checks if any event is pending. If yes the attached +callback function is called, otherwise the function returns +immediately. If sleep_time > 0 the function will block for at most the +specified time in msecs. Returns -1 on error, 0 on success and 1 if a +quit request has been scheduled. Usually this function should be called +in a loop until it returns a non-zero value*/ +int avahi_simple_poll_iterate(AvahiSimplePoll *s, int sleep_time); + +/** Request that the main loop quits. If this is called the next + call to avahi_simple_poll_iterate() will return 1 */ +void avahi_simple_poll_quit(AvahiSimplePoll *s); + +/** Prototype for a poll() type function */ +typedef int (*AvahiPollFunc)(struct pollfd *ufds, unsigned int nfds, int timeout, void *userdata); + +/** Replace the internally used poll() function. By default the system's poll() will be used */ +void avahi_simple_poll_set_func(AvahiSimplePoll *s, AvahiPollFunc func, void *userdata); + +/** The first stage of avahi_simple_poll_iterate(), use this function only if you know what you do */ +int avahi_simple_poll_prepare(AvahiSimplePoll *s, int timeout); + +/** The second stage of avahi_simple_poll_iterate(), use this function only if you know what you do */ +int avahi_simple_poll_run(AvahiSimplePoll *s); + +/** The third and final stage of avahi_simple_poll_iterate(), use this function only if you know what you do */ +int avahi_simple_poll_dispatch(AvahiSimplePoll *s); + +/** Call avahi_simple_poll_iterate() in a loop and return if it returns non-zero */ +int avahi_simple_poll_loop(AvahiSimplePoll *s); + +/** Wakeup the main loop. (for threaded environments) */ +void avahi_simple_poll_wakeup(AvahiSimplePoll *s); + +AVAHI_C_DECL_END + +#endif diff --git a/libgamestream/avahi-common/strlst-test.c b/libgamestream/avahi-common/strlst-test.c new file mode 100644 index 00000000..4c1ad9d1 --- /dev/null +++ b/libgamestream/avahi-common/strlst-test.c @@ -0,0 +1,128 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include "strlst.h" +#include "malloc.h" + +int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { + char *t, *v; + uint8_t data[1024]; + AvahiStringList *a = NULL, *b, *p; + size_t size, n; + int r; + + a = avahi_string_list_new("prefix", "a", "b", NULL); + + a = avahi_string_list_add(a, "start"); + a = avahi_string_list_add(a, "foo=99"); + a = avahi_string_list_add(a, "bar"); + a = avahi_string_list_add(a, ""); + a = avahi_string_list_add(a, ""); + a = avahi_string_list_add(a, "quux"); + a = avahi_string_list_add(a, ""); + a = avahi_string_list_add_arbitrary(a, (const uint8_t*) "null\0null", 9); + a = avahi_string_list_add_printf(a, "seven=%i %c", 7, 'x'); + a = avahi_string_list_add_pair(a, "blubb", "blaa"); + a = avahi_string_list_add_pair(a, "uxknurz", NULL); + a = avahi_string_list_add_pair_arbitrary(a, "uxknurz2", (const uint8_t*) "blafasel\0oerks", 14); + a = avahi_string_list_add(a, "i am a \"string\" with embedded double-quotes (\\\")\nand newlines (\\n)."); + + a = avahi_string_list_add(a, "end"); + + t = avahi_string_list_to_string(a); + printf("--%s--\n", t); + avahi_free(t); + + n = avahi_string_list_serialize(a, NULL, 0); + size = avahi_string_list_serialize(a, data, sizeof(data)); + assert(size == n); + + printf("%zu\n", size); + + for (t = (char*) data, n = 0; n < size; n++, t++) { + if (*t <= 32) + printf("(%u)", *t); + else + printf("%c", *t); + } + + printf("\n"); + + assert(avahi_string_list_parse(data, size, &b) == 0); + + printf("equal: %i\n", avahi_string_list_equal(a, b)); + + t = avahi_string_list_to_string(b); + printf("--%s--\n", t); + avahi_free(t); + + avahi_string_list_free(b); + + b = avahi_string_list_copy(a); + + assert(avahi_string_list_equal(a, b)); + + t = avahi_string_list_to_string(b); + printf("--%s--\n", t); + avahi_free(t); + + p = avahi_string_list_find(a, "seven"); + assert(p); + + r = avahi_string_list_get_pair(p, &t, &v, NULL); + assert(r >= 0); + assert(t); + assert(v); + + printf("<%s>=<%s>\n", t, v); + avahi_free(t); + avahi_free(v); + + p = avahi_string_list_find(a, "quux"); + assert(p); + + r = avahi_string_list_get_pair(p, &t, &v, NULL); + assert(r >= 0); + assert(t); + assert(!v); + + printf("<%s>=<%s>\n", t, v); + avahi_free(t); + avahi_free(v); + + avahi_string_list_free(a); + avahi_string_list_free(b); + + n = avahi_string_list_serialize(NULL, NULL, 0); + size = avahi_string_list_serialize(NULL, data, sizeof(data)); + assert(size == 1); + assert(size == n); + + assert(avahi_string_list_parse(data, size, &a) == 0); + assert(!a); + + return 0; +} diff --git a/libgamestream/avahi-common/strlst.c b/libgamestream/avahi-common/strlst.c new file mode 100644 index 00000000..f09ec388 --- /dev/null +++ b/libgamestream/avahi-common/strlst.c @@ -0,0 +1,565 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include + +#include "strlst.h" +#include "malloc.h" +#include "defs.h" + +AvahiStringList*avahi_string_list_add_anonymous(AvahiStringList *l, size_t size) { + AvahiStringList *n; + + if (!(n = avahi_malloc(sizeof(AvahiStringList) + size))) + return NULL; + + n->next = l; + n->size = size; + + /* NUL terminate strings, just to make sure */ + n->text[size] = 0; + + return n; +} + +AvahiStringList *avahi_string_list_add_arbitrary(AvahiStringList *l, const uint8_t*text, size_t size) { + AvahiStringList *n; + + assert(size == 0 || text); + + if (!(n = avahi_string_list_add_anonymous(l, size))) + return NULL; + + if (size > 0) + memcpy(n->text, text, size); + + return n; +} + +AvahiStringList *avahi_string_list_add(AvahiStringList *l, const char *text) { + assert(text); + + return avahi_string_list_add_arbitrary(l, (const uint8_t*) text, strlen(text)); +} + +int avahi_string_list_parse(const void* data, size_t size, AvahiStringList **ret) { + const uint8_t *c; + AvahiStringList *r = NULL; + + assert(data); + assert(ret); + + c = data; + while (size > 0) { + size_t k; + + k = *(c++); + size--; + + if (k > size) + goto fail; /* Overflow */ + + if (k > 0) { /* Ignore empty strings */ + AvahiStringList *n; + + if (!(n = avahi_string_list_add_arbitrary(r, c, k))) + goto fail; /* OOM */ + + r = n; + } + + c += k; + size -= k; + } + + *ret = r; + + return 0; + +fail: + avahi_string_list_free(r); + return -1; +} + +void avahi_string_list_free(AvahiStringList *l) { + AvahiStringList *n; + + while (l) { + n = l->next; + avahi_free(l); + l = n; + } +} + +AvahiStringList* avahi_string_list_reverse(AvahiStringList *l) { + AvahiStringList *r = NULL, *n; + + while (l) { + n = l->next; + l->next = r; + r = l; + l = n; + } + + return r; +} + +/** + * This routine is used for both human- and machine-readable output of + * TXT records. As such it must cope with escaping, in order to allow + * machines to reconstruct the original data. + * + * AFAIK no RFC specifies syntax for TXT data other than raw binary, + * though presumably zonefile syntax would make sense: + * + * - RFC 1035 says that TXT records contain ``s, and section + * 5 says: + * + * is expressed in one or two ways: as a contiguous set + * of characters without interior spaces, or as a string beginning with a " + * and ending with a ". Inside a " delimited string any character can + * occur, except for a " itself, which must be quoted using \ (back slash). + * + * This omits escaping of backslashes (!). + * + * - RFC 1034 doesn't say anything relevant. + * + * - RFC 1464 suggests a specific encoding of information within a TXT + * record but does not discuss formatting of TXT records in + * general. + * + * In order to also escape newlines, which interfere with line-by-line + * machine processing of records, this routine: + * + * - escapes >>> " <<< to >>> \" <<< + * - escapes >>> \ <<< to >>> \\ <<< + * - escapes bytes less than 32 to backslash-prefixed 3-digit DECIMAL form + */ +char* avahi_string_list_to_string(AvahiStringList *l) { + AvahiStringList *n; + size_t s = 0; + char *p, *t, *e; + + for (n = l; n; n = n->next) { + if (n != l) + s ++; /* for the inter-string separating space */ + + for (p = (char*) n->text; ((size_t) (p - (char*) n->text) < n->size); p++) { + switch (*p) { + case '"': + case '\\': + s += 2; + break; + default: + if (*p < 32) { + s += 4; + } else { + s ++; + break; + } + } + } + s += 2; /* for the leading and trailing double-quotes */ + } + + if (!(t = e = avahi_new(char, s+1))) /* plus one for the trailing NUL */ + return NULL; + + l = avahi_string_list_reverse(l); + + for (n = l; n; n = n->next) { + if (n != l) + *(e++) = ' '; + + *(e++) = '"'; + for (p = (char*) n->text; ((size_t) (p - (char*) n->text) < n->size); p++) { + switch (*p) { + case '"': + case '\\': + *(e++) = '\\'; + /* FALL THROUGH */ + default: + if (*p < 32) { + *(e++) = '\\'; + *(e++) = '0' + (char) ((uint8_t) *p / 100); + *(e++) = '0' + (char) (((uint8_t) *p / 10) % 10); + *(e++) = '0' + (char) ((uint8_t) *p % 10); + } else { + *(e++) = *p; + } + } + } + *(e++) = '"'; + + assert(e); + } + + l = avahi_string_list_reverse(l); + + *e = 0; + + return t; +} + +size_t avahi_string_list_serialize(AvahiStringList *l, void *data, size_t size) { + size_t used = 0; + + if (data) { + AvahiStringList *n; + uint8_t *c; + + l = avahi_string_list_reverse(l); + c = data; + + for (n = l; size > 1 && n; n = n->next) { + size_t k; + + if ((k = n->size) == 0) + /* Skip empty strings */ + continue; + + if (k > 255) + /* Truncate strings at 255 characters */ + k = 255; + + if (k > size-1) + /* Make sure this string fits in */ + k = size-1; + + *(c++) = (uint8_t) k; + memcpy(c, n->text, k); + c += k; + + used += 1 + k; + size -= 1 + k; + } + + l = avahi_string_list_reverse(l); + + if (used == 0 && size > 0) { + + /* Empty lists are treated specially. To comply with + * section 6.1 of the DNS-SD spec, we return a single + * empty string (i.e. a NUL byte)*/ + + *(uint8_t*) data = 0; + used = 1; + } + + } else { + AvahiStringList *n; + + for (n = l; n; n = n->next) { + size_t k; + + if ((k = n->size) == 0) + continue; + + if (k > 255) + k = 255; + + used += 1+k; + } + + if (used == 0) + used = 1; + } + + return used; +} + +int avahi_string_list_equal(const AvahiStringList *a, const AvahiStringList *b) { + + for (;;) { + if (!a && !b) + return 1; + + if (!a || !b) + return 0; + + if (a->size != b->size) + return 0; + + if (a->size != 0 && memcmp(a->text, b->text, a->size) != 0) + return 0; + + a = a->next; + b = b->next; + } +} + +AvahiStringList *avahi_string_list_add_many(AvahiStringList *r, ...) { + va_list va; + + va_start(va, r); + r = avahi_string_list_add_many_va(r, va); + va_end(va); + + return r; +} + +AvahiStringList *avahi_string_list_add_many_va(AvahiStringList *r, va_list va) { + const char *txt; + + while ((txt = va_arg(va, const char*))) + r = avahi_string_list_add(r, txt); + + return r; +} + +AvahiStringList *avahi_string_list_new(const char *txt, ...) { + va_list va; + AvahiStringList *r = NULL; + + if (txt) { + r = avahi_string_list_add(r, txt); + + va_start(va, txt); + r = avahi_string_list_add_many_va(r, va); + va_end(va); + } + + return r; +} + +AvahiStringList *avahi_string_list_new_va(va_list va) { + return avahi_string_list_add_many_va(NULL, va); +} + +AvahiStringList *avahi_string_list_copy(const AvahiStringList *l) { + AvahiStringList *r = NULL; + + for (; l; l = l->next) + if (!(r = avahi_string_list_add_arbitrary(r, l->text, l->size))) { + avahi_string_list_free(r); + return NULL; + } + + return avahi_string_list_reverse(r); +} + +AvahiStringList *avahi_string_list_new_from_array(const char *array[], int length) { + AvahiStringList *r = NULL; + int i; + + assert(array); + + for (i = 0; length >= 0 ? i < length : !!array[i]; i++) + r = avahi_string_list_add(r, array[i]); + + return r; +} + +unsigned avahi_string_list_length(const AvahiStringList *l) { + unsigned n = 0; + + for (; l; l = l->next) + n++; + + return n; +} + +AvahiStringList *avahi_string_list_add_vprintf(AvahiStringList *l, const char *format, va_list va) { + size_t len = 80; + AvahiStringList *r; + + assert(format); + + if (!(r = avahi_malloc(sizeof(AvahiStringList) + len))) + return NULL; + + for (;;) { + int n; + AvahiStringList *nr; + va_list va2; + + va_copy(va2, va); + n = vsnprintf((char*) r->text, len, format, va2); + va_end(va2); + + if (n >= 0 && n < (int) len) + break; + + if (n >= 0) + len = n+1; + else + len *= 2; + + if (!(nr = avahi_realloc(r, sizeof(AvahiStringList) + len))) { + avahi_free(r); + return NULL; + } + + r = nr; + } + + r->next = l; + r->size = strlen((char*) r->text); + + return r; +} + +AvahiStringList *avahi_string_list_add_printf(AvahiStringList *l, const char *format, ...) { + va_list va; + + assert(format); + + va_start(va, format); + l = avahi_string_list_add_vprintf(l, format, va); + va_end(va); + + return l; +} + +AvahiStringList *avahi_string_list_find(AvahiStringList *l, const char *key) { + size_t n; + + assert(key); + n = strlen(key); + + for (; l; l = l->next) { + if (strcasecmp((char*) l->text, key) == 0) + return l; + + if (strncasecmp((char*) l->text, key, n) == 0 && l->text[n] == '=') + return l; + } + + return NULL; +} + +AvahiStringList *avahi_string_list_add_pair(AvahiStringList *l, const char *key, const char *value) { + assert(key); + + if (value) + return avahi_string_list_add_printf(l, "%s=%s", key, value); + else + return avahi_string_list_add(l, key); +} + +AvahiStringList *avahi_string_list_add_pair_arbitrary(AvahiStringList *l, const char *key, const uint8_t *value, size_t size) { + size_t n; + assert(key); + + if (!value) + return avahi_string_list_add(l, key); + + n = strlen(key); + + if (!(l = avahi_string_list_add_anonymous(l, n + 1 + size))) + return NULL; + + memcpy(l->text, key, n); + l->text[n] = '='; + memcpy(l->text + n + 1, value, size); + + return l; +} + +int avahi_string_list_get_pair(AvahiStringList *l, char **key, char **value, size_t *size) { + char *e; + + assert(l); + + if (!(e = memchr(l->text, '=', l->size))) { + + if (key) + if (!(*key = avahi_strdup((char*) l->text))) + return -1; + + if (value) + *value = NULL; + + if (size) + *size = 0; + + } else { + size_t n; + + if (key) + if (!(*key = avahi_strndup((char*) l->text, e - (char *) l->text))) + return -1; + + e++; /* Advance after '=' */ + + n = l->size - (e - (char*) l->text); + + if (value) { + + if (!(*value = avahi_memdup(e, n+1))) { + if (key) + avahi_free(*key); + return -1; + } + + (*value)[n] = 0; + } + + if (size) + *size = n; + } + + return 0; +} + +AvahiStringList *avahi_string_list_get_next(AvahiStringList *l) { + assert(l); + return l->next; +} + +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; +} + +uint32_t avahi_string_list_get_service_cookie(AvahiStringList *l) { + AvahiStringList *f; + char *value = NULL, *end = NULL; + uint32_t ret; + + if (!(f = avahi_string_list_find(l, AVAHI_SERVICE_COOKIE))) + return AVAHI_SERVICE_COOKIE_INVALID; + + if (avahi_string_list_get_pair(f, NULL, &value, NULL) < 0 || !value) + return AVAHI_SERVICE_COOKIE_INVALID; + + ret = (uint32_t) strtoll(value, &end, 0); + + if (*value && end && *end != 0) { + avahi_free(value); + return AVAHI_SERVICE_COOKIE_INVALID; + } + + avahi_free(value); + + return ret; +} diff --git a/libgamestream/avahi-common/strlst.h b/libgamestream/avahi-common/strlst.h new file mode 100644 index 00000000..94adcea8 --- /dev/null +++ b/libgamestream/avahi-common/strlst.h @@ -0,0 +1,180 @@ +#ifndef footxtlisthfoo +#define footxtlisthfoo + +/*** + 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.1 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 Lesser 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. +***/ + +/** \file strlst.h Implementation of a data type to store lists of strings */ + +#include +#include +#include + +#include +#include + +AVAHI_C_DECL_BEGIN + +/** Linked list of strings that can contain any number of binary + * characters, including NUL bytes. An empty list is created by + * assigning a NULL to a pointer to AvahiStringList. The string list + * is stored in reverse order, so that appending to the string list is + * effectively a prepending to the linked list. This object is used + * primarily for storing DNS TXT record data. */ +typedef struct AvahiStringList { + struct AvahiStringList *next; /**< Pointer to the next linked list element */ + size_t size; /**< Size of text[] */ + uint8_t text[1]; /**< Character data */ +} AvahiStringList; + +/** @{ \name Construction and destruction */ + +/** Create a new string list by taking a variable list of NUL + * terminated strings. The strings are copied using g_strdup(). The + * argument list must be terminated by a NULL pointer. */ +AvahiStringList *avahi_string_list_new(const char *txt, ...) AVAHI_GCC_SENTINEL; + +/** \cond fulldocs */ +/** Same as avahi_string_list_new() but pass a va_list structure */ +AvahiStringList *avahi_string_list_new_va(va_list va); +/** \endcond */ + +/** Create a new string list from a string array. The strings are + * copied using g_strdup(). length should contain the length of the + * array, or -1 if the array is NULL terminated*/ +AvahiStringList *avahi_string_list_new_from_array(const char **array, int length); + +/** Free a string list */ +void avahi_string_list_free(AvahiStringList *l); + +/** @} */ + +/** @{ \name Adding strings */ + +/** Append a NUL terminated string to the specified string list. The + * passed string is copied using g_strdup(). Returns the new list + * start. */ +AvahiStringList *avahi_string_list_add(AvahiStringList *l, const char *text); + +/** Append a new NUL terminated formatted string to the specified string list */ +AvahiStringList *avahi_string_list_add_printf(AvahiStringList *l, const char *format, ...) AVAHI_GCC_PRINTF_ATTR23; + +/** \cond fulldocs */ +/** Append a new NUL terminated formatted string to the specified string list */ +AvahiStringList *avahi_string_list_add_vprintf(AvahiStringList *l, const char *format, va_list va); +/** \endcond */ + +/** Append an arbitrary length byte string to the list. Returns the + * new list start. */ +AvahiStringList *avahi_string_list_add_arbitrary(AvahiStringList *l, const uint8_t *text, size_t size); + +/** Append a new entry to the string list. The string is not filled +with data. The caller should fill in string data afterwards by writing +it to l->text, where l is the pointer returned by this function. This +function exists solely to optimize a few operations where otherwise +superfluous string copying would be necessary. */ +AvahiStringList*avahi_string_list_add_anonymous(AvahiStringList *l, size_t size); + +/** Same as avahi_string_list_add(), but takes a variable number of + * NUL terminated strings. The argument list must be terminated by a + * NULL pointer. Returns the new list start. */ +AvahiStringList *avahi_string_list_add_many(AvahiStringList *r, ...) AVAHI_GCC_SENTINEL; + +/** \cond fulldocs */ +/** Same as avahi_string_list_add_many(), but use a va_list + * structure. Returns the new list start. */ +AvahiStringList *avahi_string_list_add_many_va(AvahiStringList *r, va_list va); +/** \endcond */ + +/** @} */ + +/** @{ \name String list operations */ + +/** Convert the string list object to a single character string, + * seperated by spaces and enclosed in "". avahi_free() the result! This + * function doesn't work well with strings that contain NUL bytes. */ +char* avahi_string_list_to_string(AvahiStringList *l); + +/** \cond fulldocs */ +/** Serialize the string list object in a way that is compatible with + * the storing of DNS TXT records. Strings longer than 255 bytes are truncated. */ +size_t avahi_string_list_serialize(AvahiStringList *l, void * data, size_t size); + +/** Inverse of avahi_string_list_serialize() */ +int avahi_string_list_parse(const void *data, size_t size, AvahiStringList **ret); +/** \endcond */ + +/** Compare to string lists */ +int avahi_string_list_equal(const AvahiStringList *a, const AvahiStringList *b); + +/** Copy a string list */ +AvahiStringList *avahi_string_list_copy(const AvahiStringList *l); + +/** Reverse the string list. */ +AvahiStringList* avahi_string_list_reverse(AvahiStringList *l); + +/** Return the number of elements in the string list */ +unsigned avahi_string_list_length(const AvahiStringList *l); + +/** @} */ + +/** @{ \name Accessing items */ + +/** Returns the next item in the string list */ +AvahiStringList *avahi_string_list_get_next(AvahiStringList *l); + +/** Returns the text for the current item */ +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); + +/** @} */ + +/** @{ \name DNS-SD TXT pair handling */ + +/** Find the string list entry for the given DNS-SD TXT key */ +AvahiStringList *avahi_string_list_find(AvahiStringList *l, const char *key); + +/** Return the DNS-SD TXT key and value for the specified string list + * item. If size is not NULL it will be filled with the length of + * value. (for strings containing NUL bytes). If the entry doesn't + * contain a value *value will be set to NULL. You need to + * avahi_free() the strings returned in *key and *value. */ +int avahi_string_list_get_pair(AvahiStringList *l, char **key, char **value, size_t *size); + +/** Add a new DNS-SD TXT key value pair to the string list. value may + * be NULL in case you want to specify a key without a value */ +AvahiStringList *avahi_string_list_add_pair(AvahiStringList *l, const char *key, const char *value); + +/** 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); + +/** @} */ + +/** \cond fulldocs */ +/** Try to find a magic service cookie in the specified DNS-SD string + * list. Or return AVAHI_SERVICE_COOKIE_INVALID if none is found. */ +uint32_t avahi_string_list_get_service_cookie(AvahiStringList *l); +/** \endcond */ + +AVAHI_C_DECL_END + +#endif + diff --git a/libgamestream/avahi-common/thread-watch.c b/libgamestream/avahi-common/thread-watch.c new file mode 100644 index 00000000..ecb202bd --- /dev/null +++ b/libgamestream/avahi-common/thread-watch.c @@ -0,0 +1,186 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "llist.h" +#include "malloc.h" +#include "timeval.h" +#include "simple-watch.h" +#include "thread-watch.h" + +struct AvahiThreadedPoll { + AvahiSimplePoll *simple_poll; + pthread_t thread_id; + pthread_mutex_t mutex; + int thread_running; + int retval; +}; + +static int poll_func(struct pollfd *ufds, unsigned int nfds, int timeout, void *userdata) { + pthread_mutex_t *mutex = userdata; + int r; + + /* Before entering poll() we unlock the mutex, so that + * avahi_simple_poll_quit() can succeed from another thread. */ + + pthread_mutex_unlock(mutex); + r = poll(ufds, nfds, timeout); + pthread_mutex_lock(mutex); + + return r; +} + +static void* thread(void *userdata){ + AvahiThreadedPoll *p = userdata; + sigset_t mask; + + /* Make sure that signals are delivered to the main thread */ + sigfillset(&mask); + pthread_sigmask(SIG_BLOCK, &mask, NULL); + + pthread_mutex_lock(&p->mutex); + p->retval = avahi_simple_poll_loop(p->simple_poll); + pthread_mutex_unlock(&p->mutex); + + return NULL; +} + +AvahiThreadedPoll *avahi_threaded_poll_new(void) { + AvahiThreadedPoll *p; + + if (!(p = avahi_new(AvahiThreadedPoll, 1))) + goto fail; /* OOM */ + + if (!(p->simple_poll = avahi_simple_poll_new())) + goto fail; + + pthread_mutex_init(&p->mutex, NULL); + + avahi_simple_poll_set_func(p->simple_poll, poll_func, &p->mutex); + + p->thread_running = 0; + + return p; + +fail: + if (p) { + if (p->simple_poll) { + avahi_simple_poll_free(p->simple_poll); + pthread_mutex_destroy(&p->mutex); + } + + avahi_free(p); + } + + return NULL; +} + +void avahi_threaded_poll_free(AvahiThreadedPoll *p) { + assert(p); + + /* Make sure that this function is not called from the helper thread */ + assert(!p->thread_running || !pthread_equal(pthread_self(), p->thread_id)); + + if (p->thread_running) + avahi_threaded_poll_stop(p); + + if (p->simple_poll) + avahi_simple_poll_free(p->simple_poll); + + pthread_mutex_destroy(&p->mutex); + avahi_free(p); +} + +const AvahiPoll* avahi_threaded_poll_get(AvahiThreadedPoll *p) { + assert(p); + + return avahi_simple_poll_get(p->simple_poll); +} + +int avahi_threaded_poll_start(AvahiThreadedPoll *p) { + assert(p); + + assert(!p->thread_running); + + if (pthread_create(&p->thread_id, NULL, thread, p) < 0) + return -1; + + p->thread_running = 1; + + return 0; +} + +int avahi_threaded_poll_stop(AvahiThreadedPoll *p) { + assert(p); + + if (!p->thread_running) + return -1; + + /* Make sure that this function is not called from the helper thread */ + assert(!pthread_equal(pthread_self(), p->thread_id)); + + pthread_mutex_lock(&p->mutex); + avahi_simple_poll_quit(p->simple_poll); + pthread_mutex_unlock(&p->mutex); + + pthread_join(p->thread_id, NULL); + p->thread_running = 0; + + return p->retval; +} + +void avahi_threaded_poll_quit(AvahiThreadedPoll *p) { + assert(p); + + /* Make sure that this function is called from the helper thread */ + assert(pthread_equal(pthread_self(), p->thread_id)); + + avahi_simple_poll_quit(p->simple_poll); +} + +void avahi_threaded_poll_lock(AvahiThreadedPoll *p) { + assert(p); + + /* Make sure that this function is not called from the helper thread */ + assert(!p->thread_running || !pthread_equal(pthread_self(), p->thread_id)); + + pthread_mutex_lock(&p->mutex); +} + +void avahi_threaded_poll_unlock(AvahiThreadedPoll *p) { + assert(p); + + /* Make sure that this function is not called from the helper thread */ + assert(!p->thread_running || !pthread_equal(pthread_self(), p->thread_id)); + + pthread_mutex_unlock(&p->mutex); +} diff --git a/libgamestream/avahi-common/thread-watch.h b/libgamestream/avahi-common/thread-watch.h new file mode 100644 index 00000000..1b44ccb0 --- /dev/null +++ b/libgamestream/avahi-common/thread-watch.h @@ -0,0 +1,80 @@ +#ifndef foothreadedwatchhfoo +#define foothreadedwatchhfoo + +/*** + 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.1 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 Lesser 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. +***/ + +/** \file thread-watch.h Threaded poll() based main loop implementation */ + +#include +#include +#include + +AVAHI_C_DECL_BEGIN + +/** A main loop object that runs an AvahiSimplePoll in its own thread. \since 0.6.4 */ +typedef struct AvahiThreadedPoll AvahiThreadedPoll; + +/** Create a new event loop object. This will allocate the internal + * AvahiSimplePoll, but will not start the helper thread. \since 0.6.4 */ +AvahiThreadedPoll *avahi_threaded_poll_new(void); + +/** Free an event loop object. This will stop the associated event loop + * thread (if it is running). \since 0.6.4 */ +void avahi_threaded_poll_free(AvahiThreadedPoll *p); + +/** Return the abstracted poll API object for this event loop + * object. The will return the same pointer each time it is + * called. \since 0.6.4 */ +const AvahiPoll* avahi_threaded_poll_get(AvahiThreadedPoll *p); + +/** Start the event loop helper thread. After the thread has started + * you must make sure to access the event loop object + * (AvahiThreadedPoll, AvahiPoll and all its associated objects) + * synchronized, i.e. with proper locking. You may want to use + * avahi_threaded_poll_lock()/avahi_threaded_poll_unlock() for this, + * which will lock the the entire event loop. Please note that event + * loop callback functions are called from the event loop helper thread + * with that lock held, i.e. avahi_threaded_poll_lock() calls are not + * required from event callbacks. \since 0.6.4 */ +int avahi_threaded_poll_start(AvahiThreadedPoll *p); + +/** Request that the event loop quits and the associated thread + stops. Call this from outside the helper thread if you want to shut + it down. \since 0.6.4 */ +int avahi_threaded_poll_stop(AvahiThreadedPoll *p); + +/** Request that the event loop quits and the associated thread + stops. Call this from inside the helper thread if you want to shut it + down. \since 0.6.4 */ +void avahi_threaded_poll_quit(AvahiThreadedPoll *p); + +/** Lock the main loop object. Use this if you want to access the event + * loop objects (such as creating a new event source) from anything + * else but the event loop helper thread, i.e. from anything else but event + * loop callbacks \since 0.6.4 */ +void avahi_threaded_poll_lock(AvahiThreadedPoll *p); + +/** Unlock the event loop object, use this as counterpart to + * avahi_threaded_poll_lock() \since 0.6.4 */ +void avahi_threaded_poll_unlock(AvahiThreadedPoll *p); + +AVAHI_C_DECL_END + +#endif diff --git a/libgamestream/avahi-common/timeval-test.c b/libgamestream/avahi-common/timeval-test.c new file mode 100644 index 00000000..387c180c --- /dev/null +++ b/libgamestream/avahi-common/timeval-test.c @@ -0,0 +1,43 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "gccmacro.h" +#include "timeval.h" + +int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { + + struct timeval a = { 5, 5 }, b; + + b = a; + + printf("%li.%li\n", a.tv_sec, a.tv_usec); + avahi_timeval_add(&a, -50); + + printf("%li.%li\n", a.tv_sec, a.tv_usec); + + printf("%lli\n", (long long) avahi_timeval_diff(&a, &b)); + + return 0; +} diff --git a/libgamestream/avahi-common/timeval.c b/libgamestream/avahi-common/timeval.c new file mode 100644 index 00000000..cdb0f099 --- /dev/null +++ b/libgamestream/avahi-common/timeval.c @@ -0,0 +1,123 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include + +#include "timeval.h" + +int avahi_timeval_compare(const struct timeval *a, const struct timeval *b) { + assert(a); + assert(b); + + if (a->tv_sec < b->tv_sec) + return -1; + + if (a->tv_sec > b->tv_sec) + return 1; + + if (a->tv_usec < b->tv_usec) + return -1; + + if (a->tv_usec > b->tv_usec) + return 1; + + return 0; +} + +AvahiUsec avahi_timeval_diff(const struct timeval *a, const struct timeval *b) { + assert(a); + assert(b); + + if (avahi_timeval_compare(a, b) < 0) + return - avahi_timeval_diff(b, a); + + return ((AvahiUsec) a->tv_sec - b->tv_sec)*1000000 + a->tv_usec - b->tv_usec; +} + +struct timeval* avahi_timeval_add(struct timeval *a, AvahiUsec usec) { + AvahiUsec u; + assert(a); + + u = usec + a->tv_usec; + + if (u < 0) { + a->tv_usec = (long) (1000000 + (u % 1000000)); + a->tv_sec += (long) (-1 + (u / 1000000)); + } else { + a->tv_usec = (long) (u % 1000000); + a->tv_sec += (long) (u / 1000000); + } + + return a; +} + +AvahiUsec avahi_age(const struct timeval *a) { + struct timeval now; + + assert(a); + + gettimeofday(&now, NULL); + + return avahi_timeval_diff(&now, a); +} + +struct timeval *avahi_elapse_time(struct timeval *tv, unsigned msec, unsigned jitter) { + assert(tv); + + gettimeofday(tv, NULL); + + if (msec) + avahi_timeval_add(tv, (AvahiUsec) msec*1000); + + if (jitter) { + static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + static int last_rand; + static time_t timestamp = 0; + + time_t now; + int r; + + now = time(NULL); + + pthread_mutex_lock(&mutex); + if (now >= timestamp + 10) { + timestamp = now; + last_rand = rand(); + } + + r = last_rand; + + pthread_mutex_unlock(&mutex); + + /* We use the same jitter for 10 seconds. That way our + * time events elapse in bursts which has the advantage that + * packet data can be aggregated better */ + + avahi_timeval_add(tv, (AvahiUsec) (jitter*1000.0*r/(RAND_MAX+1.0))); + } + + return tv; +} + diff --git a/libgamestream/avahi-common/timeval.h b/libgamestream/avahi-common/timeval.h new file mode 100644 index 00000000..6470f015 --- /dev/null +++ b/libgamestream/avahi-common/timeval.h @@ -0,0 +1,54 @@ +#ifndef footimevalhfoo +#define footimevalhfoo + +/*** + 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.1 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 Lesser 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. +***/ + +/** \file timeval.h Functions to facilitate timeval handling */ + +#include +#include + +#include + +AVAHI_C_DECL_BEGIN + +/** A numeric data type for storing microsecond values. (signed 64bit integer) */ +typedef int64_t AvahiUsec; + +/** Compare two timeval structures and return a negative value when a < b, 0 when a == b and a positive value otherwise */ +int avahi_timeval_compare(const struct timeval *a, const struct timeval *b); + +/** Calculate the difference between two timeval structures as microsecond value */ +AvahiUsec avahi_timeval_diff(const struct timeval *a, const struct timeval *b); + +/** Add a number of microseconds to the specified timeval structure and return it. *a is modified. */ +struct timeval* avahi_timeval_add(struct timeval *a, AvahiUsec usec); + +/** Return the difference between the current time and *a. Positive if *a was earlier */ +AvahiUsec avahi_age(const struct timeval *a); + +/** Fill *tv with the current time plus "ms" milliseconds plus an + * extra jitter of "j" milliseconds. Pass 0 for j if you don't want + * the jitter */ +struct timeval *avahi_elapse_time(struct timeval *tv, unsigned ms, unsigned j); + +AVAHI_C_DECL_END + +#endif diff --git a/libgamestream/avahi-common/utf8-test.c b/libgamestream/avahi-common/utf8-test.c new file mode 100644 index 00000000..d12ed58e --- /dev/null +++ b/libgamestream/avahi-common/utf8-test.c @@ -0,0 +1,37 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include + +#include "utf8.h" + +int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { + + assert(avahi_utf8_valid("hallo")); + assert(!avahi_utf8_valid("üxknürz")); + assert(avahi_utf8_valid("üxknürz")); + + return 0; +} diff --git a/libgamestream/avahi-common/utf8.c b/libgamestream/avahi-common/utf8.c new file mode 100644 index 00000000..ab10ba06 --- /dev/null +++ b/libgamestream/avahi-common/utf8.c @@ -0,0 +1,110 @@ +/* This file is based on the GLIB utf8 validation functions. The + * original license text follows. */ + +/* gutf8.c - Operations on UTF-8 strings. + * + * Copyright (C) 1999 Tom Tromey + * Copyright (C) 2000 Red Hat, Inc. + * + * This library 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. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "utf8.h" + +#define UNICODE_VALID(Char) \ + ((Char) < 0x110000 && \ + (((Char) & 0xFFFFF800) != 0xD800) && \ + ((Char) < 0xFDD0 || (Char) > 0xFDEF) && \ + ((Char) & 0xFFFE) != 0xFFFE) + + +#define CONTINUATION_CHAR \ + do { \ + if ((*(const unsigned char *)p & 0xc0) != 0x80) /* 10xxxxxx */ \ + goto error; \ + val <<= 6; \ + val |= (*(const unsigned char *)p) & 0x3f; \ + } while(0) + + +const char * +avahi_utf8_valid (const char *str) + +{ + unsigned val = 0; + unsigned min = 0; + const char *p; + + for (p = str; *p; p++) + { + if (*(const unsigned char *)p < 128) + /* done */; + else + { + if ((*(const unsigned char *)p & 0xe0) == 0xc0) /* 110xxxxx */ + { + if ( ((*(const unsigned char *)p & 0x1e) == 0)) + goto error; + p++; + if ( ((*(const unsigned char *)p & 0xc0) != 0x80)) /* 10xxxxxx */ + goto error; + } + else + { + if ((*(const unsigned char *)p & 0xf0) == 0xe0) /* 1110xxxx */ + { + min = (1 << 11); + val = *(const unsigned char *)p & 0x0f; + goto TWO_REMAINING; + } + else if ((*(const unsigned char *)p & 0xf8) == 0xf0) /* 11110xxx */ + { + min = (1 << 16); + val = *(const unsigned char *)p & 0x07; + } + else + goto error; + + p++; + CONTINUATION_CHAR; + TWO_REMAINING: + p++; + CONTINUATION_CHAR; + p++; + CONTINUATION_CHAR; + + if ( (val < min)) + goto error; + + if ( (!UNICODE_VALID(val))) + goto error; + } + + continue; + + error: + return NULL; + } + } + + return str; +} diff --git a/libgamestream/avahi-common/utf8.h b/libgamestream/avahi-common/utf8.h new file mode 100644 index 00000000..dc1ce4bc --- /dev/null +++ b/libgamestream/avahi-common/utf8.h @@ -0,0 +1,33 @@ +#ifndef fooutf8hfoo +#define fooutf8hfoo + +/*** + 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.1 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 Lesser 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. +***/ + +#include + +#include + +AVAHI_C_DECL_BEGIN + +const char *avahi_utf8_valid(const char *str); + +AVAHI_C_DECL_END + +#endif diff --git a/libgamestream/avahi-common/watch-test.c b/libgamestream/avahi-common/watch-test.c new file mode 100644 index 00000000..6c178ba6 --- /dev/null +++ b/libgamestream/avahi-common/watch-test.c @@ -0,0 +1,115 @@ +/*** + 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.1 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 Lesser 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. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include + +#include "watch.h" +#include "timeval.h" +#include "gccmacro.h" + +static const AvahiPoll *api = NULL; + +#ifndef USE_THREAD +#include "simple-watch.h" +static AvahiSimplePoll *simple_poll = NULL; +#else +#include "thread-watch.h" +static AvahiThreadedPoll *threaded_poll = NULL; +#endif + +static void callback(AvahiWatch *w, int fd, AvahiWatchEvent event, AVAHI_GCC_UNUSED void *userdata) { + + if (event & AVAHI_WATCH_IN) { + ssize_t r; + char c; + + if ((r = read(fd, &c, 1)) <= 0) { + fprintf(stderr, "read() failed: %s\n", r < 0 ? strerror(errno) : "EOF"); + api->watch_free(w); + return; + } + + printf("Read: %c\n", c >= 32 && c < 127 ? c : '.'); + } +} + +static void wakeup(AvahiTimeout *t, AVAHI_GCC_UNUSED void *userdata) { + static int i = 0; + struct timeval tv; + + printf("Wakeup #%i\n", i++); + + if (i > 10) { +#ifndef USE_THREAD + avahi_simple_poll_quit(simple_poll); +#else + avahi_threaded_poll_quit(threaded_poll); +#endif + } else { + avahi_elapse_time(&tv, 1000, 0); + api->timeout_update(t, &tv); + } +} + +int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { + struct timeval tv; + +#ifndef USE_THREAD + simple_poll = avahi_simple_poll_new(); + assert(simple_poll); + api = avahi_simple_poll_get(simple_poll); + assert(api); +#else + threaded_poll = avahi_threaded_poll_new(); + assert(threaded_poll); + api = avahi_threaded_poll_get(threaded_poll); + assert(api); +#endif + + api->watch_new(api, 0, AVAHI_WATCH_IN, callback, NULL); + + avahi_elapse_time(&tv, 1000, 0); + api->timeout_new(api, &tv, wakeup, NULL); + +#ifndef USE_THREAD + /* Our main loop */ + avahi_simple_poll_loop(simple_poll); + avahi_simple_poll_free(simple_poll); + +#else + avahi_threaded_poll_start(threaded_poll); + + fprintf(stderr, "Now doing some stupid stuff ...\n"); + sleep(20); + fprintf(stderr, "... stupid stuff is done.\n"); + + avahi_threaded_poll_free(threaded_poll); + +#endif + + return 0; +} diff --git a/libgamestream/avahi-common/watch.h b/libgamestream/avahi-common/watch.h new file mode 100644 index 00000000..eea12ec4 --- /dev/null +++ b/libgamestream/avahi-common/watch.h @@ -0,0 +1,97 @@ +#ifndef foowatchhfoo +#define foowatchhfoo + +/*** + 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.1 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 Lesser 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. +***/ + +/** \file watch.h Simplistic main loop abstraction */ + +#include +#include + +#include + +AVAHI_C_DECL_BEGIN + +/** An I/O watch object */ +typedef struct AvahiWatch AvahiWatch; + +/** A timeout watch object */ +typedef struct AvahiTimeout AvahiTimeout; + +/** An event polling abstraction object */ +typedef struct AvahiPoll AvahiPoll; + +/** Type of watch events */ +typedef enum { + AVAHI_WATCH_IN = POLLIN, /**< Input event */ + AVAHI_WATCH_OUT = POLLOUT, /**< Output event */ + AVAHI_WATCH_ERR = POLLERR, /**< Error event */ + AVAHI_WATCH_HUP = POLLHUP /**< Hangup event */ +} AvahiWatchEvent; + +/** Called whenever an I/O event happens on an I/O watch */ +typedef void (*AvahiWatchCallback)(AvahiWatch *w, int fd, AvahiWatchEvent event, void *userdata); + +/** Called when the timeout is reached */ +typedef void (*AvahiTimeoutCallback)(AvahiTimeout *t, void *userdata); + +/** Defines an abstracted event polling API. This may be used to + connect Avahi to other main loops. This is loosely based on Unix + poll(2). A consumer will call watch_new() for all file descriptors it + wants to listen for events on. In addition he can call timeout_new() + to define time based events .*/ +struct AvahiPoll { + + /** Some abstract user data usable by the provider of the API */ + void* userdata; + + /** Create a new watch for the specified file descriptor and for + * the specified events. The API will call the callback function + * whenever any of the events happens. */ + AvahiWatch* (*watch_new)(const AvahiPoll *api, int fd, AvahiWatchEvent event, AvahiWatchCallback callback, void *userdata); + + /** Update the events to wait for. It is safe to call this function from an AvahiWatchCallback */ + void (*watch_update)(AvahiWatch *w, AvahiWatchEvent event); + + /** Return the events that happened. It is safe to call this function from an AvahiWatchCallback */ + AvahiWatchEvent (*watch_get_events)(AvahiWatch *w); + + /** Free a watch. It is safe to call this function from an AvahiWatchCallback */ + void (*watch_free)(AvahiWatch *w); + + /** Set a wakeup time for the polling loop. The API will call the + callback function when the absolute time *tv is reached. If tv is + NULL, the timeout is disabled. After the timeout expired the + callback function will be called and the timeout is disabled. You + can reenable it by calling timeout_update() */ + AvahiTimeout* (*timeout_new)(const AvahiPoll *api, const struct timeval *tv, AvahiTimeoutCallback callback, void *userdata); + + /** Update the absolute expiration time for a timeout, If tv is + * NULL, the timeout is disabled. It is safe to call this function from an AvahiTimeoutCallback */ + void (*timeout_update)(AvahiTimeout *, const struct timeval *tv); + + /** Free a timeout. It is safe to call this function from an AvahiTimeoutCallback */ + void (*timeout_free)(AvahiTimeout *t); +}; + +AVAHI_C_DECL_END + +#endif + diff --git a/libgamestream/client.c b/libgamestream/client.c index ac8568f6..6da825a6 100644 --- a/libgamestream/client.c +++ b/libgamestream/client.c @@ -31,7 +31,7 @@ #include #include #include -#include "uuid.h" +#include #include #include #include @@ -94,16 +94,16 @@ static int load_unique_id(const char* keyDirectory) { snprintf(uniqueFilePath, PATH_MAX, "%s/%s", keyDirectory, UNIQUE_FILE_NAME); FILE *fd = fopen(uniqueFilePath, "r"); - if (fd == NULL) { + if (fd == NULL || fread(unique_id, UNIQUEID_CHARS, 1, fd) != UNIQUEID_CHARS) { snprintf(unique_id,UNIQUEID_CHARS+1,"0123456789ABCDEF"); + if (fd) + fclose(fd); fd = fopen(uniqueFilePath, "w"); if (fd == NULL) return GS_FAILED; fwrite(unique_id, UNIQUEID_CHARS, 1, fd); - } else { - fread(unique_id, UNIQUEID_CHARS, 1, fd); } fclose(fd); unique_id[UNIQUEID_CHARS] = 0; @@ -237,6 +237,7 @@ static int load_serverinfo(PSERVER_DATA server, bool https) { server->currentGame = currentGameText == NULL ? 0 : atoi(currentGameText); server->supports4K = serverCodecModeSupportText != NULL; server->serverMajorVersion = atoi(server->serverInfo.serverInfoAppVersion); + server->isNvidiaSoftware = strstr(stateText, "MJOLNIR") != NULL; server->httpsPort = atoi(httpsPortText); if (!server->httpsPort) @@ -418,29 +419,10 @@ int gs_unpair(PSERVER_DATA server) { return ret; } -#ifdef __WIIU__ -// Wii U doesn't like the %2hhx formatting so this is a quick and dirty hexstring converter -// https://stackoverflow.com/a/53579348/11511475 -static void hex2bin(const char* in, size_t len, unsigned char* out) { - static const unsigned char TBL[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 58, 59, 60, 61, - 62, 63, 64, 10, 11, 12, 13, 14, 15, 71, 72, 73, 74, 75, - 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - 90, 91, 92, 93, 94, 95, 96, 10, 11, 12, 13, 14, 15 - }; - - static const unsigned char *LOOKUP = TBL - 48; - - const char* end = in + len; - - while(in < end) *(out++) = LOOKUP[*(in++)] << 4 | LOOKUP[*(in++)]; -} -#endif - int gs_pair(PSERVER_DATA server, char* pin) { int ret = GS_OK; char* result = NULL; - char url[4096]; + char url[5120]; uuid_t uuid; char uuid_str[UUID_STRLEN]; @@ -449,11 +431,6 @@ int gs_pair(PSERVER_DATA server, char* pin) { return GS_WRONG_STATE; } - if (server->currentGame != 0) { - gs_error = "The computer is currently in a game.\nYou must close the game before pairing"; - return GS_WRONG_STATE; - } - unsigned char salt_data[16]; char salt_hex[SIZEOF_AS_HEX_STR(salt_data)]; RAND_bytes(salt_data, sizeof(salt_data)); @@ -492,13 +469,9 @@ int gs_pair(PSERVER_DATA server, char* pin) { goto cleanup; } -#ifndef __WIIU__ for (int count = 0; count < strlen(result); count += 2) { sscanf(&result[count], "%2hhx", &plaincert[count / 2]); } -#else - hex2bin(result, strlen(result), plaincert); -#endif plaincert[strlen(result)/2] = '\0'; unsigned char salt_pin[sizeof(salt_data) + 4]; @@ -554,13 +527,9 @@ int gs_pair(PSERVER_DATA server, char* pin) { goto cleanup; } -#ifndef __WIIU__ for (int count = 0; count < strlen(result); count += 2) { sscanf(&result[count], "%2hhx", &challenge_response_data_enc[count / 2]); } -#else - hex2bin(result, strlen(result), challenge_response_data_enc); -#endif decrypt(challenge_response_data_enc, sizeof(challenge_response_data_enc), aes_key, challenge_response_data); @@ -619,13 +588,9 @@ int gs_pair(PSERVER_DATA server, char* pin) { goto cleanup; } -#ifndef __WIIU__ for (int count = 0; count < strlen(result); count += 2) { sscanf(&result[count], "%2hhx", &pairing_secret[count / 2]); } -#else - hex2bin(result, strlen(result), pairing_secret); -#endif if (!verifySignature(pairing_secret, 16, pairing_secret+16, SIGNATURE_LEN, plaincert)) { gs_error = "MITM attack detected"; @@ -696,6 +661,13 @@ int gs_pair(PSERVER_DATA server, char* pin) { http_free_data(data); + // If we failed when attempting to pair with a game running, that's likely the issue. + // Sunshine supports pairing with an active session, but GFE does not. + if (ret != GS_OK && server->currentGame != 0) { + gs_error = "The computer is currently in a game. You must close the game before pairing."; + ret = GS_WRONG_STATE; + } + return ret; } @@ -730,10 +702,8 @@ int gs_start_app(PSERVER_DATA server, STREAM_CONFIGURATION *config, int appId, b PDISPLAY_MODE mode = server->modes; bool correct_mode = false; - bool supported_resolution = false; while (mode != NULL) { if (mode->width == config->width && mode->height == config->height) { - supported_resolution = true; if (mode->refresh == config->fps) correct_mode = true; } @@ -762,19 +732,18 @@ int gs_start_app(PSERVER_DATA server, STREAM_CONFIGURATION *config, int appId, b if (data == NULL) return GS_OUT_OF_MEMORY; + // Using an FPS value over 60 causes SOPS to default to 720p60, + // so force it to 0 to ensure the correct resolution is set. We + // used to use 60 here but that locked the frame rate to 60 FPS + // on GFE 3.20.3. + int fps = (server->isNvidiaSoftware && config->fps > 60) ? 0 : config->fps; + uuid_generate_random(uuid); uuid_unparse(uuid, uuid_str); int surround_info = SURROUNDAUDIOINFO_FROM_AUDIO_CONFIGURATION(config->audioConfiguration); - if (server->currentGame == 0) { - // Using an FPS value over 60 causes SOPS to default to 720p60, - // so force it to 0 to ensure the correct resolution is set. We - // used to use 60 here but that locked the frame rate to 60 FPS - // on GFE 3.20.3. - int fps = config->fps > 60 ? 0 : config->fps; - snprintf(url, sizeof(url), "https://%s:%u/launch?uniqueid=%s&uuid=%s&appid=%d&mode=%dx%dx%d&additionalStates=1&sops=%d&rikey=%s&rikeyid=%d&localAudioPlayMode=%d&surroundAudioInfo=%d&remoteControllersBitmap=%d&gcmap=%d", server->serverInfo.address, server->httpsPort, unique_id, uuid_str, appId, config->width, config->height, fps, sops, rikey_hex, rikeyid, localaudio, surround_info, gamepad_mask, gamepad_mask); - } else - snprintf(url, sizeof(url), "https://%s:%u/resume?uniqueid=%s&uuid=%s&rikey=%s&rikeyid=%d&surroundAudioInfo=%d", server->serverInfo.address, server->httpsPort, unique_id, uuid_str, rikey_hex, rikeyid, surround_info); - + snprintf(url, sizeof(url), "https://%s:%u/%s?uniqueid=%s&uuid=%s&appid=%d&mode=%dx%dx%d&additionalStates=1&sops=%d&rikey=%s&rikeyid=%d&localAudioPlayMode=%d&surroundAudioInfo=%d&remoteControllersBitmap=%d&gcmap=%d%s", + server->serverInfo.address, server->httpsPort, server->currentGame ? "resume" : "launch", unique_id, uuid_str, appId, config->width, config->height, fps, sops, rikey_hex, rikeyid, localaudio, surround_info, gamepad_mask, gamepad_mask, + config->enableHdr ? "&hdrMode=1&clientHdrCapVersion=0&clientHdrCapSupportedFlagsInUint32=0&clientHdrCapMetaDataId=NV_STATIC_METADATA_TYPE_1&clientHdrCapDisplayData=0x0x0x0x0x0x0x0x0x0x0" : ""); if ((ret = http_request(url, data)) == GS_OK) server->currentGame = appId; else @@ -782,7 +751,8 @@ int gs_start_app(PSERVER_DATA server, STREAM_CONFIGURATION *config, int appId, b if ((ret = xml_status(data->memory, data->size) != GS_OK)) goto cleanup; - else if ((ret = xml_search(data->memory, data->size, "gamesession", &result)) != GS_OK) + else if ((ret = xml_search(data->memory, data->size, "gamesession", &result)) != GS_OK && + (ret = xml_search(data->memory, data->size, "resume", &result)) != GS_OK) goto cleanup; if (!strcmp(result, "0")) { @@ -841,12 +811,7 @@ int gs_quit_app(PSERVER_DATA server) { } int gs_init(PSERVER_DATA server, char *address, unsigned short httpPort, const char *keyDirectory, int log_level, bool unsupported) { -#ifndef __WIIU__ mkdirtree(keyDirectory); -#else - // the above will fail on the Wii U due to the /vol/external01 - mkdir(keyDirectory, 0775); -#endif if (load_unique_id(keyDirectory) != GS_OK) return GS_FAILED; diff --git a/libgamestream/client.h b/libgamestream/client.h index cc4c41f1..4afb1682 100644 --- a/libgamestream/client.h +++ b/libgamestream/client.h @@ -33,6 +33,7 @@ typedef struct _SERVER_DATA { bool paired; bool supports4K; bool unsupported; + bool isNvidiaSoftware; int currentGame; int serverMajorVersion; char* gsVersion; diff --git a/libgamestream/discover.c b/libgamestream/discover.c index 5e023533..28cc052d 100644 --- a/libgamestream/discover.c +++ b/libgamestream/discover.c @@ -17,8 +17,6 @@ * along with Moonlight; if not, see . */ -#ifndef __WIIU__ - #include "errors.h" #include @@ -118,5 +116,3 @@ void gs_discover_server(char* dest, unsigned short* port) { if (simple_poll) avahi_simple_poll_free(simple_poll); } - -#endif diff --git a/libgamestream/http.c b/libgamestream/http.c index fd78b48b..9a04c713 100644 --- a/libgamestream/http.c +++ b/libgamestream/http.c @@ -26,9 +26,6 @@ static CURL *curl; -static const char *pCertFile = "./client.pem"; -static const char *pKeyFile = "./key.pem"; - static bool debug; static size_t _write_curl(void *contents, size_t size, size_t nmemb, void *userp) diff --git a/libgamestream/uuid/COPYING b/libgamestream/uuid/COPYING new file mode 100644 index 00000000..6935c288 --- /dev/null +++ b/libgamestream/uuid/COPYING @@ -0,0 +1,5 @@ +This library is free software; you can redistribute it and/or +modify it under the terms of the Modified BSD License. + +The complete text of the license is available at the +Documentation/licenses/COPYING.BSD-3 file. diff --git a/libgamestream/uuid/all-io.h b/libgamestream/uuid/all-io.h new file mode 100644 index 00000000..424ab7d3 --- /dev/null +++ b/libgamestream/uuid/all-io.h @@ -0,0 +1,82 @@ +/* + * No copyright is claimed. This code is in the public domain; do with + * it what you wish. + * + * Written by Karel Zak + * Petr Uzel + */ + +#ifndef UTIL_LINUX_ALL_IO_H +#define UTIL_LINUX_ALL_IO_H + +#include +#include +#include + +#include "c.h" + +static inline int write_all(int fd, const void *buf, size_t count) +{ + while (count) { + ssize_t tmp; + + errno = 0; + tmp = write(fd, buf, count); + if (tmp > 0) { + count -= tmp; + if (count) + buf = (void *) ((char *) buf + tmp); + } else if (errno != EINTR && errno != EAGAIN) + return -1; + if (errno == EAGAIN) /* Try later, *sigh* */ + usleep(10000); + } + return 0; +} + +static inline int fwrite_all(const void *ptr, size_t size, + size_t nmemb, FILE *stream) +{ + while (nmemb) { + size_t tmp; + + errno = 0; + tmp = fwrite(ptr, size, nmemb, stream); + if (tmp > 0) { + nmemb -= tmp; + if (nmemb) + ptr = (void *) ((char *) ptr + (tmp * size)); + } else if (errno != EINTR && errno != EAGAIN) + return -1; + if (errno == EAGAIN) /* Try later, *sigh* */ + usleep(10000); + } + return 0; +} + +static inline ssize_t read_all(int fd, char *buf, size_t count) +{ + ssize_t ret; + ssize_t c = 0; + int tries = 0; + + memset(buf, 0, count); + while (count > 0) { + ret = read(fd, buf, count); + if (ret <= 0) { + if ((errno == EAGAIN || errno == EINTR || ret == 0) && + (tries++ < 5)) + continue; + return c ? c : -1; + } + if (ret > 0) + tries = 0; + count -= ret; + buf += ret; + c += ret; + } + return c; +} + + +#endif /* UTIL_LINUX_ALL_IO_H */ diff --git a/libgamestream/uuid/c.h b/libgamestream/uuid/c.h new file mode 100644 index 00000000..8b674f97 --- /dev/null +++ b/libgamestream/uuid/c.h @@ -0,0 +1,318 @@ +/* + * Fundamental C definitions. + */ + +#ifndef UTIL_LINUX_C_H +#define UTIL_LINUX_C_H + +#define HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#ifdef HAVE_STDINT_H +#include +#else +# ifdef HAVE_INTTYPES_H +# include +# endif +#endif + +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_ERR_H +# include +#endif + +#ifndef HAVE_USLEEP +# include +#endif + +/* + * Compiler specific stuff + */ +#ifndef __GNUC_PREREQ +# if defined __GNUC__ && defined __GNUC_MINOR__ +# define __GNUC_PREREQ(maj, min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +# else +# define __GNUC_PREREQ(maj, min) 0 +# endif +#endif + +#ifdef __GNUC__ + +/* &a[0] degrades to a pointer: a different type from an array */ +# define __must_be_array(a) \ + UL_BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(__typeof__(a), __typeof__(&a[0]))) + +# define ignore_result(x) ({ \ + __typeof__(x) __dummy __attribute__((__unused__)) = (x); (void) __dummy; \ +}) + +#else /* !__GNUC__ */ +# define __must_be_array(a) 0 +# define __attribute__(_arg_) +# define ignore_result(x) ((void) (x)) +#endif /* !__GNUC__ */ + +/* + * Function attributes + */ +#ifndef __ul_alloc_size +# if __GNUC_PREREQ (4, 3) +# define __ul_alloc_size(s) __attribute__((alloc_size(s))) +# else +# define __ul_alloc_size(s) +# endif +#endif + +#ifndef __ul_calloc_size +# if __GNUC_PREREQ (4, 3) +# define __ul_calloc_size(n, s) __attribute__((alloc_size(n, s))) +# else +# define __ul_calloc_size(n, s) +# endif +#endif + +/* Force a compilation error if condition is true, but also produce a + * result (of value 0 and type size_t), so the expression can be used + * e.g. in a structure initializer (or where-ever else comma expressions + * aren't permitted). + */ +#define UL_BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) +#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) + +#ifndef ARRAY_SIZE +# define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) +#endif + +#ifndef PATH_MAX +# define PATH_MAX 4096 +#endif + +#ifndef TRUE +# define TRUE 1 +#endif + +#ifndef FALSE +# define FALSE 0 +#endif + +#ifndef min +# define min(x, y) ({ \ + __typeof__(x) _min1 = (x); \ + __typeof__(y) _min2 = (y); \ + (void) (&_min1 == &_min2); \ + _min1 < _min2 ? _min1 : _min2; }) +#endif + +#ifndef max +# define max(x, y) ({ \ + __typeof__(x) _max1 = (x); \ + __typeof__(y) _max2 = (y); \ + (void) (&_max1 == &_max2); \ + _max1 > _max2 ? _max1 : _max2; }) +#endif + +#ifndef offsetof +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#endif + +#ifndef container_of +#define container_of(ptr, type, member) ({ \ + const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) +#endif + +#ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME +# ifdef HAVE___PROGNAME +extern char *__progname; +# define program_invocation_short_name __progname +# else +# ifdef HAVE_GETEXECNAME +# define program_invocation_short_name \ + prog_inv_sh_nm_from_file(getexecname(), 0) +# else +# define program_invocation_short_name \ + prog_inv_sh_nm_from_file(__FILE__, 1) +# endif +static char prog_inv_sh_nm_buf[256]; +static inline char * +prog_inv_sh_nm_from_file(char *f, char stripext) +{ + char *t; + + if ((t = strrchr(f, '/')) != NULL) + t++; + else + t = f; + + strncpy(prog_inv_sh_nm_buf, t, sizeof(prog_inv_sh_nm_buf) - 1); + prog_inv_sh_nm_buf[sizeof(prog_inv_sh_nm_buf) - 1] = '\0'; + + if (stripext && (t = strrchr(prog_inv_sh_nm_buf, '.')) != NULL) + *t = '\0'; + + return prog_inv_sh_nm_buf; +} +# endif +#endif + + +#ifndef HAVE_ERR_H +static inline void +errmsg(char doexit, int excode, char adderr, const char *fmt, ...) +{ + fprintf(stderr, "%s: ", program_invocation_short_name); + if (fmt != NULL) { + va_list argp; + va_start(argp, fmt); + vfprintf(stderr, fmt, argp); + va_end(argp); + if (adderr) + fprintf(stderr, ": "); + } + if (adderr) + fprintf(stderr, "%m"); + fprintf(stderr, "\n"); + if (doexit) + exit(excode); +} + +#ifndef HAVE_ERR +# define err(E, FMT...) errmsg(1, E, 1, FMT) +#endif + +#ifndef HAVE_ERRX +# define errx(E, FMT...) errmsg(1, E, 0, FMT) +#endif + +#ifndef HAVE_WARN +# define warn(FMT...) errmsg(0, 0, 1, FMT) +#endif + +#ifndef HAVE_WARNX +# define warnx(FMT...) errmsg(0, 0, 0, FMT) +#endif +#endif /* !HAVE_ERR_H */ + + +static inline __attribute__((const)) int is_power_of_2(unsigned long num) +{ + return (num != 0 && ((num & (num - 1)) == 0)); +} + +#ifndef HAVE_LOFF_T +typedef int64_t loff_t; +#endif + +#if !defined(HAVE_DIRFD) && (!defined(HAVE_DECL_DIRFD) || HAVE_DECL_DIRFD == 0) && defined(HAVE_DIR_DD_FD) +#include +#include +static inline int dirfd(DIR *d) +{ + return d->dd_fd; +} +#endif + +/* + * Fallback defines for old versions of glibc + */ +#include + +#ifdef O_CLOEXEC +#define UL_CLOEXECSTR "e" +#else +#define UL_CLOEXECSTR "" +#endif + +#ifndef O_CLOEXEC +#define O_CLOEXEC 0 +#endif + + +#ifndef AI_ADDRCONFIG +#define AI_ADDRCONFIG 0x0020 +#endif + +#ifndef IUTF8 +#define IUTF8 0040000 +#endif + +/* + * MAXHOSTNAMELEN replacement + */ +static inline size_t get_hostname_max(void) +{ +#if HAVE_DECL__SC_HOST_NAME_MAX + long len = sysconf(_SC_HOST_NAME_MAX); + + if (0 < len) + return len; +#endif + +#ifdef MAXHOSTNAMELEN + return MAXHOSTNAMELEN; +#elif HOST_NAME_MAX + return HOST_NAME_MAX; +#endif + return 64; +} + +#ifndef HAVE_USLEEP +/* + * This function is marked obsolete in POSIX.1-2001 and removed in + * POSIX.1-2008. It is replaced with nanosleep(). + */ +static inline int usleep(useconds_t usec) +{ + struct timespec waittime = { + .tv_sec = usec / 1000000L, + .tv_nsec = (usec % 1000000L) * 1000 + }; + return nanosleep(&waittime, NULL); +} +#endif + +/* + * Constant strings for usage() functions. For more info see + * Documentation/howto-usage-function.txt and disk-utils/delpart.c + */ +#define USAGE_HEADER _("\nUsage:\n") +#define USAGE_OPTIONS _("\nOptions:\n") +#define USAGE_SEPARATOR _("\n") +#define USAGE_HELP _(" -h, --help display this help and exit\n") +#define USAGE_VERSION _(" -V, --version output version information and exit\n") +#define USAGE_MAN_TAIL(_man) _("\nFor more details see %s.\n"), _man + +#define UTIL_LINUX_VERSION _("%s from %s\n"), program_invocation_short_name, PACKAGE_STRING + +/* + * scanf modifiers for "strings allocation" + */ +#ifdef HAVE_SCANF_MS_MODIFIER +#define UL_SCNsA "%ms" +#elif defined(HAVE_SCANF_AS_MODIFIER) +#define UL_SCNsA "%as" +#endif + +/* + * seek stuff + */ +#ifndef SEEK_DATA +# define SEEK_DATA 3 +#endif +#ifndef SEEK_HOLE +# define SEEK_HOLE 4 +#endif + +#endif /* UTIL_LINUX_C_H */ diff --git a/libgamestream/uuid/clear.c b/libgamestream/uuid/clear.c new file mode 100644 index 00000000..2d91fee9 --- /dev/null +++ b/libgamestream/uuid/clear.c @@ -0,0 +1,43 @@ +/* + * clear.c -- Clear a UUID + * + * Copyright (C) 1996, 1997 Theodore Ts'o. + * + * %Begin-Header% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, and the entire permission notice in its entirety, + * including the disclaimer of warranties. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF + * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * %End-Header% + */ + +#include "string.h" + +#include "uuidP.h" + +void uuid_clear(uuid_t uu) +{ + memset(uu, 0, 16); +} + diff --git a/libgamestream/uuid/compare.c b/libgamestream/uuid/compare.c new file mode 100644 index 00000000..8f3437a2 --- /dev/null +++ b/libgamestream/uuid/compare.c @@ -0,0 +1,55 @@ +/* + * compare.c --- compare whether or not two UUIDs are the same + * + * Returns 0 if the two UUIDs are different, and 1 if they are the same. + * + * Copyright (C) 1996, 1997 Theodore Ts'o. + * + * %Begin-Header% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, and the entire permission notice in its entirety, + * including the disclaimer of warranties. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF + * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * %End-Header% + */ + +#include "uuidP.h" +#include + +#define UUCMP(u1,u2) if (u1 != u2) return((u1 < u2) ? -1 : 1); + +int uuid_compare(const uuid_t uu1, const uuid_t uu2) +{ + struct uuid uuid1, uuid2; + + uuid_unpack(uu1, &uuid1); + uuid_unpack(uu2, &uuid2); + + UUCMP(uuid1.time_low, uuid2.time_low); + UUCMP(uuid1.time_mid, uuid2.time_mid); + UUCMP(uuid1.time_hi_and_version, uuid2.time_hi_and_version); + UUCMP(uuid1.clock_seq, uuid2.clock_seq); + return memcmp(uuid1.node, uuid2.node, 6); +} + diff --git a/libgamestream/uuid/config.h b/libgamestream/uuid/config.h new file mode 100644 index 00000000..5965f1c1 --- /dev/null +++ b/libgamestream/uuid/config.h @@ -0,0 +1,153 @@ +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the declaration of `_SC_HOST_NAME_MAX', and to 0 if + you don't. */ +#define HAVE_DECL__SC_HOST_NAME_MAX 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DLFCN_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `ftruncate' function. */ +#define HAVE_FTRUNCATE 1 + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memset' function. */ +#define HAVE_MEMSET 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETINET_IN_H */ + +/* Define to 1 if you have the `socket' function. */ +/* #undef HAVE_SOCKET */ + +/* Define to 1 if you have the `srandom' function. */ +#define HAVE_SRANDOM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strtoul' function. */ +#define HAVE_STRTOUL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_IOCTL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SOCKET_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `usleep' function. */ +#define HAVE_USLEEP 1 + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#define LT_OBJDIR ".libs/" + +/* Name of package */ +#define PACKAGE "libuuid" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "sloowfranklin@gmail.com" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "libuuid" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "libuuid 1.0.3" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "libuuid" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "1.0.3" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +#define VERSION "1.0.3" + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define for Solaris 2.5.1 so the uint8_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT8_T */ + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to `int' if does not define. */ +/* #undef ssize_t */ + +/* Define to the type of an unsigned integer type of width exactly 16 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint16_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to the type of an unsigned integer type of width exactly 8 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint8_t */ diff --git a/libgamestream/uuid/copy.c b/libgamestream/uuid/copy.c new file mode 100644 index 00000000..ead33aa2 --- /dev/null +++ b/libgamestream/uuid/copy.c @@ -0,0 +1,45 @@ +/* + * copy.c --- copy UUIDs + * + * Copyright (C) 1996, 1997 Theodore Ts'o. + * + * %Begin-Header% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, and the entire permission notice in its entirety, + * including the disclaimer of warranties. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF + * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * %End-Header% + */ + +#include "uuidP.h" + +void uuid_copy(uuid_t dst, const uuid_t src) +{ + unsigned char *cp1; + const unsigned char *cp2; + int i; + + for (i=0, cp1 = dst, cp2 = src; i < 16; i++) + *cp1++ = *cp2++; +} diff --git a/libgamestream/uuid/gen_uuid.c b/libgamestream/uuid/gen_uuid.c new file mode 100644 index 00000000..38bb4dc6 --- /dev/null +++ b/libgamestream/uuid/gen_uuid.c @@ -0,0 +1,599 @@ +/* + * gen_uuid.c --- generate a DCE-compatible uuid + * + * Copyright (C) 1996, 1997, 1998, 1999 Theodore Ts'o. + * + * %Begin-Header% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, and the entire permission notice in its entirety, + * including the disclaimer of warranties. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF + * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * %End-Header% + */ + +/* + * Force inclusion of SVID stuff since we need it if we're compiling in + * gcc-wall wall mode + */ +#define _SVID_SOURCE + +#ifdef _WIN32 +#define _WIN32_WINNT 0x0500 +#include +#define UUID MYUUID +#endif +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#include +#include +#include +#include +#include +#ifdef HAVE_SYS_TIME_H +#include +#endif +#include +#ifdef HAVE_SYS_FILE_H +#include +#endif +#ifdef HAVE_SYS_IOCTL_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_SYS_UN_H +#include +#endif +#ifdef HAVE_SYS_SOCKIO_H +#include +#endif +#ifdef HAVE_NET_IF_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_NET_IF_DL_H +#include +#endif +#if defined(__linux__) && defined(HAVE_SYS_SYSCALL_H) +#include +#endif + +#include "all-io.h" +#include "uuidP.h" +#include "uuidd.h" +#include "randutils.h" +#include "c.h" + +#ifdef HAVE_TLS +#define THREAD_LOCAL static __thread +#else +#define THREAD_LOCAL static +#endif + +#ifndef LOCK_EX +/* flock() replacement */ +#define LOCK_EX 1 +#define LOCK_SH 2 +#define LOCK_UN 3 +#define LOCK_NB 4 + +static int flock(int fd, int op) +{ + int rc = 0; + +#if defined(F_SETLK) && defined(F_SETLKW) + struct flock fl = {0}; + + switch (op & (LOCK_EX|LOCK_SH|LOCK_UN)) { + case LOCK_EX: + fl.l_type = F_WRLCK; + break; + + case LOCK_SH: + fl.l_type = F_RDLCK; + break; + + case LOCK_UN: + fl.l_type = F_UNLCK; + break; + + default: + errno = EINVAL; + return -1; + } + + fl.l_whence = SEEK_SET; + rc = fcntl (fd, op & LOCK_NB ? F_SETLK : F_SETLKW, &fl); + + if (rc && (errno == EAGAIN)) + errno = EWOULDBLOCK; +#endif /* defined(F_SETLK) && defined(F_SETLKW) */ + + return rc; +} + +#endif /* LOCK_EX */ + +#ifdef _WIN32 +static void gettimeofday (struct timeval *tv, void *dummy) +{ + FILETIME ftime; + uint64_t n; + + GetSystemTimeAsFileTime (&ftime); + n = (((uint64_t) ftime.dwHighDateTime << 32) + + (uint64_t) ftime.dwLowDateTime); + if (n) { + n /= 10; + n -= ((369 * 365 + 89) * (uint64_t) 86400) * 1000000; + } + + tv->tv_sec = n / 1000000; + tv->tv_usec = n % 1000000; +} + +static int getuid (void) +{ + return 1; +} +#endif + +/* + * Get the ethernet hardware address, if we can find it... + * + * XXX for a windows version, probably should use GetAdaptersInfo: + * http://www.codeguru.com/cpp/i-n/network/networkinformation/article.php/c5451 + * commenting out get_node_id just to get gen_uuid to compile under windows + * is not the right way to go! + */ +static int get_node_id(unsigned char *node_id) +{ +#ifdef HAVE_NET_IF_H + int sd; + struct ifreq ifr, *ifrp; + struct ifconf ifc; + char buf[1024]; + int n, i; + unsigned char *a; +#ifdef HAVE_NET_IF_DL_H + struct sockaddr_dl *sdlp; +#endif + +/* + * BSD 4.4 defines the size of an ifreq to be + * max(sizeof(ifreq), sizeof(ifreq.ifr_name)+ifreq.ifr_addr.sa_len + * However, under earlier systems, sa_len isn't present, so the size is + * just sizeof(struct ifreq) + */ +#ifdef HAVE_SA_LEN +#define ifreq_size(i) max(sizeof(struct ifreq),\ + sizeof((i).ifr_name)+(i).ifr_addr.sa_len) +#else +#define ifreq_size(i) sizeof(struct ifreq) +#endif /* HAVE_SA_LEN */ + + sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP); + if (sd < 0) { + return -1; + } + memset(buf, 0, sizeof(buf)); + ifc.ifc_len = sizeof(buf); + ifc.ifc_buf = buf; + if (ioctl (sd, SIOCGIFCONF, (char *)&ifc) < 0) { + close(sd); + return -1; + } + n = ifc.ifc_len; + for (i = 0; i < n; i+= ifreq_size(*ifrp) ) { + ifrp = (struct ifreq *)((char *) ifc.ifc_buf+i); + strncpy(ifr.ifr_name, ifrp->ifr_name, IFNAMSIZ); +#ifdef SIOCGIFHWADDR + if (ioctl(sd, SIOCGIFHWADDR, &ifr) < 0) + continue; + a = (unsigned char *) &ifr.ifr_hwaddr.sa_data; +#else +#ifdef SIOCGENADDR + if (ioctl(sd, SIOCGENADDR, &ifr) < 0) + continue; + a = (unsigned char *) ifr.ifr_enaddr; +#else +#ifdef HAVE_NET_IF_DL_H + sdlp = (struct sockaddr_dl *) &ifrp->ifr_addr; + if ((sdlp->sdl_family != AF_LINK) || (sdlp->sdl_alen != 6)) + continue; + a = (unsigned char *) &sdlp->sdl_data[sdlp->sdl_nlen]; +#else + /* + * XXX we don't have a way of getting the hardware + * address + */ + close(sd); + return 0; +#endif /* HAVE_NET_IF_DL_H */ +#endif /* SIOCGENADDR */ +#endif /* SIOCGIFHWADDR */ + if (!a[0] && !a[1] && !a[2] && !a[3] && !a[4] && !a[5]) + continue; + if (node_id) { + memcpy(node_id, a, 6); + close(sd); + return 1; + } + } + close(sd); +#endif + return 0; +} + +/* Assume that the gettimeofday() has microsecond granularity */ +#define MAX_ADJUSTMENT 10 + +/* + * Get clock from global sequence clock counter. + * + * Return -1 if the clock counter could not be opened/locked (in this case + * pseudorandom value is returned in @ret_clock_seq), otherwise return 0. + */ +static int get_clock(uint32_t *clock_high, uint32_t *clock_low, + uint16_t *ret_clock_seq, int *num) +{ + THREAD_LOCAL int adjustment = 0; + THREAD_LOCAL struct timeval last = {0, 0}; + THREAD_LOCAL int state_fd = -2; + THREAD_LOCAL FILE *state_f; + THREAD_LOCAL uint16_t clock_seq; + struct timeval tv; + uint64_t clock_reg; + mode_t save_umask; + int len; + int ret = 0; + +#ifndef __WIIU__ + if (state_fd == -2) { + save_umask = umask(0); + state_fd = open(LIBUUID_CLOCK_FILE, O_RDWR|O_CREAT|O_CLOEXEC, 0660); + (void) umask(save_umask); + if (state_fd != -1) { + state_f = fdopen(state_fd, "r+" UL_CLOEXECSTR); + if (!state_f) { + close(state_fd); + state_fd = -1; + ret = -1; + } + } + else + ret = -1; + } + if (state_fd >= 0) { + rewind(state_f); + while (flock(state_fd, LOCK_EX) < 0) { + if ((errno == EAGAIN) || (errno == EINTR)) + continue; + fclose(state_f); + close(state_fd); + state_fd = -1; + ret = -1; + break; + } + } + if (state_fd >= 0) { + unsigned int cl; + unsigned long tv1, tv2; + int a; + + if (fscanf(state_f, "clock: %04x tv: %lu %lu adj: %d\n", + &cl, &tv1, &tv2, &a) == 4) { + clock_seq = cl & 0x3FFF; + last.tv_sec = tv1; + last.tv_usec = tv2; + adjustment = a; + } + } +#endif + + if ((last.tv_sec == 0) && (last.tv_usec == 0)) { + random_get_bytes(&clock_seq, sizeof(clock_seq)); + clock_seq &= 0x3FFF; + gettimeofday(&last, 0); + last.tv_sec--; + } + +try_again: + gettimeofday(&tv, 0); + if ((tv.tv_sec < last.tv_sec) || + ((tv.tv_sec == last.tv_sec) && + (tv.tv_usec < last.tv_usec))) { + clock_seq = (clock_seq+1) & 0x3FFF; + adjustment = 0; + last = tv; + } else if ((tv.tv_sec == last.tv_sec) && + (tv.tv_usec == last.tv_usec)) { + if (adjustment >= MAX_ADJUSTMENT) + goto try_again; + adjustment++; + } else { + adjustment = 0; + last = tv; + } + + clock_reg = tv.tv_usec*10 + adjustment; + clock_reg += ((uint64_t) tv.tv_sec)*10000000; + clock_reg += (((uint64_t) 0x01B21DD2) << 32) + 0x13814000; + + if (num && (*num > 1)) { + adjustment += *num - 1; + last.tv_usec += adjustment / 10; + adjustment = adjustment % 10; + last.tv_sec += last.tv_usec / 1000000; + last.tv_usec = last.tv_usec % 1000000; + } + +#ifndef __WIIU__ + if (state_fd >= 0) { + rewind(state_f); + len = fprintf(state_f, + "clock: %04x tv: %016lu %08lu adj: %08d\n", + clock_seq, last.tv_sec, last.tv_usec, adjustment); + fflush(state_f); + if (ftruncate(state_fd, len) < 0) { + fprintf(state_f, " \n"); + fflush(state_f); + } + rewind(state_f); + flock(state_fd, LOCK_UN); + } +#endif + + *clock_high = clock_reg >> 32; + *clock_low = clock_reg; + *ret_clock_seq = clock_seq; + return ret; +} + +#if defined(HAVE_UUIDD) && defined(HAVE_SYS_UN_H) +/* + * Try using the uuidd daemon to generate the UUID + * + * Returns 0 on success, non-zero on failure. + */ +static int get_uuid_via_daemon(int op, uuid_t out, int *num) +{ + char op_buf[64]; + int op_len; + int s; + ssize_t ret; + int32_t reply_len = 0, expected = 16; + struct sockaddr_un srv_addr; + + if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) + return -1; + + srv_addr.sun_family = AF_UNIX; + strcpy(srv_addr.sun_path, UUIDD_SOCKET_PATH); + + if (connect(s, (const struct sockaddr *) &srv_addr, + sizeof(struct sockaddr_un)) < 0) + goto fail; + + op_buf[0] = op; + op_len = 1; + if (op == UUIDD_OP_BULK_TIME_UUID) { + memcpy(op_buf+1, num, sizeof(*num)); + op_len += sizeof(*num); + expected += sizeof(*num); + } + + ret = write(s, op_buf, op_len); + if (ret < 1) + goto fail; + + ret = read_all(s, (char *) &reply_len, sizeof(reply_len)); + if (ret < 0) + goto fail; + + if (reply_len != expected) + goto fail; + + ret = read_all(s, op_buf, reply_len); + + if (op == UUIDD_OP_BULK_TIME_UUID) + memcpy(op_buf+16, num, sizeof(int)); + + memcpy(out, op_buf, 16); + + close(s); + return ((ret == expected) ? 0 : -1); + +fail: + close(s); + return -1; +} + +#else /* !defined(HAVE_UUIDD) && defined(HAVE_SYS_UN_H) */ +static int get_uuid_via_daemon(int op, uuid_t out, int *num) +{ + return -1; +} +#endif + +int __uuid_generate_time(uuid_t out, int *num) +{ + static unsigned char node_id[6]; + static int has_init = 0; + struct uuid uu; + uint32_t clock_mid; + int ret; + + if (!has_init) { + if (get_node_id(node_id) <= 0) { + random_get_bytes(node_id, 6); + /* + * Set multicast bit, to prevent conflicts + * with IEEE 802 addresses obtained from + * network cards + */ + node_id[0] |= 0x01; + } + has_init = 1; + } + ret = get_clock(&clock_mid, &uu.time_low, &uu.clock_seq, num); + uu.clock_seq |= 0x8000; + uu.time_mid = (uint16_t) clock_mid; + uu.time_hi_and_version = ((clock_mid >> 16) & 0x0FFF) | 0x1000; + memcpy(uu.node, node_id, 6); + uuid_pack(&uu, out); + return ret; +} + +/* + * Generate time-based UUID and store it to @out + * + * Tries to guarantee uniqueness of the generated UUIDs by obtaining them from the uuidd daemon, + * or, if uuidd is not usable, by using the global clock state counter (see get_clock()). + * If neither of these is possible (e.g. because of insufficient permissions), it generates + * the UUID anyway, but returns -1. Otherwise, returns 0. + */ +static int uuid_generate_time_generic(uuid_t out) { +#ifdef HAVE_TLS + THREAD_LOCAL int num = 0; + THREAD_LOCAL struct uuid uu; + THREAD_LOCAL time_t last_time = 0; + time_t now; + + if (num > 0) { + now = time(0); + if (now > last_time+1) + num = 0; + } + if (num <= 0) { + num = 1000; + if (get_uuid_via_daemon(UUIDD_OP_BULK_TIME_UUID, + out, &num) == 0) { + last_time = time(0); + uuid_unpack(out, &uu); + num--; + return 0; + } + num = 0; + } + if (num > 0) { + uu.time_low++; + if (uu.time_low == 0) { + uu.time_mid++; + if (uu.time_mid == 0) + uu.time_hi_and_version++; + } + num--; + uuid_pack(&uu, out); + return 0; + } +#else + if (get_uuid_via_daemon(UUIDD_OP_TIME_UUID, out, 0) == 0) + return 0; +#endif + + return __uuid_generate_time(out, 0); +} + +/* + * Generate time-based UUID and store it to @out. + * + * Discards return value from uuid_generate_time_generic() + */ +void uuid_generate_time(uuid_t out) +{ + (void)uuid_generate_time_generic(out); +} + + +int uuid_generate_time_safe(uuid_t out) +{ + return uuid_generate_time_generic(out); +} + + +void __uuid_generate_random(uuid_t out, int *num) +{ + uuid_t buf; + struct uuid uu; + int i, n; + + if (!num || !*num) + n = 1; + else + n = *num; + + for (i = 0; i < n; i++) { + random_get_bytes(buf, sizeof(buf)); + uuid_unpack(buf, &uu); + + uu.clock_seq = (uu.clock_seq & 0x3FFF) | 0x8000; + uu.time_hi_and_version = (uu.time_hi_and_version & 0x0FFF) + | 0x4000; + uuid_pack(&uu, out); + out += sizeof(uuid_t); + } +} + +void uuid_generate_random(uuid_t out) +{ + int num = 1; + /* No real reason to use the daemon for random uuid's -- yet */ + + __uuid_generate_random(out, &num); +} + +/* + * Check whether good random source (/dev/random or /dev/urandom) + * is available. + */ +static int have_random_source(void) +{ + struct stat s; + + return (!stat("/dev/random", &s) || !stat("/dev/urandom", &s)); +} + + +/* + * This is the generic front-end to uuid_generate_random and + * uuid_generate_time. It uses uuid_generate_random only if + * /dev/urandom is available, since otherwise we won't have + * high-quality randomness. + */ +void uuid_generate(uuid_t out) +{ + if (have_random_source()) + uuid_generate_random(out); + else + uuid_generate_time(out); +} diff --git a/libgamestream/uuid/isnull.c b/libgamestream/uuid/isnull.c new file mode 100644 index 00000000..931e7e7d --- /dev/null +++ b/libgamestream/uuid/isnull.c @@ -0,0 +1,48 @@ +/* + * isnull.c --- Check whether or not the UUID is null + * + * Copyright (C) 1996, 1997 Theodore Ts'o. + * + * %Begin-Header% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, and the entire permission notice in its entirety, + * including the disclaimer of warranties. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF + * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * %End-Header% + */ + +#include "uuidP.h" + +/* Returns 1 if the uuid is the NULL uuid */ +int uuid_is_null(const uuid_t uu) +{ + const unsigned char *cp; + int i; + + for (i=0, cp = uu; i < 16; i++) + if (*cp++) + return 0; + return 1; +} + diff --git a/libgamestream/uuid/pack.c b/libgamestream/uuid/pack.c new file mode 100644 index 00000000..6e124766 --- /dev/null +++ b/libgamestream/uuid/pack.c @@ -0,0 +1,69 @@ +/* + * Internal routine for packing UUIDs + * + * Copyright (C) 1996, 1997 Theodore Ts'o. + * + * %Begin-Header% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, and the entire permission notice in its entirety, + * including the disclaimer of warranties. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF + * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * %End-Header% + */ + +#include +#include "uuidP.h" + +void uuid_pack(const struct uuid *uu, uuid_t ptr) +{ + uint32_t tmp; + unsigned char *out = ptr; + + tmp = uu->time_low; + out[3] = (unsigned char) tmp; + tmp >>= 8; + out[2] = (unsigned char) tmp; + tmp >>= 8; + out[1] = (unsigned char) tmp; + tmp >>= 8; + out[0] = (unsigned char) tmp; + + tmp = uu->time_mid; + out[5] = (unsigned char) tmp; + tmp >>= 8; + out[4] = (unsigned char) tmp; + + tmp = uu->time_hi_and_version; + out[7] = (unsigned char) tmp; + tmp >>= 8; + out[6] = (unsigned char) tmp; + + tmp = uu->clock_seq; + out[9] = (unsigned char) tmp; + tmp >>= 8; + out[8] = (unsigned char) tmp; + + memcpy(out+10, uu->node, 6); +} + diff --git a/libgamestream/uuid/parse.c b/libgamestream/uuid/parse.c new file mode 100644 index 00000000..074383ef --- /dev/null +++ b/libgamestream/uuid/parse.c @@ -0,0 +1,79 @@ +/* + * parse.c --- UUID parsing + * + * Copyright (C) 1996, 1997 Theodore Ts'o. + * + * %Begin-Header% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, and the entire permission notice in its entirety, + * including the disclaimer of warranties. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF + * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * %End-Header% + */ + +#include +#include +#include +#include + +#include "uuidP.h" + +int uuid_parse(const char *in, uuid_t uu) +{ + struct uuid uuid; + int i; + const char *cp; + char buf[3]; + + if (strlen(in) != 36) + return -1; + for (i=0, cp = in; i <= 36; i++,cp++) { + if ((i == 8) || (i == 13) || (i == 18) || + (i == 23)) { + if (*cp == '-') + continue; + else + return -1; + } + if (i== 36) + if (*cp == 0) + continue; + if (!isxdigit(*cp)) + return -1; + } + uuid.time_low = strtoul(in, NULL, 16); + uuid.time_mid = strtoul(in+9, NULL, 16); + uuid.time_hi_and_version = strtoul(in+14, NULL, 16); + uuid.clock_seq = strtoul(in+19, NULL, 16); + cp = in+24; + buf[2] = 0; + for (i=0; i < 6; i++) { + buf[0] = *cp++; + buf[1] = *cp++; + uuid.node[i] = strtoul(buf, NULL, 16); + } + + uuid_pack(&uuid, uu); + return 0; +} diff --git a/libgamestream/uuid/randutils.c b/libgamestream/uuid/randutils.c new file mode 100644 index 00000000..5d350a16 --- /dev/null +++ b/libgamestream/uuid/randutils.c @@ -0,0 +1,131 @@ +/* + * General purpose random utilities + * + * Based on libuuid code. + * + * This file may be redistributed under the terms of the + * GNU Lesser General Public License. + */ +#include +#include +#include +#include +#include +#include + +#ifndef __WIIU__ +#include +#endif + +#include "randutils.h" + +#ifdef HAVE_TLS +#define THREAD_LOCAL static __thread +#else +#define THREAD_LOCAL static +#endif + +#if defined(__linux__) && defined(__NR_gettid) && defined(HAVE_JRAND48) +#define DO_JRAND_MIX +THREAD_LOCAL unsigned short ul_jrand_seed[3]; +#endif + +int random_get_fd(void) +{ + int i, fd; + struct timeval tv; + + gettimeofday(&tv, 0); + fd = open("/dev/urandom", O_RDONLY); + if (fd == -1) + fd = open("/dev/random", O_RDONLY | O_NONBLOCK); + if (fd >= 0) { + i = fcntl(fd, F_GETFD); + if (i >= 0) + fcntl(fd, F_SETFD, i | FD_CLOEXEC); + } +#ifndef __WIIU__ + srand((getpid() << 16) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec); +#else + srand((1 << 16) ^ tv.tv_sec ^ tv.tv_usec); +#endif + +#ifdef DO_JRAND_MIX + ul_jrand_seed[0] = getpid() ^ (tv.tv_sec & 0xFFFF); + ul_jrand_seed[1] = getppid() ^ (tv.tv_usec & 0xFFFF); + ul_jrand_seed[2] = (tv.tv_sec ^ tv.tv_usec) >> 16; +#endif + /* Crank the random number generator a few times */ + gettimeofday(&tv, 0); + for (i = (tv.tv_sec ^ tv.tv_usec) & 0x1F; i > 0; i--) + rand(); + return fd; +} + + +/* + * Generate a stream of random nbytes into buf. + * Use /dev/urandom if possible, and if not, + * use glibc pseudo-random functions. + */ +void random_get_bytes(void *buf, size_t nbytes) +{ + size_t i, n = nbytes; + int fd = random_get_fd(); + int lose_counter = 0; + unsigned char *cp = (unsigned char *) buf; + + if (fd >= 0) { + while (n > 0) { + ssize_t x = read(fd, cp, n); + if (x <= 0) { + if (lose_counter++ > 16) + break; + continue; + } + n -= x; + cp += x; + lose_counter = 0; + } + + close(fd); + } + + /* + * We do this all the time, but this is the only source of + * randomness if /dev/random/urandom is out to lunch. + */ + for (cp = buf, i = 0; i < nbytes; i++) + *cp++ ^= (rand() >> 7) & 0xFF; + +#ifdef DO_JRAND_MIX + { + unsigned short tmp_seed[3]; + + memcpy(tmp_seed, ul_jrand_seed, sizeof(tmp_seed)); + ul_jrand_seed[2] = ul_jrand_seed[2] ^ syscall(__NR_gettid); + for (cp = buf, i = 0; i < nbytes; i++) + *cp++ ^= (jrand48(tmp_seed) >> 7) & 0xFF; + memcpy(ul_jrand_seed, tmp_seed, + sizeof(ul_jrand_seed)-sizeof(unsigned short)); + } +#endif + + return; +} + +#ifdef TEST_PROGRAM +int main(int argc __attribute__ ((__unused__)), + char *argv[] __attribute__ ((__unused__))) +{ + unsigned int v, i; + + /* generate and print 10 random numbers */ + for (i = 0; i < 10; i++) { + random_get_bytes(&v, sizeof(v)); + printf("%d\n", v); + } + + return EXIT_SUCCESS; +} +#endif /* TEST_PROGRAM */ diff --git a/libgamestream/uuid/randutils.h b/libgamestream/uuid/randutils.h new file mode 100644 index 00000000..dec5e355 --- /dev/null +++ b/libgamestream/uuid/randutils.h @@ -0,0 +1,12 @@ +#ifndef UTIL_LINUX_RANDUTILS +#define UTIL_LINUX_RANDUTILS + +#ifdef HAVE_SRANDOM +#define srand(x) srandom(x) +#define rand() random() +#endif + +extern int random_get_fd(void); +extern void random_get_bytes(void *buf, size_t nbytes); + +#endif diff --git a/libgamestream/uuid/unpack.c b/libgamestream/uuid/unpack.c new file mode 100644 index 00000000..beaaff3c --- /dev/null +++ b/libgamestream/uuid/unpack.c @@ -0,0 +1,63 @@ +/* + * Internal routine for unpacking UUID + * + * Copyright (C) 1996, 1997 Theodore Ts'o. + * + * %Begin-Header% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, and the entire permission notice in its entirety, + * including the disclaimer of warranties. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF + * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * %End-Header% + */ + +#include +#include "uuidP.h" + +void uuid_unpack(const uuid_t in, struct uuid *uu) +{ + const uint8_t *ptr = in; + uint32_t tmp; + + tmp = *ptr++; + tmp = (tmp << 8) | *ptr++; + tmp = (tmp << 8) | *ptr++; + tmp = (tmp << 8) | *ptr++; + uu->time_low = tmp; + + tmp = *ptr++; + tmp = (tmp << 8) | *ptr++; + uu->time_mid = tmp; + + tmp = *ptr++; + tmp = (tmp << 8) | *ptr++; + uu->time_hi_and_version = tmp; + + tmp = *ptr++; + tmp = (tmp << 8) | *ptr++; + uu->clock_seq = tmp; + + memcpy(uu->node, ptr, 6); +} + diff --git a/libgamestream/uuid/unparse.c b/libgamestream/uuid/unparse.c new file mode 100644 index 00000000..a95bbb04 --- /dev/null +++ b/libgamestream/uuid/unparse.c @@ -0,0 +1,76 @@ +/* + * unparse.c -- convert a UUID to string + * + * Copyright (C) 1996, 1997 Theodore Ts'o. + * + * %Begin-Header% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, and the entire permission notice in its entirety, + * including the disclaimer of warranties. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF + * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * %End-Header% + */ + +#include + +#include "uuidP.h" + +static const char *fmt_lower = + "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x"; + +static const char *fmt_upper = + "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X"; + +#ifdef UUID_UNPARSE_DEFAULT_UPPER +#define FMT_DEFAULT fmt_upper +#else +#define FMT_DEFAULT fmt_lower +#endif + +static void uuid_unparse_x(const uuid_t uu, char *out, const char *fmt) +{ + struct uuid uuid; + + uuid_unpack(uu, &uuid); + sprintf(out, fmt, + uuid.time_low, uuid.time_mid, uuid.time_hi_and_version, + uuid.clock_seq >> 8, uuid.clock_seq & 0xFF, + uuid.node[0], uuid.node[1], uuid.node[2], + uuid.node[3], uuid.node[4], uuid.node[5]); +} + +void uuid_unparse_lower(const uuid_t uu, char *out) +{ + uuid_unparse_x(uu, out, fmt_lower); +} + +void uuid_unparse_upper(const uuid_t uu, char *out) +{ + uuid_unparse_x(uu, out, fmt_upper); +} + +void uuid_unparse(const uuid_t uu, char *out) +{ + uuid_unparse_x(uu, out, FMT_DEFAULT); +} diff --git a/libgamestream/uuid/uuid.h b/libgamestream/uuid/uuid.h new file mode 100644 index 00000000..874d65a1 --- /dev/null +++ b/libgamestream/uuid/uuid.h @@ -0,0 +1,104 @@ +/* + * Public include file for the UUID library + * + * Copyright (C) 1996, 1997, 1998 Theodore Ts'o. + * + * %Begin-Header% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, and the entire permission notice in its entirety, + * including the disclaimer of warranties. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF + * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * %End-Header% + */ + +#ifndef _UUID_UUID_H +#define _UUID_UUID_H + +#include +#ifndef _WIN32 +#include +#endif +#include + +typedef unsigned char uuid_t[16]; + +/* UUID Variant definitions */ +#define UUID_VARIANT_NCS 0 +#define UUID_VARIANT_DCE 1 +#define UUID_VARIANT_MICROSOFT 2 +#define UUID_VARIANT_OTHER 3 + +/* UUID Type definitions */ +#define UUID_TYPE_DCE_TIME 1 +#define UUID_TYPE_DCE_RANDOM 4 + +/* Allow UUID constants to be defined */ +#ifdef __GNUC__ +#define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \ + static const uuid_t name __attribute__ ((unused)) = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15} +#else +#define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \ + static const uuid_t name = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15} +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* clear.c */ +void uuid_clear(uuid_t uu); + +/* compare.c */ +int uuid_compare(const uuid_t uu1, const uuid_t uu2); + +/* copy.c */ +void uuid_copy(uuid_t dst, const uuid_t src); + +/* gen_uuid.c */ +void uuid_generate(uuid_t out); +void uuid_generate_random(uuid_t out); +void uuid_generate_time(uuid_t out); +int uuid_generate_time_safe(uuid_t out); + +/* isnull.c */ +int uuid_is_null(const uuid_t uu); + +/* parse.c */ +int uuid_parse(const char *in, uuid_t uu); + +/* unparse.c */ +void uuid_unparse(const uuid_t uu, char *out); +void uuid_unparse_lower(const uuid_t uu, char *out); +void uuid_unparse_upper(const uuid_t uu, char *out); + +/* uuid_time.c */ +time_t uuid_time(const uuid_t uu, struct timeval *ret_tv); +int uuid_type(const uuid_t uu); +int uuid_variant(const uuid_t uu); + +#ifdef __cplusplus +} +#endif + +#endif /* _UUID_UUID_H */ diff --git a/libgamestream/uuid/uuidP.h b/libgamestream/uuid/uuidP.h new file mode 100644 index 00000000..86a5e266 --- /dev/null +++ b/libgamestream/uuid/uuidP.h @@ -0,0 +1,61 @@ +/* + * uuid.h -- private header file for uuids + * + * Copyright (C) 1996, 1997 Theodore Ts'o. + * + * %Begin-Header% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, and the entire permission notice in its entirety, + * including the disclaimer of warranties. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF + * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * %End-Header% + */ + +#include +#include + +#include "uuid.h" + +#define LIBUUID_CLOCK_FILE "/var/lib/libuuid/clock.txt" + +/* + * Offset between 15-Oct-1582 and 1-Jan-70 + */ +#define TIME_OFFSET_HIGH 0x01B21DD2 +#define TIME_OFFSET_LOW 0x13814000 + +struct uuid { + uint32_t time_low; + uint16_t time_mid; + uint16_t time_hi_and_version; + uint16_t clock_seq; + uint8_t node[6]; +}; + + +/* + * prototypes + */ +void uuid_pack(const struct uuid *uu, uuid_t ptr); +void uuid_unpack(const uuid_t in, struct uuid *uu); diff --git a/libgamestream/uuid/uuidd.h b/libgamestream/uuid/uuidd.h new file mode 100644 index 00000000..2f709680 --- /dev/null +++ b/libgamestream/uuid/uuidd.h @@ -0,0 +1,54 @@ +/* + * Definitions used by the uuidd daemon + * + * Copyright (C) 2007 Theodore Ts'o. + * + * %Begin-Header% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, and the entire permission notice in its entirety, + * including the disclaimer of warranties. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF + * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * %End-Header% + */ + +#ifndef _UUID_UUIDD_H +#define _UUID_UUIDD_H + +#define UUIDD_DIR _PATH_LOCALSTATEDIR "/uuidd" +#define UUIDD_SOCKET_PATH UUIDD_DIR "/request" +#define UUIDD_PIDFILE_PATH UUIDD_DIR "/uuidd.pid" +#define UUIDD_PATH "/usr/sbin/uuidd" + +#define UUIDD_OP_GETPID 0 +#define UUIDD_OP_GET_MAXOP 1 +#define UUIDD_OP_TIME_UUID 2 +#define UUIDD_OP_RANDOM_UUID 3 +#define UUIDD_OP_BULK_TIME_UUID 4 +#define UUIDD_OP_BULK_RANDOM_UUID 5 +#define UUIDD_MAX_OP UUIDD_OP_BULK_RANDOM_UUID + +extern int __uuid_generate_time(uuid_t out, int *num); +extern void __uuid_generate_random(uuid_t out, int *num); + +#endif /* _UUID_UUID_H */ diff --git a/libgamestream/xml.c b/libgamestream/xml.c index acf7fa6d..dd8a0b26 100644 --- a/libgamestream/xml.c +++ b/libgamestream/xml.c @@ -25,8 +25,6 @@ #define STATUS_OK 200 -static XML_Parser parser; - struct xml_query { char *memory; size_t size; diff --git a/src/wiiu/wiiu.h b/src/wiiu/wiiu.h index a4ae0e25..7843a8b4 100644 --- a/src/wiiu/wiiu.h +++ b/src/wiiu/wiiu.h @@ -4,7 +4,7 @@ #define _GNU_SOURCE #endif -#define VERSION_STRING "v1.5" +#define VERSION_STRING "v1.5.1-Unofficial" enum { STATE_INVALID, diff --git a/third_party/h264bitstream/h264_stream.c b/third_party/h264bitstream/h264_stream.c index 16a3c90f..385fb6f6 100644 --- a/third_party/h264bitstream/h264_stream.c +++ b/third_party/h264bitstream/h264_stream.c @@ -24,16 +24,11 @@ #include #include -#include #include "bs.h" #include "h264_stream.h" #include "h264_sei.h" -FILE* h264_dbgfile = NULL; - -#define printf(...) fprintf((h264_dbgfile == NULL ? stdout : h264_dbgfile), __VA_ARGS__) - /** Calculate the log base 2 of the argument, rounded up. Zero or negative arguments return zero @@ -554,7 +549,7 @@ void read_pic_parameter_set_rbsp(h264_stream_t* h, bs_t* b) if( 1 ) { have_more_data = more_rbsp_data(h, b); } if( 0 ) { - have_more_data = pps->transform_8x8_mode_flag | pps->pic_scaling_matrix_present_flag | pps->second_chroma_qp_index_offset != 0; + have_more_data = pps->transform_8x8_mode_flag | pps->pic_scaling_matrix_present_flag | (pps->second_chroma_qp_index_offset != 0); } if( have_more_data ) @@ -1441,7 +1436,7 @@ void write_pic_parameter_set_rbsp(h264_stream_t* h, bs_t* b) if( 0 ) { have_more_data = more_rbsp_data(h, b); } if( 1 ) { - have_more_data = pps->transform_8x8_mode_flag | pps->pic_scaling_matrix_present_flag | pps->second_chroma_qp_index_offset != 0; + have_more_data = pps->transform_8x8_mode_flag | pps->pic_scaling_matrix_present_flag | (pps->second_chroma_qp_index_offset != 0); } if( have_more_data ) @@ -1899,890 +1894,3 @@ void write_dec_ref_pic_marking(h264_stream_t* h, bs_t* b) } } } - - -void read_debug_seq_parameter_set_rbsp(h264_stream_t* h, bs_t* b); -void read_debug_scaling_list(bs_t* b, int* scalingList, int sizeOfScalingList, int* useDefaultScalingMatrixFlag ); -void read_debug_vui_parameters(h264_stream_t* h, bs_t* b); -void read_debug_hrd_parameters(h264_stream_t* h, bs_t* b); -void read_debug_pic_parameter_set_rbsp(h264_stream_t* h, bs_t* b); -void read_debug_sei_rbsp(h264_stream_t* h, bs_t* b); -void read_debug_sei_message(h264_stream_t* h, bs_t* b); -void read_debug_access_unit_delimiter_rbsp(h264_stream_t* h, bs_t* b); -void read_debug_end_of_seq_rbsp(h264_stream_t* h, bs_t* b); -void read_debug_end_of_stream_rbsp(h264_stream_t* h, bs_t* b); -void read_debug_filler_data_rbsp(h264_stream_t* h, bs_t* b); -void read_debug_slice_layer_rbsp(h264_stream_t* h, bs_t* b); -void read_debug_rbsp_slice_trailing_bits(h264_stream_t* h, bs_t* b); -void read_debug_rbsp_trailing_bits(h264_stream_t* h, bs_t* b); -void read_debug_slice_header(h264_stream_t* h, bs_t* b); -void read_debug_ref_pic_list_reordering(h264_stream_t* h, bs_t* b); -void read_debug_pred_weight_table(h264_stream_t* h, bs_t* b); -void read_debug_dec_ref_pic_marking(h264_stream_t* h, bs_t* b); - - - -//7.3.1 NAL unit syntax -int read_debug_nal_unit(h264_stream_t* h, uint8_t* buf, int size) -{ - nal_t* nal = h->nal; - - int nal_size = size; - int rbsp_size = size; - uint8_t* rbsp_buf = (uint8_t*)calloc(1, rbsp_size); - - if( 1 ) - { - int rc = nal_to_rbsp(buf, &nal_size, rbsp_buf, &rbsp_size); - - if (rc < 0) { free(rbsp_buf); return -1; } // handle conversion error - } - - if( 0 ) - { - rbsp_size = size*3/4; // NOTE this may have to be slightly smaller (3/4 smaller, worst case) in order to be guaranteed to fit - } - - bs_t* b = bs_new(rbsp_buf, rbsp_size); - printf("%d.%d: ", b->p - b->start, b->bits_left); int forbidden_zero_bit = bs_read_u(b, 1); printf("forbidden_zero_bit: %d \n", forbidden_zero_bit); - printf("%d.%d: ", b->p - b->start, b->bits_left); nal->nal_ref_idc = bs_read_u(b, 2); printf("nal->nal_ref_idc: %d \n", nal->nal_ref_idc); - printf("%d.%d: ", b->p - b->start, b->bits_left); nal->nal_unit_type = bs_read_u(b, 5); printf("nal->nal_unit_type: %d \n", nal->nal_unit_type); - - switch ( nal->nal_unit_type ) - { - case NAL_UNIT_TYPE_CODED_SLICE_IDR: - case NAL_UNIT_TYPE_CODED_SLICE_NON_IDR: - case NAL_UNIT_TYPE_CODED_SLICE_AUX: - read_debug_slice_layer_rbsp(h, b); - break; - -#ifdef HAVE_SEI - case NAL_UNIT_TYPE_SEI: - read_debug_sei_rbsp(h, b); - break; -#endif - - case NAL_UNIT_TYPE_SPS: - read_debug_seq_parameter_set_rbsp(h, b); - break; - - case NAL_UNIT_TYPE_PPS: - read_debug_pic_parameter_set_rbsp(h, b); - break; - - case NAL_UNIT_TYPE_AUD: - read_debug_access_unit_delimiter_rbsp(h, b); - break; - - case NAL_UNIT_TYPE_END_OF_SEQUENCE: - read_debug_end_of_seq_rbsp(h, b); - break; - - case NAL_UNIT_TYPE_END_OF_STREAM: - read_debug_end_of_stream_rbsp(h, b); - break; - - case NAL_UNIT_TYPE_FILLER: - case NAL_UNIT_TYPE_SPS_EXT: - case NAL_UNIT_TYPE_UNSPECIFIED: - case NAL_UNIT_TYPE_CODED_SLICE_DATA_PARTITION_A: - case NAL_UNIT_TYPE_CODED_SLICE_DATA_PARTITION_B: - case NAL_UNIT_TYPE_CODED_SLICE_DATA_PARTITION_C: - default: - return -1; - } - - if (bs_overrun(b)) { bs_free(b); free(rbsp_buf); return -1; } - - if( 0 ) - { - // now get the actual size used - rbsp_size = bs_pos(b); - - int rc = rbsp_to_nal(rbsp_buf, &rbsp_size, buf, &nal_size); - if (rc < 0) { bs_free(b); free(rbsp_buf); return -1; } - } - - bs_free(b); - free(rbsp_buf); - - return nal_size; -} - - - -//7.3.2.1 Sequence parameter set RBSP syntax -void read_debug_seq_parameter_set_rbsp(h264_stream_t* h, bs_t* b) -{ - int i; - - sps_t* sps = h->sps; - if( 1 ) - { - memset(sps, 0, sizeof(sps_t)); - sps->chroma_format_idc = 1; - } - - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->profile_idc = bs_read_u8(b); printf("sps->profile_idc: %d \n", sps->profile_idc); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->constraint_set0_flag = bs_read_u1(b); printf("sps->constraint_set0_flag: %d \n", sps->constraint_set0_flag); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->constraint_set1_flag = bs_read_u1(b); printf("sps->constraint_set1_flag: %d \n", sps->constraint_set1_flag); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->constraint_set2_flag = bs_read_u1(b); printf("sps->constraint_set2_flag: %d \n", sps->constraint_set2_flag); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->constraint_set3_flag = bs_read_u1(b); printf("sps->constraint_set3_flag: %d \n", sps->constraint_set3_flag); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->constraint_set4_flag = bs_read_u1(b); printf("sps->constraint_set4_flag: %d \n", sps->constraint_set4_flag); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->constraint_set5_flag = bs_read_u1(b); printf("sps->constraint_set5_flag: %d \n", sps->constraint_set5_flag); - printf("%d.%d: ", b->p - b->start, b->bits_left); int reserved_zero_2bits = bs_read_u(b, 2); printf("reserved_zero_2bits: %d \n", reserved_zero_2bits); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->level_idc = bs_read_u8(b); printf("sps->level_idc: %d \n", sps->level_idc); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->seq_parameter_set_id = bs_read_ue(b); printf("sps->seq_parameter_set_id: %d \n", sps->seq_parameter_set_id); - - if( sps->profile_idc == 100 || sps->profile_idc == 110 || - sps->profile_idc == 122 || sps->profile_idc == 144 ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->chroma_format_idc = bs_read_ue(b); printf("sps->chroma_format_idc: %d \n", sps->chroma_format_idc); - if( sps->chroma_format_idc == 3 ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->residual_colour_transform_flag = bs_read_u1(b); printf("sps->residual_colour_transform_flag: %d \n", sps->residual_colour_transform_flag); - } - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->bit_depth_luma_minus8 = bs_read_ue(b); printf("sps->bit_depth_luma_minus8: %d \n", sps->bit_depth_luma_minus8); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->bit_depth_chroma_minus8 = bs_read_ue(b); printf("sps->bit_depth_chroma_minus8: %d \n", sps->bit_depth_chroma_minus8); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->qpprime_y_zero_transform_bypass_flag = bs_read_u1(b); printf("sps->qpprime_y_zero_transform_bypass_flag: %d \n", sps->qpprime_y_zero_transform_bypass_flag); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->seq_scaling_matrix_present_flag = bs_read_u1(b); printf("sps->seq_scaling_matrix_present_flag: %d \n", sps->seq_scaling_matrix_present_flag); - if( sps->seq_scaling_matrix_present_flag ) - { - for( i = 0; i < 8; i++ ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->seq_scaling_list_present_flag[ i ] = bs_read_u1(b); printf("sps->seq_scaling_list_present_flag[ i ]: %d \n", sps->seq_scaling_list_present_flag[ i ]); - if( sps->seq_scaling_list_present_flag[ i ] ) - { - if( i < 6 ) - { - read_debug_scaling_list( b, sps->ScalingList4x4[ i ], 16, - &( sps->UseDefaultScalingMatrix4x4Flag[ i ] ) ); - } - else - { - read_debug_scaling_list( b, sps->ScalingList8x8[ i - 6 ], 64, - &( sps->UseDefaultScalingMatrix8x8Flag[ i - 6 ] ) ); - } - } - } - } - } - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->log2_max_frame_num_minus4 = bs_read_ue(b); printf("sps->log2_max_frame_num_minus4: %d \n", sps->log2_max_frame_num_minus4); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->pic_order_cnt_type = bs_read_ue(b); printf("sps->pic_order_cnt_type: %d \n", sps->pic_order_cnt_type); - if( sps->pic_order_cnt_type == 0 ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->log2_max_pic_order_cnt_lsb_minus4 = bs_read_ue(b); printf("sps->log2_max_pic_order_cnt_lsb_minus4: %d \n", sps->log2_max_pic_order_cnt_lsb_minus4); - } - else if( sps->pic_order_cnt_type == 1 ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->delta_pic_order_always_zero_flag = bs_read_u1(b); printf("sps->delta_pic_order_always_zero_flag: %d \n", sps->delta_pic_order_always_zero_flag); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->offset_for_non_ref_pic = bs_read_se(b); printf("sps->offset_for_non_ref_pic: %d \n", sps->offset_for_non_ref_pic); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->offset_for_top_to_bottom_field = bs_read_se(b); printf("sps->offset_for_top_to_bottom_field: %d \n", sps->offset_for_top_to_bottom_field); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->num_ref_frames_in_pic_order_cnt_cycle = bs_read_ue(b); printf("sps->num_ref_frames_in_pic_order_cnt_cycle: %d \n", sps->num_ref_frames_in_pic_order_cnt_cycle); - for( i = 0; i < sps->num_ref_frames_in_pic_order_cnt_cycle; i++ ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->offset_for_ref_frame[ i ] = bs_read_se(b); printf("sps->offset_for_ref_frame[ i ]: %d \n", sps->offset_for_ref_frame[ i ]); - } - } - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->num_ref_frames = bs_read_ue(b); printf("sps->num_ref_frames: %d \n", sps->num_ref_frames); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->gaps_in_frame_num_value_allowed_flag = bs_read_u1(b); printf("sps->gaps_in_frame_num_value_allowed_flag: %d \n", sps->gaps_in_frame_num_value_allowed_flag); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->pic_width_in_mbs_minus1 = bs_read_ue(b); printf("sps->pic_width_in_mbs_minus1: %d \n", sps->pic_width_in_mbs_minus1); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->pic_height_in_map_units_minus1 = bs_read_ue(b); printf("sps->pic_height_in_map_units_minus1: %d \n", sps->pic_height_in_map_units_minus1); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->frame_mbs_only_flag = bs_read_u1(b); printf("sps->frame_mbs_only_flag: %d \n", sps->frame_mbs_only_flag); - if( !sps->frame_mbs_only_flag ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->mb_adaptive_frame_field_flag = bs_read_u1(b); printf("sps->mb_adaptive_frame_field_flag: %d \n", sps->mb_adaptive_frame_field_flag); - } - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->direct_8x8_inference_flag = bs_read_u1(b); printf("sps->direct_8x8_inference_flag: %d \n", sps->direct_8x8_inference_flag); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->frame_cropping_flag = bs_read_u1(b); printf("sps->frame_cropping_flag: %d \n", sps->frame_cropping_flag); - if( sps->frame_cropping_flag ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->frame_crop_left_offset = bs_read_ue(b); printf("sps->frame_crop_left_offset: %d \n", sps->frame_crop_left_offset); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->frame_crop_right_offset = bs_read_ue(b); printf("sps->frame_crop_right_offset: %d \n", sps->frame_crop_right_offset); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->frame_crop_top_offset = bs_read_ue(b); printf("sps->frame_crop_top_offset: %d \n", sps->frame_crop_top_offset); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->frame_crop_bottom_offset = bs_read_ue(b); printf("sps->frame_crop_bottom_offset: %d \n", sps->frame_crop_bottom_offset); - } - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui_parameters_present_flag = bs_read_u1(b); printf("sps->vui_parameters_present_flag: %d \n", sps->vui_parameters_present_flag); - if( sps->vui_parameters_present_flag ) - { - read_debug_vui_parameters(h, b); - } - read_debug_rbsp_trailing_bits(h, b); - - if( 1 ) - { - memcpy(h->sps_table[sps->seq_parameter_set_id], h->sps, sizeof(sps_t)); - } -} - - -//7.3.2.1.1 Scaling list syntax -void read_debug_scaling_list(bs_t* b, int* scalingList, int sizeOfScalingList, int* useDefaultScalingMatrixFlag ) -{ - // NOTE need to be able to set useDefaultScalingMatrixFlag when reading, hence passing as pointer - int lastScale = 8; - int nextScale = 8; - int delta_scale; - for( int j = 0; j < sizeOfScalingList; j++ ) - { - if( nextScale != 0 ) - { - if( 0 ) - { - nextScale = scalingList[ j ]; - if (useDefaultScalingMatrixFlag[0]) { nextScale = 0; } - delta_scale = (nextScale - lastScale) % 256 ; - } - - printf("%d.%d: ", b->p - b->start, b->bits_left); delta_scale = bs_read_se(b); printf("delta_scale: %d \n", delta_scale); - - if( 1 ) - { - nextScale = ( lastScale + delta_scale + 256 ) % 256; - useDefaultScalingMatrixFlag[0] = ( j == 0 && nextScale == 0 ); - } - } - if( 1 ) - { - scalingList[ j ] = ( nextScale == 0 ) ? lastScale : nextScale; - } - lastScale = scalingList[ j ]; - } -} - -//Appendix E.1.1 VUI parameters syntax -void read_debug_vui_parameters(h264_stream_t* h, bs_t* b) -{ - sps_t* sps = h->sps; - - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.aspect_ratio_info_present_flag = bs_read_u1(b); printf("sps->vui.aspect_ratio_info_present_flag: %d \n", sps->vui.aspect_ratio_info_present_flag); - if( sps->vui.aspect_ratio_info_present_flag ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.aspect_ratio_idc = bs_read_u8(b); printf("sps->vui.aspect_ratio_idc: %d \n", sps->vui.aspect_ratio_idc); - if( sps->vui.aspect_ratio_idc == SAR_Extended ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.sar_width = bs_read_u(b, 16); printf("sps->vui.sar_width: %d \n", sps->vui.sar_width); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.sar_height = bs_read_u(b, 16); printf("sps->vui.sar_height: %d \n", sps->vui.sar_height); - } - } - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.overscan_info_present_flag = bs_read_u1(b); printf("sps->vui.overscan_info_present_flag: %d \n", sps->vui.overscan_info_present_flag); - if( sps->vui.overscan_info_present_flag ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.overscan_appropriate_flag = bs_read_u1(b); printf("sps->vui.overscan_appropriate_flag: %d \n", sps->vui.overscan_appropriate_flag); - } - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.video_signal_type_present_flag = bs_read_u1(b); printf("sps->vui.video_signal_type_present_flag: %d \n", sps->vui.video_signal_type_present_flag); - if( sps->vui.video_signal_type_present_flag ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.video_format = bs_read_u(b, 3); printf("sps->vui.video_format: %d \n", sps->vui.video_format); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.video_full_range_flag = bs_read_u1(b); printf("sps->vui.video_full_range_flag: %d \n", sps->vui.video_full_range_flag); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.colour_description_present_flag = bs_read_u1(b); printf("sps->vui.colour_description_present_flag: %d \n", sps->vui.colour_description_present_flag); - if( sps->vui.colour_description_present_flag ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.colour_primaries = bs_read_u8(b); printf("sps->vui.colour_primaries: %d \n", sps->vui.colour_primaries); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.transfer_characteristics = bs_read_u8(b); printf("sps->vui.transfer_characteristics: %d \n", sps->vui.transfer_characteristics); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.matrix_coefficients = bs_read_u8(b); printf("sps->vui.matrix_coefficients: %d \n", sps->vui.matrix_coefficients); - } - } - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.chroma_loc_info_present_flag = bs_read_u1(b); printf("sps->vui.chroma_loc_info_present_flag: %d \n", sps->vui.chroma_loc_info_present_flag); - if( sps->vui.chroma_loc_info_present_flag ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.chroma_sample_loc_type_top_field = bs_read_ue(b); printf("sps->vui.chroma_sample_loc_type_top_field: %d \n", sps->vui.chroma_sample_loc_type_top_field); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.chroma_sample_loc_type_bottom_field = bs_read_ue(b); printf("sps->vui.chroma_sample_loc_type_bottom_field: %d \n", sps->vui.chroma_sample_loc_type_bottom_field); - } - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.timing_info_present_flag = bs_read_u1(b); printf("sps->vui.timing_info_present_flag: %d \n", sps->vui.timing_info_present_flag); - if( sps->vui.timing_info_present_flag ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.num_units_in_tick = bs_read_u(b, 32); printf("sps->vui.num_units_in_tick: %d \n", sps->vui.num_units_in_tick); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.time_scale = bs_read_u(b, 32); printf("sps->vui.time_scale: %d \n", sps->vui.time_scale); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.fixed_frame_rate_flag = bs_read_u1(b); printf("sps->vui.fixed_frame_rate_flag: %d \n", sps->vui.fixed_frame_rate_flag); - } - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.nal_hrd_parameters_present_flag = bs_read_u1(b); printf("sps->vui.nal_hrd_parameters_present_flag: %d \n", sps->vui.nal_hrd_parameters_present_flag); - if( sps->vui.nal_hrd_parameters_present_flag ) - { - read_debug_hrd_parameters(h, b); - } - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.vcl_hrd_parameters_present_flag = bs_read_u1(b); printf("sps->vui.vcl_hrd_parameters_present_flag: %d \n", sps->vui.vcl_hrd_parameters_present_flag); - if( sps->vui.vcl_hrd_parameters_present_flag ) - { - read_debug_hrd_parameters(h, b); - } - if( sps->vui.nal_hrd_parameters_present_flag || sps->vui.vcl_hrd_parameters_present_flag ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.low_delay_hrd_flag = bs_read_u1(b); printf("sps->vui.low_delay_hrd_flag: %d \n", sps->vui.low_delay_hrd_flag); - } - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.pic_struct_present_flag = bs_read_u1(b); printf("sps->vui.pic_struct_present_flag: %d \n", sps->vui.pic_struct_present_flag); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.bitstream_restriction_flag = bs_read_u1(b); printf("sps->vui.bitstream_restriction_flag: %d \n", sps->vui.bitstream_restriction_flag); - if( sps->vui.bitstream_restriction_flag ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.motion_vectors_over_pic_boundaries_flag = bs_read_u1(b); printf("sps->vui.motion_vectors_over_pic_boundaries_flag: %d \n", sps->vui.motion_vectors_over_pic_boundaries_flag); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.max_bytes_per_pic_denom = bs_read_ue(b); printf("sps->vui.max_bytes_per_pic_denom: %d \n", sps->vui.max_bytes_per_pic_denom); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.max_bits_per_mb_denom = bs_read_ue(b); printf("sps->vui.max_bits_per_mb_denom: %d \n", sps->vui.max_bits_per_mb_denom); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.log2_max_mv_length_horizontal = bs_read_ue(b); printf("sps->vui.log2_max_mv_length_horizontal: %d \n", sps->vui.log2_max_mv_length_horizontal); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.log2_max_mv_length_vertical = bs_read_ue(b); printf("sps->vui.log2_max_mv_length_vertical: %d \n", sps->vui.log2_max_mv_length_vertical); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.num_reorder_frames = bs_read_ue(b); printf("sps->vui.num_reorder_frames: %d \n", sps->vui.num_reorder_frames); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->vui.max_dec_frame_buffering = bs_read_ue(b); printf("sps->vui.max_dec_frame_buffering: %d \n", sps->vui.max_dec_frame_buffering); - } -} - - -//Appendix E.1.2 HRD parameters syntax -void read_debug_hrd_parameters(h264_stream_t* h, bs_t* b) -{ - sps_t* sps = h->sps; - - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->hrd.cpb_cnt_minus1 = bs_read_ue(b); printf("sps->hrd.cpb_cnt_minus1: %d \n", sps->hrd.cpb_cnt_minus1); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->hrd.bit_rate_scale = bs_read_u(b, 4); printf("sps->hrd.bit_rate_scale: %d \n", sps->hrd.bit_rate_scale); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->hrd.cpb_size_scale = bs_read_u(b, 4); printf("sps->hrd.cpb_size_scale: %d \n", sps->hrd.cpb_size_scale); - for( int SchedSelIdx = 0; SchedSelIdx <= sps->hrd.cpb_cnt_minus1; SchedSelIdx++ ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->hrd.bit_rate_value_minus1[ SchedSelIdx ] = bs_read_ue(b); printf("sps->hrd.bit_rate_value_minus1[ SchedSelIdx ]: %d \n", sps->hrd.bit_rate_value_minus1[ SchedSelIdx ]); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->hrd.cpb_size_value_minus1[ SchedSelIdx ] = bs_read_ue(b); printf("sps->hrd.cpb_size_value_minus1[ SchedSelIdx ]: %d \n", sps->hrd.cpb_size_value_minus1[ SchedSelIdx ]); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->hrd.cbr_flag[ SchedSelIdx ] = bs_read_u1(b); printf("sps->hrd.cbr_flag[ SchedSelIdx ]: %d \n", sps->hrd.cbr_flag[ SchedSelIdx ]); - } - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->hrd.initial_cpb_removal_delay_length_minus1 = bs_read_u(b, 5); printf("sps->hrd.initial_cpb_removal_delay_length_minus1: %d \n", sps->hrd.initial_cpb_removal_delay_length_minus1); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->hrd.cpb_removal_delay_length_minus1 = bs_read_u(b, 5); printf("sps->hrd.cpb_removal_delay_length_minus1: %d \n", sps->hrd.cpb_removal_delay_length_minus1); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->hrd.dpb_output_delay_length_minus1 = bs_read_u(b, 5); printf("sps->hrd.dpb_output_delay_length_minus1: %d \n", sps->hrd.dpb_output_delay_length_minus1); - printf("%d.%d: ", b->p - b->start, b->bits_left); sps->hrd.time_offset_length = bs_read_u(b, 5); printf("sps->hrd.time_offset_length: %d \n", sps->hrd.time_offset_length); -} - - -/* -UNIMPLEMENTED -//7.3.2.1.2 Sequence parameter set extension RBSP syntax -int read_debug_seq_parameter_set_extension_rbsp(bs_t* b, sps_ext_t* sps_ext) { - printf("%d.%d: ", b->p - b->start, b->bits_left); seq_parameter_set_id = bs_read_ue(b); printf("seq_parameter_set_id: %d \n", seq_parameter_set_id); - printf("%d.%d: ", b->p - b->start, b->bits_left); aux_format_idc = bs_read_ue(b); printf("aux_format_idc: %d \n", aux_format_idc); - if( aux_format_idc != 0 ) { - printf("%d.%d: ", b->p - b->start, b->bits_left); bit_depth_aux_minus8 = bs_read_ue(b); printf("bit_depth_aux_minus8: %d \n", bit_depth_aux_minus8); - printf("%d.%d: ", b->p - b->start, b->bits_left); alpha_incr_flag = bs_read_u1(b); printf("alpha_incr_flag: %d \n", alpha_incr_flag); - alpha_opaque_value = bs_read_debug_u(v); - alpha_transparent_value = bs_read_debug_u(v); - } - printf("%d.%d: ", b->p - b->start, b->bits_left); additional_extension_flag = bs_read_u1(b); printf("additional_extension_flag: %d \n", additional_extension_flag); - read_debug_rbsp_trailing_bits(); -} -*/ - -//7.3.2.2 Picture parameter set RBSP syntax -void read_debug_pic_parameter_set_rbsp(h264_stream_t* h, bs_t* b) -{ - pps_t* pps = h->pps; - if( 1 ) - { - memset(pps, 0, sizeof(pps_t)); - } - - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->pic_parameter_set_id = bs_read_ue(b); printf("pps->pic_parameter_set_id: %d \n", pps->pic_parameter_set_id); - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->seq_parameter_set_id = bs_read_ue(b); printf("pps->seq_parameter_set_id: %d \n", pps->seq_parameter_set_id); - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->entropy_coding_mode_flag = bs_read_u1(b); printf("pps->entropy_coding_mode_flag: %d \n", pps->entropy_coding_mode_flag); - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->pic_order_present_flag = bs_read_u1(b); printf("pps->pic_order_present_flag: %d \n", pps->pic_order_present_flag); - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->num_slice_groups_minus1 = bs_read_ue(b); printf("pps->num_slice_groups_minus1: %d \n", pps->num_slice_groups_minus1); - - if( pps->num_slice_groups_minus1 > 0 ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->slice_group_map_type = bs_read_ue(b); printf("pps->slice_group_map_type: %d \n", pps->slice_group_map_type); - if( pps->slice_group_map_type == 0 ) - { - for( int i_group = 0; i_group <= pps->num_slice_groups_minus1; i_group++ ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->run_length_minus1[ i_group ] = bs_read_ue(b); printf("pps->run_length_minus1[ i_group ]: %d \n", pps->run_length_minus1[ i_group ]); - } - } - else if( pps->slice_group_map_type == 2 ) - { - for( int i_group = 0; i_group < pps->num_slice_groups_minus1; i_group++ ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->top_left[ i_group ] = bs_read_ue(b); printf("pps->top_left[ i_group ]: %d \n", pps->top_left[ i_group ]); - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->bottom_right[ i_group ] = bs_read_ue(b); printf("pps->bottom_right[ i_group ]: %d \n", pps->bottom_right[ i_group ]); - } - } - else if( pps->slice_group_map_type == 3 || - pps->slice_group_map_type == 4 || - pps->slice_group_map_type == 5 ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->slice_group_change_direction_flag = bs_read_u1(b); printf("pps->slice_group_change_direction_flag: %d \n", pps->slice_group_change_direction_flag); - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->slice_group_change_rate_minus1 = bs_read_ue(b); printf("pps->slice_group_change_rate_minus1: %d \n", pps->slice_group_change_rate_minus1); - } - else if( pps->slice_group_map_type == 6 ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->pic_size_in_map_units_minus1 = bs_read_ue(b); printf("pps->pic_size_in_map_units_minus1: %d \n", pps->pic_size_in_map_units_minus1); - for( int i = 0; i <= pps->pic_size_in_map_units_minus1; i++ ) - { - int v = intlog2( pps->num_slice_groups_minus1 + 1 ); - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->slice_group_id[ i ] = bs_read_u(b, v); printf("pps->slice_group_id[ i ]: %d \n", pps->slice_group_id[ i ]); - } - } - } - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->num_ref_idx_l0_active_minus1 = bs_read_ue(b); printf("pps->num_ref_idx_l0_active_minus1: %d \n", pps->num_ref_idx_l0_active_minus1); - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->num_ref_idx_l1_active_minus1 = bs_read_ue(b); printf("pps->num_ref_idx_l1_active_minus1: %d \n", pps->num_ref_idx_l1_active_minus1); - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->weighted_pred_flag = bs_read_u1(b); printf("pps->weighted_pred_flag: %d \n", pps->weighted_pred_flag); - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->weighted_bipred_idc = bs_read_u(b, 2); printf("pps->weighted_bipred_idc: %d \n", pps->weighted_bipred_idc); - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->pic_init_qp_minus26 = bs_read_se(b); printf("pps->pic_init_qp_minus26: %d \n", pps->pic_init_qp_minus26); - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->pic_init_qs_minus26 = bs_read_se(b); printf("pps->pic_init_qs_minus26: %d \n", pps->pic_init_qs_minus26); - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->chroma_qp_index_offset = bs_read_se(b); printf("pps->chroma_qp_index_offset: %d \n", pps->chroma_qp_index_offset); - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->deblocking_filter_control_present_flag = bs_read_u1(b); printf("pps->deblocking_filter_control_present_flag: %d \n", pps->deblocking_filter_control_present_flag); - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->constrained_intra_pred_flag = bs_read_u1(b); printf("pps->constrained_intra_pred_flag: %d \n", pps->constrained_intra_pred_flag); - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->redundant_pic_cnt_present_flag = bs_read_u1(b); printf("pps->redundant_pic_cnt_present_flag: %d \n", pps->redundant_pic_cnt_present_flag); - - int have_more_data = 0; - if( 1 ) { have_more_data = more_rbsp_data(h, b); } - if( 0 ) - { - have_more_data = pps->transform_8x8_mode_flag | pps->pic_scaling_matrix_present_flag | pps->second_chroma_qp_index_offset != 0; - } - - if( have_more_data ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->transform_8x8_mode_flag = bs_read_u1(b); printf("pps->transform_8x8_mode_flag: %d \n", pps->transform_8x8_mode_flag); - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->pic_scaling_matrix_present_flag = bs_read_u1(b); printf("pps->pic_scaling_matrix_present_flag: %d \n", pps->pic_scaling_matrix_present_flag); - if( pps->pic_scaling_matrix_present_flag ) - { - for( int i = 0; i < 6 + 2* pps->transform_8x8_mode_flag; i++ ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->pic_scaling_list_present_flag[ i ] = bs_read_u1(b); printf("pps->pic_scaling_list_present_flag[ i ]: %d \n", pps->pic_scaling_list_present_flag[ i ]); - if( pps->pic_scaling_list_present_flag[ i ] ) - { - if( i < 6 ) - { - read_debug_scaling_list( b, pps->ScalingList4x4[ i ], 16, - &( pps->UseDefaultScalingMatrix4x4Flag[ i ] ) ); - } - else - { - read_debug_scaling_list( b, pps->ScalingList8x8[ i - 6 ], 64, - &( pps->UseDefaultScalingMatrix8x8Flag[ i - 6 ] ) ); - } - } - } - } - printf("%d.%d: ", b->p - b->start, b->bits_left); pps->second_chroma_qp_index_offset = bs_read_se(b); printf("pps->second_chroma_qp_index_offset: %d \n", pps->second_chroma_qp_index_offset); - } - read_debug_rbsp_trailing_bits(h, b); - - if( 1 ) - { - memcpy(h->pps, h->pps_table[pps->pic_parameter_set_id], sizeof(pps_t)); - } -} - -#ifdef HAVE_SEI -//7.3.2.3 Supplemental enhancement information RBSP syntax -void read_debug_sei_rbsp(h264_stream_t* h, bs_t* b) -{ - if( 1 ) - { - for( int i = 0; i < h->num_seis; i++ ) - { - sei_free(h->seis[i]); - } - - h->num_seis = 0; - do { - h->num_seis++; - h->seis = (sei_t**)realloc(h->seis, h->num_seis * sizeof(sei_t*)); - h->seis[h->num_seis - 1] = sei_new(); - h->sei = h->seis[h->num_seis - 1]; - read_debug_sei_message(h, b); - } while( more_rbsp_data(h, b) ); - - } - - if( 0 ) - { - for (int i = 0; i < h->num_seis; i++) - { - h->sei = h->seis[i]; - read_debug_sei_message(h, b); - } - h->sei = NULL; - } - - read_debug_rbsp_trailing_bits(h, b); -} - -//7.3.2.3.1 Supplemental enhancement information message syntax -void read_debug_sei_message(h264_stream_t* h, bs_t* b) -{ - if( 0 ) - { - _write_ff_coded_number(b, h->sei->payloadType); - _write_ff_coded_number(b, h->sei->payloadSize); - } - if( 1 ) - { - h->sei->payloadType = _read_ff_coded_number(b); - h->sei->payloadSize = _read_ff_coded_number(b); - } - read_debug_sei_payload( h, b, h->sei->payloadType, h->sei->payloadSize ); -} -#endif - -//7.3.2.4 Access unit delimiter RBSP syntax -void read_debug_access_unit_delimiter_rbsp(h264_stream_t* h, bs_t* b) -{ - printf("%d.%d: ", b->p - b->start, b->bits_left); h->aud->primary_pic_type = bs_read_u(b, 3); printf("h->aud->primary_pic_type: %d \n", h->aud->primary_pic_type); - read_debug_rbsp_trailing_bits(h, b); -} - -//7.3.2.5 End of sequence RBSP syntax -void read_debug_end_of_seq_rbsp(h264_stream_t* h, bs_t* b) -{ -} - -//7.3.2.6 End of stream RBSP syntax -void read_debug_end_of_stream_rbsp(h264_stream_t* h, bs_t* b) -{ -} - -//7.3.2.7 Filler data RBSP syntax -void read_debug_filler_data_rbsp(h264_stream_t* h, bs_t* b) -{ - while( bs_next_bits(b, 8) == 0xFF ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); int ff_byte = bs_read_u(b, 8); printf("ff_byte: %d \n", ff_byte); - } - read_debug_rbsp_trailing_bits(h, b); -} - -//7.3.2.8 Slice layer without partitioning RBSP syntax -void read_debug_slice_layer_rbsp(h264_stream_t* h, bs_t* b) -{ - read_debug_slice_header(h, b); - slice_data_rbsp_t* slice_data = h->slice_data; - - if ( slice_data != NULL ) - { - if ( slice_data->rbsp_buf != NULL ) free( slice_data->rbsp_buf ); - uint8_t *sptr = b->p + (!!b->bits_left); // CABAC-specific: skip alignment bits, if there are any - slice_data->rbsp_size = b->end - sptr; - - slice_data->rbsp_buf = (uint8_t*)malloc(slice_data->rbsp_size); - memcpy( slice_data->rbsp_buf, sptr, slice_data->rbsp_size ); - // ugly hack: since next NALU starts at byte border, we are going to be padded by trailing_bits; - return; - } - - // FIXME should read or skip data - //slice_data( ); /* all categories of slice_data( ) syntax */ - read_debug_rbsp_slice_trailing_bits(h, b); -} - -/* -// UNIMPLEMENTED -//7.3.2.9.1 Slice data partition A RBSP syntax -slice_data_partition_a_layer_rbsp( ) { - read_debug_slice_header( ); // only category 2 - slice_id = bs_read_debug_ue(b) - read_debug_slice_data( ); // only category 2 - read_debug_rbsp_slice_trailing_bits( ); // only category 2 -} - -//7.3.2.9.2 Slice data partition B RBSP syntax -slice_data_partition_b_layer_rbsp( ) { - printf("%d.%d: ", b->p - b->start, b->bits_left); slice_id = bs_read_ue(b); printf("slice_id: %d \n", slice_id); // only category 3 - if( redundant_pic_cnt_present_flag ) - printf("%d.%d: ", b->p - b->start, b->bits_left); redundant_pic_cnt = bs_read_ue(b); printf("redundant_pic_cnt: %d \n", redundant_pic_cnt); - read_debug_slice_data( ); // only category 3 - read_debug_rbsp_slice_trailing_bits( ); // only category 3 -} - -//7.3.2.9.3 Slice data partition C RBSP syntax -slice_data_partition_c_layer_rbsp( ) { - printf("%d.%d: ", b->p - b->start, b->bits_left); slice_id = bs_read_ue(b); printf("slice_id: %d \n", slice_id); // only category 4 - if( redundant_pic_cnt_present_flag ) - printf("%d.%d: ", b->p - b->start, b->bits_left); redundant_pic_cnt = bs_read_ue(b); printf("redundant_pic_cnt: %d \n", redundant_pic_cnt); - read_debug_slice_data( ); // only category 4 - rbsp_slice_trailing_bits( ); // only category 4 -} -*/ - -//7.3.2.10 RBSP slice trailing bits syntax -void read_debug_rbsp_slice_trailing_bits(h264_stream_t* h, bs_t* b) -{ - read_debug_rbsp_trailing_bits(h, b); - if( h->pps->entropy_coding_mode_flag ) - { - while( more_rbsp_trailing_data(h, b) ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); int cabac_zero_word = bs_read_u(b, 16); printf("cabac_zero_word: %d \n", cabac_zero_word); - } - } -} - -//7.3.2.11 RBSP trailing bits syntax -void read_debug_rbsp_trailing_bits(h264_stream_t* h, bs_t* b) -{ - printf("%d.%d: ", b->p - b->start, b->bits_left); int rbsp_stop_one_bit = bs_read_u(b, 1); printf("rbsp_stop_one_bit: %d \n", rbsp_stop_one_bit); - - while( !bs_byte_aligned(b) ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); int rbsp_alignment_zero_bit = bs_read_u(b, 1); printf("rbsp_alignment_zero_bit: %d \n", rbsp_alignment_zero_bit); - } -} - -//7.3.3 Slice header syntax -void read_debug_slice_header(h264_stream_t* h, bs_t* b) -{ - slice_header_t* sh = h->sh; - if( 1 ) - { - memset(sh, 0, sizeof(slice_header_t)); - } - - nal_t* nal = h->nal; - - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->first_mb_in_slice = bs_read_ue(b); printf("sh->first_mb_in_slice: %d \n", sh->first_mb_in_slice); - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->slice_type = bs_read_ue(b); printf("sh->slice_type: %d \n", sh->slice_type); - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->pic_parameter_set_id = bs_read_ue(b); printf("sh->pic_parameter_set_id: %d \n", sh->pic_parameter_set_id); - - // TODO check existence, otherwise fail - pps_t* pps = h->pps; - sps_t* sps = h->sps; - memcpy(h->pps_table[sh->pic_parameter_set_id], h->pps, sizeof(pps_t)); - memcpy(h->sps_table[pps->seq_parameter_set_id], h->sps, sizeof(sps_t)); - - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->frame_num = bs_read_u(b, sps->log2_max_frame_num_minus4 + 4 ); printf("sh->frame_num: %d \n", sh->frame_num); // was u(v) - if( !sps->frame_mbs_only_flag ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->field_pic_flag = bs_read_u1(b); printf("sh->field_pic_flag: %d \n", sh->field_pic_flag); - if( sh->field_pic_flag ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->bottom_field_flag = bs_read_u1(b); printf("sh->bottom_field_flag: %d \n", sh->bottom_field_flag); - } - } - if( nal->nal_unit_type == 5 ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->idr_pic_id = bs_read_ue(b); printf("sh->idr_pic_id: %d \n", sh->idr_pic_id); - } - if( sps->pic_order_cnt_type == 0 ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->pic_order_cnt_lsb = bs_read_u(b, sps->log2_max_pic_order_cnt_lsb_minus4 + 4 ); printf("sh->pic_order_cnt_lsb: %d \n", sh->pic_order_cnt_lsb); // was u(v) - if( pps->pic_order_present_flag && !sh->field_pic_flag ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->delta_pic_order_cnt_bottom = bs_read_se(b); printf("sh->delta_pic_order_cnt_bottom: %d \n", sh->delta_pic_order_cnt_bottom); - } - } - if( sps->pic_order_cnt_type == 1 && !sps->delta_pic_order_always_zero_flag ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->delta_pic_order_cnt[ 0 ] = bs_read_se(b); printf("sh->delta_pic_order_cnt[ 0 ]: %d \n", sh->delta_pic_order_cnt[ 0 ]); - if( pps->pic_order_present_flag && !sh->field_pic_flag ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->delta_pic_order_cnt[ 1 ] = bs_read_se(b); printf("sh->delta_pic_order_cnt[ 1 ]: %d \n", sh->delta_pic_order_cnt[ 1 ]); - } - } - if( pps->redundant_pic_cnt_present_flag ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->redundant_pic_cnt = bs_read_ue(b); printf("sh->redundant_pic_cnt: %d \n", sh->redundant_pic_cnt); - } - if( is_slice_type( sh->slice_type, SH_SLICE_TYPE_B ) ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->direct_spatial_mv_pred_flag = bs_read_u1(b); printf("sh->direct_spatial_mv_pred_flag: %d \n", sh->direct_spatial_mv_pred_flag); - } - if( is_slice_type( sh->slice_type, SH_SLICE_TYPE_P ) || is_slice_type( sh->slice_type, SH_SLICE_TYPE_SP ) || is_slice_type( sh->slice_type, SH_SLICE_TYPE_B ) ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->num_ref_idx_active_override_flag = bs_read_u1(b); printf("sh->num_ref_idx_active_override_flag: %d \n", sh->num_ref_idx_active_override_flag); - if( sh->num_ref_idx_active_override_flag ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->num_ref_idx_l0_active_minus1 = bs_read_ue(b); printf("sh->num_ref_idx_l0_active_minus1: %d \n", sh->num_ref_idx_l0_active_minus1); // FIXME does this modify the pps? - if( is_slice_type( sh->slice_type, SH_SLICE_TYPE_B ) ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->num_ref_idx_l1_active_minus1 = bs_read_ue(b); printf("sh->num_ref_idx_l1_active_minus1: %d \n", sh->num_ref_idx_l1_active_minus1); - } - } - } - read_debug_ref_pic_list_reordering(h, b); - if( ( pps->weighted_pred_flag && ( is_slice_type( sh->slice_type, SH_SLICE_TYPE_P ) || is_slice_type( sh->slice_type, SH_SLICE_TYPE_SP ) ) ) || - ( pps->weighted_bipred_idc == 1 && is_slice_type( sh->slice_type, SH_SLICE_TYPE_B ) ) ) - { - read_debug_pred_weight_table(h, b); - } - if( nal->nal_ref_idc != 0 ) - { - read_debug_dec_ref_pic_marking(h, b); - } - if( pps->entropy_coding_mode_flag && ! is_slice_type( sh->slice_type, SH_SLICE_TYPE_I ) && ! is_slice_type( sh->slice_type, SH_SLICE_TYPE_SI ) ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->cabac_init_idc = bs_read_ue(b); printf("sh->cabac_init_idc: %d \n", sh->cabac_init_idc); - } - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->slice_qp_delta = bs_read_se(b); printf("sh->slice_qp_delta: %d \n", sh->slice_qp_delta); - if( is_slice_type( sh->slice_type, SH_SLICE_TYPE_SP ) || is_slice_type( sh->slice_type, SH_SLICE_TYPE_SI ) ) - { - if( is_slice_type( sh->slice_type, SH_SLICE_TYPE_SP ) ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->sp_for_switch_flag = bs_read_u1(b); printf("sh->sp_for_switch_flag: %d \n", sh->sp_for_switch_flag); - } - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->slice_qs_delta = bs_read_se(b); printf("sh->slice_qs_delta: %d \n", sh->slice_qs_delta); - } - if( pps->deblocking_filter_control_present_flag ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->disable_deblocking_filter_idc = bs_read_ue(b); printf("sh->disable_deblocking_filter_idc: %d \n", sh->disable_deblocking_filter_idc); - if( sh->disable_deblocking_filter_idc != 1 ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->slice_alpha_c0_offset_div2 = bs_read_se(b); printf("sh->slice_alpha_c0_offset_div2: %d \n", sh->slice_alpha_c0_offset_div2); - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->slice_beta_offset_div2 = bs_read_se(b); printf("sh->slice_beta_offset_div2: %d \n", sh->slice_beta_offset_div2); - } - } - if( pps->num_slice_groups_minus1 > 0 && - pps->slice_group_map_type >= 3 && pps->slice_group_map_type <= 5) - { - int v = intlog2( pps->pic_size_in_map_units_minus1 + pps->slice_group_change_rate_minus1 + 1 ); - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->slice_group_change_cycle = bs_read_u(b, v); printf("sh->slice_group_change_cycle: %d \n", sh->slice_group_change_cycle); // FIXME add 2? - } -} - -//7.3.3.1 Reference picture list reordering syntax -void read_debug_ref_pic_list_reordering(h264_stream_t* h, bs_t* b) -{ - slice_header_t* sh = h->sh; - // FIXME should be an array - - if( ! is_slice_type( sh->slice_type, SH_SLICE_TYPE_I ) && ! is_slice_type( sh->slice_type, SH_SLICE_TYPE_SI ) ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->rplr.ref_pic_list_reordering_flag_l0 = bs_read_u1(b); printf("sh->rplr.ref_pic_list_reordering_flag_l0: %d \n", sh->rplr.ref_pic_list_reordering_flag_l0); - if( sh->rplr.ref_pic_list_reordering_flag_l0 ) - { - int n = -1; - do - { - n++; - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->rplr.reorder_l0.reordering_of_pic_nums_idc[ n ] = bs_read_ue(b); printf("sh->rplr.reorder_l0.reordering_of_pic_nums_idc[ n ]: %d \n", sh->rplr.reorder_l0.reordering_of_pic_nums_idc[ n ]); - if( sh->rplr.reorder_l0.reordering_of_pic_nums_idc[ n ] == 0 || - sh->rplr.reorder_l0.reordering_of_pic_nums_idc[ n ] == 1 ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->rplr.reorder_l0.abs_diff_pic_num_minus1[ n ] = bs_read_ue(b); printf("sh->rplr.reorder_l0.abs_diff_pic_num_minus1[ n ]: %d \n", sh->rplr.reorder_l0.abs_diff_pic_num_minus1[ n ]); - } - else if( sh->rplr.reorder_l0.reordering_of_pic_nums_idc[ n ] == 2 ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->rplr.reorder_l0.long_term_pic_num[ n ] = bs_read_ue(b); printf("sh->rplr.reorder_l0.long_term_pic_num[ n ]: %d \n", sh->rplr.reorder_l0.long_term_pic_num[ n ]); - } - } while( sh->rplr.reorder_l0.reordering_of_pic_nums_idc[ n ] != 3 && ! bs_eof(b) ); - } - } - if( is_slice_type( sh->slice_type, SH_SLICE_TYPE_B ) ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->rplr.ref_pic_list_reordering_flag_l1 = bs_read_u1(b); printf("sh->rplr.ref_pic_list_reordering_flag_l1: %d \n", sh->rplr.ref_pic_list_reordering_flag_l1); - if( sh->rplr.ref_pic_list_reordering_flag_l1 ) - { - int n = -1; - do - { - n++; - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->rplr.reorder_l1.reordering_of_pic_nums_idc[ n ] = bs_read_ue(b); printf("sh->rplr.reorder_l1.reordering_of_pic_nums_idc[ n ]: %d \n", sh->rplr.reorder_l1.reordering_of_pic_nums_idc[ n ]); - if( sh->rplr.reorder_l1.reordering_of_pic_nums_idc[ n ] == 0 || - sh->rplr.reorder_l1.reordering_of_pic_nums_idc[ n ] == 1 ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->rplr.reorder_l1.abs_diff_pic_num_minus1[ n ] = bs_read_ue(b); printf("sh->rplr.reorder_l1.abs_diff_pic_num_minus1[ n ]: %d \n", sh->rplr.reorder_l1.abs_diff_pic_num_minus1[ n ]); - } - else if( sh->rplr.reorder_l1.reordering_of_pic_nums_idc[ n ] == 2 ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->rplr.reorder_l1.long_term_pic_num[ n ] = bs_read_ue(b); printf("sh->rplr.reorder_l1.long_term_pic_num[ n ]: %d \n", sh->rplr.reorder_l1.long_term_pic_num[ n ]); - } - } while( sh->rplr.reorder_l1.reordering_of_pic_nums_idc[ n ] != 3 && ! bs_eof(b) ); - } - } -} - -//7.3.3.2 Prediction weight table syntax -void read_debug_pred_weight_table(h264_stream_t* h, bs_t* b) -{ - slice_header_t* sh = h->sh; - sps_t* sps = h->sps; - pps_t* pps = h->pps; - - int i, j; - - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->pwt.luma_log2_weight_denom = bs_read_ue(b); printf("sh->pwt.luma_log2_weight_denom: %d \n", sh->pwt.luma_log2_weight_denom); - if( sps->chroma_format_idc != 0 ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->pwt.chroma_log2_weight_denom = bs_read_ue(b); printf("sh->pwt.chroma_log2_weight_denom: %d \n", sh->pwt.chroma_log2_weight_denom); - } - for( i = 0; i <= pps->num_ref_idx_l0_active_minus1; i++ ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->pwt.luma_weight_l0_flag[i] = bs_read_u1(b); printf("sh->pwt.luma_weight_l0_flag[i]: %d \n", sh->pwt.luma_weight_l0_flag[i]); - if( sh->pwt.luma_weight_l0_flag[i] ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->pwt.luma_weight_l0[ i ] = bs_read_se(b); printf("sh->pwt.luma_weight_l0[ i ]: %d \n", sh->pwt.luma_weight_l0[ i ]); - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->pwt.luma_offset_l0[ i ] = bs_read_se(b); printf("sh->pwt.luma_offset_l0[ i ]: %d \n", sh->pwt.luma_offset_l0[ i ]); - } - if ( sps->chroma_format_idc != 0 ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->pwt.chroma_weight_l0_flag[i] = bs_read_u1(b); printf("sh->pwt.chroma_weight_l0_flag[i]: %d \n", sh->pwt.chroma_weight_l0_flag[i]); - if( sh->pwt.chroma_weight_l0_flag[i] ) - { - for( j =0; j < 2; j++ ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->pwt.chroma_weight_l0[ i ][ j ] = bs_read_se(b); printf("sh->pwt.chroma_weight_l0[ i ][ j ]: %d \n", sh->pwt.chroma_weight_l0[ i ][ j ]); - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->pwt.chroma_offset_l0[ i ][ j ] = bs_read_se(b); printf("sh->pwt.chroma_offset_l0[ i ][ j ]: %d \n", sh->pwt.chroma_offset_l0[ i ][ j ]); - } - } - } - } - if( is_slice_type( sh->slice_type, SH_SLICE_TYPE_B ) ) - { - for( i = 0; i <= pps->num_ref_idx_l1_active_minus1; i++ ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->pwt.luma_weight_l1_flag[i] = bs_read_u1(b); printf("sh->pwt.luma_weight_l1_flag[i]: %d \n", sh->pwt.luma_weight_l1_flag[i]); - if( sh->pwt.luma_weight_l1_flag[i] ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->pwt.luma_weight_l1[ i ] = bs_read_se(b); printf("sh->pwt.luma_weight_l1[ i ]: %d \n", sh->pwt.luma_weight_l1[ i ]); - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->pwt.luma_offset_l1[ i ] = bs_read_se(b); printf("sh->pwt.luma_offset_l1[ i ]: %d \n", sh->pwt.luma_offset_l1[ i ]); - } - if( sps->chroma_format_idc != 0 ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->pwt.chroma_weight_l1_flag[i] = bs_read_u1(b); printf("sh->pwt.chroma_weight_l1_flag[i]: %d \n", sh->pwt.chroma_weight_l1_flag[i]); - if( sh->pwt.chroma_weight_l1_flag[i] ) - { - for( j = 0; j < 2; j++ ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->pwt.chroma_weight_l1[ i ][ j ] = bs_read_se(b); printf("sh->pwt.chroma_weight_l1[ i ][ j ]: %d \n", sh->pwt.chroma_weight_l1[ i ][ j ]); - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->pwt.chroma_offset_l1[ i ][ j ] = bs_read_se(b); printf("sh->pwt.chroma_offset_l1[ i ][ j ]: %d \n", sh->pwt.chroma_offset_l1[ i ][ j ]); - } - } - } - } - } -} - -//7.3.3.3 Decoded reference picture marking syntax -void read_debug_dec_ref_pic_marking(h264_stream_t* h, bs_t* b) -{ - slice_header_t* sh = h->sh; - // FIXME should be an array - - if( h->nal->nal_unit_type == 5 ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->drpm.no_output_of_prior_pics_flag = bs_read_u1(b); printf("sh->drpm.no_output_of_prior_pics_flag: %d \n", sh->drpm.no_output_of_prior_pics_flag); - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->drpm.long_term_reference_flag = bs_read_u1(b); printf("sh->drpm.long_term_reference_flag: %d \n", sh->drpm.long_term_reference_flag); - } - else - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->drpm.adaptive_ref_pic_marking_mode_flag = bs_read_u1(b); printf("sh->drpm.adaptive_ref_pic_marking_mode_flag: %d \n", sh->drpm.adaptive_ref_pic_marking_mode_flag); - if( sh->drpm.adaptive_ref_pic_marking_mode_flag ) - { - int n = -1; - do - { - n++; - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->drpm.memory_management_control_operation[ n ] = bs_read_ue(b); printf("sh->drpm.memory_management_control_operation[ n ]: %d \n", sh->drpm.memory_management_control_operation[ n ]); - if( sh->drpm.memory_management_control_operation[ n ] == 1 || - sh->drpm.memory_management_control_operation[ n ] == 3 ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->drpm.difference_of_pic_nums_minus1[ n ] = bs_read_ue(b); printf("sh->drpm.difference_of_pic_nums_minus1[ n ]: %d \n", sh->drpm.difference_of_pic_nums_minus1[ n ]); - } - if(sh->drpm.memory_management_control_operation[ n ] == 2 ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->drpm.long_term_pic_num[ n ] = bs_read_ue(b); printf("sh->drpm.long_term_pic_num[ n ]: %d \n", sh->drpm.long_term_pic_num[ n ]); - } - if( sh->drpm.memory_management_control_operation[ n ] == 3 || - sh->drpm.memory_management_control_operation[ n ] == 6 ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->drpm.long_term_frame_idx[ n ] = bs_read_ue(b); printf("sh->drpm.long_term_frame_idx[ n ]: %d \n", sh->drpm.long_term_frame_idx[ n ]); - } - if( sh->drpm.memory_management_control_operation[ n ] == 4 ) - { - printf("%d.%d: ", b->p - b->start, b->bits_left); sh->drpm.max_long_term_frame_idx_plus1[ n ] = bs_read_ue(b); printf("sh->drpm.max_long_term_frame_idx_plus1[ n ]: %d \n", sh->drpm.max_long_term_frame_idx_plus1[ n ]); - } - } while( sh->drpm.memory_management_control_operation[ n ] != 0 && ! bs_eof(b) ); - } - } -}