]> git.meshlink.io Git - catta/commitdiff
rename everything avahi to catta
authorSven M. Hallberg <pesco@khjk.org>
Wed, 20 Aug 2014 13:43:39 +0000 (15:43 +0200)
committerSven M. Hallberg <pesco@khjk.org>
Wed, 20 Aug 2014 13:43:39 +0000 (15:43 +0200)
145 files changed:
Makefile.am
avahi.pc.in [deleted file]
catta.pc.in [new file with mode: 0644]
configure.ac
doxygen.cfg
doxygen_to_devhelp.xsl
examples/Makefile.am
examples/core-browse-services.c
examples/core-publish-service.c
include/Makefile.am
include/avahi/address.h [deleted file]
include/avahi/alternative.h [deleted file]
include/avahi/cdecl.h [deleted file]
include/avahi/core.h [deleted file]
include/avahi/defs.h [deleted file]
include/avahi/domain.h [deleted file]
include/avahi/error.h [deleted file]
include/avahi/gccmacro.h [deleted file]
include/avahi/llist.h [deleted file]
include/avahi/log.h [deleted file]
include/avahi/lookup.h [deleted file]
include/avahi/malloc.h [deleted file]
include/avahi/publish.h [deleted file]
include/avahi/rlist.h [deleted file]
include/avahi/rr.h [deleted file]
include/avahi/simple-watch.h [deleted file]
include/avahi/strlst.h [deleted file]
include/avahi/thread-watch.h [deleted file]
include/avahi/timeval.h [deleted file]
include/avahi/watch.h [deleted file]
include/catta/address.h [new file with mode: 0644]
include/catta/alternative.h [new file with mode: 0644]
include/catta/cdecl.h [new file with mode: 0644]
include/catta/core.h [new file with mode: 0644]
include/catta/defs.h [new file with mode: 0644]
include/catta/domain.h [new file with mode: 0644]
include/catta/error.h [new file with mode: 0644]
include/catta/gccmacro.h [new file with mode: 0644]
include/catta/llist.h [new file with mode: 0644]
include/catta/log.h [new file with mode: 0644]
include/catta/lookup.h [new file with mode: 0644]
include/catta/malloc.h [new file with mode: 0644]
include/catta/publish.h [new file with mode: 0644]
include/catta/rlist.h [new file with mode: 0644]
include/catta/rr.h [new file with mode: 0644]
include/catta/simple-watch.h [new file with mode: 0644]
include/catta/strlst.h [new file with mode: 0644]
include/catta/thread-watch.h [new file with mode: 0644]
include/catta/timeval.h [new file with mode: 0644]
include/catta/watch.h [new file with mode: 0644]
m4/Makefile.am
src/Makefile.am
src/addr-util.c
src/addr-util.h
src/address.c
src/alternative.c
src/announce.c
src/announce.h
src/browse-dns-server.c
src/browse-domain.c
src/browse-service-type.c
src/browse-service.c
src/browse.c
src/browse.h
src/cache.c
src/cache.h
src/dns-srv-rr.h
src/dns.c
src/dns.h
src/domain-util.c
src/domain-util.h
src/domain.c
src/entry.c
src/error.c
src/fdutil.c
src/fdutil.h
src/hashmap.c
src/hashmap.h
src/iface-linux.c
src/iface-linux.h
src/iface-none.c
src/iface-pfroute.c
src/iface-pfroute.h
src/iface.c
src/iface.h
src/internal.h
src/log.c
src/malloc.c
src/multicast-lookup.c
src/multicast-lookup.h
src/netlink.c
src/netlink.h
src/prioq.c
src/prioq.h
src/probe-sched.c
src/probe-sched.h
src/querier.c
src/querier.h
src/query-sched.c
src/query-sched.h
src/resolve-address.c
src/resolve-host-name.c
src/resolve-service.c
src/response-sched.c
src/response-sched.h
src/rlist.c
src/rr-util.h
src/rr.c
src/rrlist.c
src/rrlist.h
src/server.c
src/simple-watch.c
src/socket.c
src/socket.h
src/strlst.c
src/thread-watch.c
src/timeeventq.c
src/timeeventq.h
src/timeval.c
src/utf8.c
src/utf8.h
src/util.c
src/util.h
src/wide-area.c
src/wide-area.h
tests/.gitignore
tests/Makefile.am
tests/alternative-test.c
tests/avahi-reflector.c [deleted file]
tests/avahi-test.c [deleted file]
tests/catta-reflector.c [new file with mode: 0644]
tests/catta-test.c [new file with mode: 0644]
tests/conformance-test.c
tests/dns-spin-test.c
tests/dns-test.c
tests/domain-test.c
tests/hashmap-test.c
tests/prioq-test.c
tests/querier-test.c
tests/strlst-test.c
tests/timeeventq-test.c
tests/timeval-test.c
tests/update-test.c
tests/utf8-test.c
tests/watch-test.c

index 26ce6bd2c3f4725a5dbced4bbbb151006bb096d3..5fb53928fcac33232f404421405f6a3e8c482be8 100644 (file)
@@ -1,17 +1,17 @@
-# This file is part of avahi.
+# This file is part of catta.
 #
-# avahi is free software; you can redistribute it and/or modify it
+# catta 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
+# catta 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
+# License along with catta; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 # USA.
 
@@ -35,7 +35,7 @@ EXTRA_DIST = \
        docs/overview.dia \
        docs/server-states.dia \
        docs/avahi-poll.dia \
-       avahi.pc.in \
+       catta.pc.in \
        doxygen_to_devhelp.xsl
 
 SUBDIRS = \
@@ -46,21 +46,21 @@ SUBDIRS = \
        examples
 
 DX_INPUT = \
-       $(srcdir)/include/avahi/address.h \
-       $(srcdir)/include/avahi/malloc.h \
-       $(srcdir)/include/avahi/strlst.h \
-       $(srcdir)/include/avahi/alternative.h \
-       $(srcdir)/include/avahi/defs.h \
-       $(srcdir)/include/avahi/error.h \
-       $(srcdir)/include/avahi/domain.h \
-       $(srcdir)/include/avahi/watch.h \
-       $(srcdir)/include/avahi/simple-watch.h \
-       $(srcdir)/include/avahi/thread-watch.h \
-       $(srcdir)/include/avahi/core.h \
-       $(srcdir)/include/avahi/lookup.h \
-       $(srcdir)/include/avahi/publish.h \
-       $(srcdir)/include/avahi/rr.h \
-       $(srcdir)/include/avahi/log.h
+       $(srcdir)/include/catta/address.h \
+       $(srcdir)/include/catta/malloc.h \
+       $(srcdir)/include/catta/strlst.h \
+       $(srcdir)/include/catta/alternative.h \
+       $(srcdir)/include/catta/defs.h \
+       $(srcdir)/include/catta/error.h \
+       $(srcdir)/include/catta/domain.h \
+       $(srcdir)/include/catta/watch.h \
+       $(srcdir)/include/catta/simple-watch.h \
+       $(srcdir)/include/catta/thread-watch.h \
+       $(srcdir)/include/catta/core.h \
+       $(srcdir)/include/catta/lookup.h \
+       $(srcdir)/include/catta/publish.h \
+       $(srcdir)/include/catta/rr.h \
+       $(srcdir)/include/catta/log.h
 
 DX_EXAMPLE_PATH = $(srcdir)/examples
 DX_EXAMPLE_PATTERNS = *.c
@@ -72,11 +72,11 @@ pkgconfigdir = $(libdir)/pkgconfig
            -e 's,@libdir\@,$(libdir),g' \
            -e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' $< > $@
 
-pkgconfig_DATA = avahi.pc
-CLEANFILES = avahi.pc
-CLEANFILES += avahi.devhelp
+pkgconfig_DATA = catta.pc
+CLEANFILES = catta.pc
+CLEANFILES += catta.devhelp
 
-avahi.devhelp: doxygen-run
+catta.devhelp: doxygen-run
        xsltproc -o $@ doxygen_to_devhelp.xsl doxygen/xml/index.xml
 
 MOSTLYCLEANFILES = $(DX_CLEANFILES)
diff --git a/avahi.pc.in b/avahi.pc.in
deleted file mode 100644 (file)
index 8be903c..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-prefix=@prefix@
-exec_prefix=${prefix}
-libdir=@libdir@
-includedir=${prefix}/include
-
-Name: avahi
-Description: Avahi Multicast DNS Responder (Embeddable Stack)
-Version: @PACKAGE_VERSION@
-Libs: -L${libdir} -lavahi
-Cflags: -D_REENTRANT -I${includedir}
diff --git a/catta.pc.in b/catta.pc.in
new file mode 100644 (file)
index 0000000..c6b036a
--- /dev/null
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=${prefix}
+libdir=@libdir@
+includedir=${prefix}/include
+
+Name: catta
+Description: Catta Embeddable mDNS Stack
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lcatta
+Cflags: -D_REENTRANT -I${includedir}
index 80cbfb202714a4ab49382b20082dcb27c2e2a090..59255603f0872c7344aa66bf0fe38d284f0e602e 100644 (file)
@@ -1,33 +1,33 @@
 # -*- Autoconf -*-
 # Process this file with autoconf to produce a configure script.
 
-# This file is part of avahi.
+# This file is part of catta.
 #
-# avahi is free software; you can redistribute it and/or modify it
+# catta 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
+# catta 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
+# License along with catta; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 # USA.
 
 AC_PREREQ(2.63)
-AC_INIT([avahi],[0.6.31],[avahi (at) lists (dot) freedesktop (dot) org])
+AC_INIT([catta],[0.1],[])
 AC_CONFIG_SRCDIR([src/server.c])
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_HEADERS([config.h])
 AM_INIT_AUTOMAKE([foreign 1.11 -Wall -Wno-portability silent-rules tar-pax])
 
-AC_SUBST(PACKAGE_URL, [http://avahi.org/])
+AC_SUBST(PACKAGE_URL, [http://github.com/everbase/catta/])
 
-AC_SUBST(LIBAVAHI_VERSION_INFO, [7:2:0])
+AC_SUBST(LIBCATTA_VERSION_INFO, [0:0:0])
 
 AC_CANONICAL_HOST
 
@@ -198,14 +198,14 @@ AM_CONDITIONAL(HAVE_SYS_SYSCTL_H, [ test x"$HAVE_SYS_SYSCTL_H" = xyes ])
 # Check for lifconf struct; only present on Solaris
 #
 AC_MSG_CHECKING(for struct lifconf)
-AC_CACHE_VAL(avahi_cv_has_struct_lifconf,
+AC_CACHE_VAL(catta_cv_has_struct_lifconf,
 [AC_TRY_COMPILE(
 [#include <sys/socket.h>
 #include <net/if.h>
 ],[sizeof (struct lifconf);],
-avahi_cv_has_struct_lifconf=yes,avahi_cv_has_struct_lifconf=no)])
-AC_MSG_RESULT($avahi_cv_has_struct_lifconf)
-if test $avahi_cv_has_struct_lifconf = yes; then
+catta_cv_has_struct_lifconf=yes,catta_cv_has_struct_lifconf=no)])
+AC_MSG_RESULT($catta_cv_has_struct_lifconf)
+if test $catta_cv_has_struct_lifconf = yes; then
     AC_DEFINE(HAVE_STRUCT_LIFCONF,1,[Define if there is a struct lifconf.])
 fi
 
@@ -304,7 +304,7 @@ DX_RTF_FEATURE(OFF)
 DX_XML_FEATURE(ON)
 DX_PDF_FEATURE(OFF)
 DX_PS_FEATURE(OFF)
-DX_INIT_DOXYGEN(avahi, doxygen.cfg, doxygen)
+DX_INIT_DOXYGEN(catta, doxygen.cfg, doxygen)
 
 #
 # Conditionally compile test and example programs
index 5c03609b8c78be96542dca5891b79d773de95402..3e905ce1ea38e75257acc8f69c2d02f59ce28d40 100644 (file)
@@ -94,7 +94,7 @@ VERBATIM_HEADERS       = YES
 #---------------------------------------------------------------------------
 ALPHABETICAL_INDEX     = YES
 COLS_IN_ALPHA_INDEX    = 5
-IGNORE_PREFIX          = Avahi AVAHI_ avahi_
+IGNORE_PREFIX          = Catta CATTA_ catta_
 #---------------------------------------------------------------------------
 # configuration options related to the HTML output
 #---------------------------------------------------------------------------
@@ -174,7 +174,7 @@ EXPAND_ONLY_PREDEF     = YES
 SEARCH_INCLUDES        = YES
 INCLUDE_PATH           = 
 INCLUDE_FILE_PATTERNS  = 
-PREDEFINED             = "DOXYGEN_SHOULD_SKIP_THIS" "AVAHI_C_DECL_BEGIN=" "AVAHI_C_DECL_END="
+PREDEFINED             = "DOXYGEN_SHOULD_SKIP_THIS" "CATTA_C_DECL_BEGIN=" "CATTA_C_DECL_END="
 EXPAND_AS_DEFINED      = 
 SKIP_FUNCTION_MACROS   = YES
 #---------------------------------------------------------------------------
index ca6aa972e828d03857c951e45ab4fda4779329c9..32e9f79110d7a9fe80d3b7e0da45ca238a668d85 100644 (file)
@@ -7,11 +7,11 @@
 
 <xsl:output method="xml" version="1.0" indent="yes"/>
 
-<xsl:param name="reference_prefix">../../../doc/avahi-docs/html/</xsl:param>
+<xsl:param name="reference_prefix">../../../doc/catta-docs/html/</xsl:param>
 
 <xsl:template match="/">
-  <book title="Avahi Reference Manual"
-        name="avahi"
+  <book title="Catta Reference Manual"
+        name="catta"
         link="{$reference_prefix}main.html">
   <chapters>
     <sub name="Headers" link="{$reference_prefix}files.html">
index 15718fe496b971d194118abe758ce4befc318916..c7faa918a55f4b44da18dd226a3712b583a82d81 100644 (file)
@@ -1,17 +1,17 @@
-# This file is part of avahi.
+# This file is part of catta.
 #
-# avahi is free software; you can redistribute it and/or modify it
+# catta 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
+# catta 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
+# License along with catta; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 # USA.
 
@@ -25,8 +25,8 @@ endif
 
 core_publish_service_SOURCES = core-publish-service.c
 core_publish_service_CFLAGS = $(AM_CFLAGS)
-core_publish_service_LDADD = $(AM_LDADD) ../src/libavahi.la
+core_publish_service_LDADD = $(AM_LDADD) ../src/libcatta.la
 
 core_browse_services_SOURCES = core-browse-services.c
 core_browse_services_CFLAGS = $(AM_CFLAGS)
-core_browse_services_LDADD = $(AM_LDADD) ../src/libavahi.la
+core_browse_services_LDADD = $(AM_LDADD) ../src/libcatta.la
index 563125b54ad326429722567d46d4f713f616a36a..44f8ece0f48fb8d346d52f2f73d18538cec89d8b 100644 (file)
@@ -1,5 +1,5 @@
 /* PLEASE NOTE *
- * This file demonstrates how to use Avahi's core API, this is
+ * This file demonstrates how to use Catta's core API, this is
  * the embeddable mDNS stack for embedded applications.
  *
  * End user applications should *not* use this API and should use
  */
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <stdlib.h>
 #include <time.h>
 
-#include <avahi/core.h>
-#include <avahi/lookup.h>
-#include <avahi/simple-watch.h>
-#include <avahi/malloc.h>
-#include <avahi/error.h>
+#include <catta/core.h>
+#include <catta/lookup.h>
+#include <catta/simple-watch.h>
+#include <catta/malloc.h>
+#include <catta/error.h>
 
-static AvahiSimplePoll *simple_poll = NULL;
-static AvahiServer *server = NULL;
+static CattaSimplePoll *simple_poll = NULL;
+static CattaServer *server = NULL;
 
 static void resolve_callback(
-    AvahiSServiceResolver *r,
-    AVAHI_GCC_UNUSED AvahiIfIndex interface,
-    AVAHI_GCC_UNUSED AvahiProtocol protocol,
-    AvahiResolverEvent event,
+    CattaSServiceResolver *r,
+    CATTA_GCC_UNUSED CattaIfIndex interface,
+    CATTA_GCC_UNUSED CattaProtocol protocol,
+    CattaResolverEvent event,
     const char *name,
     const char *type,
     const char *domain,
     const char *host_name,
-    const AvahiAddress *address,
+    const CattaAddress *address,
     uint16_t port,
-    AvahiStringList *txt,
-    AvahiLookupResultFlags flags,
-    AVAHI_GCC_UNUSED void* userdata) {
+    CattaStringList *txt,
+    CattaLookupResultFlags flags,
+    CATTA_GCC_UNUSED void* userdata) {
 
     assert(r);
 
     /* Called whenever a service has been resolved successfully or timed out */
 
     switch (event) {
-        case AVAHI_RESOLVER_FAILURE:
-            fprintf(stderr, "(Resolver) Failed to resolve service '%s' of type '%s' in domain '%s': %s\n", name, type, domain, avahi_strerror(avahi_server_errno(server)));
+        case CATTA_RESOLVER_FAILURE:
+            fprintf(stderr, "(Resolver) Failed to resolve service '%s' of type '%s' in domain '%s': %s\n", name, type, domain, catta_strerror(catta_server_errno(server)));
             break;
 
-        case AVAHI_RESOLVER_FOUND: {
-            char a[AVAHI_ADDRESS_STR_MAX], *t;
+        case CATTA_RESOLVER_FOUND: {
+            char a[CATTA_ADDRESS_STR_MAX], *t;
 
             fprintf(stderr, "(Resolver) Service '%s' of type '%s' in domain '%s':\n", name, type, domain);
 
-            avahi_address_snprint(a, sizeof(a), address);
-            t = avahi_string_list_to_string(txt);
+            catta_address_snprint(a, sizeof(a), address);
+            t = catta_string_list_to_string(txt);
             fprintf(stderr,
                     "\t%s:%u (%s)\n"
                     "\tTXT=%s\n"
@@ -87,43 +87,43 @@ static void resolve_callback(
                     "\tcached: %i\n",
                     host_name, port, a,
                     t,
-                    avahi_string_list_get_service_cookie(txt),
-                    !!(flags & AVAHI_LOOKUP_RESULT_LOCAL),
-                    !!(flags & AVAHI_LOOKUP_RESULT_WIDE_AREA),
-                    !!(flags & AVAHI_LOOKUP_RESULT_MULTICAST),
-                    !!(flags & AVAHI_LOOKUP_RESULT_CACHED));
-            avahi_free(t);
+                    catta_string_list_get_service_cookie(txt),
+                    !!(flags & CATTA_LOOKUP_RESULT_LOCAL),
+                    !!(flags & CATTA_LOOKUP_RESULT_WIDE_AREA),
+                    !!(flags & CATTA_LOOKUP_RESULT_MULTICAST),
+                    !!(flags & CATTA_LOOKUP_RESULT_CACHED));
+            catta_free(t);
         }
     }
 
-    avahi_s_service_resolver_free(r);
+    catta_s_service_resolver_free(r);
 }
 
 static void browse_callback(
-    AvahiSServiceBrowser *b,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiBrowserEvent event,
+    CattaSServiceBrowser *b,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaBrowserEvent event,
     const char *name,
     const char *type,
     const char *domain,
-    AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
+    CATTA_GCC_UNUSED CattaLookupResultFlags flags,
     void* userdata) {
 
-    AvahiServer *s = userdata;
+    CattaServer *s = userdata;
     assert(b);
 
     /* Called whenever a new services becomes available on the LAN or is removed from the LAN */
 
     switch (event) {
 
-        case AVAHI_BROWSER_FAILURE:
+        case CATTA_BROWSER_FAILURE:
 
-            fprintf(stderr, "(Browser) %s\n", avahi_strerror(avahi_server_errno(server)));
-            avahi_simple_poll_quit(simple_poll);
+            fprintf(stderr, "(Browser) %s\n", catta_strerror(catta_server_errno(server)));
+            catta_simple_poll_quit(simple_poll);
             return;
 
-        case AVAHI_BROWSER_NEW:
+        case CATTA_BROWSER_NEW:
             fprintf(stderr, "(Browser) NEW: service '%s' of type '%s' in domain '%s'\n", name, type, domain);
 
             /* We ignore the returned resolver object. In the callback
@@ -131,25 +131,25 @@ static void browse_callback(
                the callback function is called the server will free
                the resolver for us. */
 
-            if (!(avahi_s_service_resolver_new(s, interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, 0, resolve_callback, s)))
-                fprintf(stderr, "Failed to resolve service '%s': %s\n", name, avahi_strerror(avahi_server_errno(s)));
+            if (!(catta_s_service_resolver_new(s, interface, protocol, name, type, domain, CATTA_PROTO_UNSPEC, 0, resolve_callback, s)))
+                fprintf(stderr, "Failed to resolve service '%s': %s\n", name, catta_strerror(catta_server_errno(s)));
 
             break;
 
-        case AVAHI_BROWSER_REMOVE:
+        case CATTA_BROWSER_REMOVE:
             fprintf(stderr, "(Browser) REMOVE: service '%s' of type '%s' in domain '%s'\n", name, type, domain);
             break;
 
-        case AVAHI_BROWSER_ALL_FOR_NOW:
-        case AVAHI_BROWSER_CACHE_EXHAUSTED:
-            fprintf(stderr, "(Browser) %s\n", event == AVAHI_BROWSER_CACHE_EXHAUSTED ? "CACHE_EXHAUSTED" : "ALL_FOR_NOW");
+        case CATTA_BROWSER_ALL_FOR_NOW:
+        case CATTA_BROWSER_CACHE_EXHAUSTED:
+            fprintf(stderr, "(Browser) %s\n", event == CATTA_BROWSER_CACHE_EXHAUSTED ? "CACHE_EXHAUSTED" : "ALL_FOR_NOW");
             break;
     }
 }
 
-int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char*argv[]) {
-    AvahiServerConfig config;
-    AvahiSServiceBrowser *sb = NULL;
+int main(CATTA_GCC_UNUSED int argc, CATTA_GCC_UNUSED char*argv[]) {
+    CattaServerConfig config;
+    CattaSServiceBrowser *sb = NULL;
     int error;
     int ret = 1;
 
@@ -157,43 +157,43 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char*argv[]) {
     srand(time(NULL));
 
     /* Allocate main loop object */
-    if (!(simple_poll = avahi_simple_poll_new())) {
+    if (!(simple_poll = catta_simple_poll_new())) {
         fprintf(stderr, "Failed to create simple poll object.\n");
         goto fail;
     }
 
     /* Do not publish any local records */
-    avahi_server_config_init(&config);
+    catta_server_config_init(&config);
     config.publish_hinfo = 0;
     config.publish_addresses = 0;
     config.publish_workstation = 0;
     config.publish_domain = 0;
 
     /* Set a unicast DNS server for wide area DNS-SD */
-    avahi_address_parse("192.168.50.1", AVAHI_PROTO_UNSPEC, &config.wide_area_servers[0]);
+    catta_address_parse("192.168.50.1", CATTA_PROTO_UNSPEC, &config.wide_area_servers[0]);
     config.n_wide_area_servers = 1;
     config.enable_wide_area = 1;
 
     /* Allocate a new server */
-    server = avahi_server_new(avahi_simple_poll_get(simple_poll), &config, NULL, NULL, &error);
+    server = catta_server_new(catta_simple_poll_get(simple_poll), &config, NULL, NULL, &error);
 
     /* Free the configuration data */
-    avahi_server_config_free(&config);
+    catta_server_config_free(&config);
 
     /* Check wether creating the server object succeeded */
     if (!server) {
-        fprintf(stderr, "Failed to create server: %s\n", avahi_strerror(error));
+        fprintf(stderr, "Failed to create server: %s\n", catta_strerror(error));
         goto fail;
     }
 
     /* Create the service browser */
-    if (!(sb = avahi_s_service_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_ipp._tcp", NULL, 0, browse_callback, server))) {
-        fprintf(stderr, "Failed to create service browser: %s\n", avahi_strerror(avahi_server_errno(server)));
+    if (!(sb = catta_s_service_browser_new(server, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, "_ipp._tcp", NULL, 0, browse_callback, server))) {
+        fprintf(stderr, "Failed to create service browser: %s\n", catta_strerror(catta_server_errno(server)));
         goto fail;
     }
 
     /* Run the main loop */
-    avahi_simple_poll_loop(simple_poll);
+    catta_simple_poll_loop(simple_poll);
 
     ret = 0;
 
@@ -201,13 +201,13 @@ fail:
 
     /* Cleanup things */
     if (sb)
-        avahi_s_service_browser_free(sb);
+        catta_s_service_browser_free(sb);
 
     if (server)
-        avahi_server_free(server);
+        catta_server_free(server);
 
     if (simple_poll)
-        avahi_simple_poll_free(simple_poll);
+        catta_simple_poll_free(simple_poll);
 
     return ret;
 }
index e1afe5164f89054533bac27f5ffb71bda065e628..8d6377e6b70becd99ab37487d09fa44061ccf411 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <stdlib.h>
 #include <assert.h>
 
-#include <avahi/core.h>
-#include <avahi/publish.h>
-#include <avahi/simple-watch.h>
-#include <avahi/malloc.h>
-#include <avahi/alternative.h>
-#include <avahi/error.h>
+#include <catta/core.h>
+#include <catta/publish.h>
+#include <catta/simple-watch.h>
+#include <catta/malloc.h>
+#include <catta/alternative.h>
+#include <catta/error.h>
 
-static AvahiSEntryGroup *group = NULL;
-static AvahiSimplePoll *simple_poll = NULL;
+static CattaSEntryGroup *group = NULL;
+static CattaSimplePoll *simple_poll = NULL;
 static char *name = NULL;
 
-static void create_services(AvahiServer *s);
+static void create_services(CattaServer *s);
 
-static void entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntryGroupState state, AVAHI_GCC_UNUSED void *userdata) {
+static void entry_group_callback(CattaServer *s, CattaSEntryGroup *g, CattaEntryGroupState state, CATTA_GCC_UNUSED void *userdata) {
     assert(s);
     assert(g == group);
 
@@ -47,18 +47,18 @@ static void entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntry
 
     switch (state) {
 
-        case AVAHI_ENTRY_GROUP_ESTABLISHED:
+        case CATTA_ENTRY_GROUP_ESTABLISHED:
 
             /* The entry group has been established successfully */
             fprintf(stderr, "Service '%s' successfully established.\n", name);
             break;
 
-        case AVAHI_ENTRY_GROUP_COLLISION: {
+        case CATTA_ENTRY_GROUP_COLLISION: {
             char *n;
 
             /* A service name collision happened. Let's pick a new name */
-            n = avahi_alternative_service_name(name);
-            avahi_free(name);
+            n = catta_alternative_service_name(name);
+            catta_free(name);
             name = n;
 
             fprintf(stderr, "Service name collision, renaming service to '%s'\n", name);
@@ -68,29 +68,29 @@ static void entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntry
             break;
         }
 
-        case AVAHI_ENTRY_GROUP_FAILURE :
+        case CATTA_ENTRY_GROUP_FAILURE :
 
-            fprintf(stderr, "Entry group failure: %s\n", avahi_strerror(avahi_server_errno(s)));
+            fprintf(stderr, "Entry group failure: %s\n", catta_strerror(catta_server_errno(s)));
 
             /* Some kind of failure happened while we were registering our services */
-            avahi_simple_poll_quit(simple_poll);
+            catta_simple_poll_quit(simple_poll);
             break;
 
-        case AVAHI_ENTRY_GROUP_UNCOMMITED:
-        case AVAHI_ENTRY_GROUP_REGISTERING:
+        case CATTA_ENTRY_GROUP_UNCOMMITED:
+        case CATTA_ENTRY_GROUP_REGISTERING:
             ;
     }
 }
 
-static void create_services(AvahiServer *s) {
+static void create_services(CattaServer *s) {
     char r[128];
     int ret;
     assert(s);
 
     /* If this is the first time we're called, let's create a new entry group */
     if (!group)
-        if (!(group = avahi_s_entry_group_new(s, entry_group_callback, NULL))) {
-            fprintf(stderr, "avahi_entry_group_new() failed: %s\n", avahi_strerror(avahi_server_errno(s)));
+        if (!(group = catta_s_entry_group_new(s, entry_group_callback, NULL))) {
+            fprintf(stderr, "catta_entry_group_new() failed: %s\n", catta_strerror(catta_server_errno(s)));
             goto fail;
         }
 
@@ -100,43 +100,43 @@ static void create_services(AvahiServer *s) {
     snprintf(r, sizeof(r), "random=%i", rand());
 
     /* Add the service for IPP */
-    if ((ret = avahi_server_add_service(s, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, name, "_ipp._tcp", NULL, NULL, 651, "test=blah", r, NULL)) < 0) {
-        fprintf(stderr, "Failed to add _ipp._tcp service: %s\n", avahi_strerror(ret));
+    if ((ret = catta_server_add_service(s, group, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, 0, name, "_ipp._tcp", NULL, NULL, 651, "test=blah", r, NULL)) < 0) {
+        fprintf(stderr, "Failed to add _ipp._tcp service: %s\n", catta_strerror(ret));
         goto fail;
     }
 
     /* Add the same service for BSD LPR */
-    if ((ret = avahi_server_add_service(s, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, name, "_printer._tcp", NULL, NULL, 515, NULL)) < 0) {
-        fprintf(stderr, "Failed to add _printer._tcp service: %s\n", avahi_strerror(ret));
+    if ((ret = catta_server_add_service(s, group, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, 0, name, "_printer._tcp", NULL, NULL, 515, NULL)) < 0) {
+        fprintf(stderr, "Failed to add _printer._tcp service: %s\n", catta_strerror(ret));
         goto fail;
     }
 
     /* Add an additional (hypothetic) subtype */
-    if ((ret = avahi_server_add_service_subtype(s, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, name, "_printer._tcp", NULL, "_magic._sub._printer._tcp") < 0)) {
-        fprintf(stderr, "Failed to add subtype _magic._sub._printer._tcp: %s\n", avahi_strerror(ret));
+    if ((ret = catta_server_add_service_subtype(s, group, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, 0, name, "_printer._tcp", NULL, "_magic._sub._printer._tcp") < 0)) {
+        fprintf(stderr, "Failed to add subtype _magic._sub._printer._tcp: %s\n", catta_strerror(ret));
         goto fail;
     }
 
     /* Tell the server to register the service */
-    if ((ret = avahi_s_entry_group_commit(group)) < 0) {
-        fprintf(stderr, "Failed to commit entry_group: %s\n", avahi_strerror(ret));
+    if ((ret = catta_s_entry_group_commit(group)) < 0) {
+        fprintf(stderr, "Failed to commit entry_group: %s\n", catta_strerror(ret));
         goto fail;
     }
 
     return;
 
 fail:
-    avahi_simple_poll_quit(simple_poll);
+    catta_simple_poll_quit(simple_poll);
 }
 
-static void server_callback(AvahiServer *s, AvahiServerState state, AVAHI_GCC_UNUSED void * userdata) {
+static void server_callback(CattaServer *s, CattaServerState state, CATTA_GCC_UNUSED void * userdata) {
     assert(s);
 
     /* Called whenever the server state changes */
 
     switch (state) {
 
-        case AVAHI_SERVER_RUNNING:
+        case CATTA_SERVER_RUNNING:
             /* The serve has startup successfully and registered its host
              * name on the network, so it's time to create our services */
 
@@ -145,20 +145,20 @@ static void server_callback(AvahiServer *s, AvahiServerState state, AVAHI_GCC_UN
 
             break;
 
-        case AVAHI_SERVER_COLLISION: {
+        case CATTA_SERVER_COLLISION: {
             char *n;
             int r;
 
             /* A host name collision happened. Let's pick a new name for the server */
-            n = avahi_alternative_host_name(avahi_server_get_host_name(s));
+            n = catta_alternative_host_name(catta_server_get_host_name(s));
             fprintf(stderr, "Host name collision, retrying with '%s'\n", n);
-            r = avahi_server_set_host_name(s, n);
-            avahi_free(n);
+            r = catta_server_set_host_name(s, n);
+            catta_free(n);
 
             if (r < 0) {
-                fprintf(stderr, "Failed to set new host name: %s\n", avahi_strerror(r));
+                fprintf(stderr, "Failed to set new host name: %s\n", catta_strerror(r));
 
-                avahi_simple_poll_quit(simple_poll);
+                catta_simple_poll_quit(simple_poll);
                 return;
             }
 
@@ -166,32 +166,32 @@ static void server_callback(AvahiServer *s, AvahiServerState state, AVAHI_GCC_UN
 
             /* Fall through */
 
-        case AVAHI_SERVER_REGISTERING:
+        case CATTA_SERVER_REGISTERING:
 
            /* Let's drop our registered services. When the server is back
-             * in AVAHI_SERVER_RUNNING state we will register them
+             * in CATTA_SERVER_RUNNING state we will register them
              * again with the new host name. */
             if (group)
-                avahi_s_entry_group_reset(group);
+                catta_s_entry_group_reset(group);
 
             break;
 
-        case AVAHI_SERVER_FAILURE:
+        case CATTA_SERVER_FAILURE:
 
             /* Terminate on failure */
 
-            fprintf(stderr, "Server failure: %s\n", avahi_strerror(avahi_server_errno(s)));
-            avahi_simple_poll_quit(simple_poll);
+            fprintf(stderr, "Server failure: %s\n", catta_strerror(catta_server_errno(s)));
+            catta_simple_poll_quit(simple_poll);
             break;
 
-        case AVAHI_SERVER_INVALID:
+        case CATTA_SERVER_INVALID:
             ;
     }
 }
 
-int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char*argv[]) {
-    AvahiServerConfig config;
-    AvahiServer *server = NULL;
+int main(CATTA_GCC_UNUSED int argc, CATTA_GCC_UNUSED char*argv[]) {
+    CattaServerConfig config;
+    CattaServer *server = NULL;
     int error;
     int ret = 1;
 
@@ -199,33 +199,33 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char*argv[]) {
     srand(time(NULL));
 
     /* Allocate main loop object */
-    if (!(simple_poll = avahi_simple_poll_new())) {
+    if (!(simple_poll = catta_simple_poll_new())) {
         fprintf(stderr, "Failed to create simple poll object.\n");
         goto fail;
     }
 
-    name = avahi_strdup("MegaPrinter");
+    name = catta_strdup("MegaPrinter");
 
     /* Let's set the host name for this server. */
-    avahi_server_config_init(&config);
-    config.host_name = avahi_strdup("gurkiman");
+    catta_server_config_init(&config);
+    config.host_name = catta_strdup("gurkiman");
     config.publish_workstation = 0;
     config.publish_no_reverse = 1;
 
     /* Allocate a new server */
-    server = avahi_server_new(avahi_simple_poll_get(simple_poll), &config, server_callback, NULL, &error);
+    server = catta_server_new(catta_simple_poll_get(simple_poll), &config, server_callback, NULL, &error);
 
     /* Free the configuration data */
-    avahi_server_config_free(&config);
+    catta_server_config_free(&config);
 
     /* Check wether creating the server object succeeded */
     if (!server) {
-        fprintf(stderr, "Failed to create server: %s\n", avahi_strerror(error));
+        fprintf(stderr, "Failed to create server: %s\n", catta_strerror(error));
         goto fail;
     }
 
     /* Run the main loop */
-    avahi_simple_poll_loop(simple_poll);
+    catta_simple_poll_loop(simple_poll);
 
     ret = 0;
 
@@ -234,12 +234,12 @@ fail:
     /* Cleanup things */
 
     if (server)
-        avahi_server_free(server);
+        catta_server_free(server);
 
     if (simple_poll)
-        avahi_simple_poll_free(simple_poll);
+        catta_simple_poll_free(simple_poll);
 
-    avahi_free(name);
+    catta_free(name);
 
     return ret;
 }
index 0844c7ebe42a4ab80713572c49170e72d77246fc..79513202775d0055da9b43334767f2da389aceaf 100644 (file)
@@ -1,38 +1,38 @@
-# This file is part of avahi.
+# This file is part of catta.
 #
-# avahi is free software; you can redistribute it and/or modify it
+# catta 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
+# catta 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
+# License along with catta; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 # USA.
 
 nobase_include_HEADERS = \
-       avahi/strlst.h \
-       avahi/address.h \
-       avahi/alternative.h \
-       avahi/domain.h \
-       avahi/cdecl.h \
-       avahi/defs.h \
-       avahi/malloc.h \
-       avahi/watch.h \
-       avahi/timeval.h \
-       avahi/simple-watch.h \
-       avahi/thread-watch.h \
-       avahi/gccmacro.h \
-       avahi/error.h \
-       avahi/llist.h \
-       avahi/rlist.h \
-       avahi/core.h \
-       avahi/log.h \
-       avahi/rr.h \
-       avahi/publish.h \
-       avahi/lookup.h
+       catta/strlst.h \
+       catta/address.h \
+       catta/alternative.h \
+       catta/domain.h \
+       catta/cdecl.h \
+       catta/defs.h \
+       catta/malloc.h \
+       catta/watch.h \
+       catta/timeval.h \
+       catta/simple-watch.h \
+       catta/thread-watch.h \
+       catta/gccmacro.h \
+       catta/error.h \
+       catta/llist.h \
+       catta/rlist.h \
+       catta/core.h \
+       catta/log.h \
+       catta/rr.h \
+       catta/publish.h \
+       catta/lookup.h
diff --git a/include/avahi/address.h b/include/avahi/address.h
deleted file mode 100644 (file)
index 7051ef1..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-#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 <inttypes.h>
-#include <sys/types.h>
-
-#include <avahi/cdecl.h>
-
-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/include/avahi/alternative.h b/include/avahi/alternative.h
deleted file mode 100644 (file)
index c4a2846..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-#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/cdecl.h>
-
-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/include/avahi/cdecl.h b/include/avahi/cdecl.h
deleted file mode 100644 (file)
index aef6aba..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#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/include/avahi/core.h b/include/avahi/core.h
deleted file mode 100644 (file)
index 491def7..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-#ifndef foocorehfoo
-#define foocorehfoo
-
-/***
-  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 core.h The Avahi Multicast DNS and DNS Service Discovery implementation. */
-
-/** An mDNS responder object */
-typedef struct AvahiServer AvahiServer;
-
-#include <avahi/cdecl.h>
-#include <avahi/address.h>
-#include <avahi/defs.h>
-#include <avahi/watch.h>
-#include <avahi/timeval.h>
-#include <avahi/rr.h>
-
-AVAHI_C_DECL_BEGIN
-
-/** Maximum number of defined DNS servers for wide area DNS */
-#define AVAHI_WIDE_AREA_SERVERS_MAX 4
-
-/** Prototype for callback functions which are called whenever the state of an AvahiServer object changes */
-typedef void (*AvahiServerCallback) (AvahiServer *s, AvahiServerState state, void* userdata);
-
-/** Stores configuration options for a server instance */
-typedef struct AvahiServerConfig {
-    char *host_name;                  /**< Default host name. If left empty defaults to the result of gethostname(2) of the libc */
-    char *domain_name;                /**< Default domain name. If left empty defaults to .local */
-    int use_ipv4;                     /**< Enable IPv4 support */
-    int use_ipv6;                     /**< Enable IPv6 support */
-    AvahiStringList *allow_interfaces;/**< Allow specific interface to be used for Avahi */
-    AvahiStringList *deny_interfaces; /**< Deny specific interfaces to be used for Avahi */
-    int publish_hinfo;                /**< Register a HINFO record for the host containing the local OS and CPU type */
-    int publish_addresses;            /**< Register A, AAAA and PTR records for all local IP addresses */
-    int publish_no_reverse;           /**< Do not register PTR records */
-    int publish_workstation;          /**< Register a _workstation._tcp service */
-    int publish_domain;               /**< Announce the local domain for browsing */
-    int check_response_ttl;           /**< If enabled the server ignores all incoming responses with IP TTL != 255. Newer versions of the RFC do no longer contain this check, so it is disabled by default. */
-    int use_iff_running;              /**< Require IFF_RUNNING on local network interfaces. This is the official way to check for link beat. Unfortunately this doesn't work with all drivers. So bettere leave this off. */
-    int enable_reflector;             /**< Reflect incoming mDNS traffic to all local networks. This allows mDNS based network browsing beyond ethernet borders */
-    int reflect_ipv;                  /**< if enable_reflector is 1, enable/disable reflecting between IPv4 and IPv6 */
-    int add_service_cookie;           /**< Add magic service cookie to all locally generated records implicitly */
-    int enable_wide_area;             /**< Enable wide area support */
-    AvahiAddress wide_area_servers[AVAHI_WIDE_AREA_SERVERS_MAX]; /** Unicast DNS server to use for wide area lookup */
-    unsigned n_wide_area_servers;     /**< Number of servers in wide_area_servers[] */
-    int disallow_other_stacks;        /**< Make sure that only one mDNS responder is run at the same time on the local machine. If this is enable Avahi will not set SO_REUSADDR on its sockets, effectively preventing other stacks from running on the local machine */
-    AvahiStringList *browse_domains;  /**< Additional browsing domains */
-    int disable_publishing;           /**< Disable publishing of any record */
-    int allow_point_to_point;         /**< Enable publishing on POINTOPOINT interfaces */
-    int publish_a_on_ipv6;            /**< Publish an IPv4 A RR on IPv6 sockets */
-    int publish_aaaa_on_ipv4;         /**< Publish an IPv4 A RR on IPv6 sockets */
-    unsigned n_cache_entries_max;     /**< Maximum number of cache entries per interface */
-    AvahiUsec ratelimit_interval;     /**< If non-zero, rate-limiting interval parameter. */
-    unsigned ratelimit_burst;         /**< If ratelimit_interval is non-zero, rate-limiting burst parameter. */
-} AvahiServerConfig;
-
-/** Allocate a new mDNS responder object. */
-AvahiServer *avahi_server_new(
-    const AvahiPoll *api,          /**< The main loop adapter */
-    const AvahiServerConfig *sc,   /**< If non-NULL a pointer to a configuration structure for the server. The server makes an internal deep copy of this structure, so you may free it using avahi_server_config_done() immediately after calling this function. */
-    AvahiServerCallback callback,  /**< A callback which is called whenever the state of the server changes */
-    void* userdata,                /**< An opaque pointer which is passed to the callback function */
-    int *error);
-
-/** Free an mDNS responder object */
-void avahi_server_free(AvahiServer* s);
-
-/** Fill in default values for a server configuration structure. If you
- * make use of an AvahiServerConfig structure be sure to initialize
- * it with this function for the sake of upwards library
- * compatibility. This call may allocate strings on the heap. To
- * release this memory make sure to call
- * avahi_server_config_done(). If you want to replace any strings in
- * the structure be sure to free the strings filled in by this
- * function with avahi_free() first and allocate the replacements with
- * g_malloc() (or g_strdup()).*/
-AvahiServerConfig* avahi_server_config_init(
-   AvahiServerConfig *c /**< A structure which shall be filled in */ );
-
-/** Make a deep copy of the configuration structure *c to *ret. */
-AvahiServerConfig* avahi_server_config_copy(
-    AvahiServerConfig *ret /**< destination */,
-    const AvahiServerConfig *c /**< source */);
-
-/** Free the data in a server configuration structure. */
-void avahi_server_config_free(AvahiServerConfig *c);
-
-/** Return the currently chosen domain name of the server object. The
- * return value points to an internally allocated string. Be sure to
- * make a copy of the string before calling any other library
- * functions. */
-const char* avahi_server_get_domain_name(AvahiServer *s);
-
-/** Return the currently chosen host name. The return value points to a internally allocated string. */
-const char* avahi_server_get_host_name(AvahiServer *s);
-
-/** Return the currently chosen host name as a FQDN ("fully qualified
- * domain name", i.e. the concatenation of the host and domain
- * name). The return value points to a internally allocated string. */
-const char* avahi_server_get_host_name_fqdn(AvahiServer *s);
-
-/** Change the host name of a running mDNS responder. This will drop
-all automicatilly generated RRs and readd them with the new
-name. Since the responder has to probe for the new RRs this function
-takes some time to take effect altough it returns immediately. This
-function is intended to be called when a host name conflict is
-reported using AvahiServerCallback. The caller should readd all user
-defined RRs too since they otherwise continue to point to the outdated
-host name..*/
-int avahi_server_set_host_name(AvahiServer *s, const char *host_name);
-
-/** Change the domain name of a running mDNS responder. The same rules
- * as with avahi_server_set_host_name() apply. */
-int avahi_server_set_domain_name(AvahiServer *s, const char *domain_name);
-
-/** Return the opaque user data pointer attached to a server object */
-void* avahi_server_get_data(AvahiServer *s);
-
-/** Change the opaque user data pointer attached to a server object */
-void avahi_server_set_data(AvahiServer *s, void* userdata);
-
-/** Return the current state of the server object */
-AvahiServerState avahi_server_get_state(AvahiServer *s);
-
-/** Callback prototype for avahi_server_dump() */
-typedef void (*AvahiDumpCallback)(const char *text, void* userdata);
-
-/** Dump the current server status by calling "callback" for each line.  */
-int avahi_server_dump(AvahiServer *s, AvahiDumpCallback callback, void* userdata);
-
-/** Return the last error code */
-int avahi_server_errno(AvahiServer *s);
-
-/** Return the local service cookie */
-uint32_t avahi_server_get_local_service_cookie(AvahiServer *s);
-
-/** Set the wide area DNS servers */
-int avahi_server_set_wide_area_servers(AvahiServer *s, const AvahiAddress *a, unsigned n);
-
-/** Set the browsing domains */
-int avahi_server_set_browse_domains(AvahiServer *s, AvahiStringList *domains);
-
-/** Return the current configuration of the server \since 0.6.17 */
-const AvahiServerConfig* avahi_server_get_config(AvahiServer *s);
-
-AVAHI_C_DECL_END
-
-#endif
diff --git a/include/avahi/defs.h b/include/avahi/defs.h
deleted file mode 100644 (file)
index 8c66700..0000000
+++ /dev/null
@@ -1,356 +0,0 @@
-#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 <avahi/cdecl.h>
-
-/** \mainpage
- *
- * \section choose_api Choosing an API
- *
- * Avahi provides three programming APIs for integration of
- * mDNS/DNS-SD features into your C progams:
- *
- * \li <b>avahi-core</b>: 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 <b>the D-Bus API</b>: 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 <b>avahi-client</b>: 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 <b>avahi-gobject</b>: 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 <b>avahi-compat-libdns_sd</b>: the original Bonjour API as documented
- * in the header file "dns_sd.h" by Apple Computer, Inc.
- *
- * \li <b>avahi-compat-howl</b>: 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 <b>avahi-glib</b>: The GLIB main loop as used by GTk+/GNOME
- *
- * \li <b>avahi-qt</b>: The Qt main loop as used by Qt/KDE
- *
- * Finally, we provide a high-level Gtk+ GUI dialog called
- * <b>avahi-ui</b> 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/include/avahi/domain.h b/include/avahi/domain.h
deleted file mode 100644 (file)
index b3630af..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-#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 <inttypes.h>
-#include <sys/types.h>
-
-#include <avahi/cdecl.h>
-
-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/include/avahi/error.h b/include/avahi/error.h
deleted file mode 100644 (file)
index bfab2d3..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-#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/cdecl.h>
-
-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/include/avahi/gccmacro.h b/include/avahi/gccmacro.h
deleted file mode 100644 (file)
index 08b9980..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-#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/cdecl.h>
-
-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/include/avahi/llist.h b/include/avahi/llist.h
deleted file mode 100644 (file)
index 5101353..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-#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 <assert.h>
-
-#include <avahi/cdecl.h>
-
-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/include/avahi/log.h b/include/avahi/log.h
deleted file mode 100644 (file)
index df9b6f1..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-#ifndef foologhfoo
-#define foologhfoo
-
-/***
-  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 <stdarg.h>
-
-#include <avahi/cdecl.h>
-#include <avahi/gccmacro.h>
-
-/** \file log.h Extensible logging subsystem */
-
-AVAHI_C_DECL_BEGIN
-
-/** Log level for avahi_log_xxx() */
-typedef enum {
-    AVAHI_LOG_ERROR  = 0,    /**< Error messages */
-    AVAHI_LOG_WARN   = 1,    /**< Warning messages */
-    AVAHI_LOG_NOTICE = 2,    /**< Notice messages */
-    AVAHI_LOG_INFO   = 3,    /**< Info messages */
-    AVAHI_LOG_DEBUG  = 4,    /**< Debug messages */
-    AVAHI_LOG_LEVEL_MAX
-} AvahiLogLevel;
-
-/** Prototype for a user supplied log function */
-typedef void (*AvahiLogFunction)(AvahiLogLevel level, const char *txt);
-
-/** Set a user supplied log function, replacing the default which
- * prints to log messages unconditionally to STDERR. Pass NULL for
- * resetting to the default log function */
-void avahi_set_log_function(AvahiLogFunction function);
-
-/** Issue a log message using a va_list object */
-void avahi_log_ap(AvahiLogLevel level, const char *format, va_list ap);
-
-/** Issue a log message by passing a log level and a format string */
-void avahi_log(AvahiLogLevel level, const char*format, ...) AVAHI_GCC_PRINTF_ATTR23;
-
-/** Shortcut for avahi_log(AVAHI_LOG_ERROR, ...) */
-void avahi_log_error(const char*format, ...) AVAHI_GCC_PRINTF_ATTR12;
-
-/** Shortcut for avahi_log(AVAHI_LOG_WARN, ...) */
-void avahi_log_warn(const char*format, ...) AVAHI_GCC_PRINTF_ATTR12;
-
-/** Shortcut for avahi_log(AVAHI_LOG_NOTICE, ...) */
-void avahi_log_notice(const char*format, ...) AVAHI_GCC_PRINTF_ATTR12;
-
-/** Shortcut for avahi_log(AVAHI_LOG_INFO, ...) */
-void avahi_log_info(const char*format, ...) AVAHI_GCC_PRINTF_ATTR12;
-
-/** Shortcut for avahi_log(AVAHI_LOG_DEBUG, ...) */
-void avahi_log_debug(const char*format, ...) AVAHI_GCC_PRINTF_ATTR12;
-
-AVAHI_C_DECL_END
-
-#endif
diff --git a/include/avahi/lookup.h b/include/avahi/lookup.h
deleted file mode 100644 (file)
index 5a04ff9..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-#ifndef foolookuphfoo
-#define foolookuphfoo
-
-/***
-  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 avahi/lookup.h Functions for browsing/resolving services and other RRs */
-
-/** \example core-browse-services.c Example how to browse for DNS-SD
- * services using an embedded mDNS stack. */
-
-/** A browsing object for arbitrary RRs */
-typedef struct AvahiSRecordBrowser AvahiSRecordBrowser;
-
-/** A host name to IP adddress resolver object */
-typedef struct AvahiSHostNameResolver AvahiSHostNameResolver;
-
-/** An IP address to host name resolver object ("reverse lookup") */
-typedef struct AvahiSAddressResolver AvahiSAddressResolver;
-
-/** A local domain browsing object. May be used to enumerate domains used on the local LAN */
-typedef struct AvahiSDomainBrowser AvahiSDomainBrowser;
-
-/** A DNS-SD service type browsing object. May be used to enumerate the service types of all available services on the local LAN */
-typedef struct AvahiSServiceTypeBrowser AvahiSServiceTypeBrowser;
-
-/** A DNS-SD service browser. Use this to enumerate available services of a certain kind on the local LAN. Use AvahiSServiceResolver to get specific service data like address and port for a service. */
-typedef struct AvahiSServiceBrowser AvahiSServiceBrowser;
-
-/** A DNS-SD service resolver.  Use this to retrieve addres, port and TXT data for a DNS-SD service */
-typedef struct AvahiSServiceResolver AvahiSServiceResolver;
-
-#include <avahi/cdecl.h>
-#include <avahi/defs.h>
-#include <avahi/core.h>
-
-AVAHI_C_DECL_BEGIN
-
-/** Callback prototype for AvahiSRecordBrowser events */
-typedef void (*AvahiSRecordBrowserCallback)(
-    AvahiSRecordBrowser *b,          /**< The AvahiSRecordBrowser object that is emitting this callback */
-    AvahiIfIndex interface,          /**< Logical OS network interface number the record was found on */
-    AvahiProtocol protocol,          /**< Protocol number the record was found. */
-    AvahiBrowserEvent event,         /**< Browsing event, either AVAHI_BROWSER_NEW or AVAHI_BROWSER_REMOVE */
-    AvahiRecord *record,             /**< The record that was found */
-    AvahiLookupResultFlags flags,  /**< Lookup flags */
-    void* userdata                   /**< Arbitrary user data passed to avahi_s_record_browser_new() */ );
-
-/** Create a new browsing object for arbitrary RRs */
-AvahiSRecordBrowser *avahi_s_record_browser_new(
-    AvahiServer *server,                    /**< The server object to which attach this query */
-    AvahiIfIndex interface,                 /**< Logical OS interface number where to look for the records, or AVAHI_IF_UNSPEC to look on interfaces */
-    AvahiProtocol protocol,                 /**< Protocol number to use when looking for the record, or AVAHI_PROTO_UNSPEC to look on all protocols */
-    AvahiKey *key,                          /**< The search key */
-    AvahiLookupFlags flags,                 /**< Lookup flags. Must have set either AVAHI_LOOKUP_FORCE_WIDE_AREA or AVAHI_LOOKUP_FORCE_MULTICAST, since domain based detection is not available here. */
-    AvahiSRecordBrowserCallback callback,   /**< The callback to call on browsing events */
-    void* userdata                          /**< Arbitrary use suppliable data which is passed to the callback */);
-
-/** Free an AvahiSRecordBrowser object */
-void avahi_s_record_browser_free(AvahiSRecordBrowser *b);
-
-/** Callback prototype for AvahiSHostNameResolver events */
-typedef void (*AvahiSHostNameResolverCallback)(
-    AvahiSHostNameResolver *r,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiResolverEvent event, /**< Resolving event */
-    const char *host_name,   /**< Host name which should be resolved. May differ in case from the query */
-    const AvahiAddress *a,    /**< The address, or NULL if the host name couldn't be resolved. */
-    AvahiLookupResultFlags flags,  /**< Lookup flags */
-    void* userdata);
-
-/** Create an AvahiSHostNameResolver object for resolving a host name to an adddress. See AvahiSRecordBrowser for more info on the paramters. */
-AvahiSHostNameResolver *avahi_s_host_name_resolver_new(
-    AvahiServer *server,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    const char *host_name,                  /**< The host name to look for */
-    AvahiProtocol aprotocol,                /**< The address family of the desired address or AVAHI_PROTO_UNSPEC if doesn't matter. */
-    AvahiLookupFlags flags,                 /**< Lookup flags. */
-    AvahiSHostNameResolverCallback calback,
-    void* userdata);
-
-/** Free a AvahiSHostNameResolver object */
-void avahi_s_host_name_resolver_free(AvahiSHostNameResolver *r);
-
-/** Callback prototype for AvahiSAddressResolver events */
-typedef void (*AvahiSAddressResolverCallback)(
-    AvahiSAddressResolver *r,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiResolverEvent event,
-    const AvahiAddress *a,
-    const char *host_name,   /**< A host name for the specified address, if one was found, i.e. event == AVAHI_RESOLVER_FOUND */
-    AvahiLookupResultFlags flags,  /**< Lookup flags */
-    void* userdata);
-
-/** Create an AvahiSAddressResolver object. See AvahiSRecordBrowser for more info on the paramters. */
-AvahiSAddressResolver *avahi_s_address_resolver_new(
-    AvahiServer *server,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    const AvahiAddress *address,
-    AvahiLookupFlags flags,                 /**< Lookup flags. */
-    AvahiSAddressResolverCallback calback,
-    void* userdata);
-
-/** Free an AvahiSAddressResolver object */
-void avahi_s_address_resolver_free(AvahiSAddressResolver *r);
-
-/** Callback prototype for AvahiSDomainBrowser events */
-typedef void (*AvahiSDomainBrowserCallback)(
-    AvahiSDomainBrowser *b,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiBrowserEvent event,
-    const char *domain,
-    AvahiLookupResultFlags flags,  /**< Lookup flags */
-    void* userdata);
-
-/** Create a new AvahiSDomainBrowser object */
-AvahiSDomainBrowser *avahi_s_domain_browser_new(
-    AvahiServer *server,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    const char *domain,
-    AvahiDomainBrowserType type,
-    AvahiLookupFlags flags,                 /**< Lookup flags. */
-    AvahiSDomainBrowserCallback callback,
-    void* userdata);
-
-/** Free an AvahiSDomainBrowser object */
-void avahi_s_domain_browser_free(AvahiSDomainBrowser *b);
-
-/** Callback prototype for AvahiSServiceTypeBrowser events */
-typedef void (*AvahiSServiceTypeBrowserCallback)(
-    AvahiSServiceTypeBrowser *b,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiBrowserEvent event,
-    const char *type,
-    const char *domain,
-    AvahiLookupResultFlags flags,  /**< Lookup flags */
-    void* userdata);
-
-/** Create a new AvahiSServiceTypeBrowser object. */
-AvahiSServiceTypeBrowser *avahi_s_service_type_browser_new(
-    AvahiServer *server,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    const char *domain,
-    AvahiLookupFlags flags,                 /**< Lookup flags. */
-    AvahiSServiceTypeBrowserCallback callback,
-    void* userdata);
-
-/** Free an AvahiSServiceTypeBrowser object */
-void avahi_s_service_type_browser_free(AvahiSServiceTypeBrowser *b);
-
-/** Callback prototype for AvahiSServiceBrowser events */
-typedef void (*AvahiSServiceBrowserCallback)(
-    AvahiSServiceBrowser *b,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiBrowserEvent event,
-    const char *name     /**< Service name, e.g. "Lennart's Files" */,
-    const char *type     /**< DNS-SD type, e.g. "_http._tcp" */,
-    const char *domain   /**< Domain of this service, e.g. "local" */,
-    AvahiLookupResultFlags flags,  /**< Lookup flags */
-    void* userdata);
-
-/** Create a new AvahiSServiceBrowser object. */
-AvahiSServiceBrowser *avahi_s_service_browser_new(
-    AvahiServer *server,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    const char *service_type /** DNS-SD service type, e.g. "_http._tcp" */,
-    const char *domain,
-    AvahiLookupFlags flags,                 /**< Lookup flags. */
-    AvahiSServiceBrowserCallback callback,
-    void* userdata);
-
-/** Free an AvahiSServiceBrowser object */
-void avahi_s_service_browser_free(AvahiSServiceBrowser *b);
-
-/** Callback prototype for AvahiSServiceResolver events */
-typedef void (*AvahiSServiceResolverCallback)(
-    AvahiSServiceResolver *r,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiResolverEvent event,  /**< Is AVAHI_RESOLVER_FOUND when the service was resolved successfully, and everytime it changes. Is AVAHI_RESOLVER_TIMOUT when the service failed to resolve or disappeared. */
-    const char *name,       /**< Service name */
-    const char *type,       /**< Service Type */
-    const char *domain,
-    const char *host_name,  /**< Host name of the service */
-    const AvahiAddress *a,   /**< The resolved host name */
-    uint16_t port,            /**< Service name */
-    AvahiStringList *txt,    /**< TXT record data */
-    AvahiLookupResultFlags flags,  /**< Lookup flags */
-    void* userdata);
-
-/** Create a new AvahiSServiceResolver object. The specified callback function will be called with the resolved service data. */
-AvahiSServiceResolver *avahi_s_service_resolver_new(
-    AvahiServer *server,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    const char *name,
-    const char *type,
-    const char *domain,
-    AvahiProtocol aprotocol,    /**< Address family of the desired service address. Use AVAHI_PROTO_UNSPEC if you don't care */
-    AvahiLookupFlags flags,                 /**< Lookup flags. */
-    AvahiSServiceResolverCallback calback,
-    void* userdata);
-
-/** Free an AvahiSServiceResolver object */
-void avahi_s_service_resolver_free(AvahiSServiceResolver *r);
-
-AVAHI_C_DECL_END
-
-#endif
diff --git a/include/avahi/malloc.h b/include/avahi/malloc.h
deleted file mode 100644 (file)
index 3467cc2..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-#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 <sys/types.h>
-#include <stdarg.h>
-#include <limits.h>
-#include <assert.h>
-
-#include <avahi/cdecl.h>
-#include <avahi/gccmacro.h>
-
-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/include/avahi/publish.h b/include/avahi/publish.h
deleted file mode 100644 (file)
index d877249..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-#ifndef foopublishhfoo
-#define foopublishhfoo
-
-/***
-  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 core/publish.h Functions for publising local services and RRs */
-
-/** \example core-publish-service.c Example how to register a DNS-SD
- * service using an embedded mDNS stack. It behaves like a network
- * printer registering both an IPP and a BSD LPR service. */
-
-/** A group of locally registered DNS RRs */
-typedef struct AvahiSEntryGroup AvahiSEntryGroup;
-
-#include <avahi/cdecl.h>
-#include <avahi/core.h>
-
-AVAHI_C_DECL_BEGIN
-
-/** Prototype for callback functions which are called whenever the state of an AvahiSEntryGroup object changes */
-typedef void (*AvahiSEntryGroupCallback) (AvahiServer *s, AvahiSEntryGroup *g, AvahiEntryGroupState state, void* userdata);
-
-/** Iterate through all local entries of the server. (when g is NULL)
- * or of a specified entry group. At the first call state should point
- * to a NULL initialized void pointer, That pointer is used to track
- * the current iteration. It is not safe to call any other
- * avahi_server_xxx() function during the iteration. If the last entry
- * has been read, NULL is returned. */
-const AvahiRecord *avahi_server_iterate(AvahiServer *s, AvahiSEntryGroup *g, void **state);
-
-/** Create a new entry group. The specified callback function is
- * called whenever the state of the group changes. Use entry group
- * objects to keep track of you RRs. Add new RRs to a group using
- * avahi_server_add_xxx(). Make sure to call avahi_s_entry_group_commit()
- * to start the registration process for your RRs */
-AvahiSEntryGroup *avahi_s_entry_group_new(AvahiServer *s, AvahiSEntryGroupCallback callback, void* userdata);
-
-/** Free an entry group. All RRs assigned to the group are removed from the server */
-void avahi_s_entry_group_free(AvahiSEntryGroup *g);
-
-/** Commit an entry group. This starts the probing and registration process for all RRs in the group */
-int avahi_s_entry_group_commit(AvahiSEntryGroup *g);
-
-/** Remove all entries from the entry group and reset the state to AVAHI_ENTRY_GROUP_UNCOMMITED. */
-void avahi_s_entry_group_reset(AvahiSEntryGroup *g);
-
-/** Return 1 if the entry group is empty, i.e. has no records attached. */
-int avahi_s_entry_group_is_empty(AvahiSEntryGroup *g);
-
-/** Return the current state of the specified entry group */
-AvahiEntryGroupState avahi_s_entry_group_get_state(AvahiSEntryGroup *g);
-
-/** Change the opaque user data pointer attached to an entry group object */
-void avahi_s_entry_group_set_data(AvahiSEntryGroup *g, void* userdata);
-
-/** Return the opaque user data pointer currently set for the entry group object */
-void* avahi_s_entry_group_get_data(AvahiSEntryGroup *g);
-
-/** Add a new resource record to the server. Returns 0 on success, negative otherwise. */
-int avahi_server_add(
-    AvahiServer *s,           /**< The server object to add this record to */
-    AvahiSEntryGroup *g,       /**< An entry group object if this new record shall be attached to one, or NULL. If you plan to remove the record sometime later you a required to pass an entry group object here. */
-    AvahiIfIndex interface,   /**< A numeric index of a network interface to attach this record to, or AVAHI_IF_UNSPEC to attach this record to all interfaces */
-    AvahiProtocol protocol,   /**< A protocol family to attach this record to. One of the AVAHI_PROTO_xxx constants. Use AVAHI_PROTO_UNSPEC to make this record available on all protocols (wich means on both IPv4 and IPv6). */
-    AvahiPublishFlags flags,    /**< Special flags for this record */
-    AvahiRecord *r            /**< The record to add. This function increases the reference counter of this object. */);
-
-/** Add an IP address mapping to the server. This will add both the
- * host-name-to-address and the reverse mapping to the server. See
- * avahi_server_add() for more information. If adding one of the RRs
- * fails, the function returns with an error, but it is not defined if
- * the other RR is deleted from the server or not. Therefore, you have
- * to free the AvahiSEntryGroup and create a new one before
- * proceeding. */
-int avahi_server_add_address(
-    AvahiServer *s,
-    AvahiSEntryGroup *g,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiPublishFlags flags,
-    const char *name,
-    AvahiAddress *a);
-
-/** Add an DNS-SD service to the Server. This will add all required
- * RRs to the server. See avahi_server_add() for more information.  If
- * adding one of the RRs fails, the function returns with an error,
- * but it is not defined if the other RR is deleted from the server or
- * not. Therefore, you have to free the AvahiSEntryGroup and create a
- * new one before proceeding. */
-int avahi_server_add_service(
-    AvahiServer *s,
-    AvahiSEntryGroup *g,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiPublishFlags flags,
-    const char *name,         /**< Service name, e.g. "Lennart's Files" */
-    const char *type,         /**< DNS-SD type, e.g. "_http._tcp" */
-    const char *domain,
-    const char *host,         /**< Host name where this servcie resides, or NULL if on the local host */
-    uint16_t port,              /**< Port number of the service */
-    ...  /**< Text records, terminated by NULL */) AVAHI_GCC_SENTINEL;
-
-/** Mostly identical to avahi_server_add_service(), but takes an AvahiStringList object for the TXT records.  The AvahiStringList object is copied. */
-int avahi_server_add_service_strlst(
-    AvahiServer *s,
-    AvahiSEntryGroup *g,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiPublishFlags flags,
-    const char *name,
-    const char *type,
-    const char *domain,
-    const char *host,
-    uint16_t port,
-    AvahiStringList *strlst);
-
-/** Add a subtype for an already existing service */
-int avahi_server_add_service_subtype(
-    AvahiServer *s,
-    AvahiSEntryGroup *g,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiPublishFlags flags,
-    const char *name,         /**< Specify the name of main service you already added here */
-    const char *type,         /**< Specify the main type of the service you already added here */
-    const char *domain,       /**< Specify the main type of the service you already added here */
-    const char *subtype       /**< The new subtype for the specified service */ );
-
-/** Update the TXT record for a service with the data from the specified string list */
-int avahi_server_update_service_txt_strlst(
-    AvahiServer *s,
-    AvahiSEntryGroup *g,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiPublishFlags flags,
-    const char *name,
-    const char *type,
-    const char *domain,
-    AvahiStringList *strlst);
-
-/** Update the TXT record for a service with the NULL termonate list of strings */
-int avahi_server_update_service_txt(
-    AvahiServer *s,
-    AvahiSEntryGroup *g,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiPublishFlags flags,
-    const char *name,
-    const char *type,
-    const char *domain,
-    ...) AVAHI_GCC_SENTINEL;
-
-/** Check if there is a service locally defined and return the entry group it is attached to. Returns NULL if the service isn't local*/
-int avahi_server_get_group_of_service(AvahiServer *s, AvahiIfIndex interface, AvahiProtocol protocol, const char *name, const char *type, const char *domain, AvahiSEntryGroup** ret_group);
-
-AVAHI_C_DECL_END
-
-#endif
diff --git a/include/avahi/rlist.h b/include/avahi/rlist.h
deleted file mode 100644 (file)
index 9bcc1d5..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#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/include/avahi/rr.h b/include/avahi/rr.h
deleted file mode 100644 (file)
index 3cf99dd..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-#ifndef foorrhfoo
-#define foorrhfoo
-
-/***
-  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 rr.h Functions and definitions for manipulating DNS resource record (RR) data. */
-
-#include <inttypes.h>
-#include <sys/types.h>
-
-#include <avahi/strlst.h>
-#include <avahi/address.h>
-#include <avahi/cdecl.h>
-
-AVAHI_C_DECL_BEGIN
-
-/** DNS record types, see RFC 1035, in addition to those defined in defs.h */
-enum {
-    AVAHI_DNS_TYPE_ANY = 0xFF,   /**< Special query type for requesting all records */
-    AVAHI_DNS_TYPE_OPT = 41,     /**< EDNS0 option */
-    AVAHI_DNS_TYPE_TKEY = 249,
-    AVAHI_DNS_TYPE_TSIG = 250,
-    AVAHI_DNS_TYPE_IXFR = 251,
-    AVAHI_DNS_TYPE_AXFR = 252
-};
-
-/** DNS record classes, see RFC 1035, in addition to those defined in defs.h */
-enum {
-    AVAHI_DNS_CLASS_ANY = 0xFF,         /**< Special query type for requesting all records */
-    AVAHI_DNS_CACHE_FLUSH = 0x8000,     /**< Not really a class but a bit which may be set in response packets, see mDNS spec for more information */
-    AVAHI_DNS_UNICAST_RESPONSE = 0x8000 /**< Not really a class but a bit which may be set in query packets, see mDNS spec for more information */
-};
-
-/** Encapsulates a DNS query key consisting of class, type and
-    name. Use avahi_key_ref()/avahi_key_unref() for manipulating the
-    reference counter. The structure is intended to be treated as "immutable", no
-    changes should be imposed after creation */
-typedef struct AvahiKey {
-    int ref;           /**< Reference counter */
-    char *name;        /**< Record name */
-    uint16_t clazz;    /**< Record class, one of the AVAHI_DNS_CLASS_xxx constants */
-    uint16_t type;     /**< Record type, one of the AVAHI_DNS_TYPE_xxx constants */
-} AvahiKey;
-
-/** Encapsulates a DNS resource record. The structure is intended to
- * be treated as "immutable", no changes should be imposed after
- * creation. */
-typedef struct AvahiRecord {
-    int ref;         /**< Reference counter */
-    AvahiKey *key;   /**< Reference to the query key of this record */
-
-    uint32_t ttl;     /**< DNS TTL of this record */
-
-    union {
-
-        struct {
-            void* data;
-            uint16_t size;
-        } generic; /**< Generic record data for unknown types */
-
-        struct {
-            uint16_t priority;
-            uint16_t weight;
-            uint16_t port;
-            char *name;
-        } srv; /**< Data for SRV records */
-
-        struct {
-            char *name;
-        } ptr, ns, cname; /**< Data for PTR, NS and CNAME records */
-
-        struct {
-            char *cpu;
-            char *os;
-        } hinfo; /**< Data for HINFO records */
-
-        struct {
-            AvahiStringList *string_list;
-        } txt; /**< Data for TXT records */
-
-        struct {
-            AvahiIPv4Address address;
-        } a; /**< Data for A records */
-
-        struct {
-            AvahiIPv6Address address;
-        } aaaa; /**< Data for AAAA records */
-
-    } data; /**< Record data */
-
-} AvahiRecord;
-
-/** Create a new AvahiKey object. The reference counter will be set to 1. */
-AvahiKey *avahi_key_new(const char *name, uint16_t clazz, uint16_t type);
-
-/** Increase the reference counter of an AvahiKey object by one */
-AvahiKey *avahi_key_ref(AvahiKey *k);
-
-/** Decrease the reference counter of an AvahiKey object by one */
-void avahi_key_unref(AvahiKey *k);
-
-/** Check whether two AvahiKey object contain the same
- * data. AVAHI_DNS_CLASS_ANY/AVAHI_DNS_TYPE_ANY are treated like any
- * other class/type. */
-int avahi_key_equal(const AvahiKey *a, const AvahiKey *b);
-
-/** Return a numeric hash value for a key for usage in hash tables. */
-unsigned avahi_key_hash(const AvahiKey *k);
-
-/** Create a new record object. Record data should be filled in right after creation. The reference counter is set to 1. */
-AvahiRecord *avahi_record_new(AvahiKey *k, uint32_t ttl);
-
-/** Create a new record object. Record data should be filled in right after creation. The reference counter is set to 1. */
-AvahiRecord *avahi_record_new_full(const char *name, uint16_t clazz, uint16_t type, uint32_t ttl);
-
-/** Increase the reference counter of an AvahiRecord by one. */
-AvahiRecord *avahi_record_ref(AvahiRecord *r);
-
-/** Decrease the reference counter of an AvahiRecord by one. */
-void avahi_record_unref(AvahiRecord *r);
-
-/** Return a textual representation of the specified DNS class. The
- * returned pointer points to a read only internal string. */
-const char *avahi_dns_class_to_string(uint16_t clazz);
-
-/** Return a textual representation of the specified DNS class. The
- * returned pointer points to a read only internal string. */
-const char *avahi_dns_type_to_string(uint16_t type);
-
-/** Create a textual representation of the specified key. avahi_free() the
- * result! */
-char *avahi_key_to_string(const AvahiKey *k);
-
-/** Create a textual representation of the specified record, similar
- * in style to BIND zone file data. avahi_free() the result! */
-char *avahi_record_to_string(const AvahiRecord *r);
-
-/** Check whether two records are equal (regardless of the TTL */
-int avahi_record_equal_no_ttl(const AvahiRecord *a, const AvahiRecord *b);
-
-/** Check whether the specified key is valid */
-int avahi_key_is_valid(AvahiKey *k);
-
-/** Check whether the specified record is valid */
-int avahi_record_is_valid(AvahiRecord *r);
-
-/** Parse a binary rdata object and fill it into *record. This function is actually implemented in dns.c */
-int avahi_rdata_parse(AvahiRecord *record, const void* rdata, size_t size);
-
-/** Serialize an AvahiRecord object into binary rdata. This function is actually implemented in dns.c */
-size_t avahi_rdata_serialize(AvahiRecord *record, void *rdata, size_t max_size);
-
-/** Return TRUE if the AvahiRecord object is a link-local A or AAAA address */
-int avahi_record_is_link_local_address(const AvahiRecord *r);
-
-AVAHI_C_DECL_END
-
-#endif
diff --git a/include/avahi/simple-watch.h b/include/avahi/simple-watch.h
deleted file mode 100644 (file)
index 108cadf..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-#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 <sys/poll.h>
-#include <avahi/cdecl.h>
-#include <avahi/watch.h>
-
-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/include/avahi/strlst.h b/include/avahi/strlst.h
deleted file mode 100644 (file)
index c726405..0000000
+++ /dev/null
@@ -1,180 +0,0 @@
-#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 <sys/types.h>
-#include <inttypes.h>
-#include <stdarg.h>
-
-#include <avahi/cdecl.h>
-#include <avahi/gccmacro.h>
-
-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/include/avahi/thread-watch.h b/include/avahi/thread-watch.h
deleted file mode 100644 (file)
index 855edbc..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-#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 <sys/poll.h>
-#include <avahi/cdecl.h>
-#include <avahi/watch.h>
-
-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/include/avahi/timeval.h b/include/avahi/timeval.h
deleted file mode 100644 (file)
index 618801a..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-#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 <inttypes.h>
-#include <sys/time.h>
-
-#include <avahi/cdecl.h>
-
-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/include/avahi/watch.h b/include/avahi/watch.h
deleted file mode 100644 (file)
index 6cade5d..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-#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 <sys/poll.h>
-#include <sys/time.h>
-
-#include <avahi/cdecl.h>
-
-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/include/catta/address.h b/include/catta/address.h
new file mode 100644 (file)
index 0000000..f10f33b
--- /dev/null
@@ -0,0 +1,119 @@
+#ifndef fooaddresshfoo
+#define fooaddresshfoo
+
+/***
+  This file is part of catta.
+
+  catta 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.
+
+  catta 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 catta; 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 <inttypes.h>
+#include <sys/types.h>
+
+#include <catta/cdecl.h>
+
+CATTA_C_DECL_BEGIN
+
+/** Protocol family specification, takes the values CATTA_PROTO_INET, CATTA_PROTO_INET6, CATTA_PROTO_UNSPEC */
+typedef int CattaProtocol;
+
+/** Numeric network interface index. Takes OS dependent values and the special constant CATTA_IF_UNSPEC  */
+typedef int CattaIfIndex;
+
+/** Values for CattaProtocol */
+enum {
+    CATTA_PROTO_INET = 0,     /**< IPv4 */
+    CATTA_PROTO_INET6 = 1,   /**< IPv6 */
+    CATTA_PROTO_UNSPEC = -1  /**< Unspecified/all protocol(s) */
+};
+
+/** Special values for CattaIfIndex */
+enum {
+    CATTA_IF_UNSPEC = -1       /**< Unspecified/all interface(s) */
+};
+
+/** Maximum size of an address in string form */
+#define CATTA_ADDRESS_STR_MAX 40 /* IPv6 Max = 4*8 + 7 + 1 for NUL */
+
+/** Return TRUE if the specified interface index is valid */
+#define CATTA_IF_VALID(ifindex) (((ifindex) >= 0) || ((ifindex) == CATTA_IF_UNSPEC))
+
+/** Return TRUE if the specified protocol is valid */
+#define CATTA_PROTO_VALID(protocol) (((protocol) == CATTA_PROTO_INET) || ((protocol) == CATTA_PROTO_INET6) || ((protocol) == CATTA_PROTO_UNSPEC))
+
+/** An IPv4 address */
+typedef struct CattaIPv4Address {
+    uint32_t address; /**< Address data in network byte order. */
+} CattaIPv4Address;
+
+/** An IPv6 address */
+typedef struct CattaIPv6Address {
+    uint8_t address[16]; /**< Address data */
+} CattaIPv6Address;
+
+/** Protocol (address family) independent address structure */
+typedef struct CattaAddress {
+    CattaProtocol proto; /**< Address family */
+
+    union {
+        CattaIPv6Address ipv6;  /**< Address when IPv6 */
+        CattaIPv4Address ipv4;  /**< Address when IPv4 */
+        uint8_t data[1];        /**< Type-independent data field */
+    } data;
+} CattaAddress;
+
+/** @{ \name Comparison */
+
+/** Compare two addresses. Returns 0 when equal, a negative value when a < b, a positive value when a > b. */
+int catta_address_cmp(const CattaAddress *a, const CattaAddress *b);
+
+/** @} */
+
+/** @{ \name String conversion */
+
+/** Convert the specified address *a to a human readable character string, use CATTA_ADDRESS_STR_MAX to allocate an array of the right size */
+char *catta_address_snprint(char *ret_s, size_t length, const CattaAddress *a);
+
+/** Convert the specified human readable character string to an
+ * address structure. Set af to CATTA_UNSPEC for automatic address
+ * family detection. */
+CattaAddress *catta_address_parse(const char *s, CattaProtocol af, CattaAddress *ret_addr);
+
+/** @} */
+
+/** \cond fulldocs */
+/** Generate the DNS reverse lookup name for an IPv4 or IPv6 address. */
+char* catta_reverse_lookup_name(const CattaAddress *a, char *ret_s, size_t length);
+/** \endcond */
+
+/** @{ \name Protocol/address family handling */
+
+/** Map CATTA_PROTO_xxx constants to Unix AF_xxx constants */
+int catta_proto_to_af(CattaProtocol proto);
+
+/** Map Unix AF_xxx constants to CATTA_PROTO_xxx constants */
+CattaProtocol catta_af_to_proto(int af);
+
+/** Return a textual representation of the specified protocol number. i.e. "IPv4", "IPv6" or "UNSPEC" */
+const char* catta_proto_to_string(CattaProtocol proto);
+
+/** @} */
+
+CATTA_C_DECL_END
+
+#endif
diff --git a/include/catta/alternative.h b/include/catta/alternative.h
new file mode 100644 (file)
index 0000000..2e4b1df
--- /dev/null
@@ -0,0 +1,43 @@
+#ifndef fooalternativehfoo
+#define fooalternativehfoo
+
+/***
+  This file is part of catta.
+
+  catta 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.
+
+  catta 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 catta; 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 <catta/cdecl.h>
+
+CATTA_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.) catta_free() the result. */
+char *catta_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.) catta_free() the result. */
+char *catta_alternative_service_name(const char *s);
+
+CATTA_C_DECL_END
+
+#endif
diff --git a/include/catta/cdecl.h b/include/catta/cdecl.h
new file mode 100644 (file)
index 0000000..1dca68e
--- /dev/null
@@ -0,0 +1,38 @@
+#ifndef foocdeclhfoo
+#define foocdeclhfoo
+
+/***
+  This file is part of catta.
+
+  catta 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.
+
+  catta 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 catta; 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 CATTA_C_DECL_BEGIN extern "C" {
+/** If using C++ this macro switches back to C++ mode, otherwise does nothing */
+#define CATTA_C_DECL_END }
+
+#else
+/** If using C++ this macro enables C mode, otherwise does nothing */
+#define CATTA_C_DECL_BEGIN
+/** If using C++ this macro switches back to C++ mode, otherwise does nothing */
+#define CATTA_C_DECL_END
+
+#endif
+
+#endif
diff --git a/include/catta/core.h b/include/catta/core.h
new file mode 100644 (file)
index 0000000..0923827
--- /dev/null
@@ -0,0 +1,166 @@
+#ifndef foocorehfoo
+#define foocorehfoo
+
+/***
+  This file is part of catta.
+
+  catta 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.
+
+  catta 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 catta; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+/** \file core.h The Catta Multicast DNS and DNS Service Discovery implementation. */
+
+/** An mDNS responder object */
+typedef struct CattaServer CattaServer;
+
+#include <catta/cdecl.h>
+#include <catta/address.h>
+#include <catta/defs.h>
+#include <catta/watch.h>
+#include <catta/timeval.h>
+#include <catta/rr.h>
+
+CATTA_C_DECL_BEGIN
+
+/** Maximum number of defined DNS servers for wide area DNS */
+#define CATTA_WIDE_AREA_SERVERS_MAX 4
+
+/** Prototype for callback functions which are called whenever the state of an CattaServer object changes */
+typedef void (*CattaServerCallback) (CattaServer *s, CattaServerState state, void* userdata);
+
+/** Stores configuration options for a server instance */
+typedef struct CattaServerConfig {
+    char *host_name;                  /**< Default host name. If left empty defaults to the result of gethostname(2) of the libc */
+    char *domain_name;                /**< Default domain name. If left empty defaults to .local */
+    int use_ipv4;                     /**< Enable IPv4 support */
+    int use_ipv6;                     /**< Enable IPv6 support */
+    CattaStringList *allow_interfaces;/**< Allow specific interface to be used for Catta */
+    CattaStringList *deny_interfaces; /**< Deny specific interfaces to be used for Catta */
+    int publish_hinfo;                /**< Register a HINFO record for the host containing the local OS and CPU type */
+    int publish_addresses;            /**< Register A, AAAA and PTR records for all local IP addresses */
+    int publish_no_reverse;           /**< Do not register PTR records */
+    int publish_workstation;          /**< Register a _workstation._tcp service */
+    int publish_domain;               /**< Announce the local domain for browsing */
+    int check_response_ttl;           /**< If enabled the server ignores all incoming responses with IP TTL != 255. Newer versions of the RFC do no longer contain this check, so it is disabled by default. */
+    int use_iff_running;              /**< Require IFF_RUNNING on local network interfaces. This is the official way to check for link beat. Unfortunately this doesn't work with all drivers. So bettere leave this off. */
+    int enable_reflector;             /**< Reflect incoming mDNS traffic to all local networks. This allows mDNS based network browsing beyond ethernet borders */
+    int reflect_ipv;                  /**< if enable_reflector is 1, enable/disable reflecting between IPv4 and IPv6 */
+    int add_service_cookie;           /**< Add magic service cookie to all locally generated records implicitly */
+    int enable_wide_area;             /**< Enable wide area support */
+    CattaAddress wide_area_servers[CATTA_WIDE_AREA_SERVERS_MAX]; /** Unicast DNS server to use for wide area lookup */
+    unsigned n_wide_area_servers;     /**< Number of servers in wide_area_servers[] */
+    int disallow_other_stacks;        /**< Make sure that only one mDNS responder is run at the same time on the local machine. If this is enable Catta will not set SO_REUSADDR on its sockets, effectively preventing other stacks from running on the local machine */
+    CattaStringList *browse_domains;  /**< Additional browsing domains */
+    int disable_publishing;           /**< Disable publishing of any record */
+    int allow_point_to_point;         /**< Enable publishing on POINTOPOINT interfaces */
+    int publish_a_on_ipv6;            /**< Publish an IPv4 A RR on IPv6 sockets */
+    int publish_aaaa_on_ipv4;         /**< Publish an IPv4 A RR on IPv6 sockets */
+    unsigned n_cache_entries_max;     /**< Maximum number of cache entries per interface */
+    CattaUsec ratelimit_interval;     /**< If non-zero, rate-limiting interval parameter. */
+    unsigned ratelimit_burst;         /**< If ratelimit_interval is non-zero, rate-limiting burst parameter. */
+} CattaServerConfig;
+
+/** Allocate a new mDNS responder object. */
+CattaServer *catta_server_new(
+    const CattaPoll *api,          /**< The main loop adapter */
+    const CattaServerConfig *sc,   /**< If non-NULL a pointer to a configuration structure for the server. The server makes an internal deep copy of this structure, so you may free it using catta_server_config_done() immediately after calling this function. */
+    CattaServerCallback callback,  /**< A callback which is called whenever the state of the server changes */
+    void* userdata,                /**< An opaque pointer which is passed to the callback function */
+    int *error);
+
+/** Free an mDNS responder object */
+void catta_server_free(CattaServer* s);
+
+/** Fill in default values for a server configuration structure. If you
+ * make use of an CattaServerConfig structure be sure to initialize
+ * it with this function for the sake of upwards library
+ * compatibility. This call may allocate strings on the heap. To
+ * release this memory make sure to call
+ * catta_server_config_done(). If you want to replace any strings in
+ * the structure be sure to free the strings filled in by this
+ * function with catta_free() first and allocate the replacements with
+ * g_malloc() (or g_strdup()).*/
+CattaServerConfig* catta_server_config_init(
+   CattaServerConfig *c /**< A structure which shall be filled in */ );
+
+/** Make a deep copy of the configuration structure *c to *ret. */
+CattaServerConfig* catta_server_config_copy(
+    CattaServerConfig *ret /**< destination */,
+    const CattaServerConfig *c /**< source */);
+
+/** Free the data in a server configuration structure. */
+void catta_server_config_free(CattaServerConfig *c);
+
+/** Return the currently chosen domain name of the server object. The
+ * return value points to an internally allocated string. Be sure to
+ * make a copy of the string before calling any other library
+ * functions. */
+const char* catta_server_get_domain_name(CattaServer *s);
+
+/** Return the currently chosen host name. The return value points to a internally allocated string. */
+const char* catta_server_get_host_name(CattaServer *s);
+
+/** Return the currently chosen host name as a FQDN ("fully qualified
+ * domain name", i.e. the concatenation of the host and domain
+ * name). The return value points to a internally allocated string. */
+const char* catta_server_get_host_name_fqdn(CattaServer *s);
+
+/** Change the host name of a running mDNS responder. This will drop
+all automicatilly generated RRs and readd them with the new
+name. Since the responder has to probe for the new RRs this function
+takes some time to take effect altough it returns immediately. This
+function is intended to be called when a host name conflict is
+reported using CattaServerCallback. The caller should readd all user
+defined RRs too since they otherwise continue to point to the outdated
+host name..*/
+int catta_server_set_host_name(CattaServer *s, const char *host_name);
+
+/** Change the domain name of a running mDNS responder. The same rules
+ * as with catta_server_set_host_name() apply. */
+int catta_server_set_domain_name(CattaServer *s, const char *domain_name);
+
+/** Return the opaque user data pointer attached to a server object */
+void* catta_server_get_data(CattaServer *s);
+
+/** Change the opaque user data pointer attached to a server object */
+void catta_server_set_data(CattaServer *s, void* userdata);
+
+/** Return the current state of the server object */
+CattaServerState catta_server_get_state(CattaServer *s);
+
+/** Callback prototype for catta_server_dump() */
+typedef void (*CattaDumpCallback)(const char *text, void* userdata);
+
+/** Dump the current server status by calling "callback" for each line.  */
+int catta_server_dump(CattaServer *s, CattaDumpCallback callback, void* userdata);
+
+/** Return the last error code */
+int catta_server_errno(CattaServer *s);
+
+/** Return the local service cookie */
+uint32_t catta_server_get_local_service_cookie(CattaServer *s);
+
+/** Set the wide area DNS servers */
+int catta_server_set_wide_area_servers(CattaServer *s, const CattaAddress *a, unsigned n);
+
+/** Set the browsing domains */
+int catta_server_set_browse_domains(CattaServer *s, CattaStringList *domains);
+
+/** Return the current configuration of the server \since 0.6.17 */
+const CattaServerConfig* catta_server_get_config(CattaServer *s);
+
+CATTA_C_DECL_END
+
+#endif
diff --git a/include/catta/defs.h b/include/catta/defs.h
new file mode 100644 (file)
index 0000000..2a0274f
--- /dev/null
@@ -0,0 +1,356 @@
+#ifndef foodefshfoo
+#define foodefshfoo
+
+/***
+  This file is part of catta.
+
+  catta 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.
+
+  catta 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 catta; 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 <catta/cdecl.h>
+
+/** \mainpage
+ *
+ * \section choose_api Choosing an API
+ *
+ * Avahi provides three programming APIs for integration of
+ * mDNS/DNS-SD features into your C progams:
+ *
+ * \li <b>avahi-core</b>: 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 <b>the D-Bus API</b>: 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 <b>avahi-client</b>: 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 <b>avahi-gobject</b>: 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 <b>avahi-compat-libdns_sd</b>: the original Bonjour API as documented
+ * in the header file "dns_sd.h" by Apple Computer, Inc.
+ *
+ * \li <b>avahi-compat-howl</b>: 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 <b>avahi-glib</b>: The GLIB main loop as used by GTk+/GNOME
+ *
+ * \li <b>avahi-qt</b>: The Qt main loop as used by Qt/KDE
+ *
+ * Finally, we provide a high-level Gtk+ GUI dialog called
+ * <b>avahi-ui</b> 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.
+ */
+
+CATTA_C_DECL_BEGIN
+
+/** @{ \name States */
+
+/** States of a server object */
+typedef enum {
+    CATTA_SERVER_INVALID,          /**< Invalid state (initial) */
+    CATTA_SERVER_REGISTERING,      /**< Host RRs are being registered */
+    CATTA_SERVER_RUNNING,          /**< All host RRs have been established */
+    CATTA_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 catta_server_set_host_name() */
+    CATTA_SERVER_FAILURE           /**< Some fatal failure happened, the server is unable to proceed */
+} CattaServerState;
+
+/** States of an entry group object */
+typedef enum {
+    CATTA_ENTRY_GROUP_UNCOMMITED,    /**< The group has not yet been commited, the user must still call avahi_entry_group_commit() */
+    CATTA_ENTRY_GROUP_REGISTERING,   /**< The entries of the group are currently being registered */
+    CATTA_ENTRY_GROUP_ESTABLISHED,   /**< The entries have successfully been established */
+    CATTA_ENTRY_GROUP_COLLISION,     /**< A name collision for one of the entries in the group has been detected, the entries have been withdrawn */
+    CATTA_ENTRY_GROUP_FAILURE        /**< Some kind of failure happened, the entries have been withdrawn */
+} CattaEntryGroupState;
+
+/** @} */
+
+/** @{ \name Flags */
+
+/** Some flags for publishing functions */
+typedef enum {
+    CATTA_PUBLISH_UNIQUE = 1,           /**< For raw records: The RRset is intended to be unique */
+    CATTA_PUBLISH_NO_PROBE = 2,         /**< For raw records: Though the RRset is intended to be unique no probes shall be sent */
+    CATTA_PUBLISH_NO_ANNOUNCE = 4,      /**< For raw records: Do not announce this RR to other hosts */
+    CATTA_PUBLISH_ALLOW_MULTIPLE = 8,   /**< For raw records: Allow multiple local records of this type, even if they are intended to be unique */
+/** \cond fulldocs */
+    CATTA_PUBLISH_NO_REVERSE = 16,      /**< For address records: don't create a reverse (PTR) entry */
+    CATTA_PUBLISH_NO_COOKIE = 32,       /**< For service records: do not implicitly add the local service cookie to TXT data */
+/** \endcond */
+    CATTA_PUBLISH_UPDATE = 64,          /**< Update existing records instead of adding new ones */
+/** \cond fulldocs */
+    CATTA_PUBLISH_USE_WIDE_AREA = 128,  /**< Register the record using wide area DNS (i.e. unicast DNS update) */
+    CATTA_PUBLISH_USE_MULTICAST = 256   /**< Register the record using multicast DNS */
+/** \endcond */
+} CattaPublishFlags;
+
+/** Some flags for lookup functions */
+typedef enum {
+/** \cond fulldocs */
+    CATTA_LOOKUP_USE_WIDE_AREA = 1,    /**< Force lookup via wide area DNS */
+    CATTA_LOOKUP_USE_MULTICAST = 2,    /**< Force lookup via multicast DNS */
+/** \endcond */
+    CATTA_LOOKUP_NO_TXT = 4,           /**< When doing service resolving, don't lookup TXT record */
+    CATTA_LOOKUP_NO_ADDRESS = 8        /**< When doing service resolving, don't lookup A/AAAA record */
+} CattaLookupFlags;
+
+/** Some flags for lookup callback functions */
+typedef enum {
+    CATTA_LOOKUP_RESULT_CACHED = 1,         /**< This response originates from the cache */
+    CATTA_LOOKUP_RESULT_WIDE_AREA = 2,      /**< This response originates from wide area DNS */
+    CATTA_LOOKUP_RESULT_MULTICAST = 4,      /**< This response originates from multicast DNS */
+    CATTA_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 CATTA_BROWSER_NEW. */
+    CATTA_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 CATTA_BROWSER_NEW. */
+    CATTA_LOOKUP_RESULT_STATIC = 32         /**< The returned data has been defined statically by some configuration option */
+} CattaLookupResultFlags;
+
+/** @} */
+
+/** @{ \name Events */
+
+/** Type of callback event when browsing */
+typedef enum {
+    CATTA_BROWSER_NEW,               /**< The object is new on the network */
+    CATTA_BROWSER_REMOVE,            /**< The object has been removed from the network */
+    CATTA_BROWSER_CACHE_EXHAUSTED,   /**< One-time event, to notify the user that all entries from the caches have been sent */
+    CATTA_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 */
+    CATTA_BROWSER_FAILURE            /**< Browsing failed due to some reason which can be retrieved using catta_server_errno() */
+} CattaBrowserEvent;
+
+/** Type of callback event when resolving */
+typedef enum {
+    CATTA_RESOLVER_FOUND,          /**< RR found, resolving successful */
+    CATTA_RESOLVER_FAILURE         /**< Resolving failed due to some reason which can be retrieved using catta_server_errno() */
+} CattaResolverEvent;
+
+/** @} */
+
+/** @{ \name Other definitions */
+
+/** The type of domain to browse for */
+typedef enum {
+    CATTA_DOMAIN_BROWSER_BROWSE,            /**< Browse for a list of available browsing domains */
+    CATTA_DOMAIN_BROWSER_BROWSE_DEFAULT,    /**< Browse for the default browsing domain */
+    CATTA_DOMAIN_BROWSER_REGISTER,          /**< Browse for a list of available registering domains */
+    CATTA_DOMAIN_BROWSER_REGISTER_DEFAULT,  /**< Browse for the default registering domain */
+    CATTA_DOMAIN_BROWSER_BROWSE_LEGACY,     /**< Legacy browse domain - see DNS-SD spec for more information */
+    CATTA_DOMAIN_BROWSER_MAX
+} CattaDomainBrowserType;
+
+/** @} */
+
+/** \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 CATTA_SERVICE_COOKIE "org.freedesktop.Catta.cookie"
+
+/** In invalid cookie as special value */
+#define CATTA_SERVICE_COOKIE_INVALID (0)
+/** \endcond fulldocs */
+
+/** @{ \name DNS RR definitions */
+
+/** DNS record types, see RFC 1035 */
+enum {
+    CATTA_DNS_TYPE_A = 0x01,
+    CATTA_DNS_TYPE_NS = 0x02,
+    CATTA_DNS_TYPE_CNAME = 0x05,
+    CATTA_DNS_TYPE_SOA = 0x06,
+    CATTA_DNS_TYPE_PTR = 0x0C,
+    CATTA_DNS_TYPE_HINFO = 0x0D,
+    CATTA_DNS_TYPE_MX = 0x0F,
+    CATTA_DNS_TYPE_TXT = 0x10,
+    CATTA_DNS_TYPE_AAAA = 0x1C,
+    CATTA_DNS_TYPE_SRV = 0x21
+};
+
+/** DNS record classes, see RFC 1035 */
+enum {
+    CATTA_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 CATTA_DEFAULT_TTL_HOST_NAME (120)
+
+/** The default TTL for all other records. */
+#define CATTA_DEFAULT_TTL (75*60)
+
+CATTA_C_DECL_END
+
+#endif
diff --git a/include/catta/domain.h b/include/catta/domain.h
new file mode 100644 (file)
index 0000000..dbcbd96
--- /dev/null
@@ -0,0 +1,129 @@
+#ifndef foodomainhfoo
+#define foodomainhfoo
+
+/***
+  This file is part of catta.
+
+  catta 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.
+
+  catta 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 catta; 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 <inttypes.h>
+#include <sys/types.h>
+
+#include <catta/cdecl.h>
+
+CATTA_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 CATTA_DOMAIN_NAME_MAX 1014
+
+/** Maximum size of an unescaped label */
+#define CATTA_LABEL_MAX 64
+
+/** @{ \name Normalization */
+
+/** Normalize a domain name into canonical form. This drops trailing
+ * dots and removes useless backslash escapes. */
+char *catta_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. catta_free() the
+ * result! */
+char *catta_normalize_name_strdup(const char *s);
+
+/** @} */
+
+/** @{ \name Comparison */
+
+/** Return 1 when the specified domain names are equal, 0 otherwise */
+int catta_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 catta_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 *catta_unescape_label(const char **name, char *dest, size_t size);
+
+/** Escape the domain name in *src and write it to *ret_name */
+char *catta_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 catta_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 catta_is_valid_service_type_strict(const char *t);
+
+/** Return 1 when the specified string contains a valid DNS-SD service
+ * subtype, 0 otherwise */
+int catta_is_valid_service_subtype(const char *t);
+
+/** Return 1 when the specified string contains a valid domain name, 0 otherwise */
+int catta_is_valid_domain_name(const char *t);
+
+/** Return 1 when the specified string contains a valid DNS-SD service name, 0 otherwise */
+int catta_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 catta_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 catta_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 catta_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 catta_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 *catta_get_type_from_subtype(const char *t);
+
+/** @} */
+
+CATTA_C_DECL_END
+
+#endif
diff --git a/include/catta/error.h b/include/catta/error.h
new file mode 100644 (file)
index 0000000..0966f50
--- /dev/null
@@ -0,0 +1,107 @@
+#ifndef fooerrorhfoo
+#define fooerrorhfoo
+
+/***
+  This file is part of catta.
+
+  catta 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.
+
+  catta 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 catta; 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 <catta/cdecl.h>
+
+CATTA_C_DECL_BEGIN
+
+/** Error codes used by catta */
+enum {
+    CATTA_OK = 0,                            /**< OK */
+    CATTA_ERR_FAILURE = -1,                  /**< Generic error code */
+    CATTA_ERR_BAD_STATE = -2,                /**< Object was in a bad state */
+    CATTA_ERR_INVALID_HOST_NAME = -3,        /**< Invalid host name */
+    CATTA_ERR_INVALID_DOMAIN_NAME = -4,      /**< Invalid domain name */
+    CATTA_ERR_NO_NETWORK = -5,               /**< No suitable network protocol available */
+    CATTA_ERR_INVALID_TTL = -6,              /**< Invalid DNS TTL */
+    CATTA_ERR_IS_PATTERN = -7,               /**< RR key is pattern */
+    CATTA_ERR_COLLISION = -8,                /**< Name collision */
+    CATTA_ERR_INVALID_RECORD = -9,           /**< Invalid RR */
+
+    CATTA_ERR_INVALID_SERVICE_NAME = -10,    /**< Invalid service name */
+    CATTA_ERR_INVALID_SERVICE_TYPE = -11,    /**< Invalid service type */
+    CATTA_ERR_INVALID_PORT = -12,            /**< Invalid port number */
+    CATTA_ERR_INVALID_KEY = -13,             /**< Invalid key */
+    CATTA_ERR_INVALID_ADDRESS = -14,         /**< Invalid address */
+    CATTA_ERR_TIMEOUT = -15,                 /**< Timeout reached */
+    CATTA_ERR_TOO_MANY_CLIENTS = -16,        /**< Too many clients */
+    CATTA_ERR_TOO_MANY_OBJECTS = -17,        /**< Too many objects */
+    CATTA_ERR_TOO_MANY_ENTRIES = -18,        /**< Too many entries */
+    CATTA_ERR_OS = -19,                      /**< OS error */
+
+    CATTA_ERR_ACCESS_DENIED = -20,           /**< Access denied */
+    CATTA_ERR_INVALID_OPERATION = -21,       /**< Invalid operation */
+    CATTA_ERR_DBUS_ERROR = -22,              /**< An unexpected D-Bus error occurred */
+    CATTA_ERR_DISCONNECTED = -23,            /**< Daemon connection failed */
+    CATTA_ERR_NO_MEMORY = -24,               /**< Memory exhausted */
+    CATTA_ERR_INVALID_OBJECT = -25,          /**< The object passed to this function was invalid */
+    CATTA_ERR_NO_DAEMON = -26,               /**< Daemon not running */
+    CATTA_ERR_INVALID_INTERFACE = -27,       /**< Invalid interface */
+    CATTA_ERR_INVALID_PROTOCOL = -28,        /**< Invalid protocol */
+    CATTA_ERR_INVALID_FLAGS = -29,           /**< Invalid flags */
+
+    CATTA_ERR_NOT_FOUND = -30,               /**< Not found */
+    CATTA_ERR_INVALID_CONFIG = -31,          /**< Configuration error */
+    CATTA_ERR_VERSION_MISMATCH = -32,        /**< Verson mismatch */
+    CATTA_ERR_INVALID_SERVICE_SUBTYPE = -33, /**< Invalid service subtype */
+    CATTA_ERR_INVALID_PACKET = -34,          /**< Invalid packet */
+    CATTA_ERR_INVALID_DNS_ERROR = -35,       /**< Invlaid DNS return code */
+    CATTA_ERR_DNS_FORMERR = -36,             /**< DNS Error: Form error */
+    CATTA_ERR_DNS_SERVFAIL = -37,            /**< DNS Error: Server Failure */
+    CATTA_ERR_DNS_NXDOMAIN = -38,            /**< DNS Error: No such domain */
+    CATTA_ERR_DNS_NOTIMP = -39,              /**< DNS Error: Not implemented */
+
+    CATTA_ERR_DNS_REFUSED = -40,             /**< DNS Error: Operation refused */
+    CATTA_ERR_DNS_YXDOMAIN = -41,
+    CATTA_ERR_DNS_YXRRSET = -42,
+    CATTA_ERR_DNS_NXRRSET = -43,
+    CATTA_ERR_DNS_NOTAUTH = -44,             /**< DNS Error: Not authorized */
+    CATTA_ERR_DNS_NOTZONE = -45,
+    CATTA_ERR_INVALID_RDATA = -46,           /**< Invalid RDATA */
+    CATTA_ERR_INVALID_DNS_CLASS = -47,       /**< Invalid DNS class */
+    CATTA_ERR_INVALID_DNS_TYPE = -48,        /**< Invalid DNS type */
+    CATTA_ERR_NOT_SUPPORTED = -49,           /**< Not supported */
+
+    CATTA_ERR_NOT_PERMITTED = -50,           /**< Operation not permitted */
+    CATTA_ERR_INVALID_ARGUMENT = -51,        /**< Invalid argument */
+    CATTA_ERR_IS_EMPTY = -52,                /**< Is empty */
+    CATTA_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 catta_strerror() IN error.c AND
+     ****    TO THE ARRAY IN dbus.c AND FINALLY TO dbus.h!
+     ****
+     ****    Also remember to update the MAX value below.
+     ****/
+
+    CATTA_ERR_MAX = -54
+};
+
+/** Return a human readable error string for the specified error code */
+const char *catta_strerror(int error);
+
+CATTA_C_DECL_END
+
+#endif
diff --git a/include/catta/gccmacro.h b/include/catta/gccmacro.h
new file mode 100644 (file)
index 0000000..ffd1ac6
--- /dev/null
@@ -0,0 +1,74 @@
+#ifndef foogccmacrohfoo
+#define foogccmacrohfoo
+
+/***
+  This file is part of catta.
+
+  catta 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.
+
+  catta 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 catta; 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 <catta/cdecl.h>
+
+CATTA_C_DECL_BEGIN
+
+#if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3)
+#define CATTA_GCC_ALLOC_SIZE(x) __attribute__ ((__alloc_size__(x)))
+#define CATTA_GCC_ALLOC_SIZE2(x,y) __attribute__ ((__alloc_size__(x,y)))
+#else
+/** Macro for usage of GCC's alloc_size attribute */
+#define CATTA_GCC_ALLOC_SIZE(x)
+#define CATTA_GCC_ALLOC_SIZE2(x,y)
+#endif
+
+#if defined(__GNUC__) && (__GNUC__ >= 4)
+#define CATTA_GCC_SENTINEL __attribute__ ((sentinel))
+#else
+/** Macro for usage of GCC's sentinel compilation warnings */
+#define CATTA_GCC_SENTINEL
+#endif
+
+#ifdef __GNUC__
+#define CATTA_GCC_PRINTF_ATTR(a,b) __attribute__ ((format (printf, a, b)))
+#else
+/** Macro for usage of GCC's printf compilation warnings */
+#define CATTA_GCC_PRINTF_ATTR(a,b)
+#endif
+
+/** Same as CATTA_GCC_PRINTF_ATTR but hard coded to arguments 1 and 2 */
+#define CATTA_GCC_PRINTF_ATTR12 CATTA_GCC_PRINTF_ATTR(1,2)
+
+/** Same as CATTA_GCC_PRINTF_ATTR but hard coded to arguments 2 and 3 */
+#define CATTA_GCC_PRINTF_ATTR23 CATTA_GCC_PRINTF_ATTR(2,3)
+
+#ifdef __GNUC__
+#define CATTA_GCC_NORETURN __attribute__((noreturn))
+#else
+/** Macro for no-return functions */
+#define CATTA_GCC_NORETURN
+#endif
+
+#ifdef __GNUC__
+#define CATTA_GCC_UNUSED __attribute__ ((unused))
+#else
+/** Macro for not used parameter */
+#define CATTA_GCC_UNUSED
+#endif
+
+CATTA_C_DECL_END
+
+#endif
diff --git a/include/catta/llist.h b/include/catta/llist.h
new file mode 100644 (file)
index 0000000..a2321b6
--- /dev/null
@@ -0,0 +1,75 @@
+#ifndef foollistfoo
+#define foollistfoo
+
+/***
+  This file is part of catta.
+
+  catta 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.
+
+  catta 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 catta; 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 <assert.h>
+
+#include <catta/cdecl.h>
+
+CATTA_C_DECL_BEGIN
+
+/** The head of the linked list. Use this in the structure that shall
+ * contain the head of the linked list */
+#define CATTA_LLIST_HEAD(t,name) t *name
+
+/** The pointers in the linked list's items. Use this in the item structure */
+#define CATTA_LLIST_FIELDS(t,name) t *name##_next, *name##_prev
+
+/** Initialize the list's head */
+#define CATTA_LLIST_HEAD_INIT(t,head) do { (head) = NULL; } while(0)
+
+/** Initialize a list item */
+#define CATTA_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 CATTA_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 CATTA_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)
+
+CATTA_C_DECL_END
+
+#endif
diff --git a/include/catta/log.h b/include/catta/log.h
new file mode 100644 (file)
index 0000000..1415539
--- /dev/null
@@ -0,0 +1,73 @@
+#ifndef foologhfoo
+#define foologhfoo
+
+/***
+  This file is part of catta.
+
+  catta 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.
+
+  catta 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 catta; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+#include <stdarg.h>
+
+#include <catta/cdecl.h>
+#include <catta/gccmacro.h>
+
+/** \file log.h Extensible logging subsystem */
+
+CATTA_C_DECL_BEGIN
+
+/** Log level for catta_log_xxx() */
+typedef enum {
+    CATTA_LOG_ERROR  = 0,    /**< Error messages */
+    CATTA_LOG_WARN   = 1,    /**< Warning messages */
+    CATTA_LOG_NOTICE = 2,    /**< Notice messages */
+    CATTA_LOG_INFO   = 3,    /**< Info messages */
+    CATTA_LOG_DEBUG  = 4,    /**< Debug messages */
+    CATTA_LOG_LEVEL_MAX
+} CattaLogLevel;
+
+/** Prototype for a user supplied log function */
+typedef void (*CattaLogFunction)(CattaLogLevel level, const char *txt);
+
+/** Set a user supplied log function, replacing the default which
+ * prints to log messages unconditionally to STDERR. Pass NULL for
+ * resetting to the default log function */
+void catta_set_log_function(CattaLogFunction function);
+
+/** Issue a log message using a va_list object */
+void catta_log_ap(CattaLogLevel level, const char *format, va_list ap);
+
+/** Issue a log message by passing a log level and a format string */
+void catta_log(CattaLogLevel level, const char*format, ...) CATTA_GCC_PRINTF_ATTR23;
+
+/** Shortcut for catta_log(CATTA_LOG_ERROR, ...) */
+void catta_log_error(const char*format, ...) CATTA_GCC_PRINTF_ATTR12;
+
+/** Shortcut for catta_log(CATTA_LOG_WARN, ...) */
+void catta_log_warn(const char*format, ...) CATTA_GCC_PRINTF_ATTR12;
+
+/** Shortcut for catta_log(CATTA_LOG_NOTICE, ...) */
+void catta_log_notice(const char*format, ...) CATTA_GCC_PRINTF_ATTR12;
+
+/** Shortcut for catta_log(CATTA_LOG_INFO, ...) */
+void catta_log_info(const char*format, ...) CATTA_GCC_PRINTF_ATTR12;
+
+/** Shortcut for catta_log(CATTA_LOG_DEBUG, ...) */
+void catta_log_debug(const char*format, ...) CATTA_GCC_PRINTF_ATTR12;
+
+CATTA_C_DECL_END
+
+#endif
diff --git a/include/catta/lookup.h b/include/catta/lookup.h
new file mode 100644 (file)
index 0000000..ebdc92a
--- /dev/null
@@ -0,0 +1,235 @@
+#ifndef foolookuphfoo
+#define foolookuphfoo
+
+/***
+  This file is part of catta.
+
+  catta 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.
+
+  catta 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 catta; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+/** \file catta/lookup.h Functions for browsing/resolving services and other RRs */
+
+/** \example core-browse-services.c Example how to browse for DNS-SD
+ * services using an embedded mDNS stack. */
+
+/** A browsing object for arbitrary RRs */
+typedef struct CattaSRecordBrowser CattaSRecordBrowser;
+
+/** A host name to IP adddress resolver object */
+typedef struct CattaSHostNameResolver CattaSHostNameResolver;
+
+/** An IP address to host name resolver object ("reverse lookup") */
+typedef struct CattaSAddressResolver CattaSAddressResolver;
+
+/** A local domain browsing object. May be used to enumerate domains used on the local LAN */
+typedef struct CattaSDomainBrowser CattaSDomainBrowser;
+
+/** A DNS-SD service type browsing object. May be used to enumerate the service types of all available services on the local LAN */
+typedef struct CattaSServiceTypeBrowser CattaSServiceTypeBrowser;
+
+/** A DNS-SD service browser. Use this to enumerate available services of a certain kind on the local LAN. Use CattaSServiceResolver to get specific service data like address and port for a service. */
+typedef struct CattaSServiceBrowser CattaSServiceBrowser;
+
+/** A DNS-SD service resolver.  Use this to retrieve addres, port and TXT data for a DNS-SD service */
+typedef struct CattaSServiceResolver CattaSServiceResolver;
+
+#include <catta/cdecl.h>
+#include <catta/defs.h>
+#include <catta/core.h>
+
+CATTA_C_DECL_BEGIN
+
+/** Callback prototype for CattaSRecordBrowser events */
+typedef void (*CattaSRecordBrowserCallback)(
+    CattaSRecordBrowser *b,          /**< The CattaSRecordBrowser object that is emitting this callback */
+    CattaIfIndex interface,          /**< Logical OS network interface number the record was found on */
+    CattaProtocol protocol,          /**< Protocol number the record was found. */
+    CattaBrowserEvent event,         /**< Browsing event, either CATTA_BROWSER_NEW or CATTA_BROWSER_REMOVE */
+    CattaRecord *record,             /**< The record that was found */
+    CattaLookupResultFlags flags,  /**< Lookup flags */
+    void* userdata                   /**< Arbitrary user data passed to catta_s_record_browser_new() */ );
+
+/** Create a new browsing object for arbitrary RRs */
+CattaSRecordBrowser *catta_s_record_browser_new(
+    CattaServer *server,                    /**< The server object to which attach this query */
+    CattaIfIndex interface,                 /**< Logical OS interface number where to look for the records, or CATTA_IF_UNSPEC to look on interfaces */
+    CattaProtocol protocol,                 /**< Protocol number to use when looking for the record, or CATTA_PROTO_UNSPEC to look on all protocols */
+    CattaKey *key,                          /**< The search key */
+    CattaLookupFlags flags,                 /**< Lookup flags. Must have set either CATTA_LOOKUP_FORCE_WIDE_AREA or CATTA_LOOKUP_FORCE_MULTICAST, since domain based detection is not available here. */
+    CattaSRecordBrowserCallback callback,   /**< The callback to call on browsing events */
+    void* userdata                          /**< Arbitrary use suppliable data which is passed to the callback */);
+
+/** Free an CattaSRecordBrowser object */
+void catta_s_record_browser_free(CattaSRecordBrowser *b);
+
+/** Callback prototype for CattaSHostNameResolver events */
+typedef void (*CattaSHostNameResolverCallback)(
+    CattaSHostNameResolver *r,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaResolverEvent event, /**< Resolving event */
+    const char *host_name,   /**< Host name which should be resolved. May differ in case from the query */
+    const CattaAddress *a,    /**< The address, or NULL if the host name couldn't be resolved. */
+    CattaLookupResultFlags flags,  /**< Lookup flags */
+    void* userdata);
+
+/** Create an CattaSHostNameResolver object for resolving a host name to an adddress. See CattaSRecordBrowser for more info on the paramters. */
+CattaSHostNameResolver *catta_s_host_name_resolver_new(
+    CattaServer *server,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    const char *host_name,                  /**< The host name to look for */
+    CattaProtocol aprotocol,                /**< The address family of the desired address or CATTA_PROTO_UNSPEC if doesn't matter. */
+    CattaLookupFlags flags,                 /**< Lookup flags. */
+    CattaSHostNameResolverCallback calback,
+    void* userdata);
+
+/** Free a CattaSHostNameResolver object */
+void catta_s_host_name_resolver_free(CattaSHostNameResolver *r);
+
+/** Callback prototype for CattaSAddressResolver events */
+typedef void (*CattaSAddressResolverCallback)(
+    CattaSAddressResolver *r,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaResolverEvent event,
+    const CattaAddress *a,
+    const char *host_name,   /**< A host name for the specified address, if one was found, i.e. event == CATTA_RESOLVER_FOUND */
+    CattaLookupResultFlags flags,  /**< Lookup flags */
+    void* userdata);
+
+/** Create an CattaSAddressResolver object. See CattaSRecordBrowser for more info on the paramters. */
+CattaSAddressResolver *catta_s_address_resolver_new(
+    CattaServer *server,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    const CattaAddress *address,
+    CattaLookupFlags flags,                 /**< Lookup flags. */
+    CattaSAddressResolverCallback calback,
+    void* userdata);
+
+/** Free an CattaSAddressResolver object */
+void catta_s_address_resolver_free(CattaSAddressResolver *r);
+
+/** Callback prototype for CattaSDomainBrowser events */
+typedef void (*CattaSDomainBrowserCallback)(
+    CattaSDomainBrowser *b,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaBrowserEvent event,
+    const char *domain,
+    CattaLookupResultFlags flags,  /**< Lookup flags */
+    void* userdata);
+
+/** Create a new CattaSDomainBrowser object */
+CattaSDomainBrowser *catta_s_domain_browser_new(
+    CattaServer *server,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    const char *domain,
+    CattaDomainBrowserType type,
+    CattaLookupFlags flags,                 /**< Lookup flags. */
+    CattaSDomainBrowserCallback callback,
+    void* userdata);
+
+/** Free an CattaSDomainBrowser object */
+void catta_s_domain_browser_free(CattaSDomainBrowser *b);
+
+/** Callback prototype for CattaSServiceTypeBrowser events */
+typedef void (*CattaSServiceTypeBrowserCallback)(
+    CattaSServiceTypeBrowser *b,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaBrowserEvent event,
+    const char *type,
+    const char *domain,
+    CattaLookupResultFlags flags,  /**< Lookup flags */
+    void* userdata);
+
+/** Create a new CattaSServiceTypeBrowser object. */
+CattaSServiceTypeBrowser *catta_s_service_type_browser_new(
+    CattaServer *server,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    const char *domain,
+    CattaLookupFlags flags,                 /**< Lookup flags. */
+    CattaSServiceTypeBrowserCallback callback,
+    void* userdata);
+
+/** Free an CattaSServiceTypeBrowser object */
+void catta_s_service_type_browser_free(CattaSServiceTypeBrowser *b);
+
+/** Callback prototype for CattaSServiceBrowser events */
+typedef void (*CattaSServiceBrowserCallback)(
+    CattaSServiceBrowser *b,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaBrowserEvent event,
+    const char *name     /**< Service name, e.g. "Lennart's Files" */,
+    const char *type     /**< DNS-SD type, e.g. "_http._tcp" */,
+    const char *domain   /**< Domain of this service, e.g. "local" */,
+    CattaLookupResultFlags flags,  /**< Lookup flags */
+    void* userdata);
+
+/** Create a new CattaSServiceBrowser object. */
+CattaSServiceBrowser *catta_s_service_browser_new(
+    CattaServer *server,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    const char *service_type /** DNS-SD service type, e.g. "_http._tcp" */,
+    const char *domain,
+    CattaLookupFlags flags,                 /**< Lookup flags. */
+    CattaSServiceBrowserCallback callback,
+    void* userdata);
+
+/** Free an CattaSServiceBrowser object */
+void catta_s_service_browser_free(CattaSServiceBrowser *b);
+
+/** Callback prototype for CattaSServiceResolver events */
+typedef void (*CattaSServiceResolverCallback)(
+    CattaSServiceResolver *r,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaResolverEvent event,  /**< Is CATTA_RESOLVER_FOUND when the service was resolved successfully, and everytime it changes. Is CATTA_RESOLVER_TIMOUT when the service failed to resolve or disappeared. */
+    const char *name,       /**< Service name */
+    const char *type,       /**< Service Type */
+    const char *domain,
+    const char *host_name,  /**< Host name of the service */
+    const CattaAddress *a,   /**< The resolved host name */
+    uint16_t port,            /**< Service name */
+    CattaStringList *txt,    /**< TXT record data */
+    CattaLookupResultFlags flags,  /**< Lookup flags */
+    void* userdata);
+
+/** Create a new CattaSServiceResolver object. The specified callback function will be called with the resolved service data. */
+CattaSServiceResolver *catta_s_service_resolver_new(
+    CattaServer *server,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    const char *name,
+    const char *type,
+    const char *domain,
+    CattaProtocol aprotocol,    /**< Address family of the desired service address. Use CATTA_PROTO_UNSPEC if you don't care */
+    CattaLookupFlags flags,                 /**< Lookup flags. */
+    CattaSServiceResolverCallback calback,
+    void* userdata);
+
+/** Free an CattaSServiceResolver object */
+void catta_s_service_resolver_free(CattaSServiceResolver *r);
+
+CATTA_C_DECL_END
+
+#endif
diff --git a/include/catta/malloc.h b/include/catta/malloc.h
new file mode 100644 (file)
index 0000000..57f35ad
--- /dev/null
@@ -0,0 +1,96 @@
+#ifndef foomallochfoo
+#define foomallochfoo
+
+/***
+  This file is part of catta.
+
+  catta 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.
+
+  catta 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 catta; 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 <sys/types.h>
+#include <stdarg.h>
+#include <limits.h>
+#include <assert.h>
+
+#include <catta/cdecl.h>
+#include <catta/gccmacro.h>
+
+CATTA_C_DECL_BEGIN
+
+/** Allocate some memory, just like the libc malloc() */
+void *catta_malloc(size_t size) CATTA_GCC_ALLOC_SIZE(1);
+
+/** Similar to catta_malloc() but set the memory to zero */
+void *catta_malloc0(size_t size) CATTA_GCC_ALLOC_SIZE(1);
+
+/** Free some memory */
+void catta_free(void *p);
+
+/** Similar to libc's realloc() */
+void *catta_realloc(void *p, size_t size) CATTA_GCC_ALLOC_SIZE(2);
+
+/** Internal helper for catta_new() */
+static inline void* CATTA_GCC_ALLOC_SIZE2(1,2) catta_new_internal(unsigned n, size_t k) {
+    assert(n < INT_MAX/k);
+    return catta_malloc(n*k);
+}
+
+/** Allocate n new structures of the specified type. */
+#define catta_new(type, n) ((type*) catta_new_internal((n), sizeof(type)))
+
+/** Internal helper for catta_new0() */
+static inline void* CATTA_GCC_ALLOC_SIZE2(1,2) catta_new0_internal(unsigned n, size_t k) {
+    assert(n < INT_MAX/k);
+    return catta_malloc0(n*k);
+}
+
+/** Same as catta_new() but set the memory to zero */
+#define catta_new0(type, n) ((type*) catta_new0_internal((n), sizeof(type)))
+
+/** Just like libc's strdup() */
+char *catta_strdup(const char *s);
+
+/** Just like libc's strndup() */
+char *catta_strndup(const char *s, size_t l);
+
+/** Duplicate the given memory block into a new one allocated with catta_malloc() */
+void *catta_memdup(const void *s, size_t l) CATTA_GCC_ALLOC_SIZE(2);
+
+/** Wraps allocator functions */
+typedef struct CattaAllocator {
+    void* (*malloc)(size_t size) CATTA_GCC_ALLOC_SIZE(1);
+    void (*free)(void *p);
+    void* (*realloc)(void *p, size_t size) CATTA_GCC_ALLOC_SIZE(2);
+    void* (*calloc)(size_t nmemb, size_t size) CATTA_GCC_ALLOC_SIZE2(1,2);   /**< May be NULL */
+} CattaAllocator;
+
+/** Change the allocator. May be NULL to return to default (libc)
+ * allocators. The structure is not copied! */
+void catta_set_allocator(const CattaAllocator *a);
+
+/** Like sprintf() but store the result in a freshly allocated buffer. Free this with catta_free() */
+char *catta_strdup_printf(const char *fmt, ... ) CATTA_GCC_PRINTF_ATTR12;
+
+/** \cond fulldocs */
+/** Same as catta_strdup_printf() but take a va_list instead of varargs */
+char *catta_strdup_vprintf(const char *fmt, va_list ap);
+/** \endcond */
+
+CATTA_C_DECL_END
+
+#endif
diff --git a/include/catta/publish.h b/include/catta/publish.h
new file mode 100644 (file)
index 0000000..1176b1f
--- /dev/null
@@ -0,0 +1,175 @@
+#ifndef foopublishhfoo
+#define foopublishhfoo
+
+/***
+  This file is part of catta.
+
+  catta 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.
+
+  catta 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 catta; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+/** \file core/publish.h Functions for publising local services and RRs */
+
+/** \example core-publish-service.c Example how to register a DNS-SD
+ * service using an embedded mDNS stack. It behaves like a network
+ * printer registering both an IPP and a BSD LPR service. */
+
+/** A group of locally registered DNS RRs */
+typedef struct CattaSEntryGroup CattaSEntryGroup;
+
+#include <catta/cdecl.h>
+#include <catta/core.h>
+
+CATTA_C_DECL_BEGIN
+
+/** Prototype for callback functions which are called whenever the state of an CattaSEntryGroup object changes */
+typedef void (*CattaSEntryGroupCallback) (CattaServer *s, CattaSEntryGroup *g, CattaEntryGroupState state, void* userdata);
+
+/** Iterate through all local entries of the server. (when g is NULL)
+ * or of a specified entry group. At the first call state should point
+ * to a NULL initialized void pointer, That pointer is used to track
+ * the current iteration. It is not safe to call any other
+ * catta_server_xxx() function during the iteration. If the last entry
+ * has been read, NULL is returned. */
+const CattaRecord *catta_server_iterate(CattaServer *s, CattaSEntryGroup *g, void **state);
+
+/** Create a new entry group. The specified callback function is
+ * called whenever the state of the group changes. Use entry group
+ * objects to keep track of you RRs. Add new RRs to a group using
+ * catta_server_add_xxx(). Make sure to call catta_s_entry_group_commit()
+ * to start the registration process for your RRs */
+CattaSEntryGroup *catta_s_entry_group_new(CattaServer *s, CattaSEntryGroupCallback callback, void* userdata);
+
+/** Free an entry group. All RRs assigned to the group are removed from the server */
+void catta_s_entry_group_free(CattaSEntryGroup *g);
+
+/** Commit an entry group. This starts the probing and registration process for all RRs in the group */
+int catta_s_entry_group_commit(CattaSEntryGroup *g);
+
+/** Remove all entries from the entry group and reset the state to CATTA_ENTRY_GROUP_UNCOMMITED. */
+void catta_s_entry_group_reset(CattaSEntryGroup *g);
+
+/** Return 1 if the entry group is empty, i.e. has no records attached. */
+int catta_s_entry_group_is_empty(CattaSEntryGroup *g);
+
+/** Return the current state of the specified entry group */
+CattaEntryGroupState catta_s_entry_group_get_state(CattaSEntryGroup *g);
+
+/** Change the opaque user data pointer attached to an entry group object */
+void catta_s_entry_group_set_data(CattaSEntryGroup *g, void* userdata);
+
+/** Return the opaque user data pointer currently set for the entry group object */
+void* catta_s_entry_group_get_data(CattaSEntryGroup *g);
+
+/** Add a new resource record to the server. Returns 0 on success, negative otherwise. */
+int catta_server_add(
+    CattaServer *s,           /**< The server object to add this record to */
+    CattaSEntryGroup *g,       /**< An entry group object if this new record shall be attached to one, or NULL. If you plan to remove the record sometime later you a required to pass an entry group object here. */
+    CattaIfIndex interface,   /**< A numeric index of a network interface to attach this record to, or CATTA_IF_UNSPEC to attach this record to all interfaces */
+    CattaProtocol protocol,   /**< A protocol family to attach this record to. One of the CATTA_PROTO_xxx constants. Use CATTA_PROTO_UNSPEC to make this record available on all protocols (wich means on both IPv4 and IPv6). */
+    CattaPublishFlags flags,    /**< Special flags for this record */
+    CattaRecord *r            /**< The record to add. This function increases the reference counter of this object. */);
+
+/** Add an IP address mapping to the server. This will add both the
+ * host-name-to-address and the reverse mapping to the server. See
+ * catta_server_add() for more information. If adding one of the RRs
+ * fails, the function returns with an error, but it is not defined if
+ * the other RR is deleted from the server or not. Therefore, you have
+ * to free the CattaSEntryGroup and create a new one before
+ * proceeding. */
+int catta_server_add_address(
+    CattaServer *s,
+    CattaSEntryGroup *g,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaPublishFlags flags,
+    const char *name,
+    CattaAddress *a);
+
+/** Add an DNS-SD service to the Server. This will add all required
+ * RRs to the server. See catta_server_add() for more information.  If
+ * adding one of the RRs fails, the function returns with an error,
+ * but it is not defined if the other RR is deleted from the server or
+ * not. Therefore, you have to free the CattaSEntryGroup and create a
+ * new one before proceeding. */
+int catta_server_add_service(
+    CattaServer *s,
+    CattaSEntryGroup *g,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaPublishFlags flags,
+    const char *name,         /**< Service name, e.g. "Lennart's Files" */
+    const char *type,         /**< DNS-SD type, e.g. "_http._tcp" */
+    const char *domain,
+    const char *host,         /**< Host name where this servcie resides, or NULL if on the local host */
+    uint16_t port,              /**< Port number of the service */
+    ...  /**< Text records, terminated by NULL */) CATTA_GCC_SENTINEL;
+
+/** Mostly identical to catta_server_add_service(), but takes an CattaStringList object for the TXT records.  The CattaStringList object is copied. */
+int catta_server_add_service_strlst(
+    CattaServer *s,
+    CattaSEntryGroup *g,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaPublishFlags flags,
+    const char *name,
+    const char *type,
+    const char *domain,
+    const char *host,
+    uint16_t port,
+    CattaStringList *strlst);
+
+/** Add a subtype for an already existing service */
+int catta_server_add_service_subtype(
+    CattaServer *s,
+    CattaSEntryGroup *g,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaPublishFlags flags,
+    const char *name,         /**< Specify the name of main service you already added here */
+    const char *type,         /**< Specify the main type of the service you already added here */
+    const char *domain,       /**< Specify the main type of the service you already added here */
+    const char *subtype       /**< The new subtype for the specified service */ );
+
+/** Update the TXT record for a service with the data from the specified string list */
+int catta_server_update_service_txt_strlst(
+    CattaServer *s,
+    CattaSEntryGroup *g,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaPublishFlags flags,
+    const char *name,
+    const char *type,
+    const char *domain,
+    CattaStringList *strlst);
+
+/** Update the TXT record for a service with the NULL termonate list of strings */
+int catta_server_update_service_txt(
+    CattaServer *s,
+    CattaSEntryGroup *g,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaPublishFlags flags,
+    const char *name,
+    const char *type,
+    const char *domain,
+    ...) CATTA_GCC_SENTINEL;
+
+/** Check if there is a service locally defined and return the entry group it is attached to. Returns NULL if the service isn't local*/
+int catta_server_get_group_of_service(CattaServer *s, CattaIfIndex interface, CattaProtocol protocol, const char *name, const char *type, const char *domain, CattaSEntryGroup** ret_group);
+
+CATTA_C_DECL_END
+
+#endif
diff --git a/include/catta/rlist.h b/include/catta/rlist.h
new file mode 100644 (file)
index 0000000..9dd8b20
--- /dev/null
@@ -0,0 +1,49 @@
+#ifndef foorlistfoo
+#define foorlistfoo
+
+/***
+  This file is part of catta.
+
+  catta 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.
+
+  catta 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 catta; 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"
+
+CATTA_C_DECL_BEGIN
+
+/** A doubly linked list type */
+typedef struct CattaRList CattaRList;
+
+/** A doubly linked list type */
+struct CattaRList {
+    CATTA_LLIST_FIELDS(CattaRList, rlist);
+    void *data;
+};
+
+/** Prepend a new item to the beginning of the list and return the new beginning */
+CattaRList* catta_rlist_prepend(CattaRList *r, void *data);
+
+/** Remove the first occurence of the specified item from the list and return the new beginning */
+CattaRList* catta_rlist_remove(CattaRList *r, void *data);
+
+/** Remove the specified item from the list and return the new beginning */
+CattaRList* catta_rlist_remove_by_link(CattaRList *r, CattaRList *n);
+
+CATTA_C_DECL_END
+
+#endif
diff --git a/include/catta/rr.h b/include/catta/rr.h
new file mode 100644 (file)
index 0000000..b6014d2
--- /dev/null
@@ -0,0 +1,175 @@
+#ifndef foorrhfoo
+#define foorrhfoo
+
+/***
+  This file is part of catta.
+
+  catta 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.
+
+  catta 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 catta; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+/** \file rr.h Functions and definitions for manipulating DNS resource record (RR) data. */
+
+#include <inttypes.h>
+#include <sys/types.h>
+
+#include <catta/strlst.h>
+#include <catta/address.h>
+#include <catta/cdecl.h>
+
+CATTA_C_DECL_BEGIN
+
+/** DNS record types, see RFC 1035, in addition to those defined in defs.h */
+enum {
+    CATTA_DNS_TYPE_ANY = 0xFF,   /**< Special query type for requesting all records */
+    CATTA_DNS_TYPE_OPT = 41,     /**< EDNS0 option */
+    CATTA_DNS_TYPE_TKEY = 249,
+    CATTA_DNS_TYPE_TSIG = 250,
+    CATTA_DNS_TYPE_IXFR = 251,
+    CATTA_DNS_TYPE_AXFR = 252
+};
+
+/** DNS record classes, see RFC 1035, in addition to those defined in defs.h */
+enum {
+    CATTA_DNS_CLASS_ANY = 0xFF,         /**< Special query type for requesting all records */
+    CATTA_DNS_CACHE_FLUSH = 0x8000,     /**< Not really a class but a bit which may be set in response packets, see mDNS spec for more information */
+    CATTA_DNS_UNICAST_RESPONSE = 0x8000 /**< Not really a class but a bit which may be set in query packets, see mDNS spec for more information */
+};
+
+/** Encapsulates a DNS query key consisting of class, type and
+    name. Use catta_key_ref()/catta_key_unref() for manipulating the
+    reference counter. The structure is intended to be treated as "immutable", no
+    changes should be imposed after creation */
+typedef struct CattaKey {
+    int ref;           /**< Reference counter */
+    char *name;        /**< Record name */
+    uint16_t clazz;    /**< Record class, one of the CATTA_DNS_CLASS_xxx constants */
+    uint16_t type;     /**< Record type, one of the CATTA_DNS_TYPE_xxx constants */
+} CattaKey;
+
+/** Encapsulates a DNS resource record. The structure is intended to
+ * be treated as "immutable", no changes should be imposed after
+ * creation. */
+typedef struct CattaRecord {
+    int ref;         /**< Reference counter */
+    CattaKey *key;   /**< Reference to the query key of this record */
+
+    uint32_t ttl;     /**< DNS TTL of this record */
+
+    union {
+
+        struct {
+            void* data;
+            uint16_t size;
+        } generic; /**< Generic record data for unknown types */
+
+        struct {
+            uint16_t priority;
+            uint16_t weight;
+            uint16_t port;
+            char *name;
+        } srv; /**< Data for SRV records */
+
+        struct {
+            char *name;
+        } ptr, ns, cname; /**< Data for PTR, NS and CNAME records */
+
+        struct {
+            char *cpu;
+            char *os;
+        } hinfo; /**< Data for HINFO records */
+
+        struct {
+            CattaStringList *string_list;
+        } txt; /**< Data for TXT records */
+
+        struct {
+            CattaIPv4Address address;
+        } a; /**< Data for A records */
+
+        struct {
+            CattaIPv6Address address;
+        } aaaa; /**< Data for AAAA records */
+
+    } data; /**< Record data */
+
+} CattaRecord;
+
+/** Create a new CattaKey object. The reference counter will be set to 1. */
+CattaKey *catta_key_new(const char *name, uint16_t clazz, uint16_t type);
+
+/** Increase the reference counter of an CattaKey object by one */
+CattaKey *catta_key_ref(CattaKey *k);
+
+/** Decrease the reference counter of an CattaKey object by one */
+void catta_key_unref(CattaKey *k);
+
+/** Check whether two CattaKey object contain the same
+ * data. CATTA_DNS_CLASS_ANY/CATTA_DNS_TYPE_ANY are treated like any
+ * other class/type. */
+int catta_key_equal(const CattaKey *a, const CattaKey *b);
+
+/** Return a numeric hash value for a key for usage in hash tables. */
+unsigned catta_key_hash(const CattaKey *k);
+
+/** Create a new record object. Record data should be filled in right after creation. The reference counter is set to 1. */
+CattaRecord *catta_record_new(CattaKey *k, uint32_t ttl);
+
+/** Create a new record object. Record data should be filled in right after creation. The reference counter is set to 1. */
+CattaRecord *catta_record_new_full(const char *name, uint16_t clazz, uint16_t type, uint32_t ttl);
+
+/** Increase the reference counter of an CattaRecord by one. */
+CattaRecord *catta_record_ref(CattaRecord *r);
+
+/** Decrease the reference counter of an CattaRecord by one. */
+void catta_record_unref(CattaRecord *r);
+
+/** Return a textual representation of the specified DNS class. The
+ * returned pointer points to a read only internal string. */
+const char *catta_dns_class_to_string(uint16_t clazz);
+
+/** Return a textual representation of the specified DNS class. The
+ * returned pointer points to a read only internal string. */
+const char *catta_dns_type_to_string(uint16_t type);
+
+/** Create a textual representation of the specified key. catta_free() the
+ * result! */
+char *catta_key_to_string(const CattaKey *k);
+
+/** Create a textual representation of the specified record, similar
+ * in style to BIND zone file data. catta_free() the result! */
+char *catta_record_to_string(const CattaRecord *r);
+
+/** Check whether two records are equal (regardless of the TTL */
+int catta_record_equal_no_ttl(const CattaRecord *a, const CattaRecord *b);
+
+/** Check whether the specified key is valid */
+int catta_key_is_valid(CattaKey *k);
+
+/** Check whether the specified record is valid */
+int catta_record_is_valid(CattaRecord *r);
+
+/** Parse a binary rdata object and fill it into *record. This function is actually implemented in dns.c */
+int catta_rdata_parse(CattaRecord *record, const void* rdata, size_t size);
+
+/** Serialize an CattaRecord object into binary rdata. This function is actually implemented in dns.c */
+size_t catta_rdata_serialize(CattaRecord *record, void *rdata, size_t max_size);
+
+/** Return TRUE if the CattaRecord object is a link-local A or AAAA address */
+int catta_record_is_link_local_address(const CattaRecord *r);
+
+CATTA_C_DECL_END
+
+#endif
diff --git a/include/catta/simple-watch.h b/include/catta/simple-watch.h
new file mode 100644 (file)
index 0000000..ce91d1f
--- /dev/null
@@ -0,0 +1,85 @@
+#ifndef foosimplewatchhfoo
+#define foosimplewatchhfoo
+
+/***
+  This file is part of catta.
+
+  catta 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.
+
+  catta 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 catta; 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 <sys/poll.h>
+#include <catta/cdecl.h>
+#include <catta/watch.h>
+
+CATTA_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 CattaSimplePoll CattaSimplePoll;
+
+/** Create a new main loop object */
+CattaSimplePoll *catta_simple_poll_new(void);
+
+/** Free a main loop object */
+void catta_simple_poll_free(CattaSimplePoll *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 CattaPoll* catta_simple_poll_get(CattaSimplePoll *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 catta_simple_poll_iterate(CattaSimplePoll *s, int sleep_time);
+
+/** Request that the main loop quits. If this is called the next
+ call to catta_simple_poll_iterate() will return 1 */
+void catta_simple_poll_quit(CattaSimplePoll *s);
+
+/** Prototype for a poll() type function */
+typedef int (*CattaPollFunc)(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 catta_simple_poll_set_func(CattaSimplePoll *s, CattaPollFunc func, void *userdata);
+
+/** The first stage of catta_simple_poll_iterate(), use this function only if you know what you do */
+int catta_simple_poll_prepare(CattaSimplePoll *s, int timeout);
+
+/** The second stage of catta_simple_poll_iterate(), use this function only if you know what you do */
+int catta_simple_poll_run(CattaSimplePoll *s);
+
+/** The third and final stage of catta_simple_poll_iterate(), use this function only if you know what you do */
+int catta_simple_poll_dispatch(CattaSimplePoll *s);
+
+/** Call catta_simple_poll_iterate() in a loop and return if it returns non-zero */
+int catta_simple_poll_loop(CattaSimplePoll *s);
+
+/** Wakeup the main loop. (for threaded environments) */
+void catta_simple_poll_wakeup(CattaSimplePoll *s);
+
+CATTA_C_DECL_END
+
+#endif
diff --git a/include/catta/strlst.h b/include/catta/strlst.h
new file mode 100644 (file)
index 0000000..6001bb5
--- /dev/null
@@ -0,0 +1,180 @@
+#ifndef footxtlisthfoo
+#define footxtlisthfoo
+
+/***
+  This file is part of catta.
+
+  catta 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.
+
+  catta 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 catta; 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 <sys/types.h>
+#include <inttypes.h>
+#include <stdarg.h>
+
+#include <catta/cdecl.h>
+#include <catta/gccmacro.h>
+
+CATTA_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 CattaStringList. 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 CattaStringList {
+    struct CattaStringList *next; /**< Pointer to the next linked list element */
+    size_t size;  /**< Size of text[] */
+    uint8_t text[1]; /**< Character data */
+} CattaStringList;
+
+/** @{ \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. */
+CattaStringList *catta_string_list_new(const char *txt, ...) CATTA_GCC_SENTINEL;
+
+/** \cond fulldocs */
+/** Same as catta_string_list_new() but pass a va_list structure */
+CattaStringList *catta_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*/
+CattaStringList *catta_string_list_new_from_array(const char **array, int length);
+
+/** Free a string list */
+void catta_string_list_free(CattaStringList *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. */
+CattaStringList *catta_string_list_add(CattaStringList *l, const char *text);
+
+/** Append a new NUL terminated formatted string to the specified string list */
+CattaStringList *catta_string_list_add_printf(CattaStringList *l, const char *format, ...) CATTA_GCC_PRINTF_ATTR23;
+
+/** \cond fulldocs */
+/** Append a new NUL terminated formatted string to the specified string list */
+CattaStringList *catta_string_list_add_vprintf(CattaStringList *l, const char *format, va_list va);
+/** \endcond */
+
+/** Append an arbitrary length byte string to the list. Returns the
+ * new list start. */
+CattaStringList *catta_string_list_add_arbitrary(CattaStringList *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. */
+CattaStringList*catta_string_list_add_anonymous(CattaStringList *l, size_t size);
+
+/** Same as catta_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. */
+CattaStringList *catta_string_list_add_many(CattaStringList *r, ...) CATTA_GCC_SENTINEL;
+
+/** \cond fulldocs */
+/** Same as catta_string_list_add_many(), but use a va_list
+ * structure. Returns the new list start. */
+CattaStringList *catta_string_list_add_many_va(CattaStringList *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 "". catta_free() the result! This
+ * function doesn't work well with strings that contain NUL bytes. */
+char* catta_string_list_to_string(CattaStringList *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 catta_string_list_serialize(CattaStringList *l, void * data, size_t size);
+
+/** Inverse of catta_string_list_serialize() */
+int catta_string_list_parse(const void *data, size_t size, CattaStringList **ret);
+/** \endcond */
+
+/** Compare to string lists */
+int catta_string_list_equal(const CattaStringList *a, const CattaStringList *b);
+
+/** Copy a string list */
+CattaStringList *catta_string_list_copy(const CattaStringList *l);
+
+/** Reverse the string list. */
+CattaStringList* catta_string_list_reverse(CattaStringList *l);
+
+/** Return the number of elements in the string list */
+unsigned catta_string_list_length(const CattaStringList *l);
+
+/** @} */
+
+/** @{ \name Accessing items */
+
+/** Returns the next item in the string list */
+CattaStringList *catta_string_list_get_next(CattaStringList *l);
+
+/** Returns the text for the current item */
+uint8_t *catta_string_list_get_text(CattaStringList *l);
+
+/** Returns the size of the current text */
+size_t catta_string_list_get_size(CattaStringList *l);
+
+/** @} */
+
+/** @{ \name DNS-SD TXT pair handling */
+
+/** Find the string list entry for the given DNS-SD TXT key */
+CattaStringList *catta_string_list_find(CattaStringList *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
+ * catta_free() the strings returned in *key and *value. */
+int catta_string_list_get_pair(CattaStringList *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 */
+CattaStringList *catta_string_list_add_pair(CattaStringList *l, const char *key, const char *value);
+
+/** Same as catta_string_list_add_pair() but allow strings containing NUL bytes in *value. */
+CattaStringList *catta_string_list_add_pair_arbitrary(CattaStringList *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 CATTA_SERVICE_COOKIE_INVALID if none is found. */
+uint32_t catta_string_list_get_service_cookie(CattaStringList *l);
+/** \endcond */
+
+CATTA_C_DECL_END
+
+#endif
+
diff --git a/include/catta/thread-watch.h b/include/catta/thread-watch.h
new file mode 100644 (file)
index 0000000..3ecb1e4
--- /dev/null
@@ -0,0 +1,80 @@
+#ifndef foothreadedwatchhfoo
+#define foothreadedwatchhfoo
+
+/***
+  This file is part of catta.
+
+  catta 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.
+
+  catta 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 catta; 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 <sys/poll.h>
+#include <catta/cdecl.h>
+#include <catta/watch.h>
+
+CATTA_C_DECL_BEGIN
+
+/** A main loop object that runs an CattaSimplePoll in its own thread. \since 0.6.4 */
+typedef struct CattaThreadedPoll CattaThreadedPoll;
+
+/** Create a new event loop object. This will allocate the internal
+ * CattaSimplePoll, but will not start the helper thread. \since 0.6.4 */
+CattaThreadedPoll *catta_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 catta_threaded_poll_free(CattaThreadedPoll *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 CattaPoll* catta_threaded_poll_get(CattaThreadedPoll *p);
+
+/** Start the event loop helper thread. After the thread has started
+ * you must make sure to access the event loop object
+ * (CattaThreadedPoll, CattaPoll and all its associated objects)
+ * synchronized, i.e. with proper locking. You may want to use
+ * catta_threaded_poll_lock()/catta_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. catta_threaded_poll_lock() calls are not
+ * required from event callbacks. \since 0.6.4 */
+int catta_threaded_poll_start(CattaThreadedPoll *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 catta_threaded_poll_stop(CattaThreadedPoll *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 catta_threaded_poll_quit(CattaThreadedPoll *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 catta_threaded_poll_lock(CattaThreadedPoll *p);
+
+/** Unlock the event loop object, use this as counterpart to
+ * catta_threaded_poll_lock() \since 0.6.4 */
+void catta_threaded_poll_unlock(CattaThreadedPoll *p);
+
+CATTA_C_DECL_END
+
+#endif
diff --git a/include/catta/timeval.h b/include/catta/timeval.h
new file mode 100644 (file)
index 0000000..0323f92
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef footimevalhfoo
+#define footimevalhfoo
+
+/***
+  This file is part of catta.
+
+  catta 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.
+
+  catta 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 catta; 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 <inttypes.h>
+#include <sys/time.h>
+
+#include <catta/cdecl.h>
+
+CATTA_C_DECL_BEGIN
+
+/** A numeric data type for storing microsecond values. (signed 64bit integer) */
+typedef int64_t CattaUsec;
+
+/** Compare two timeval structures and return a negative value when a < b, 0 when a == b and a positive value otherwise */
+int catta_timeval_compare(const struct timeval *a, const struct timeval *b);
+
+/** Calculate the difference between two timeval structures as microsecond value */
+CattaUsec catta_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* catta_timeval_add(struct timeval *a, CattaUsec usec);
+
+/** Return the difference between the current time and *a. Positive if *a was earlier */
+CattaUsec catta_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 *catta_elapse_time(struct timeval *tv, unsigned ms, unsigned j);
+
+CATTA_C_DECL_END
+
+#endif
diff --git a/include/catta/watch.h b/include/catta/watch.h
new file mode 100644 (file)
index 0000000..ef50797
--- /dev/null
@@ -0,0 +1,97 @@
+#ifndef foowatchhfoo
+#define foowatchhfoo
+
+/***
+  This file is part of catta.
+
+  catta 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.
+
+  catta 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 catta; 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 <sys/poll.h>
+#include <sys/time.h>
+
+#include <catta/cdecl.h>
+
+CATTA_C_DECL_BEGIN
+
+/** An I/O watch object */
+typedef struct CattaWatch CattaWatch;
+
+/** A timeout watch object */
+typedef struct CattaTimeout CattaTimeout;
+
+/** An event polling abstraction object */
+typedef struct CattaPoll CattaPoll;
+
+/** Type of watch events */
+typedef enum {
+    CATTA_WATCH_IN = POLLIN,      /**< Input event */
+    CATTA_WATCH_OUT = POLLOUT,    /**< Output event */
+    CATTA_WATCH_ERR = POLLERR,    /**< Error event */
+    CATTA_WATCH_HUP = POLLHUP     /**< Hangup event */
+} CattaWatchEvent;
+
+/** Called whenever an I/O event happens  on an I/O watch */
+typedef void (*CattaWatchCallback)(CattaWatch *w, int fd, CattaWatchEvent event, void *userdata);
+
+/** Called when the timeout is reached */
+typedef void (*CattaTimeoutCallback)(CattaTimeout *t, void *userdata);
+
+/** Defines an abstracted event polling API. This may be used to
+ connect Catta 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 CattaPoll {
+
+    /** 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. */
+    CattaWatch* (*watch_new)(const CattaPoll *api, int fd, CattaWatchEvent event, CattaWatchCallback callback, void *userdata);
+
+    /** Update the events to wait for. It is safe to call this function from an CattaWatchCallback */
+    void (*watch_update)(CattaWatch *w, CattaWatchEvent event);
+
+    /** Return the events that happened. It is safe to call this function from an CattaWatchCallback  */
+    CattaWatchEvent (*watch_get_events)(CattaWatch *w);
+
+    /** Free a watch. It is safe to call this function from an CattaWatchCallback */
+    void (*watch_free)(CattaWatch *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()  */
+    CattaTimeout* (*timeout_new)(const CattaPoll *api, const struct timeval *tv, CattaTimeoutCallback 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 CattaTimeoutCallback */
+    void (*timeout_update)(CattaTimeout *, const struct timeval *tv);
+
+    /** Free a timeout. It is safe to call this function from an CattaTimeoutCallback */
+    void (*timeout_free)(CattaTimeout *t);
+};
+
+CATTA_C_DECL_END
+
+#endif
+
index 3aaef0505bc71accfa6220fb38a57c25ebba3cd6..e853e4bfaa2b2e82c27fbba5ca4c29528a6a018f 100644 (file)
@@ -1,17 +1,17 @@
-# This file is part of avahi.
+# This file is part of catta.
 #
-# avahi is free software; you can redistribute it and/or modify it
+# catta 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
+# catta 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
+# License along with catta; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 # USA.
 
index 023abda1e03827602c2fbdd58c8d1c7419eb16be..236f9517a5ae32f7ed84ee1c4a9681246818382f 100644 (file)
@@ -1,17 +1,17 @@
-# This file is part of avahi.
+# This file is part of catta.
 #
-# avahi is free software; you can redistribute it and/or modify it
+# catta 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
+# catta 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
+# License along with catta; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 # USA.
 
@@ -20,9 +20,9 @@ AM_CFLAGS=-I$(top_srcdir)/include
 # This cool debug trap works on i386/gcc only
 AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")'
 
-lib_LTLIBRARIES = libavahi.la
+lib_LTLIBRARIES = libcatta.la
 
-libavahi_la_SOURCES = \
+libcatta_la_SOURCES = \
        malloc.c \
        address.c \
        alternative.c \
@@ -67,19 +67,19 @@ libavahi_la_SOURCES = \
        dns-srv-rr.h
 
 if HAVE_NETLINK
-libavahi_la_SOURCES += \
+libcatta_la_SOURCES += \
        iface-linux.c iface-linux.h \
        netlink.c netlink.h
 else
 if HAVE_PF_ROUTE
-libavahi_la_SOURCES += \
+libcatta_la_SOURCES += \
        iface-pfroute.c iface-pfroute.h
 else
-libavahi_la_SOURCES += \
+libcatta_la_SOURCES += \
        iface-none.c
 endif
 endif
 
-libavahi_la_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS)
-libavahi_la_LIBADD = $(AM_LDADD) $(PTHREAD_CFLAGS) $(PTHREAD_LIBS) $(INTLLIBS)
-libavahi_la_LDFLAGS = $(AM_LDFLAGS)  -version-info $(LIBAVAHI_VERSION_INFO)
+libcatta_la_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS)
+libcatta_la_LIBADD = $(AM_LDADD) $(PTHREAD_CFLAGS) $(PTHREAD_LIBS) $(INTLLIBS)
+libcatta_la_LDFLAGS = $(AM_LDFLAGS)  -version-info $(LIBCATTA_VERSION_INFO)
index 979b1b774d901af22abad6a0fa8b0ae8efc3ab89..003f18223cb64cedc5ddbfed663808664b649a6c 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 #include "addr-util.h"
 
-AvahiAddress *avahi_address_from_sockaddr(const struct sockaddr* sa, AvahiAddress *ret_addr) {
+CattaAddress *catta_address_from_sockaddr(const struct sockaddr* sa, CattaAddress *ret_addr) {
     assert(sa);
     assert(ret_addr);
 
     assert(sa->sa_family == AF_INET || sa->sa_family == AF_INET6);
 
-    ret_addr->proto = avahi_af_to_proto(sa->sa_family);
+    ret_addr->proto = catta_af_to_proto(sa->sa_family);
 
     if (sa->sa_family == AF_INET)
         memcpy(&ret_addr->data.ipv4, &((const struct sockaddr_in*) sa)->sin_addr, sizeof(ret_addr->data.ipv4));
@@ -46,7 +46,7 @@ AvahiAddress *avahi_address_from_sockaddr(const struct sockaddr* sa, AvahiAddres
     return ret_addr;
 }
 
-uint16_t avahi_port_from_sockaddr(const struct sockaddr* sa) {
+uint16_t catta_port_from_sockaddr(const struct sockaddr* sa) {
     assert(sa);
 
     assert(sa->sa_family == AF_INET || sa->sa_family == AF_INET6);
@@ -57,7 +57,7 @@ uint16_t avahi_port_from_sockaddr(const struct sockaddr* sa) {
         return ntohs(((const struct sockaddr_in6*) sa)->sin6_port);
 }
 
-int avahi_address_is_ipv4_in_ipv6(const AvahiAddress *a) {
+int catta_address_is_ipv4_in_ipv6(const CattaAddress *a) {
 
     static const uint8_t ipv4_in_ipv6[] = {
         0x00, 0x00, 0x00, 0x00,
@@ -67,7 +67,7 @@ int avahi_address_is_ipv4_in_ipv6(const AvahiAddress *a) {
 
     assert(a);
 
-    if (a->proto != AVAHI_PROTO_INET6)
+    if (a->proto != CATTA_PROTO_INET6)
         return 0;
 
     return memcmp(a->data.ipv6.address, ipv4_in_ipv6, sizeof(ipv4_in_ipv6)) == 0;
@@ -78,14 +78,14 @@ int avahi_address_is_ipv4_in_ipv6(const AvahiAddress *a) {
 #define IPV6LL_NETWORK 0xFE80
 #define IPV6LL_NETMASK 0xFFC0
 
-int avahi_address_is_link_local(const AvahiAddress *a) {
+int catta_address_is_link_local(const CattaAddress *a) {
     assert(a);
 
-    if (a->proto == AVAHI_PROTO_INET) {
+    if (a->proto == CATTA_PROTO_INET) {
         uint32_t n = ntohl(a->data.ipv4.address);
         return (n & IPV4LL_NETMASK) == IPV4LL_NETWORK;
     }
-    else if (a->proto == AVAHI_PROTO_INET6) {
+    else if (a->proto == CATTA_PROTO_INET6) {
         unsigned n = (a->data.ipv6.address[0] << 8) | (a->data.ipv6.address[1] << 0);
         return (n & IPV6LL_NETMASK) == IPV6LL_NETWORK;
     }
index 313772bf7ef7f6980222aab9a9a501af6e1ac09b..4b4e958867f7b13daa949cfac05e5acab9ae0e15 100644 (file)
@@ -2,20 +2,20 @@
 #define fooaddrutilhfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <inttypes.h>
 #include <sys/socket.h>
 
-#include <avahi/cdecl.h>
-#include <avahi/address.h>
+#include <catta/cdecl.h>
+#include <catta/address.h>
 
-AVAHI_C_DECL_BEGIN
+CATTA_C_DECL_BEGIN
 
 /** Make an address structture of a sockaddr structure */
-AvahiAddress *avahi_address_from_sockaddr(const struct sockaddr* sa, AvahiAddress *ret_addr);
+CattaAddress *catta_address_from_sockaddr(const struct sockaddr* sa, CattaAddress *ret_addr);
 
 /** Return the port number of a sockaddr structure (either IPv4 or IPv6) */
-uint16_t avahi_port_from_sockaddr(const struct sockaddr* sa);
+uint16_t catta_port_from_sockaddr(const struct sockaddr* sa);
 
 /** Check whether the specified IPv6 address is in fact an
  * encapsulated IPv4 address, returns 1 if yes, 0 otherwise */
-int avahi_address_is_ipv4_in_ipv6(const AvahiAddress *a);
+int catta_address_is_ipv4_in_ipv6(const CattaAddress *a);
 
 /** Check whether the specified address is a link-local IPv4 or IPv6 address;
  * returns 1 if yes, 0 otherwise */
-int avahi_address_is_link_local(const AvahiAddress *a);
+int catta_address_is_link_local(const CattaAddress *a);
 
-AVAHI_C_DECL_END
+CATTA_C_DECL_END
 
 #endif
index 94716848cb7f8976134893ffea0cb0634655b389..c207fdc28445d2542d66af3546b2019524060c2d 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <assert.h>
 #include <stdio.h>
 
-#include <avahi/address.h>
-#include <avahi/malloc.h>
+#include <catta/address.h>
+#include <catta/malloc.h>
 
-static size_t address_get_size(const AvahiAddress *a) {
+static size_t address_get_size(const CattaAddress *a) {
     assert(a);
 
-    if (a->proto == AVAHI_PROTO_INET)
+    if (a->proto == CATTA_PROTO_INET)
         return 4;
-    else if (a->proto == AVAHI_PROTO_INET6)
+    else if (a->proto == CATTA_PROTO_INET6)
         return 16;
 
     return 0;
 }
 
-int avahi_address_cmp(const AvahiAddress *a, const AvahiAddress *b) {
+int catta_address_cmp(const CattaAddress *a, const CattaAddress *b) {
     assert(a);
     assert(b);
 
@@ -53,30 +53,30 @@ int avahi_address_cmp(const AvahiAddress *a, const AvahiAddress *b) {
     return memcmp(a->data.data, b->data.data, address_get_size(a));
 }
 
-char *avahi_address_snprint(char *s, size_t length, const AvahiAddress *a) {
+char *catta_address_snprint(char *s, size_t length, const CattaAddress *a) {
     assert(s);
     assert(length);
     assert(a);
 
-    if (!(inet_ntop(avahi_proto_to_af(a->proto), a->data.data, s, length)))
+    if (!(inet_ntop(catta_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) {
+char* catta_reverse_lookup_name(const CattaAddress *a, char *ret_s, size_t length) {
     assert(ret_s);
     assert(length > 0);
     assert(a);
 
-    if (a->proto == AVAHI_PROTO_INET) {
+    if (a->proto == CATTA_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);
+        assert(a->proto == CATTA_PROTO_INET6);
 
         snprintf(
             ret_s, length,
@@ -102,20 +102,20 @@ char* avahi_reverse_lookup_name(const AvahiAddress *a, char *ret_s, size_t lengt
     return ret_s;
 }
 
-AvahiAddress *avahi_address_parse(const char *s, AvahiProtocol proto, AvahiAddress *ret_addr) {
+CattaAddress *catta_address_parse(const char *s, CattaProtocol proto, CattaAddress *ret_addr) {
     assert(ret_addr);
     assert(s);
 
-    if (proto == AVAHI_PROTO_UNSPEC) {
+    if (proto == CATTA_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;
+                ret_addr->proto = CATTA_PROTO_INET6;
         } else
-            ret_addr->proto = AVAHI_PROTO_INET;
+            ret_addr->proto = CATTA_PROTO_INET;
     } else {
-        if (inet_pton(avahi_proto_to_af(proto), s, ret_addr->data.data) <= 0)
+        if (inet_pton(catta_proto_to_af(proto), s, ret_addr->data.data) <= 0)
             return NULL;
 
         ret_addr->proto = proto;
@@ -124,32 +124,32 @@ AvahiAddress *avahi_address_parse(const char *s, AvahiProtocol proto, AvahiAddre
     return ret_addr;
 }
 
-int avahi_proto_to_af(AvahiProtocol proto) {
-    if (proto == AVAHI_PROTO_INET)
+int catta_proto_to_af(CattaProtocol proto) {
+    if (proto == CATTA_PROTO_INET)
         return AF_INET;
-    if (proto == AVAHI_PROTO_INET6)
+    if (proto == CATTA_PROTO_INET6)
         return AF_INET6;
 
-    assert(proto == AVAHI_PROTO_UNSPEC);
+    assert(proto == CATTA_PROTO_UNSPEC);
     return AF_UNSPEC;
 }
 
-AvahiProtocol avahi_af_to_proto(int af) {
+CattaProtocol catta_af_to_proto(int af) {
     if (af == AF_INET)
-        return AVAHI_PROTO_INET;
+        return CATTA_PROTO_INET;
     if (af == AF_INET6)
-        return AVAHI_PROTO_INET6;
+        return CATTA_PROTO_INET6;
 
     assert(af == AF_UNSPEC);
-    return AVAHI_PROTO_UNSPEC;
+    return CATTA_PROTO_UNSPEC;
 }
 
-const char* avahi_proto_to_string(AvahiProtocol proto) {
-    if (proto == AVAHI_PROTO_INET)
+const char* catta_proto_to_string(CattaProtocol proto) {
+    if (proto == CATTA_PROTO_INET)
         return "IPv4";
-    if (proto == AVAHI_PROTO_INET6)
+    if (proto == CATTA_PROTO_INET6)
         return "IPv6";
 
-    assert(proto == AVAHI_PROTO_UNSPEC);
+    assert(proto == CATTA_PROTO_UNSPEC);
     return "UNSPEC";
 }
index 85a2b60be51a529c3d5e7eef89a73aca6dd8a010..d77fb8425ee142dee874907bb461fbdf9b9316b1 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
@@ -26,9 +26,9 @@
 #include <ctype.h>
 #include <assert.h>
 
-#include <avahi/alternative.h>
-#include <avahi/malloc.h>
-#include <avahi/domain.h>
+#include <catta/alternative.h>
+#include <catta/malloc.h>
+#include <catta/domain.h>
 #include "utf8.h"
 
 static void drop_incomplete_utf8(char *c) {
@@ -38,7 +38,7 @@ static void drop_incomplete_utf8(char *c) {
 
     while (e >= c) {
 
-        if (avahi_utf8_valid(c))
+        if (catta_utf8_valid(c))
             break;
 
         assert(*e & 128);
@@ -48,13 +48,13 @@ static void drop_incomplete_utf8(char *c) {
     }
 }
 
-char *avahi_alternative_host_name(const char *s) {
+char *catta_alternative_host_name(const char *s) {
     const char *e;
     char *r;
 
     assert(s);
 
-    if (!avahi_is_valid_host_name(s))
+    if (!catta_is_valid_host_name(s))
         return NULL;
 
     if ((e = strrchr(s, '-'))) {
@@ -78,49 +78,49 @@ char *avahi_alternative_host_name(const char *s) {
         int n;
 
         n = atoi(e)+1;
-        if (!(m = avahi_strdup_printf("%i", n)))
+        if (!(m = catta_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 (l >= CATTA_LABEL_MAX-1-strlen(m)-1)
+            l = CATTA_LABEL_MAX-1-strlen(m)-1;
 
-        if (!(c = avahi_strndup(s, l))) {
-            avahi_free(m);
+        if (!(c = catta_strndup(s, l))) {
+            catta_free(m);
             return NULL;
         }
 
         drop_incomplete_utf8(c);
 
-        r = avahi_strdup_printf("%s-%s", c, m);
-        avahi_free(c);
-        avahi_free(m);
+        r = catta_strdup_printf("%s-%s", c, m);
+        catta_free(c);
+        catta_free(m);
 
     } else {
         char *c;
 
-        if (!(c = avahi_strndup(s, AVAHI_LABEL_MAX-1-2)))
+        if (!(c = catta_strndup(s, CATTA_LABEL_MAX-1-2)))
             return NULL;
 
         drop_incomplete_utf8(c);
 
-        r = avahi_strdup_printf("%s-2", c);
-        avahi_free(c);
+        r = catta_strdup_printf("%s-2", c);
+        catta_free(c);
     }
 
-    assert(avahi_is_valid_host_name(r));
+    assert(catta_is_valid_host_name(r));
 
     return r;
 }
 
-char *avahi_alternative_service_name(const char *s) {
+char *catta_alternative_service_name(const char *s) {
     const char *e;
     char *r;
 
     assert(s);
 
-    if (!avahi_is_valid_service_name(s))
+    if (!catta_is_valid_service_name(s))
         return NULL;
 
     if ((e = strstr(s, " #"))) {
@@ -146,37 +146,37 @@ char *avahi_alternative_service_name(const char *s) {
         int n;
 
         n = atoi(e)+1;
-        if (!(m = avahi_strdup_printf("%i", n)))
+        if (!(m = catta_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 (l >= CATTA_LABEL_MAX-1-strlen(m)-2)
+            l = CATTA_LABEL_MAX-1-strlen(m)-2;
 
-        if (!(c = avahi_strndup(s, l))) {
-            avahi_free(m);
+        if (!(c = catta_strndup(s, l))) {
+            catta_free(m);
             return NULL;
         }
 
         drop_incomplete_utf8(c);
 
-        r = avahi_strdup_printf("%s #%s", c, m);
-        avahi_free(c);
-        avahi_free(m);
+        r = catta_strdup_printf("%s #%s", c, m);
+        catta_free(c);
+        catta_free(m);
     } else {
         char *c;
 
-        if (!(c = avahi_strndup(s, AVAHI_LABEL_MAX-1-3)))
+        if (!(c = catta_strndup(s, CATTA_LABEL_MAX-1-3)))
             return NULL;
 
         drop_incomplete_utf8(c);
 
-        r = avahi_strdup_printf("%s #2", c);
-        avahi_free(c);
+        r = catta_strdup_printf("%s #2", c);
+        catta_free(c);
     }
 
-    assert(avahi_is_valid_service_name(r));
+    assert(catta_is_valid_service_name(r));
 
     return r;
 }
index 48d2abefdbd26b09b40353874608122bb59618b6..06e96e7c9413e74e191c621958b8167ab6ff02d8 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 #include <stdlib.h>
 
-#include <avahi/timeval.h>
-#include <avahi/malloc.h>
+#include <catta/timeval.h>
+#include <catta/malloc.h>
 
 #include "announce.h"
-#include <avahi/log.h>
+#include <catta/log.h>
 #include "rr-util.h"
 
-#define AVAHI_ANNOUNCEMENT_JITTER_MSEC 250
-#define AVAHI_PROBE_JITTER_MSEC 250
-#define AVAHI_PROBE_INTERVAL_MSEC 250
+#define CATTA_ANNOUNCEMENT_JITTER_MSEC 250
+#define CATTA_PROBE_JITTER_MSEC 250
+#define CATTA_PROBE_INTERVAL_MSEC 250
 
-static void remove_announcer(AvahiServer *s, AvahiAnnouncer *a) {
+static void remove_announcer(CattaServer *s, CattaAnnouncer *a) {
     assert(s);
     assert(a);
 
     if (a->time_event)
-        avahi_time_event_free(a->time_event);
+        catta_time_event_free(a->time_event);
 
-    AVAHI_LLIST_REMOVE(AvahiAnnouncer, by_interface, a->interface->announcers, a);
-    AVAHI_LLIST_REMOVE(AvahiAnnouncer, by_entry, a->entry->announcers, a);
+    CATTA_LLIST_REMOVE(CattaAnnouncer, by_interface, a->interface->announcers, a);
+    CATTA_LLIST_REMOVE(CattaAnnouncer, by_entry, a->entry->announcers, a);
 
-    avahi_free(a);
+    catta_free(a);
 }
 
-static void elapse_announce(AvahiTimeEvent *e, void *userdata);
+static void elapse_announce(CattaTimeEvent *e, void *userdata);
 
-static void set_timeout(AvahiAnnouncer *a, const struct timeval *tv) {
+static void set_timeout(CattaAnnouncer *a, const struct timeval *tv) {
     assert(a);
 
     if (!tv) {
         if (a->time_event) {
-            avahi_time_event_free(a->time_event);
+            catta_time_event_free(a->time_event);
             a->time_event = NULL;
         }
     } else {
 
         if (a->time_event)
-            avahi_time_event_update(a->time_event, tv);
+            catta_time_event_update(a->time_event, tv);
         else
-            a->time_event = avahi_time_event_new(a->server->time_event_queue, tv, elapse_announce, a);
+            a->time_event = catta_time_event_new(a->server->time_event_queue, tv, elapse_announce, a);
     }
 }
 
-static void next_state(AvahiAnnouncer *a);
+static void next_state(CattaAnnouncer *a);
 
-void avahi_s_entry_group_check_probed(AvahiSEntryGroup *g, int immediately) {
-    AvahiEntry *e;
+void catta_s_entry_group_check_probed(CattaSEntryGroup *g, int immediately) {
+    CattaEntry *e;
     assert(g);
     assert(!g->dead);
 
     /* Check whether all group members have been probed */
 
-    if (g->state != AVAHI_ENTRY_GROUP_REGISTERING || g->n_probing > 0)
+    if (g->state != CATTA_ENTRY_GROUP_REGISTERING || g->n_probing > 0)
         return;
 
-    avahi_s_entry_group_change_state(g, AVAHI_ENTRY_GROUP_ESTABLISHED);
+    catta_s_entry_group_change_state(g, CATTA_ENTRY_GROUP_ESTABLISHED);
 
     if (g->dead)
         return;
 
     for (e = g->entries; e; e = e->by_group_next) {
-        AvahiAnnouncer *a;
+        CattaAnnouncer *a;
 
         for (a = e->announcers; a; a = a->by_entry_next) {
 
-            if (a->state != AVAHI_WAITING)
+            if (a->state != CATTA_WAITING)
                 continue;
 
-            a->state = AVAHI_ANNOUNCING;
+            a->state = CATTA_ANNOUNCING;
 
             if (immediately) {
                 /* Shortcut */
@@ -101,23 +101,23 @@ void avahi_s_entry_group_check_probed(AvahiSEntryGroup *g, int immediately) {
             } else {
                 struct timeval tv;
                 a->n_iteration = 0;
-                avahi_elapse_time(&tv, 0, AVAHI_ANNOUNCEMENT_JITTER_MSEC);
+                catta_elapse_time(&tv, 0, CATTA_ANNOUNCEMENT_JITTER_MSEC);
                 set_timeout(a, &tv);
             }
         }
     }
 }
 
-static void next_state(AvahiAnnouncer *a) {
+static void next_state(CattaAnnouncer *a) {
     assert(a);
 
-    if (a->state == AVAHI_WAITING) {
+    if (a->state == CATTA_WAITING) {
 
         assert(a->entry->group);
 
-        avahi_s_entry_group_check_probed(a->entry->group, 1);
+        catta_s_entry_group_check_probed(a->entry->group, 1);
 
-    } else if (a->state == AVAHI_PROBING) {
+    } else if (a->state == CATTA_PROBING) {
 
         if (a->n_iteration >= 4) {
             /* Probing done */
@@ -127,10 +127,10 @@ static void next_state(AvahiAnnouncer *a) {
                 a->entry->group->n_probing--;
             }
 
-            if (a->entry->group && a->entry->group->state == AVAHI_ENTRY_GROUP_REGISTERING)
-                a->state = AVAHI_WAITING;
+            if (a->entry->group && a->entry->group->state == CATTA_ENTRY_GROUP_REGISTERING)
+                a->state = CATTA_WAITING;
             else {
-                a->state = AVAHI_ANNOUNCING;
+                a->state = CATTA_ANNOUNCING;
                 a->n_iteration = 1;
             }
 
@@ -139,33 +139,33 @@ static void next_state(AvahiAnnouncer *a) {
         } else {
             struct timeval tv;
 
-            avahi_interface_post_probe(a->interface, a->entry->record, 0);
+            catta_interface_post_probe(a->interface, a->entry->record, 0);
 
-            avahi_elapse_time(&tv, AVAHI_PROBE_INTERVAL_MSEC, 0);
+            catta_elapse_time(&tv, CATTA_PROBE_INTERVAL_MSEC, 0);
             set_timeout(a, &tv);
 
             a->n_iteration++;
         }
 
-    } else if (a->state == AVAHI_ANNOUNCING) {
+    } else if (a->state == CATTA_ANNOUNCING) {
 
-        if (a->entry->flags & AVAHI_PUBLISH_UNIQUE)
+        if (a->entry->flags & CATTA_PUBLISH_UNIQUE)
             /* Send the whole rrset at once */
-            avahi_server_prepare_matching_responses(a->server, a->interface, a->entry->record->key, 0);
+            catta_server_prepare_matching_responses(a->server, a->interface, a->entry->record->key, 0);
         else
-            avahi_server_prepare_response(a->server, a->interface, a->entry, 0, 0);
+            catta_server_prepare_response(a->server, a->interface, a->entry, 0, 0);
 
-        avahi_server_generate_response(a->server, a->interface, NULL, NULL, 0, 0, 0);
+        catta_server_generate_response(a->server, a->interface, NULL, NULL, 0, 0, 0);
 
         if (++a->n_iteration >= 4) {
             /* Announcing done */
 
-            a->state = AVAHI_ESTABLISHED;
+            a->state = CATTA_ESTABLISHED;
 
             set_timeout(a, NULL);
         } else {
             struct timeval tv;
-            avahi_elapse_time(&tv, a->sec_delay*1000, AVAHI_ANNOUNCEMENT_JITTER_MSEC);
+            catta_elapse_time(&tv, a->sec_delay*1000, CATTA_ANNOUNCEMENT_JITTER_MSEC);
 
             if (a->n_iteration < 10)
                 a->sec_delay *= 2;
@@ -175,14 +175,14 @@ static void next_state(AvahiAnnouncer *a) {
     }
 }
 
-static void elapse_announce(AvahiTimeEvent *e, void *userdata) {
+static void elapse_announce(CattaTimeEvent *e, void *userdata) {
     assert(e);
 
     next_state(userdata);
 }
 
-static AvahiAnnouncer *get_announcer(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) {
-    AvahiAnnouncer *a;
+static CattaAnnouncer *get_announcer(CattaServer *s, CattaEntry *e, CattaInterface *i) {
+    CattaAnnouncer *a;
 
     assert(s);
     assert(e);
@@ -195,56 +195,56 @@ static AvahiAnnouncer *get_announcer(AvahiServer *s, AvahiEntry *e, AvahiInterfa
     return NULL;
 }
 
-static void go_to_initial_state(AvahiAnnouncer *a) {
-    AvahiEntry *e;
+static void go_to_initial_state(CattaAnnouncer *a) {
+    CattaEntry *e;
     struct timeval tv;
 
     assert(a);
     e = a->entry;
 
-    if ((e->flags & AVAHI_PUBLISH_UNIQUE) && !(e->flags & AVAHI_PUBLISH_NO_PROBE))
-        a->state = AVAHI_PROBING;
-    else if (!(e->flags & AVAHI_PUBLISH_NO_ANNOUNCE)) {
+    if ((e->flags & CATTA_PUBLISH_UNIQUE) && !(e->flags & CATTA_PUBLISH_NO_PROBE))
+        a->state = CATTA_PROBING;
+    else if (!(e->flags & CATTA_PUBLISH_NO_ANNOUNCE)) {
 
-        if (!e->group || e->group->state == AVAHI_ENTRY_GROUP_ESTABLISHED)
-            a->state = AVAHI_ANNOUNCING;
+        if (!e->group || e->group->state == CATTA_ENTRY_GROUP_ESTABLISHED)
+            a->state = CATTA_ANNOUNCING;
         else
-            a->state = AVAHI_WAITING;
+            a->state = CATTA_WAITING;
 
     } else
-        a->state = AVAHI_ESTABLISHED;
+        a->state = CATTA_ESTABLISHED;
 
     a->n_iteration = 1;
     a->sec_delay = 1;
 
-    if (a->state == AVAHI_PROBING && e->group)
+    if (a->state == CATTA_PROBING && e->group)
         e->group->n_probing++;
 
-    if (a->state == AVAHI_PROBING)
-        set_timeout(a, avahi_elapse_time(&tv, 0, AVAHI_PROBE_JITTER_MSEC));
-    else if (a->state == AVAHI_ANNOUNCING)
-        set_timeout(a, avahi_elapse_time(&tv, 0, AVAHI_ANNOUNCEMENT_JITTER_MSEC));
+    if (a->state == CATTA_PROBING)
+        set_timeout(a, catta_elapse_time(&tv, 0, CATTA_PROBE_JITTER_MSEC));
+    else if (a->state == CATTA_ANNOUNCING)
+        set_timeout(a, catta_elapse_time(&tv, 0, CATTA_ANNOUNCEMENT_JITTER_MSEC));
     else
         set_timeout(a, NULL);
 }
 
-static void new_announcer(AvahiServer *s, AvahiInterface *i, AvahiEntry *e) {
-    AvahiAnnouncer *a;
+static void new_announcer(CattaServer *s, CattaInterface *i, CattaEntry *e) {
+    CattaAnnouncer *a;
 
     assert(s);
     assert(i);
     assert(e);
     assert(!e->dead);
 
-    if (!avahi_interface_match(i, e->interface, e->protocol) || !i->announcing || !avahi_entry_is_commited(e))
+    if (!catta_interface_match(i, e->interface, e->protocol) || !i->announcing || !catta_entry_is_commited(e))
         return;
 
     /* We don't want duplicate announcers */
     if (get_announcer(s, e, i))
         return;
 
-    if ((!(a = avahi_new(AvahiAnnouncer, 1)))) {
-        avahi_log_error(__FILE__": Out of memory.");
+    if ((!(a = catta_new(CattaAnnouncer, 1)))) {
+        catta_log_error(__FILE__": Out of memory.");
         return;
     }
 
@@ -253,14 +253,14 @@ static void new_announcer(AvahiServer *s, AvahiInterface *i, AvahiEntry *e) {
     a->entry = e;
     a->time_event = NULL;
 
-    AVAHI_LLIST_PREPEND(AvahiAnnouncer, by_interface, i->announcers, a);
-    AVAHI_LLIST_PREPEND(AvahiAnnouncer, by_entry, e->announcers, a);
+    CATTA_LLIST_PREPEND(CattaAnnouncer, by_interface, i->announcers, a);
+    CATTA_LLIST_PREPEND(CattaAnnouncer, by_entry, e->announcers, a);
 
     go_to_initial_state(a);
 }
 
-void avahi_announce_interface(AvahiServer *s, AvahiInterface *i) {
-    AvahiEntry *e;
+void catta_announce_interface(CattaServer *s, CattaInterface *i) {
+    CattaEntry *e;
 
     assert(s);
     assert(i);
@@ -273,8 +273,8 @@ void avahi_announce_interface(AvahiServer *s, AvahiInterface *i) {
             new_announcer(s, i, e);
 }
 
-static void announce_walk_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata) {
-    AvahiEntry *e = userdata;
+static void announce_walk_callback(CattaInterfaceMonitor *m, CattaInterface *i, void* userdata) {
+    CattaEntry *e = userdata;
 
     assert(m);
     assert(i);
@@ -284,27 +284,27 @@ static void announce_walk_callback(AvahiInterfaceMonitor *m, AvahiInterface *i,
     new_announcer(m->server, i, e);
 }
 
-void avahi_announce_entry(AvahiServer *s, AvahiEntry *e) {
+void catta_announce_entry(CattaServer *s, CattaEntry *e) {
     assert(s);
     assert(e);
     assert(!e->dead);
 
-    avahi_interface_monitor_walk(s->monitor, e->interface, e->protocol, announce_walk_callback, e);
+    catta_interface_monitor_walk(s->monitor, e->interface, e->protocol, announce_walk_callback, e);
 }
 
-void avahi_announce_group(AvahiServer *s, AvahiSEntryGroup *g) {
-    AvahiEntry *e;
+void catta_announce_group(CattaServer *s, CattaSEntryGroup *g) {
+    CattaEntry *e;
 
     assert(s);
     assert(g);
 
     for (e = g->entries; e; e = e->by_group_next)
         if (!e->dead)
-            avahi_announce_entry(s, e);
+            catta_announce_entry(s, e);
 }
 
-int avahi_entry_is_registered(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) {
-    AvahiAnnouncer *a;
+int catta_entry_is_registered(CattaServer *s, CattaEntry *e, CattaInterface *i) {
+    CattaAnnouncer *a;
 
     assert(s);
     assert(e);
@@ -315,13 +315,13 @@ int avahi_entry_is_registered(AvahiServer *s, AvahiEntry *e, AvahiInterface *i)
         return 0;
 
     return
-        a->state == AVAHI_ANNOUNCING ||
-        a->state == AVAHI_ESTABLISHED ||
-        (a->state == AVAHI_WAITING && !(e->flags & AVAHI_PUBLISH_UNIQUE));
+        a->state == CATTA_ANNOUNCING ||
+        a->state == CATTA_ESTABLISHED ||
+        (a->state == CATTA_WAITING && !(e->flags & CATTA_PUBLISH_UNIQUE));
 }
 
-int avahi_entry_is_probing(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) {
-    AvahiAnnouncer *a;
+int catta_entry_is_probing(CattaServer *s, CattaEntry *e, CattaInterface *i) {
+    CattaAnnouncer *a;
 
     assert(s);
     assert(e);
@@ -332,12 +332,12 @@ int avahi_entry_is_probing(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) {
         return 0;
 
     return
-        a->state == AVAHI_PROBING ||
-        (a->state == AVAHI_WAITING && (e->flags & AVAHI_PUBLISH_UNIQUE));
+        a->state == CATTA_PROBING ||
+        (a->state == CATTA_WAITING && (e->flags & CATTA_PUBLISH_UNIQUE));
 }
 
-void avahi_entry_return_to_initial_state(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) {
-    AvahiAnnouncer *a;
+void catta_entry_return_to_initial_state(CattaServer *s, CattaEntry *e, CattaInterface *i) {
+    CattaAnnouncer *a;
 
     assert(s);
     assert(e);
@@ -346,18 +346,18 @@ void avahi_entry_return_to_initial_state(AvahiServer *s, AvahiEntry *e, AvahiInt
     if (!(a = get_announcer(s, e, i)))
         return;
 
-    if (a->state == AVAHI_PROBING && a->entry->group)
+    if (a->state == CATTA_PROBING && a->entry->group)
         a->entry->group->n_probing--;
 
     go_to_initial_state(a);
 }
 
-static AvahiRecord *make_goodbye_record(AvahiRecord *r) {
-    AvahiRecord *g;
+static CattaRecord *make_goodbye_record(CattaRecord *r) {
+    CattaRecord *g;
 
     assert(r);
 
-    if (!(g = avahi_record_copy(r)))
+    if (!(g = catta_record_copy(r)))
         return NULL; /* OOM */
 
     assert(g->ref == 1);
@@ -366,18 +366,18 @@ static AvahiRecord *make_goodbye_record(AvahiRecord *r) {
     return g;
 }
 
-static int is_duplicate_entry(AvahiServer *s, AvahiEntry *e) {
-    AvahiEntry *i;
+static int is_duplicate_entry(CattaServer *s, CattaEntry *e) {
+    CattaEntry *i;
 
     assert(s);
     assert(e);
 
-    for (i = avahi_hashmap_lookup(s->entries_by_key, e->record->key); i; i = i->by_key_next) {
+    for (i = catta_hashmap_lookup(s->entries_by_key, e->record->key); i; i = i->by_key_next) {
 
         if ((i == e) || (i->dead))
             continue;
 
-        if (!avahi_record_equal_no_ttl(i->record, e->record))
+        if (!catta_record_equal_no_ttl(i->record, e->record))
             continue;
 
         return 1;
@@ -386,22 +386,22 @@ static int is_duplicate_entry(AvahiServer *s, AvahiEntry *e) {
     return 0;
 }
 
-static void send_goodbye_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata) {
-    AvahiEntry *e = userdata;
-    AvahiRecord *g;
+static void send_goodbye_callback(CattaInterfaceMonitor *m, CattaInterface *i, void* userdata) {
+    CattaEntry *e = userdata;
+    CattaRecord *g;
 
     assert(m);
     assert(i);
     assert(e);
     assert(!e->dead);
 
-    if (!avahi_interface_match(i, e->interface, e->protocol))
+    if (!catta_interface_match(i, e->interface, e->protocol))
         return;
 
-    if (e->flags & AVAHI_PUBLISH_NO_ANNOUNCE)
+    if (e->flags & CATTA_PUBLISH_NO_ANNOUNCE)
         return;
 
-    if (!avahi_entry_is_registered(m->server, e, i))
+    if (!catta_entry_is_registered(m->server, e, i))
         return;
 
     if (is_duplicate_entry(m->server, e))
@@ -410,66 +410,66 @@ static void send_goodbye_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, v
     if (!(g = make_goodbye_record(e->record)))
         return; /* OOM */
 
-    avahi_interface_post_response(i, g, e->flags & AVAHI_PUBLISH_UNIQUE, NULL, 1);
-    avahi_record_unref(g);
+    catta_interface_post_response(i, g, e->flags & CATTA_PUBLISH_UNIQUE, NULL, 1);
+    catta_record_unref(g);
 }
 
-static void reannounce(AvahiAnnouncer *a) {
-    AvahiEntry *e;
+static void reannounce(CattaAnnouncer *a) {
+    CattaEntry *e;
     struct timeval tv;
 
     assert(a);
     e = a->entry;
 
     /* If the group this entry belongs to is not even commited, there's nothing to reannounce */
-    if (e->group && (e->group->state == AVAHI_ENTRY_GROUP_UNCOMMITED || e->group->state == AVAHI_ENTRY_GROUP_COLLISION))
+    if (e->group && (e->group->state == CATTA_ENTRY_GROUP_UNCOMMITED || e->group->state == CATTA_ENTRY_GROUP_COLLISION))
         return;
 
     /* Because we might change state we decrease the probing counter first */
-    if (a->state == AVAHI_PROBING && a->entry->group)
+    if (a->state == CATTA_PROBING && a->entry->group)
         a->entry->group->n_probing--;
 
-    if (a->state == AVAHI_PROBING ||
-        (a->state == AVAHI_WAITING && (e->flags & AVAHI_PUBLISH_UNIQUE) && !(e->flags & AVAHI_PUBLISH_NO_PROBE)))
+    if (a->state == CATTA_PROBING ||
+        (a->state == CATTA_WAITING && (e->flags & CATTA_PUBLISH_UNIQUE) && !(e->flags & CATTA_PUBLISH_NO_PROBE)))
 
         /* We were probing or waiting after probe, so we restart probing from the beginning here */
 
-        a->state = AVAHI_PROBING;
-    else if (a->state == AVAHI_WAITING)
+        a->state = CATTA_PROBING;
+    else if (a->state == CATTA_WAITING)
 
         /* We were waiting, but were not probing before, so we continue waiting  */
-        a->state = AVAHI_WAITING;
+        a->state = CATTA_WAITING;
 
-    else if (e->flags & AVAHI_PUBLISH_NO_ANNOUNCE)
+    else if (e->flags & CATTA_PUBLISH_NO_ANNOUNCE)
 
         /* No announcer needed */
-        a->state = AVAHI_ESTABLISHED;
+        a->state = CATTA_ESTABLISHED;
 
     else {
 
         /* Ok, let's restart announcing */
-        a->state = AVAHI_ANNOUNCING;
+        a->state = CATTA_ANNOUNCING;
     }
 
     /* Now let's increase the probing counter again */
-    if (a->state == AVAHI_PROBING && e->group)
+    if (a->state == CATTA_PROBING && e->group)
         e->group->n_probing++;
 
     a->n_iteration = 1;
     a->sec_delay = 1;
 
-    if (a->state == AVAHI_PROBING)
-        set_timeout(a, avahi_elapse_time(&tv, 0, AVAHI_PROBE_JITTER_MSEC));
-    else if (a->state == AVAHI_ANNOUNCING)
-        set_timeout(a, avahi_elapse_time(&tv, 0, AVAHI_ANNOUNCEMENT_JITTER_MSEC));
+    if (a->state == CATTA_PROBING)
+        set_timeout(a, catta_elapse_time(&tv, 0, CATTA_PROBE_JITTER_MSEC));
+    else if (a->state == CATTA_ANNOUNCING)
+        set_timeout(a, catta_elapse_time(&tv, 0, CATTA_ANNOUNCEMENT_JITTER_MSEC));
     else
         set_timeout(a, NULL);
 }
 
 
-static void reannounce_walk_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata) {
-    AvahiEntry *e = userdata;
-    AvahiAnnouncer *a;
+static void reannounce_walk_callback(CattaInterfaceMonitor *m, CattaInterface *i, void* userdata) {
+    CattaEntry *e = userdata;
+    CattaAnnouncer *a;
 
     assert(m);
     assert(i);
@@ -482,22 +482,22 @@ static void reannounce_walk_callback(AvahiInterfaceMonitor *m, AvahiInterface *i
     reannounce(a);
 }
 
-void avahi_reannounce_entry(AvahiServer *s, AvahiEntry *e) {
+void catta_reannounce_entry(CattaServer *s, CattaEntry *e) {
 
     assert(s);
     assert(e);
     assert(!e->dead);
 
-    avahi_interface_monitor_walk(s->monitor, e->interface, e->protocol, reannounce_walk_callback, e);
+    catta_interface_monitor_walk(s->monitor, e->interface, e->protocol, reannounce_walk_callback, e);
 }
 
-void avahi_goodbye_interface(AvahiServer *s, AvahiInterface *i, int send_goodbye, int remove) {
+void catta_goodbye_interface(CattaServer *s, CattaInterface *i, int send_goodbye, int remove) {
     assert(s);
     assert(i);
 
     if (send_goodbye)
         if (i->announcing) {
-            AvahiEntry *e;
+            CattaEntry *e;
 
             for (e = s->entries; e; e = e->entries_next)
                 if (!e->dead)
@@ -509,13 +509,13 @@ void avahi_goodbye_interface(AvahiServer *s, AvahiInterface *i, int send_goodbye
             remove_announcer(s, i->announcers);
 }
 
-void avahi_goodbye_entry(AvahiServer *s, AvahiEntry *e, int send_goodbye, int remove) {
+void catta_goodbye_entry(CattaServer *s, CattaEntry *e, int send_goodbye, int remove) {
     assert(s);
     assert(e);
 
     if (send_goodbye)
         if (!e->dead)
-            avahi_interface_monitor_walk(s->monitor, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, send_goodbye_callback, e);
+            catta_interface_monitor_walk(s->monitor, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, send_goodbye_callback, e);
 
     if (remove)
         while (e->announcers)
index 19014fbccf7c9b5fa90f757a7a616f9379b21621..e8e62dc87f0b6a2eabf50b2e3913eaf058c0e2ae 100644 (file)
@@ -2,68 +2,68 @@
 #define fooannouncehfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
-typedef struct AvahiAnnouncer AvahiAnnouncer;
+typedef struct CattaAnnouncer CattaAnnouncer;
 
-#include <avahi/llist.h>
-#include <avahi/publish.h>
+#include <catta/llist.h>
+#include <catta/publish.h>
 #include "iface.h"
 #include "internal.h"
 #include "timeeventq.h"
 
 typedef enum {
-    AVAHI_PROBING,         /* probing phase */
-    AVAHI_WAITING,         /* wait for other records in group */
-    AVAHI_ANNOUNCING,      /* announcing phase */
-    AVAHI_ESTABLISHED      /* we'e established */
-} AvahiAnnouncerState;
+    CATTA_PROBING,         /* probing phase */
+    CATTA_WAITING,         /* wait for other records in group */
+    CATTA_ANNOUNCING,      /* announcing phase */
+    CATTA_ESTABLISHED      /* we'e established */
+} CattaAnnouncerState;
 
-struct AvahiAnnouncer {
-    AvahiServer *server;
-    AvahiInterface *interface;
-    AvahiEntry *entry;
+struct CattaAnnouncer {
+    CattaServer *server;
+    CattaInterface *interface;
+    CattaEntry *entry;
 
-    AvahiTimeEvent *time_event;
+    CattaTimeEvent *time_event;
 
-    AvahiAnnouncerState state;
+    CattaAnnouncerState state;
     unsigned n_iteration;
     unsigned sec_delay;
 
-    AVAHI_LLIST_FIELDS(AvahiAnnouncer, by_interface);
-    AVAHI_LLIST_FIELDS(AvahiAnnouncer, by_entry);
+    CATTA_LLIST_FIELDS(CattaAnnouncer, by_interface);
+    CATTA_LLIST_FIELDS(CattaAnnouncer, by_entry);
 };
 
-void avahi_announce_interface(AvahiServer *s, AvahiInterface *i);
-void avahi_announce_entry(AvahiServer *s, AvahiEntry *e);
-void avahi_announce_group(AvahiServer *s, AvahiSEntryGroup *g);
+void catta_announce_interface(CattaServer *s, CattaInterface *i);
+void catta_announce_entry(CattaServer *s, CattaEntry *e);
+void catta_announce_group(CattaServer *s, CattaSEntryGroup *g);
 
-void avahi_entry_return_to_initial_state(AvahiServer *s, AvahiEntry *e, AvahiInterface *i);
+void catta_entry_return_to_initial_state(CattaServer *s, CattaEntry *e, CattaInterface *i);
 
-void avahi_s_entry_group_check_probed(AvahiSEntryGroup *g, int immediately);
+void catta_s_entry_group_check_probed(CattaSEntryGroup *g, int immediately);
 
-int avahi_entry_is_registered(AvahiServer *s, AvahiEntry *e, AvahiInterface *i);
-int avahi_entry_is_probing(AvahiServer *s, AvahiEntry *e, AvahiInterface *i);
+int catta_entry_is_registered(CattaServer *s, CattaEntry *e, CattaInterface *i);
+int catta_entry_is_probing(CattaServer *s, CattaEntry *e, CattaInterface *i);
 
-void avahi_goodbye_interface(AvahiServer *s, AvahiInterface *i, int send_goodbye, int rem);
-void avahi_goodbye_entry(AvahiServer *s, AvahiEntry *e, int send_goodbye, int rem);
+void catta_goodbye_interface(CattaServer *s, CattaInterface *i, int send_goodbye, int rem);
+void catta_goodbye_entry(CattaServer *s, CattaEntry *e, int send_goodbye, int rem);
 
-void avahi_reannounce_entry(AvahiServer *s, AvahiEntry *e);
+void catta_reannounce_entry(CattaServer *s, CattaEntry *e);
 
 #endif
index a937d18dbf2069678f996a0a7fec00faca7311a8..640ec517d6e4b1a6a93227686a1ea0e4b611101d 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 #include <string.h>
 
-#include <avahi/domain.h>
-#include <avahi/malloc.h>
-#include <avahi/error.h>
+#include <catta/domain.h>
+#include <catta/malloc.h>
+#include <catta/error.h>
 
 #include "browse.h"
-#include <avahi/log.h>
-#include <avahi/rr.h>
+#include <catta/log.h>
+#include <catta/rr.h>
 
-typedef struct AvahiDNSServerInfo AvahiDNSServerInfo;
+typedef struct CattaDNSServerInfo CattaDNSServerInfo;
 
-struct AvahiDNSServerInfo {
-    AvahiSDNSServerBrowser *browser;
+struct CattaDNSServerInfo {
+    CattaSDNSServerBrowser *browser;
 
-    AvahiIfIndex interface;
-    AvahiProtocol protocol;
-    AvahiRecord *srv_record;
-    AvahiSHostNameResolver *host_name_resolver;
-    AvahiAddress address;
-    AvahiLookupResultFlags flags;
+    CattaIfIndex interface;
+    CattaProtocol protocol;
+    CattaRecord *srv_record;
+    CattaSHostNameResolver *host_name_resolver;
+    CattaAddress address;
+    CattaLookupResultFlags flags;
 
-    AVAHI_LLIST_FIELDS(AvahiDNSServerInfo, info);
+    CATTA_LLIST_FIELDS(CattaDNSServerInfo, info);
 };
 
-struct AvahiSDNSServerBrowser {
-    AvahiServer *server;
+struct CattaSDNSServerBrowser {
+    CattaServer *server;
 
-    AvahiSRecordBrowser *record_browser;
-    AvahiSDNSServerBrowserCallback callback;
+    CattaSRecordBrowser *record_browser;
+    CattaSDNSServerBrowserCallback callback;
     void* userdata;
-    AvahiProtocol aprotocol;
-    AvahiLookupFlags user_flags;
+    CattaProtocol aprotocol;
+    CattaLookupFlags user_flags;
 
     unsigned n_info;
 
-    AVAHI_LLIST_FIELDS(AvahiSDNSServerBrowser, browser);
-    AVAHI_LLIST_HEAD(AvahiDNSServerInfo, info);
+    CATTA_LLIST_FIELDS(CattaSDNSServerBrowser, browser);
+    CATTA_LLIST_HEAD(CattaDNSServerInfo, info);
 };
 
-static AvahiDNSServerInfo* get_server_info(AvahiSDNSServerBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiRecord *r) {
-    AvahiDNSServerInfo *i;
+static CattaDNSServerInfo* get_server_info(CattaSDNSServerBrowser *b, CattaIfIndex interface, CattaProtocol protocol, CattaRecord *r) {
+    CattaDNSServerInfo *i;
 
     assert(b);
     assert(r);
@@ -70,53 +70,53 @@ static AvahiDNSServerInfo* get_server_info(AvahiSDNSServerBrowser *b, AvahiIfInd
     for (i = b->info; i; i = i->info_next)
         if (i->interface == interface &&
             i->protocol == protocol &&
-            avahi_record_equal_no_ttl(r, i->srv_record))
+            catta_record_equal_no_ttl(r, i->srv_record))
             return i;
 
     return NULL;
 }
 
-static void server_info_free(AvahiSDNSServerBrowser *b, AvahiDNSServerInfo *i) {
+static void server_info_free(CattaSDNSServerBrowser *b, CattaDNSServerInfo *i) {
     assert(b);
     assert(i);
 
-    avahi_record_unref(i->srv_record);
+    catta_record_unref(i->srv_record);
     if (i->host_name_resolver)
-        avahi_s_host_name_resolver_free(i->host_name_resolver);
+        catta_s_host_name_resolver_free(i->host_name_resolver);
 
-    AVAHI_LLIST_REMOVE(AvahiDNSServerInfo, info, b->info, i);
+    CATTA_LLIST_REMOVE(CattaDNSServerInfo, info, b->info, i);
 
     assert(b->n_info >= 1);
     b->n_info--;
 
-    avahi_free(i);
+    catta_free(i);
 }
 
 static void host_name_resolver_callback(
-    AvahiSHostNameResolver *r,
-    AVAHI_GCC_UNUSED AvahiIfIndex interface,
-    AVAHI_GCC_UNUSED AvahiProtocol protocol,
-    AvahiResolverEvent event,
+    CattaSHostNameResolver *r,
+    CATTA_GCC_UNUSED CattaIfIndex interface,
+    CATTA_GCC_UNUSED CattaProtocol protocol,
+    CattaResolverEvent event,
     const char *host_name,
-    const AvahiAddress *a,
-    AvahiLookupResultFlags flags,
+    const CattaAddress *a,
+    CattaLookupResultFlags flags,
     void* userdata) {
 
-    AvahiDNSServerInfo *i = userdata;
+    CattaDNSServerInfo *i = userdata;
 
     assert(r);
     assert(host_name);
     assert(i);
 
     switch (event) {
-        case AVAHI_RESOLVER_FOUND: {
+        case CATTA_RESOLVER_FOUND: {
             i->address = *a;
 
             i->browser->callback(
                 i->browser,
                 i->interface,
                 i->protocol,
-                AVAHI_BROWSER_NEW,
+                CATTA_BROWSER_NEW,
                 i->srv_record->data.srv.name,
                 &i->address,
                 i->srv_record->data.srv.port,
@@ -126,38 +126,38 @@ static void host_name_resolver_callback(
             break;
         }
 
-        case AVAHI_RESOLVER_FAILURE:
+        case CATTA_RESOLVER_FAILURE:
             /* Ignore */
             break;
     }
 
-    avahi_s_host_name_resolver_free(i->host_name_resolver);
+    catta_s_host_name_resolver_free(i->host_name_resolver);
     i->host_name_resolver = NULL;
 }
 
 static void record_browser_callback(
-    AvahiSRecordBrowser*rr,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiBrowserEvent event,
-    AvahiRecord *record,
-    AvahiLookupResultFlags flags,
+    CattaSRecordBrowser*rr,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaBrowserEvent event,
+    CattaRecord *record,
+    CattaLookupResultFlags flags,
     void* userdata) {
 
-    AvahiSDNSServerBrowser *b = userdata;
+    CattaSDNSServerBrowser *b = userdata;
 
     assert(rr);
     assert(b);
 
     /* Filter flags */
-    flags &= AVAHI_LOOKUP_RESULT_CACHED | AVAHI_LOOKUP_RESULT_MULTICAST | AVAHI_LOOKUP_RESULT_WIDE_AREA;
+    flags &= CATTA_LOOKUP_RESULT_CACHED | CATTA_LOOKUP_RESULT_MULTICAST | CATTA_LOOKUP_RESULT_WIDE_AREA;
 
     switch (event) {
-        case AVAHI_BROWSER_NEW: {
-            AvahiDNSServerInfo *i;
+        case CATTA_BROWSER_NEW: {
+            CattaDNSServerInfo *i;
 
             assert(record);
-            assert(record->key->type == AVAHI_DNS_TYPE_SRV);
+            assert(record->key->type == CATTA_DNS_TYPE_SRV);
 
             if (get_server_info(b, interface, protocol, record))
                 return;
@@ -165,14 +165,14 @@ static void record_browser_callback(
             if (b->n_info >= 10)
                 return;
 
-            if (!(i = avahi_new(AvahiDNSServerInfo, 1)))
+            if (!(i = catta_new(CattaDNSServerInfo, 1)))
                 return; /* OOM */
 
             i->browser = b;
             i->interface = interface;
             i->protocol = protocol;
-            i->srv_record = avahi_record_ref(record);
-            i->host_name_resolver = avahi_s_host_name_resolver_new(
+            i->srv_record = catta_record_ref(record);
+            i->host_name_resolver = catta_s_host_name_resolver_new(
                 b->server,
                 interface, protocol,
                 record->data.srv.name,
@@ -181,17 +181,17 @@ static void record_browser_callback(
                 host_name_resolver_callback, i);
             i->flags = flags;
 
-            AVAHI_LLIST_PREPEND(AvahiDNSServerInfo, info, b->info, i);
+            CATTA_LLIST_PREPEND(CattaDNSServerInfo, info, b->info, i);
 
             b->n_info++;
             break;
         }
 
-        case AVAHI_BROWSER_REMOVE: {
-            AvahiDNSServerInfo *i;
+        case CATTA_BROWSER_REMOVE: {
+            CattaDNSServerInfo *i;
 
             assert(record);
-            assert(record->key->type == AVAHI_DNS_TYPE_SRV);
+            assert(record->key->type == CATTA_DNS_TYPE_SRV);
 
             if (!(i = get_server_info(b, interface, protocol, record)))
                 return;
@@ -212,9 +212,9 @@ static void record_browser_callback(
             break;
         }
 
-        case AVAHI_BROWSER_FAILURE:
-        case AVAHI_BROWSER_ALL_FOR_NOW:
-        case AVAHI_BROWSER_CACHE_EXHAUSTED:
+        case CATTA_BROWSER_FAILURE:
+        case CATTA_BROWSER_ALL_FOR_NOW:
+        case CATTA_BROWSER_CACHE_EXHAUSTED:
 
             b->callback(
                 b,
@@ -231,47 +231,47 @@ static void record_browser_callback(
     }
 }
 
-AvahiSDNSServerBrowser *avahi_s_dns_server_browser_new(
-    AvahiServer *server,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
+CattaSDNSServerBrowser *catta_s_dns_server_browser_new(
+    CattaServer *server,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
     const char *domain,
-    AvahiDNSServerType type,
-    AvahiProtocol aprotocol,
-    AvahiLookupFlags flags,
-    AvahiSDNSServerBrowserCallback callback,
+    CattaDNSServerType type,
+    CattaProtocol aprotocol,
+    CattaLookupFlags flags,
+    CattaSDNSServerBrowserCallback callback,
     void* userdata) {
 
-    static const char * const type_table[AVAHI_DNS_SERVER_MAX] = {
+    static const char * const type_table[CATTA_DNS_SERVER_MAX] = {
         "_domain._udp",
         "_dns-update._udp"
     };
 
-    AvahiSDNSServerBrowser *b;
-    AvahiKey *k = NULL;
-    char n[AVAHI_DOMAIN_NAME_MAX];
+    CattaSDNSServerBrowser *b;
+    CattaKey *k = NULL;
+    char n[CATTA_DOMAIN_NAME_MAX];
     int r;
 
     assert(server);
     assert(callback);
 
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_PROTO_VALID(aprotocol), AVAHI_ERR_INVALID_PROTOCOL);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_FLAGS_VALID(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, type < AVAHI_DNS_SERVER_MAX, AVAHI_ERR_INVALID_FLAGS);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_PROTO_VALID(aprotocol), CATTA_ERR_INVALID_PROTOCOL);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, !domain || catta_is_valid_domain_name(domain), CATTA_ERR_INVALID_DOMAIN_NAME);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_FLAGS_VALID(flags, CATTA_LOOKUP_USE_WIDE_AREA|CATTA_LOOKUP_USE_MULTICAST), CATTA_ERR_INVALID_FLAGS);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, type < CATTA_DNS_SERVER_MAX, CATTA_ERR_INVALID_FLAGS);
 
     if (!domain)
         domain = server->domain_name;
 
-    if ((r = avahi_service_name_join(n, sizeof(n), NULL, type_table[type], domain)) < 0) {
-        avahi_server_set_errno(server, r);
+    if ((r = catta_service_name_join(n, sizeof(n), NULL, type_table[type], domain)) < 0) {
+        catta_server_set_errno(server, r);
         return NULL;
     }
 
-    if (!(b = avahi_new(AvahiSDNSServerBrowser, 1))) {
-        avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
+    if (!(b = catta_new(CattaSDNSServerBrowser, 1))) {
+        catta_server_set_errno(server, CATTA_ERR_NO_MEMORY);
         return NULL;
     }
 
@@ -282,41 +282,41 @@ AvahiSDNSServerBrowser *avahi_s_dns_server_browser_new(
     b->n_info = 0;
     b->user_flags = flags;
 
-    AVAHI_LLIST_HEAD_INIT(AvahiDNSServerInfo, b->info);
-    AVAHI_LLIST_PREPEND(AvahiSDNSServerBrowser, browser, server->dns_server_browsers, b);
+    CATTA_LLIST_HEAD_INIT(CattaDNSServerInfo, b->info);
+    CATTA_LLIST_PREPEND(CattaSDNSServerBrowser, browser, server->dns_server_browsers, b);
 
-    if (!(k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_SRV))) {
-        avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
+    if (!(k = catta_key_new(n, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_SRV))) {
+        catta_server_set_errno(server, CATTA_ERR_NO_MEMORY);
         goto fail;
     }
 
-    if (!(b->record_browser = avahi_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, b)))
+    if (!(b->record_browser = catta_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, b)))
         goto fail;
 
-    avahi_key_unref(k);
+    catta_key_unref(k);
 
     return b;
 
 fail:
 
     if (k)
-        avahi_key_unref(k);
+        catta_key_unref(k);
 
-    avahi_s_dns_server_browser_free(b);
+    catta_s_dns_server_browser_free(b);
     return NULL;
 }
 
-void avahi_s_dns_server_browser_free(AvahiSDNSServerBrowser *b) {
+void catta_s_dns_server_browser_free(CattaSDNSServerBrowser *b) {
     assert(b);
 
     while (b->info)
         server_info_free(b, b->info);
 
-    AVAHI_LLIST_REMOVE(AvahiSDNSServerBrowser, browser, b->server->dns_server_browsers, b);
+    CATTA_LLIST_REMOVE(CattaSDNSServerBrowser, browser, b->server->dns_server_browsers, b);
 
     if (b->record_browser)
-        avahi_s_record_browser_free(b->record_browser);
+        catta_s_record_browser_free(b->record_browser);
 
-    avahi_free(b);
+    catta_free(b);
 }
 
index 097e5d5b60bd2a3e69f702fb75afe7a24b5f6ca8..8ae99e49383c8bd14b9d5bee4754445fdac58b50 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 #include <stdlib.h>
 
-#include <avahi/domain.h>
-#include <avahi/malloc.h>
-#include <avahi/error.h>
+#include <catta/domain.h>
+#include <catta/malloc.h>
+#include <catta/error.h>
 
 #include "browse.h"
-#include <avahi/log.h>
+#include <catta/log.h>
 
-struct AvahiSDomainBrowser {
+struct CattaSDomainBrowser {
     int ref;
 
-    AvahiServer *server;
+    CattaServer *server;
 
-    AvahiSRecordBrowser *record_browser;
+    CattaSRecordBrowser *record_browser;
 
-    AvahiDomainBrowserType type;
-    AvahiSDomainBrowserCallback callback;
+    CattaDomainBrowserType type;
+    CattaSDomainBrowserCallback callback;
     void* userdata;
 
-    AvahiTimeEvent *defer_event;
+    CattaTimeEvent *defer_event;
 
     int all_for_now_scheduled;
 
-    AVAHI_LLIST_FIELDS(AvahiSDomainBrowser, browser);
+    CATTA_LLIST_FIELDS(CattaSDomainBrowser, browser);
 };
 
-static void inc_ref(AvahiSDomainBrowser *b) {
+static void inc_ref(CattaSDomainBrowser *b) {
     assert(b);
     assert(b->ref >= 1);
 
@@ -56,21 +56,21 @@ static void inc_ref(AvahiSDomainBrowser *b) {
 }
 
 static void record_browser_callback(
-    AvahiSRecordBrowser*rr,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiBrowserEvent event,
-    AvahiRecord *record,
-    AvahiLookupResultFlags flags,
+    CattaSRecordBrowser*rr,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaBrowserEvent event,
+    CattaRecord *record,
+    CattaLookupResultFlags flags,
     void* userdata) {
 
-    AvahiSDomainBrowser *b = userdata;
+    CattaSDomainBrowser *b = userdata;
     char *n = NULL;
 
     assert(rr);
     assert(b);
 
-    if (event == AVAHI_BROWSER_ALL_FOR_NOW &&
+    if (event == CATTA_BROWSER_ALL_FOR_NOW &&
         b->defer_event) {
 
         b->all_for_now_scheduled = 1;
@@ -78,19 +78,19 @@ static void record_browser_callback(
     }
 
     /* Filter flags */
-    flags &= AVAHI_LOOKUP_RESULT_CACHED | AVAHI_LOOKUP_RESULT_MULTICAST | AVAHI_LOOKUP_RESULT_WIDE_AREA;
+    flags &= CATTA_LOOKUP_RESULT_CACHED | CATTA_LOOKUP_RESULT_MULTICAST | CATTA_LOOKUP_RESULT_WIDE_AREA;
 
     if (record) {
-        assert(record->key->type == AVAHI_DNS_TYPE_PTR);
+        assert(record->key->type == CATTA_DNS_TYPE_PTR);
         n = record->data.ptr.name;
 
-        if (b->type == AVAHI_DOMAIN_BROWSER_BROWSE) {
-            AvahiStringList *l;
+        if (b->type == CATTA_DOMAIN_BROWSER_BROWSE) {
+            CattaStringList *l;
 
             /* Filter out entries defined statically */
 
             for (l = b->server->config.browse_domains; l; l = l->next)
-                if (avahi_domain_equal((char*) l->text, n))
+                if (catta_domain_equal((char*) l->text, n))
                     return;
         }
 
@@ -99,16 +99,16 @@ static void record_browser_callback(
     b->callback(b, interface, protocol, event, n, flags, b->userdata);
 }
 
-static void defer_callback(AvahiTimeEvent *e, void *userdata) {
-    AvahiSDomainBrowser *b = userdata;
-    AvahiStringList *l;
+static void defer_callback(CattaTimeEvent *e, void *userdata) {
+    CattaSDomainBrowser *b = userdata;
+    CattaStringList *l;
 
     assert(e);
     assert(b);
 
-    assert(b->type == AVAHI_DOMAIN_BROWSER_BROWSE);
+    assert(b->type == CATTA_DOMAIN_BROWSER_BROWSE);
 
-    avahi_time_event_free(b->defer_event);
+    catta_time_event_free(b->defer_event);
     b->defer_event = NULL;
 
     /* Increase ref counter */
@@ -121,31 +121,31 @@ static void defer_callback(AvahiTimeEvent *e, void *userdata) {
         if (b->ref <= 1)
             break;
 
-        b->callback(b, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_BROWSER_NEW, (char*) l->text, AVAHI_LOOKUP_RESULT_STATIC, b->userdata);
+        b->callback(b, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, CATTA_BROWSER_NEW, (char*) l->text, CATTA_LOOKUP_RESULT_STATIC, b->userdata);
     }
 
     if (b->ref > 1) {
         /* If the ALL_FOR_NOW event has already been scheduled, execute it now */
 
         if (b->all_for_now_scheduled)
-            b->callback(b, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_BROWSER_ALL_FOR_NOW, NULL, 0, b->userdata);
+            b->callback(b, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, CATTA_BROWSER_ALL_FOR_NOW, NULL, 0, b->userdata);
     }
 
     /* Decrease ref counter */
-    avahi_s_domain_browser_free(b);
+    catta_s_domain_browser_free(b);
 }
 
-AvahiSDomainBrowser *avahi_s_domain_browser_new(
-    AvahiServer *server,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
+CattaSDomainBrowser *catta_s_domain_browser_new(
+    CattaServer *server,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
     const char *domain,
-    AvahiDomainBrowserType type,
-    AvahiLookupFlags flags,
-    AvahiSDomainBrowserCallback callback,
+    CattaDomainBrowserType type,
+    CattaLookupFlags flags,
+    CattaSDomainBrowserCallback callback,
     void* userdata) {
 
-    static const char * const type_table[AVAHI_DOMAIN_BROWSER_MAX] = {
+    static const char * const type_table[CATTA_DOMAIN_BROWSER_MAX] = {
         "b",
         "db",
         "r",
@@ -153,30 +153,30 @@ AvahiSDomainBrowser *avahi_s_domain_browser_new(
         "lb"
     };
 
-    AvahiSDomainBrowser *b;
-    AvahiKey *k = NULL;
-    char n[AVAHI_DOMAIN_NAME_MAX];
+    CattaSDomainBrowser *b;
+    CattaKey *k = NULL;
+    char n[CATTA_DOMAIN_NAME_MAX];
     int r;
 
     assert(server);
     assert(callback);
 
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, type < AVAHI_DOMAIN_BROWSER_MAX, AVAHI_ERR_INVALID_FLAGS);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_FLAGS_VALID(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, type < CATTA_DOMAIN_BROWSER_MAX, CATTA_ERR_INVALID_FLAGS);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, !domain || catta_is_valid_domain_name(domain), CATTA_ERR_INVALID_DOMAIN_NAME);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_FLAGS_VALID(flags, CATTA_LOOKUP_USE_WIDE_AREA|CATTA_LOOKUP_USE_MULTICAST), CATTA_ERR_INVALID_FLAGS);
 
     if (!domain)
         domain = server->domain_name;
 
-    if ((r = avahi_service_name_join(n, sizeof(n), type_table[type], "_dns-sd._udp", domain)) < 0) {
-        avahi_server_set_errno(server, r);
+    if ((r = catta_service_name_join(n, sizeof(n), type_table[type], "_dns-sd._udp", domain)) < 0) {
+        catta_server_set_errno(server, r);
         return NULL;
     }
 
-    if (!(b = avahi_new(AvahiSDomainBrowser, 1))) {
-        avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
+    if (!(b = catta_new(CattaSDomainBrowser, 1))) {
+        catta_server_set_errno(server, CATTA_ERR_NO_MEMORY);
         return NULL;
     }
 
@@ -189,47 +189,47 @@ AvahiSDomainBrowser *avahi_s_domain_browser_new(
     b->all_for_now_scheduled = 0;
     b->defer_event = NULL;
 
-    AVAHI_LLIST_PREPEND(AvahiSDomainBrowser, browser, server->domain_browsers, b);
+    CATTA_LLIST_PREPEND(CattaSDomainBrowser, browser, server->domain_browsers, b);
 
-    if (!(k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR))) {
-        avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
+    if (!(k = catta_key_new(n, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_PTR))) {
+        catta_server_set_errno(server, CATTA_ERR_NO_MEMORY);
         goto fail;
     }
 
-    if (!(b->record_browser = avahi_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, b)))
+    if (!(b->record_browser = catta_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, b)))
         goto fail;
 
-    avahi_key_unref(k);
+    catta_key_unref(k);
 
-    if (type == AVAHI_DOMAIN_BROWSER_BROWSE && b->server->config.browse_domains)
-        b->defer_event = avahi_time_event_new(server->time_event_queue, NULL, defer_callback, b);
+    if (type == CATTA_DOMAIN_BROWSER_BROWSE && b->server->config.browse_domains)
+        b->defer_event = catta_time_event_new(server->time_event_queue, NULL, defer_callback, b);
 
     return b;
 
 fail:
 
     if (k)
-        avahi_key_unref(k);
+        catta_key_unref(k);
 
-    avahi_s_domain_browser_free(b);
+    catta_s_domain_browser_free(b);
 
     return NULL;
 }
 
-void avahi_s_domain_browser_free(AvahiSDomainBrowser *b) {
+void catta_s_domain_browser_free(CattaSDomainBrowser *b) {
     assert(b);
 
     assert(b->ref >= 1);
     if (--b->ref > 0)
         return;
 
-    AVAHI_LLIST_REMOVE(AvahiSDomainBrowser, browser, b->server->domain_browsers, b);
+    CATTA_LLIST_REMOVE(CattaSDomainBrowser, browser, b->server->domain_browsers, b);
 
     if (b->record_browser)
-        avahi_s_record_browser_free(b->record_browser);
+        catta_s_record_browser_free(b->record_browser);
 
     if (b->defer_event)
-        avahi_time_event_free(b->defer_event);
+        catta_time_event_free(b->defer_event);
 
-    avahi_free(b);
+    catta_free(b);
 }
index bbcd7ea880268ce00aca50d5d11fb658b60a8fb5..4d40a82afda4f4f794ef34b9d9d39599fc1b5130 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 #include <string.h>
 
-#include <avahi/domain.h>
-#include <avahi/malloc.h>
-#include <avahi/error.h>
+#include <catta/domain.h>
+#include <catta/malloc.h>
+#include <catta/error.h>
 
 #include "browse.h"
-#include <avahi/log.h>
+#include <catta/log.h>
 
-struct AvahiSServiceTypeBrowser {
-    AvahiServer *server;
+struct CattaSServiceTypeBrowser {
+    CattaServer *server;
     char *domain_name;
 
-    AvahiSRecordBrowser *record_browser;
+    CattaSRecordBrowser *record_browser;
 
-    AvahiSServiceTypeBrowserCallback callback;
+    CattaSServiceTypeBrowserCallback callback;
     void* userdata;
 
-    AVAHI_LLIST_FIELDS(AvahiSServiceTypeBrowser, browser);
+    CATTA_LLIST_FIELDS(CattaSServiceTypeBrowser, browser);
 };
 
 static void record_browser_callback(
-    AvahiSRecordBrowser*rr,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiBrowserEvent event,
-    AvahiRecord *record,
-    AvahiLookupResultFlags flags,
+    CattaSRecordBrowser*rr,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaBrowserEvent event,
+    CattaRecord *record,
+    CattaLookupResultFlags flags,
     void* userdata) {
 
-    AvahiSServiceTypeBrowser *b = userdata;
+    CattaSServiceTypeBrowser *b = userdata;
 
     assert(rr);
     assert(b);
 
     /* Filter flags */
-    flags &= AVAHI_LOOKUP_RESULT_CACHED | AVAHI_LOOKUP_RESULT_MULTICAST | AVAHI_LOOKUP_RESULT_WIDE_AREA;
+    flags &= CATTA_LOOKUP_RESULT_CACHED | CATTA_LOOKUP_RESULT_MULTICAST | CATTA_LOOKUP_RESULT_WIDE_AREA;
 
     if (record) {
-        char type[AVAHI_DOMAIN_NAME_MAX], domain[AVAHI_DOMAIN_NAME_MAX];
+        char type[CATTA_DOMAIN_NAME_MAX], domain[CATTA_DOMAIN_NAME_MAX];
 
-        assert(record->key->type == AVAHI_DNS_TYPE_PTR);
+        assert(record->key->type == CATTA_DNS_TYPE_PTR);
 
-        if (avahi_service_name_split(record->data.ptr.name, NULL, 0, type, sizeof(type), domain, sizeof(domain)) < 0) {
-            avahi_log_warn("Invalid service type '%s'", record->key->name);
+        if (catta_service_name_split(record->data.ptr.name, NULL, 0, type, sizeof(type), domain, sizeof(domain)) < 0) {
+            catta_log_warn("Invalid service type '%s'", record->key->name);
             return;
         }
 
@@ -74,38 +74,38 @@ static void record_browser_callback(
         b->callback(b, interface, protocol, event, NULL, b->domain_name, flags, b->userdata);
 }
 
-AvahiSServiceTypeBrowser *avahi_s_service_type_browser_new(
-    AvahiServer *server,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
+CattaSServiceTypeBrowser *catta_s_service_type_browser_new(
+    CattaServer *server,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
     const char *domain,
-    AvahiLookupFlags flags,
-    AvahiSServiceTypeBrowserCallback callback,
+    CattaLookupFlags flags,
+    CattaSServiceTypeBrowserCallback callback,
     void* userdata) {
 
-    AvahiSServiceTypeBrowser *b;
-    AvahiKey *k = NULL;
-    char n[AVAHI_DOMAIN_NAME_MAX];
+    CattaSServiceTypeBrowser *b;
+    CattaKey *k = NULL;
+    char n[CATTA_DOMAIN_NAME_MAX];
     int r;
 
     assert(server);
     assert(callback);
 
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_FLAGS_VALID(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, !domain || catta_is_valid_domain_name(domain), CATTA_ERR_INVALID_DOMAIN_NAME);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_FLAGS_VALID(flags, CATTA_LOOKUP_USE_WIDE_AREA|CATTA_LOOKUP_USE_MULTICAST), CATTA_ERR_INVALID_FLAGS);
 
     if (!domain)
         domain = server->domain_name;
 
-    if ((r = avahi_service_name_join(n, sizeof(n), NULL, "_services._dns-sd._udp", domain)) < 0) {
-        avahi_server_set_errno(server, r);
+    if ((r = catta_service_name_join(n, sizeof(n), NULL, "_services._dns-sd._udp", domain)) < 0) {
+        catta_server_set_errno(server, r);
         return NULL;
     }
 
-    if (!(b = avahi_new(AvahiSServiceTypeBrowser, 1))) {
-        avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
+    if (!(b = catta_new(CattaSServiceTypeBrowser, 1))) {
+        catta_server_set_errno(server, CATTA_ERR_NO_MEMORY);
         return NULL;
     }
 
@@ -114,44 +114,44 @@ AvahiSServiceTypeBrowser *avahi_s_service_type_browser_new(
     b->userdata = userdata;
     b->record_browser = NULL;
 
-    AVAHI_LLIST_PREPEND(AvahiSServiceTypeBrowser, browser, server->service_type_browsers, b);
+    CATTA_LLIST_PREPEND(CattaSServiceTypeBrowser, browser, server->service_type_browsers, b);
 
-    if (!(b->domain_name = avahi_normalize_name_strdup(domain))) {
-        avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
+    if (!(b->domain_name = catta_normalize_name_strdup(domain))) {
+        catta_server_set_errno(server, CATTA_ERR_NO_MEMORY);
         goto fail;
     }
 
-    if (!(k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR))) {
-        avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
+    if (!(k = catta_key_new(n, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_PTR))) {
+        catta_server_set_errno(server, CATTA_ERR_NO_MEMORY);
         goto fail;
     }
 
-    if (!(b->record_browser = avahi_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, b)))
+    if (!(b->record_browser = catta_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, b)))
         goto fail;
 
-    avahi_key_unref(k);
+    catta_key_unref(k);
 
     return b;
 
 fail:
     if (k)
-        avahi_key_unref(k);
+        catta_key_unref(k);
 
-    avahi_s_service_type_browser_free(b);
+    catta_s_service_type_browser_free(b);
 
     return NULL;
 }
 
-void avahi_s_service_type_browser_free(AvahiSServiceTypeBrowser *b) {
+void catta_s_service_type_browser_free(CattaSServiceTypeBrowser *b) {
     assert(b);
 
-    AVAHI_LLIST_REMOVE(AvahiSServiceTypeBrowser, browser, b->server->service_type_browsers, b);
+    CATTA_LLIST_REMOVE(CattaSServiceTypeBrowser, browser, b->server->service_type_browsers, b);
 
     if (b->record_browser)
-        avahi_s_record_browser_free(b->record_browser);
+        catta_s_record_browser_free(b->record_browser);
 
-    avahi_free(b->domain_name);
-    avahi_free(b);
+    catta_free(b->domain_name);
+    catta_free(b);
 }
 
 
index 0d3c3269981c7a43dc732a378b952472222094c2..4a4c8df618387915cc6928e1a25955752d659d07 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 #include <string.h>
 
-#include <avahi/domain.h>
-#include <avahi/malloc.h>
-#include <avahi/error.h>
+#include <catta/domain.h>
+#include <catta/malloc.h>
+#include <catta/error.h>
 
 #include "browse.h"
-#include <avahi/log.h>
+#include <catta/log.h>
 
-struct AvahiSServiceBrowser {
-    AvahiServer *server;
+struct CattaSServiceBrowser {
+    CattaServer *server;
     char *domain_name;
     char *service_type;
 
-    AvahiSRecordBrowser *record_browser;
+    CattaSRecordBrowser *record_browser;
 
-    AvahiSServiceBrowserCallback callback;
+    CattaSServiceBrowserCallback callback;
     void* userdata;
 
-    AVAHI_LLIST_FIELDS(AvahiSServiceBrowser, browser);
+    CATTA_LLIST_FIELDS(CattaSServiceBrowser, browser);
 };
 
 static void record_browser_callback(
-    AvahiSRecordBrowser*rr,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiBrowserEvent event,
-    AvahiRecord *record,
-    AvahiLookupResultFlags flags,
+    CattaSRecordBrowser*rr,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaBrowserEvent event,
+    CattaRecord *record,
+    CattaLookupResultFlags flags,
     void* userdata) {
 
-    AvahiSServiceBrowser *b = userdata;
+    CattaSServiceBrowser *b = userdata;
 
     assert(rr);
     assert(b);
 
     /* Filter flags */
-    flags &= AVAHI_LOOKUP_RESULT_CACHED | AVAHI_LOOKUP_RESULT_MULTICAST | AVAHI_LOOKUP_RESULT_WIDE_AREA;
+    flags &= CATTA_LOOKUP_RESULT_CACHED | CATTA_LOOKUP_RESULT_MULTICAST | CATTA_LOOKUP_RESULT_WIDE_AREA;
 
     if (record) {
-        char service[AVAHI_LABEL_MAX], type[AVAHI_DOMAIN_NAME_MAX], domain[AVAHI_DOMAIN_NAME_MAX];
+        char service[CATTA_LABEL_MAX], type[CATTA_DOMAIN_NAME_MAX], domain[CATTA_DOMAIN_NAME_MAX];
 
-        assert(record->key->type == AVAHI_DNS_TYPE_PTR);
+        assert(record->key->type == CATTA_DNS_TYPE_PTR);
 
-        if (event == AVAHI_BROWSER_NEW && avahi_server_is_service_local(b->server, interface, protocol, record->data.ptr.name))
-            flags |= AVAHI_LOOKUP_RESULT_LOCAL;
+        if (event == CATTA_BROWSER_NEW && catta_server_is_service_local(b->server, interface, protocol, record->data.ptr.name))
+            flags |= CATTA_LOOKUP_RESULT_LOCAL;
 
-        if (avahi_service_name_split(record->data.ptr.name, service, sizeof(service), type, sizeof(type), domain, sizeof(domain)) < 0) {
-            avahi_log_warn("Failed to split '%s'", record->key->name);
+        if (catta_service_name_split(record->data.ptr.name, service, sizeof(service), type, sizeof(type), domain, sizeof(domain)) < 0) {
+            catta_log_warn("Failed to split '%s'", record->key->name);
             return;
         }
 
@@ -80,41 +80,41 @@ static void record_browser_callback(
 
 }
 
-AvahiSServiceBrowser *avahi_s_service_browser_new(
-    AvahiServer *server,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
+CattaSServiceBrowser *catta_s_service_browser_new(
+    CattaServer *server,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
     const char *service_type,
     const char *domain,
-    AvahiLookupFlags flags,
-    AvahiSServiceBrowserCallback callback,
+    CattaLookupFlags flags,
+    CattaSServiceBrowserCallback callback,
     void* userdata) {
 
-    AvahiSServiceBrowser *b;
-    AvahiKey *k = NULL;
-    char n[AVAHI_DOMAIN_NAME_MAX];
+    CattaSServiceBrowser *b;
+    CattaKey *k = NULL;
+    char n[CATTA_DOMAIN_NAME_MAX];
     int r;
 
     assert(server);
     assert(callback);
     assert(service_type);
 
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_FLAGS_VALID(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, avahi_is_valid_service_type_generic(service_type), AVAHI_ERR_INVALID_SERVICE_TYPE);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, !domain || catta_is_valid_domain_name(domain), CATTA_ERR_INVALID_DOMAIN_NAME);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_FLAGS_VALID(flags, CATTA_LOOKUP_USE_WIDE_AREA|CATTA_LOOKUP_USE_MULTICAST), CATTA_ERR_INVALID_FLAGS);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, catta_is_valid_service_type_generic(service_type), CATTA_ERR_INVALID_SERVICE_TYPE);
 
     if (!domain)
         domain = server->domain_name;
 
-    if ((r = avahi_service_name_join(n, sizeof(n), NULL, service_type, domain)) < 0) {
-        avahi_server_set_errno(server, r);
+    if ((r = catta_service_name_join(n, sizeof(n), NULL, service_type, domain)) < 0) {
+        catta_server_set_errno(server, r);
         return NULL;
     }
 
-    if (!(b = avahi_new(AvahiSServiceBrowser, 1))) {
-        avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
+    if (!(b = catta_new(CattaSServiceBrowser, 1))) {
+        catta_server_set_errno(server, CATTA_ERR_NO_MEMORY);
         return NULL;
     }
 
@@ -124,44 +124,44 @@ AvahiSServiceBrowser *avahi_s_service_browser_new(
     b->userdata = userdata;
     b->record_browser = NULL;
 
-    AVAHI_LLIST_PREPEND(AvahiSServiceBrowser, browser, server->service_browsers, b);
+    CATTA_LLIST_PREPEND(CattaSServiceBrowser, browser, server->service_browsers, b);
 
-    if (!(b->domain_name = avahi_normalize_name_strdup(domain)) ||
-        !(b->service_type = avahi_normalize_name_strdup(service_type))) {
-        avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
+    if (!(b->domain_name = catta_normalize_name_strdup(domain)) ||
+        !(b->service_type = catta_normalize_name_strdup(service_type))) {
+        catta_server_set_errno(server, CATTA_ERR_NO_MEMORY);
         goto fail;
     }
 
-    if (!(k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR))) {
-        avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
+    if (!(k = catta_key_new(n, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_PTR))) {
+        catta_server_set_errno(server, CATTA_ERR_NO_MEMORY);
         goto fail;
     }
 
-    if (!(b->record_browser = avahi_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, b)))
+    if (!(b->record_browser = catta_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, b)))
         goto fail;
 
-    avahi_key_unref(k);
+    catta_key_unref(k);
 
     return b;
 
 fail:
 
     if (k)
-        avahi_key_unref(k);
+        catta_key_unref(k);
 
-    avahi_s_service_browser_free(b);
+    catta_s_service_browser_free(b);
     return NULL;
 }
 
-void avahi_s_service_browser_free(AvahiSServiceBrowser *b) {
+void catta_s_service_browser_free(CattaSServiceBrowser *b) {
     assert(b);
 
-    AVAHI_LLIST_REMOVE(AvahiSServiceBrowser, browser, b->server->service_browsers, b);
+    CATTA_LLIST_REMOVE(CattaSServiceBrowser, browser, b->server->service_browsers, b);
 
     if (b->record_browser)
-        avahi_s_record_browser_free(b->record_browser);
+        catta_s_record_browser_free(b->record_browser);
 
-    avahi_free(b->domain_name);
-    avahi_free(b->service_type);
-    avahi_free(b);
+    catta_free(b->domain_name);
+    catta_free(b->service_type);
+    catta_free(b);
 }
index f9a1848a98135ca1625f4d89fbf8f73fe1033d46..0324499767cc8907284b1775b633cd8e7cf2c259 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 #include <stdlib.h>
 
-#include <avahi/timeval.h>
-#include <avahi/malloc.h>
-#include <avahi/error.h>
-#include <avahi/domain.h>
-#include <avahi/rlist.h>
-#include <avahi/address.h>
-#include <avahi/log.h>
+#include <catta/timeval.h>
+#include <catta/malloc.h>
+#include <catta/error.h>
+#include <catta/domain.h>
+#include <catta/rlist.h>
+#include <catta/address.h>
+#include <catta/log.h>
 
 #include "browse.h"
 #include "querier.h"
 #include "domain-util.h"
 #include "rr-util.h"
 
-#define AVAHI_LOOKUPS_PER_BROWSER_MAX 15
+#define CATTA_LOOKUPS_PER_BROWSER_MAX 15
 
-struct AvahiSRBLookup {
-    AvahiSRecordBrowser *record_browser;
+struct CattaSRBLookup {
+    CattaSRecordBrowser *record_browser;
 
     unsigned ref;
 
-    AvahiIfIndex interface;
-    AvahiProtocol protocol;
-    AvahiLookupFlags flags;
+    CattaIfIndex interface;
+    CattaProtocol protocol;
+    CattaLookupFlags flags;
 
-    AvahiKey *key;
+    CattaKey *key;
 
-    AvahiWideAreaLookup *wide_area;
-    AvahiMulticastLookup *multicast;
+    CattaWideAreaLookup *wide_area;
+    CattaMulticastLookup *multicast;
 
-    AvahiRList *cname_lookups;
+    CattaRList *cname_lookups;
 
-    AVAHI_LLIST_FIELDS(AvahiSRBLookup, lookups);
+    CATTA_LLIST_FIELDS(CattaSRBLookup, lookups);
 };
 
-static void lookup_handle_cname(AvahiSRBLookup *l, AvahiIfIndex interface, AvahiProtocol protocol, AvahiLookupFlags flags, AvahiRecord *r);
-static void lookup_drop_cname(AvahiSRBLookup *l, AvahiIfIndex interface, AvahiProtocol protocol, AvahiLookupFlags flags, AvahiRecord *r);
+static void lookup_handle_cname(CattaSRBLookup *l, CattaIfIndex interface, CattaProtocol protocol, CattaLookupFlags flags, CattaRecord *r);
+static void lookup_drop_cname(CattaSRBLookup *l, CattaIfIndex interface, CattaProtocol protocol, CattaLookupFlags flags, CattaRecord *r);
 
-static void transport_flags_from_domain(AvahiServer *s, AvahiLookupFlags *flags, const char *domain) {
+static void transport_flags_from_domain(CattaServer *s, CattaLookupFlags *flags, const char *domain) {
     assert(flags);
     assert(domain);
 
-    assert(!((*flags & AVAHI_LOOKUP_USE_MULTICAST) && (*flags & AVAHI_LOOKUP_USE_WIDE_AREA)));
+    assert(!((*flags & CATTA_LOOKUP_USE_MULTICAST) && (*flags & CATTA_LOOKUP_USE_WIDE_AREA)));
 
-    if (*flags & (AVAHI_LOOKUP_USE_MULTICAST|AVAHI_LOOKUP_USE_WIDE_AREA))
+    if (*flags & (CATTA_LOOKUP_USE_MULTICAST|CATTA_LOOKUP_USE_WIDE_AREA))
         return;
 
     if (!s->wide_area_lookup_engine ||
-        !avahi_wide_area_has_servers(s->wide_area_lookup_engine) ||
-        avahi_domain_ends_with(domain, AVAHI_MDNS_SUFFIX_LOCAL) ||
-        avahi_domain_ends_with(domain, AVAHI_MDNS_SUFFIX_ADDR_IPV4) ||
-        avahi_domain_ends_with(domain, AVAHI_MDNS_SUFFIX_ADDR_IPV6))
-        *flags |= AVAHI_LOOKUP_USE_MULTICAST;
+        !catta_wide_area_has_servers(s->wide_area_lookup_engine) ||
+        catta_domain_ends_with(domain, CATTA_MDNS_SUFFIX_LOCAL) ||
+        catta_domain_ends_with(domain, CATTA_MDNS_SUFFIX_ADDR_IPV4) ||
+        catta_domain_ends_with(domain, CATTA_MDNS_SUFFIX_ADDR_IPV6))
+        *flags |= CATTA_LOOKUP_USE_MULTICAST;
     else
-        *flags |= AVAHI_LOOKUP_USE_WIDE_AREA;
+        *flags |= CATTA_LOOKUP_USE_WIDE_AREA;
 }
 
-static AvahiSRBLookup* lookup_new(
-    AvahiSRecordBrowser *b,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiLookupFlags flags,
-    AvahiKey *key) {
+static CattaSRBLookup* lookup_new(
+    CattaSRecordBrowser *b,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaLookupFlags flags,
+    CattaKey *key) {
 
-    AvahiSRBLookup *l;
+    CattaSRBLookup *l;
 
     assert(b);
-    assert(AVAHI_IF_VALID(interface));
-    assert(AVAHI_PROTO_VALID(protocol));
+    assert(CATTA_IF_VALID(interface));
+    assert(CATTA_PROTO_VALID(protocol));
 
-    if (b->n_lookups >= AVAHI_LOOKUPS_PER_BROWSER_MAX)
+    if (b->n_lookups >= CATTA_LOOKUPS_PER_BROWSER_MAX)
         /* We don't like cyclic CNAMEs */
         return NULL;
 
-    if (!(l = avahi_new(AvahiSRBLookup, 1)))
+    if (!(l = catta_new(CattaSRBLookup, 1)))
         return NULL;
 
     l->ref = 1;
     l->record_browser = b;
     l->interface = interface;
     l->protocol = protocol;
-    l->key = avahi_key_ref(key);
+    l->key = catta_key_ref(key);
     l->wide_area = NULL;
     l->multicast = NULL;
     l->cname_lookups = NULL;
@@ -111,43 +111,43 @@ static AvahiSRBLookup* lookup_new(
 
     transport_flags_from_domain(b->server, &l->flags, key->name);
 
-    AVAHI_LLIST_PREPEND(AvahiSRBLookup, lookups, b->lookups, l);
+    CATTA_LLIST_PREPEND(CattaSRBLookup, lookups, b->lookups, l);
 
     b->n_lookups ++;
 
     return l;
 }
 
-static void lookup_unref(AvahiSRBLookup *l) {
+static void lookup_unref(CattaSRBLookup *l) {
     assert(l);
     assert(l->ref >= 1);
 
     if (--l->ref >= 1)
         return;
 
-    AVAHI_LLIST_REMOVE(AvahiSRBLookup, lookups, l->record_browser->lookups, l);
+    CATTA_LLIST_REMOVE(CattaSRBLookup, lookups, l->record_browser->lookups, l);
     l->record_browser->n_lookups --;
 
     if (l->wide_area) {
-        avahi_wide_area_lookup_free(l->wide_area);
+        catta_wide_area_lookup_free(l->wide_area);
         l->wide_area = NULL;
     }
 
     if (l->multicast) {
-        avahi_multicast_lookup_free(l->multicast);
+        catta_multicast_lookup_free(l->multicast);
         l->multicast = NULL;
     }
 
     while (l->cname_lookups) {
         lookup_unref(l->cname_lookups->data);
-        l->cname_lookups = avahi_rlist_remove_by_link(l->cname_lookups, l->cname_lookups);
+        l->cname_lookups = catta_rlist_remove_by_link(l->cname_lookups, l->cname_lookups);
     }
 
-    avahi_key_unref(l->key);
-    avahi_free(l);
+    catta_key_unref(l->key);
+    catta_free(l);
 }
 
-static AvahiSRBLookup* lookup_ref(AvahiSRBLookup *l) {
+static CattaSRBLookup* lookup_ref(CattaSRBLookup *l) {
     assert(l);
     assert(l->ref >= 1);
 
@@ -155,23 +155,23 @@ static AvahiSRBLookup* lookup_ref(AvahiSRBLookup *l) {
     return l;
 }
 
-static AvahiSRBLookup *lookup_find(
-    AvahiSRecordBrowser *b,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiLookupFlags flags,
-    AvahiKey *key) {
+static CattaSRBLookup *lookup_find(
+    CattaSRecordBrowser *b,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaLookupFlags flags,
+    CattaKey *key) {
 
-    AvahiSRBLookup *l;
+    CattaSRBLookup *l;
 
     assert(b);
 
     for (l = b->lookups; l; l = l->lookups_next) {
 
-        if ((l->interface == AVAHI_IF_UNSPEC || l->interface == interface) &&
-            (l->interface == AVAHI_PROTO_UNSPEC || l->protocol == protocol) &&
+        if ((l->interface == CATTA_IF_UNSPEC || l->interface == interface) &&
+            (l->interface == CATTA_PROTO_UNSPEC || l->protocol == protocol) &&
             l->flags == flags &&
-            avahi_key_equal(l->key, key))
+            catta_key_equal(l->key, key))
 
             return l;
     }
@@ -179,7 +179,7 @@ static AvahiSRBLookup *lookup_find(
     return NULL;
 }
 
-static void browser_cancel(AvahiSRecordBrowser *b) {
+static void browser_cancel(CattaSRecordBrowser *b) {
     assert(b);
 
     if (b->root_lookup) {
@@ -188,20 +188,20 @@ static void browser_cancel(AvahiSRecordBrowser *b) {
     }
 
     if (b->defer_time_event) {
-        avahi_time_event_free(b->defer_time_event);
+        catta_time_event_free(b->defer_time_event);
         b->defer_time_event = NULL;
     }
 }
 
 static void lookup_wide_area_callback(
-    AvahiWideAreaLookupEngine *e,
-    AvahiBrowserEvent event,
-    AvahiLookupResultFlags flags,
-    AvahiRecord *r,
+    CattaWideAreaLookupEngine *e,
+    CattaBrowserEvent event,
+    CattaLookupResultFlags flags,
+    CattaRecord *r,
     void *userdata) {
 
-    AvahiSRBLookup *l = userdata;
-    AvahiSRecordBrowser *b;
+    CattaSRBLookup *l = userdata;
+    CattaSRecordBrowser *b;
 
     assert(e);
     assert(l);
@@ -215,30 +215,30 @@ static void lookup_wide_area_callback(
     lookup_ref(l);
 
     switch (event) {
-        case AVAHI_BROWSER_NEW:
+        case CATTA_BROWSER_NEW:
             assert(r);
 
-            if (r->key->clazz == AVAHI_DNS_CLASS_IN &&
-                r->key->type == AVAHI_DNS_TYPE_CNAME)
+            if (r->key->clazz == CATTA_DNS_CLASS_IN &&
+                r->key->type == CATTA_DNS_TYPE_CNAME)
                 /* It's a CNAME record, so let's follow it. We only follow it on wide area DNS! */
-                lookup_handle_cname(l, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_LOOKUP_USE_WIDE_AREA, r);
+                lookup_handle_cname(l, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, CATTA_LOOKUP_USE_WIDE_AREA, r);
             else {
                 /* It's a normal record, so let's call the user callback */
-                assert(avahi_key_equal(r->key, l->key));
+                assert(catta_key_equal(r->key, l->key));
 
-                b->callback(b, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, event, r, flags, b->userdata);
+                b->callback(b, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, event, r, flags, b->userdata);
             }
             break;
 
-        case AVAHI_BROWSER_REMOVE:
-        case AVAHI_BROWSER_CACHE_EXHAUSTED:
+        case CATTA_BROWSER_REMOVE:
+        case CATTA_BROWSER_CACHE_EXHAUSTED:
             /* Not defined for wide area DNS */
             abort();
 
-        case AVAHI_BROWSER_ALL_FOR_NOW:
-        case AVAHI_BROWSER_FAILURE:
+        case CATTA_BROWSER_ALL_FOR_NOW:
+        case CATTA_BROWSER_FAILURE:
 
-            b->callback(b, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, event, NULL, flags, b->userdata);
+            b->callback(b, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, event, NULL, flags, b->userdata);
             break;
     }
 
@@ -247,16 +247,16 @@ static void lookup_wide_area_callback(
 }
 
 static void lookup_multicast_callback(
-    AvahiMulticastLookupEngine *e,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiBrowserEvent event,
-    AvahiLookupResultFlags flags,
-    AvahiRecord *r,
+    CattaMulticastLookupEngine *e,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaBrowserEvent event,
+    CattaLookupResultFlags flags,
+    CattaRecord *r,
     void *userdata) {
 
-    AvahiSRBLookup *l = userdata;
-    AvahiSRecordBrowser *b;
+    CattaSRBLookup *l = userdata;
+    CattaSRecordBrowser *b;
 
     assert(e);
     assert(l);
@@ -269,45 +269,45 @@ static void lookup_multicast_callback(
     lookup_ref(l);
 
     switch (event) {
-        case AVAHI_BROWSER_NEW:
+        case CATTA_BROWSER_NEW:
             assert(r);
 
-            if (r->key->clazz == AVAHI_DNS_CLASS_IN &&
-                r->key->type == AVAHI_DNS_TYPE_CNAME)
+            if (r->key->clazz == CATTA_DNS_CLASS_IN &&
+                r->key->type == CATTA_DNS_TYPE_CNAME)
                 /* It's a CNAME record, so let's follow it. We allow browsing on both multicast and wide area. */
                 lookup_handle_cname(l, interface, protocol, b->flags, r);
             else {
                 /* It's a normal record, so let's call the user callback */
 
-                if (avahi_server_is_record_local(b->server, interface, protocol, r))
-                    flags |= AVAHI_LOOKUP_RESULT_LOCAL;
+                if (catta_server_is_record_local(b->server, interface, protocol, r))
+                    flags |= CATTA_LOOKUP_RESULT_LOCAL;
 
                 b->callback(b, interface, protocol, event, r, flags, b->userdata);
             }
             break;
 
-        case AVAHI_BROWSER_REMOVE:
+        case CATTA_BROWSER_REMOVE:
             assert(r);
 
-            if (r->key->clazz == AVAHI_DNS_CLASS_IN &&
-                r->key->type == AVAHI_DNS_TYPE_CNAME)
+            if (r->key->clazz == CATTA_DNS_CLASS_IN &&
+                r->key->type == CATTA_DNS_TYPE_CNAME)
                 /* It's a CNAME record, so let's drop that query! */
                 lookup_drop_cname(l, interface, protocol, 0, r);
             else {
                 /* It's a normal record, so let's call the user callback */
-                assert(avahi_key_equal(b->key, l->key));
+                assert(catta_key_equal(b->key, l->key));
 
                 b->callback(b, interface, protocol, event, r, flags, b->userdata);
             }
             break;
 
-        case AVAHI_BROWSER_ALL_FOR_NOW:
+        case CATTA_BROWSER_ALL_FOR_NOW:
 
-            b->callback(b, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, event, NULL, flags, b->userdata);
+            b->callback(b, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, event, NULL, flags, b->userdata);
             break;
 
-        case AVAHI_BROWSER_CACHE_EXHAUSTED:
-        case AVAHI_BROWSER_FAILURE:
+        case CATTA_BROWSER_CACHE_EXHAUSTED:
+        case CATTA_BROWSER_FAILURE:
             /* Not defined for multicast DNS */
             abort();
 
@@ -316,48 +316,48 @@ static void lookup_multicast_callback(
     lookup_unref(l);
 }
 
-static int lookup_start(AvahiSRBLookup *l) {
+static int lookup_start(CattaSRBLookup *l) {
     assert(l);
 
-    assert(!(l->flags & AVAHI_LOOKUP_USE_WIDE_AREA) != !(l->flags & AVAHI_LOOKUP_USE_MULTICAST));
+    assert(!(l->flags & CATTA_LOOKUP_USE_WIDE_AREA) != !(l->flags & CATTA_LOOKUP_USE_MULTICAST));
     assert(!l->wide_area && !l->multicast);
 
-    if (l->flags & AVAHI_LOOKUP_USE_WIDE_AREA) {
+    if (l->flags & CATTA_LOOKUP_USE_WIDE_AREA) {
 
-        if (!(l->wide_area = avahi_wide_area_lookup_new(l->record_browser->server->wide_area_lookup_engine, l->key, lookup_wide_area_callback, l)))
+        if (!(l->wide_area = catta_wide_area_lookup_new(l->record_browser->server->wide_area_lookup_engine, l->key, lookup_wide_area_callback, l)))
             return -1;
 
     } else {
-        assert(l->flags & AVAHI_LOOKUP_USE_MULTICAST);
+        assert(l->flags & CATTA_LOOKUP_USE_MULTICAST);
 
-        if (!(l->multicast = avahi_multicast_lookup_new(l->record_browser->server->multicast_lookup_engine, l->interface, l->protocol, l->key, lookup_multicast_callback, l)))
+        if (!(l->multicast = catta_multicast_lookup_new(l->record_browser->server->multicast_lookup_engine, l->interface, l->protocol, l->key, lookup_multicast_callback, l)))
             return -1;
     }
 
     return 0;
 }
 
-static int lookup_scan_cache(AvahiSRBLookup *l) {
+static int lookup_scan_cache(CattaSRBLookup *l) {
     int n = 0;
 
     assert(l);
 
-    assert(!(l->flags & AVAHI_LOOKUP_USE_WIDE_AREA) != !(l->flags & AVAHI_LOOKUP_USE_MULTICAST));
+    assert(!(l->flags & CATTA_LOOKUP_USE_WIDE_AREA) != !(l->flags & CATTA_LOOKUP_USE_MULTICAST));
 
 
-    if (l->flags & AVAHI_LOOKUP_USE_WIDE_AREA) {
-        n = (int) avahi_wide_area_scan_cache(l->record_browser->server->wide_area_lookup_engine, l->key, lookup_wide_area_callback, l);
+    if (l->flags & CATTA_LOOKUP_USE_WIDE_AREA) {
+        n = (int) catta_wide_area_scan_cache(l->record_browser->server->wide_area_lookup_engine, l->key, lookup_wide_area_callback, l);
 
     } else {
-        assert(l->flags & AVAHI_LOOKUP_USE_MULTICAST);
-        n = (int) avahi_multicast_lookup_engine_scan_cache(l->record_browser->server->multicast_lookup_engine, l->interface, l->protocol, l->key, lookup_multicast_callback, l);
+        assert(l->flags & CATTA_LOOKUP_USE_MULTICAST);
+        n = (int) catta_multicast_lookup_engine_scan_cache(l->record_browser->server->multicast_lookup_engine, l->interface, l->protocol, l->key, lookup_multicast_callback, l);
     }
 
     return n;
 }
 
-static AvahiSRBLookup* lookup_add(AvahiSRecordBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiLookupFlags flags, AvahiKey *key) {
-    AvahiSRBLookup *l;
+static CattaSRBLookup* lookup_add(CattaSRecordBrowser *b, CattaIfIndex interface, CattaProtocol protocol, CattaLookupFlags flags, CattaKey *key) {
+    CattaSRBLookup *l;
 
     assert(b);
     assert(!b->dead);
@@ -371,7 +371,7 @@ static AvahiSRBLookup* lookup_add(AvahiSRecordBrowser *b, AvahiIfIndex interface
     return l;
 }
 
-static int lookup_go(AvahiSRBLookup *l) {
+static int lookup_go(CattaSRBLookup *l) {
     int n = 0;
     assert(l);
 
@@ -386,7 +386,7 @@ static int lookup_go(AvahiSRBLookup *l) {
     /* Start the lookup */
     if (!l->record_browser->dead && l->ref > 1) {
 
-        if ((l->flags & AVAHI_LOOKUP_USE_MULTICAST) || n == 0)
+        if ((l->flags & CATTA_LOOKUP_USE_MULTICAST) || n == 0)
             /* We do no start a query if the cache contained entries and we're on wide area */
 
             if (lookup_start(l) < 0)
@@ -398,63 +398,63 @@ static int lookup_go(AvahiSRBLookup *l) {
     return n;
 }
 
-static void lookup_handle_cname(AvahiSRBLookup *l, AvahiIfIndex interface, AvahiProtocol protocol, AvahiLookupFlags flags, AvahiRecord *r) {
-    AvahiKey *k;
-    AvahiSRBLookup *n;
+static void lookup_handle_cname(CattaSRBLookup *l, CattaIfIndex interface, CattaProtocol protocol, CattaLookupFlags flags, CattaRecord *r) {
+    CattaKey *k;
+    CattaSRBLookup *n;
 
     assert(l);
     assert(r);
 
-    assert(r->key->clazz == AVAHI_DNS_CLASS_IN);
-    assert(r->key->type == AVAHI_DNS_TYPE_CNAME);
+    assert(r->key->clazz == CATTA_DNS_CLASS_IN);
+    assert(r->key->type == CATTA_DNS_TYPE_CNAME);
 
-    k = avahi_key_new(r->data.ptr.name, l->record_browser->key->clazz, l->record_browser->key->type);
+    k = catta_key_new(r->data.ptr.name, l->record_browser->key->clazz, l->record_browser->key->type);
     n = lookup_add(l->record_browser, interface, protocol, flags, k);
-    avahi_key_unref(k);
+    catta_key_unref(k);
 
     if (!n) {
-        avahi_log_debug(__FILE__": Failed to create SRBLookup.");
+        catta_log_debug(__FILE__": Failed to create SRBLookup.");
         return;
     }
 
-    l->cname_lookups = avahi_rlist_prepend(l->cname_lookups, lookup_ref(n));
+    l->cname_lookups = catta_rlist_prepend(l->cname_lookups, lookup_ref(n));
 
     lookup_go(n);
     lookup_unref(n);
 }
 
-static void lookup_drop_cname(AvahiSRBLookup *l, AvahiIfIndex interface, AvahiProtocol protocol, AvahiLookupFlags flags, AvahiRecord *r) {
-    AvahiKey *k;
-    AvahiSRBLookup *n = NULL;
-    AvahiRList *rl;
+static void lookup_drop_cname(CattaSRBLookup *l, CattaIfIndex interface, CattaProtocol protocol, CattaLookupFlags flags, CattaRecord *r) {
+    CattaKey *k;
+    CattaSRBLookup *n = NULL;
+    CattaRList *rl;
 
-    assert(r->key->clazz == AVAHI_DNS_CLASS_IN);
-    assert(r->key->type == AVAHI_DNS_TYPE_CNAME);
+    assert(r->key->clazz == CATTA_DNS_CLASS_IN);
+    assert(r->key->type == CATTA_DNS_TYPE_CNAME);
 
-    k = avahi_key_new(r->data.ptr.name, l->record_browser->key->clazz, l->record_browser->key->type);
+    k = catta_key_new(r->data.ptr.name, l->record_browser->key->clazz, l->record_browser->key->type);
 
     for (rl = l->cname_lookups; rl; rl = rl->rlist_next) {
         n = rl->data;
 
         assert(n);
 
-        if ((n->interface == AVAHI_IF_UNSPEC || n->interface == interface) &&
-            (n->interface == AVAHI_PROTO_UNSPEC || n->protocol == protocol) &&
+        if ((n->interface == CATTA_IF_UNSPEC || n->interface == interface) &&
+            (n->interface == CATTA_PROTO_UNSPEC || n->protocol == protocol) &&
             n->flags == flags &&
-            avahi_key_equal(n->key, k))
+            catta_key_equal(n->key, k))
             break;
     }
 
-    avahi_key_unref(k);
+    catta_key_unref(k);
 
     if (rl) {
-        l->cname_lookups = avahi_rlist_remove_by_link(l->cname_lookups, rl);
+        l->cname_lookups = catta_rlist_remove_by_link(l->cname_lookups, rl);
         lookup_unref(n);
     }
 }
 
-static void defer_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void *userdata) {
-    AvahiSRecordBrowser *b = userdata;
+static void defer_callback(CATTA_GCC_UNUSED CattaTimeEvent *e, void *userdata) {
+    CattaSRecordBrowser *b = userdata;
     int n;
 
     assert(b);
@@ -462,7 +462,7 @@ static void defer_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void *userdata) {
 
     /* Remove the defer timeout */
     if (b->defer_time_event) {
-        avahi_time_event_free(b->defer_time_event);
+        catta_time_event_free(b->defer_time_event);
         b->defer_time_event = NULL;
     }
 
@@ -479,11 +479,11 @@ static void defer_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void *userdata) {
     if (n < 0) {
         /* sending of the initial query failed */
 
-        avahi_server_set_errno(b->server, AVAHI_ERR_FAILURE);
+        catta_server_set_errno(b->server, CATTA_ERR_FAILURE);
 
         b->callback(
-            b, b->interface, b->protocol, AVAHI_BROWSER_FAILURE, NULL,
-            b->flags & AVAHI_LOOKUP_USE_WIDE_AREA ? AVAHI_LOOKUP_RESULT_WIDE_AREA : AVAHI_LOOKUP_RESULT_MULTICAST,
+            b, b->interface, b->protocol, CATTA_BROWSER_FAILURE, NULL,
+            b->flags & CATTA_LOOKUP_USE_WIDE_AREA ? CATTA_LOOKUP_RESULT_WIDE_AREA : CATTA_LOOKUP_RESULT_MULTICAST,
             b->userdata);
 
         browser_cancel(b);
@@ -492,21 +492,21 @@ static void defer_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void *userdata) {
 
     /* Tell the client that we're done with the cache */
     b->callback(
-        b, b->interface, b->protocol, AVAHI_BROWSER_CACHE_EXHAUSTED, NULL,
-        b->flags & AVAHI_LOOKUP_USE_WIDE_AREA ? AVAHI_LOOKUP_RESULT_WIDE_AREA : AVAHI_LOOKUP_RESULT_MULTICAST,
+        b, b->interface, b->protocol, CATTA_BROWSER_CACHE_EXHAUSTED, NULL,
+        b->flags & CATTA_LOOKUP_USE_WIDE_AREA ? CATTA_LOOKUP_RESULT_WIDE_AREA : CATTA_LOOKUP_RESULT_MULTICAST,
         b->userdata);
 
-    if (!b->dead && b->root_lookup && b->root_lookup->flags & AVAHI_LOOKUP_USE_WIDE_AREA && n > 0) {
+    if (!b->dead && b->root_lookup && b->root_lookup->flags & CATTA_LOOKUP_USE_WIDE_AREA && n > 0) {
 
         /* If we do wide area lookups and the the cache contained
          * entries, we assume that it is complete, and tell the user
          * so by firing ALL_FOR_NOW. */
 
-        b->callback(b, b->interface, b->protocol, AVAHI_BROWSER_ALL_FOR_NOW, NULL, AVAHI_LOOKUP_RESULT_WIDE_AREA, b->userdata);
+        b->callback(b, b->interface, b->protocol, CATTA_BROWSER_ALL_FOR_NOW, NULL, CATTA_LOOKUP_RESULT_WIDE_AREA, b->userdata);
     }
 }
 
-void avahi_s_record_browser_restart(AvahiSRecordBrowser *b) {
+void catta_s_record_browser_restart(CattaSRecordBrowser *b) {
     assert(b);
     assert(!b->dead);
 
@@ -514,35 +514,35 @@ void avahi_s_record_browser_restart(AvahiSRecordBrowser *b) {
 
     /* Request a new iteration of the cache scanning */
     if (!b->defer_time_event) {
-        b->defer_time_event = avahi_time_event_new(b->server->time_event_queue, NULL, defer_callback, b);
+        b->defer_time_event = catta_time_event_new(b->server->time_event_queue, NULL, defer_callback, b);
         assert(b->defer_time_event);
     }
 }
 
-AvahiSRecordBrowser *avahi_s_record_browser_new(
-    AvahiServer *server,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiKey *key,
-    AvahiLookupFlags flags,
-    AvahiSRecordBrowserCallback callback,
+CattaSRecordBrowser *catta_s_record_browser_new(
+    CattaServer *server,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaKey *key,
+    CattaLookupFlags flags,
+    CattaSRecordBrowserCallback callback,
     void* userdata) {
 
-    AvahiSRecordBrowser *b;
+    CattaSRecordBrowser *b;
 
     assert(server);
     assert(key);
     assert(callback);
 
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, !avahi_key_is_pattern(key), AVAHI_ERR_IS_PATTERN);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, avahi_key_is_valid(key), AVAHI_ERR_INVALID_KEY);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_FLAGS_VALID(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, !(flags & AVAHI_LOOKUP_USE_WIDE_AREA) || !(flags & AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, !catta_key_is_pattern(key), CATTA_ERR_IS_PATTERN);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, catta_key_is_valid(key), CATTA_ERR_INVALID_KEY);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_FLAGS_VALID(flags, CATTA_LOOKUP_USE_WIDE_AREA|CATTA_LOOKUP_USE_MULTICAST), CATTA_ERR_INVALID_FLAGS);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, !(flags & CATTA_LOOKUP_USE_WIDE_AREA) || !(flags & CATTA_LOOKUP_USE_MULTICAST), CATTA_ERR_INVALID_FLAGS);
 
-    if (!(b = avahi_new(AvahiSRecordBrowser, 1))) {
-        avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
+    if (!(b = catta_new(CattaSRecordBrowser, 1))) {
+        catta_server_set_errno(server, CATTA_ERR_NO_MEMORY);
         return NULL;
     }
 
@@ -550,24 +550,24 @@ AvahiSRecordBrowser *avahi_s_record_browser_new(
     b->server = server;
     b->interface = interface;
     b->protocol = protocol;
-    b->key = avahi_key_ref(key);
+    b->key = catta_key_ref(key);
     b->flags = flags;
     b->callback = callback;
     b->userdata = userdata;
     b->n_lookups = 0;
-    AVAHI_LLIST_HEAD_INIT(AvahiSRBLookup, b->lookups);
+    CATTA_LLIST_HEAD_INIT(CattaSRBLookup, b->lookups);
     b->root_lookup = NULL;
 
-    AVAHI_LLIST_PREPEND(AvahiSRecordBrowser, browser, server->record_browsers, b);
+    CATTA_LLIST_PREPEND(CattaSRecordBrowser, browser, server->record_browsers, b);
 
     /* The currently cached entries are scanned a bit later, and than we will start querying, too */
-    b->defer_time_event = avahi_time_event_new(server->time_event_queue, NULL, defer_callback, b);
+    b->defer_time_event = catta_time_event_new(server->time_event_queue, NULL, defer_callback, b);
     assert(b->defer_time_event);
 
     return b;
 }
 
-void avahi_s_record_browser_free(AvahiSRecordBrowser *b) {
+void catta_s_record_browser_free(CattaSRecordBrowser *b) {
     assert(b);
     assert(!b->dead);
 
@@ -577,21 +577,21 @@ void avahi_s_record_browser_free(AvahiSRecordBrowser *b) {
     browser_cancel(b);
 }
 
-void avahi_s_record_browser_destroy(AvahiSRecordBrowser *b) {
+void catta_s_record_browser_destroy(CattaSRecordBrowser *b) {
     assert(b);
 
     browser_cancel(b);
 
-    AVAHI_LLIST_REMOVE(AvahiSRecordBrowser, browser, b->server->record_browsers, b);
+    CATTA_LLIST_REMOVE(CattaSRecordBrowser, browser, b->server->record_browsers, b);
 
-    avahi_key_unref(b->key);
+    catta_key_unref(b->key);
 
-    avahi_free(b);
+    catta_free(b);
 }
 
-void avahi_browser_cleanup(AvahiServer *server) {
-    AvahiSRecordBrowser *b;
-    AvahiSRecordBrowser *n;
+void catta_browser_cleanup(CattaServer *server) {
+    CattaSRecordBrowser *b;
+    CattaSRecordBrowser *n;
 
     assert(server);
 
@@ -602,12 +602,12 @@ void avahi_browser_cleanup(AvahiServer *server) {
             n = b->browser_next;
 
             if (b->dead)
-                avahi_s_record_browser_destroy(b);
+                catta_s_record_browser_destroy(b);
         }
     }
 
     if (server->wide_area_lookup_engine)
-        avahi_wide_area_cleanup(server->wide_area_lookup_engine);
-    avahi_multicast_lookup_engine_cleanup(server->multicast_lookup_engine);
+        catta_wide_area_cleanup(server->wide_area_lookup_engine);
+    catta_multicast_lookup_engine_cleanup(server->multicast_lookup_engine);
 }
 
index d09948bb9b64e25deaa80643308a84acd6667053..76b7a6d545b01340aff8ea5314cab14c4f2438ab 100644 (file)
@@ -2,59 +2,59 @@
 #define foobrowsehfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
-#include <avahi/llist.h>
-#include <avahi/core.h>
-#include <avahi/lookup.h>
+#include <catta/llist.h>
+#include <catta/core.h>
+#include <catta/lookup.h>
 
 #include "timeeventq.h"
 #include "internal.h"
 #include "dns.h"
 
-typedef struct AvahiSRBLookup AvahiSRBLookup;
+typedef struct CattaSRBLookup CattaSRBLookup;
 
-struct AvahiSRecordBrowser {
-    AVAHI_LLIST_FIELDS(AvahiSRecordBrowser, browser);
+struct CattaSRecordBrowser {
+    CATTA_LLIST_FIELDS(CattaSRecordBrowser, browser);
     int dead;
-    AvahiServer *server;
+    CattaServer *server;
 
-    AvahiKey *key;
-    AvahiIfIndex interface;
-    AvahiProtocol protocol;
-    AvahiLookupFlags flags;
+    CattaKey *key;
+    CattaIfIndex interface;
+    CattaProtocol protocol;
+    CattaLookupFlags flags;
 
-    AvahiTimeEvent *defer_time_event;
+    CattaTimeEvent *defer_time_event;
 
-    AvahiSRecordBrowserCallback callback;
+    CattaSRecordBrowserCallback callback;
     void* userdata;
 
     /* Lookup data */
-    AVAHI_LLIST_HEAD(AvahiSRBLookup, lookups);
+    CATTA_LLIST_HEAD(CattaSRBLookup, lookups);
     unsigned n_lookups;
 
-    AvahiSRBLookup *root_lookup;
+    CattaSRBLookup *root_lookup;
 };
 
-void avahi_browser_cleanup(AvahiServer *server);
+void catta_browser_cleanup(CattaServer *server);
 
-void avahi_s_record_browser_destroy(AvahiSRecordBrowser *b);
-void avahi_s_record_browser_restart(AvahiSRecordBrowser *b);
+void catta_s_record_browser_destroy(CattaSRecordBrowser *b);
+void catta_s_record_browser_restart(CattaSRecordBrowser *b);
 
 #endif
index 0fcc5a3aabc99a71f66f45d55ea3cf69abcb00b9..f4203ebffe8efed0dec35a1f6e526345b3b4ee78 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <stdlib.h>
 #include <time.h>
 
-#include <avahi/timeval.h>
-#include <avahi/malloc.h>
-#include <avahi/log.h>
+#include <catta/timeval.h>
+#include <catta/malloc.h>
+#include <catta/log.h>
 
 #include "cache.h"
 #include "rr-util.h"
 
-static void remove_entry(AvahiCache *c, AvahiCacheEntry *e) {
-    AvahiCacheEntry *t;
+static void remove_entry(CattaCache *c, CattaCacheEntry *e) {
+    CattaCacheEntry *t;
 
     assert(c);
     assert(e);
 
-/*     avahi_log_debug("removing from cache: %p %p", c, e); */
+/*     catta_log_debug("removing from cache: %p %p", c, e); */
 
     /* Remove from hash table */
-    t = avahi_hashmap_lookup(c->hashmap, e->record->key);
-    AVAHI_LLIST_REMOVE(AvahiCacheEntry, by_key, t, e);
+    t = catta_hashmap_lookup(c->hashmap, e->record->key);
+    CATTA_LLIST_REMOVE(CattaCacheEntry, by_key, t, e);
     if (t)
-        avahi_hashmap_replace(c->hashmap, t->record->key, t);
+        catta_hashmap_replace(c->hashmap, t->record->key, t);
     else
-        avahi_hashmap_remove(c->hashmap, e->record->key);
+        catta_hashmap_remove(c->hashmap, e->record->key);
 
     /* Remove from linked list */
-    AVAHI_LLIST_REMOVE(AvahiCacheEntry, entry, c->entries, e);
+    CATTA_LLIST_REMOVE(CattaCacheEntry, entry, c->entries, e);
 
     if (e->time_event)
-        avahi_time_event_free(e->time_event);
+        catta_time_event_free(e->time_event);
 
-    avahi_multicast_lookup_engine_notify(c->server->multicast_lookup_engine, c->interface, e->record, AVAHI_BROWSER_REMOVE);
+    catta_multicast_lookup_engine_notify(c->server->multicast_lookup_engine, c->interface, e->record, CATTA_BROWSER_REMOVE);
 
-    avahi_record_unref(e->record);
+    catta_record_unref(e->record);
 
-    avahi_free(e);
+    catta_free(e);
 
     assert(c->n_entries >= 1);
     --c->n_entries;
 }
 
-AvahiCache *avahi_cache_new(AvahiServer *server, AvahiInterface *iface) {
-    AvahiCache *c;
+CattaCache *catta_cache_new(CattaServer *server, CattaInterface *iface) {
+    CattaCache *c;
     assert(server);
 
-    if (!(c = avahi_new(AvahiCache, 1))) {
-        avahi_log_error(__FILE__": Out of memory.");
+    if (!(c = catta_new(CattaCache, 1))) {
+        catta_log_error(__FILE__": Out of memory.");
         return NULL; /* OOM */
     }
 
     c->server = server;
     c->interface = iface;
 
-    if (!(c->hashmap = avahi_hashmap_new((AvahiHashFunc) avahi_key_hash, (AvahiEqualFunc) avahi_key_equal, NULL, NULL))) {
-        avahi_log_error(__FILE__": Out of memory.");
-        avahi_free(c);
+    if (!(c->hashmap = catta_hashmap_new((CattaHashFunc) catta_key_hash, (CattaEqualFunc) catta_key_equal, NULL, NULL))) {
+        catta_log_error(__FILE__": Out of memory.");
+        catta_free(c);
         return NULL; /* OOM */
     }
 
-    AVAHI_LLIST_HEAD_INIT(AvahiCacheEntry, c->entries);
+    CATTA_LLIST_HEAD_INIT(CattaCacheEntry, c->entries);
     c->n_entries = 0;
 
     c->last_rand_timestamp = 0;
@@ -90,47 +90,47 @@ AvahiCache *avahi_cache_new(AvahiServer *server, AvahiInterface *iface) {
     return c;
 }
 
-void avahi_cache_free(AvahiCache *c) {
+void catta_cache_free(CattaCache *c) {
     assert(c);
 
     while (c->entries)
         remove_entry(c, c->entries);
     assert(c->n_entries == 0);
 
-    avahi_hashmap_free(c->hashmap);
+    catta_hashmap_free(c->hashmap);
 
-    avahi_free(c);
+    catta_free(c);
 }
 
-static AvahiCacheEntry *lookup_key(AvahiCache *c, AvahiKey *k) {
+static CattaCacheEntry *lookup_key(CattaCache *c, CattaKey *k) {
     assert(c);
     assert(k);
 
-    assert(!avahi_key_is_pattern(k));
+    assert(!catta_key_is_pattern(k));
 
-    return avahi_hashmap_lookup(c->hashmap, k);
+    return catta_hashmap_lookup(c->hashmap, k);
 }
 
-void* avahi_cache_walk(AvahiCache *c, AvahiKey *pattern, AvahiCacheWalkCallback cb, void* userdata) {
+void* catta_cache_walk(CattaCache *c, CattaKey *pattern, CattaCacheWalkCallback cb, void* userdata) {
     void* ret;
 
     assert(c);
     assert(pattern);
     assert(cb);
 
-    if (avahi_key_is_pattern(pattern)) {
-        AvahiCacheEntry *e, *n;
+    if (catta_key_is_pattern(pattern)) {
+        CattaCacheEntry *e, *n;
 
         for (e = c->entries; e; e = n) {
             n = e->entry_next;
 
-            if (avahi_key_pattern_match(pattern, e->record->key))
+            if (catta_key_pattern_match(pattern, e->record->key))
                 if ((ret = cb(c, pattern, e, userdata)))
                     return ret;
         }
 
     } else {
-        AvahiCacheEntry *e, *n;
+        CattaCacheEntry *e, *n;
 
         for (e = lookup_key(c, pattern); e; e = n) {
             n = e->by_key_next;
@@ -143,66 +143,66 @@ void* avahi_cache_walk(AvahiCache *c, AvahiKey *pattern, AvahiCacheWalkCallback
     return NULL;
 }
 
-static void* lookup_record_callback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEntry *e, void *userdata) {
+static void* lookup_record_callback(CattaCache *c, CattaKey *pattern, CattaCacheEntry *e, void *userdata) {
     assert(c);
     assert(pattern);
     assert(e);
 
-    if (avahi_record_equal_no_ttl(e->record, userdata))
+    if (catta_record_equal_no_ttl(e->record, userdata))
         return e;
 
     return NULL;
 }
 
-static AvahiCacheEntry *lookup_record(AvahiCache *c, AvahiRecord *r) {
+static CattaCacheEntry *lookup_record(CattaCache *c, CattaRecord *r) {
     assert(c);
     assert(r);
 
-    return avahi_cache_walk(c, r->key, lookup_record_callback, r);
+    return catta_cache_walk(c, r->key, lookup_record_callback, r);
 }
 
-static void next_expiry(AvahiCache *c, AvahiCacheEntry *e, unsigned percent);
+static void next_expiry(CattaCache *c, CattaCacheEntry *e, unsigned percent);
 
-static void elapse_func(AvahiTimeEvent *t, void *userdata) {
-    AvahiCacheEntry *e = userdata;
+static void elapse_func(CattaTimeEvent *t, void *userdata) {
+    CattaCacheEntry *e = userdata;
 /*     char *txt; */
     unsigned percent = 0;
 
     assert(t);
     assert(e);
 
-/*     txt = avahi_record_to_string(e->record); */
+/*     txt = catta_record_to_string(e->record); */
 
     switch (e->state) {
 
-        case AVAHI_CACHE_EXPIRY_FINAL:
-        case AVAHI_CACHE_POOF_FINAL:
-        case AVAHI_CACHE_GOODBYE_FINAL:
-        case AVAHI_CACHE_REPLACE_FINAL:
+        case CATTA_CACHE_EXPIRY_FINAL:
+        case CATTA_CACHE_POOF_FINAL:
+        case CATTA_CACHE_GOODBYE_FINAL:
+        case CATTA_CACHE_REPLACE_FINAL:
 
             remove_entry(e->cache, e);
 
             e = NULL;
-/*         avahi_log_debug("Removing entry from cache due to expiration (%s)", txt); */
+/*         catta_log_debug("Removing entry from cache due to expiration (%s)", txt); */
             break;
 
-        case AVAHI_CACHE_VALID:
-        case AVAHI_CACHE_POOF:
-            e->state = AVAHI_CACHE_EXPIRY1;
+        case CATTA_CACHE_VALID:
+        case CATTA_CACHE_POOF:
+            e->state = CATTA_CACHE_EXPIRY1;
             percent = 85;
             break;
 
-        case AVAHI_CACHE_EXPIRY1:
-            e->state = AVAHI_CACHE_EXPIRY2;
+        case CATTA_CACHE_EXPIRY1:
+            e->state = CATTA_CACHE_EXPIRY2;
             percent = 90;
             break;
-        case AVAHI_CACHE_EXPIRY2:
-            e->state = AVAHI_CACHE_EXPIRY3;
+        case CATTA_CACHE_EXPIRY2:
+            e->state = CATTA_CACHE_EXPIRY3;
             percent = 95;
             break;
 
-        case AVAHI_CACHE_EXPIRY3:
-            e->state = AVAHI_CACHE_EXPIRY_FINAL;
+        case CATTA_CACHE_EXPIRY3:
+            e->state = CATTA_CACHE_EXPIRY_FINAL;
             percent = 100;
             break;
     }
@@ -212,36 +212,36 @@ static void elapse_func(AvahiTimeEvent *t, void *userdata) {
         assert(percent > 0);
 
         /* Request a cache update if we are subscribed to this entry */
-        if (avahi_querier_shall_refresh_cache(e->cache->interface, e->record->key))
-            avahi_interface_post_query(e->cache->interface, e->record->key, 0, NULL);
+        if (catta_querier_shall_refresh_cache(e->cache->interface, e->record->key))
+            catta_interface_post_query(e->cache->interface, e->record->key, 0, NULL);
 
         /* Check again later */
         next_expiry(e->cache, e, percent);
 
     }
 
-/*     avahi_free(txt); */
+/*     catta_free(txt); */
 }
 
-static void update_time_event(AvahiCache *c, AvahiCacheEntry *e) {
+static void update_time_event(CattaCache *c, CattaCacheEntry *e) {
     assert(c);
     assert(e);
 
     if (e->time_event)
-        avahi_time_event_update(e->time_event, &e->expiry);
+        catta_time_event_update(e->time_event, &e->expiry);
     else
-        e->time_event = avahi_time_event_new(c->server->time_event_queue, &e->expiry, elapse_func, e);
+        e->time_event = catta_time_event_new(c->server->time_event_queue, &e->expiry, elapse_func, e);
 }
 
-static void next_expiry(AvahiCache *c, AvahiCacheEntry *e, unsigned percent) {
-    AvahiUsec usec, left, right;
+static void next_expiry(CattaCache *c, CattaCacheEntry *e, unsigned percent) {
+    CattaUsec usec, left, right;
     time_t now;
 
     assert(c);
     assert(e);
     assert(percent > 0 && percent <= 100);
 
-    usec = (AvahiUsec) e->record->ttl * 10000;
+    usec = (CattaUsec) e->record->ttl * 10000;
 
     left = usec * percent;
     right = usec * (percent+2); /* 2% jitter */
@@ -253,44 +253,44 @@ static void next_expiry(AvahiCache *c, AvahiCacheEntry *e, unsigned percent) {
         c->last_rand_timestamp = now;
     }
 
-    usec = left + (AvahiUsec) ((double) (right-left) * c->last_rand / (RAND_MAX+1.0));
+    usec = left + (CattaUsec) ((double) (right-left) * c->last_rand / (RAND_MAX+1.0));
 
     e->expiry = e->timestamp;
-    avahi_timeval_add(&e->expiry, usec);
+    catta_timeval_add(&e->expiry, usec);
 
 /*     g_message("wake up in +%lu seconds", e->expiry.tv_sec - e->timestamp.tv_sec); */
 
     update_time_event(c, e);
 }
 
-static void expire_in_one_second(AvahiCache *c, AvahiCacheEntry *e, AvahiCacheEntryState state) {
+static void expire_in_one_second(CattaCache *c, CattaCacheEntry *e, CattaCacheEntryState state) {
     assert(c);
     assert(e);
 
     e->state = state;
     gettimeofday(&e->expiry, NULL);
-    avahi_timeval_add(&e->expiry, 1000000); /* 1s */
+    catta_timeval_add(&e->expiry, 1000000); /* 1s */
     update_time_event(c, e);
 }
 
-void avahi_cache_update(AvahiCache *c, AvahiRecord *r, int cache_flush, const AvahiAddress *a) {
+void catta_cache_update(CattaCache *c, CattaRecord *r, int cache_flush, const CattaAddress *a) {
 /*     char *txt; */
 
     assert(c);
     assert(r && r->ref >= 1);
 
-/*     txt = avahi_record_to_string(r); */
+/*     txt = catta_record_to_string(r); */
 
     if (r->ttl == 0) {
         /* This is a goodbye request */
 
-        AvahiCacheEntry *e;
+        CattaCacheEntry *e;
 
         if ((e = lookup_record(c, r)))
-            expire_in_one_second(c, e, AVAHI_CACHE_GOODBYE_FINAL);
+            expire_in_one_second(c, e, CATTA_CACHE_GOODBYE_FINAL);
 
     } else {
-        AvahiCacheEntry *e = NULL, *first;
+        CattaCacheEntry *e = NULL, *first;
         struct timeval now;
 
         gettimeofday(&now, NULL);
@@ -303,84 +303,84 @@ void avahi_cache_update(AvahiCache *c, AvahiRecord *r, int cache_flush, const Av
 
                 /* For unique entries drop all entries older than one second */
                 for (e = first; e; e = e->by_key_next) {
-                    AvahiUsec t;
+                    CattaUsec t;
 
-                    t = avahi_timeval_diff(&now, &e->timestamp);
+                    t = catta_timeval_diff(&now, &e->timestamp);
 
                     if (t > 1000000)
-                        expire_in_one_second(c, e, AVAHI_CACHE_REPLACE_FINAL);
+                        expire_in_one_second(c, e, CATTA_CACHE_REPLACE_FINAL);
                 }
             }
 
             /* Look for exactly the same entry */
             for (e = first; e; e = e->by_key_next)
-                if (avahi_record_equal_no_ttl(e->record, r))
+                if (catta_record_equal_no_ttl(e->record, r))
                     break;
         }
 
         if (e) {
 
-/*             avahi_log_debug("found matching cache entry");  */
+/*             catta_log_debug("found matching cache entry");  */
 
             /* We need to update the hash table key if we replace the
              * record */
             if (e->by_key_prev == NULL)
-                avahi_hashmap_replace(c->hashmap, r->key, e);
+                catta_hashmap_replace(c->hashmap, r->key, e);
 
             /* Update the record */
-            avahi_record_unref(e->record);
-            e->record = avahi_record_ref(r);
+            catta_record_unref(e->record);
+            e->record = catta_record_ref(r);
 
-/*             avahi_log_debug("cache: updating %s", txt);   */
+/*             catta_log_debug("cache: updating %s", txt);   */
 
         } else {
             /* No entry found, therefore we create a new one */
 
-/*             avahi_log_debug("cache: couldn't find matching cache entry for %s", txt);   */
+/*             catta_log_debug("cache: couldn't find matching cache entry for %s", txt);   */
 
             if (c->n_entries >= c->server->config.n_cache_entries_max)
                 return;
 
-            if (!(e = avahi_new(AvahiCacheEntry, 1))) {
-                avahi_log_error(__FILE__": Out of memory");
+            if (!(e = catta_new(CattaCacheEntry, 1))) {
+                catta_log_error(__FILE__": Out of memory");
                 return;
             }
 
             e->cache = c;
             e->time_event = NULL;
-            e->record = avahi_record_ref(r);
+            e->record = catta_record_ref(r);
 
             /* Append to hash table */
-            AVAHI_LLIST_PREPEND(AvahiCacheEntry, by_key, first, e);
-            avahi_hashmap_replace(c->hashmap, e->record->key, first);
+            CATTA_LLIST_PREPEND(CattaCacheEntry, by_key, first, e);
+            catta_hashmap_replace(c->hashmap, e->record->key, first);
 
             /* Append to linked list */
-            AVAHI_LLIST_PREPEND(AvahiCacheEntry, entry, c->entries, e);
+            CATTA_LLIST_PREPEND(CattaCacheEntry, entry, c->entries, e);
 
             c->n_entries++;
 
             /* Notify subscribers */
-            avahi_multicast_lookup_engine_notify(c->server->multicast_lookup_engine, c->interface, e->record, AVAHI_BROWSER_NEW);
+            catta_multicast_lookup_engine_notify(c->server->multicast_lookup_engine, c->interface, e->record, CATTA_BROWSER_NEW);
         }
 
         e->origin = *a;
         e->timestamp = now;
         next_expiry(c, e, 80);
-        e->state = AVAHI_CACHE_VALID;
+        e->state = CATTA_CACHE_VALID;
         e->cache_flush = cache_flush;
     }
 
-/*     avahi_free(txt);  */
+/*     catta_free(txt);  */
 }
 
 struct dump_data {
-    AvahiDumpCallback callback;
+    CattaDumpCallback callback;
     void* userdata;
 };
 
 static void dump_callback(void* key, void* data, void* userdata) {
-    AvahiCacheEntry *e = data;
-    AvahiKey *k = key;
+    CattaCacheEntry *e = data;
+    CattaKey *k = key;
     struct dump_data *dump_data = userdata;
 
     assert(k);
@@ -390,15 +390,15 @@ static void dump_callback(void* key, void* data, void* userdata) {
     for (; e; e = e->by_key_next) {
         char *t;
 
-        if (!(t = avahi_record_to_string(e->record)))
+        if (!(t = catta_record_to_string(e->record)))
             continue; /* OOM */
 
         dump_data->callback(t, dump_data->userdata);
-        avahi_free(t);
+        catta_free(t);
     }
 }
 
-int avahi_cache_dump(AvahiCache *c, AvahiDumpCallback callback, void* userdata) {
+int catta_cache_dump(CattaCache *c, CattaDumpCallback callback, void* userdata) {
     struct dump_data data;
 
     assert(c);
@@ -409,12 +409,12 @@ int avahi_cache_dump(AvahiCache *c, AvahiDumpCallback callback, void* userdata)
     data.callback = callback;
     data.userdata = userdata;
 
-    avahi_hashmap_foreach(c->hashmap, dump_callback, &data);
+    catta_hashmap_foreach(c->hashmap, dump_callback, &data);
 
     return 0;
 }
 
-int avahi_cache_entry_half_ttl(AvahiCache *c, AvahiCacheEntry *e) {
+int catta_cache_entry_half_ttl(CattaCache *c, CattaCacheEntry *e) {
     struct timeval now;
     unsigned age;
 
@@ -423,14 +423,14 @@ int avahi_cache_entry_half_ttl(AvahiCache *c, AvahiCacheEntry *e) {
 
     gettimeofday(&now, NULL);
 
-    age = (unsigned) (avahi_timeval_diff(&now, &e->timestamp)/1000000);
+    age = (unsigned) (catta_timeval_diff(&now, &e->timestamp)/1000000);
 
-/*     avahi_log_debug("age: %lli, ttl/2: %u", age, e->record->ttl);  */
+/*     catta_log_debug("age: %lli, ttl/2: %u", age, e->record->ttl);  */
 
     return age >= e->record->ttl/2;
 }
 
-void avahi_cache_flush(AvahiCache *c) {
+void catta_cache_flush(CattaCache *c) {
     assert(c);
 
     while (c->entries)
@@ -439,8 +439,8 @@ void avahi_cache_flush(AvahiCache *c) {
 
 /*** Passive observation of failure ***/
 
-static void* start_poof_callback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEntry *e, void *userdata) {
-    AvahiAddress *a = userdata;
+static void* start_poof_callback(CattaCache *c, CattaKey *pattern, CattaCacheEntry *e, void *userdata) {
+    CattaAddress *a = userdata;
     struct timeval now;
 
     assert(c);
@@ -451,20 +451,20 @@ static void* start_poof_callback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEnt
     gettimeofday(&now, NULL);
 
     switch (e->state) {
-        case AVAHI_CACHE_VALID:
+        case CATTA_CACHE_VALID:
 
             /* The entry was perfectly valid till, now, so let's enter
              * POOF mode */
 
-            e->state = AVAHI_CACHE_POOF;
+            e->state = CATTA_CACHE_POOF;
             e->poof_address = *a;
             e->poof_timestamp = now;
             e->poof_num = 0;
 
             break;
 
-        case AVAHI_CACHE_POOF:
-            if (avahi_timeval_diff(&now, &e->poof_timestamp) < 1000000)
+        case CATTA_CACHE_POOF:
+            if (catta_timeval_diff(&now, &e->poof_timestamp) < 1000000)
               break;
 
             e->poof_timestamp = now;
@@ -474,7 +474,7 @@ static void* start_poof_callback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEnt
             /* This is the 4th time we got no response, so let's
              * fucking remove this entry. */
             if (e->poof_num > 3)
-              expire_in_one_second(c, e, AVAHI_CACHE_POOF_FINAL);
+              expire_in_one_second(c, e, CATTA_CACHE_POOF_FINAL);
             break;
 
         default:
@@ -484,15 +484,15 @@ static void* start_poof_callback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEnt
     return NULL;
 }
 
-void avahi_cache_start_poof(AvahiCache *c, AvahiKey *key, const AvahiAddress *a) {
+void catta_cache_start_poof(CattaCache *c, CattaKey *key, const CattaAddress *a) {
     assert(c);
     assert(key);
 
-    avahi_cache_walk(c, key, start_poof_callback, (void*) a);
+    catta_cache_walk(c, key, start_poof_callback, (void*) a);
 }
 
-void avahi_cache_stop_poof(AvahiCache *c, AvahiRecord *record, const AvahiAddress *a) {
-    AvahiCacheEntry *e;
+void catta_cache_stop_poof(CattaCache *c, CattaRecord *record, const CattaAddress *a) {
+    CattaCacheEntry *e;
 
     assert(c);
     assert(record);
@@ -505,9 +505,9 @@ void avahi_cache_stop_poof(AvahiCache *c, AvahiRecord *record, const AvahiAddres
        record. If the matching cache entry is in POOF state and the
        query address is the same, we put it back into valid mode */
 
-    if (e->state == AVAHI_CACHE_POOF || e->state == AVAHI_CACHE_POOF_FINAL)
-        if (avahi_address_cmp(a, &e->poof_address) == 0) {
-            e->state = AVAHI_CACHE_VALID;
+    if (e->state == CATTA_CACHE_POOF || e->state == CATTA_CACHE_POOF_FINAL)
+        if (catta_address_cmp(a, &e->poof_address) == 0) {
+            e->state = CATTA_CACHE_VALID;
             next_expiry(c, e, 80);
         }
 }
index a1c8db3c77f676de65ed5c2b1253638cd29e712b..a205b705d44f75d7d2916ddd8dae6dbacadb3f0c 100644 (file)
@@ -2,74 +2,74 @@
 #define foocachehfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
-typedef struct AvahiCache AvahiCache;
+typedef struct CattaCache CattaCache;
 
-#include <avahi/llist.h>
+#include <catta/llist.h>
 #include "prioq.h"
 #include "internal.h"
 #include "timeeventq.h"
 #include "hashmap.h"
 
 typedef enum {
-    AVAHI_CACHE_VALID,
-    AVAHI_CACHE_EXPIRY1,
-    AVAHI_CACHE_EXPIRY2,
-    AVAHI_CACHE_EXPIRY3,
-    AVAHI_CACHE_EXPIRY_FINAL,
-    AVAHI_CACHE_POOF,       /* Passive observation of failure */
-    AVAHI_CACHE_POOF_FINAL,
-    AVAHI_CACHE_GOODBYE_FINAL,
-    AVAHI_CACHE_REPLACE_FINAL
-} AvahiCacheEntryState;
-
-typedef struct AvahiCacheEntry AvahiCacheEntry;
-
-struct AvahiCacheEntry {
-    AvahiCache *cache;
-    AvahiRecord *record;
+    CATTA_CACHE_VALID,
+    CATTA_CACHE_EXPIRY1,
+    CATTA_CACHE_EXPIRY2,
+    CATTA_CACHE_EXPIRY3,
+    CATTA_CACHE_EXPIRY_FINAL,
+    CATTA_CACHE_POOF,       /* Passive observation of failure */
+    CATTA_CACHE_POOF_FINAL,
+    CATTA_CACHE_GOODBYE_FINAL,
+    CATTA_CACHE_REPLACE_FINAL
+} CattaCacheEntryState;
+
+typedef struct CattaCacheEntry CattaCacheEntry;
+
+struct CattaCacheEntry {
+    CattaCache *cache;
+    CattaRecord *record;
     struct timeval timestamp;
     struct timeval poof_timestamp;
     struct timeval expiry;
     int cache_flush;
     int poof_num;
 
-    AvahiAddress origin;
+    CattaAddress origin;
 
-    AvahiCacheEntryState state;
-    AvahiTimeEvent *time_event;
+    CattaCacheEntryState state;
+    CattaTimeEvent *time_event;
 
-    AvahiAddress poof_address;
+    CattaAddress poof_address;
 
-    AVAHI_LLIST_FIELDS(AvahiCacheEntry, by_key);
-    AVAHI_LLIST_FIELDS(AvahiCacheEntry, entry);
+    CATTA_LLIST_FIELDS(CattaCacheEntry, by_key);
+    CATTA_LLIST_FIELDS(CattaCacheEntry, entry);
 };
 
-struct AvahiCache {
-    AvahiServer *server;
+struct CattaCache {
+    CattaServer *server;
 
-    AvahiInterface *interface;
+    CattaInterface *interface;
 
-    AvahiHashmap *hashmap;
+    CattaHashmap *hashmap;
 
-    AVAHI_LLIST_HEAD(AvahiCacheEntry, entries);
+    CATTA_LLIST_HEAD(CattaCacheEntry, entries);
 
     unsigned n_entries;
 
@@ -77,25 +77,25 @@ struct AvahiCache {
     time_t last_rand_timestamp;
 };
 
-AvahiCache *avahi_cache_new(AvahiServer *server, AvahiInterface *interface);
-void avahi_cache_free(AvahiCache *c);
+CattaCache *catta_cache_new(CattaServer *server, CattaInterface *interface);
+void catta_cache_free(CattaCache *c);
 
-void avahi_cache_update(AvahiCache *c, AvahiRecord *r, int cache_flush, const AvahiAddress *a);
+void catta_cache_update(CattaCache *c, CattaRecord *r, int cache_flush, const CattaAddress *a);
 
-int avahi_cache_dump(AvahiCache *c, AvahiDumpCallback callback, void* userdata);
+int catta_cache_dump(CattaCache *c, CattaDumpCallback callback, void* userdata);
 
-typedef void* AvahiCacheWalkCallback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEntry *e, void* userdata);
-void* avahi_cache_walk(AvahiCache *c, AvahiKey *pattern, AvahiCacheWalkCallback cb, void* userdata);
+typedef void* CattaCacheWalkCallback(CattaCache *c, CattaKey *pattern, CattaCacheEntry *e, void* userdata);
+void* catta_cache_walk(CattaCache *c, CattaKey *pattern, CattaCacheWalkCallback cb, void* userdata);
 
-int avahi_cache_entry_half_ttl(AvahiCache *c, AvahiCacheEntry *e);
+int catta_cache_entry_half_ttl(CattaCache *c, CattaCacheEntry *e);
 
 /** Start the "Passive observation of Failure" algorithm for all
  * records of the specified key. The specified address is  */
-void avahi_cache_start_poof(AvahiCache *c, AvahiKey *key, const AvahiAddress *a);
+void catta_cache_start_poof(CattaCache *c, CattaKey *key, const CattaAddress *a);
 
 /* Stop a previously started POOF algorithm for a record. (Used for response suppresions records */
-void avahi_cache_stop_poof(AvahiCache *c, AvahiRecord *record, const AvahiAddress *a);
+void catta_cache_stop_poof(CattaCache *c, CattaRecord *record, const CattaAddress *a);
 
-void avahi_cache_flush(AvahiCache *c);
+void catta_cache_flush(CattaCache *c);
 
 #endif
index c52111bbe3bcd0eb983eca533e53182a5a1d940e..e028f2b5a4b5b234aba1ccf6ac3c2078d647584e 100644 (file)
@@ -2,86 +2,86 @@
 #define foodnssrvhfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
-/** \file avahi/dns-srv-rr.h Functions for announcing and browsing for unicast DNS servers via mDNS */
+/** \file catta/dns-srv-rr.h Functions for announcing and browsing for unicast DNS servers via mDNS */
 
 /** A domain service browser object. Use this to browse for
  * conventional unicast DNS servers which may be used to resolve
  * conventional domain names */
-typedef struct AvahiSDNSServerBrowser AvahiSDNSServerBrowser;
+typedef struct CattaSDNSServerBrowser CattaSDNSServerBrowser;
 
-#include <avahi/cdecl.h>
-#include <avahi/defs.h>
-#include <avahi/core.h>
-#include <avahi/publish.h>
+#include <catta/cdecl.h>
+#include <catta/defs.h>
+#include <catta/core.h>
+#include <catta/publish.h>
 
-AVAHI_C_DECL_BEGIN
+CATTA_C_DECL_BEGIN
 
 /** The type of DNS server */
 typedef enum {
-    AVAHI_DNS_SERVER_RESOLVE,         /**< Unicast DNS servers for normal resolves (_domain._udp)*/
-    AVAHI_DNS_SERVER_UPDATE,           /**< Unicast DNS servers for updates (_dns-update._udp)*/
-    AVAHI_DNS_SERVER_MAX
-} AvahiDNSServerType;
+    CATTA_DNS_SERVER_RESOLVE,         /**< Unicast DNS servers for normal resolves (_domain._udp)*/
+    CATTA_DNS_SERVER_UPDATE,           /**< Unicast DNS servers for updates (_dns-update._udp)*/
+    CATTA_DNS_SERVER_MAX
+} CattaDNSServerType;
 
 /** Publish the specified unicast DNS server address via mDNS. You may
  * browse for records create this way wit
- * avahi_s_dns_server_browser_new(). */
-int avahi_server_add_dns_server_address(
-    AvahiServer *s,
-    AvahiSEntryGroup *g,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiPublishFlags flags,
+ * catta_s_dns_server_browser_new(). */
+int catta_server_add_dns_server_address(
+    CattaServer *s,
+    CattaSEntryGroup *g,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaPublishFlags flags,
     const char *domain,
-    AvahiDNSServerType type,
-    const AvahiAddress *address,
+    CattaDNSServerType type,
+    const CattaAddress *address,
     uint16_t port /** should be 53 */);
 
-/** Callback prototype for AvahiSDNSServerBrowser events */
-typedef void (*AvahiSDNSServerBrowserCallback)(
-    AvahiSDNSServerBrowser *b,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiBrowserEvent event,
+/** Callback prototype for CattaSDNSServerBrowser events */
+typedef void (*CattaSDNSServerBrowserCallback)(
+    CattaSDNSServerBrowser *b,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaBrowserEvent event,
     const char *host_name,       /**< Host name of the DNS server, probably useless */
-    const AvahiAddress *a,        /**< Address of the DNS server */
+    const CattaAddress *a,        /**< Address of the DNS server */
     uint16_t port,                 /**< Port number of the DNS servers, probably 53 */
-    AvahiLookupResultFlags flags,  /**< Lookup flags */
+    CattaLookupResultFlags flags,  /**< Lookup flags */
     void* userdata);
 
-/** Create a new AvahiSDNSServerBrowser object */
-AvahiSDNSServerBrowser *avahi_s_dns_server_browser_new(
-    AvahiServer *server,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
+/** Create a new CattaSDNSServerBrowser object */
+CattaSDNSServerBrowser *catta_s_dns_server_browser_new(
+    CattaServer *server,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
     const char *domain,
-    AvahiDNSServerType type,
-    AvahiProtocol aprotocol,  /**< Address protocol for the DNS server */
-    AvahiLookupFlags flags,                 /**< Lookup flags. */
-    AvahiSDNSServerBrowserCallback callback,
+    CattaDNSServerType type,
+    CattaProtocol aprotocol,  /**< Address protocol for the DNS server */
+    CattaLookupFlags flags,                 /**< Lookup flags. */
+    CattaSDNSServerBrowserCallback callback,
     void* userdata);
 
-/** Free an AvahiSDNSServerBrowser object */
-void avahi_s_dns_server_browser_free(AvahiSDNSServerBrowser *b);
+/** Free an CattaSDNSServerBrowser object */
+void catta_s_dns_server_browser_free(CattaSDNSServerBrowser *b);
 
-AVAHI_C_DECL_END
+CATTA_C_DECL_END
 
 #endif
index 2a704cb8c887468aaab6c7696e993b29b78bb3df..d98a0296c24381b22155769894b7ab62a012a02f 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <sys/types.h>
 #include <netinet/in.h>
 
-#include <avahi/defs.h>
-#include <avahi/domain.h>
-#include <avahi/malloc.h>
+#include <catta/defs.h>
+#include <catta/domain.h>
+#include <catta/malloc.h>
 
 #include "dns.h"
-#include <avahi/log.h>
+#include <catta/log.h>
 
-AvahiDnsPacket* avahi_dns_packet_new(unsigned mtu) {
-    AvahiDnsPacket *p;
+CattaDnsPacket* catta_dns_packet_new(unsigned mtu) {
+    CattaDnsPacket *p;
     size_t max_size;
 
     if (mtu <= 0)
-        max_size = AVAHI_DNS_PACKET_SIZE_MAX;
-    else if (mtu >= AVAHI_DNS_PACKET_EXTRA_SIZE)
-        max_size = mtu - AVAHI_DNS_PACKET_EXTRA_SIZE;
+        max_size = CATTA_DNS_PACKET_SIZE_MAX;
+    else if (mtu >= CATTA_DNS_PACKET_EXTRA_SIZE)
+        max_size = mtu - CATTA_DNS_PACKET_EXTRA_SIZE;
     else
         max_size = 0;
 
-    if (max_size < AVAHI_DNS_PACKET_HEADER_SIZE)
-        max_size = AVAHI_DNS_PACKET_HEADER_SIZE;
+    if (max_size < CATTA_DNS_PACKET_HEADER_SIZE)
+        max_size = CATTA_DNS_PACKET_HEADER_SIZE;
 
-    if (!(p = avahi_malloc(sizeof(AvahiDnsPacket) + max_size)))
+    if (!(p = catta_malloc(sizeof(CattaDnsPacket) + max_size)))
         return p;
 
-    p->size = p->rindex = AVAHI_DNS_PACKET_HEADER_SIZE;
+    p->size = p->rindex = CATTA_DNS_PACKET_HEADER_SIZE;
     p->max_size = max_size;
     p->name_table = NULL;
     p->data = NULL;
 
-    memset(AVAHI_DNS_PACKET_DATA(p), 0, p->size);
+    memset(CATTA_DNS_PACKET_DATA(p), 0, p->size);
     return p;
 }
 
-AvahiDnsPacket* avahi_dns_packet_new_query(unsigned mtu) {
-    AvahiDnsPacket *p;
+CattaDnsPacket* catta_dns_packet_new_query(unsigned mtu) {
+    CattaDnsPacket *p;
 
-    if (!(p = avahi_dns_packet_new(mtu)))
+    if (!(p = catta_dns_packet_new(mtu)))
         return NULL;
 
-    avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_FLAGS, AVAHI_DNS_FLAGS(0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
+    catta_dns_packet_set_field(p, CATTA_DNS_FIELD_FLAGS, CATTA_DNS_FLAGS(0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
     return p;
 }
 
-AvahiDnsPacket* avahi_dns_packet_new_response(unsigned mtu, int aa) {
-    AvahiDnsPacket *p;
+CattaDnsPacket* catta_dns_packet_new_response(unsigned mtu, int aa) {
+    CattaDnsPacket *p;
 
-    if (!(p = avahi_dns_packet_new(mtu)))
+    if (!(p = catta_dns_packet_new(mtu)))
         return NULL;
 
-    avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_FLAGS, AVAHI_DNS_FLAGS(1, 0, aa, 0, 0, 0, 0, 0, 0, 0));
+    catta_dns_packet_set_field(p, CATTA_DNS_FIELD_FLAGS, CATTA_DNS_FLAGS(1, 0, aa, 0, 0, 0, 0, 0, 0, 0));
     return p;
 }
 
-AvahiDnsPacket* avahi_dns_packet_new_reply(AvahiDnsPacket* p, unsigned mtu, int copy_queries, int aa) {
-    AvahiDnsPacket *r;
+CattaDnsPacket* catta_dns_packet_new_reply(CattaDnsPacket* p, unsigned mtu, int copy_queries, int aa) {
+    CattaDnsPacket *r;
     assert(p);
 
-    if (!(r = avahi_dns_packet_new_response(mtu, aa)))
+    if (!(r = catta_dns_packet_new_response(mtu, aa)))
         return NULL;
 
     if (copy_queries) {
@@ -94,77 +94,77 @@ AvahiDnsPacket* avahi_dns_packet_new_reply(AvahiDnsPacket* p, unsigned mtu, int
         uint32_t n;
 
         saved_rindex = p->rindex;
-        p->rindex = AVAHI_DNS_PACKET_HEADER_SIZE;
+        p->rindex = CATTA_DNS_PACKET_HEADER_SIZE;
 
-        for (n = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_QDCOUNT); n > 0; n--) {
-            AvahiKey *k;
+        for (n = catta_dns_packet_get_field(p, CATTA_DNS_FIELD_QDCOUNT); n > 0; n--) {
+            CattaKey *k;
             int unicast_response;
 
-            if ((k = avahi_dns_packet_consume_key(p, &unicast_response))) {
-                avahi_dns_packet_append_key(r, k, unicast_response);
-                avahi_key_unref(k);
+            if ((k = catta_dns_packet_consume_key(p, &unicast_response))) {
+                catta_dns_packet_append_key(r, k, unicast_response);
+                catta_key_unref(k);
             }
         }
 
         p->rindex = saved_rindex;
 
-        avahi_dns_packet_set_field(r, AVAHI_DNS_FIELD_QDCOUNT, avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_QDCOUNT));
+        catta_dns_packet_set_field(r, CATTA_DNS_FIELD_QDCOUNT, catta_dns_packet_get_field(p, CATTA_DNS_FIELD_QDCOUNT));
     }
 
-    avahi_dns_packet_set_field(r, AVAHI_DNS_FIELD_ID, avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ID));
+    catta_dns_packet_set_field(r, CATTA_DNS_FIELD_ID, catta_dns_packet_get_field(p, CATTA_DNS_FIELD_ID));
 
-    avahi_dns_packet_set_field(r, AVAHI_DNS_FIELD_FLAGS,
-                               (avahi_dns_packet_get_field(r, AVAHI_DNS_FIELD_FLAGS) & ~AVAHI_DNS_FLAG_OPCODE) |
-                               (avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_FLAGS) & AVAHI_DNS_FLAG_OPCODE));
+    catta_dns_packet_set_field(r, CATTA_DNS_FIELD_FLAGS,
+                               (catta_dns_packet_get_field(r, CATTA_DNS_FIELD_FLAGS) & ~CATTA_DNS_FLAG_OPCODE) |
+                               (catta_dns_packet_get_field(p, CATTA_DNS_FIELD_FLAGS) & CATTA_DNS_FLAG_OPCODE));
 
     return r;
 }
 
 
-void avahi_dns_packet_free(AvahiDnsPacket *p) {
+void catta_dns_packet_free(CattaDnsPacket *p) {
     assert(p);
 
     if (p->name_table)
-        avahi_hashmap_free(p->name_table);
+        catta_hashmap_free(p->name_table);
 
-    avahi_free(p);
+    catta_free(p);
 }
 
-void avahi_dns_packet_set_field(AvahiDnsPacket *p, unsigned idx, uint16_t v) {
+void catta_dns_packet_set_field(CattaDnsPacket *p, unsigned idx, uint16_t v) {
     assert(p);
-    assert(idx < AVAHI_DNS_PACKET_HEADER_SIZE);
+    assert(idx < CATTA_DNS_PACKET_HEADER_SIZE);
 
-    ((uint16_t*) AVAHI_DNS_PACKET_DATA(p))[idx] = htons(v);
+    ((uint16_t*) CATTA_DNS_PACKET_DATA(p))[idx] = htons(v);
 }
 
-uint16_t avahi_dns_packet_get_field(AvahiDnsPacket *p, unsigned idx) {
+uint16_t catta_dns_packet_get_field(CattaDnsPacket *p, unsigned idx) {
     assert(p);
-    assert(idx < AVAHI_DNS_PACKET_HEADER_SIZE);
+    assert(idx < CATTA_DNS_PACKET_HEADER_SIZE);
 
-    return ntohs(((uint16_t*) AVAHI_DNS_PACKET_DATA(p))[idx]);
+    return ntohs(((uint16_t*) CATTA_DNS_PACKET_DATA(p))[idx]);
 }
 
-void avahi_dns_packet_inc_field(AvahiDnsPacket *p, unsigned idx) {
+void catta_dns_packet_inc_field(CattaDnsPacket *p, unsigned idx) {
     assert(p);
-    assert(idx < AVAHI_DNS_PACKET_HEADER_SIZE);
+    assert(idx < CATTA_DNS_PACKET_HEADER_SIZE);
 
-    avahi_dns_packet_set_field(p, idx, avahi_dns_packet_get_field(p, idx) + 1);
+    catta_dns_packet_set_field(p, idx, catta_dns_packet_get_field(p, idx) + 1);
 }
 
 
 static void name_table_cleanup(void *key, void *value, void *user_data) {
-    AvahiDnsPacket *p = user_data;
+    CattaDnsPacket *p = user_data;
 
-    if ((uint8_t*) value >= AVAHI_DNS_PACKET_DATA(p) + p->size)
-        avahi_hashmap_remove(p->name_table, key);
+    if ((uint8_t*) value >= CATTA_DNS_PACKET_DATA(p) + p->size)
+        catta_hashmap_remove(p->name_table, key);
 }
 
-void avahi_dns_packet_cleanup_name_table(AvahiDnsPacket *p) {
+void catta_dns_packet_cleanup_name_table(CattaDnsPacket *p) {
     if (p->name_table)
-        avahi_hashmap_foreach(p->name_table, name_table_cleanup, p);
+        catta_hashmap_foreach(p->name_table, name_table_cleanup, p);
 }
 
-uint8_t* avahi_dns_packet_append_name(AvahiDnsPacket *p, const char *name) {
+uint8_t* catta_dns_packet_append_name(CattaDnsPacket *p, const char *name) {
     uint8_t *d, *saved_ptr = NULL;
     size_t saved_size;
 
@@ -172,7 +172,7 @@ uint8_t* avahi_dns_packet_append_name(AvahiDnsPacket *p, const char *name) {
     assert(name);
 
     saved_size = p->size;
-    saved_ptr = avahi_dns_packet_extend(p, 0);
+    saved_ptr = catta_dns_packet_extend(p, 0);
 
     while (*name) {
         uint8_t* prev;
@@ -181,17 +181,17 @@ uint8_t* avahi_dns_packet_append_name(AvahiDnsPacket *p, const char *name) {
 
         /* Check whether we can compress this name. */
 
-        if (p->name_table && (prev = avahi_hashmap_lookup(p->name_table, name))) {
+        if (p->name_table && (prev = catta_hashmap_lookup(p->name_table, name))) {
             unsigned idx;
 
-            assert(prev >= AVAHI_DNS_PACKET_DATA(p));
-            idx = (unsigned) (prev - AVAHI_DNS_PACKET_DATA(p));
+            assert(prev >= CATTA_DNS_PACKET_DATA(p));
+            idx = (unsigned) (prev - CATTA_DNS_PACKET_DATA(p));
 
             assert(idx < p->size);
 
             if (idx < 0x4000) {
                 uint8_t *t;
-                if (!(t = (uint8_t*) avahi_dns_packet_extend(p, sizeof(uint16_t))))
+                if (!(t = (uint8_t*) catta_dns_packet_extend(p, sizeof(uint16_t))))
                     return NULL;
 
                t[0] = (uint8_t) ((0xC000 | idx) >> 8);
@@ -202,23 +202,23 @@ uint8_t* avahi_dns_packet_append_name(AvahiDnsPacket *p, const char *name) {
 
         pname = name;
 
-        if (!(avahi_unescape_label(&name, label, sizeof(label))))
+        if (!(catta_unescape_label(&name, label, sizeof(label))))
             goto fail;
 
-        if (!(d = avahi_dns_packet_append_string(p, label)))
+        if (!(d = catta_dns_packet_append_string(p, label)))
             goto fail;
 
         if (!p->name_table)
             /* This works only for normalized domain names */
-            p->name_table = avahi_hashmap_new(avahi_string_hash, avahi_string_equal, avahi_free, NULL);
+            p->name_table = catta_hashmap_new(catta_string_hash, catta_string_equal, catta_free, NULL);
 
-        if (!(u = avahi_strdup(pname)))
-            avahi_log_error("avahi_strdup() failed.");
+        if (!(u = catta_strdup(pname)))
+            catta_log_error("catta_strdup() failed.");
         else
-            avahi_hashmap_insert(p->name_table, u, d);
+            catta_hashmap_insert(p->name_table, u, d);
     }
 
-    if (!(d = avahi_dns_packet_extend(p, 1)))
+    if (!(d = catta_dns_packet_extend(p, 1)))
         goto fail;
 
     *d = 0;
@@ -227,16 +227,16 @@ uint8_t* avahi_dns_packet_append_name(AvahiDnsPacket *p, const char *name) {
 
 fail:
     p->size = saved_size;
-    avahi_dns_packet_cleanup_name_table(p);
+    catta_dns_packet_cleanup_name_table(p);
 
     return NULL;
 }
 
-uint8_t* avahi_dns_packet_append_uint16(AvahiDnsPacket *p, uint16_t v) {
+uint8_t* catta_dns_packet_append_uint16(CattaDnsPacket *p, uint16_t v) {
     uint8_t *d;
     assert(p);
 
-    if (!(d = avahi_dns_packet_extend(p, sizeof(uint16_t))))
+    if (!(d = catta_dns_packet_extend(p, sizeof(uint16_t))))
         return NULL;
 
     d[0] = (uint8_t) (v >> 8);
@@ -244,11 +244,11 @@ uint8_t* avahi_dns_packet_append_uint16(AvahiDnsPacket *p, uint16_t v) {
     return d;
 }
 
-uint8_t *avahi_dns_packet_append_uint32(AvahiDnsPacket *p, uint32_t v) {
+uint8_t *catta_dns_packet_append_uint32(CattaDnsPacket *p, uint32_t v) {
     uint8_t *d;
     assert(p);
 
-    if (!(d = avahi_dns_packet_extend(p, sizeof(uint32_t))))
+    if (!(d = catta_dns_packet_extend(p, sizeof(uint32_t))))
         return NULL;
 
     d[0] = (uint8_t) (v >> 24);
@@ -259,21 +259,21 @@ uint8_t *avahi_dns_packet_append_uint32(AvahiDnsPacket *p, uint32_t v) {
     return d;
 }
 
-uint8_t *avahi_dns_packet_append_bytes(AvahiDnsPacket  *p, const void *b, size_t l) {
+uint8_t *catta_dns_packet_append_bytes(CattaDnsPacket  *p, const void *b, size_t l) {
     uint8_t* d;
 
     assert(p);
     assert(b);
     assert(l);
 
-    if (!(d = avahi_dns_packet_extend(p, l)))
+    if (!(d = catta_dns_packet_extend(p, l)))
         return NULL;
 
     memcpy(d, b, l);
     return d;
 }
 
-uint8_t* avahi_dns_packet_append_string(AvahiDnsPacket *p, const char *s) {
+uint8_t* catta_dns_packet_append_string(CattaDnsPacket *p, const char *s) {
     uint8_t* d;
     size_t k;
 
@@ -283,7 +283,7 @@ uint8_t* avahi_dns_packet_append_string(AvahiDnsPacket *p, const char *s) {
     if ((k = strlen(s)) >= 255)
         k = 255;
 
-    if (!(d = avahi_dns_packet_extend(p, k+1)))
+    if (!(d = catta_dns_packet_extend(p, k+1)))
         return NULL;
 
     *d = (uint8_t) k;
@@ -292,7 +292,7 @@ uint8_t* avahi_dns_packet_append_string(AvahiDnsPacket *p, const char *s) {
     return d;
 }
 
-uint8_t *avahi_dns_packet_extend(AvahiDnsPacket *p, size_t l) {
+uint8_t *catta_dns_packet_extend(CattaDnsPacket *p, size_t l) {
     uint8_t *d;
 
     assert(p);
@@ -300,49 +300,49 @@ uint8_t *avahi_dns_packet_extend(AvahiDnsPacket *p, size_t l) {
     if (p->size+l > p->max_size)
         return NULL;
 
-    d = AVAHI_DNS_PACKET_DATA(p) + p->size;
+    d = CATTA_DNS_PACKET_DATA(p) + p->size;
     p->size += l;
 
     return d;
 }
 
-int avahi_dns_packet_check_valid(AvahiDnsPacket *p) {
+int catta_dns_packet_check_valid(CattaDnsPacket *p) {
     uint16_t flags;
     assert(p);
 
-    if (p->size < AVAHI_DNS_PACKET_HEADER_SIZE)
+    if (p->size < CATTA_DNS_PACKET_HEADER_SIZE)
         return -1;
 
-    flags = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_FLAGS);
+    flags = catta_dns_packet_get_field(p, CATTA_DNS_FIELD_FLAGS);
 
-    if (flags & AVAHI_DNS_FLAG_OPCODE)
+    if (flags & CATTA_DNS_FLAG_OPCODE)
         return -1;
 
     return 0;
 }
 
-int avahi_dns_packet_check_valid_multicast(AvahiDnsPacket *p) {
+int catta_dns_packet_check_valid_multicast(CattaDnsPacket *p) {
     uint16_t flags;
     assert(p);
 
-    if (avahi_dns_packet_check_valid(p) < 0)
+    if (catta_dns_packet_check_valid(p) < 0)
         return -1;
 
-    flags = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_FLAGS);
+    flags = catta_dns_packet_get_field(p, CATTA_DNS_FIELD_FLAGS);
 
-    if (flags & AVAHI_DNS_FLAG_RCODE)
+    if (flags & CATTA_DNS_FLAG_RCODE)
         return -1;
 
     return 0;
 }
 
-int avahi_dns_packet_is_query(AvahiDnsPacket *p) {
+int catta_dns_packet_is_query(CattaDnsPacket *p) {
     assert(p);
 
-    return !(avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_FLAGS) & AVAHI_DNS_FLAG_QR);
+    return !(catta_dns_packet_get_field(p, CATTA_DNS_FIELD_FLAGS) & CATTA_DNS_FLAG_QR);
 }
 
-static int consume_labels(AvahiDnsPacket *p, unsigned idx, char *ret_name, size_t l) {
+static int consume_labels(CattaDnsPacket *p, unsigned idx, char *ret_name, size_t l) {
     int ret = 0;
     int compressed = 0;
     int first_label = 1;
@@ -350,13 +350,13 @@ static int consume_labels(AvahiDnsPacket *p, unsigned idx, char *ret_name, size_
     int i;
     assert(p && ret_name && l);
 
-    for (i = 0; i < AVAHI_DNS_LABELS_MAX; i++) {
+    for (i = 0; i < CATTA_DNS_LABELS_MAX; i++) {
         uint8_t n;
 
         if (idx+1 > p->size)
             return -1;
 
-        n = AVAHI_DNS_PACKET_DATA(p)[idx];
+        n = CATTA_DNS_PACKET_DATA(p)[idx];
 
         if (!n) {
             idx++;
@@ -387,7 +387,7 @@ static int consume_labels(AvahiDnsPacket *p, unsigned idx, char *ret_name, size_
             } else
                 first_label = 0;
 
-            if (!(avahi_escape_label((char*) AVAHI_DNS_PACKET_DATA(p) + idx, n, &ret_name, &l)))
+            if (!(catta_escape_label((char*) CATTA_DNS_PACKET_DATA(p) + idx, n, &ret_name, &l)))
                 return -1;
 
             idx += n;
@@ -400,9 +400,9 @@ static int consume_labels(AvahiDnsPacket *p, unsigned idx, char *ret_name, size_
             if (idx+2 > p->size)
                 return -1;
 
-            label_ptr = ((unsigned) (AVAHI_DNS_PACKET_DATA(p)[idx] & ~0xC0)) << 8 | AVAHI_DNS_PACKET_DATA(p)[idx+1];
+            label_ptr = ((unsigned) (CATTA_DNS_PACKET_DATA(p)[idx] & ~0xC0)) << 8 | CATTA_DNS_PACKET_DATA(p)[idx+1];
 
-            if ((label_ptr < AVAHI_DNS_PACKET_HEADER_SIZE) || (label_ptr >= idx))
+            if ((label_ptr < CATTA_DNS_PACKET_HEADER_SIZE) || (label_ptr >= idx))
                 return -1;
 
             idx = label_ptr;
@@ -418,7 +418,7 @@ static int consume_labels(AvahiDnsPacket *p, unsigned idx, char *ret_name, size_
     return -1;
 }
 
-int avahi_dns_packet_consume_name(AvahiDnsPacket *p, char *ret_name, size_t l) {
+int catta_dns_packet_consume_name(CattaDnsPacket *p, char *ret_name, size_t l) {
     int r;
 
     if ((r = consume_labels(p, p->rindex, ret_name, l)) < 0)
@@ -428,7 +428,7 @@ int avahi_dns_packet_consume_name(AvahiDnsPacket *p, char *ret_name, size_t l) {
     return 0;
 }
 
-int avahi_dns_packet_consume_uint16(AvahiDnsPacket *p, uint16_t *ret_v) {
+int catta_dns_packet_consume_uint16(CattaDnsPacket *p, uint16_t *ret_v) {
     uint8_t *d;
 
     assert(p);
@@ -437,14 +437,14 @@ int avahi_dns_packet_consume_uint16(AvahiDnsPacket *p, uint16_t *ret_v) {
     if (p->rindex + sizeof(uint16_t) > p->size)
         return -1;
 
-    d = (uint8_t*) (AVAHI_DNS_PACKET_DATA(p) + p->rindex);
+    d = (uint8_t*) (CATTA_DNS_PACKET_DATA(p) + p->rindex);
     *ret_v = (d[0] << 8) | d[1];
     p->rindex += sizeof(uint16_t);
 
     return 0;
 }
 
-int avahi_dns_packet_consume_uint32(AvahiDnsPacket *p, uint32_t *ret_v) {
+int catta_dns_packet_consume_uint32(CattaDnsPacket *p, uint32_t *ret_v) {
     uint8_t* d;
 
     assert(p);
@@ -453,14 +453,14 @@ int avahi_dns_packet_consume_uint32(AvahiDnsPacket *p, uint32_t *ret_v) {
     if (p->rindex + sizeof(uint32_t) > p->size)
         return -1;
 
-    d = (uint8_t*) (AVAHI_DNS_PACKET_DATA(p) + p->rindex);
+    d = (uint8_t*) (CATTA_DNS_PACKET_DATA(p) + p->rindex);
     *ret_v = (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | d[3];
     p->rindex += sizeof(uint32_t);
 
     return 0;
 }
 
-int avahi_dns_packet_consume_bytes(AvahiDnsPacket *p, void * ret_data, size_t l) {
+int catta_dns_packet_consume_bytes(CattaDnsPacket *p, void * ret_data, size_t l) {
     assert(p);
     assert(ret_data);
     assert(l > 0);
@@ -468,13 +468,13 @@ int avahi_dns_packet_consume_bytes(AvahiDnsPacket *p, void * ret_data, size_t l)
     if (p->rindex + l > p->size)
         return -1;
 
-    memcpy(ret_data, AVAHI_DNS_PACKET_DATA(p) + p->rindex, l);
+    memcpy(ret_data, CATTA_DNS_PACKET_DATA(p) + p->rindex, l);
     p->rindex += l;
 
     return 0;
 }
 
-int avahi_dns_packet_consume_string(AvahiDnsPacket *p, char *ret_string, size_t l) {
+int catta_dns_packet_consume_string(CattaDnsPacket *p, char *ret_string, size_t l) {
     size_t k;
 
     assert(p);
@@ -484,7 +484,7 @@ int avahi_dns_packet_consume_string(AvahiDnsPacket *p, char *ret_string, size_t
     if (p->rindex >= p->size)
         return -1;
 
-    k = AVAHI_DNS_PACKET_DATA(p)[p->rindex];
+    k = CATTA_DNS_PACKET_DATA(p)[p->rindex];
 
     if (p->rindex+1+k > p->size)
         return -1;
@@ -492,7 +492,7 @@ int avahi_dns_packet_consume_string(AvahiDnsPacket *p, char *ret_string, size_t
     if (l > k+1)
         l = k+1;
 
-    memcpy(ret_string, AVAHI_DNS_PACKET_DATA(p)+p->rindex+1, l-1);
+    memcpy(ret_string, CATTA_DNS_PACKET_DATA(p)+p->rindex+1, l-1);
     ret_string[l-1] = 0;
 
     p->rindex += 1+k;
@@ -500,16 +500,16 @@ int avahi_dns_packet_consume_string(AvahiDnsPacket *p, char *ret_string, size_t
     return 0;
 }
 
-const void* avahi_dns_packet_get_rptr(AvahiDnsPacket *p) {
+const void* catta_dns_packet_get_rptr(CattaDnsPacket *p) {
     assert(p);
 
     if (p->rindex > p->size)
         return NULL;
 
-    return AVAHI_DNS_PACKET_DATA(p) + p->rindex;
+    return CATTA_DNS_PACKET_DATA(p) + p->rindex;
 }
 
-int avahi_dns_packet_skip(AvahiDnsPacket *p, size_t length) {
+int catta_dns_packet_skip(CattaDnsPacket *p, size_t length) {
     assert(p);
 
     if (p->rindex + length > p->size)
@@ -519,92 +519,92 @@ int avahi_dns_packet_skip(AvahiDnsPacket *p, size_t length) {
     return 0;
 }
 
-static int parse_rdata(AvahiDnsPacket *p, AvahiRecord *r, uint16_t rdlength) {
-    char buf[AVAHI_DOMAIN_NAME_MAX];
+static int parse_rdata(CattaDnsPacket *p, CattaRecord *r, uint16_t rdlength) {
+    char buf[CATTA_DOMAIN_NAME_MAX];
     const void* start;
 
     assert(p);
     assert(r);
 
-    start = avahi_dns_packet_get_rptr(p);
+    start = catta_dns_packet_get_rptr(p);
 
     switch (r->key->type) {
-        case AVAHI_DNS_TYPE_PTR:
-        case AVAHI_DNS_TYPE_CNAME:
-        case AVAHI_DNS_TYPE_NS:
+        case CATTA_DNS_TYPE_PTR:
+        case CATTA_DNS_TYPE_CNAME:
+        case CATTA_DNS_TYPE_NS:
 
-            if (avahi_dns_packet_consume_name(p, buf, sizeof(buf)) < 0)
+            if (catta_dns_packet_consume_name(p, buf, sizeof(buf)) < 0)
                 return -1;
 
-            r->data.ptr.name = avahi_strdup(buf);
+            r->data.ptr.name = catta_strdup(buf);
             break;
 
 
-        case AVAHI_DNS_TYPE_SRV:
+        case CATTA_DNS_TYPE_SRV:
 
-            if (avahi_dns_packet_consume_uint16(p, &r->data.srv.priority) < 0 ||
-                avahi_dns_packet_consume_uint16(p, &r->data.srv.weight) < 0 ||
-                avahi_dns_packet_consume_uint16(p, &r->data.srv.port) < 0 ||
-                avahi_dns_packet_consume_name(p, buf, sizeof(buf)) < 0)
+            if (catta_dns_packet_consume_uint16(p, &r->data.srv.priority) < 0 ||
+                catta_dns_packet_consume_uint16(p, &r->data.srv.weight) < 0 ||
+                catta_dns_packet_consume_uint16(p, &r->data.srv.port) < 0 ||
+                catta_dns_packet_consume_name(p, buf, sizeof(buf)) < 0)
                 return -1;
 
-            r->data.srv.name = avahi_strdup(buf);
+            r->data.srv.name = catta_strdup(buf);
             break;
 
-        case AVAHI_DNS_TYPE_HINFO:
+        case CATTA_DNS_TYPE_HINFO:
 
-            if (avahi_dns_packet_consume_string(p, buf, sizeof(buf)) < 0)
+            if (catta_dns_packet_consume_string(p, buf, sizeof(buf)) < 0)
                 return -1;
 
-            r->data.hinfo.cpu = avahi_strdup(buf);
+            r->data.hinfo.cpu = catta_strdup(buf);
 
-            if (avahi_dns_packet_consume_string(p, buf, sizeof(buf)) < 0)
+            if (catta_dns_packet_consume_string(p, buf, sizeof(buf)) < 0)
                 return -1;
 
-            r->data.hinfo.os = avahi_strdup(buf);
+            r->data.hinfo.os = catta_strdup(buf);
             break;
 
-        case AVAHI_DNS_TYPE_TXT:
+        case CATTA_DNS_TYPE_TXT:
 
             if (rdlength > 0) {
-                if (avahi_string_list_parse(avahi_dns_packet_get_rptr(p), rdlength, &r->data.txt.string_list) < 0)
+                if (catta_string_list_parse(catta_dns_packet_get_rptr(p), rdlength, &r->data.txt.string_list) < 0)
                     return -1;
 
-                if (avahi_dns_packet_skip(p, rdlength) < 0)
+                if (catta_dns_packet_skip(p, rdlength) < 0)
                     return -1;
             } else
                 r->data.txt.string_list = NULL;
 
             break;
 
-        case AVAHI_DNS_TYPE_A:
+        case CATTA_DNS_TYPE_A:
 
-/*             avahi_log_debug("A"); */
+/*             catta_log_debug("A"); */
 
-            if (avahi_dns_packet_consume_bytes(p, &r->data.a.address, sizeof(AvahiIPv4Address)) < 0)
+            if (catta_dns_packet_consume_bytes(p, &r->data.a.address, sizeof(CattaIPv4Address)) < 0)
                 return -1;
 
             break;
 
-        case AVAHI_DNS_TYPE_AAAA:
+        case CATTA_DNS_TYPE_AAAA:
 
-/*             avahi_log_debug("aaaa"); */
+/*             catta_log_debug("aaaa"); */
 
-            if (avahi_dns_packet_consume_bytes(p, &r->data.aaaa.address, sizeof(AvahiIPv6Address)) < 0)
+            if (catta_dns_packet_consume_bytes(p, &r->data.aaaa.address, sizeof(CattaIPv6Address)) < 0)
                 return -1;
 
             break;
 
         default:
 
-/*             avahi_log_debug("generic"); */
+/*             catta_log_debug("generic"); */
 
             if (rdlength > 0) {
 
-                r->data.generic.data = avahi_memdup(avahi_dns_packet_get_rptr(p), rdlength);
+                r->data.generic.data = catta_memdup(catta_dns_packet_get_rptr(p), rdlength);
                 r->data.generic.size = rdlength;
 
-                if (avahi_dns_packet_skip(p, rdlength) < 0)
+                if (catta_dns_packet_skip(p, rdlength) < 0)
                     return -1;
             }
 
@@ -612,80 +612,80 @@ static int parse_rdata(AvahiDnsPacket *p, AvahiRecord *r, uint16_t rdlength) {
     }
 
     /* Check if we read enough data */
-    if ((const uint8_t*) avahi_dns_packet_get_rptr(p) - (const uint8_t*) start != rdlength)
+    if ((const uint8_t*) catta_dns_packet_get_rptr(p) - (const uint8_t*) start != rdlength)
         return -1;
 
     return 0;
 }
 
-AvahiRecord* avahi_dns_packet_consume_record(AvahiDnsPacket *p, int *ret_cache_flush) {
-    char name[AVAHI_DOMAIN_NAME_MAX];
+CattaRecord* catta_dns_packet_consume_record(CattaDnsPacket *p, int *ret_cache_flush) {
+    char name[CATTA_DOMAIN_NAME_MAX];
     uint16_t type, class;
     uint32_t ttl;
     uint16_t rdlength;
-    AvahiRecord *r = NULL;
+    CattaRecord *r = NULL;
 
     assert(p);
 
-    if (avahi_dns_packet_consume_name(p, name, sizeof(name)) < 0 ||
-        avahi_dns_packet_consume_uint16(p, &type) < 0 ||
-        avahi_dns_packet_consume_uint16(p, &class) < 0 ||
-        avahi_dns_packet_consume_uint32(p, &ttl) < 0 ||
-        avahi_dns_packet_consume_uint16(p, &rdlength) < 0 ||
+    if (catta_dns_packet_consume_name(p, name, sizeof(name)) < 0 ||
+        catta_dns_packet_consume_uint16(p, &type) < 0 ||
+        catta_dns_packet_consume_uint16(p, &class) < 0 ||
+        catta_dns_packet_consume_uint32(p, &ttl) < 0 ||
+        catta_dns_packet_consume_uint16(p, &rdlength) < 0 ||
         p->rindex + rdlength > p->size)
         goto fail;
 
     if (ret_cache_flush)
-        *ret_cache_flush = !!(class & AVAHI_DNS_CACHE_FLUSH);
-    class &= ~AVAHI_DNS_CACHE_FLUSH;
+        *ret_cache_flush = !!(class & CATTA_DNS_CACHE_FLUSH);
+    class &= ~CATTA_DNS_CACHE_FLUSH;
 
-    if (!(r = avahi_record_new_full(name, class, type, ttl)))
+    if (!(r = catta_record_new_full(name, class, type, ttl)))
         goto fail;
 
     if (parse_rdata(p, r, rdlength) < 0)
         goto fail;
 
-    if (!avahi_record_is_valid(r))
+    if (!catta_record_is_valid(r))
         goto fail;
 
     return r;
 
 fail:
     if (r)
-        avahi_record_unref(r);
+        catta_record_unref(r);
 
     return NULL;
 }
 
-AvahiKey* avahi_dns_packet_consume_key(AvahiDnsPacket *p, int *ret_unicast_response) {
+CattaKey* catta_dns_packet_consume_key(CattaDnsPacket *p, int *ret_unicast_response) {
     char name[256];
     uint16_t type, class;
-    AvahiKey *k;
+    CattaKey *k;
 
     assert(p);
 
-    if (avahi_dns_packet_consume_name(p, name, sizeof(name)) < 0 ||
-        avahi_dns_packet_consume_uint16(p, &type) < 0 ||
-        avahi_dns_packet_consume_uint16(p, &class) < 0)
+    if (catta_dns_packet_consume_name(p, name, sizeof(name)) < 0 ||
+        catta_dns_packet_consume_uint16(p, &type) < 0 ||
+        catta_dns_packet_consume_uint16(p, &class) < 0)
         return NULL;
 
     if (ret_unicast_response)
-        *ret_unicast_response = !!(class & AVAHI_DNS_UNICAST_RESPONSE);
+        *ret_unicast_response = !!(class & CATTA_DNS_UNICAST_RESPONSE);
 
-    class &= ~AVAHI_DNS_UNICAST_RESPONSE;
+    class &= ~CATTA_DNS_UNICAST_RESPONSE;
 
-    if (!(k = avahi_key_new(name, class, type)))
+    if (!(k = catta_key_new(name, class, type)))
         return NULL;
 
-    if (!avahi_key_is_valid(k)) {
-        avahi_key_unref(k);
+    if (!catta_key_is_valid(k)) {
+        catta_key_unref(k);
         return NULL;
     }
 
     return k;
 }
 
-uint8_t* avahi_dns_packet_append_key(AvahiDnsPacket *p, AvahiKey *k, int unicast_response) {
+uint8_t* catta_dns_packet_append_key(CattaDnsPacket *p, CattaKey *k, int unicast_response) {
     uint8_t *t;
     size_t size;
 
@@ -694,11 +694,11 @@ uint8_t* avahi_dns_packet_append_key(AvahiDnsPacket *p, AvahiKey *k, int unicast
 
     size = p->size;
 
-    if (!(t = avahi_dns_packet_append_name(p, k->name)) ||
-        !avahi_dns_packet_append_uint16(p, k->type) ||
-        !avahi_dns_packet_append_uint16(p, k->clazz | (unicast_response ? AVAHI_DNS_UNICAST_RESPONSE : 0))) {
+    if (!(t = catta_dns_packet_append_name(p, k->name)) ||
+        !catta_dns_packet_append_uint16(p, k->type) ||
+        !catta_dns_packet_append_uint16(p, k->clazz | (unicast_response ? CATTA_DNS_UNICAST_RESPONSE : 0))) {
         p->size = size;
-        avahi_dns_packet_cleanup_name_table(p);
+        catta_dns_packet_cleanup_name_table(p);
 
         return NULL;
     }
@@ -706,63 +706,63 @@ uint8_t* avahi_dns_packet_append_key(AvahiDnsPacket *p, AvahiKey *k, int unicast
     return t;
 }
 
-static int append_rdata(AvahiDnsPacket *p, AvahiRecord *r) {
+static int append_rdata(CattaDnsPacket *p, CattaRecord *r) {
     assert(p);
     assert(r);
 
     switch (r->key->type) {
 
-        case AVAHI_DNS_TYPE_PTR:
-        case AVAHI_DNS_TYPE_CNAME:
-        case AVAHI_DNS_TYPE_NS:
+        case CATTA_DNS_TYPE_PTR:
+        case CATTA_DNS_TYPE_CNAME:
+        case CATTA_DNS_TYPE_NS:
 
-            if (!(avahi_dns_packet_append_name(p, r->data.ptr.name)))
+            if (!(catta_dns_packet_append_name(p, r->data.ptr.name)))
                 return -1;
 
             break;
 
-        case AVAHI_DNS_TYPE_SRV:
+        case CATTA_DNS_TYPE_SRV:
 
-            if (!avahi_dns_packet_append_uint16(p, r->data.srv.priority) ||
-                !avahi_dns_packet_append_uint16(p, r->data.srv.weight) ||
-                !avahi_dns_packet_append_uint16(p, r->data.srv.port) ||
-                !avahi_dns_packet_append_name(p, r->data.srv.name))
+            if (!catta_dns_packet_append_uint16(p, r->data.srv.priority) ||
+                !catta_dns_packet_append_uint16(p, r->data.srv.weight) ||
+                !catta_dns_packet_append_uint16(p, r->data.srv.port) ||
+                !catta_dns_packet_append_name(p, r->data.srv.name))
                 return -1;
 
             break;
 
-        case AVAHI_DNS_TYPE_HINFO:
-            if (!avahi_dns_packet_append_string(p, r->data.hinfo.cpu) ||
-                !avahi_dns_packet_append_string(p, r->data.hinfo.os))
+        case CATTA_DNS_TYPE_HINFO:
+            if (!catta_dns_packet_append_string(p, r->data.hinfo.cpu) ||
+                !catta_dns_packet_append_string(p, r->data.hinfo.os))
                 return -1;
 
             break;
 
-        case AVAHI_DNS_TYPE_TXT: {
+        case CATTA_DNS_TYPE_TXT: {
 
             uint8_t *data;
             size_t n;
 
-            n = avahi_string_list_serialize(r->data.txt.string_list, NULL, 0);
+            n = catta_string_list_serialize(r->data.txt.string_list, NULL, 0);
 
-            if (!(data = avahi_dns_packet_extend(p, n)))
+            if (!(data = catta_dns_packet_extend(p, n)))
                 return -1;
 
-            avahi_string_list_serialize(r->data.txt.string_list, data, n);
+            catta_string_list_serialize(r->data.txt.string_list, data, n);
             break;
         }
 
 
-        case AVAHI_DNS_TYPE_A:
+        case CATTA_DNS_TYPE_A:
 
-            if (!avahi_dns_packet_append_bytes(p, &r->data.a.address, sizeof(r->data.a.address)))
+            if (!catta_dns_packet_append_bytes(p, &r->data.a.address, sizeof(r->data.a.address)))
                 return -1;
 
             break;
 
-        case AVAHI_DNS_TYPE_AAAA:
+        case CATTA_DNS_TYPE_AAAA:
 
-            if (!avahi_dns_packet_append_bytes(p, &r->data.aaaa.address, sizeof(r->data.aaaa.address)))
+            if (!catta_dns_packet_append_bytes(p, &r->data.aaaa.address, sizeof(r->data.aaaa.address)))
                 return -1;
 
             break;
@@ -770,7 +770,7 @@ static int append_rdata(AvahiDnsPacket *p, AvahiRecord *r) {
         default:
 
             if (r->data.generic.size)
-                if (!avahi_dns_packet_append_bytes(p, r->data.generic.data, r->data.generic.size))
+                if (!catta_dns_packet_append_bytes(p, r->data.generic.data, r->data.generic.size))
                     return -1;
 
             break;
@@ -780,7 +780,7 @@ static int append_rdata(AvahiDnsPacket *p, AvahiRecord *r) {
 }
 
 
-uint8_t* avahi_dns_packet_append_record(AvahiDnsPacket *p, AvahiRecord *r, int cache_flush, unsigned max_ttl) {
+uint8_t* catta_dns_packet_append_record(CattaDnsPacket *p, CattaRecord *r, int cache_flush, unsigned max_ttl) {
     uint8_t *t, *l, *start;
     size_t size;
 
@@ -789,22 +789,22 @@ uint8_t* avahi_dns_packet_append_record(AvahiDnsPacket *p, AvahiRecord *r, int c
 
     size = p->size;
 
-    if (!(t = avahi_dns_packet_append_name(p, r->key->name)) ||
-        !avahi_dns_packet_append_uint16(p, r->key->type) ||
-        !avahi_dns_packet_append_uint16(p, cache_flush ? (r->key->clazz | AVAHI_DNS_CACHE_FLUSH) : (r->key->clazz &~ AVAHI_DNS_CACHE_FLUSH)) ||
-        !avahi_dns_packet_append_uint32(p, (max_ttl && r->ttl > max_ttl) ? max_ttl : r->ttl) ||
-        !(l = avahi_dns_packet_append_uint16(p, 0)))
+    if (!(t = catta_dns_packet_append_name(p, r->key->name)) ||
+        !catta_dns_packet_append_uint16(p, r->key->type) ||
+        !catta_dns_packet_append_uint16(p, cache_flush ? (r->key->clazz | CATTA_DNS_CACHE_FLUSH) : (r->key->clazz &~ CATTA_DNS_CACHE_FLUSH)) ||
+        !catta_dns_packet_append_uint32(p, (max_ttl && r->ttl > max_ttl) ? max_ttl : r->ttl) ||
+        !(l = catta_dns_packet_append_uint16(p, 0)))
         goto fail;
 
-    start = avahi_dns_packet_extend(p, 0);
+    start = catta_dns_packet_extend(p, 0);
 
     if (append_rdata(p, r) < 0)
         goto fail;
 
-    size = avahi_dns_packet_extend(p, 0) - start;
-    assert(size <= AVAHI_DNS_RDATA_MAX);
+    size = catta_dns_packet_extend(p, 0) - start;
+    assert(size <= CATTA_DNS_RDATA_MAX);
 
-/*     avahi_log_debug("appended %u", size); */
+/*     catta_log_debug("appended %u", size); */
 
     l[0] = (uint8_t) ((uint16_t) size >> 8);
     l[1] = (uint8_t) ((uint16_t) size);
@@ -814,18 +814,18 @@ uint8_t* avahi_dns_packet_append_record(AvahiDnsPacket *p, AvahiRecord *r, int c
 
 fail:
     p->size = size;
-    avahi_dns_packet_cleanup_name_table(p);
+    catta_dns_packet_cleanup_name_table(p);
 
     return NULL;
 }
 
-int avahi_dns_packet_is_empty(AvahiDnsPacket *p) {
+int catta_dns_packet_is_empty(CattaDnsPacket *p) {
     assert(p);
 
-    return p->size <= AVAHI_DNS_PACKET_HEADER_SIZE;
+    return p->size <= CATTA_DNS_PACKET_HEADER_SIZE;
 }
 
-size_t avahi_dns_packet_space(AvahiDnsPacket *p) {
+size_t catta_dns_packet_space(CattaDnsPacket *p) {
     assert(p);
 
     assert(p->size <= p->max_size);
@@ -833,9 +833,9 @@ size_t avahi_dns_packet_space(AvahiDnsPacket *p) {
     return p->max_size - p->size;
 }
 
-int avahi_rdata_parse(AvahiRecord *record, const void* rdata, size_t size) {
+int catta_rdata_parse(CattaRecord *record, const void* rdata, size_t size) {
     int ret;
-    AvahiDnsPacket p;
+    CattaDnsPacket p;
 
     assert(record);
     assert(rdata);
@@ -852,9 +852,9 @@ int avahi_rdata_parse(AvahiRecord *record, const void* rdata, size_t size) {
     return ret;
 }
 
-size_t avahi_rdata_serialize(AvahiRecord *record, void *rdata, size_t max_size) {
+size_t catta_rdata_serialize(CattaRecord *record, void *rdata, size_t max_size) {
     int ret;
-    AvahiDnsPacket p;
+    CattaDnsPacket p;
 
     assert(record);
     assert(rdata);
@@ -868,7 +868,7 @@ size_t avahi_rdata_serialize(AvahiRecord *record, void *rdata, size_t max_size)
     ret = append_rdata(&p, record);
 
     if (p.name_table)
-         avahi_hashmap_free(p.name_table);
+         catta_hashmap_free(p.name_table);
 
     if (ret < 0)
         return (size_t) -1;
index e5eb928e10d7503dde687b1a0e11de44c7816ccc..b86e3428c3849346d5b008c526e1197e85277627 100644 (file)
--- a/src/dns.h
+++ b/src/dns.h
@@ -2,97 +2,97 @@
 #define foodnshfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
-#include <avahi/rr.h>
+#include <catta/rr.h>
 #include "hashmap.h"
 
-#define AVAHI_DNS_PACKET_HEADER_SIZE 12
-#define AVAHI_DNS_PACKET_EXTRA_SIZE 48
-#define AVAHI_DNS_LABELS_MAX 127
-#define AVAHI_DNS_RDATA_MAX 0xFFFF
-#define AVAHI_DNS_PACKET_SIZE_MAX (AVAHI_DNS_PACKET_HEADER_SIZE + 256 + 2 + 2 + 4 + 2 + AVAHI_DNS_RDATA_MAX)
+#define CATTA_DNS_PACKET_HEADER_SIZE 12
+#define CATTA_DNS_PACKET_EXTRA_SIZE 48
+#define CATTA_DNS_LABELS_MAX 127
+#define CATTA_DNS_RDATA_MAX 0xFFFF
+#define CATTA_DNS_PACKET_SIZE_MAX (CATTA_DNS_PACKET_HEADER_SIZE + 256 + 2 + 2 + 4 + 2 + CATTA_DNS_RDATA_MAX)
 
-typedef struct AvahiDnsPacket {
+typedef struct CattaDnsPacket {
     size_t size, rindex, max_size;
-    AvahiHashmap *name_table; /* for name compression */
+    CattaHashmap *name_table; /* for name compression */
     uint8_t *data;
-} AvahiDnsPacket;
+} CattaDnsPacket;
 
-#define AVAHI_DNS_PACKET_DATA(p) ((p)->data ? (p)->data : ((uint8_t*) p) + sizeof(AvahiDnsPacket))
+#define CATTA_DNS_PACKET_DATA(p) ((p)->data ? (p)->data : ((uint8_t*) p) + sizeof(CattaDnsPacket))
 
-AvahiDnsPacket* avahi_dns_packet_new(unsigned mtu);
-AvahiDnsPacket* avahi_dns_packet_new_query(unsigned mtu);
-AvahiDnsPacket* avahi_dns_packet_new_response(unsigned mtu, int aa);
+CattaDnsPacket* catta_dns_packet_new(unsigned mtu);
+CattaDnsPacket* catta_dns_packet_new_query(unsigned mtu);
+CattaDnsPacket* catta_dns_packet_new_response(unsigned mtu, int aa);
 
-AvahiDnsPacket* avahi_dns_packet_new_reply(AvahiDnsPacket* p, unsigned mtu, int copy_queries, int aa);
+CattaDnsPacket* catta_dns_packet_new_reply(CattaDnsPacket* p, unsigned mtu, int copy_queries, int aa);
 
-void avahi_dns_packet_free(AvahiDnsPacket *p);
-void avahi_dns_packet_set_field(AvahiDnsPacket *p, unsigned idx, uint16_t v);
-uint16_t avahi_dns_packet_get_field(AvahiDnsPacket *p, unsigned idx);
-void avahi_dns_packet_inc_field(AvahiDnsPacket *p, unsigned idx);
+void catta_dns_packet_free(CattaDnsPacket *p);
+void catta_dns_packet_set_field(CattaDnsPacket *p, unsigned idx, uint16_t v);
+uint16_t catta_dns_packet_get_field(CattaDnsPacket *p, unsigned idx);
+void catta_dns_packet_inc_field(CattaDnsPacket *p, unsigned idx);
 
-uint8_t *avahi_dns_packet_extend(AvahiDnsPacket *p, size_t l);
+uint8_t *catta_dns_packet_extend(CattaDnsPacket *p, size_t l);
 
-void avahi_dns_packet_cleanup_name_table(AvahiDnsPacket *p);
+void catta_dns_packet_cleanup_name_table(CattaDnsPacket *p);
 
-uint8_t *avahi_dns_packet_append_uint16(AvahiDnsPacket *p, uint16_t v);
-uint8_t *avahi_dns_packet_append_uint32(AvahiDnsPacket *p, uint32_t v);
-uint8_t *avahi_dns_packet_append_name(AvahiDnsPacket *p, const char *name);
-uint8_t *avahi_dns_packet_append_bytes(AvahiDnsPacket  *p, const void *d, size_t l);
-uint8_t* avahi_dns_packet_append_key(AvahiDnsPacket *p, AvahiKey *k, int unicast_response);
-uint8_t* avahi_dns_packet_append_record(AvahiDnsPacket *p, AvahiRecord *r, int cache_flush, unsigned max_ttl);
-uint8_t* avahi_dns_packet_append_string(AvahiDnsPacket *p, const char *s);
+uint8_t *catta_dns_packet_append_uint16(CattaDnsPacket *p, uint16_t v);
+uint8_t *catta_dns_packet_append_uint32(CattaDnsPacket *p, uint32_t v);
+uint8_t *catta_dns_packet_append_name(CattaDnsPacket *p, const char *name);
+uint8_t *catta_dns_packet_append_bytes(CattaDnsPacket  *p, const void *d, size_t l);
+uint8_t* catta_dns_packet_append_key(CattaDnsPacket *p, CattaKey *k, int unicast_response);
+uint8_t* catta_dns_packet_append_record(CattaDnsPacket *p, CattaRecord *r, int cache_flush, unsigned max_ttl);
+uint8_t* catta_dns_packet_append_string(CattaDnsPacket *p, const char *s);
 
-int avahi_dns_packet_is_query(AvahiDnsPacket *p);
-int avahi_dns_packet_check_valid(AvahiDnsPacket *p);
-int avahi_dns_packet_check_valid_multicast(AvahiDnsPacket *p);
+int catta_dns_packet_is_query(CattaDnsPacket *p);
+int catta_dns_packet_check_valid(CattaDnsPacket *p);
+int catta_dns_packet_check_valid_multicast(CattaDnsPacket *p);
 
-int avahi_dns_packet_consume_uint16(AvahiDnsPacket *p, uint16_t *ret_v);
-int avahi_dns_packet_consume_uint32(AvahiDnsPacket *p, uint32_t *ret_v);
-int avahi_dns_packet_consume_name(AvahiDnsPacket *p, char *ret_name, size_t l);
-int avahi_dns_packet_consume_bytes(AvahiDnsPacket *p, void* ret_data, size_t l);
-AvahiKey* avahi_dns_packet_consume_key(AvahiDnsPacket *p, int *ret_unicast_response);
-AvahiRecord* avahi_dns_packet_consume_record(AvahiDnsPacket *p, int *ret_cache_flush);
-int avahi_dns_packet_consume_string(AvahiDnsPacket *p, char *ret_string, size_t l);
+int catta_dns_packet_consume_uint16(CattaDnsPacket *p, uint16_t *ret_v);
+int catta_dns_packet_consume_uint32(CattaDnsPacket *p, uint32_t *ret_v);
+int catta_dns_packet_consume_name(CattaDnsPacket *p, char *ret_name, size_t l);
+int catta_dns_packet_consume_bytes(CattaDnsPacket *p, void* ret_data, size_t l);
+CattaKey* catta_dns_packet_consume_key(CattaDnsPacket *p, int *ret_unicast_response);
+CattaRecord* catta_dns_packet_consume_record(CattaDnsPacket *p, int *ret_cache_flush);
+int catta_dns_packet_consume_string(CattaDnsPacket *p, char *ret_string, size_t l);
 
-const void* avahi_dns_packet_get_rptr(AvahiDnsPacket *p);
+const void* catta_dns_packet_get_rptr(CattaDnsPacket *p);
 
-int avahi_dns_packet_skip(AvahiDnsPacket *p, size_t length);
+int catta_dns_packet_skip(CattaDnsPacket *p, size_t length);
 
-int avahi_dns_packet_is_empty(AvahiDnsPacket *p);
-size_t avahi_dns_packet_space(AvahiDnsPacket *p);
+int catta_dns_packet_is_empty(CattaDnsPacket *p);
+size_t catta_dns_packet_space(CattaDnsPacket *p);
 
-#define AVAHI_DNS_FIELD_ID 0
-#define AVAHI_DNS_FIELD_FLAGS 1
-#define AVAHI_DNS_FIELD_QDCOUNT 2
-#define AVAHI_DNS_FIELD_ANCOUNT 3
-#define AVAHI_DNS_FIELD_NSCOUNT 4
-#define AVAHI_DNS_FIELD_ARCOUNT 5
+#define CATTA_DNS_FIELD_ID 0
+#define CATTA_DNS_FIELD_FLAGS 1
+#define CATTA_DNS_FIELD_QDCOUNT 2
+#define CATTA_DNS_FIELD_ANCOUNT 3
+#define CATTA_DNS_FIELD_NSCOUNT 4
+#define CATTA_DNS_FIELD_ARCOUNT 5
 
-#define AVAHI_DNS_FLAG_QR (1 << 15)
-#define AVAHI_DNS_FLAG_OPCODE (15 << 11)
-#define AVAHI_DNS_FLAG_RCODE (15)
-#define AVAHI_DNS_FLAG_TC (1 << 9)
-#define AVAHI_DNS_FLAG_AA (1 << 10)
+#define CATTA_DNS_FLAG_QR (1 << 15)
+#define CATTA_DNS_FLAG_OPCODE (15 << 11)
+#define CATTA_DNS_FLAG_RCODE (15)
+#define CATTA_DNS_FLAG_TC (1 << 9)
+#define CATTA_DNS_FLAG_AA (1 << 10)
 
-#define AVAHI_DNS_FLAGS(qr, opcode, aa, tc, rd, ra, z, ad, cd, rcode) \
+#define CATTA_DNS_FLAGS(qr, opcode, aa, tc, rd, ra, z, ad, cd, rcode) \
         (((uint16_t) !!qr << 15) |  \
          ((uint16_t) (opcode & 15) << 11) | \
          ((uint16_t) !!aa << 10) | \
@@ -103,9 +103,9 @@ size_t avahi_dns_packet_space(AvahiDnsPacket *p);
          ((uint16_t) !!cd << 4) | \
          ((uint16_t) (rcode & 15)))
 
-#define AVAHI_MDNS_SUFFIX_LOCAL "local"
-#define AVAHI_MDNS_SUFFIX_ADDR_IPV4 "254.169.in-addr.arpa"
-#define AVAHI_MDNS_SUFFIX_ADDR_IPV6 "0.8.e.f.ip6.arpa"
+#define CATTA_MDNS_SUFFIX_LOCAL "local"
+#define CATTA_MDNS_SUFFIX_ADDR_IPV4 "254.169.in-addr.arpa"
+#define CATTA_MDNS_SUFFIX_ADDR_IPV6 "0.8.e.f.ip6.arpa"
 
 #endif
 
index 15b5ae12d2ed8c5c23fad77233293d35181fcee2..af40414838af8d422ea58879253f9e0a0a3b7869 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
@@ -29,9 +29,9 @@
 #include <sys/utsname.h>
 #include <stdio.h>
 
-#include <avahi/malloc.h>
+#include <catta/malloc.h>
 
-#include <avahi/log.h>
+#include <catta/log.h>
 #include "domain-util.h"
 #include "util.h"
 
@@ -84,7 +84,7 @@ static int load_lsb_distrib_id(char *ret_s, size_t size) {
 }
 #endif
 
-char *avahi_get_host_name(char *ret_s, size_t size) {
+char *catta_get_host_name(char *ret_s, size_t size) {
     assert(ret_s);
     assert(size > 0);
 
@@ -96,7 +96,7 @@ char *avahi_get_host_name(char *ret_s, size_t size) {
 
     if (strcmp(ret_s, "localhost") == 0 || strncmp(ret_s, "localhost.", 10) == 0) {
         *ret_s = 0;
-        avahi_log_warn("System host name is set to 'localhost'. This is not a suitable mDNS host name, looking for alternatives.");
+        catta_log_warn("System host name is set to 'localhost'. This is not a suitable mDNS host name, looking for alternatives.");
     }
 
     if (*ret_s == 0) {
@@ -107,7 +107,7 @@ char *avahi_get_host_name(char *ret_s, size_t size) {
         /* Try LSB distribution name first */
         if (load_lsb_distrib_id(ret_s, size) >= 0) {
             strip_bad_chars(ret_s);
-            avahi_strdown(ret_s);
+            catta_strdown(ret_s);
         }
 
         if (*ret_s == 0)
@@ -120,7 +120,7 @@ char *avahi_get_host_name(char *ret_s, size_t size) {
             if (uname(&utsname) >= 0) {
                 snprintf(ret_s, size, "%s", utsname.sysname);
                 strip_bad_chars(ret_s);
-                avahi_strdown(ret_s);
+                catta_strdown(ret_s);
             }
 
             /* Give up */
@@ -129,22 +129,22 @@ char *avahi_get_host_name(char *ret_s, size_t size) {
         }
     }
 
-    if (size >= AVAHI_LABEL_MAX)
-       ret_s[AVAHI_LABEL_MAX-1] = 0;
+    if (size >= CATTA_LABEL_MAX)
+       ret_s[CATTA_LABEL_MAX-1] = 0;
 
     return ret_s;
 }
 
-char *avahi_get_host_name_strdup(void) {
-    char t[AVAHI_DOMAIN_NAME_MAX];
+char *catta_get_host_name_strdup(void) {
+    char t[CATTA_DOMAIN_NAME_MAX];
 
-    if (!(avahi_get_host_name(t, sizeof(t))))
+    if (!(catta_get_host_name(t, sizeof(t))))
         return NULL;
 
-    return avahi_strdup(t);
+    return catta_strdup(t);
 }
 
-int avahi_binary_domain_cmp(const char *a, const char *b) {
+int catta_binary_domain_cmp(const char *a, const char *b) {
     assert(a);
     assert(b);
 
@@ -152,12 +152,12 @@ int avahi_binary_domain_cmp(const char *a, const char *b) {
         return 0;
 
     for (;;) {
-        char ca[AVAHI_LABEL_MAX], cb[AVAHI_LABEL_MAX], *p;
+        char ca[CATTA_LABEL_MAX], cb[CATTA_LABEL_MAX], *p;
         int r;
 
-        p = avahi_unescape_label(&a, ca, sizeof(ca));
+        p = catta_unescape_label(&a, ca, sizeof(ca));
         assert(p);
-        p = avahi_unescape_label(&b, cb, sizeof(cb));
+        p = catta_unescape_label(&b, cb, sizeof(cb));
         assert(p);
 
         if ((r = strcmp(ca, cb)))
@@ -168,20 +168,20 @@ int avahi_binary_domain_cmp(const char *a, const char *b) {
     }
 }
 
-int avahi_domain_ends_with(const char *domain, const char *suffix) {
+int catta_domain_ends_with(const char *domain, const char *suffix) {
     assert(domain);
     assert(suffix);
 
     for (;;) {
-        char dummy[AVAHI_LABEL_MAX], *r;
+        char dummy[CATTA_LABEL_MAX], *r;
 
         if (*domain == 0)
             return 0;
 
-        if (avahi_domain_equal(domain, suffix))
+        if (catta_domain_equal(domain, suffix))
             return 1;
 
-        r = avahi_unescape_label(&domain, dummy, sizeof(dummy));
+        r = catta_unescape_label(&domain, dummy, sizeof(dummy));
         assert(r);
     }
 }
index 2b786dfc75da4bd7bb2d0835a820b3d29fd4967d..409be81963b49a0809782d60ea14cebea68af304 100644 (file)
@@ -2,20 +2,20 @@
 #define foodomainutilhfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <inttypes.h>
 #include <sys/types.h>
 
-#include <avahi/cdecl.h>
-#include <avahi/domain.h>
+#include <catta/cdecl.h>
+#include <catta/domain.h>
 
-AVAHI_C_DECL_BEGIN
+CATTA_C_DECL_BEGIN
 
 /** Return the local host name. */
-char *avahi_get_host_name(char *ret_s, size_t size);
+char *catta_get_host_name(char *ret_s, size_t size);
 
-/** Return the local host name. avahi_free() the result! */
-char *avahi_get_host_name_strdup(void);
+/** Return the local host name. catta_free() the result! */
+char *catta_get_host_name_strdup(void);
 
 /** Do a binary comparison of to specified domain names, return -1, 0, or 1, depending on the order. */
-int avahi_binary_domain_cmp(const char *a, const char *b);
+int catta_binary_domain_cmp(const char *a, const char *b);
 
 /** Returns 1 if the the end labels of domain are eqal to suffix */
-int avahi_domain_ends_with(const char *domain, const char *suffix);
+int catta_domain_ends_with(const char *domain, const char *suffix);
 
-AVAHI_C_DECL_END
+CATTA_C_DECL_END
 
 #endif
index 42d9e80f4c1e983c7268c050e6bea823e12d7145..04592e4ca656492a1c52be260a7a5d1f5b5ab409 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <stdlib.h>
 #include <assert.h>
 
-#include <avahi/domain.h>
-#include <avahi/malloc.h>
-#include <avahi/error.h>
-#include <avahi/address.h>
+#include <catta/domain.h>
+#include <catta/malloc.h>
+#include <catta/error.h>
+#include <catta/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) {
+char *catta_unescape_label(const char **name, char *dest, size_t size) {
     unsigned i = 0;
     char *d;
 
@@ -106,14 +106,14 @@ char *avahi_unescape_label(const char **name, char *dest, size_t size) {
 
     *d = 0;
 
-    if (!avahi_utf8_valid(dest))
+    if (!catta_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 *catta_escape_label(const char* src, size_t src_length, char **ret_name, size_t *ret_size) {
     char *r;
 
     assert(src);
@@ -175,7 +175,7 @@ char *avahi_escape_label(const char* src, size_t src_length, char **ret_name, si
     return r;
 }
 
-char *avahi_normalize_name(const char *s, char *ret_s, size_t size) {
+char *catta_normalize_name(const char *s, char *ret_s, size_t size) {
     int empty = 1;
     char *r;
 
@@ -187,9 +187,9 @@ char *avahi_normalize_name(const char *s, char *ret_s, size_t size) {
     *ret_s = 0;
 
     while (*s) {
-        char label[AVAHI_LABEL_MAX];
+        char label[CATTA_LABEL_MAX];
 
-        if (!(avahi_unescape_label(&s, label, sizeof(label))))
+        if (!(catta_unescape_label(&s, label, sizeof(label))))
             return NULL;
 
         if (label[0] == 0) {
@@ -210,23 +210,23 @@ char *avahi_normalize_name(const char *s, char *ret_s, size_t size) {
         } else
             empty = 0;
 
-        avahi_escape_label(label, strlen(label), &r, &size);
+        catta_escape_label(label, strlen(label), &r, &size);
     }
 
     return ret_s;
 }
 
-char *avahi_normalize_name_strdup(const char *s) {
-    char t[AVAHI_DOMAIN_NAME_MAX];
+char *catta_normalize_name_strdup(const char *s) {
+    char t[CATTA_DOMAIN_NAME_MAX];
     assert(s);
 
-    if (!(avahi_normalize_name(s, t, sizeof(t))))
+    if (!(catta_normalize_name(s, t, sizeof(t))))
         return NULL;
 
-    return avahi_strdup(t);
+    return catta_strdup(t);
 }
 
-int avahi_domain_equal(const char *a, const char *b) {
+int catta_domain_equal(const char *a, const char *b) {
     assert(a);
     assert(b);
 
@@ -234,11 +234,11 @@ int avahi_domain_equal(const char *a, const char *b) {
         return 1;
 
     for (;;) {
-        char ca[AVAHI_LABEL_MAX], cb[AVAHI_LABEL_MAX], *r;
+        char ca[CATTA_LABEL_MAX], cb[CATTA_LABEL_MAX], *r;
 
-        r = avahi_unescape_label(&a, ca, sizeof(ca));
+        r = catta_unescape_label(&a, ca, sizeof(ca));
         assert(r);
-        r = avahi_unescape_label(&b, cb, sizeof(cb));
+        r = catta_unescape_label(&b, cb, sizeof(cb));
         assert(r);
 
         if (strcasecmp(ca, cb))
@@ -251,16 +251,16 @@ int avahi_domain_equal(const char *a, const char *b) {
     return 1;
 }
 
-int avahi_is_valid_service_type_generic(const char *t) {
+int catta_is_valid_service_type_generic(const char *t) {
     assert(t);
 
-    if (strlen(t) >= AVAHI_DOMAIN_NAME_MAX || !*t)
+    if (strlen(t) >= CATTA_DOMAIN_NAME_MAX || !*t)
         return 0;
 
     do {
-        char label[AVAHI_LABEL_MAX];
+        char label[CATTA_LABEL_MAX];
 
-        if (!(avahi_unescape_label(&t, label, sizeof(label))))
+        if (!(catta_unescape_label(&t, label, sizeof(label))))
             return 0;
 
         if (strlen(label) <= 2 || label[0] != '_')
@@ -271,16 +271,16 @@ int avahi_is_valid_service_type_generic(const char *t) {
     return 1;
 }
 
-int avahi_is_valid_service_type_strict(const char *t) {
-    char label[AVAHI_LABEL_MAX];
+int catta_is_valid_service_type_strict(const char *t) {
+    char label[CATTA_LABEL_MAX];
     assert(t);
 
-    if (strlen(t) >= AVAHI_DOMAIN_NAME_MAX || !*t)
+    if (strlen(t) >= CATTA_DOMAIN_NAME_MAX || !*t)
         return 0;
 
     /* Application name */
 
-    if (!(avahi_unescape_label(&t, label, sizeof(label))))
+    if (!(catta_unescape_label(&t, label, sizeof(label))))
         return 0;
 
     if (strlen(label) <= 2 || label[0] != '_')
@@ -291,7 +291,7 @@ int avahi_is_valid_service_type_strict(const char *t) {
 
     /* _tcp or _udp boilerplate */
 
-    if (!(avahi_unescape_label(&t, label, sizeof(label))))
+    if (!(catta_unescape_label(&t, label, sizeof(label))))
         return 0;
 
     if (strcasecmp(label, "_tcp") && strcasecmp(label, "_udp"))
@@ -303,17 +303,17 @@ int avahi_is_valid_service_type_strict(const char *t) {
     return 1;
 }
 
-const char *avahi_get_type_from_subtype(const char *t) {
-    char label[AVAHI_LABEL_MAX];
+const char *catta_get_type_from_subtype(const char *t) {
+    char label[CATTA_LABEL_MAX];
     const char *ret;
     assert(t);
 
-    if (strlen(t) >= AVAHI_DOMAIN_NAME_MAX || !*t)
+    if (strlen(t) >= CATTA_DOMAIN_NAME_MAX || !*t)
         return NULL;
 
     /* Subtype name */
 
-    if (!(avahi_unescape_label(&t, label, sizeof(label))))
+    if (!(catta_unescape_label(&t, label, sizeof(label))))
         return NULL;
 
     if (strlen(label) <= 2 || label[0] != '_')
@@ -324,7 +324,7 @@ const char *avahi_get_type_from_subtype(const char *t) {
 
     /* String "_sub" */
 
-    if (!(avahi_unescape_label(&t, label, sizeof(label))))
+    if (!(catta_unescape_label(&t, label, sizeof(label))))
         return NULL;
 
     if (strcasecmp(label, "_sub"))
@@ -337,7 +337,7 @@ const char *avahi_get_type_from_subtype(const char *t) {
 
     /* Application name */
 
-    if (!(avahi_unescape_label(&t, label, sizeof(label))))
+    if (!(catta_unescape_label(&t, label, sizeof(label))))
         return NULL;
 
     if (strlen(label) <= 2 || label[0] != '_')
@@ -348,7 +348,7 @@ const char *avahi_get_type_from_subtype(const char *t) {
 
     /* _tcp or _udp boilerplate */
 
-    if (!(avahi_unescape_label(&t, label, sizeof(label))))
+    if (!(catta_unescape_label(&t, label, sizeof(label))))
         return NULL;
 
     if (strcasecmp(label, "_tcp") && strcasecmp(label, "_udp"))
@@ -360,23 +360,23 @@ const char *avahi_get_type_from_subtype(const char *t) {
     return ret;
 }
 
-int avahi_is_valid_service_subtype(const char *t) {
+int catta_is_valid_service_subtype(const char *t) {
     assert(t);
 
-    return !!avahi_get_type_from_subtype(t);
+    return !!catta_get_type_from_subtype(t);
 }
 
-int avahi_is_valid_domain_name(const char *t) {
+int catta_is_valid_domain_name(const char *t) {
     int is_first = 1;
     assert(t);
 
-    if (strlen(t) >= AVAHI_DOMAIN_NAME_MAX)
+    if (strlen(t) >= CATTA_DOMAIN_NAME_MAX)
         return 0;
 
     do {
-        char label[AVAHI_LABEL_MAX];
+        char label[CATTA_LABEL_MAX];
 
-        if (!(avahi_unescape_label(&t, label, sizeof(label))))
+        if (!(catta_unescape_label(&t, label, sizeof(label))))
             return 0;
 
         /* Explicitly allow the root domain name */
@@ -393,23 +393,23 @@ int avahi_is_valid_domain_name(const char *t) {
     return 1;
 }
 
-int avahi_is_valid_service_name(const char *t) {
+int catta_is_valid_service_name(const char *t) {
     assert(t);
 
-    if (strlen(t) >= AVAHI_LABEL_MAX || !*t)
+    if (strlen(t) >= CATTA_LABEL_MAX || !*t)
         return 0;
 
     return 1;
 }
 
-int avahi_is_valid_host_name(const char *t) {
-    char label[AVAHI_LABEL_MAX];
+int catta_is_valid_host_name(const char *t) {
+    char label[CATTA_LABEL_MAX];
     assert(t);
 
-    if (strlen(t) >= AVAHI_DOMAIN_NAME_MAX || !*t)
+    if (strlen(t) >= CATTA_DOMAIN_NAME_MAX || !*t)
         return 0;
 
-    if (!(avahi_unescape_label(&t, label, sizeof(label))))
+    if (!(catta_unescape_label(&t, label, sizeof(label))))
         return 0;
 
     if (strlen(label) < 1)
@@ -421,13 +421,13 @@ int avahi_is_valid_host_name(const char *t) {
     return 1;
 }
 
-unsigned avahi_domain_hash(const char *s) {
+unsigned catta_domain_hash(const char *s) {
     unsigned hash = 0;
 
     while (*s) {
-        char c[AVAHI_LABEL_MAX], *p, *r;
+        char c[CATTA_LABEL_MAX], *p, *r;
 
-        r = avahi_unescape_label(&s, c, sizeof(c));
+        r = catta_unescape_label(&s, c, sizeof(c));
         assert(r);
 
         for (p = c; *p; p++)
@@ -437,44 +437,44 @@ unsigned avahi_domain_hash(const char *s) {
     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];
+int catta_service_name_join(char *p, size_t size, const char *name, const char *type, const char *domain) {
+    char escaped_name[CATTA_LABEL_MAX*4];
+    char normalized_type[CATTA_DOMAIN_NAME_MAX];
+    char normalized_domain[CATTA_DOMAIN_NAME_MAX];
 
     assert(p);
 
     /* Validity checks */
 
-    if ((name && !avahi_is_valid_service_name(name)))
-        return AVAHI_ERR_INVALID_SERVICE_NAME;
+    if ((name && !catta_is_valid_service_name(name)))
+        return CATTA_ERR_INVALID_SERVICE_NAME;
 
-    if (!avahi_is_valid_service_type_generic(type))
-        return AVAHI_ERR_INVALID_SERVICE_TYPE;
+    if (!catta_is_valid_service_type_generic(type))
+        return CATTA_ERR_INVALID_SERVICE_TYPE;
 
-    if (!avahi_is_valid_domain_name(domain))
-        return AVAHI_ERR_INVALID_DOMAIN_NAME;
+    if (!catta_is_valid_domain_name(domain))
+        return CATTA_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);
+        r = catta_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 (!(catta_normalize_name(type, normalized_type, sizeof(normalized_type))))
+        return CATTA_ERR_INVALID_SERVICE_TYPE;
 
-    if (!(avahi_normalize_name(domain, normalized_domain, sizeof(normalized_domain))))
-        return AVAHI_ERR_INVALID_DOMAIN_NAME;
+    if (!(catta_normalize_name(domain, normalized_domain, sizeof(normalized_domain))))
+        return CATTA_ERR_INVALID_DOMAIN_NAME;
 
     /* Concatenation */
 
     snprintf(p, size, "%s%s%s.%s", name ? escaped_name : "", name ? "." : "", normalized_type, normalized_domain);
 
-    return AVAHI_OK;
+    return CATTA_OK;
 }
 
 #ifndef HAVE_STRLCPY
@@ -493,7 +493,7 @@ static size_t strlcpy(char *dest, const char *src, size_t n) {
 
 #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) {
+int catta_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,
@@ -519,7 +519,7 @@ int avahi_service_name_split(const char *p, char *name, size_t name_size, char *
     while (*p) {
         char buf[64];
 
-        if (!(avahi_unescape_label(&p, buf, sizeof(buf))))
+        if (!(catta_unescape_label(&p, buf, sizeof(buf))))
             return -1;
 
         switch (state) {
@@ -534,7 +534,7 @@ int avahi_service_name_split(const char *p, char *name, size_t name_size, char *
 
                     if (!type_empty) {
                         if (!type_size)
-                            return AVAHI_ERR_NO_MEMORY;
+                            return CATTA_ERR_NO_MEMORY;
 
                         *(type++) = '.';
                         type_size --;
@@ -542,8 +542,8 @@ int avahi_service_name_split(const char *p, char *name, size_t name_size, char *
                     } else
                         type_empty = 0;
 
-                    if (!(avahi_escape_label(buf, strlen(buf), &type, &type_size)))
-                        return AVAHI_ERR_NO_MEMORY;
+                    if (!(catta_escape_label(buf, strlen(buf), &type, &type_size)))
+                        return CATTA_ERR_NO_MEMORY;
 
                     break;
                 }
@@ -555,15 +555,15 @@ int avahi_service_name_split(const char *p, char *name, size_t name_size, char *
 
                 if (!domain_empty) {
                     if (!domain_size)
-                        return AVAHI_ERR_NO_MEMORY;
+                        return CATTA_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;
+                if (!(catta_escape_label(buf, strlen(buf), &domain, &domain_size)))
+                    return CATTA_ERR_NO_MEMORY;
 
                 break;
         }
@@ -572,37 +572,37 @@ int avahi_service_name_split(const char *p, char *name, size_t name_size, char *
     return 0;
 }
 
-int avahi_is_valid_fqdn(const char *t) {
-    char label[AVAHI_LABEL_MAX];
-    char normalized[AVAHI_DOMAIN_NAME_MAX];
+int catta_is_valid_fqdn(const char *t) {
+    char label[CATTA_LABEL_MAX];
+    char normalized[CATTA_DOMAIN_NAME_MAX];
     const char *k = t;
-    AvahiAddress a;
+    CattaAddress a;
     assert(t);
 
-    if (strlen(t) >= AVAHI_DOMAIN_NAME_MAX)
+    if (strlen(t) >= CATTA_DOMAIN_NAME_MAX)
         return 0;
 
-    if (!avahi_is_valid_domain_name(t))
+    if (!catta_is_valid_domain_name(t))
         return 0;
 
     /* Check if there are at least two labels*/
-    if (!(avahi_unescape_label(&k, label, sizeof(label))))
+    if (!(catta_unescape_label(&k, label, sizeof(label))))
         return 0;
 
     if (label[0] == 0 || !k)
         return 0;
 
-    if (!(avahi_unescape_label(&k, label, sizeof(label))))
+    if (!(catta_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))))
+    if (!(catta_normalize_name(t, normalized, sizeof(normalized))))
         return 0;
 
-    if (avahi_address_parse(normalized, AVAHI_PROTO_UNSPEC, &a))
+    if (catta_address_parse(normalized, CATTA_PROTO_UNSPEC, &a))
         return 0;
 
     return 1;
index 4b66c100bda38df205bf1e623372070ce335fe3c..a56e0bd6407c8571c93a98195a506760d6a5f80d 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <sys/types.h>
 #include <sys/socket.h>
 
-#include <avahi/domain.h>
-#include <avahi/timeval.h>
-#include <avahi/malloc.h>
-#include <avahi/error.h>
-#include <avahi/domain.h>
-#include <avahi/log.h>
+#include <catta/domain.h>
+#include <catta/timeval.h>
+#include <catta/malloc.h>
+#include <catta/error.h>
+#include <catta/domain.h>
+#include <catta/log.h>
 
 #include "internal.h"
 #include "iface.h"
 #include "rr-util.h"
 #include "domain-util.h"
 
-static void transport_flags_from_domain(AvahiServer *s, AvahiPublishFlags *flags, const char *domain) {
+static void transport_flags_from_domain(CattaServer *s, CattaPublishFlags *flags, const char *domain) {
     assert(flags);
     assert(domain);
 
-    assert(!((*flags & AVAHI_PUBLISH_USE_MULTICAST) && (*flags & AVAHI_PUBLISH_USE_WIDE_AREA)));
+    assert(!((*flags & CATTA_PUBLISH_USE_MULTICAST) && (*flags & CATTA_PUBLISH_USE_WIDE_AREA)));
 
-    if (*flags & (AVAHI_PUBLISH_USE_MULTICAST|AVAHI_PUBLISH_USE_WIDE_AREA))
+    if (*flags & (CATTA_PUBLISH_USE_MULTICAST|CATTA_PUBLISH_USE_WIDE_AREA))
         return;
 
     if (!s->wide_area_lookup_engine ||
-        !avahi_wide_area_has_servers(s->wide_area_lookup_engine) ||
-        avahi_domain_ends_with(domain, AVAHI_MDNS_SUFFIX_LOCAL) ||
-        avahi_domain_ends_with(domain, AVAHI_MDNS_SUFFIX_ADDR_IPV4) ||
-        avahi_domain_ends_with(domain, AVAHI_MDNS_SUFFIX_ADDR_IPV6))
-        *flags |= AVAHI_PUBLISH_USE_MULTICAST;
+        !catta_wide_area_has_servers(s->wide_area_lookup_engine) ||
+        catta_domain_ends_with(domain, CATTA_MDNS_SUFFIX_LOCAL) ||
+        catta_domain_ends_with(domain, CATTA_MDNS_SUFFIX_ADDR_IPV4) ||
+        catta_domain_ends_with(domain, CATTA_MDNS_SUFFIX_ADDR_IPV6))
+        *flags |= CATTA_PUBLISH_USE_MULTICAST;
     else
-        *flags |= AVAHI_PUBLISH_USE_WIDE_AREA;
+        *flags |= CATTA_PUBLISH_USE_WIDE_AREA;
 }
 
-void avahi_entry_free(AvahiServer*s, AvahiEntry *e) {
-    AvahiEntry *t;
+void catta_entry_free(CattaServer*s, CattaEntry *e) {
+    CattaEntry *t;
 
     assert(s);
     assert(e);
 
-    avahi_goodbye_entry(s, e, 1, 1);
+    catta_goodbye_entry(s, e, 1, 1);
 
     /* Remove from linked list */
-    AVAHI_LLIST_REMOVE(AvahiEntry, entries, s->entries, e);
+    CATTA_LLIST_REMOVE(CattaEntry, entries, s->entries, e);
 
     /* Remove from hash table indexed by name */
-    t = avahi_hashmap_lookup(s->entries_by_key, e->record->key);
-    AVAHI_LLIST_REMOVE(AvahiEntry, by_key, t, e);
+    t = catta_hashmap_lookup(s->entries_by_key, e->record->key);
+    CATTA_LLIST_REMOVE(CattaEntry, by_key, t, e);
     if (t)
-        avahi_hashmap_replace(s->entries_by_key, t->record->key, t);
+        catta_hashmap_replace(s->entries_by_key, t->record->key, t);
     else
-        avahi_hashmap_remove(s->entries_by_key, e->record->key);
+        catta_hashmap_remove(s->entries_by_key, e->record->key);
 
     /* Remove from associated group */
     if (e->group)
-        AVAHI_LLIST_REMOVE(AvahiEntry, by_group, e->group->entries, e);
+        CATTA_LLIST_REMOVE(CattaEntry, by_group, e->group->entries, e);
 
-    avahi_record_unref(e->record);
-    avahi_free(e);
+    catta_record_unref(e->record);
+    catta_free(e);
 }
 
-void avahi_entry_group_free(AvahiServer *s, AvahiSEntryGroup *g) {
+void catta_entry_group_free(CattaServer *s, CattaSEntryGroup *g) {
     assert(s);
     assert(g);
 
     while (g->entries)
-        avahi_entry_free(s, g->entries);
+        catta_entry_free(s, g->entries);
 
     if (g->register_time_event)
-        avahi_time_event_free(g->register_time_event);
+        catta_time_event_free(g->register_time_event);
 
-    AVAHI_LLIST_REMOVE(AvahiSEntryGroup, groups, s->groups, g);
-    avahi_free(g);
+    CATTA_LLIST_REMOVE(CattaSEntryGroup, groups, s->groups, g);
+    catta_free(g);
 }
 
-void avahi_cleanup_dead_entries(AvahiServer *s) {
+void catta_cleanup_dead_entries(CattaServer *s) {
     assert(s);
 
     if (s->need_group_cleanup) {
-        AvahiSEntryGroup *g, *next;
+        CattaSEntryGroup *g, *next;
 
         for (g = s->groups; g; g = next) {
             next = g->groups_next;
 
             if (g->dead)
-                avahi_entry_group_free(s, g);
+                catta_entry_group_free(s, g);
         }
 
         s->need_group_cleanup = 0;
     }
 
     if (s->need_entry_cleanup) {
-        AvahiEntry *e, *next;
+        CattaEntry *e, *next;
 
         for (e = s->entries; e; e = next) {
             next = e->entries_next;
 
             if (e->dead)
-                avahi_entry_free(s, e);
+                catta_entry_free(s, e);
         }
 
         s->need_entry_cleanup = 0;
     }
 
     if (s->need_browser_cleanup)
-        avahi_browser_cleanup(s);
+        catta_browser_cleanup(s);
 
     if (s->cleanup_time_event) {
-        avahi_time_event_free(s->cleanup_time_event);
+        catta_time_event_free(s->cleanup_time_event);
         s->cleanup_time_event = NULL;
     }
 }
 
-static int check_record_conflict(AvahiServer *s, AvahiIfIndex interface, AvahiProtocol protocol, AvahiRecord *r, AvahiPublishFlags flags) {
-    AvahiEntry *e;
+static int check_record_conflict(CattaServer *s, CattaIfIndex interface, CattaProtocol protocol, CattaRecord *r, CattaPublishFlags flags) {
+    CattaEntry *e;
 
     assert(s);
     assert(r);
 
-    for (e = avahi_hashmap_lookup(s->entries_by_key, r->key); e; e = e->by_key_next) {
+    for (e = catta_hashmap_lookup(s->entries_by_key, r->key); e; e = e->by_key_next) {
         if (e->dead)
             continue;
 
-        if (!(flags & AVAHI_PUBLISH_UNIQUE) && !(e->flags & AVAHI_PUBLISH_UNIQUE))
+        if (!(flags & CATTA_PUBLISH_UNIQUE) && !(e->flags & CATTA_PUBLISH_UNIQUE))
             continue;
 
-        if ((flags & AVAHI_PUBLISH_ALLOW_MULTIPLE) && (e->flags & AVAHI_PUBLISH_ALLOW_MULTIPLE) )
+        if ((flags & CATTA_PUBLISH_ALLOW_MULTIPLE) && (e->flags & CATTA_PUBLISH_ALLOW_MULTIPLE) )
             continue;
 
-        if (avahi_record_equal_no_ttl(r, e->record)) {
+        if (catta_record_equal_no_ttl(r, e->record)) {
             /* The records are the same, not a conflict in any case */
             continue;
         }
@@ -172,8 +172,8 @@ static int check_record_conflict(AvahiServer *s, AvahiIfIndex interface, AvahiPr
         if ((interface <= 0 ||
              e->interface <= 0 ||
              e->interface == interface) &&
-            (protocol == AVAHI_PROTO_UNSPEC ||
-             e->protocol == AVAHI_PROTO_UNSPEC ||
+            (protocol == CATTA_PROTO_UNSPEC ||
+             e->protocol == CATTA_PROTO_UNSPEC ||
              e->protocol == protocol))
 
             return -1;
@@ -182,61 +182,61 @@ static int check_record_conflict(AvahiServer *s, AvahiIfIndex interface, AvahiPr
     return 0;
 }
 
-static AvahiEntry * server_add_internal(
-    AvahiServer *s,
-    AvahiSEntryGroup *g,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiPublishFlags flags,
-    AvahiRecord *r) {
+static CattaEntry * server_add_internal(
+    CattaServer *s,
+    CattaSEntryGroup *g,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaPublishFlags flags,
+    CattaRecord *r) {
 
-    AvahiEntry *e;
+    CattaEntry *e;
 
     assert(s);
     assert(r);
 
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(s, s->state != AVAHI_SERVER_FAILURE && s->state != AVAHI_SERVER_INVALID, AVAHI_ERR_BAD_STATE);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(s, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(s, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(s, AVAHI_FLAGS_VALID(
+    CATTA_CHECK_VALIDITY_RETURN_NULL(s, s->state != CATTA_SERVER_FAILURE && s->state != CATTA_SERVER_INVALID, CATTA_ERR_BAD_STATE);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(s, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(s, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(s, CATTA_FLAGS_VALID(
                                          flags,
-                                         AVAHI_PUBLISH_NO_ANNOUNCE|
-                                         AVAHI_PUBLISH_NO_PROBE|
-                                         AVAHI_PUBLISH_UNIQUE|
-                                         AVAHI_PUBLISH_ALLOW_MULTIPLE|
-                                         AVAHI_PUBLISH_UPDATE|
-                                         AVAHI_PUBLISH_USE_WIDE_AREA|
-                                         AVAHI_PUBLISH_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(s, avahi_is_valid_domain_name(r->key->name), AVAHI_ERR_INVALID_HOST_NAME);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(s, r->ttl != 0, AVAHI_ERR_INVALID_TTL);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(s, !avahi_key_is_pattern(r->key), AVAHI_ERR_IS_PATTERN);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(s, avahi_record_is_valid(r), AVAHI_ERR_INVALID_RECORD);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(s, r->key->clazz == AVAHI_DNS_CLASS_IN, AVAHI_ERR_INVALID_DNS_CLASS);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(s,
+                                         CATTA_PUBLISH_NO_ANNOUNCE|
+                                         CATTA_PUBLISH_NO_PROBE|
+                                         CATTA_PUBLISH_UNIQUE|
+                                         CATTA_PUBLISH_ALLOW_MULTIPLE|
+                                         CATTA_PUBLISH_UPDATE|
+                                         CATTA_PUBLISH_USE_WIDE_AREA|
+                                         CATTA_PUBLISH_USE_MULTICAST), CATTA_ERR_INVALID_FLAGS);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(s, catta_is_valid_domain_name(r->key->name), CATTA_ERR_INVALID_HOST_NAME);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(s, r->ttl != 0, CATTA_ERR_INVALID_TTL);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(s, !catta_key_is_pattern(r->key), CATTA_ERR_IS_PATTERN);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(s, catta_record_is_valid(r), CATTA_ERR_INVALID_RECORD);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(s, r->key->clazz == CATTA_DNS_CLASS_IN, CATTA_ERR_INVALID_DNS_CLASS);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(s,
                                      (r->key->type != 0) &&
-                                     (r->key->type != AVAHI_DNS_TYPE_ANY) &&
-                                     (r->key->type != AVAHI_DNS_TYPE_OPT) &&
-                                     (r->key->type != AVAHI_DNS_TYPE_TKEY) &&
-                                     (r->key->type != AVAHI_DNS_TYPE_TSIG) &&
-                                     (r->key->type != AVAHI_DNS_TYPE_IXFR) &&
-                                     (r->key->type != AVAHI_DNS_TYPE_AXFR), AVAHI_ERR_INVALID_DNS_TYPE);
+                                     (r->key->type != CATTA_DNS_TYPE_ANY) &&
+                                     (r->key->type != CATTA_DNS_TYPE_OPT) &&
+                                     (r->key->type != CATTA_DNS_TYPE_TKEY) &&
+                                     (r->key->type != CATTA_DNS_TYPE_TSIG) &&
+                                     (r->key->type != CATTA_DNS_TYPE_IXFR) &&
+                                     (r->key->type != CATTA_DNS_TYPE_AXFR), CATTA_ERR_INVALID_DNS_TYPE);
 
     transport_flags_from_domain(s, &flags, r->key->name);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(s, flags & AVAHI_PUBLISH_USE_MULTICAST, AVAHI_ERR_NOT_SUPPORTED);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(s, !s->config.disable_publishing, AVAHI_ERR_NOT_PERMITTED);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(s,
+    CATTA_CHECK_VALIDITY_RETURN_NULL(s, flags & CATTA_PUBLISH_USE_MULTICAST, CATTA_ERR_NOT_SUPPORTED);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(s, !s->config.disable_publishing, CATTA_ERR_NOT_PERMITTED);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(s,
                                      !g ||
-                                     (g->state != AVAHI_ENTRY_GROUP_ESTABLISHED && g->state != AVAHI_ENTRY_GROUP_REGISTERING) ||
-                                     (flags & AVAHI_PUBLISH_UPDATE), AVAHI_ERR_BAD_STATE);
+                                     (g->state != CATTA_ENTRY_GROUP_ESTABLISHED && g->state != CATTA_ENTRY_GROUP_REGISTERING) ||
+                                     (flags & CATTA_PUBLISH_UPDATE), CATTA_ERR_BAD_STATE);
 
-    if (flags & AVAHI_PUBLISH_UPDATE) {
-        AvahiRecord *old_record;
+    if (flags & CATTA_PUBLISH_UPDATE) {
+        CattaRecord *old_record;
         int is_first = 1;
 
         /* Update and existing record */
 
         /* Find the first matching entry */
-        for (e = avahi_hashmap_lookup(s->entries_by_key, r->key); e; e = e->by_key_next) {
+        for (e = catta_hashmap_lookup(s->entries_by_key, r->key); e; e = e->by_key_next) {
             if (!e->dead && e->group == g && e->interface == interface && e->protocol == protocol)
                 break;
 
@@ -245,90 +245,90 @@ static AvahiEntry * server_add_internal(
 
         /* Hmm, nothing found? */
         if (!e) {
-            avahi_server_set_errno(s, AVAHI_ERR_NOT_FOUND);
+            catta_server_set_errno(s, CATTA_ERR_NOT_FOUND);
             return NULL;
         }
 
         /* Update the entry */
         old_record = e->record;
-        e->record = avahi_record_ref(r);
+        e->record = catta_record_ref(r);
         e->flags = flags;
 
         /* Announce our changes when needed */
-        if (!avahi_record_equal_no_ttl(old_record, r) && (!g || g->state != AVAHI_ENTRY_GROUP_UNCOMMITED)) {
+        if (!catta_record_equal_no_ttl(old_record, r) && (!g || g->state != CATTA_ENTRY_GROUP_UNCOMMITED)) {
 
             /* Remove the old entry from all caches, if needed */
-            if (!(e->flags & AVAHI_PUBLISH_UNIQUE))
-                avahi_goodbye_entry(s, e, 1, 0);
+            if (!(e->flags & CATTA_PUBLISH_UNIQUE))
+                catta_goodbye_entry(s, e, 1, 0);
 
             /* Reannounce our updated entry */
-            avahi_reannounce_entry(s, e);
+            catta_reannounce_entry(s, e);
         }
 
         /* If we were the first entry in the list, we need to update the key */
         if (is_first)
-            avahi_hashmap_replace(s->entries_by_key, e->record->key, e);
+            catta_hashmap_replace(s->entries_by_key, e->record->key, e);
 
-        avahi_record_unref(old_record);
+        catta_record_unref(old_record);
 
     } else {
-        AvahiEntry *t;
+        CattaEntry *t;
 
         /* Add a new record */
 
         if (check_record_conflict(s, interface, protocol, r, flags) < 0) {
-            avahi_server_set_errno(s, AVAHI_ERR_COLLISION);
+            catta_server_set_errno(s, CATTA_ERR_COLLISION);
             return NULL;
         }
 
-        if (!(e = avahi_new(AvahiEntry, 1))) {
-            avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
+        if (!(e = catta_new(CattaEntry, 1))) {
+            catta_server_set_errno(s, CATTA_ERR_NO_MEMORY);
             return NULL;
         }
 
         e->server = s;
-        e->record = avahi_record_ref(r);
+        e->record = catta_record_ref(r);
         e->group = g;
         e->interface = interface;
         e->protocol = protocol;
         e->flags = flags;
         e->dead = 0;
 
-        AVAHI_LLIST_HEAD_INIT(AvahiAnnouncer, e->announcers);
+        CATTA_LLIST_HEAD_INIT(CattaAnnouncer, e->announcers);
 
-        AVAHI_LLIST_PREPEND(AvahiEntry, entries, s->entries, e);
+        CATTA_LLIST_PREPEND(CattaEntry, entries, s->entries, e);
 
         /* Insert into hash table indexed by name */
-        t = avahi_hashmap_lookup(s->entries_by_key, e->record->key);
-        AVAHI_LLIST_PREPEND(AvahiEntry, by_key, t, e);
-        avahi_hashmap_replace(s->entries_by_key, e->record->key, t);
+        t = catta_hashmap_lookup(s->entries_by_key, e->record->key);
+        CATTA_LLIST_PREPEND(CattaEntry, by_key, t, e);
+        catta_hashmap_replace(s->entries_by_key, e->record->key, t);
 
         /* Insert into group list */
         if (g)
-            AVAHI_LLIST_PREPEND(AvahiEntry, by_group, g->entries, e);
+            CATTA_LLIST_PREPEND(CattaEntry, by_group, g->entries, e);
 
-        avahi_announce_entry(s, e);
+        catta_announce_entry(s, e);
     }
 
     return e;
 }
 
-int avahi_server_add(
-    AvahiServer *s,
-    AvahiSEntryGroup *g,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiPublishFlags flags,
-    AvahiRecord *r) {
+int catta_server_add(
+    CattaServer *s,
+    CattaSEntryGroup *g,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaPublishFlags flags,
+    CattaRecord *r) {
 
     if (!server_add_internal(s, g, interface, protocol, flags, r))
-        return avahi_server_errno(s);
+        return catta_server_errno(s);
 
-    return AVAHI_OK;
+    return CATTA_OK;
 }
 
-const AvahiRecord *avahi_server_iterate(AvahiServer *s, AvahiSEntryGroup *g, void **state) {
-    AvahiEntry **e = (AvahiEntry**) state;
+const CattaRecord *catta_server_iterate(CattaServer *s, CattaSEntryGroup *g, void **state) {
+    CattaEntry **e = (CattaEntry**) state;
     assert(s);
     assert(e);
 
@@ -341,11 +341,11 @@ const AvahiRecord *avahi_server_iterate(AvahiServer *s, AvahiSEntryGroup *g, voi
     if (!*e)
         return NULL;
 
-    return avahi_record_ref((*e)->record);
+    return catta_record_ref((*e)->record);
 }
 
-int avahi_server_dump(AvahiServer *s, AvahiDumpCallback callback, void* userdata) {
-    AvahiEntry *e;
+int catta_server_dump(CattaServer *s, CattaDumpCallback callback, void* userdata) {
+    CattaEntry *e;
 
     assert(s);
     assert(callback);
@@ -359,246 +359,246 @@ int avahi_server_dump(AvahiServer *s, AvahiDumpCallback callback, void* userdata
         if (e->dead)
             continue;
 
-        if (!(t = avahi_record_to_string(e->record)))
-            return avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
+        if (!(t = catta_record_to_string(e->record)))
+            return catta_server_set_errno(s, CATTA_ERR_NO_MEMORY);
 
         snprintf(ln, sizeof(ln), "%s ; iface=%i proto=%i", t, e->interface, e->protocol);
-        avahi_free(t);
+        catta_free(t);
 
         callback(ln, userdata);
     }
 
-    avahi_dump_caches(s->monitor, callback, userdata);
+    catta_dump_caches(s->monitor, callback, userdata);
 
     if (s->wide_area_lookup_engine)
-        avahi_wide_area_cache_dump(s->wide_area_lookup_engine, callback, userdata);
-    return AVAHI_OK;
+        catta_wide_area_cache_dump(s->wide_area_lookup_engine, callback, userdata);
+    return CATTA_OK;
 }
 
-static AvahiEntry *server_add_ptr_internal(
-    AvahiServer *s,
-    AvahiSEntryGroup *g,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiPublishFlags flags,
+static CattaEntry *server_add_ptr_internal(
+    CattaServer *s,
+    CattaSEntryGroup *g,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaPublishFlags flags,
     uint32_t ttl,
     const char *name,
     const char *dest) {
 
-    AvahiRecord *r;
-    AvahiEntry *e;
+    CattaRecord *r;
+    CattaEntry *e;
 
     assert(s);
     assert(dest);
 
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(s, !name || avahi_is_valid_domain_name(name), AVAHI_ERR_INVALID_HOST_NAME);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(s, avahi_is_valid_domain_name(dest), AVAHI_ERR_INVALID_HOST_NAME);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(s, !name || catta_is_valid_domain_name(name), CATTA_ERR_INVALID_HOST_NAME);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(s, catta_is_valid_domain_name(dest), CATTA_ERR_INVALID_HOST_NAME);
 
     if (!name)
         name = s->host_name_fqdn;
 
-    if (!(r = avahi_record_new_full(name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR, ttl))) {
-        avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
+    if (!(r = catta_record_new_full(name, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_PTR, ttl))) {
+        catta_server_set_errno(s, CATTA_ERR_NO_MEMORY);
         return NULL;
     }
 
-    r->data.ptr.name = avahi_normalize_name_strdup(dest);
+    r->data.ptr.name = catta_normalize_name_strdup(dest);
     e = server_add_internal(s, g, interface, protocol, flags, r);
-    avahi_record_unref(r);
+    catta_record_unref(r);
     return e;
 }
 
-int avahi_server_add_ptr(
-    AvahiServer *s,
-    AvahiSEntryGroup *g,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiPublishFlags flags,
+int catta_server_add_ptr(
+    CattaServer *s,
+    CattaSEntryGroup *g,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaPublishFlags flags,
     uint32_t ttl,
     const char *name,
     const char *dest) {
 
-    AvahiEntry *e;
+    CattaEntry *e;
 
     assert(s);
 
     if (!(e = server_add_ptr_internal(s, g, interface, protocol, flags, ttl, name, dest)))
-        return avahi_server_errno(s);
+        return catta_server_errno(s);
 
-    return AVAHI_OK;
+    return CATTA_OK;
 }
 
-int avahi_server_add_address(
-    AvahiServer *s,
-    AvahiSEntryGroup *g,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiPublishFlags flags,
+int catta_server_add_address(
+    CattaServer *s,
+    CattaSEntryGroup *g,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaPublishFlags flags,
     const char *name,
-    AvahiAddress *a) {
+    CattaAddress *a) {
 
-    char n[AVAHI_DOMAIN_NAME_MAX];
-    int ret = AVAHI_OK;
-    AvahiEntry *entry = NULL, *reverse = NULL;
-    AvahiRecord  *r;
+    char n[CATTA_DOMAIN_NAME_MAX];
+    int ret = CATTA_OK;
+    CattaEntry *entry = NULL, *reverse = NULL;
+    CattaRecord  *r;
 
     assert(s);
     assert(a);
 
-    AVAHI_CHECK_VALIDITY(s, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
-    AVAHI_CHECK_VALIDITY(s, AVAHI_PROTO_VALID(protocol) && AVAHI_PROTO_VALID(a->proto), AVAHI_ERR_INVALID_PROTOCOL);
-    AVAHI_CHECK_VALIDITY(s, AVAHI_FLAGS_VALID(flags,
-                                              AVAHI_PUBLISH_NO_REVERSE|
-                                              AVAHI_PUBLISH_NO_ANNOUNCE|
-                                              AVAHI_PUBLISH_NO_PROBE|
-                                              AVAHI_PUBLISH_UPDATE|
-                                              AVAHI_PUBLISH_USE_WIDE_AREA|
-                                              AVAHI_PUBLISH_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
-    AVAHI_CHECK_VALIDITY(s, !name || avahi_is_valid_fqdn(name), AVAHI_ERR_INVALID_HOST_NAME);
+    CATTA_CHECK_VALIDITY(s, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+    CATTA_CHECK_VALIDITY(s, CATTA_PROTO_VALID(protocol) && CATTA_PROTO_VALID(a->proto), CATTA_ERR_INVALID_PROTOCOL);
+    CATTA_CHECK_VALIDITY(s, CATTA_FLAGS_VALID(flags,
+                                              CATTA_PUBLISH_NO_REVERSE|
+                                              CATTA_PUBLISH_NO_ANNOUNCE|
+                                              CATTA_PUBLISH_NO_PROBE|
+                                              CATTA_PUBLISH_UPDATE|
+                                              CATTA_PUBLISH_USE_WIDE_AREA|
+                                              CATTA_PUBLISH_USE_MULTICAST), CATTA_ERR_INVALID_FLAGS);
+    CATTA_CHECK_VALIDITY(s, !name || catta_is_valid_fqdn(name), CATTA_ERR_INVALID_HOST_NAME);
 
     /* Prepare the host naem */
 
     if (!name)
         name = s->host_name_fqdn;
     else {
-        AVAHI_ASSERT_TRUE(avahi_normalize_name(name, n, sizeof(n)));
+        CATTA_ASSERT_TRUE(catta_normalize_name(name, n, sizeof(n)));
         name = n;
     }
 
     transport_flags_from_domain(s, &flags, name);
-    AVAHI_CHECK_VALIDITY(s, flags & AVAHI_PUBLISH_USE_MULTICAST, AVAHI_ERR_NOT_SUPPORTED);
+    CATTA_CHECK_VALIDITY(s, flags & CATTA_PUBLISH_USE_MULTICAST, CATTA_ERR_NOT_SUPPORTED);
 
     /* Create the A/AAAA record */
 
-    if (a->proto == AVAHI_PROTO_INET) {
+    if (a->proto == CATTA_PROTO_INET) {
 
-        if (!(r = avahi_record_new_full(name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_A, AVAHI_DEFAULT_TTL_HOST_NAME))) {
-            ret = avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
+        if (!(r = catta_record_new_full(name, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_A, CATTA_DEFAULT_TTL_HOST_NAME))) {
+            ret = catta_server_set_errno(s, CATTA_ERR_NO_MEMORY);
             goto finish;
         }
 
         r->data.a.address = a->data.ipv4;
 
     } else {
-        assert(a->proto == AVAHI_PROTO_INET6);
+        assert(a->proto == CATTA_PROTO_INET6);
 
-        if (!(r = avahi_record_new_full(name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_AAAA, AVAHI_DEFAULT_TTL_HOST_NAME))) {
-            ret = avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
+        if (!(r = catta_record_new_full(name, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_AAAA, CATTA_DEFAULT_TTL_HOST_NAME))) {
+            ret = catta_server_set_errno(s, CATTA_ERR_NO_MEMORY);
             goto finish;
         }
 
         r->data.aaaa.address = a->data.ipv6;
     }
 
-    entry = server_add_internal(s, g, interface, protocol, (flags & ~ AVAHI_PUBLISH_NO_REVERSE) | AVAHI_PUBLISH_UNIQUE | AVAHI_PUBLISH_ALLOW_MULTIPLE, r);
-    avahi_record_unref(r);
+    entry = server_add_internal(s, g, interface, protocol, (flags & ~ CATTA_PUBLISH_NO_REVERSE) | CATTA_PUBLISH_UNIQUE | CATTA_PUBLISH_ALLOW_MULTIPLE, r);
+    catta_record_unref(r);
 
     if (!entry) {
-        ret = avahi_server_errno(s);
+        ret = catta_server_errno(s);
         goto finish;
     }
 
     /* Create the reverse lookup entry */
 
-    if (!(flags & AVAHI_PUBLISH_NO_REVERSE)) {
-        char reverse_n[AVAHI_DOMAIN_NAME_MAX];
-        avahi_reverse_lookup_name(a, reverse_n, sizeof(reverse_n));
+    if (!(flags & CATTA_PUBLISH_NO_REVERSE)) {
+        char reverse_n[CATTA_DOMAIN_NAME_MAX];
+        catta_reverse_lookup_name(a, reverse_n, sizeof(reverse_n));
 
-        if (!(reverse = server_add_ptr_internal(s, g, interface, protocol, flags | AVAHI_PUBLISH_UNIQUE, AVAHI_DEFAULT_TTL_HOST_NAME, reverse_n, name))) {
-            ret = avahi_server_errno(s);
+        if (!(reverse = server_add_ptr_internal(s, g, interface, protocol, flags | CATTA_PUBLISH_UNIQUE, CATTA_DEFAULT_TTL_HOST_NAME, reverse_n, name))) {
+            ret = catta_server_errno(s);
             goto finish;
         }
     }
 
 finish:
 
-    if (ret != AVAHI_OK && !(flags & AVAHI_PUBLISH_UPDATE)) {
+    if (ret != CATTA_OK && !(flags & CATTA_PUBLISH_UPDATE)) {
         if (entry)
-            avahi_entry_free(s, entry);
+            catta_entry_free(s, entry);
         if (reverse)
-            avahi_entry_free(s, reverse);
+            catta_entry_free(s, reverse);
     }
 
     return ret;
 }
 
-static AvahiEntry *server_add_txt_strlst_nocopy(
-    AvahiServer *s,
-    AvahiSEntryGroup *g,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiPublishFlags flags,
+static CattaEntry *server_add_txt_strlst_nocopy(
+    CattaServer *s,
+    CattaSEntryGroup *g,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaPublishFlags flags,
     uint32_t ttl,
     const char *name,
-    AvahiStringList *strlst) {
+    CattaStringList *strlst) {
 
-    AvahiRecord *r;
-    AvahiEntry *e;
+    CattaRecord *r;
+    CattaEntry *e;
 
     assert(s);
 
-    if (!(r = avahi_record_new_full(name ? name : s->host_name_fqdn, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_TXT, ttl))) {
-        avahi_string_list_free(strlst);
-        avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
+    if (!(r = catta_record_new_full(name ? name : s->host_name_fqdn, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_TXT, ttl))) {
+        catta_string_list_free(strlst);
+        catta_server_set_errno(s, CATTA_ERR_NO_MEMORY);
         return NULL;
     }
 
     r->data.txt.string_list = strlst;
     e = server_add_internal(s, g, interface, protocol, flags, r);
-    avahi_record_unref(r);
+    catta_record_unref(r);
 
     return e;
 }
 
-static AvahiStringList *add_magic_cookie(
-    AvahiServer *s,
-    AvahiStringList *strlst) {
+static CattaStringList *add_magic_cookie(
+    CattaServer *s,
+    CattaStringList *strlst) {
 
     assert(s);
 
     if (!s->config.add_service_cookie)
         return strlst;
 
-    if (avahi_string_list_find(strlst, AVAHI_SERVICE_COOKIE))
+    if (catta_string_list_find(strlst, CATTA_SERVICE_COOKIE))
         /* This string list already contains a magic cookie */
         return strlst;
 
-    return avahi_string_list_add_printf(strlst, AVAHI_SERVICE_COOKIE"=%u", s->local_service_cookie);
+    return catta_string_list_add_printf(strlst, CATTA_SERVICE_COOKIE"=%u", s->local_service_cookie);
 }
 
 static int server_add_service_strlst_nocopy(
-    AvahiServer *s,
-    AvahiSEntryGroup *g,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiPublishFlags flags,
+    CattaServer *s,
+    CattaSEntryGroup *g,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaPublishFlags flags,
     const char *name,
     const char *type,
     const char *domain,
     const char *host,
     uint16_t port,
-    AvahiStringList *strlst) {
+    CattaStringList *strlst) {
 
-    char ptr_name[AVAHI_DOMAIN_NAME_MAX], svc_name[AVAHI_DOMAIN_NAME_MAX], enum_ptr[AVAHI_DOMAIN_NAME_MAX], *h = NULL;
-    AvahiRecord *r = NULL;
-    int ret = AVAHI_OK;
-    AvahiEntry *srv_entry = NULL, *txt_entry = NULL, *ptr_entry = NULL, *enum_entry = NULL;
+    char ptr_name[CATTA_DOMAIN_NAME_MAX], svc_name[CATTA_DOMAIN_NAME_MAX], enum_ptr[CATTA_DOMAIN_NAME_MAX], *h = NULL;
+    CattaRecord *r = NULL;
+    int ret = CATTA_OK;
+    CattaEntry *srv_entry = NULL, *txt_entry = NULL, *ptr_entry = NULL, *enum_entry = NULL;
 
     assert(s);
     assert(type);
     assert(name);
 
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL);
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_FLAGS_VALID(flags,
-                                                                AVAHI_PUBLISH_NO_COOKIE|
-                                                                AVAHI_PUBLISH_UPDATE|
-                                                                AVAHI_PUBLISH_USE_WIDE_AREA|
-                                                                AVAHI_PUBLISH_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, avahi_is_valid_service_name(name), AVAHI_ERR_INVALID_SERVICE_NAME);
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, avahi_is_valid_service_type_strict(type), AVAHI_ERR_INVALID_SERVICE_TYPE);
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME);
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, !host || avahi_is_valid_fqdn(host), AVAHI_ERR_INVALID_HOST_NAME);
+    CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+    CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
+    CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, CATTA_FLAGS_VALID(flags,
+                                                                CATTA_PUBLISH_NO_COOKIE|
+                                                                CATTA_PUBLISH_UPDATE|
+                                                                CATTA_PUBLISH_USE_WIDE_AREA|
+                                                                CATTA_PUBLISH_USE_MULTICAST), CATTA_ERR_INVALID_FLAGS);
+    CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, catta_is_valid_service_name(name), CATTA_ERR_INVALID_SERVICE_NAME);
+    CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, catta_is_valid_service_type_strict(type), CATTA_ERR_INVALID_SERVICE_TYPE);
+    CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, !domain || catta_is_valid_domain_name(domain), CATTA_ERR_INVALID_DOMAIN_NAME);
+    CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, !host || catta_is_valid_fqdn(host), CATTA_ERR_INVALID_HOST_NAME);
 
     if (!domain)
         domain = s->domain_name;
@@ -607,31 +607,31 @@ static int server_add_service_strlst_nocopy(
         host = s->host_name_fqdn;
 
     transport_flags_from_domain(s, &flags, domain);
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, flags & AVAHI_PUBLISH_USE_MULTICAST, AVAHI_ERR_NOT_SUPPORTED);
+    CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, flags & CATTA_PUBLISH_USE_MULTICAST, CATTA_ERR_NOT_SUPPORTED);
 
-    if (!(h = avahi_normalize_name_strdup(host))) {
-        ret = avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
+    if (!(h = catta_normalize_name_strdup(host))) {
+        ret = catta_server_set_errno(s, CATTA_ERR_NO_MEMORY);
         goto fail;
     }
 
-    if ((ret = avahi_service_name_join(svc_name, sizeof(svc_name), name, type, domain)) < 0 ||
-        (ret = avahi_service_name_join(ptr_name, sizeof(ptr_name), NULL, type, domain)) < 0 ||
-        (ret = avahi_service_name_join(enum_ptr, sizeof(enum_ptr), NULL, "_services._dns-sd._udp", domain)) < 0) {
-        avahi_server_set_errno(s, ret);
+    if ((ret = catta_service_name_join(svc_name, sizeof(svc_name), name, type, domain)) < 0 ||
+        (ret = catta_service_name_join(ptr_name, sizeof(ptr_name), NULL, type, domain)) < 0 ||
+        (ret = catta_service_name_join(enum_ptr, sizeof(enum_ptr), NULL, "_services._dns-sd._udp", domain)) < 0) {
+        catta_server_set_errno(s, ret);
         goto fail;
     }
 
     /* Add service enumeration PTR record */
 
-    if (!(ptr_entry = server_add_ptr_internal(s, g, interface, protocol, 0, AVAHI_DEFAULT_TTL, ptr_name, svc_name))) {
-        ret = avahi_server_errno(s);
+    if (!(ptr_entry = server_add_ptr_internal(s, g, interface, protocol, 0, CATTA_DEFAULT_TTL, ptr_name, svc_name))) {
+        ret = catta_server_errno(s);
         goto fail;
     }
 
     /* Add SRV record */
 
-    if (!(r = avahi_record_new_full(svc_name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_SRV, AVAHI_DEFAULT_TTL_HOST_NAME))) {
-        ret = avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
+    if (!(r = catta_record_new_full(svc_name, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_SRV, CATTA_DEFAULT_TTL_HOST_NAME))) {
+        ret = catta_server_set_errno(s, CATTA_ERR_NO_MEMORY);
         goto fail;
     }
 
@@ -640,78 +640,78 @@ static int server_add_service_strlst_nocopy(
     r->data.srv.port = port;
     r->data.srv.name = h;
     h = NULL;
-    srv_entry = server_add_internal(s, g, interface, protocol, AVAHI_PUBLISH_UNIQUE, r);
-    avahi_record_unref(r);
+    srv_entry = server_add_internal(s, g, interface, protocol, CATTA_PUBLISH_UNIQUE, r);
+    catta_record_unref(r);
 
     if (!srv_entry) {
-        ret = avahi_server_errno(s);
+        ret = catta_server_errno(s);
         goto fail;
     }
 
     /* Add TXT record */
 
-    if (!(flags & AVAHI_PUBLISH_NO_COOKIE))
+    if (!(flags & CATTA_PUBLISH_NO_COOKIE))
         strlst = add_magic_cookie(s, strlst);
 
-    txt_entry = server_add_txt_strlst_nocopy(s, g, interface, protocol, AVAHI_PUBLISH_UNIQUE, AVAHI_DEFAULT_TTL, svc_name, strlst);
+    txt_entry = server_add_txt_strlst_nocopy(s, g, interface, protocol, CATTA_PUBLISH_UNIQUE, CATTA_DEFAULT_TTL, svc_name, strlst);
     strlst = NULL;
 
     if (!txt_entry) {
-        ret = avahi_server_errno(s);
+        ret = catta_server_errno(s);
         goto fail;
     }
 
     /* Add service type enumeration record */
 
-    if (!(enum_entry = server_add_ptr_internal(s, g, interface, protocol, 0, AVAHI_DEFAULT_TTL, enum_ptr, ptr_name))) {
-        ret = avahi_server_errno(s);
+    if (!(enum_entry = server_add_ptr_internal(s, g, interface, protocol, 0, CATTA_DEFAULT_TTL, enum_ptr, ptr_name))) {
+        ret = catta_server_errno(s);
         goto fail;
     }
 
 fail:
-    if (ret != AVAHI_OK && !(flags & AVAHI_PUBLISH_UPDATE)) {
+    if (ret != CATTA_OK && !(flags & CATTA_PUBLISH_UPDATE)) {
         if (srv_entry)
-            avahi_entry_free(s, srv_entry);
+            catta_entry_free(s, srv_entry);
         if (txt_entry)
-            avahi_entry_free(s, txt_entry);
+            catta_entry_free(s, txt_entry);
         if (ptr_entry)
-            avahi_entry_free(s, ptr_entry);
+            catta_entry_free(s, ptr_entry);
         if (enum_entry)
-            avahi_entry_free(s, enum_entry);
+            catta_entry_free(s, enum_entry);
     }
 
-    avahi_string_list_free(strlst);
-    avahi_free(h);
+    catta_string_list_free(strlst);
+    catta_free(h);
 
     return ret;
 }
 
-int avahi_server_add_service_strlst(
-    AvahiServer *s,
-    AvahiSEntryGroup *g,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiPublishFlags flags,
+int catta_server_add_service_strlst(
+    CattaServer *s,
+    CattaSEntryGroup *g,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaPublishFlags flags,
     const char *name,
     const char *type,
     const char *domain,
     const char *host,
     uint16_t port,
-    AvahiStringList *strlst) {
+    CattaStringList *strlst) {
 
     assert(s);
     assert(type);
     assert(name);
 
-    return server_add_service_strlst_nocopy(s, g, interface, protocol, flags, name, type, domain, host, port, avahi_string_list_copy(strlst));
+    return server_add_service_strlst_nocopy(s, g, interface, protocol, flags, name, type, domain, host, port, catta_string_list_copy(strlst));
 }
 
-int avahi_server_add_service(
-    AvahiServer *s,
-    AvahiSEntryGroup *g,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiPublishFlags flags,
+int catta_server_add_service(
+    CattaServer *s,
+    CattaSEntryGroup *g,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaPublishFlags flags,
     const char *name,
     const char *type,
     const char *domain,
@@ -723,90 +723,90 @@ int avahi_server_add_service(
     int ret;
 
     va_start(va, port);
-    ret = server_add_service_strlst_nocopy(s, g, interface, protocol, flags, name, type, domain, host, port, avahi_string_list_new_va(va));
+    ret = server_add_service_strlst_nocopy(s, g, interface, protocol, flags, name, type, domain, host, port, catta_string_list_new_va(va));
     va_end(va);
 
     return ret;
 }
 
 static int server_update_service_txt_strlst_nocopy(
-    AvahiServer *s,
-    AvahiSEntryGroup *g,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiPublishFlags flags,
+    CattaServer *s,
+    CattaSEntryGroup *g,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaPublishFlags flags,
     const char *name,
     const char *type,
     const char *domain,
-    AvahiStringList *strlst) {
+    CattaStringList *strlst) {
 
-    char svc_name[AVAHI_DOMAIN_NAME_MAX];
-    int ret = AVAHI_OK;
-    AvahiEntry *e;
+    char svc_name[CATTA_DOMAIN_NAME_MAX];
+    int ret = CATTA_OK;
+    CattaEntry *e;
 
     assert(s);
     assert(type);
     assert(name);
 
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL);
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_FLAGS_VALID(flags,
-                                                                AVAHI_PUBLISH_NO_COOKIE|
-                                                                AVAHI_PUBLISH_USE_WIDE_AREA|
-                                                                AVAHI_PUBLISH_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, avahi_is_valid_service_name(name), AVAHI_ERR_INVALID_SERVICE_NAME);
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, avahi_is_valid_service_type_strict(type), AVAHI_ERR_INVALID_SERVICE_TYPE);
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME);
+    CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+    CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
+    CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, CATTA_FLAGS_VALID(flags,
+                                                                CATTA_PUBLISH_NO_COOKIE|
+                                                                CATTA_PUBLISH_USE_WIDE_AREA|
+                                                                CATTA_PUBLISH_USE_MULTICAST), CATTA_ERR_INVALID_FLAGS);
+    CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, catta_is_valid_service_name(name), CATTA_ERR_INVALID_SERVICE_NAME);
+    CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, catta_is_valid_service_type_strict(type), CATTA_ERR_INVALID_SERVICE_TYPE);
+    CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, !domain || catta_is_valid_domain_name(domain), CATTA_ERR_INVALID_DOMAIN_NAME);
 
     if (!domain)
         domain = s->domain_name;
 
     transport_flags_from_domain(s, &flags, domain);
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, flags & AVAHI_PUBLISH_USE_MULTICAST, AVAHI_ERR_NOT_SUPPORTED);
+    CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, flags & CATTA_PUBLISH_USE_MULTICAST, CATTA_ERR_NOT_SUPPORTED);
 
-    if ((ret = avahi_service_name_join(svc_name, sizeof(svc_name), name, type, domain)) < 0) {
-        avahi_server_set_errno(s, ret);
+    if ((ret = catta_service_name_join(svc_name, sizeof(svc_name), name, type, domain)) < 0) {
+        catta_server_set_errno(s, ret);
         goto fail;
     }
 
     /* Add TXT record */
-    if (!(flags & AVAHI_PUBLISH_NO_COOKIE))
+    if (!(flags & CATTA_PUBLISH_NO_COOKIE))
         strlst = add_magic_cookie(s, strlst);
 
-    e = server_add_txt_strlst_nocopy(s, g, interface, protocol, AVAHI_PUBLISH_UNIQUE | AVAHI_PUBLISH_UPDATE, AVAHI_DEFAULT_TTL, svc_name, strlst);
+    e = server_add_txt_strlst_nocopy(s, g, interface, protocol, CATTA_PUBLISH_UNIQUE | CATTA_PUBLISH_UPDATE, CATTA_DEFAULT_TTL, svc_name, strlst);
     strlst = NULL;
 
     if (!e)
-        ret = avahi_server_errno(s);
+        ret = catta_server_errno(s);
 
 fail:
 
-    avahi_string_list_free(strlst);
+    catta_string_list_free(strlst);
 
     return ret;
 }
 
-int avahi_server_update_service_txt_strlst(
-    AvahiServer *s,
-    AvahiSEntryGroup *g,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiPublishFlags flags,
+int catta_server_update_service_txt_strlst(
+    CattaServer *s,
+    CattaSEntryGroup *g,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaPublishFlags flags,
     const char *name,
     const char *type,
     const char *domain,
-    AvahiStringList *strlst) {
+    CattaStringList *strlst) {
 
-    return server_update_service_txt_strlst_nocopy(s, g, interface, protocol, flags, name, type, domain, avahi_string_list_copy(strlst));
+    return server_update_service_txt_strlst_nocopy(s, g, interface, protocol, flags, name, type, domain, catta_string_list_copy(strlst));
 }
 
 /** Update the TXT record for a service with the NULL termonate list of strings */
-int avahi_server_update_service_txt(
-    AvahiServer *s,
-    AvahiSEntryGroup *g,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiPublishFlags flags,
+int catta_server_update_service_txt(
+    CattaServer *s,
+    CattaSEntryGroup *g,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaPublishFlags flags,
     const char *name,
     const char *type,
     const char *domain,
@@ -816,51 +816,51 @@ int avahi_server_update_service_txt(
     int ret;
 
     va_start(va, domain);
-    ret = server_update_service_txt_strlst_nocopy(s, g, interface, protocol, flags, name, type, domain, avahi_string_list_new_va(va));
+    ret = server_update_service_txt_strlst_nocopy(s, g, interface, protocol, flags, name, type, domain, catta_string_list_new_va(va));
     va_end(va);
 
     return ret;
 }
 
-int avahi_server_add_service_subtype(
-    AvahiServer *s,
-    AvahiSEntryGroup *g,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiPublishFlags flags,
+int catta_server_add_service_subtype(
+    CattaServer *s,
+    CattaSEntryGroup *g,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaPublishFlags flags,
     const char *name,
     const char *type,
     const char *domain,
     const char *subtype) {
 
-    int ret = AVAHI_OK;
-    char svc_name[AVAHI_DOMAIN_NAME_MAX], ptr_name[AVAHI_DOMAIN_NAME_MAX];
+    int ret = CATTA_OK;
+    char svc_name[CATTA_DOMAIN_NAME_MAX], ptr_name[CATTA_DOMAIN_NAME_MAX];
 
     assert(name);
     assert(type);
     assert(subtype);
 
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL);
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_FLAGS_VALID(flags, AVAHI_PUBLISH_USE_MULTICAST|AVAHI_PUBLISH_USE_WIDE_AREA), AVAHI_ERR_INVALID_FLAGS);
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, avahi_is_valid_service_name(name), AVAHI_ERR_INVALID_SERVICE_NAME);
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, avahi_is_valid_service_type_strict(type), AVAHI_ERR_INVALID_SERVICE_TYPE);
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME);
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, avahi_is_valid_service_subtype(subtype), AVAHI_ERR_INVALID_SERVICE_SUBTYPE);
+    CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+    CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
+    CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, CATTA_FLAGS_VALID(flags, CATTA_PUBLISH_USE_MULTICAST|CATTA_PUBLISH_USE_WIDE_AREA), CATTA_ERR_INVALID_FLAGS);
+    CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, catta_is_valid_service_name(name), CATTA_ERR_INVALID_SERVICE_NAME);
+    CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, catta_is_valid_service_type_strict(type), CATTA_ERR_INVALID_SERVICE_TYPE);
+    CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, !domain || catta_is_valid_domain_name(domain), CATTA_ERR_INVALID_DOMAIN_NAME);
+    CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, catta_is_valid_service_subtype(subtype), CATTA_ERR_INVALID_SERVICE_SUBTYPE);
 
     if (!domain)
         domain = s->domain_name;
 
     transport_flags_from_domain(s, &flags, domain);
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, flags & AVAHI_PUBLISH_USE_MULTICAST, AVAHI_ERR_NOT_SUPPORTED);
+    CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, flags & CATTA_PUBLISH_USE_MULTICAST, CATTA_ERR_NOT_SUPPORTED);
 
-    if ((ret = avahi_service_name_join(svc_name, sizeof(svc_name), name, type, domain)) < 0 ||
-        (ret = avahi_service_name_join(ptr_name, sizeof(ptr_name), NULL, subtype, domain)) < 0) {
-        avahi_server_set_errno(s, ret);
+    if ((ret = catta_service_name_join(svc_name, sizeof(svc_name), name, type, domain)) < 0 ||
+        (ret = catta_service_name_join(ptr_name, sizeof(ptr_name), NULL, subtype, domain)) < 0) {
+        catta_server_set_errno(s, ret);
         goto fail;
     }
 
-    if ((ret = avahi_server_add_ptr(s, g, interface, protocol, 0, AVAHI_DEFAULT_TTL, ptr_name, svc_name)) < 0)
+    if ((ret = catta_server_add_ptr(s, g, interface, protocol, 0, CATTA_DEFAULT_TTL, ptr_name, svc_name)) < 0)
         goto fail;
 
 fail:
@@ -890,49 +890,49 @@ static void hexstring(char *s, size_t sl, const void *p, size_t pl) {
         *s = 0;
 }
 
-static AvahiEntry *server_add_dns_server_name(
-    AvahiServer *s,
-    AvahiSEntryGroup *g,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiPublishFlags flags,
+static CattaEntry *server_add_dns_server_name(
+    CattaServer *s,
+    CattaSEntryGroup *g,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaPublishFlags flags,
     const char *domain,
-    AvahiDNSServerType type,
+    CattaDNSServerType type,
     const char *name,
     uint16_t port /** should be 53 */) {
 
-    AvahiEntry *e;
-    char t[AVAHI_DOMAIN_NAME_MAX], normalized_d[AVAHI_DOMAIN_NAME_MAX], *n;
+    CattaEntry *e;
+    char t[CATTA_DOMAIN_NAME_MAX], normalized_d[CATTA_DOMAIN_NAME_MAX], *n;
 
-    AvahiRecord *r;
+    CattaRecord *r;
 
     assert(s);
     assert(name);
 
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(s, AVAHI_FLAGS_VALID(flags, AVAHI_PUBLISH_USE_WIDE_AREA|AVAHI_PUBLISH_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(s, type == AVAHI_DNS_SERVER_UPDATE || type == AVAHI_DNS_SERVER_RESOLVE, AVAHI_ERR_INVALID_FLAGS);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(s, port != 0, AVAHI_ERR_INVALID_PORT);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(s, avahi_is_valid_fqdn(name), AVAHI_ERR_INVALID_HOST_NAME);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(s, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(s, CATTA_FLAGS_VALID(flags, CATTA_PUBLISH_USE_WIDE_AREA|CATTA_PUBLISH_USE_MULTICAST), CATTA_ERR_INVALID_FLAGS);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(s, type == CATTA_DNS_SERVER_UPDATE || type == CATTA_DNS_SERVER_RESOLVE, CATTA_ERR_INVALID_FLAGS);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(s, port != 0, CATTA_ERR_INVALID_PORT);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(s, catta_is_valid_fqdn(name), CATTA_ERR_INVALID_HOST_NAME);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(s, !domain || catta_is_valid_domain_name(domain), CATTA_ERR_INVALID_DOMAIN_NAME);
 
     if (!domain)
         domain = s->domain_name;
 
     transport_flags_from_domain(s, &flags, domain);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(s, flags & AVAHI_PUBLISH_USE_MULTICAST, AVAHI_ERR_NOT_SUPPORTED);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(s, flags & CATTA_PUBLISH_USE_MULTICAST, CATTA_ERR_NOT_SUPPORTED);
 
-    if (!(n = avahi_normalize_name_strdup(name))) {
-        avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
+    if (!(n = catta_normalize_name_strdup(name))) {
+        catta_server_set_errno(s, CATTA_ERR_NO_MEMORY);
         return NULL;
     }
 
-    AVAHI_ASSERT_TRUE(avahi_normalize_name(domain, normalized_d, sizeof(normalized_d)));
+    CATTA_ASSERT_TRUE(catta_normalize_name(domain, normalized_d, sizeof(normalized_d)));
 
-    snprintf(t, sizeof(t), "%s.%s", type == AVAHI_DNS_SERVER_RESOLVE ? "_domain._udp" : "_dns-update._udp", normalized_d);
+    snprintf(t, sizeof(t), "%s.%s", type == CATTA_DNS_SERVER_RESOLVE ? "_domain._udp" : "_dns-update._udp", normalized_d);
 
-    if (!(r = avahi_record_new_full(t, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_SRV, AVAHI_DEFAULT_TTL_HOST_NAME))) {
-        avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
-        avahi_free(n);
+    if (!(r = catta_record_new_full(t, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_SRV, CATTA_DEFAULT_TTL_HOST_NAME))) {
+        catta_server_set_errno(s, CATTA_ERR_NO_MEMORY);
+        catta_free(n);
         return NULL;
     }
 
@@ -941,95 +941,95 @@ static AvahiEntry *server_add_dns_server_name(
     r->data.srv.port = port;
     r->data.srv.name = n;
     e = server_add_internal(s, g, interface, protocol, 0, r);
-    avahi_record_unref(r);
+    catta_record_unref(r);
 
     return e;
 }
 
-int avahi_server_add_dns_server_address(
-    AvahiServer *s,
-    AvahiSEntryGroup *g,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiPublishFlags flags,
+int catta_server_add_dns_server_address(
+    CattaServer *s,
+    CattaSEntryGroup *g,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaPublishFlags flags,
     const char *domain,
-    AvahiDNSServerType type,
-    const AvahiAddress *address,
+    CattaDNSServerType type,
+    const CattaAddress *address,
     uint16_t port /** should be 53 */) {
 
-    AvahiRecord *r;
+    CattaRecord *r;
     char n[64], h[64];
-    AvahiEntry *a_entry, *s_entry;
+    CattaEntry *a_entry, *s_entry;
 
     assert(s);
     assert(address);
 
-    AVAHI_CHECK_VALIDITY(s, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
-    AVAHI_CHECK_VALIDITY(s, AVAHI_PROTO_VALID(protocol) && AVAHI_PROTO_VALID(address->proto), AVAHI_ERR_INVALID_PROTOCOL);
-    AVAHI_CHECK_VALIDITY(s, AVAHI_FLAGS_VALID(flags, AVAHI_PUBLISH_USE_MULTICAST|AVAHI_PUBLISH_USE_WIDE_AREA), AVAHI_ERR_INVALID_FLAGS);
-    AVAHI_CHECK_VALIDITY(s, type == AVAHI_DNS_SERVER_UPDATE || type == AVAHI_DNS_SERVER_RESOLVE, AVAHI_ERR_INVALID_FLAGS);
-    AVAHI_CHECK_VALIDITY(s, port != 0, AVAHI_ERR_INVALID_PORT);
-    AVAHI_CHECK_VALIDITY(s, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME);
+    CATTA_CHECK_VALIDITY(s, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+    CATTA_CHECK_VALIDITY(s, CATTA_PROTO_VALID(protocol) && CATTA_PROTO_VALID(address->proto), CATTA_ERR_INVALID_PROTOCOL);
+    CATTA_CHECK_VALIDITY(s, CATTA_FLAGS_VALID(flags, CATTA_PUBLISH_USE_MULTICAST|CATTA_PUBLISH_USE_WIDE_AREA), CATTA_ERR_INVALID_FLAGS);
+    CATTA_CHECK_VALIDITY(s, type == CATTA_DNS_SERVER_UPDATE || type == CATTA_DNS_SERVER_RESOLVE, CATTA_ERR_INVALID_FLAGS);
+    CATTA_CHECK_VALIDITY(s, port != 0, CATTA_ERR_INVALID_PORT);
+    CATTA_CHECK_VALIDITY(s, !domain || catta_is_valid_domain_name(domain), CATTA_ERR_INVALID_DOMAIN_NAME);
 
     if (!domain)
         domain = s->domain_name;
 
     transport_flags_from_domain(s, &flags, domain);
-    AVAHI_CHECK_VALIDITY(s, flags & AVAHI_PUBLISH_USE_MULTICAST, AVAHI_ERR_NOT_SUPPORTED);
+    CATTA_CHECK_VALIDITY(s, flags & CATTA_PUBLISH_USE_MULTICAST, CATTA_ERR_NOT_SUPPORTED);
 
-    if (address->proto == AVAHI_PROTO_INET) {
-        hexstring(h, sizeof(h), &address->data, sizeof(AvahiIPv4Address));
+    if (address->proto == CATTA_PROTO_INET) {
+        hexstring(h, sizeof(h), &address->data, sizeof(CattaIPv4Address));
         snprintf(n, sizeof(n), "ip-%s.%s", h, domain);
-        r = avahi_record_new_full(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_A, AVAHI_DEFAULT_TTL_HOST_NAME);
+        r = catta_record_new_full(n, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_A, CATTA_DEFAULT_TTL_HOST_NAME);
         r->data.a.address = address->data.ipv4;
     } else {
-        hexstring(h, sizeof(h), &address->data, sizeof(AvahiIPv6Address));
+        hexstring(h, sizeof(h), &address->data, sizeof(CattaIPv6Address));
         snprintf(n, sizeof(n), "ip6-%s.%s", h, domain);
-        r = avahi_record_new_full(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_AAAA, AVAHI_DEFAULT_TTL_HOST_NAME);
+        r = catta_record_new_full(n, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_AAAA, CATTA_DEFAULT_TTL_HOST_NAME);
         r->data.aaaa.address = address->data.ipv6;
     }
 
     if (!r)
-        return avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
+        return catta_server_set_errno(s, CATTA_ERR_NO_MEMORY);
 
-    a_entry = server_add_internal(s, g, interface, protocol, AVAHI_PUBLISH_UNIQUE | AVAHI_PUBLISH_ALLOW_MULTIPLE, r);
-    avahi_record_unref(r);
+    a_entry = server_add_internal(s, g, interface, protocol, CATTA_PUBLISH_UNIQUE | CATTA_PUBLISH_ALLOW_MULTIPLE, r);
+    catta_record_unref(r);
 
     if (!a_entry)
-        return avahi_server_errno(s);
+        return catta_server_errno(s);
 
     if (!(s_entry = server_add_dns_server_name(s, g, interface, protocol, flags, domain, type, n, port))) {
-        if (!(flags & AVAHI_PUBLISH_UPDATE))
-            avahi_entry_free(s, a_entry);
-        return avahi_server_errno(s);
+        if (!(flags & CATTA_PUBLISH_UPDATE))
+            catta_entry_free(s, a_entry);
+        return catta_server_errno(s);
     }
 
-    return AVAHI_OK;
+    return CATTA_OK;
 }
 
-void avahi_s_entry_group_change_state(AvahiSEntryGroup *g, AvahiEntryGroupState state) {
+void catta_s_entry_group_change_state(CattaSEntryGroup *g, CattaEntryGroupState state) {
     assert(g);
 
     if (g->state == state)
         return;
 
-    assert(state <= AVAHI_ENTRY_GROUP_COLLISION);
+    assert(state <= CATTA_ENTRY_GROUP_COLLISION);
 
-    if (g->state == AVAHI_ENTRY_GROUP_ESTABLISHED) {
+    if (g->state == CATTA_ENTRY_GROUP_ESTABLISHED) {
 
         /* If the entry group was established for a time longer then
          * 5s, reset the establishment trial counter */
 
-        if (avahi_age(&g->established_at) > 5000000)
+        if (catta_age(&g->established_at) > 5000000)
             g->n_register_try = 0;
-    } else if (g->state == AVAHI_ENTRY_GROUP_REGISTERING) {
+    } else if (g->state == CATTA_ENTRY_GROUP_REGISTERING) {
         if (g->register_time_event) {
-            avahi_time_event_free(g->register_time_event);
+            catta_time_event_free(g->register_time_event);
             g->register_time_event = NULL;
         }
     }
 
-    if (state == AVAHI_ENTRY_GROUP_ESTABLISHED)
+    if (state == CATTA_ENTRY_GROUP_ESTABLISHED)
 
         /* If the entry group is now established, remember the time
          * this happened */
@@ -1042,13 +1042,13 @@ void avahi_s_entry_group_change_state(AvahiSEntryGroup *g, AvahiEntryGroupState
         g->callback(g->server, g, state, g->userdata);
 }
 
-AvahiSEntryGroup *avahi_s_entry_group_new(AvahiServer *s, AvahiSEntryGroupCallback callback, void* userdata) {
-    AvahiSEntryGroup *g;
+CattaSEntryGroup *catta_s_entry_group_new(CattaServer *s, CattaSEntryGroupCallback callback, void* userdata) {
+    CattaSEntryGroup *g;
 
     assert(s);
 
-    if (!(g = avahi_new(AvahiSEntryGroup, 1))) {
-        avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
+    if (!(g = catta_new(CattaSEntryGroup, 1))) {
+        catta_server_set_errno(s, CATTA_ERR_NO_MEMORY);
         return NULL;
     }
 
@@ -1056,50 +1056,50 @@ AvahiSEntryGroup *avahi_s_entry_group_new(AvahiServer *s, AvahiSEntryGroupCallba
     g->callback = callback;
     g->userdata = userdata;
     g->dead = 0;
-    g->state = AVAHI_ENTRY_GROUP_UNCOMMITED;
+    g->state = CATTA_ENTRY_GROUP_UNCOMMITED;
     g->n_probing = 0;
     g->n_register_try = 0;
     g->register_time_event = NULL;
     g->register_time.tv_sec = 0;
     g->register_time.tv_usec = 0;
-    AVAHI_LLIST_HEAD_INIT(AvahiEntry, g->entries);
+    CATTA_LLIST_HEAD_INIT(CattaEntry, g->entries);
 
-    AVAHI_LLIST_PREPEND(AvahiSEntryGroup, groups, s->groups, g);
+    CATTA_LLIST_PREPEND(CattaSEntryGroup, groups, s->groups, g);
     return g;
 }
 
-static void cleanup_time_event_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void* userdata) {
-    AvahiServer *s = userdata;
+static void cleanup_time_event_callback(CATTA_GCC_UNUSED CattaTimeEvent *e, void* userdata) {
+    CattaServer *s = userdata;
 
     assert(s);
 
-    avahi_cleanup_dead_entries(s);
+    catta_cleanup_dead_entries(s);
 }
 
-static void schedule_cleanup(AvahiServer *s) {
+static void schedule_cleanup(CattaServer *s) {
     struct timeval tv;
 
     assert(s);
 
     if (!s->cleanup_time_event)
-        s->cleanup_time_event = avahi_time_event_new(s->time_event_queue, avahi_elapse_time(&tv, 1000, 0), &cleanup_time_event_callback, s);
+        s->cleanup_time_event = catta_time_event_new(s->time_event_queue, catta_elapse_time(&tv, 1000, 0), &cleanup_time_event_callback, s);
 }
 
-void avahi_s_entry_group_free(AvahiSEntryGroup *g) {
-    AvahiEntry *e;
+void catta_s_entry_group_free(CattaSEntryGroup *g) {
+    CattaEntry *e;
 
     assert(g);
     assert(g->server);
 
     for (e = g->entries; e; e = e->by_group_next) {
         if (!e->dead) {
-            avahi_goodbye_entry(g->server, e, 1, 1);
+            catta_goodbye_entry(g->server, e, 1, 1);
             e->dead = 1;
         }
     }
 
     if (g->register_time_event) {
-        avahi_time_event_free(g->register_time_event);
+        catta_time_event_free(g->register_time_event);
         g->register_time_event = NULL;
     }
 
@@ -1111,53 +1111,53 @@ void avahi_s_entry_group_free(AvahiSEntryGroup *g) {
     schedule_cleanup(g->server);
 }
 
-static void entry_group_commit_real(AvahiSEntryGroup *g) {
+static void entry_group_commit_real(CattaSEntryGroup *g) {
     assert(g);
 
     gettimeofday(&g->register_time, NULL);
 
-    avahi_s_entry_group_change_state(g, AVAHI_ENTRY_GROUP_REGISTERING);
+    catta_s_entry_group_change_state(g, CATTA_ENTRY_GROUP_REGISTERING);
 
     if (g->dead)
         return;
 
-    avahi_announce_group(g->server, g);
-    avahi_s_entry_group_check_probed(g, 0);
+    catta_announce_group(g->server, g);
+    catta_s_entry_group_check_probed(g, 0);
 }
 
-static void entry_group_register_time_event_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void* userdata) {
-    AvahiSEntryGroup *g = userdata;
+static void entry_group_register_time_event_callback(CATTA_GCC_UNUSED CattaTimeEvent *e, void* userdata) {
+    CattaSEntryGroup *g = userdata;
     assert(g);
 
-    avahi_time_event_free(g->register_time_event);
+    catta_time_event_free(g->register_time_event);
     g->register_time_event = NULL;
 
     /* Holdoff time passed, so let's start probing */
     entry_group_commit_real(g);
 }
 
-int avahi_s_entry_group_commit(AvahiSEntryGroup *g) {
+int catta_s_entry_group_commit(CattaSEntryGroup *g) {
     struct timeval now;
 
     assert(g);
     assert(!g->dead);
 
-    if (g->state != AVAHI_ENTRY_GROUP_UNCOMMITED && g->state != AVAHI_ENTRY_GROUP_COLLISION)
-        return avahi_server_set_errno(g->server, AVAHI_ERR_BAD_STATE);
+    if (g->state != CATTA_ENTRY_GROUP_UNCOMMITED && g->state != CATTA_ENTRY_GROUP_COLLISION)
+        return catta_server_set_errno(g->server, CATTA_ERR_BAD_STATE);
 
-    if (avahi_s_entry_group_is_empty(g))
-        return avahi_server_set_errno(g->server, AVAHI_ERR_IS_EMPTY);
+    if (catta_s_entry_group_is_empty(g))
+        return catta_server_set_errno(g->server, CATTA_ERR_IS_EMPTY);
 
     g->n_register_try++;
 
-    avahi_timeval_add(&g->register_time,
-                      1000*(g->n_register_try >= AVAHI_RR_RATE_LIMIT_COUNT ?
-                            AVAHI_RR_HOLDOFF_MSEC_RATE_LIMIT :
-                            AVAHI_RR_HOLDOFF_MSEC));
+    catta_timeval_add(&g->register_time,
+                      1000*(g->n_register_try >= CATTA_RR_RATE_LIMIT_COUNT ?
+                            CATTA_RR_HOLDOFF_MSEC_RATE_LIMIT :
+                            CATTA_RR_HOLDOFF_MSEC));
 
     gettimeofday(&now, NULL);
 
-    if (avahi_timeval_compare(&g->register_time, &now) <= 0) {
+    if (catta_timeval_compare(&g->register_time, &now) <= 0) {
 
         /* Holdoff time passed, so let's start probing */
         entry_group_commit_real(g);
@@ -1165,21 +1165,21 @@ int avahi_s_entry_group_commit(AvahiSEntryGroup *g) {
 
          /* Holdoff time has not yet passed, so let's wait */
         assert(!g->register_time_event);
-        g->register_time_event = avahi_time_event_new(g->server->time_event_queue, &g->register_time, entry_group_register_time_event_callback, g);
+        g->register_time_event = catta_time_event_new(g->server->time_event_queue, &g->register_time, entry_group_register_time_event_callback, g);
 
-        avahi_s_entry_group_change_state(g, AVAHI_ENTRY_GROUP_REGISTERING);
+        catta_s_entry_group_change_state(g, CATTA_ENTRY_GROUP_REGISTERING);
     }
 
-    return AVAHI_OK;
+    return CATTA_OK;
 }
 
-void avahi_s_entry_group_reset(AvahiSEntryGroup *g) {
-    AvahiEntry *e;
+void catta_s_entry_group_reset(CattaSEntryGroup *g) {
+    CattaEntry *e;
     assert(g);
 
     for (e = g->entries; e; e = e->by_group_next) {
         if (!e->dead) {
-            avahi_goodbye_entry(g->server, e, 1, 1);
+            catta_goodbye_entry(g->server, e, 1, 1);
             e->dead = 1;
         }
     }
@@ -1187,41 +1187,41 @@ void avahi_s_entry_group_reset(AvahiSEntryGroup *g) {
 
     g->n_probing = 0;
 
-    avahi_s_entry_group_change_state(g, AVAHI_ENTRY_GROUP_UNCOMMITED);
+    catta_s_entry_group_change_state(g, CATTA_ENTRY_GROUP_UNCOMMITED);
 
     schedule_cleanup(g->server);
 }
 
-int avahi_entry_is_commited(AvahiEntry *e) {
+int catta_entry_is_commited(CattaEntry *e) {
     assert(e);
     assert(!e->dead);
 
     return !e->group ||
-        e->group->state == AVAHI_ENTRY_GROUP_REGISTERING ||
-        e->group->state == AVAHI_ENTRY_GROUP_ESTABLISHED;
+        e->group->state == CATTA_ENTRY_GROUP_REGISTERING ||
+        e->group->state == CATTA_ENTRY_GROUP_ESTABLISHED;
 }
 
-AvahiEntryGroupState avahi_s_entry_group_get_state(AvahiSEntryGroup *g) {
+CattaEntryGroupState catta_s_entry_group_get_state(CattaSEntryGroup *g) {
     assert(g);
     assert(!g->dead);
 
     return g->state;
 }
 
-void avahi_s_entry_group_set_data(AvahiSEntryGroup *g, void* userdata) {
+void catta_s_entry_group_set_data(CattaSEntryGroup *g, void* userdata) {
     assert(g);
 
     g->userdata = userdata;
 }
 
-void* avahi_s_entry_group_get_data(AvahiSEntryGroup *g) {
+void* catta_s_entry_group_get_data(CattaSEntryGroup *g) {
     assert(g);
 
     return g->userdata;
 }
 
-int avahi_s_entry_group_is_empty(AvahiSEntryGroup *g) {
-    AvahiEntry *e;
+int catta_s_entry_group_is_empty(CattaSEntryGroup *g) {
+    CattaEntry *e;
     assert(g);
 
     /* Look for an entry that is not dead */
index 419a39fa1f0cfc43c1f4d0223e9d280e573c0f1b..543d1b1ad1e7607f7544ed1572a1c748c57d40dd 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
  ***/
 #include <config.h>
 #endif
 
-#include <avahi/error.h>
+#include <catta/error.h>
 
-const char *avahi_strerror(int error) {
+const char *catta_strerror(int error) {
 
-    const char * const msg[- AVAHI_ERR_MAX] = {
+    const char * const msg[- CATTA_ERR_MAX] = {
         "OK",
         "Operation failed",
         "Bad state",
@@ -87,7 +87,7 @@ const char *avahi_strerror(int error) {
         "The requested operation is invalid because redundant"
     };
 
-    if (-error < 0 || -error >= -AVAHI_ERR_MAX)
+    if (-error < 0 || -error >= -CATTA_ERR_MAX)
         return "Invalid Error Code";
 
     return msg[-error];
index c294754ada767c9f35c386f9c10fde5d47b02115..c483ce8de1e4859a7d2c366246d938ed0dc8d393 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
@@ -28,7 +28,7 @@
 
 #include "fdutil.h"
 
-int avahi_set_cloexec(int fd) {
+int catta_set_cloexec(int fd) {
     int n;
 
     assert(fd >= 0);
@@ -42,7 +42,7 @@ int avahi_set_cloexec(int fd) {
     return fcntl(fd, F_SETFD, n|FD_CLOEXEC);
 }
 
-int avahi_set_nonblock(int fd) {
+int catta_set_nonblock(int fd) {
     int n;
 
     assert(fd >= 0);
@@ -56,7 +56,7 @@ int avahi_set_nonblock(int fd) {
     return fcntl(fd, F_SETFL, n|O_NONBLOCK);
 }
 
-int avahi_wait_for_write(int fd) {
+int catta_wait_for_write(int fd) {
     fd_set fds;
     int r;
 
index a0e72dff6530d16967553c7cf90cf00492128a3b..b8bb74cf50ec415a174af1c332a5b41e87a0d6b8 100644 (file)
@@ -2,32 +2,32 @@
 #define foofdutilhfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
-#include <avahi/cdecl.h>
+#include <catta/cdecl.h>
 
-AVAHI_C_DECL_BEGIN
+CATTA_C_DECL_BEGIN
 
-int avahi_set_cloexec(int fd);
-int avahi_set_nonblock(int fd);
-int avahi_wait_for_write(int fd);
+int catta_set_cloexec(int fd);
+int catta_set_nonblock(int fd);
+int catta_wait_for_write(int fd);
 
-AVAHI_C_DECL_END
+CATTA_C_DECL_END
 
 #endif
index ae03416f6d98cdc0d4ca45a8fac579b5b19b01f2..32f2510d7b31a519f27379323f243a8ebca56819 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
@@ -24,9 +24,9 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <avahi/llist.h>
-#include <avahi/domain.h>
-#include <avahi/malloc.h>
+#include <catta/llist.h>
+#include <catta/domain.h>
+#include <catta/malloc.h>
 
 #include "hashmap.h"
 #include "util.h"
 
 typedef struct Entry Entry;
 struct Entry {
-    AvahiHashmap *hashmap;
+    CattaHashmap *hashmap;
     void *key;
     void *value;
 
-    AVAHI_LLIST_FIELDS(Entry, bucket);
-    AVAHI_LLIST_FIELDS(Entry, entries);
+    CATTA_LLIST_FIELDS(Entry, bucket);
+    CATTA_LLIST_FIELDS(Entry, entries);
 };
 
-struct AvahiHashmap {
-    AvahiHashFunc hash_func;
-    AvahiEqualFunc equal_func;
-    AvahiFreeFunc key_free_func, value_free_func;
+struct CattaHashmap {
+    CattaHashFunc hash_func;
+    CattaEqualFunc equal_func;
+    CattaFreeFunc key_free_func, value_free_func;
 
     Entry *entries[HASH_MAP_SIZE];
-    AVAHI_LLIST_HEAD(Entry, entries_list);
+    CATTA_LLIST_HEAD(Entry, entries_list);
 };
 
-static Entry* entry_get(AvahiHashmap *m, const void *key) {
+static Entry* entry_get(CattaHashmap *m, const void *key) {
     unsigned idx;
     Entry *e;
 
@@ -65,31 +65,31 @@ static Entry* entry_get(AvahiHashmap *m, const void *key) {
     return NULL;
 }
 
-static void entry_free(AvahiHashmap *m, Entry *e, int stolen) {
+static void entry_free(CattaHashmap *m, Entry *e, int stolen) {
     unsigned idx;
     assert(m);
     assert(e);
 
     idx = m->hash_func(e->key) % HASH_MAP_SIZE;
 
-    AVAHI_LLIST_REMOVE(Entry, bucket, m->entries[idx], e);
-    AVAHI_LLIST_REMOVE(Entry, entries, m->entries_list, e);
+    CATTA_LLIST_REMOVE(Entry, bucket, m->entries[idx], e);
+    CATTA_LLIST_REMOVE(Entry, entries, m->entries_list, e);
 
     if (m->key_free_func)
         m->key_free_func(e->key);
     if (m->value_free_func && !stolen)
         m->value_free_func(e->value);
 
-    avahi_free(e);
+    catta_free(e);
 }
 
-AvahiHashmap* avahi_hashmap_new(AvahiHashFunc hash_func, AvahiEqualFunc equal_func, AvahiFreeFunc key_free_func, AvahiFreeFunc value_free_func) {
-    AvahiHashmap *m;
+CattaHashmap* catta_hashmap_new(CattaHashFunc hash_func, CattaEqualFunc equal_func, CattaFreeFunc key_free_func, CattaFreeFunc value_free_func) {
+    CattaHashmap *m;
 
     assert(hash_func);
     assert(equal_func);
 
-    if (!(m = avahi_new0(AvahiHashmap, 1)))
+    if (!(m = catta_new0(CattaHashmap, 1)))
         return NULL;
 
     m->hash_func = hash_func;
@@ -97,21 +97,21 @@ AvahiHashmap* avahi_hashmap_new(AvahiHashFunc hash_func, AvahiEqualFunc equal_fu
     m->key_free_func = key_free_func;
     m->value_free_func = value_free_func;
 
-    AVAHI_LLIST_HEAD_INIT(Entry, m->entries_list);
+    CATTA_LLIST_HEAD_INIT(Entry, m->entries_list);
 
     return m;
 }
 
-void avahi_hashmap_free(AvahiHashmap *m) {
+void catta_hashmap_free(CattaHashmap *m) {
     assert(m);
 
     while (m->entries_list)
         entry_free(m, m->entries_list, 0);
 
-    avahi_free(m);
+    catta_free(m);
 }
 
-void* avahi_hashmap_lookup(AvahiHashmap *m, const void *key) {
+void* catta_hashmap_lookup(CattaHashmap *m, const void *key) {
     Entry *e;
 
     assert(m);
@@ -122,7 +122,7 @@ void* avahi_hashmap_lookup(AvahiHashmap *m, const void *key) {
     return e->value;
 }
 
-int avahi_hashmap_insert(AvahiHashmap *m, void *key, void *value) {
+int catta_hashmap_insert(CattaHashmap *m, void *key, void *value) {
     unsigned idx;
     Entry *e;
 
@@ -137,23 +137,23 @@ int avahi_hashmap_insert(AvahiHashmap *m, void *key, void *value) {
         return 1;
     }
 
-    if (!(e = avahi_new(Entry, 1)))
+    if (!(e = catta_new(Entry, 1)))
         return -1;
 
     e->hashmap = m;
     e->key = key;
     e->value = value;
 
-    AVAHI_LLIST_PREPEND(Entry, entries, m->entries_list, e);
+    CATTA_LLIST_PREPEND(Entry, entries, m->entries_list, e);
 
     idx = m->hash_func(key) % HASH_MAP_SIZE;
-    AVAHI_LLIST_PREPEND(Entry, bucket, m->entries[idx], e);
+    CATTA_LLIST_PREPEND(Entry, bucket, m->entries[idx], e);
 
     return 0;
 }
 
 
-int avahi_hashmap_replace(AvahiHashmap *m, void *key, void *value) {
+int catta_hashmap_replace(CattaHashmap *m, void *key, void *value) {
     unsigned idx;
     Entry *e;
 
@@ -171,22 +171,22 @@ int avahi_hashmap_replace(AvahiHashmap *m, void *key, void *value) {
         return 1;
     }
 
-    if (!(e = avahi_new(Entry, 1)))
+    if (!(e = catta_new(Entry, 1)))
         return -1;
 
     e->hashmap = m;
     e->key = key;
     e->value = value;
 
-    AVAHI_LLIST_PREPEND(Entry, entries, m->entries_list, e);
+    CATTA_LLIST_PREPEND(Entry, entries, m->entries_list, e);
 
     idx = m->hash_func(key) % HASH_MAP_SIZE;
-    AVAHI_LLIST_PREPEND(Entry, bucket, m->entries[idx], e);
+    CATTA_LLIST_PREPEND(Entry, bucket, m->entries[idx], e);
 
     return 0;
 }
 
-void avahi_hashmap_remove(AvahiHashmap *m, const void *key) {
+void catta_hashmap_remove(CattaHashmap *m, const void *key) {
     Entry *e;
 
     assert(m);
@@ -197,7 +197,7 @@ void avahi_hashmap_remove(AvahiHashmap *m, const void *key) {
     entry_free(m, e, 0);
 }
 
-void avahi_hashmap_foreach(AvahiHashmap *m, AvahiHashmapForeachCallback callback, void *userdata) {
+void catta_hashmap_foreach(CattaHashmap *m, CattaHashmapForeachCallback callback, void *userdata) {
     Entry *e, *next;
     assert(m);
     assert(callback);
@@ -209,7 +209,7 @@ void avahi_hashmap_foreach(AvahiHashmap *m, AvahiHashmapForeachCallback callback
     }
 }
 
-unsigned avahi_string_hash(const void *data) {
+unsigned catta_string_hash(const void *data) {
     const char *p = data;
     unsigned hash = 0;
 
@@ -221,7 +221,7 @@ unsigned avahi_string_hash(const void *data) {
     return hash;
 }
 
-int avahi_string_equal(const void *a, const void *b) {
+int catta_string_equal(const void *a, const void *b) {
     const char *p = a, *q = b;
 
     assert(p);
@@ -230,7 +230,7 @@ int avahi_string_equal(const void *a, const void *b) {
     return strcmp(p, q) == 0;
 }
 
-unsigned avahi_int_hash(const void *data) {
+unsigned catta_int_hash(const void *data) {
     const int *i = data;
 
     assert(i);
@@ -238,7 +238,7 @@ unsigned avahi_int_hash(const void *data) {
     return (unsigned) *i;
 }
 
-int avahi_int_equal(const void *a, const void *b) {
+int catta_int_equal(const void *a, const void *b) {
     const int *_a = a, *_b = b;
 
     assert(_a);
index 16adf6f8f96bedc4a412cf5d3e29d75fa99dd7fb..9c78ed9a2b701a93b0e8aca030d23746c2b949ce 100644 (file)
@@ -2,52 +2,52 @@
 #define foohashmaphfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
-#include <avahi/cdecl.h>
+#include <catta/cdecl.h>
 
-AVAHI_C_DECL_BEGIN
+CATTA_C_DECL_BEGIN
 
-typedef struct AvahiHashmap AvahiHashmap;
+typedef struct CattaHashmap CattaHashmap;
 
-typedef unsigned (*AvahiHashFunc)(const void *data);
-typedef int (*AvahiEqualFunc)(const void *a, const void *b);
-typedef void (*AvahiFreeFunc)(void *p);
+typedef unsigned (*CattaHashFunc)(const void *data);
+typedef int (*CattaEqualFunc)(const void *a, const void *b);
+typedef void (*CattaFreeFunc)(void *p);
 
-AvahiHashmap* avahi_hashmap_new(AvahiHashFunc hash_func, AvahiEqualFunc equal_func, AvahiFreeFunc key_free_func, AvahiFreeFunc value_free_func);
+CattaHashmap* catta_hashmap_new(CattaHashFunc hash_func, CattaEqualFunc equal_func, CattaFreeFunc key_free_func, CattaFreeFunc value_free_func);
 
-void avahi_hashmap_free(AvahiHashmap *m);
-void* avahi_hashmap_lookup(AvahiHashmap *m, const void *key);
-int avahi_hashmap_insert(AvahiHashmap *m, void *key, void *value);
-int avahi_hashmap_replace(AvahiHashmap *m, void *key, void *value);
-void avahi_hashmap_remove(AvahiHashmap *m, const void *key);
+void catta_hashmap_free(CattaHashmap *m);
+void* catta_hashmap_lookup(CattaHashmap *m, const void *key);
+int catta_hashmap_insert(CattaHashmap *m, void *key, void *value);
+int catta_hashmap_replace(CattaHashmap *m, void *key, void *value);
+void catta_hashmap_remove(CattaHashmap *m, const void *key);
 
-typedef void (*AvahiHashmapForeachCallback)(void *key, void *value, void *userdata);
+typedef void (*CattaHashmapForeachCallback)(void *key, void *value, void *userdata);
 
-void avahi_hashmap_foreach(AvahiHashmap *m, AvahiHashmapForeachCallback callback, void *userdata);
+void catta_hashmap_foreach(CattaHashmap *m, CattaHashmapForeachCallback callback, void *userdata);
 
-unsigned avahi_string_hash(const void *data);
-int avahi_string_equal(const void *a, const void *b);
+unsigned catta_string_hash(const void *data);
+int catta_string_equal(const void *a, const void *b);
 
-unsigned avahi_int_hash(const void *data);
-int avahi_int_equal(const void *a, const void *b);
+unsigned catta_int_hash(const void *data);
+int catta_int_equal(const void *a, const void *b);
 
-AVAHI_C_DECL_END
+CATTA_C_DECL_END
 
 #endif
index 4ee5b1698f9d6725bcfeaac4164c0ab62e291db8..a3dc769a4f0df966d9c7aa6f6af6b88f05e18d6a 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
@@ -26,9 +26,9 @@
 #include <errno.h>
 #include <string.h>
 
-#include <avahi/malloc.h>
+#include <catta/malloc.h>
 
-#include <avahi/log.h>
+#include <catta/log.h>
 #include "iface.h"
 #include "iface-linux.h"
 
@@ -42,7 +42,7 @@
 #define IFA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))))
 #endif
 
-static int netlink_list_items(AvahiNetlink *nl, uint16_t type, unsigned *ret_seq) {
+static int netlink_list_items(CattaNetlink *nl, uint16_t type, unsigned *ret_seq) {
     struct nlmsghdr *n;
     struct rtgenmsg *gen;
     uint8_t req[1024];
@@ -60,11 +60,11 @@ static int netlink_list_items(AvahiNetlink *nl, uint16_t type, unsigned *ret_seq
     memset(gen, 0, sizeof(struct rtgenmsg));
     gen->rtgen_family = AF_UNSPEC;
 
-    return avahi_netlink_send(nl, n, ret_seq);
+    return catta_netlink_send(nl, n, ret_seq);
 }
 
-static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdata) {
-    AvahiInterfaceMonitor *m = userdata;
+static void netlink_callback(CattaNetlink *nl, struct nlmsghdr *n, void* userdata) {
+    CattaInterfaceMonitor *m = userdata;
 
     /* This routine is called for every RTNETLINK response packet */
 
@@ -77,7 +77,7 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat
         /* A new interface appeared or an existing one has been modified */
 
         struct ifinfomsg *ifinfomsg = NLMSG_DATA(n);
-        AvahiHwInterface *hw;
+        CattaHwInterface *hw;
         struct rtattr *a = NULL;
         size_t l;
 
@@ -85,19 +85,19 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat
         if (ifinfomsg->ifi_family != AF_UNSPEC)
             return;
 
-        /* Check whether there already is an AvahiHwInterface object
+        /* Check whether there already is an CattaHwInterface object
          * for this link, so that we can update its data. Note that
          * Netlink sends us an RTM_NEWLINK not only when a new
          * interface appears, but when it changes, too */
 
-        if (!(hw = avahi_interface_monitor_get_hw_interface(m, ifinfomsg->ifi_index)))
+        if (!(hw = catta_interface_monitor_get_hw_interface(m, ifinfomsg->ifi_index)))
 
             /* No object found, so let's create a new
-             * one. avahi_hw_interface_new() will call
-             * avahi_interface_new() internally twice for IPv4 and
+             * one. catta_hw_interface_new() will call
+             * catta_interface_new() internally twice for IPv4 and
              * IPv6, so there is no need for us to do that
              * ourselves */
-            if (!(hw = avahi_hw_interface_new(m, (AvahiIfIndex) ifinfomsg->ifi_index)))
+            if (!(hw = catta_hw_interface_new(m, (CattaIfIndex) ifinfomsg->ifi_index)))
                 return; /* OOM */
 
         /* Check whether the flags of this interface are OK for us */
@@ -117,8 +117,8 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat
                 case IFLA_IFNAME:
 
                     /* Fill in interface name */
-                    avahi_free(hw->name);
-                    hw->name = avahi_strndup(RTA_DATA(a), RTA_PAYLOAD(a));
+                    catta_free(hw->name);
+                    hw->name = catta_strndup(RTA_DATA(a), RTA_PAYLOAD(a));
                     break;
 
                 case IFLA_MTU:
@@ -132,8 +132,8 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat
 
                     /* Fill in hardware (MAC) address */
                     hw->mac_address_size = RTA_PAYLOAD(a);
-                    if (hw->mac_address_size > AVAHI_MAC_ADDRESS_MAX)
-                        hw->mac_address_size = AVAHI_MAC_ADDRESS_MAX;
+                    if (hw->mac_address_size > CATTA_MAC_ADDRESS_MAX)
+                        hw->mac_address_size = CATTA_MAC_ADDRESS_MAX;
 
                     memcpy(hw->mac_address, RTA_DATA(a), hw->mac_address_size);
                     break;
@@ -146,56 +146,56 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat
         }
 
         /* Check whether this interface is now "relevant" for us. If
-         * it is Avahi will start to announce its records on this
+         * it is Catta will start to announce its records on this
          * interface and send out queries for subscribed records on
          * it */
-        avahi_hw_interface_check_relevant(hw);
+        catta_hw_interface_check_relevant(hw);
 
         /* Update any associated RRs of this interface. (i.e. the
          * _workstation._tcp record containing the MAC address) */
-        avahi_hw_interface_update_rrs(hw, 0);
+        catta_hw_interface_update_rrs(hw, 0);
 
     } else if (n->nlmsg_type == RTM_DELLINK) {
 
         /* An interface has been removed */
 
         struct ifinfomsg *ifinfomsg = NLMSG_DATA(n);
-        AvahiHwInterface *hw;
+        CattaHwInterface *hw;
 
         /* A (superfluous?) sanity check */
         if (ifinfomsg->ifi_family != AF_UNSPEC)
             return;
 
-        /* Get a reference to our AvahiHwInterface object of this interface */
-        if (!(hw = avahi_interface_monitor_get_hw_interface(m, (AvahiIfIndex) ifinfomsg->ifi_index)))
+        /* Get a reference to our CattaHwInterface object of this interface */
+        if (!(hw = catta_interface_monitor_get_hw_interface(m, (CattaIfIndex) ifinfomsg->ifi_index)))
             return;
 
         /* Free our object */
-        avahi_hw_interface_free(hw, 0);
+        catta_hw_interface_free(hw, 0);
 
     } else if (n->nlmsg_type == RTM_NEWADDR || n->nlmsg_type == RTM_DELADDR) {
 
         /* An address has been added, modified or removed */
 
         struct ifaddrmsg *ifaddrmsg = NLMSG_DATA(n);
-        AvahiInterface *i;
+        CattaInterface *i;
         struct rtattr *a = NULL;
         size_t l;
-        AvahiAddress raddr, rlocal, *r;
+        CattaAddress raddr, rlocal, *r;
         int raddr_valid = 0, rlocal_valid = 0;
 
         /* We are only interested in IPv4 and IPv6 */
         if (ifaddrmsg->ifa_family != AF_INET && ifaddrmsg->ifa_family != AF_INET6)
             return;
 
-        /* Try to get a reference to our AvahiInterface object for the
+        /* Try to get a reference to our CattaInterface object for the
          * interface this address is assigned to. If ther is no object
          * for this interface, we ignore this address. */
-        if (!(i = avahi_interface_monitor_get_interface(m, (AvahiIfIndex) ifaddrmsg->ifa_index, avahi_af_to_proto(ifaddrmsg->ifa_family))))
+        if (!(i = catta_interface_monitor_get_interface(m, (CattaIfIndex) ifaddrmsg->ifa_index, catta_af_to_proto(ifaddrmsg->ifa_family))))
             return;
 
         /* Fill in address family for our new address */
-        rlocal.proto = raddr.proto = avahi_af_to_proto(ifaddrmsg->ifa_family);
+        rlocal.proto = raddr.proto = catta_af_to_proto(ifaddrmsg->ifa_family);
 
         l = NLMSG_PAYLOAD(n, sizeof(struct ifaddrmsg));
         a = IFA_RTA(ifaddrmsg);
@@ -206,8 +206,8 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat
 
                 case IFA_ADDRESS:
 
-                    if ((rlocal.proto == AVAHI_PROTO_INET6 && RTA_PAYLOAD(a) != 16) ||
-                        (rlocal.proto == AVAHI_PROTO_INET && RTA_PAYLOAD(a) != 4))
+                    if ((rlocal.proto == CATTA_PROTO_INET6 && RTA_PAYLOAD(a) != 16) ||
+                        (rlocal.proto == CATTA_PROTO_INET && RTA_PAYLOAD(a) != 4))
                         return;
 
                     memcpy(rlocal.data.data, RTA_DATA(a), RTA_PAYLOAD(a));
@@ -223,8 +223,8 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat
                      * link while IFA_ADDRESS refers to the other
                      * end. */
 
-                    if ((raddr.proto == AVAHI_PROTO_INET6 && RTA_PAYLOAD(a) != 16) ||
-                        (raddr.proto == AVAHI_PROTO_INET && RTA_PAYLOAD(a) != 4))
+                    if ((raddr.proto == CATTA_PROTO_INET6 && RTA_PAYLOAD(a) != 16) ||
+                        (raddr.proto == CATTA_PROTO_INET && RTA_PAYLOAD(a) != 4))
                         return;
 
                     memcpy(raddr.data.data, RTA_DATA(a), RTA_PAYLOAD(a));
@@ -248,38 +248,38 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat
             return;
 
         if (n->nlmsg_type == RTM_NEWADDR) {
-            AvahiInterfaceAddress *addr;
+            CattaInterfaceAddress *addr;
 
             /* This address is new or has been modified, so let's get an object for it */
-            if (!(addr = avahi_interface_monitor_get_address(m, i, r)))
+            if (!(addr = catta_interface_monitor_get_address(m, i, r)))
 
                 /* Mmm, no object existing yet, so let's create a new one */
-                if (!(addr = avahi_interface_address_new(m, i, r, ifaddrmsg->ifa_prefixlen)))
+                if (!(addr = catta_interface_address_new(m, i, r, ifaddrmsg->ifa_prefixlen)))
                     return; /* OOM */
 
             /* Update the scope field for the address */
             addr->global_scope = ifaddrmsg->ifa_scope == RT_SCOPE_UNIVERSE || ifaddrmsg->ifa_scope == RT_SCOPE_SITE;
             addr->deprecated = !!(ifaddrmsg->ifa_flags & IFA_F_DEPRECATED);
         } else {
-            AvahiInterfaceAddress *addr;
+            CattaInterfaceAddress *addr;
             assert(n->nlmsg_type == RTM_DELADDR);
 
-            /* Try to get a reference to our AvahiInterfaceAddress object for this address */
-            if (!(addr = avahi_interface_monitor_get_address(m, i, r)))
+            /* Try to get a reference to our CattaInterfaceAddress object for this address */
+            if (!(addr = catta_interface_monitor_get_address(m, i, r)))
                 return;
 
             /* And free it */
-            avahi_interface_address_free(addr);
+            catta_interface_address_free(addr);
         }
 
-        /* Avahi only considers interfaces with at least one address
+        /* Catta only considers interfaces with at least one address
          * attached relevant. Since we migh have added or removed an
          * address, let's have it check again whether the interface is
          * now relevant */
-        avahi_interface_check_relevant(i);
+        catta_interface_check_relevant(i);
 
         /* Update any associated RRs, like A or AAAA for our new/removed address */
-        avahi_interface_update_rrs(i, 0);
+        catta_interface_update_rrs(i, 0);
 
     } else if (n->nlmsg_type == NLMSG_DONE) {
 
@@ -291,7 +291,7 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat
              * let's go on with wild dumping the addresses */
 
             if (netlink_list_items(m->osdep.netlink, RTM_GETADDR, &m->osdep.query_addr_seq) < 0) {
-                avahi_log_warn("NETLINK: Failed to list addrs: %s", strerror(errno));
+                catta_log_warn("NETLINK: Failed to list addrs: %s", strerror(errno));
                 m->osdep.list = LIST_DONE;
             } else
 
@@ -299,12 +299,12 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat
                 m->osdep.list = LIST_ADDR;
 
         } else
-            /* We're done. Tell avahi_interface_monitor_sync() to finish. */
+            /* We're done. Tell catta_interface_monitor_sync() to finish. */
             m->osdep.list = LIST_DONE;
 
         if (m->osdep.list == LIST_DONE) {
 
-            /* Only after this boolean variable has been set, Avahi
+            /* Only after this boolean variable has been set, Catta
              * will start to announce or browse on all interfaces. It
              * is originaly set to 0, which means that relevancy
              * checks and RR updates are disabled during the wild
@@ -312,13 +312,13 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat
             m->list_complete = 1;
 
             /* So let's check if any interfaces are relevant now */
-            avahi_interface_monitor_check_relevant(m);
+            catta_interface_monitor_check_relevant(m);
 
             /* And update all RRs attached to any interface */
-            avahi_interface_monitor_update_rrs(m, 0);
+            catta_interface_monitor_update_rrs(m, 0);
 
             /* Tell the user that the wild dump is complete */
-            avahi_log_info("Network interface enumeration completed.");
+            catta_log_info("Network interface enumeration completed.");
         }
 
     } else if (n->nlmsg_type == NLMSG_ERROR &&
@@ -329,11 +329,11 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat
          * ignore it otherwise */
 
         if (e->error)
-            avahi_log_warn("NETLINK: Failed to browse: %s", strerror(-e->error));
+            catta_log_warn("NETLINK: Failed to browse: %s", strerror(-e->error));
     }
 }
 
-int avahi_interface_monitor_init_osdep(AvahiInterfaceMonitor *m) {
+int catta_interface_monitor_init_osdep(CattaInterfaceMonitor *m) {
     assert(m);
 
     /* Initialize our own data */
@@ -345,7 +345,7 @@ int avahi_interface_monitor_init_osdep(AvahiInterfaceMonitor *m) {
      * makes netlink easier to use. It will attach to the main loop
      * for us and call netlink_callback() whenever an event
      * happens. */
-    if (!(m->osdep.netlink = avahi_netlink_new(m->server->poll_api, RTMGRP_LINK|RTMGRP_IPV4_IFADDR|RTMGRP_IPV6_IFADDR, netlink_callback, m)))
+    if (!(m->osdep.netlink = catta_netlink_new(m->server->poll_api, RTMGRP_LINK|RTMGRP_IPV4_IFADDR|RTMGRP_IPV6_IFADDR, netlink_callback, m)))
         goto fail;
 
     /* Set the initial state. */
@@ -360,32 +360,32 @@ int avahi_interface_monitor_init_osdep(AvahiInterfaceMonitor *m) {
 fail:
 
     if (m->osdep.netlink) {
-        avahi_netlink_free(m->osdep.netlink);
+        catta_netlink_free(m->osdep.netlink);
         m->osdep.netlink = NULL;
     }
 
     return -1;
 }
 
-void avahi_interface_monitor_free_osdep(AvahiInterfaceMonitor *m) {
+void catta_interface_monitor_free_osdep(CattaInterfaceMonitor *m) {
     assert(m);
 
     if (m->osdep.netlink) {
-        avahi_netlink_free(m->osdep.netlink);
+        catta_netlink_free(m->osdep.netlink);
         m->osdep.netlink = NULL;
     }
 }
 
-void avahi_interface_monitor_sync(AvahiInterfaceMonitor *m) {
+void catta_interface_monitor_sync(CattaInterfaceMonitor *m) {
     assert(m);
 
     /* Let's handle netlink events until we are done with wild
      * dumping */
 
     while (!m->list_complete)
-        if (!avahi_netlink_work(m->osdep.netlink, 1) == 0)
+        if (!catta_netlink_work(m->osdep.netlink, 1) == 0)
             break;
 
-    /* At this point Avahi knows about all local interfaces and
+    /* At this point Catta knows about all local interfaces and
      * addresses in existance. */
 }
index 677f86dd7c6b561692edd1a4733edd241467c1b5..cfd00f69dcc66c55d5cc005c7256a9ec12764cbe 100644 (file)
@@ -2,30 +2,30 @@
 #define fooifacelinuxhfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
-typedef struct AvahiInterfaceMonitorOSDep AvahiInterfaceMonitorOSDep;
+typedef struct CattaInterfaceMonitorOSDep CattaInterfaceMonitorOSDep;
 
 #include "netlink.h"
 
-struct AvahiInterfaceMonitorOSDep {
-    AvahiNetlink *netlink;
+struct CattaInterfaceMonitorOSDep {
+    CattaNetlink *netlink;
 
     unsigned query_addr_seq, query_link_seq;
 
index 715e497e218a0c1b5479188cd74ac10300acd9c4..5dda5822091762f663dcc04da7f156b00868c50d 100644 (file)
@@ -1,30 +1,30 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 #include "iface.h"
 
-int avahi_interface_monitor_init_osdep(AvahiInterfaceMonitor *m) {
+int catta_interface_monitor_init_osdep(CattaInterfaceMonitor *m) {
     return 0;
 }
 
-void avahi_interface_monitor_free_osdep(AvahiInterfaceMonitor *m) {
+void catta_interface_monitor_free_osdep(CattaInterfaceMonitor *m) {
 }
 
-void avahi_interface_monitor_sync(AvahiInterfaceMonitor *m) {
+void catta_interface_monitor_sync(CattaInterfaceMonitor *m) {
 }
index 34c90fa068f70292192bf87032b530c2877304b0..3db53a38a1f5238b664b85810ad821e262ef4033 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
@@ -21,7 +21,7 @@
 #include <config.h>
 #endif
 
-#include <avahi/malloc.h>
+#include <catta/malloc.h>
 
 #include <string.h>
 #include <unistd.h>
@@ -41,7 +41,7 @@
 #include <net/if_dl.h>
 #include <netinet/in.h>
 
-#include <avahi/log.h>
+#include <catta/log.h>
 #include "iface.h"
 #include "iface-pfroute.h"
 #include "util.h"
@@ -57,9 +57,9 @@ static int bitcount (unsigned int n)
   return count ;
 }
 
-static void rtm_info(struct rt_msghdr *rtm, AvahiInterfaceMonitor *m)
+static void rtm_info(struct rt_msghdr *rtm, CattaInterfaceMonitor *m)
 {
-  AvahiHwInterface *hw;
+  CattaHwInterface *hw;
   struct if_msghdr *ifm = (struct if_msghdr *)rtm;
   struct sockaddr_dl *sdl = (struct sockaddr_dl *)(ifm + 1);
 
@@ -67,14 +67,14 @@ static void rtm_info(struct rt_msghdr *rtm, AvahiInterfaceMonitor *m)
     return;
 
   if (ifm->ifm_addrs == 0 && ifm->ifm_index > 0) {
-    if (!(hw = avahi_interface_monitor_get_hw_interface(m, (AvahiIfIndex) ifm->ifm_index)))
+    if (!(hw = catta_interface_monitor_get_hw_interface(m, (CattaIfIndex) ifm->ifm_index)))
       return;
-    avahi_hw_interface_free(hw, 0);
+    catta_hw_interface_free(hw, 0);
     return;
   }
 
-  if (!(hw = avahi_interface_monitor_get_hw_interface(m, ifm->ifm_index)))
-    if (!(hw = avahi_hw_interface_new(m, (AvahiIfIndex) ifm->ifm_index)))
+  if (!(hw = catta_interface_monitor_get_hw_interface(m, ifm->ifm_index)))
+    if (!(hw = catta_hw_interface_new(m, (CattaIfIndex) ifm->ifm_index)))
       return; /* OOM */
 
   hw->flags_ok =
@@ -84,28 +84,28 @@ static void rtm_info(struct rt_msghdr *rtm, AvahiInterfaceMonitor *m)
     (ifm->ifm_flags & IFF_MULTICAST) &&
     (m->server->config.allow_point_to_point || !(ifm->ifm_flags & IFF_POINTOPOINT));
 
-  avahi_free(hw->name);
-  hw->name = avahi_strndup(sdl->sdl_data, sdl->sdl_nlen);
+  catta_free(hw->name);
+  hw->name = catta_strndup(sdl->sdl_data, sdl->sdl_nlen);
 
   hw->mtu = ifm->ifm_data.ifi_mtu;
 
   hw->mac_address_size = sdl->sdl_alen;
-  if (hw->mac_address_size > AVAHI_MAC_ADDRESS_MAX)
-    hw->mac_address_size = AVAHI_MAC_ADDRESS_MAX;
+  if (hw->mac_address_size > CATTA_MAC_ADDRESS_MAX)
+    hw->mac_address_size = CATTA_MAC_ADDRESS_MAX;
 
   memcpy(hw->mac_address, sdl->sdl_data + sdl->sdl_nlen, hw->mac_address_size);
 
 /*   { */
 /*     char mac[256]; */
-/*     avahi_log_debug("======\n name: %s\n index:%d\n mtu:%d\n mac:%s\n flags_ok:%d\n======",  */
+/*     catta_log_debug("======\n name: %s\n index:%d\n mtu:%d\n mac:%s\n flags_ok:%d\n======",  */
 /*                 hw->name, hw->index,  */
 /*                 hw->mtu,  */
-/*                 avahi_format_mac_address(mac, sizeof(mac), hw->mac_address, hw->mac_address_size), */
+/*                 catta_format_mac_address(mac, sizeof(mac), hw->mac_address, hw->mac_address_size), */
 /*                 hw->flags_ok); */
 /*   } */
 
-  avahi_hw_interface_check_relevant(hw);
-  avahi_hw_interface_update_rrs(hw, 0);
+  catta_hw_interface_check_relevant(hw);
+  catta_hw_interface_update_rrs(hw, 0);
 }
 
 #define ROUNDUP(a) \
@@ -116,10 +116,10 @@ static void rtm_info(struct rt_msghdr *rtm, AvahiInterfaceMonitor *m)
 #define ADVANCE(x, n) (x += ROUNDUP(sizeof(struct sockaddr)))
 #endif
 
-static void rtm_addr(struct rt_msghdr *rtm, AvahiInterfaceMonitor *m)
+static void rtm_addr(struct rt_msghdr *rtm, CattaInterfaceMonitor *m)
 {
-  AvahiInterface *iface;
-  AvahiAddress raddr;
+  CattaInterface *iface;
+  CattaAddress raddr;
   int raddr_valid = 0;
   struct ifa_msghdr *ifam = (struct ifa_msghdr *) rtm;
   char *cp = (char *)(ifam + 1);
@@ -149,10 +149,10 @@ static void rtm_addr(struct rt_msghdr *rtm, AvahiInterfaceMonitor *m)
   if(sa->sa_family != AF_INET && sa->sa_family != AF_INET6)
     return;
 
-  if (!(iface = avahi_interface_monitor_get_interface(m, (AvahiIfIndex) ifam->ifam_index, avahi_af_to_proto(sa->sa_family))))
+  if (!(iface = catta_interface_monitor_get_interface(m, (CattaIfIndex) ifam->ifam_index, catta_af_to_proto(sa->sa_family))))
     return;
 
-  raddr.proto = avahi_af_to_proto(sa->sa_family);
+  raddr.proto = catta_af_to_proto(sa->sa_family);
 
   for(cp = cp0, i = 0; i < RTAX_MAX; i++)
     {
@@ -210,11 +210,11 @@ static void rtm_addr(struct rt_msghdr *rtm, AvahiInterfaceMonitor *m)
 
   if(rtm->rtm_type == RTM_NEWADDR)
     {
-      AvahiInterfaceAddress *addriface;
-      if (!(addriface = avahi_interface_monitor_get_address(m, iface, &raddr)))
-       if (!(addriface = avahi_interface_address_new(m, iface, &raddr, prefixlen)))
+      CattaInterfaceAddress *addriface;
+      if (!(addriface = catta_interface_monitor_get_address(m, iface, &raddr)))
+       if (!(addriface = catta_interface_address_new(m, iface, &raddr, prefixlen)))
          return; /* OOM */
-      if (raddr.proto == AVAHI_PROTO_INET6)
+      if (raddr.proto == CATTA_PROTO_INET6)
         {
          addriface->global_scope = !(IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)raddr.data.data) || IN6_IS_ADDR_MULTICAST((struct in6_addr *)raddr.data.data));
        }
@@ -223,24 +223,24 @@ static void rtm_addr(struct rt_msghdr *rtm, AvahiInterfaceMonitor *m)
     }
   else
     {
-      AvahiInterfaceAddress *addriface;
+      CattaInterfaceAddress *addriface;
       assert(rtm->rtm_type == RTM_DELADDR);
-      if (!(addriface = avahi_interface_monitor_get_address(m, iface, &raddr)))
+      if (!(addriface = catta_interface_monitor_get_address(m, iface, &raddr)))
        return;
-      avahi_interface_address_free(addriface);
+      catta_interface_address_free(addriface);
     }
 
-  avahi_interface_check_relevant(iface);
-  avahi_interface_update_rrs(iface, 0);
+  catta_interface_check_relevant(iface);
+  catta_interface_update_rrs(iface, 0);
 }
 
-static void parse_rtmsg(struct rt_msghdr *rtm, AvahiInterfaceMonitor *m)
+static void parse_rtmsg(struct rt_msghdr *rtm, CattaInterfaceMonitor *m)
 {
   assert(m);
   assert(rtm);
 
   if (rtm->rtm_version != RTM_VERSION) {
-    avahi_log_warn("routing message version %d not understood",
+    catta_log_warn("routing message version %d not understood",
                   rtm->rtm_version);
     return;
   }
@@ -258,9 +258,9 @@ static void parse_rtmsg(struct rt_msghdr *rtm, AvahiInterfaceMonitor *m)
   }
 }
 
-static void socket_event(AvahiWatch *w, int fd, AVAHI_GCC_UNUSED AvahiWatchEvent event,void *userdata) {
-  AvahiInterfaceMonitor *m = (AvahiInterfaceMonitor *)userdata;
-  AvahiPfRoute *nl = m->osdep.pfroute;
+static void socket_event(CattaWatch *w, int fd, CATTA_GCC_UNUSED CattaWatchEvent event,void *userdata) {
+  CattaInterfaceMonitor *m = (CattaInterfaceMonitor *)userdata;
+  CattaPfRoute *nl = m->osdep.pfroute;
     ssize_t bytes;
     char msg[2048];
 
@@ -273,7 +273,7 @@ static void socket_event(AvahiWatch *w, int fd, AVAHI_GCC_UNUSED AvahiWatchEvent
       if((bytes = recv(nl->fd, msg, 2048, MSG_DONTWAIT)) < 0) {
        if (errno == EAGAIN || errno == EINTR)
          return;
-       avahi_log_error(__FILE__": recv() failed: %s", strerror(errno));
+       catta_log_error(__FILE__": recv() failed: %s", strerror(errno));
        return;
       }
       parse_rtmsg((struct rt_msghdr *)msg, m);
@@ -281,7 +281,7 @@ static void socket_event(AvahiWatch *w, int fd, AVAHI_GCC_UNUSED AvahiWatchEvent
     while (bytes > 0);
 }
 
-int avahi_interface_monitor_init_osdep(AvahiInterfaceMonitor *m) {
+int catta_interface_monitor_init_osdep(CattaInterfaceMonitor *m) {
     int fd = -1;
 
     assert(m);
@@ -289,22 +289,22 @@ int avahi_interface_monitor_init_osdep(AvahiInterfaceMonitor *m) {
     m->osdep.pfroute = NULL;
 
     if ((fd = socket(PF_ROUTE, SOCK_RAW, AF_UNSPEC)) < 0) {
-        avahi_log_error(__FILE__": socket(PF_ROUTE): %s", strerror(errno));
+        catta_log_error(__FILE__": socket(PF_ROUTE): %s", strerror(errno));
         goto fail;
     }
 
-    if (!(m->osdep.pfroute = avahi_new(AvahiPfRoute , 1))) {
-        avahi_log_error(__FILE__": avahi_new() failed.");
+    if (!(m->osdep.pfroute = catta_new(CattaPfRoute , 1))) {
+        catta_log_error(__FILE__": catta_new() failed.");
         goto fail;
     }
     m->osdep.pfroute->fd = fd;
 
     if (!(m->osdep.pfroute->watch = m->server->poll_api->watch_new(m->server->poll_api,
                                                                   m->osdep.pfroute->fd,
-                                                                  AVAHI_WATCH_IN,
+                                                                  CATTA_WATCH_IN,
                                                                   socket_event,
                                                                   m))) {
-      avahi_log_error(__FILE__": Failed to create watch.");
+      catta_log_error(__FILE__": Failed to create watch.");
       goto fail;
     }
 
@@ -325,7 +325,7 @@ fail:
     return -1;
 }
 
-void avahi_interface_monitor_free_osdep(AvahiInterfaceMonitor *m) {
+void catta_interface_monitor_free_osdep(CattaInterfaceMonitor *m) {
     assert(m);
 
     if (m->osdep.pfroute) {
@@ -335,7 +335,7 @@ void avahi_interface_monitor_free_osdep(AvahiInterfaceMonitor *m) {
       if (m->osdep.pfroute->fd >= 0)
         close(m->osdep.pfroute->fd);
 
-      avahi_free(m->osdep.pfroute);
+      catta_free(m->osdep.pfroute);
       m->osdep.pfroute = NULL;
     }
 }
@@ -366,42 +366,42 @@ static int ip6_masklen (struct in6_addr netmask) {
     return len;
 }
 
-static void if_add_interface(struct lifreq *lifreq, AvahiInterfaceMonitor *m, int fd, int count)
+static void if_add_interface(struct lifreq *lifreq, CattaInterfaceMonitor *m, int fd, int count)
 {
-    AvahiHwInterface *hw;
-    AvahiAddress addr;
+    CattaHwInterface *hw;
+    CattaAddress addr;
     struct lifreq lifrcopy;
     unsigned int index;
     int flags;
     int mtu;
     int prefixlen;
-    AvahiInterfaceAddress *addriface;
-    AvahiInterface *iface;
+    CattaInterfaceAddress *addriface;
+    CattaInterface *iface;
     struct sockaddr_in mask;
     struct sockaddr_in6 mask6;
-    char caddr[AVAHI_ADDRESS_STR_MAX];
+    char caddr[CATTA_ADDRESS_STR_MAX];
 
     lifrcopy = *lifreq;
 
     if (ioctl(fd, SIOCGLIFFLAGS, &lifrcopy) < 0) {
-        avahi_log_error(__FILE__": ioctl(SIOCGLIFFLAGS) %s", strerror(errno));
+        catta_log_error(__FILE__": ioctl(SIOCGLIFFLAGS) %s", strerror(errno));
         return;
     }
     flags = lifrcopy.lifr_flags;
 
     if (ioctl(fd, SIOCGLIFMTU, &lifrcopy) < 0) {
-        avahi_log_error(__FILE__": ioctl(SIOCGLIFMTU) %s", strerror(errno));
+        catta_log_error(__FILE__": ioctl(SIOCGLIFMTU) %s", strerror(errno));
         return;
     }
     mtu = lifrcopy.lifr_metric;
 
     if (ioctl(fd, SIOCGLIFADDR, &lifrcopy) < 0) {
-        avahi_log_error(__FILE__": ioctl(SIOCGLIFADDR) %s", strerror(errno));
+        catta_log_error(__FILE__": ioctl(SIOCGLIFADDR) %s", strerror(errno));
         return;
     }
-    addr.proto = avahi_af_to_proto(lifreq->lifr_addr.ss_family);
+    addr.proto = catta_af_to_proto(lifreq->lifr_addr.ss_family);
     if (ioctl(fd, SIOCGLIFNETMASK, &lifrcopy) < 0) {
-        avahi_log_error(__FILE__": ioctl(SIOCGLIFNETMASK) %s", strerror(errno));
+        catta_log_error(__FILE__": ioctl(SIOCGLIFNETMASK) %s", strerror(errno));
         return;
     }
     switch (lifreq->lifr_addr.ss_family) {
@@ -420,8 +420,8 @@ static void if_add_interface(struct lifreq *lifreq, AvahiInterfaceMonitor *m, in
     }
     index = if_nametoindex(lifreq->lifr_name);
 
-    if (!(hw = avahi_interface_monitor_get_hw_interface(m, (AvahiIfIndex) index))) {
-        if (!(hw = avahi_hw_interface_new(m, (AvahiIfIndex) index)))
+    if (!(hw = catta_interface_monitor_get_hw_interface(m, (CattaIfIndex) index))) {
+        if (!(hw = catta_hw_interface_new(m, (CattaIfIndex) index)))
             return; /* OOM */
 
         hw->flags_ok =
@@ -430,26 +430,26 @@ static void if_add_interface(struct lifreq *lifreq, AvahiInterfaceMonitor *m, in
             !(flags & IFF_LOOPBACK) &&
             (flags & IFF_MULTICAST) &&
             (m->server->config.allow_point_to_point || !(flags & IFF_POINTOPOINT));
-        hw->name = avahi_strdup(lifreq->lifr_name);
+        hw->name = catta_strdup(lifreq->lifr_name);
         hw->mtu = mtu;
         /* TODO get mac address */
     }
 
-    if (!(iface = avahi_interface_monitor_get_interface(m, (AvahiIfIndex)index, addr.proto)))
+    if (!(iface = catta_interface_monitor_get_interface(m, (CattaIfIndex)index, addr.proto)))
         return;
 
-    if (!(addriface = avahi_interface_monitor_get_address(m, iface, &addr)))
-        if (!(addriface = avahi_interface_address_new(m, iface, &addr, prefixlen)))
+    if (!(addriface = catta_interface_monitor_get_address(m, iface, &addr)))
+        if (!(addriface = catta_interface_address_new(m, iface, &addr, prefixlen)))
             return; /* OOM */
 
     addriface->global_scope = 1;
 
-    avahi_hw_interface_check_relevant(hw);
-    avahi_hw_interface_update_rrs(hw, 0);
+    catta_hw_interface_check_relevant(hw);
+    catta_hw_interface_update_rrs(hw, 0);
 }
 #endif
 
-void avahi_interface_monitor_sync(AvahiInterfaceMonitor *m) {
+void catta_interface_monitor_sync(CattaInterfaceMonitor *m) {
 #ifndef HAVE_STRUCT_LIFCONF
   size_t needed;
   int mib[6];
@@ -467,21 +467,21 @@ void avahi_interface_monitor_sync(AvahiInterfaceMonitor *m) {
   mib[5] = 0;             /* no flags */
   if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
     {
-      avahi_log_error("sysctl failed: %s", strerror(errno));
-      avahi_log_error("route-sysctl-estimate");
+      catta_log_error("sysctl failed: %s", strerror(errno));
+      catta_log_error("route-sysctl-estimate");
       return;
     }
-  if ((buf = avahi_malloc(needed)) == NULL)
+  if ((buf = catta_malloc(needed)) == NULL)
     {
-      avahi_log_error("malloc failed in avahi_interface_monitor_sync");
+      catta_log_error("malloc failed in catta_interface_monitor_sync");
       return;
     }
   if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) {
-    avahi_log_warn("sysctl failed: %s", strerror(errno));
+    catta_log_warn("sysctl failed: %s", strerror(errno));
     if (errno == ENOMEM && count++ < 10) {
-      avahi_log_warn("Routing table grew, retrying");
+      catta_log_warn("Routing table grew, retrying");
       sleep(1);
-      avahi_free(buf);
+      catta_free(buf);
       goto retry2;
     }
   }
@@ -492,9 +492,9 @@ void avahi_interface_monitor_sync(AvahiInterfaceMonitor *m) {
   }
 
   m->list_complete = 1;
-  avahi_interface_monitor_check_relevant(m);
-  avahi_interface_monitor_update_rrs(m, 0);
-  avahi_log_info("Network interface enumeration completed.");
+  catta_interface_monitor_check_relevant(m);
+  catta_interface_monitor_update_rrs(m, 0);
+  catta_log_info("Network interface enumeration completed.");
 #elif defined (SIOCGLIFNUM) && defined(HAVE_STRUCT_LIFCONF) /* Solaris 8 and later; Sol 7? */
     int sockfd;
     int ret;
@@ -504,25 +504,25 @@ void avahi_interface_monitor_sync(AvahiInterfaceMonitor *m) {
     struct lifreq *lifreq;
 
     if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
-        avahi_log_error(__FILE__": socket(PFROUTE): %s", strerror(errno));
+        catta_log_error(__FILE__": socket(PFROUTE): %s", strerror(errno));
         return;
     }
     lifc.lifc_buf = NULL;
     lifn.lifn_family = AF_UNSPEC;
     lifn.lifn_flags = 0;
     if (ioctl(sockfd, SIOCGLIFNUM, &lifn) < 0) {
-        avahi_log_error(__FILE__": ioctl(SIOCGLIFNUM): %s", strerror(errno));
+        catta_log_error(__FILE__": ioctl(SIOCGLIFNUM): %s", strerror(errno));
         goto end;
     }
     lifc.lifc_len = lifn.lifn_count * sizeof (struct lifreq);
-    if ((lifc.lifc_buf = avahi_malloc(lifc.lifc_len)) == NULL) {
-            avahi_log_error("malloc failed in avahi_interface_monitor_sync");
+    if ((lifc.lifc_buf = catta_malloc(lifc.lifc_len)) == NULL) {
+            catta_log_error("malloc failed in catta_interface_monitor_sync");
             goto end;
     }
     lifc.lifc_family = NULL;
     lifc.lifc_flags = 0;
     if(ioctl(sockfd, SIOCGLIFCONF, &lifc) < 0) {
-        avahi_log_error(__FILE__": ioctl(SIOCGLIFCONF): %s", strerror(errno));
+        catta_log_error(__FILE__": ioctl(SIOCGLIFCONF): %s", strerror(errno));
         goto end;
     }
     lifreq = lifc.lifc_req;
@@ -532,12 +532,12 @@ void avahi_interface_monitor_sync(AvahiInterfaceMonitor *m) {
         lifreq++;
     }
     m->list_complete = 1;
-    avahi_interface_monitor_check_relevant(m);
-    avahi_interface_monitor_update_rrs(m, 0);
+    catta_interface_monitor_check_relevant(m);
+    catta_interface_monitor_update_rrs(m, 0);
 end:
     close(sockfd);
-    avahi_free(lifc.lifc_buf);
+    catta_free(lifc.lifc_buf);
 
-    avahi_log_info("Network interface enumeration completed.");
+    catta_log_info("Network interface enumeration completed.");
 #endif
 }
index 15c2dcb1c90c88a630b9561db77e71abb6065712..cc6758217ff0a62c5a74cf1e787044e8a78af6a9 100644 (file)
@@ -2,36 +2,36 @@
 #define fooifacepfroutehfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
-#include <avahi/watch.h>
+#include <catta/watch.h>
 
-typedef struct AvahiPfRoute AvahiPfRoute;
-struct AvahiPfRoute {
+typedef struct CattaPfRoute CattaPfRoute;
+struct CattaPfRoute {
   int fd;
-  AvahiWatch *watch;
-  AvahiInterfaceMonitor *m;
+  CattaWatch *watch;
+  CattaInterfaceMonitor *m;
 };
 
-typedef struct AvahiInterfaceMonitorOSDep AvahiInterfaceMonitorOSDep;
+typedef struct CattaInterfaceMonitorOSDep CattaInterfaceMonitorOSDep;
 
-struct AvahiInterfaceMonitorOSDep {
-    AvahiPfRoute *pfroute;
+struct CattaInterfaceMonitorOSDep {
+    CattaPfRoute *pfroute;
 };
 
 #endif
index aed4caddf66f0cc08f6299c7070a6d243cd31924..0940d63060f5ccd20916dea1a2fb49c8a2a90dd3 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <sys/socket.h>
 #include <netinet/in.h>
 
-#include <avahi/error.h>
-#include <avahi/malloc.h>
-#include <avahi/domain.h>
-#include <avahi/log.h>
+#include <catta/error.h>
+#include <catta/malloc.h>
+#include <catta/domain.h>
+#include <catta/log.h>
 
 #include "iface.h"
 #include "dns.h"
 #include "multicast-lookup.h"
 #include "querier.h"
 
-void avahi_interface_address_update_rrs(AvahiInterfaceAddress *a, int remove_rrs) {
-    AvahiInterfaceMonitor *m;
+void catta_interface_address_update_rrs(CattaInterfaceAddress *a, int remove_rrs) {
+    CattaInterfaceMonitor *m;
 
     assert(a);
     m = a->monitor;
 
     if (m->list_complete &&
-        avahi_interface_address_is_relevant(a) &&
-        avahi_interface_is_relevant(a->interface) &&
+        catta_interface_address_is_relevant(a) &&
+        catta_interface_is_relevant(a->interface) &&
         !remove_rrs &&
         m->server->config.publish_addresses &&
-        (m->server->state == AVAHI_SERVER_RUNNING ||
-        m->server->state == AVAHI_SERVER_REGISTERING)) {
+        (m->server->state == CATTA_SERVER_RUNNING ||
+        m->server->state == CATTA_SERVER_REGISTERING)) {
 
         /* Fill the entry group */
         if (!a->entry_group)
-            a->entry_group = avahi_s_entry_group_new(m->server, avahi_host_rr_entry_group_callback, NULL);
+            a->entry_group = catta_s_entry_group_new(m->server, catta_host_rr_entry_group_callback, NULL);
 
         if (!a->entry_group) /* OOM */
             return;
 
-        if (avahi_s_entry_group_is_empty(a->entry_group)) {
-            char t[AVAHI_ADDRESS_STR_MAX];
-            AvahiProtocol p;
+        if (catta_s_entry_group_is_empty(a->entry_group)) {
+            char t[CATTA_ADDRESS_STR_MAX];
+            CattaProtocol p;
 
-            p = (a->interface->protocol == AVAHI_PROTO_INET && m->server->config.publish_a_on_ipv6) ||
-                (a->interface->protocol == AVAHI_PROTO_INET6 && m->server->config.publish_aaaa_on_ipv4) ? AVAHI_PROTO_UNSPEC : a->interface->protocol;
+            p = (a->interface->protocol == CATTA_PROTO_INET && m->server->config.publish_a_on_ipv6) ||
+                (a->interface->protocol == CATTA_PROTO_INET6 && m->server->config.publish_aaaa_on_ipv4) ? CATTA_PROTO_UNSPEC : a->interface->protocol;
 
-            avahi_address_snprint(t, sizeof(t), &a->address);
-            avahi_log_info("Registering new address record for %s on %s.%s.", t, a->interface->hardware->name, p == AVAHI_PROTO_UNSPEC ? "*" : avahi_proto_to_string(p));
+            catta_address_snprint(t, sizeof(t), &a->address);
+            catta_log_info("Registering new address record for %s on %s.%s.", t, a->interface->hardware->name, p == CATTA_PROTO_UNSPEC ? "*" : catta_proto_to_string(p));
 
-            if (avahi_server_add_address(m->server, a->entry_group, a->interface->hardware->index, p, m->server->config.publish_no_reverse ? AVAHI_PUBLISH_NO_REVERSE : 0, NULL, &a->address) < 0) {
-                avahi_log_warn(__FILE__": avahi_server_add_address() failed: %s", avahi_strerror(m->server->error));
-                avahi_s_entry_group_free(a->entry_group);
+            if (catta_server_add_address(m->server, a->entry_group, a->interface->hardware->index, p, m->server->config.publish_no_reverse ? CATTA_PUBLISH_NO_REVERSE : 0, NULL, &a->address) < 0) {
+                catta_log_warn(__FILE__": catta_server_add_address() failed: %s", catta_strerror(m->server->error));
+                catta_s_entry_group_free(a->entry_group);
                 a->entry_group = NULL;
                 return;
             }
 
-            avahi_s_entry_group_commit(a->entry_group);
+            catta_s_entry_group_commit(a->entry_group);
         }
     } else {
 
         /* Clear the entry group */
 
-        if (a->entry_group && !avahi_s_entry_group_is_empty(a->entry_group)) {
-            char t[AVAHI_ADDRESS_STR_MAX];
-            avahi_address_snprint(t, sizeof(t), &a->address);
+        if (a->entry_group && !catta_s_entry_group_is_empty(a->entry_group)) {
+            char t[CATTA_ADDRESS_STR_MAX];
+            catta_address_snprint(t, sizeof(t), &a->address);
 
-            avahi_log_info("Withdrawing address record for %s on %s.", t, a->interface->hardware->name);
+            catta_log_info("Withdrawing address record for %s on %s.", t, a->interface->hardware->name);
 
-            if (avahi_s_entry_group_get_state(a->entry_group) == AVAHI_ENTRY_GROUP_REGISTERING &&
-                m->server->state == AVAHI_SERVER_REGISTERING)
-                avahi_server_decrease_host_rr_pending(m->server);
+            if (catta_s_entry_group_get_state(a->entry_group) == CATTA_ENTRY_GROUP_REGISTERING &&
+                m->server->state == CATTA_SERVER_REGISTERING)
+                catta_server_decrease_host_rr_pending(m->server);
 
-            avahi_s_entry_group_reset(a->entry_group);
+            catta_s_entry_group_reset(a->entry_group);
         }
     }
 }
 
-void avahi_interface_update_rrs(AvahiInterface *i, int remove_rrs) {
-    AvahiInterfaceAddress *a;
+void catta_interface_update_rrs(CattaInterface *i, int remove_rrs) {
+    CattaInterfaceAddress *a;
 
     assert(i);
 
     for (a = i->addresses; a; a = a->address_next)
-        avahi_interface_address_update_rrs(a, remove_rrs);
+        catta_interface_address_update_rrs(a, remove_rrs);
 }
 
-void avahi_hw_interface_update_rrs(AvahiHwInterface *hw, int remove_rrs) {
-    AvahiInterface *i;
-    AvahiInterfaceMonitor *m;
+void catta_hw_interface_update_rrs(CattaHwInterface *hw, int remove_rrs) {
+    CattaInterface *i;
+    CattaInterfaceMonitor *m;
 
     assert(hw);
     m = hw->monitor;
 
     for (i = hw->interfaces; i; i = i->by_hardware_next)
-        avahi_interface_update_rrs(i, remove_rrs);
+        catta_interface_update_rrs(i, remove_rrs);
 
     if (m->list_complete &&
         !remove_rrs &&
         m->server->config.publish_workstation &&
-        (m->server->state == AVAHI_SERVER_RUNNING)) {
+        (m->server->state == CATTA_SERVER_RUNNING)) {
 
         if (!hw->entry_group)
-            hw->entry_group = avahi_s_entry_group_new(m->server, avahi_host_rr_entry_group_callback, NULL);
+            hw->entry_group = catta_s_entry_group_new(m->server, catta_host_rr_entry_group_callback, NULL);
 
         if (!hw->entry_group)
             return; /* OOM */
 
-        if (avahi_s_entry_group_is_empty(hw->entry_group)) {
-            char name[AVAHI_LABEL_MAX], unescaped[AVAHI_LABEL_MAX], mac[256];
+        if (catta_s_entry_group_is_empty(hw->entry_group)) {
+            char name[CATTA_LABEL_MAX], unescaped[CATTA_LABEL_MAX], mac[256];
             const char *p = m->server->host_name;
 
-            avahi_unescape_label(&p, unescaped, sizeof(unescaped));
-            avahi_format_mac_address(mac, sizeof(mac), hw->mac_address, hw->mac_address_size);
+            catta_unescape_label(&p, unescaped, sizeof(unescaped));
+            catta_format_mac_address(mac, sizeof(mac), hw->mac_address, hw->mac_address_size);
             snprintf(name, sizeof(name), "%s [%s]", unescaped, mac);
 
-            if (avahi_server_add_service(m->server, hw->entry_group, hw->index, AVAHI_PROTO_UNSPEC, 0, name, "_workstation._tcp", NULL, NULL, 9, NULL) < 0) {
-                avahi_log_warn(__FILE__": avahi_server_add_service() failed: %s", avahi_strerror(m->server->error));
-                avahi_s_entry_group_free(hw->entry_group);
+            if (catta_server_add_service(m->server, hw->entry_group, hw->index, CATTA_PROTO_UNSPEC, 0, name, "_workstation._tcp", NULL, NULL, 9, NULL) < 0) {
+                catta_log_warn(__FILE__": catta_server_add_service() failed: %s", catta_strerror(m->server->error));
+                catta_s_entry_group_free(hw->entry_group);
                 hw->entry_group = NULL;
             } else
-                avahi_s_entry_group_commit(hw->entry_group);
+                catta_s_entry_group_commit(hw->entry_group);
         }
 
     } else {
 
-        if (hw->entry_group && !avahi_s_entry_group_is_empty(hw->entry_group)) {
+        if (hw->entry_group && !catta_s_entry_group_is_empty(hw->entry_group)) {
 
-            avahi_log_info("Withdrawing workstation service for %s.", hw->name);
+            catta_log_info("Withdrawing workstation service for %s.", hw->name);
 
-            if (avahi_s_entry_group_get_state(hw->entry_group) == AVAHI_ENTRY_GROUP_REGISTERING &&
-                m->server->state == AVAHI_SERVER_REGISTERING)
-                avahi_server_decrease_host_rr_pending(m->server);
+            if (catta_s_entry_group_get_state(hw->entry_group) == CATTA_ENTRY_GROUP_REGISTERING &&
+                m->server->state == CATTA_SERVER_REGISTERING)
+                catta_server_decrease_host_rr_pending(m->server);
 
-            avahi_s_entry_group_reset(hw->entry_group);
+            catta_s_entry_group_reset(hw->entry_group);
         }
     }
 }
 
-void avahi_interface_monitor_update_rrs(AvahiInterfaceMonitor *m, int remove_rrs) {
-    AvahiHwInterface *hw;
+void catta_interface_monitor_update_rrs(CattaInterfaceMonitor *m, int remove_rrs) {
+    CattaHwInterface *hw;
 
     assert(m);
 
     for (hw = m->hw_interfaces; hw; hw = hw->hardware_next)
-        avahi_hw_interface_update_rrs(hw, remove_rrs);
+        catta_hw_interface_update_rrs(hw, remove_rrs);
 }
 
-static int interface_mdns_mcast_join(AvahiInterface *i, int join) {
-    char at[AVAHI_ADDRESS_STR_MAX];
+static int interface_mdns_mcast_join(CattaInterface *i, int join) {
+    char at[CATTA_ADDRESS_STR_MAX];
     int r;
     assert(i);
 
     if (!!join  == !!i->mcast_joined)
         return 0;
 
-    if ((i->protocol == AVAHI_PROTO_INET6 && i->monitor->server->fd_ipv6 < 0) ||
-        (i->protocol == AVAHI_PROTO_INET && i->monitor->server->fd_ipv4 < 0))
+    if ((i->protocol == CATTA_PROTO_INET6 && i->monitor->server->fd_ipv6 < 0) ||
+        (i->protocol == CATTA_PROTO_INET && i->monitor->server->fd_ipv4 < 0))
         return -1;
 
     if (join) {
-        AvahiInterfaceAddress *a;
+        CattaInterfaceAddress *a;
 
         /* Look if there's an address with global scope */
         for (a = i->addresses; a; a = a->address_next)
@@ -203,18 +203,18 @@ static int interface_mdns_mcast_join(AvahiInterface *i, int join) {
         i->local_mcast_address = a->address;
     }
 
-    avahi_log_info("%s mDNS multicast group on interface %s.%s with address %s.",
+    catta_log_info("%s mDNS multicast group on interface %s.%s with address %s.",
                    join ? "Joining" : "Leaving",
                    i->hardware->name,
-                   avahi_proto_to_string(i->protocol),
-                   avahi_address_snprint(at, sizeof(at), &i->local_mcast_address));
+                   catta_proto_to_string(i->protocol),
+                   catta_address_snprint(at, sizeof(at), &i->local_mcast_address));
 
-    if (i->protocol == AVAHI_PROTO_INET6)
-        r = avahi_mdns_mcast_join_ipv6(i->monitor->server->fd_ipv6, &i->local_mcast_address.data.ipv6, i->hardware->index, join);
+    if (i->protocol == CATTA_PROTO_INET6)
+        r = catta_mdns_mcast_join_ipv6(i->monitor->server->fd_ipv6, &i->local_mcast_address.data.ipv6, i->hardware->index, join);
     else {
-        assert(i->protocol == AVAHI_PROTO_INET);
+        assert(i->protocol == CATTA_PROTO_INET);
 
-        r = avahi_mdns_mcast_join_ipv4(i->monitor->server->fd_ipv4, &i->local_mcast_address.data.ipv4, i->hardware->index, join);
+        r = catta_mdns_mcast_join_ipv4(i->monitor->server->fd_ipv4, &i->local_mcast_address.data.ipv4, i->hardware->index, join);
     }
 
     if (r < 0)
@@ -225,8 +225,8 @@ static int interface_mdns_mcast_join(AvahiInterface *i, int join) {
     return 0;
 }
 
-static int interface_mdns_mcast_rejoin(AvahiInterface *i) {
-    AvahiInterfaceAddress *a, *usable = NULL, *found = NULL;
+static int interface_mdns_mcast_rejoin(CattaInterface *i) {
+    CattaInterfaceAddress *a, *usable = NULL, *found = NULL;
     assert(i);
 
     if (!i->mcast_joined)
@@ -239,7 +239,7 @@ static int interface_mdns_mcast_rejoin(AvahiInterface *i) {
         if (a->global_scope && !usable)
             usable = a;
 
-        if (avahi_address_cmp(&a->address, &i->local_mcast_address) == 0) {
+        if (catta_address_cmp(&a->address, &i->local_mcast_address) == 0) {
 
             if (a->global_scope)
                 /* No action necessary: the address still exists and
@@ -258,79 +258,79 @@ static int interface_mdns_mcast_rejoin(AvahiInterface *i) {
     return interface_mdns_mcast_join(i, 1);
 }
 
-void avahi_interface_address_free(AvahiInterfaceAddress *a) {
+void catta_interface_address_free(CattaInterfaceAddress *a) {
     assert(a);
     assert(a->interface);
 
-    avahi_interface_address_update_rrs(a, 1);
-    AVAHI_LLIST_REMOVE(AvahiInterfaceAddress, address, a->interface->addresses, a);
+    catta_interface_address_update_rrs(a, 1);
+    CATTA_LLIST_REMOVE(CattaInterfaceAddress, address, a->interface->addresses, a);
 
     if (a->entry_group)
-        avahi_s_entry_group_free(a->entry_group);
+        catta_s_entry_group_free(a->entry_group);
 
     interface_mdns_mcast_rejoin(a->interface);
 
-    avahi_free(a);
+    catta_free(a);
 }
 
-void avahi_interface_free(AvahiInterface *i, int send_goodbye) {
+void catta_interface_free(CattaInterface *i, int send_goodbye) {
     assert(i);
 
     /* Handle goodbyes and remove announcers */
-    avahi_goodbye_interface(i->monitor->server, i, send_goodbye, 1);
-    avahi_response_scheduler_force(i->response_scheduler);
+    catta_goodbye_interface(i->monitor->server, i, send_goodbye, 1);
+    catta_response_scheduler_force(i->response_scheduler);
     assert(!i->announcers);
 
     if (i->mcast_joined)
         interface_mdns_mcast_join(i, 0);
 
     /* Remove queriers */
-    avahi_querier_free_all(i);
-    avahi_hashmap_free(i->queriers_by_key);
+    catta_querier_free_all(i);
+    catta_hashmap_free(i->queriers_by_key);
 
     /* Remove local RRs */
-    avahi_interface_update_rrs(i, 1);
+    catta_interface_update_rrs(i, 1);
 
     while (i->addresses)
-        avahi_interface_address_free(i->addresses);
+        catta_interface_address_free(i->addresses);
 
-    avahi_response_scheduler_free(i->response_scheduler);
-    avahi_query_scheduler_free(i->query_scheduler);
-    avahi_probe_scheduler_free(i->probe_scheduler);
-    avahi_cache_free(i->cache);
+    catta_response_scheduler_free(i->response_scheduler);
+    catta_query_scheduler_free(i->query_scheduler);
+    catta_probe_scheduler_free(i->probe_scheduler);
+    catta_cache_free(i->cache);
 
-    AVAHI_LLIST_REMOVE(AvahiInterface, interface, i->monitor->interfaces, i);
-    AVAHI_LLIST_REMOVE(AvahiInterface, by_hardware, i->hardware->interfaces, i);
+    CATTA_LLIST_REMOVE(CattaInterface, interface, i->monitor->interfaces, i);
+    CATTA_LLIST_REMOVE(CattaInterface, by_hardware, i->hardware->interfaces, i);
 
-    avahi_free(i);
+    catta_free(i);
 }
 
-void avahi_hw_interface_free(AvahiHwInterface *hw, int send_goodbye) {
+void catta_hw_interface_free(CattaHwInterface *hw, int send_goodbye) {
     assert(hw);
 
-    avahi_hw_interface_update_rrs(hw, 1);
+    catta_hw_interface_update_rrs(hw, 1);
 
     while (hw->interfaces)
-        avahi_interface_free(hw->interfaces, send_goodbye);
+        catta_interface_free(hw->interfaces, send_goodbye);
 
     if (hw->entry_group)
-        avahi_s_entry_group_free(hw->entry_group);
+        catta_s_entry_group_free(hw->entry_group);
 
-    AVAHI_LLIST_REMOVE(AvahiHwInterface, hardware, hw->monitor->hw_interfaces, hw);
-    avahi_hashmap_remove(hw->monitor->hashmap, &hw->index);
+    CATTA_LLIST_REMOVE(CattaHwInterface, hardware, hw->monitor->hw_interfaces, hw);
+    catta_hashmap_remove(hw->monitor->hashmap, &hw->index);
 
-    avahi_free(hw->name);
-    avahi_free(hw);
+    catta_free(hw->name);
+    catta_free(hw);
 }
 
-AvahiInterface* avahi_interface_new(AvahiInterfaceMonitor *m, AvahiHwInterface *hw, AvahiProtocol protocol) {
-    AvahiInterface *i;
+CattaInterface* catta_interface_new(CattaInterfaceMonitor *m, CattaHwInterface *hw, CattaProtocol protocol) {
+    CattaInterface *i;
 
     assert(m);
     assert(hw);
-    assert(AVAHI_PROTO_VALID(protocol));
+    assert(CATTA_PROTO_VALID(protocol));
 
-    if (!(i = avahi_new(AvahiInterface, 1)))
+    if (!(i = catta_new(CattaInterface, 1)))
         goto fail; /* OOM */
 
     i->monitor = m;
@@ -339,22 +339,22 @@ AvahiInterface* avahi_interface_new(AvahiInterfaceMonitor *m, AvahiHwInterface *
     i->announcing = 0;
     i->mcast_joined = 0;
 
-    AVAHI_LLIST_HEAD_INIT(AvahiInterfaceAddress, i->addresses);
-    AVAHI_LLIST_HEAD_INIT(AvahiAnnouncer, i->announcers);
+    CATTA_LLIST_HEAD_INIT(CattaInterfaceAddress, i->addresses);
+    CATTA_LLIST_HEAD_INIT(CattaAnnouncer, i->announcers);
 
-    AVAHI_LLIST_HEAD_INIT(AvahiQuerier, i->queriers);
-    i->queriers_by_key = avahi_hashmap_new((AvahiHashFunc) avahi_key_hash, (AvahiEqualFunc) avahi_key_equal, NULL, NULL);
+    CATTA_LLIST_HEAD_INIT(CattaQuerier, i->queriers);
+    i->queriers_by_key = catta_hashmap_new((CattaHashFunc) catta_key_hash, (CattaEqualFunc) catta_key_equal, NULL, NULL);
 
-    i->cache = avahi_cache_new(m->server, i);
-    i->response_scheduler = avahi_response_scheduler_new(i);
-    i->query_scheduler = avahi_query_scheduler_new(i);
-    i->probe_scheduler = avahi_probe_scheduler_new(i);
+    i->cache = catta_cache_new(m->server, i);
+    i->response_scheduler = catta_response_scheduler_new(i);
+    i->query_scheduler = catta_query_scheduler_new(i);
+    i->probe_scheduler = catta_probe_scheduler_new(i);
 
     if (!i->cache || !i->response_scheduler || !i->query_scheduler || !i->probe_scheduler)
         goto fail; /* OOM */
 
-    AVAHI_LLIST_PREPEND(AvahiInterface, by_hardware, hw->interfaces, i);
-    AVAHI_LLIST_PREPEND(AvahiInterface, interface, m->interfaces, i);
+    CATTA_LLIST_PREPEND(CattaInterface, by_hardware, hw->interfaces, i);
+    CATTA_LLIST_PREPEND(CattaInterface, interface, m->interfaces, i);
 
     return i;
 
@@ -362,25 +362,25 @@ fail:
 
     if (i) {
         if (i->cache)
-            avahi_cache_free(i->cache);
+            catta_cache_free(i->cache);
         if (i->response_scheduler)
-            avahi_response_scheduler_free(i->response_scheduler);
+            catta_response_scheduler_free(i->response_scheduler);
         if (i->query_scheduler)
-            avahi_query_scheduler_free(i->query_scheduler);
+            catta_query_scheduler_free(i->query_scheduler);
         if (i->probe_scheduler)
-            avahi_probe_scheduler_free(i->probe_scheduler);
+            catta_probe_scheduler_free(i->probe_scheduler);
     }
 
     return NULL;
 }
 
-AvahiHwInterface *avahi_hw_interface_new(AvahiInterfaceMonitor *m, AvahiIfIndex idx) {
-    AvahiHwInterface *hw;
+CattaHwInterface *catta_hw_interface_new(CattaInterfaceMonitor *m, CattaIfIndex idx) {
+    CattaHwInterface *hw;
 
     assert(m);
-    assert(AVAHI_IF_VALID(idx));
+    assert(CATTA_IF_VALID(idx));
 
-    if  (!(hw = avahi_new(AvahiHwInterface, 1)))
+    if  (!(hw = catta_new(CattaHwInterface, 1)))
         return NULL;
 
     hw->monitor = m;
@@ -394,26 +394,26 @@ AvahiHwInterface *avahi_hw_interface_new(AvahiInterfaceMonitor *m, AvahiIfIndex
     hw->ratelimit_begin.tv_usec = 0;
     hw->ratelimit_counter = 0;
 
-    AVAHI_LLIST_HEAD_INIT(AvahiInterface, hw->interfaces);
-    AVAHI_LLIST_PREPEND(AvahiHwInterface, hardware, m->hw_interfaces, hw);
+    CATTA_LLIST_HEAD_INIT(CattaInterface, hw->interfaces);
+    CATTA_LLIST_PREPEND(CattaHwInterface, hardware, m->hw_interfaces, hw);
 
-    avahi_hashmap_insert(m->hashmap, &hw->index, hw);
+    catta_hashmap_insert(m->hashmap, &hw->index, hw);
 
     if (m->server->fd_ipv4 >= 0 || m->server->config.publish_a_on_ipv6)
-        avahi_interface_new(m, hw, AVAHI_PROTO_INET);
+        catta_interface_new(m, hw, CATTA_PROTO_INET);
     if (m->server->fd_ipv6 >= 0 || m->server->config.publish_aaaa_on_ipv4)
-        avahi_interface_new(m, hw, AVAHI_PROTO_INET6);
+        catta_interface_new(m, hw, CATTA_PROTO_INET6);
 
     return hw;
 }
 
-AvahiInterfaceAddress *avahi_interface_address_new(AvahiInterfaceMonitor *m, AvahiInterface *i, const AvahiAddress *addr, unsigned prefix_len) {
-    AvahiInterfaceAddress *a;
+CattaInterfaceAddress *catta_interface_address_new(CattaInterfaceMonitor *m, CattaInterface *i, const CattaAddress *addr, unsigned prefix_len) {
+    CattaInterfaceAddress *a;
 
     assert(m);
     assert(i);
 
-    if (!(a = avahi_new(AvahiInterfaceAddress, 1)))
+    if (!(a = catta_new(CattaInterfaceAddress, 1)))
         return NULL;
 
     a->interface = i;
@@ -424,43 +424,43 @@ AvahiInterfaceAddress *avahi_interface_address_new(AvahiInterfaceMonitor *m, Ava
     a->deprecated = 0;
     a->entry_group = NULL;
 
-    AVAHI_LLIST_PREPEND(AvahiInterfaceAddress, address, i->addresses, a);
+    CATTA_LLIST_PREPEND(CattaInterfaceAddress, address, i->addresses, a);
 
     return a;
 }
 
-void avahi_interface_check_relevant(AvahiInterface *i) {
+void catta_interface_check_relevant(CattaInterface *i) {
     int b;
-    AvahiInterfaceMonitor *m;
+    CattaInterfaceMonitor *m;
 
     assert(i);
     m = i->monitor;
 
-    b = avahi_interface_is_relevant(i);
+    b = catta_interface_is_relevant(i);
 
     if (m->list_complete && b && !i->announcing) {
         interface_mdns_mcast_join(i, 1);
 
         if (i->mcast_joined) {
-            avahi_log_info("New relevant interface %s.%s for mDNS.", i->hardware->name, avahi_proto_to_string(i->protocol));
+            catta_log_info("New relevant interface %s.%s for mDNS.", i->hardware->name, catta_proto_to_string(i->protocol));
 
             i->announcing = 1;
-            avahi_announce_interface(m->server, i);
-            avahi_multicast_lookup_engine_new_interface(m->server->multicast_lookup_engine, i);
+            catta_announce_interface(m->server, i);
+            catta_multicast_lookup_engine_new_interface(m->server->multicast_lookup_engine, i);
         }
 
     } else if (!b && i->announcing) {
-        avahi_log_info("Interface %s.%s no longer relevant for mDNS.", i->hardware->name, avahi_proto_to_string(i->protocol));
+        catta_log_info("Interface %s.%s no longer relevant for mDNS.", i->hardware->name, catta_proto_to_string(i->protocol));
 
         interface_mdns_mcast_join(i, 0);
 
-        avahi_goodbye_interface(m->server, i, 0, 1);
-        avahi_querier_free_all(i);
+        catta_goodbye_interface(m->server, i, 0, 1);
+        catta_querier_free_all(i);
 
-        avahi_response_scheduler_clear(i->response_scheduler);
-        avahi_query_scheduler_clear(i->query_scheduler);
-        avahi_probe_scheduler_clear(i->probe_scheduler);
-        avahi_cache_flush(i->cache);
+        catta_response_scheduler_clear(i->response_scheduler);
+        catta_query_scheduler_clear(i->query_scheduler);
+        catta_probe_scheduler_clear(i->probe_scheduler);
+        catta_cache_flush(i->cache);
 
         i->announcing = 0;
 
@@ -468,73 +468,73 @@ void avahi_interface_check_relevant(AvahiInterface *i) {
         interface_mdns_mcast_rejoin(i);
 }
 
-void avahi_hw_interface_check_relevant(AvahiHwInterface *hw) {
-    AvahiInterface *i;
+void catta_hw_interface_check_relevant(CattaHwInterface *hw) {
+    CattaInterface *i;
 
     assert(hw);
 
     for (i = hw->interfaces; i; i = i->by_hardware_next)
-        avahi_interface_check_relevant(i);
+        catta_interface_check_relevant(i);
 }
 
-void avahi_interface_monitor_check_relevant(AvahiInterfaceMonitor *m) {
-    AvahiInterface *i;
+void catta_interface_monitor_check_relevant(CattaInterfaceMonitor *m) {
+    CattaInterface *i;
 
     assert(m);
 
     for (i = m->interfaces; i; i = i->interface_next)
-        avahi_interface_check_relevant(i);
+        catta_interface_check_relevant(i);
 }
 
-AvahiInterfaceMonitor *avahi_interface_monitor_new(AvahiServer *s) {
-    AvahiInterfaceMonitor *m = NULL;
+CattaInterfaceMonitor *catta_interface_monitor_new(CattaServer *s) {
+    CattaInterfaceMonitor *m = NULL;
 
-    if (!(m = avahi_new0(AvahiInterfaceMonitor, 1)))
+    if (!(m = catta_new0(CattaInterfaceMonitor, 1)))
         return NULL; /* OOM */
 
     m->server = s;
     m->list_complete = 0;
-    m->hashmap = avahi_hashmap_new(avahi_int_hash, avahi_int_equal, NULL, NULL);
+    m->hashmap = catta_hashmap_new(catta_int_hash, catta_int_equal, NULL, NULL);
 
-    AVAHI_LLIST_HEAD_INIT(AvahiInterface, m->interfaces);
-    AVAHI_LLIST_HEAD_INIT(AvahiHwInterface, m->hw_interfaces);
+    CATTA_LLIST_HEAD_INIT(CattaInterface, m->interfaces);
+    CATTA_LLIST_HEAD_INIT(CattaHwInterface, m->hw_interfaces);
 
-    if (avahi_interface_monitor_init_osdep(m) < 0)
+    if (catta_interface_monitor_init_osdep(m) < 0)
         goto fail;
 
     return m;
 
 fail:
-    avahi_interface_monitor_free(m);
+    catta_interface_monitor_free(m);
     return NULL;
 }
 
-void avahi_interface_monitor_free(AvahiInterfaceMonitor *m) {
+void catta_interface_monitor_free(CattaInterfaceMonitor *m) {
     assert(m);
 
     while (m->hw_interfaces)
-        avahi_hw_interface_free(m->hw_interfaces, 1);
+        catta_hw_interface_free(m->hw_interfaces, 1);
 
     assert(!m->interfaces);
 
-    avahi_interface_monitor_free_osdep(m);
+    catta_interface_monitor_free_osdep(m);
 
     if (m->hashmap)
-        avahi_hashmap_free(m->hashmap);
+        catta_hashmap_free(m->hashmap);
 
-    avahi_free(m);
+    catta_free(m);
 }
 
 
-AvahiInterface* avahi_interface_monitor_get_interface(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol) {
-    AvahiHwInterface *hw;
-    AvahiInterface *i;
+CattaInterface* catta_interface_monitor_get_interface(CattaInterfaceMonitor *m, CattaIfIndex idx, CattaProtocol protocol) {
+    CattaHwInterface *hw;
+    CattaInterface *i;
 
     assert(m);
     assert(idx >= 0);
-    assert(protocol != AVAHI_PROTO_UNSPEC);
+    assert(protocol != CATTA_PROTO_UNSPEC);
 
-    if (!(hw = avahi_interface_monitor_get_hw_interface(m, idx)))
+    if (!(hw = catta_interface_monitor_get_hw_interface(m, idx)))
         return NULL;
 
     for (i = hw->interfaces; i; i = i->by_hardware_next)
@@ -544,28 +544,28 @@ AvahiInterface* avahi_interface_monitor_get_interface(AvahiInterfaceMonitor *m,
     return NULL;
 }
 
-AvahiHwInterface* avahi_interface_monitor_get_hw_interface(AvahiInterfaceMonitor *m, AvahiIfIndex idx) {
+CattaHwInterface* catta_interface_monitor_get_hw_interface(CattaInterfaceMonitor *m, CattaIfIndex idx) {
     assert(m);
     assert(idx >= 0);
 
-    return avahi_hashmap_lookup(m->hashmap, &idx);
+    return catta_hashmap_lookup(m->hashmap, &idx);
 }
 
-AvahiInterfaceAddress* avahi_interface_monitor_get_address(AvahiInterfaceMonitor *m, AvahiInterface *i, const AvahiAddress *raddr) {
-    AvahiInterfaceAddress *ia;
+CattaInterfaceAddress* catta_interface_monitor_get_address(CattaInterfaceMonitor *m, CattaInterface *i, const CattaAddress *raddr) {
+    CattaInterfaceAddress *ia;
 
     assert(m);
     assert(i);
     assert(raddr);
 
     for (ia = i->addresses; ia; ia = ia->address_next)
-        if (avahi_address_cmp(&ia->address, raddr) == 0)
+        if (catta_address_cmp(&ia->address, raddr) == 0)
             return ia;
 
     return NULL;
 }
 
-void avahi_interface_send_packet_unicast(AvahiInterface *i, AvahiDnsPacket *p, const AvahiAddress *a, uint16_t port) {
+void catta_interface_send_packet_unicast(CattaInterface *i, CattaDnsPacket *p, const CattaAddress *a, uint16_t port) {
     assert(i);
     assert(p);
 
@@ -580,10 +580,10 @@ void avahi_interface_send_packet_unicast(AvahiInterface *i, AvahiDnsPacket *p, c
         gettimeofday(&now, NULL);
 
         end = i->hardware->ratelimit_begin;
-        avahi_timeval_add(&end, i->monitor->server->config.ratelimit_interval);
+        catta_timeval_add(&end, i->monitor->server->config.ratelimit_interval);
 
         if (i->hardware->ratelimit_begin.tv_sec <= 0 ||
-            avahi_timeval_compare(&end, &now) < 0) {
+            catta_timeval_compare(&end, &now) < 0) {
 
             i->hardware->ratelimit_begin = now;
             i->hardware->ratelimit_counter = 0;
@@ -595,64 +595,64 @@ void avahi_interface_send_packet_unicast(AvahiInterface *i, AvahiDnsPacket *p, c
         i->hardware->ratelimit_counter++;
     }
 
-    if (i->protocol == AVAHI_PROTO_INET && i->monitor->server->fd_ipv4 >= 0)
-        avahi_send_dns_packet_ipv4(i->monitor->server->fd_ipv4, i->hardware->index, p, i->mcast_joined ? &i->local_mcast_address.data.ipv4 : NULL, a ? &a->data.ipv4 : NULL, port);
-    else if (i->protocol == AVAHI_PROTO_INET6 && i->monitor->server->fd_ipv6 >= 0)
-        avahi_send_dns_packet_ipv6(i->monitor->server->fd_ipv6, i->hardware->index, p, i->mcast_joined ? &i->local_mcast_address.data.ipv6 : NULL, a ? &a->data.ipv6 : NULL, port);
+    if (i->protocol == CATTA_PROTO_INET && i->monitor->server->fd_ipv4 >= 0)
+        catta_send_dns_packet_ipv4(i->monitor->server->fd_ipv4, i->hardware->index, p, i->mcast_joined ? &i->local_mcast_address.data.ipv4 : NULL, a ? &a->data.ipv4 : NULL, port);
+    else if (i->protocol == CATTA_PROTO_INET6 && i->monitor->server->fd_ipv6 >= 0)
+        catta_send_dns_packet_ipv6(i->monitor->server->fd_ipv6, i->hardware->index, p, i->mcast_joined ? &i->local_mcast_address.data.ipv6 : NULL, a ? &a->data.ipv6 : NULL, port);
 }
 
-void avahi_interface_send_packet(AvahiInterface *i, AvahiDnsPacket *p) {
+void catta_interface_send_packet(CattaInterface *i, CattaDnsPacket *p) {
     assert(i);
     assert(p);
 
-    avahi_interface_send_packet_unicast(i, p, NULL, 0);
+    catta_interface_send_packet_unicast(i, p, NULL, 0);
 }
 
-int avahi_interface_post_query(AvahiInterface *i, AvahiKey *key, int immediately, unsigned *ret_id) {
+int catta_interface_post_query(CattaInterface *i, CattaKey *key, int immediately, unsigned *ret_id) {
     assert(i);
     assert(key);
 
     if (!i->announcing)
         return 0;
 
-    return avahi_query_scheduler_post(i->query_scheduler, key, immediately, ret_id);
+    return catta_query_scheduler_post(i->query_scheduler, key, immediately, ret_id);
 }
 
-int avahi_interface_withraw_query(AvahiInterface *i, unsigned id) {
+int catta_interface_withraw_query(CattaInterface *i, unsigned id) {
 
-    return avahi_query_scheduler_withdraw_by_id(i->query_scheduler, id);
+    return catta_query_scheduler_withdraw_by_id(i->query_scheduler, id);
 }
 
-int avahi_interface_post_response(AvahiInterface *i, AvahiRecord *record, int flush_cache, const AvahiAddress *querier, int immediately) {
+int catta_interface_post_response(CattaInterface *i, CattaRecord *record, int flush_cache, const CattaAddress *querier, int immediately) {
     assert(i);
     assert(record);
 
     if (!i->announcing)
         return 0;
 
-    return avahi_response_scheduler_post(i->response_scheduler, record, flush_cache, querier, immediately);
+    return catta_response_scheduler_post(i->response_scheduler, record, flush_cache, querier, immediately);
 }
 
-int avahi_interface_post_probe(AvahiInterface *i, AvahiRecord *record, int immediately) {
+int catta_interface_post_probe(CattaInterface *i, CattaRecord *record, int immediately) {
     assert(i);
     assert(record);
 
     if (!i->announcing)
         return 0;
 
-    return avahi_probe_scheduler_post(i->probe_scheduler, record, immediately);
+    return catta_probe_scheduler_post(i->probe_scheduler, record, immediately);
 }
 
-int avahi_dump_caches(AvahiInterfaceMonitor *m, AvahiDumpCallback callback, void* userdata) {
-    AvahiInterface *i;
+int catta_dump_caches(CattaInterfaceMonitor *m, CattaDumpCallback callback, void* userdata) {
+    CattaInterface *i;
     assert(m);
 
     for (i = m->interfaces; i; i = i->interface_next) {
-        if (avahi_interface_is_relevant(i)) {
+        if (catta_interface_is_relevant(i)) {
             char ln[256];
-            snprintf(ln, sizeof(ln), ";;; INTERFACE %s.%s ;;;", i->hardware->name, avahi_proto_to_string(i->protocol));
+            snprintf(ln, sizeof(ln), ";;; INTERFACE %s.%s ;;;", i->hardware->name, catta_proto_to_string(i->protocol));
             callback(ln, userdata);
-            if (avahi_cache_dump(i->cache, callback, userdata) < 0)
+            if (catta_cache_dump(i->cache, callback, userdata) < 0)
                 return -1;
         }
     }
@@ -660,8 +660,8 @@ int avahi_dump_caches(AvahiInterfaceMonitor *m, AvahiDumpCallback callback, void
     return 0;
 }
 
-static int avahi_interface_is_relevant_internal(AvahiInterface *i) {
-    AvahiInterfaceAddress *a;
+static int catta_interface_is_relevant_internal(CattaInterface *i) {
+    CattaInterfaceAddress *a;
 
     assert(i);
 
@@ -669,14 +669,14 @@ static int avahi_interface_is_relevant_internal(AvahiInterface *i) {
         return 0;
 
     for (a = i->addresses; a; a = a->address_next)
-        if (avahi_interface_address_is_relevant(a))
+        if (catta_interface_address_is_relevant(a))
             return 1;
 
     return 0;
 }
 
-int avahi_interface_is_relevant(AvahiInterface *i) {
-    AvahiStringList *l;
+int catta_interface_is_relevant(CattaInterface *i) {
+    CattaStringList *l;
     assert(i);
 
     for (l = i->monitor->server->config.deny_interfaces; l; l = l->next)
@@ -693,11 +693,11 @@ int avahi_interface_is_relevant(AvahiInterface *i) {
     }
 
 good:
-    return avahi_interface_is_relevant_internal(i);
+    return catta_interface_is_relevant_internal(i);
 }
 
-int avahi_interface_address_is_relevant(AvahiInterfaceAddress *a) {
-    AvahiInterfaceAddress *b;
+int catta_interface_address_is_relevant(CattaInterfaceAddress *a) {
+    CattaInterfaceAddress *b;
     assert(a);
 
     /* Publish public and non-deprecated IP addresses */
@@ -717,65 +717,65 @@ int avahi_interface_address_is_relevant(AvahiInterfaceAddress *a) {
     return 1;
 }
 
-int avahi_interface_match(AvahiInterface *i, AvahiIfIndex idx, AvahiProtocol protocol) {
+int catta_interface_match(CattaInterface *i, CattaIfIndex idx, CattaProtocol protocol) {
     assert(i);
 
-    if (idx != AVAHI_IF_UNSPEC && idx != i->hardware->index)
+    if (idx != CATTA_IF_UNSPEC && idx != i->hardware->index)
         return 0;
 
-    if (protocol != AVAHI_PROTO_UNSPEC && protocol != i->protocol)
+    if (protocol != CATTA_PROTO_UNSPEC && protocol != i->protocol)
         return 0;
 
     return 1;
 }
 
-void avahi_interface_monitor_walk(AvahiInterfaceMonitor *m, AvahiIfIndex interface, AvahiProtocol protocol, AvahiInterfaceMonitorWalkCallback callback, void* userdata) {
+void catta_interface_monitor_walk(CattaInterfaceMonitor *m, CattaIfIndex interface, CattaProtocol protocol, CattaInterfaceMonitorWalkCallback callback, void* userdata) {
     assert(m);
     assert(callback);
 
-    if (interface != AVAHI_IF_UNSPEC) {
-        if (protocol != AVAHI_PROTO_UNSPEC) {
-            AvahiInterface *i;
+    if (interface != CATTA_IF_UNSPEC) {
+        if (protocol != CATTA_PROTO_UNSPEC) {
+            CattaInterface *i;
 
-            if ((i = avahi_interface_monitor_get_interface(m, interface, protocol)))
+            if ((i = catta_interface_monitor_get_interface(m, interface, protocol)))
                 callback(m, i, userdata);
 
         } else {
-            AvahiHwInterface *hw;
-            AvahiInterface *i;
+            CattaHwInterface *hw;
+            CattaInterface *i;
 
-            if ((hw = avahi_interface_monitor_get_hw_interface(m, interface)))
+            if ((hw = catta_interface_monitor_get_hw_interface(m, interface)))
                 for (i = hw->interfaces; i; i = i->by_hardware_next)
-                    if (avahi_interface_match(i, interface, protocol))
+                    if (catta_interface_match(i, interface, protocol))
                         callback(m, i, userdata);
         }
 
     } else {
-        AvahiInterface *i;
+        CattaInterface *i;
 
         for (i = m->interfaces; i; i = i->interface_next)
-            if (avahi_interface_match(i, interface, protocol))
+            if (catta_interface_match(i, interface, protocol))
                 callback(m, i, userdata);
     }
 }
 
 
-int avahi_address_is_local(AvahiInterfaceMonitor *m, const AvahiAddress *a) {
-    AvahiInterface *i;
-    AvahiInterfaceAddress *ia;
+int catta_address_is_local(CattaInterfaceMonitor *m, const CattaAddress *a) {
+    CattaInterface *i;
+    CattaInterfaceAddress *ia;
     assert(m);
     assert(a);
 
     for (i = m->interfaces; i; i = i->interface_next)
         for (ia = i->addresses; ia; ia = ia->address_next)
-            if (avahi_address_cmp(a, &ia->address) == 0)
+            if (catta_address_cmp(a, &ia->address) == 0)
                 return 1;
 
     return 0;
 }
 
-int avahi_interface_address_on_link(AvahiInterface *i, const AvahiAddress *a) {
-    AvahiInterfaceAddress *ia;
+int catta_interface_address_on_link(CattaInterface *i, const CattaAddress *a) {
+    CattaInterfaceAddress *ia;
 
     assert(i);
     assert(a);
@@ -785,7 +785,7 @@ int avahi_interface_address_on_link(AvahiInterface *i, const AvahiAddress *a) {
 
     for (ia = i->addresses; ia; ia = ia->address_next) {
 
-        if (a->proto == AVAHI_PROTO_INET) {
+        if (a->proto == CATTA_PROTO_INET) {
             uint32_t m;
 
             m = ~(((uint32_t) -1) >> ia->prefix_len);
@@ -795,7 +795,7 @@ int avahi_interface_address_on_link(AvahiInterface *i, const AvahiAddress *a) {
         } else {
             unsigned j;
             unsigned char pl;
-            assert(a->proto == AVAHI_PROTO_INET6);
+            assert(a->proto == CATTA_PROTO_INET6);
 
             pl = ia->prefix_len;
 
@@ -822,26 +822,26 @@ int avahi_interface_address_on_link(AvahiInterface *i, const AvahiAddress *a) {
     return 0;
 }
 
-int avahi_interface_has_address(AvahiInterfaceMonitor *m, AvahiIfIndex iface, const AvahiAddress *a) {
-    AvahiInterface *i;
-    AvahiInterfaceAddress *j;
+int catta_interface_has_address(CattaInterfaceMonitor *m, CattaIfIndex iface, const CattaAddress *a) {
+    CattaInterface *i;
+    CattaInterfaceAddress *j;
 
     assert(m);
-    assert(iface != AVAHI_IF_UNSPEC);
+    assert(iface != CATTA_IF_UNSPEC);
     assert(a);
 
-    if (!(i = avahi_interface_monitor_get_interface(m, iface, a->proto)))
+    if (!(i = catta_interface_monitor_get_interface(m, iface, a->proto)))
         return 0;
 
     for (j = i->addresses; j; j = j->address_next)
-        if (avahi_address_cmp(a, &j->address) == 0)
+        if (catta_address_cmp(a, &j->address) == 0)
             return 1;
 
     return 0;
 }
 
-AvahiIfIndex avahi_find_interface_for_address(AvahiInterfaceMonitor *m, const AvahiAddress *a) {
-    AvahiInterface *i;
+CattaIfIndex catta_find_interface_for_address(CattaInterfaceMonitor *m, const CattaAddress *a) {
+    CattaInterface *i;
     assert(m);
 
     /* Some stupid OS don't support passing the interface index when a
@@ -851,15 +851,15 @@ AvahiIfIndex avahi_find_interface_for_address(AvahiInterfaceMonitor *m, const Av
      * it. */
 
     for (i = m->interfaces; i; i = i->interface_next) {
-        AvahiInterfaceAddress *ai;
+        CattaInterfaceAddress *ai;
 
         if (i->protocol != a->proto)
             continue;
 
         for (ai = i->addresses; ai; ai = ai->address_next)
-            if (avahi_address_cmp(a, &ai->address) == 0)
+            if (catta_address_cmp(a, &ai->address) == 0)
                 return i->hardware->index;
     }
 
-    return AVAHI_IF_UNSPEC;
+    return CATTA_IF_UNSPEC;
 }
index 88d75c282bafb6e3d14821b84d752b5f9c9e8eae..22d225ee9acdfb80906ea5584716457b810f3dfd 100644 (file)
@@ -2,31 +2,31 @@
 #define fooifacehfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
-typedef struct AvahiInterfaceMonitor AvahiInterfaceMonitor;
-typedef struct AvahiInterfaceAddress AvahiInterfaceAddress;
-typedef struct AvahiInterface AvahiInterface;
-typedef struct AvahiHwInterface AvahiHwInterface;
+typedef struct CattaInterfaceMonitor CattaInterfaceMonitor;
+typedef struct CattaInterfaceAddress CattaInterfaceAddress;
+typedef struct CattaInterface CattaInterface;
+typedef struct CattaHwInterface CattaHwInterface;
 
-#include <avahi/llist.h>
-#include <avahi/address.h>
+#include <catta/llist.h>
+#include <catta/address.h>
 
 #include "internal.h"
 #include "cache.h"
@@ -43,8 +43,8 @@ typedef struct AvahiHwInterface AvahiHwInterface;
 #elif defined(HAVE_PF_ROUTE)
 #include "iface-pfroute.h"
 #else
-typedef struct AvahiInterfaceMonitorOSDep AvahiInterfaceMonitorOSDep;
-struct AvahiInterfaceMonitorOSDep {
+typedef struct CattaInterfaceMonitorOSDep CattaInterfaceMonitorOSDep;
+struct CattaInterfaceMonitorOSDep {
 
     unsigned query_addr_seq, query_link_seq;
 
@@ -56,140 +56,140 @@ struct AvahiInterfaceMonitorOSDep {
 };
 #endif
 
-#define AVAHI_MAC_ADDRESS_MAX 32
+#define CATTA_MAC_ADDRESS_MAX 32
 
-struct AvahiInterfaceMonitor {
-    AvahiServer *server;
-    AvahiHashmap *hashmap;
+struct CattaInterfaceMonitor {
+    CattaServer *server;
+    CattaHashmap *hashmap;
 
-    AVAHI_LLIST_HEAD(AvahiInterface, interfaces);
-    AVAHI_LLIST_HEAD(AvahiHwInterface, hw_interfaces);
+    CATTA_LLIST_HEAD(CattaInterface, interfaces);
+    CATTA_LLIST_HEAD(CattaHwInterface, hw_interfaces);
 
     int list_complete;
-    AvahiInterfaceMonitorOSDep osdep;
+    CattaInterfaceMonitorOSDep osdep;
 };
 
-struct AvahiHwInterface {
-    AvahiInterfaceMonitor *monitor;
+struct CattaHwInterface {
+    CattaInterfaceMonitor *monitor;
 
-    AVAHI_LLIST_FIELDS(AvahiHwInterface, hardware);
+    CATTA_LLIST_FIELDS(CattaHwInterface, hardware);
 
     char *name;
-    AvahiIfIndex index;
+    CattaIfIndex index;
     int flags_ok;
 
     unsigned mtu;
 
-    uint8_t mac_address[AVAHI_MAC_ADDRESS_MAX];
+    uint8_t mac_address[CATTA_MAC_ADDRESS_MAX];
     size_t mac_address_size;
 
-    AvahiSEntryGroup *entry_group;
+    CattaSEntryGroup *entry_group;
 
     /* Packet rate limiting */
     struct timeval ratelimit_begin;
     unsigned ratelimit_counter;
 
-    AVAHI_LLIST_HEAD(AvahiInterface, interfaces);
+    CATTA_LLIST_HEAD(CattaInterface, interfaces);
 };
 
-struct AvahiInterface {
-    AvahiInterfaceMonitor *monitor;
-    AvahiHwInterface *hardware;
+struct CattaInterface {
+    CattaInterfaceMonitor *monitor;
+    CattaHwInterface *hardware;
 
-    AVAHI_LLIST_FIELDS(AvahiInterface, interface);
-    AVAHI_LLIST_FIELDS(AvahiInterface, by_hardware);
+    CATTA_LLIST_FIELDS(CattaInterface, interface);
+    CATTA_LLIST_FIELDS(CattaInterface, by_hardware);
 
-    AvahiProtocol protocol;
+    CattaProtocol protocol;
     int announcing;
-    AvahiAddress local_mcast_address;
+    CattaAddress local_mcast_address;
     int mcast_joined;
 
-    AvahiCache *cache;
+    CattaCache *cache;
 
-    AvahiQueryScheduler *query_scheduler;
-    AvahiResponseScheduler * response_scheduler;
-    AvahiProbeScheduler *probe_scheduler;
+    CattaQueryScheduler *query_scheduler;
+    CattaResponseScheduler * response_scheduler;
+    CattaProbeScheduler *probe_scheduler;
 
-    AVAHI_LLIST_HEAD(AvahiInterfaceAddress, addresses);
-    AVAHI_LLIST_HEAD(AvahiAnnouncer, announcers);
+    CATTA_LLIST_HEAD(CattaInterfaceAddress, addresses);
+    CATTA_LLIST_HEAD(CattaAnnouncer, announcers);
 
-    AvahiHashmap *queriers_by_key;
-    AVAHI_LLIST_HEAD(AvahiQuerier, queriers);
+    CattaHashmap *queriers_by_key;
+    CATTA_LLIST_HEAD(CattaQuerier, queriers);
 };
 
-struct AvahiInterfaceAddress {
-    AvahiInterfaceMonitor *monitor;
-    AvahiInterface *interface;
+struct CattaInterfaceAddress {
+    CattaInterfaceMonitor *monitor;
+    CattaInterface *interface;
 
-    AVAHI_LLIST_FIELDS(AvahiInterfaceAddress, address);
+    CATTA_LLIST_FIELDS(CattaInterfaceAddress, address);
 
-    AvahiAddress address;
+    CattaAddress address;
     unsigned prefix_len;
 
     int global_scope;
     int deprecated;
 
-    AvahiSEntryGroup *entry_group;
+    CattaSEntryGroup *entry_group;
 };
 
-AvahiInterfaceMonitor *avahi_interface_monitor_new(AvahiServer *server);
-void avahi_interface_monitor_free(AvahiInterfaceMonitor *m);
+CattaInterfaceMonitor *catta_interface_monitor_new(CattaServer *server);
+void catta_interface_monitor_free(CattaInterfaceMonitor *m);
 
-int avahi_interface_monitor_init_osdep(AvahiInterfaceMonitor *m);
-void avahi_interface_monitor_free_osdep(AvahiInterfaceMonitor *m);
-void avahi_interface_monitor_sync(AvahiInterfaceMonitor *m);
+int catta_interface_monitor_init_osdep(CattaInterfaceMonitor *m);
+void catta_interface_monitor_free_osdep(CattaInterfaceMonitor *m);
+void catta_interface_monitor_sync(CattaInterfaceMonitor *m);
 
-typedef void (*AvahiInterfaceMonitorWalkCallback)(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata);
-void avahi_interface_monitor_walk(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol, AvahiInterfaceMonitorWalkCallback callback, void* userdata);
-int avahi_dump_caches(AvahiInterfaceMonitor *m, AvahiDumpCallback callback, void* userdata);
+typedef void (*CattaInterfaceMonitorWalkCallback)(CattaInterfaceMonitor *m, CattaInterface *i, void* userdata);
+void catta_interface_monitor_walk(CattaInterfaceMonitor *m, CattaIfIndex idx, CattaProtocol protocol, CattaInterfaceMonitorWalkCallback callback, void* userdata);
+int catta_dump_caches(CattaInterfaceMonitor *m, CattaDumpCallback callback, void* userdata);
 
-void avahi_interface_monitor_update_rrs(AvahiInterfaceMonitor *m, int remove_rrs);
-int avahi_address_is_local(AvahiInterfaceMonitor *m, const AvahiAddress *a);
-void avahi_interface_monitor_check_relevant(AvahiInterfaceMonitor *m);
+void catta_interface_monitor_update_rrs(CattaInterfaceMonitor *m, int remove_rrs);
+int catta_address_is_local(CattaInterfaceMonitor *m, const CattaAddress *a);
+void catta_interface_monitor_check_relevant(CattaInterfaceMonitor *m);
 
-/* AvahiHwInterface */
+/* CattaHwInterface */
 
-AvahiHwInterface *avahi_hw_interface_new(AvahiInterfaceMonitor *m, AvahiIfIndex idx);
-void avahi_hw_interface_free(AvahiHwInterface *hw, int send_goodbye);
+CattaHwInterface *catta_hw_interface_new(CattaInterfaceMonitor *m, CattaIfIndex idx);
+void catta_hw_interface_free(CattaHwInterface *hw, int send_goodbye);
 
-void avahi_hw_interface_update_rrs(AvahiHwInterface *hw, int remove_rrs);
-void avahi_hw_interface_check_relevant(AvahiHwInterface *hw);
+void catta_hw_interface_update_rrs(CattaHwInterface *hw, int remove_rrs);
+void catta_hw_interface_check_relevant(CattaHwInterface *hw);
 
-AvahiHwInterface* avahi_interface_monitor_get_hw_interface(AvahiInterfaceMonitor *m, int idx);
+CattaHwInterface* catta_interface_monitor_get_hw_interface(CattaInterfaceMonitor *m, int idx);
 
-/* AvahiInterface */
+/* CattaInterface */
 
-AvahiInterface* avahi_interface_new(AvahiInterfaceMonitor *m, AvahiHwInterface *hw, AvahiProtocol protocol);
-void avahi_interface_free(AvahiInterface *i, int send_goodbye);
+CattaInterface* catta_interface_new(CattaInterfaceMonitor *m, CattaHwInterface *hw, CattaProtocol protocol);
+void catta_interface_free(CattaInterface *i, int send_goodbye);
 
-void avahi_interface_update_rrs(AvahiInterface *i, int remove_rrs);
-void avahi_interface_check_relevant(AvahiInterface *i);
-int avahi_interface_is_relevant(AvahiInterface *i);
+void catta_interface_update_rrs(CattaInterface *i, int remove_rrs);
+void catta_interface_check_relevant(CattaInterface *i);
+int catta_interface_is_relevant(CattaInterface *i);
 
-void avahi_interface_send_packet(AvahiInterface *i, AvahiDnsPacket *p);
-void avahi_interface_send_packet_unicast(AvahiInterface *i, AvahiDnsPacket *p, const AvahiAddress *a, uint16_t port);
+void catta_interface_send_packet(CattaInterface *i, CattaDnsPacket *p);
+void catta_interface_send_packet_unicast(CattaInterface *i, CattaDnsPacket *p, const CattaAddress *a, uint16_t port);
 
-int avahi_interface_post_query(AvahiInterface *i, AvahiKey *k, int immediately, unsigned *ret_id);
-int avahi_interface_withraw_query(AvahiInterface *i, unsigned id);
-int avahi_interface_post_response(AvahiInterface *i, AvahiRecord *record, int flush_cache, const AvahiAddress *querier, int immediately);
-int avahi_interface_post_probe(AvahiInterface *i, AvahiRecord *p, int immediately);
+int catta_interface_post_query(CattaInterface *i, CattaKey *k, int immediately, unsigned *ret_id);
+int catta_interface_withraw_query(CattaInterface *i, unsigned id);
+int catta_interface_post_response(CattaInterface *i, CattaRecord *record, int flush_cache, const CattaAddress *querier, int immediately);
+int catta_interface_post_probe(CattaInterface *i, CattaRecord *p, int immediately);
 
-int avahi_interface_match(AvahiInterface *i, AvahiIfIndex idx, AvahiProtocol protocol);
-int avahi_interface_address_on_link(AvahiInterface *i, const AvahiAddress *a);
-int avahi_interface_has_address(AvahiInterfaceMonitor *m, AvahiIfIndex iface, const AvahiAddress *a);
+int catta_interface_match(CattaInterface *i, CattaIfIndex idx, CattaProtocol protocol);
+int catta_interface_address_on_link(CattaInterface *i, const CattaAddress *a);
+int catta_interface_has_address(CattaInterfaceMonitor *m, CattaIfIndex iface, const CattaAddress *a);
 
-AvahiInterface* avahi_interface_monitor_get_interface(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol);
+CattaInterface* catta_interface_monitor_get_interface(CattaInterfaceMonitor *m, CattaIfIndex idx, CattaProtocol protocol);
 
-/* AvahiInterfaceAddress */
+/* CattaInterfaceAddress */
 
-AvahiInterfaceAddress *avahi_interface_address_new(AvahiInterfaceMonitor *m, AvahiInterface *i, const AvahiAddress *addr, unsigned prefix_len);
-void avahi_interface_address_free(AvahiInterfaceAddress *a);
+CattaInterfaceAddress *catta_interface_address_new(CattaInterfaceMonitor *m, CattaInterface *i, const CattaAddress *addr, unsigned prefix_len);
+void catta_interface_address_free(CattaInterfaceAddress *a);
 
-void avahi_interface_address_update_rrs(AvahiInterfaceAddress *a, int remove_rrs);
-int avahi_interface_address_is_relevant(AvahiInterfaceAddress *a);
+void catta_interface_address_update_rrs(CattaInterfaceAddress *a, int remove_rrs);
+int catta_interface_address_is_relevant(CattaInterfaceAddress *a);
 
-AvahiInterfaceAddress* avahi_interface_monitor_get_address(AvahiInterfaceMonitor *m, AvahiInterface *i, const AvahiAddress *raddr);
+CattaInterfaceAddress* catta_interface_monitor_get_address(CattaInterfaceMonitor *m, CattaInterface *i, const CattaAddress *raddr);
 
-AvahiIfIndex avahi_find_interface_for_address(AvahiInterfaceMonitor *m, const AvahiAddress *a);
+CattaIfIndex catta_find_interface_for_address(CattaInterfaceMonitor *m, const CattaAddress *a);
 
 #endif
index d378a28b42b4728719073d089b8803d8d3b4173b..a7ee95e816ac758a6221df81c03c0270a6ccec80 100644 (file)
@@ -2,31 +2,31 @@
 #define foointernalhfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 /** A locally registered DNS resource record */
-typedef struct AvahiEntry AvahiEntry;
+typedef struct CattaEntry CattaEntry;
 
-#include <avahi/llist.h>
-#include <avahi/watch.h>
-#include <avahi/timeval.h>
-#include <avahi/core.h>
+#include <catta/llist.h>
+#include <catta/watch.h>
+#include <catta/timeval.h>
+#include <catta/core.h>
 
 #include "iface.h"
 #include "prioq.h"
@@ -40,92 +40,92 @@ typedef struct AvahiEntry AvahiEntry;
 #include "multicast-lookup.h"
 #include "dns-srv-rr.h"
 
-#define AVAHI_LEGACY_UNICAST_REFLECT_SLOTS_MAX 100
+#define CATTA_LEGACY_UNICAST_REFLECT_SLOTS_MAX 100
 
-#define AVAHI_FLAGS_VALID(flags, max) (!((flags) & ~(max)))
+#define CATTA_FLAGS_VALID(flags, max) (!((flags) & ~(max)))
 
-#define AVAHI_RR_HOLDOFF_MSEC 1000
-#define AVAHI_RR_HOLDOFF_MSEC_RATE_LIMIT 20000
-#define AVAHI_RR_RATE_LIMIT_COUNT 15
+#define CATTA_RR_HOLDOFF_MSEC 1000
+#define CATTA_RR_HOLDOFF_MSEC_RATE_LIMIT 20000
+#define CATTA_RR_RATE_LIMIT_COUNT 15
 
-typedef struct AvahiLegacyUnicastReflectSlot AvahiLegacyUnicastReflectSlot;
+typedef struct CattaLegacyUnicastReflectSlot CattaLegacyUnicastReflectSlot;
 
-struct AvahiLegacyUnicastReflectSlot {
-    AvahiServer *server;
+struct CattaLegacyUnicastReflectSlot {
+    CattaServer *server;
 
     uint16_t id, original_id;
-    AvahiAddress address;
+    CattaAddress address;
     uint16_t port;
     int interface;
     struct timeval elapse_time;
-    AvahiTimeEvent *time_event;
+    CattaTimeEvent *time_event;
 };
 
-struct AvahiEntry {
-    AvahiServer *server;
-    AvahiSEntryGroup *group;
+struct CattaEntry {
+    CattaServer *server;
+    CattaSEntryGroup *group;
 
     int dead;
 
-    AvahiPublishFlags flags;
-    AvahiRecord *record;
-    AvahiIfIndex interface;
-    AvahiProtocol protocol;
+    CattaPublishFlags flags;
+    CattaRecord *record;
+    CattaIfIndex interface;
+    CattaProtocol protocol;
 
-    AVAHI_LLIST_FIELDS(AvahiEntry, entries);
-    AVAHI_LLIST_FIELDS(AvahiEntry, by_key);
-    AVAHI_LLIST_FIELDS(AvahiEntry, by_group);
+    CATTA_LLIST_FIELDS(CattaEntry, entries);
+    CATTA_LLIST_FIELDS(CattaEntry, by_key);
+    CATTA_LLIST_FIELDS(CattaEntry, by_group);
 
-    AVAHI_LLIST_HEAD(AvahiAnnouncer, announcers);
+    CATTA_LLIST_HEAD(CattaAnnouncer, announcers);
 };
 
-struct AvahiSEntryGroup {
-    AvahiServer *server;
+struct CattaSEntryGroup {
+    CattaServer *server;
     int dead;
 
-    AvahiEntryGroupState state;
+    CattaEntryGroupState state;
     void* userdata;
-    AvahiSEntryGroupCallback callback;
+    CattaSEntryGroupCallback callback;
 
     unsigned n_probing;
 
     unsigned n_register_try;
     struct timeval register_time;
-    AvahiTimeEvent *register_time_event;
+    CattaTimeEvent *register_time_event;
 
     struct timeval established_at;
 
-    AVAHI_LLIST_FIELDS(AvahiSEntryGroup, groups);
-    AVAHI_LLIST_HEAD(AvahiEntry, entries);
+    CATTA_LLIST_FIELDS(CattaSEntryGroup, groups);
+    CATTA_LLIST_HEAD(CattaEntry, entries);
 };
 
-struct AvahiServer {
-    const AvahiPoll *poll_api;
+struct CattaServer {
+    const CattaPoll *poll_api;
 
-    AvahiInterfaceMonitor *monitor;
-    AvahiServerConfig config;
+    CattaInterfaceMonitor *monitor;
+    CattaServerConfig config;
 
-    AVAHI_LLIST_HEAD(AvahiEntry, entries);
-    AvahiHashmap *entries_by_key;
+    CATTA_LLIST_HEAD(CattaEntry, entries);
+    CattaHashmap *entries_by_key;
 
-    AVAHI_LLIST_HEAD(AvahiSEntryGroup, groups);
+    CATTA_LLIST_HEAD(CattaSEntryGroup, groups);
 
-    AVAHI_LLIST_HEAD(AvahiSRecordBrowser, record_browsers);
-    AvahiHashmap *record_browser_hashmap;
-    AVAHI_LLIST_HEAD(AvahiSHostNameResolver, host_name_resolvers);
-    AVAHI_LLIST_HEAD(AvahiSAddressResolver, address_resolvers);
-    AVAHI_LLIST_HEAD(AvahiSDomainBrowser, domain_browsers);
-    AVAHI_LLIST_HEAD(AvahiSServiceTypeBrowser, service_type_browsers);
-    AVAHI_LLIST_HEAD(AvahiSServiceBrowser, service_browsers);
-    AVAHI_LLIST_HEAD(AvahiSServiceResolver, service_resolvers);
-    AVAHI_LLIST_HEAD(AvahiSDNSServerBrowser, dns_server_browsers);
+    CATTA_LLIST_HEAD(CattaSRecordBrowser, record_browsers);
+    CattaHashmap *record_browser_hashmap;
+    CATTA_LLIST_HEAD(CattaSHostNameResolver, host_name_resolvers);
+    CATTA_LLIST_HEAD(CattaSAddressResolver, address_resolvers);
+    CATTA_LLIST_HEAD(CattaSDomainBrowser, domain_browsers);
+    CATTA_LLIST_HEAD(CattaSServiceTypeBrowser, service_type_browsers);
+    CATTA_LLIST_HEAD(CattaSServiceBrowser, service_browsers);
+    CATTA_LLIST_HEAD(CattaSServiceResolver, service_resolvers);
+    CATTA_LLIST_HEAD(CattaSDNSServerBrowser, dns_server_browsers);
 
     int need_entry_cleanup, need_group_cleanup, need_browser_cleanup;
 
     /* Used for scheduling RR cleanup */
-    AvahiTimeEvent *cleanup_time_event;
+    CattaTimeEvent *cleanup_time_event;
 
-    AvahiTimeEventQueue *time_event_queue;
+    CattaTimeEventQueue *time_event_queue;
 
     char *host_name, *host_name_fqdn, *domain_name;
 
@@ -133,22 +133,22 @@ struct AvahiServer {
         /* The following two sockets two are used for reflection only */
         fd_legacy_unicast_ipv4, fd_legacy_unicast_ipv6;
 
-    AvahiWatch *watch_ipv4, *watch_ipv6,
+    CattaWatch *watch_ipv4, *watch_ipv6,
         *watch_legacy_unicast_ipv4, *watch_legacy_unicast_ipv6;
 
-    AvahiServerState state;
-    AvahiServerCallback callback;
+    CattaServerState state;
+    CattaServerCallback callback;
     void* userdata;
 
-    AvahiSEntryGroup *hinfo_entry_group;
-    AvahiSEntryGroup *browse_domain_entry_group;
+    CattaSEntryGroup *hinfo_entry_group;
+    CattaSEntryGroup *browse_domain_entry_group;
     unsigned n_host_rr_pending;
 
     /* Used for assembling responses */
-    AvahiRecordList *record_list;
+    CattaRecordList *record_list;
 
     /* Used for reflection of legacy unicast packets */
-    AvahiLegacyUnicastReflectSlot **legacy_unicast_reflect_slots;
+    CattaLegacyUnicastReflectSlot **legacy_unicast_reflect_slots;
     uint16_t legacy_unicast_reflect_id;
 
     /* The last error code */
@@ -157,69 +157,69 @@ struct AvahiServer {
     /* The local service cookie */
     uint32_t local_service_cookie;
 
-    AvahiMulticastLookupEngine *multicast_lookup_engine;
-    AvahiWideAreaLookupEngine *wide_area_lookup_engine;
+    CattaMulticastLookupEngine *multicast_lookup_engine;
+    CattaWideAreaLookupEngine *wide_area_lookup_engine;
 };
 
-void avahi_entry_free(AvahiServer*s, AvahiEntry *e);
-void avahi_entry_group_free(AvahiServer *s, AvahiSEntryGroup *g);
+void catta_entry_free(CattaServer*s, CattaEntry *e);
+void catta_entry_group_free(CattaServer *s, CattaSEntryGroup *g);
 
-void avahi_cleanup_dead_entries(AvahiServer *s);
+void catta_cleanup_dead_entries(CattaServer *s);
 
-void avahi_server_prepare_response(AvahiServer *s, AvahiInterface *i, AvahiEntry *e, int unicast_response, int auxiliary);
-void avahi_server_prepare_matching_responses(AvahiServer *s, AvahiInterface *i, AvahiKey *k, int unicast_response);
-void avahi_server_generate_response(AvahiServer *s, AvahiInterface *i, AvahiDnsPacket *p, const AvahiAddress *a, uint16_t port, int legacy_unicast, int is_probe);
+void catta_server_prepare_response(CattaServer *s, CattaInterface *i, CattaEntry *e, int unicast_response, int auxiliary);
+void catta_server_prepare_matching_responses(CattaServer *s, CattaInterface *i, CattaKey *k, int unicast_response);
+void catta_server_generate_response(CattaServer *s, CattaInterface *i, CattaDnsPacket *p, const CattaAddress *a, uint16_t port, int legacy_unicast, int is_probe);
 
-void avahi_s_entry_group_change_state(AvahiSEntryGroup *g, AvahiEntryGroupState state);
+void catta_s_entry_group_change_state(CattaSEntryGroup *g, CattaEntryGroupState state);
 
-int avahi_entry_is_commited(AvahiEntry *e);
+int catta_entry_is_commited(CattaEntry *e);
 
-void avahi_server_enumerate_aux_records(AvahiServer *s, AvahiInterface *i, AvahiRecord *r, void (*callback)(AvahiServer *s, AvahiRecord *r, int flush_cache, void* userdata), void* userdata);
+void catta_server_enumerate_aux_records(CattaServer *s, CattaInterface *i, CattaRecord *r, void (*callback)(CattaServer *s, CattaRecord *r, int flush_cache, void* userdata), void* userdata);
 
-void avahi_host_rr_entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntryGroupState state, void *userdata);
+void catta_host_rr_entry_group_callback(CattaServer *s, CattaSEntryGroup *g, CattaEntryGroupState state, void *userdata);
 
-void avahi_server_decrease_host_rr_pending(AvahiServer *s);
+void catta_server_decrease_host_rr_pending(CattaServer *s);
 
-int avahi_server_set_errno(AvahiServer *s, int error);
+int catta_server_set_errno(CattaServer *s, int error);
 
-int avahi_server_is_service_local(AvahiServer *s, AvahiIfIndex interface, AvahiProtocol protocol, const char *name);
-int avahi_server_is_record_local(AvahiServer *s, AvahiIfIndex interface, AvahiProtocol protocol, AvahiRecord *record);
+int catta_server_is_service_local(CattaServer *s, CattaIfIndex interface, CattaProtocol protocol, const char *name);
+int catta_server_is_record_local(CattaServer *s, CattaIfIndex interface, CattaProtocol protocol, CattaRecord *record);
 
-int avahi_server_add_ptr(
-    AvahiServer *s,
-    AvahiSEntryGroup *g,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiPublishFlags flags,
+int catta_server_add_ptr(
+    CattaServer *s,
+    CattaSEntryGroup *g,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaPublishFlags flags,
     uint32_t ttl,
     const char *name,
     const char *dest);
 
-#define AVAHI_CHECK_VALIDITY(server, expression, error) { \
+#define CATTA_CHECK_VALIDITY(server, expression, error) { \
         if (!(expression)) \
-            return avahi_server_set_errno((server), (error)); \
+            return catta_server_set_errno((server), (error)); \
 }
 
-#define AVAHI_CHECK_VALIDITY_RETURN_NULL(server, expression, error) { \
+#define CATTA_CHECK_VALIDITY_RETURN_NULL(server, expression, error) { \
         if (!(expression)) { \
-            avahi_server_set_errno((server), (error)); \
+            catta_server_set_errno((server), (error)); \
             return NULL; \
         } \
 }
 
-#define AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(server, expression, error) {\
+#define CATTA_CHECK_VALIDITY_SET_RET_GOTO_FAIL(server, expression, error) {\
     if (!(expression)) { \
-        ret = avahi_server_set_errno((server), (error)); \
+        ret = catta_server_set_errno((server), (error)); \
         goto fail; \
     } \
 }
 
-#define AVAHI_ASSERT_TRUE(expression) { \
+#define CATTA_ASSERT_TRUE(expression) { \
     int __tmp = !!(expression); \
     assert(__tmp); \
 }
 
-#define AVAHI_ASSERT_SUCCESS(expression) { \
+#define CATTA_ASSERT_SUCCESS(expression) { \
     int __tmp = (expression); \
     assert(__tmp == 0); \
 }
index d159c95e1413a23098ab5ab120b3d3cd0b2cd501..076ea855423eaa222404611e5f74a5d3aa22345f 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <stdio.h>
 #include <stdarg.h>
 
-#include <avahi/log.h>
+#include <catta/log.h>
 
-static AvahiLogFunction log_function = NULL;
+static CattaLogFunction log_function = NULL;
 
-void avahi_set_log_function(AvahiLogFunction function) {
+void catta_set_log_function(CattaLogFunction function) {
     log_function = function;
 }
 
-void avahi_log_ap(AvahiLogLevel level, const char*format, va_list ap) {
+void catta_log_ap(CattaLogLevel level, const char*format, va_list ap) {
     char txt[256];
 
     vsnprintf(txt, sizeof(txt), format, ap);
@@ -43,44 +43,44 @@ void avahi_log_ap(AvahiLogLevel level, const char*format, va_list ap) {
         fprintf(stderr, "%s\n", txt);
 }
 
-void avahi_log(AvahiLogLevel level, const char*format, ...) {
+void catta_log(CattaLogLevel level, const char*format, ...) {
     va_list ap;
     va_start(ap, format);
-    avahi_log_ap(level, format, ap);
+    catta_log_ap(level, format, ap);
     va_end(ap);
 }
 
-void avahi_log_error(const char*format, ...) {
+void catta_log_error(const char*format, ...) {
     va_list ap;
     va_start(ap, format);
-    avahi_log_ap(AVAHI_LOG_ERROR, format, ap);
+    catta_log_ap(CATTA_LOG_ERROR, format, ap);
     va_end(ap);
 }
 
-void avahi_log_warn(const char*format, ...) {
+void catta_log_warn(const char*format, ...) {
     va_list ap;
     va_start(ap, format);
-    avahi_log_ap(AVAHI_LOG_WARN, format, ap);
+    catta_log_ap(CATTA_LOG_WARN, format, ap);
     va_end(ap);
 }
 
-void avahi_log_notice(const char*format, ...) {
+void catta_log_notice(const char*format, ...) {
     va_list ap;
     va_start(ap, format);
-    avahi_log_ap(AVAHI_LOG_NOTICE, format, ap);
+    catta_log_ap(CATTA_LOG_NOTICE, format, ap);
     va_end(ap);
 }
 
-void avahi_log_info(const char*format, ...) {
+void catta_log_info(const char*format, ...) {
     va_list ap;
     va_start(ap, format);
-    avahi_log_ap(AVAHI_LOG_INFO, format, ap);
+    catta_log_ap(CATTA_LOG_INFO, format, ap);
     va_end(ap);
 }
 
-void avahi_log_debug(const char*format, ...) {
+void catta_log_debug(const char*format, ...) {
     va_list ap;
     va_start(ap, format);
-    avahi_log_ap(AVAHI_LOG_DEBUG, format, ap);
+    catta_log_ap(CATTA_LOG_DEBUG, format, ap);
     va_end(ap);
 }
index bfc187c3add96331ffee74a7a500c8d561911b0b..40c96c60cd3826e866f3af77a6d60e1b97458eff 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
@@ -27,7 +27,7 @@
 #include <stdio.h>
 #include <unistd.h>
 
-#include <avahi/malloc.h>
+#include <catta/malloc.h>
 
 #ifndef va_copy
 #ifdef __va_copy
@@ -37,9 +37,9 @@
 #endif
 #endif
 
-static const AvahiAllocator *allocator = NULL;
+static const CattaAllocator *allocator = NULL;
 
-static void oom(void) AVAHI_GCC_NORETURN;
+static void oom(void) CATTA_GCC_NORETURN;
 
 static void oom(void) {
 
@@ -58,7 +58,7 @@ static void oom(void) {
     abort();
 }
 
-/* Default implementation for avahi_malloc() */
+/* Default implementation for catta_malloc() */
 static void* xmalloc(size_t size) {
     void *p;
 
@@ -71,7 +71,7 @@ static void* xmalloc(size_t size) {
     return p;
 }
 
-/* Default implementation for avahi_realloc() */
+/* Default implementation for catta_realloc() */
 static void *xrealloc(void *p, size_t size) {
 
     if (size == 0) {
@@ -85,7 +85,7 @@ static void *xrealloc(void *p, size_t size) {
     return p;
 }
 
-/* Default implementation for avahi_calloc() */
+/* Default implementation for catta_calloc() */
 static void *xcalloc(size_t nmemb, size_t size) {
     void *p;
 
@@ -98,7 +98,7 @@ static void *xcalloc(size_t nmemb, size_t size) {
     return p;
 }
 
-void *avahi_malloc(size_t size) {
+void *catta_malloc(size_t size) {
 
     if (size <= 0)
         return NULL;
@@ -110,7 +110,7 @@ void *avahi_malloc(size_t size) {
     return allocator->malloc(size);
 }
 
-void *avahi_malloc0(size_t size) {
+void *catta_malloc0(size_t size) {
     void *p;
 
     if (size <= 0)
@@ -129,7 +129,7 @@ void *avahi_malloc0(size_t size) {
     return p;
 }
 
-void avahi_free(void *p) {
+void catta_free(void *p) {
 
     if (!p)
         return;
@@ -143,10 +143,10 @@ void avahi_free(void *p) {
     allocator->free(p);
 }
 
-void *avahi_realloc(void *p, size_t size) {
+void *catta_realloc(void *p, size_t size) {
 
     if (size == 0) {
-        avahi_free(p);
+        catta_free(p);
         return NULL;
     }
 
@@ -157,7 +157,7 @@ void *avahi_realloc(void *p, size_t size) {
     return allocator->realloc(p, size);
 }
 
-char *avahi_strdup(const char *s) {
+char *catta_strdup(const char *s) {
     char *r;
     size_t size;
 
@@ -165,14 +165,14 @@ char *avahi_strdup(const char *s) {
         return NULL;
 
     size = strlen(s);
-    if (!(r = avahi_malloc(size+1)))
+    if (!(r = catta_malloc(size+1)))
         return NULL;
 
     memcpy(r, s, size+1);
     return r;
 }
 
-char *avahi_strndup(const char *s, size_t max) {
+char *catta_strndup(const char *s, size_t max) {
     char *r;
     size_t size;
     const char *p;
@@ -184,7 +184,7 @@ char *avahi_strndup(const char *s, size_t max) {
          size < max && *p;
          p++, size++);
 
-    if (!(r = avahi_new(char, size+1)))
+    if (!(r = catta_new(char, size+1)))
         return NULL;
 
     memcpy(r, s, size);
@@ -193,17 +193,17 @@ char *avahi_strndup(const char *s, size_t max) {
 }
 
 /* Change the allocator */
-void avahi_set_allocator(const AvahiAllocator *a) {
+void catta_set_allocator(const CattaAllocator *a) {
     allocator = a;
 }
 
-char *avahi_strdup_vprintf(const char *fmt, va_list ap) {
+char *catta_strdup_vprintf(const char *fmt, va_list ap) {
     size_t len = 80;
     char *buf;
 
     assert(fmt);
 
-    if (!(buf = avahi_malloc(len)))
+    if (!(buf = catta_malloc(len)))
         return NULL;
 
     for (;;) {
@@ -223,8 +223,8 @@ char *avahi_strdup_vprintf(const char *fmt, va_list ap) {
         else
             len *= 2;
 
-        if (!(nbuf = avahi_realloc(buf, len))) {
-            avahi_free(buf);
+        if (!(nbuf = catta_realloc(buf, len))) {
+            catta_free(buf);
             return NULL;
         }
 
@@ -232,24 +232,24 @@ char *avahi_strdup_vprintf(const char *fmt, va_list ap) {
     }
 }
 
-char *avahi_strdup_printf(const char *fmt, ... ) {
+char *catta_strdup_printf(const char *fmt, ... ) {
     char *s;
     va_list ap;
 
     assert(fmt);
 
     va_start(ap, fmt);
-    s = avahi_strdup_vprintf(fmt, ap);
+    s = catta_strdup_vprintf(fmt, ap);
     va_end(ap);
 
     return s;
 }
 
-void *avahi_memdup(const void *s, size_t l) {
+void *catta_memdup(const void *s, size_t l) {
     void *p;
     assert(s);
 
-    if (!(p = avahi_malloc(l)))
+    if (!(p = catta_malloc(l)))
         return NULL;
 
     memcpy(p, s, l);
index e1bca373310544275d3bb1d5948f887a2949b12a..85a13671b03c3bfbdffd71009a972ee94f2d722d 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 #include <stdlib.h>
 
-#include <avahi/malloc.h>
-#include <avahi/timeval.h>
+#include <catta/malloc.h>
+#include <catta/timeval.h>
 
 #include "internal.h"
 #include "browse.h"
 #include "socket.h"
-#include <avahi/log.h>
+#include <catta/log.h>
 #include "hashmap.h"
 #include "multicast-lookup.h"
 #include "rr-util.h"
 
-struct AvahiMulticastLookup {
-    AvahiMulticastLookupEngine *engine;
+struct CattaMulticastLookup {
+    CattaMulticastLookupEngine *engine;
     int dead;
 
-    AvahiKey *key, *cname_key;
+    CattaKey *key, *cname_key;
 
-    AvahiMulticastLookupCallback callback;
+    CattaMulticastLookupCallback callback;
     void *userdata;
 
-    AvahiIfIndex interface;
-    AvahiProtocol protocol;
+    CattaIfIndex interface;
+    CattaProtocol protocol;
 
     int queriers_added;
 
-    AvahiTimeEvent *all_for_now_event;
+    CattaTimeEvent *all_for_now_event;
 
-    AVAHI_LLIST_FIELDS(AvahiMulticastLookup, lookups);
-    AVAHI_LLIST_FIELDS(AvahiMulticastLookup, by_key);
+    CATTA_LLIST_FIELDS(CattaMulticastLookup, lookups);
+    CATTA_LLIST_FIELDS(CattaMulticastLookup, by_key);
 };
 
-struct AvahiMulticastLookupEngine {
-    AvahiServer *server;
+struct CattaMulticastLookupEngine {
+    CattaServer *server;
 
     /* Lookups */
-    AVAHI_LLIST_HEAD(AvahiMulticastLookup, lookups);
-    AvahiHashmap *lookups_by_key;
+    CATTA_LLIST_HEAD(CattaMulticastLookup, lookups);
+    CattaHashmap *lookups_by_key;
 
     int cleanup_dead;
 };
 
-static void all_for_now_callback(AvahiTimeEvent *e, void* userdata) {
-    AvahiMulticastLookup *l = userdata;
+static void all_for_now_callback(CattaTimeEvent *e, void* userdata) {
+    CattaMulticastLookup *l = userdata;
 
     assert(e);
     assert(l);
 
-    avahi_time_event_free(l->all_for_now_event);
+    catta_time_event_free(l->all_for_now_event);
     l->all_for_now_event = NULL;
 
-    l->callback(l->engine, l->interface, l->protocol, AVAHI_BROWSER_ALL_FOR_NOW, AVAHI_LOOKUP_RESULT_MULTICAST, NULL, l->userdata);
+    l->callback(l->engine, l->interface, l->protocol, CATTA_BROWSER_ALL_FOR_NOW, CATTA_LOOKUP_RESULT_MULTICAST, NULL, l->userdata);
 }
 
-AvahiMulticastLookup *avahi_multicast_lookup_new(
-    AvahiMulticastLookupEngine *e,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiKey *key,
-    AvahiMulticastLookupCallback callback,
+CattaMulticastLookup *catta_multicast_lookup_new(
+    CattaMulticastLookupEngine *e,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaKey *key,
+    CattaMulticastLookupCallback callback,
     void *userdata) {
 
-    AvahiMulticastLookup *l, *t;
+    CattaMulticastLookup *l, *t;
     struct timeval tv;
 
     assert(e);
-    assert(AVAHI_IF_VALID(interface));
-    assert(AVAHI_PROTO_VALID(protocol));
+    assert(CATTA_IF_VALID(interface));
+    assert(CATTA_PROTO_VALID(protocol));
     assert(key);
     assert(callback);
 
-    l = avahi_new(AvahiMulticastLookup, 1);
+    l = catta_new(CattaMulticastLookup, 1);
     l->engine = e;
     l->dead = 0;
-    l->key = avahi_key_ref(key);
-    l->cname_key = avahi_key_new_cname(l->key);
+    l->key = catta_key_ref(key);
+    l->cname_key = catta_key_new_cname(l->key);
     l->callback = callback;
     l->userdata = userdata;
     l->interface = interface;
@@ -105,65 +105,65 @@ AvahiMulticastLookup *avahi_multicast_lookup_new(
     l->all_for_now_event = NULL;
     l->queriers_added = 0;
 
-    t = avahi_hashmap_lookup(e->lookups_by_key, l->key);
-    AVAHI_LLIST_PREPEND(AvahiMulticastLookup, by_key, t, l);
-    avahi_hashmap_replace(e->lookups_by_key, avahi_key_ref(l->key), t);
+    t = catta_hashmap_lookup(e->lookups_by_key, l->key);
+    CATTA_LLIST_PREPEND(CattaMulticastLookup, by_key, t, l);
+    catta_hashmap_replace(e->lookups_by_key, catta_key_ref(l->key), t);
 
-    AVAHI_LLIST_PREPEND(AvahiMulticastLookup, lookups, e->lookups, l);
+    CATTA_LLIST_PREPEND(CattaMulticastLookup, lookups, e->lookups, l);
 
-    avahi_querier_add_for_all(e->server, interface, protocol, l->key, &tv);
+    catta_querier_add_for_all(e->server, interface, protocol, l->key, &tv);
     l->queriers_added = 1;
 
     /* Add a second */
-    avahi_timeval_add(&tv, 1000000);
+    catta_timeval_add(&tv, 1000000);
 
     /* Issue the ALL_FOR_NOW event one second after the querier was initially created */
-    l->all_for_now_event = avahi_time_event_new(e->server->time_event_queue, &tv, all_for_now_callback, l);
+    l->all_for_now_event = catta_time_event_new(e->server->time_event_queue, &tv, all_for_now_callback, l);
 
     return l;
 }
 
-static void lookup_stop(AvahiMulticastLookup *l) {
+static void lookup_stop(CattaMulticastLookup *l) {
     assert(l);
 
     l->callback = NULL;
 
     if (l->queriers_added) {
-        avahi_querier_remove_for_all(l->engine->server, l->interface, l->protocol, l->key);
+        catta_querier_remove_for_all(l->engine->server, l->interface, l->protocol, l->key);
         l->queriers_added = 0;
     }
 
     if (l->all_for_now_event) {
-        avahi_time_event_free(l->all_for_now_event);
+        catta_time_event_free(l->all_for_now_event);
         l->all_for_now_event = NULL;
     }
 }
 
-static void lookup_destroy(AvahiMulticastLookup *l) {
-    AvahiMulticastLookup *t;
+static void lookup_destroy(CattaMulticastLookup *l) {
+    CattaMulticastLookup *t;
     assert(l);
 
     lookup_stop(l);
 
-    t = avahi_hashmap_lookup(l->engine->lookups_by_key, l->key);
-    AVAHI_LLIST_REMOVE(AvahiMulticastLookup, by_key, t, l);
+    t = catta_hashmap_lookup(l->engine->lookups_by_key, l->key);
+    CATTA_LLIST_REMOVE(CattaMulticastLookup, by_key, t, l);
     if (t)
-        avahi_hashmap_replace(l->engine->lookups_by_key, avahi_key_ref(l->key), t);
+        catta_hashmap_replace(l->engine->lookups_by_key, catta_key_ref(l->key), t);
     else
-        avahi_hashmap_remove(l->engine->lookups_by_key, l->key);
+        catta_hashmap_remove(l->engine->lookups_by_key, l->key);
 
-    AVAHI_LLIST_REMOVE(AvahiMulticastLookup, lookups, l->engine->lookups, l);
+    CATTA_LLIST_REMOVE(CattaMulticastLookup, lookups, l->engine->lookups, l);
 
     if (l->key)
-        avahi_key_unref(l->key);
+        catta_key_unref(l->key);
 
     if (l->cname_key)
-        avahi_key_unref(l->cname_key);
+        catta_key_unref(l->cname_key);
 
-    avahi_free(l);
+    catta_free(l);
 }
 
-void avahi_multicast_lookup_free(AvahiMulticastLookup *l) {
+void catta_multicast_lookup_free(CattaMulticastLookup *l) {
     assert(l);
 
     if (l->dead)
@@ -174,8 +174,8 @@ void avahi_multicast_lookup_free(AvahiMulticastLookup *l) {
     lookup_stop(l);
 }
 
-void avahi_multicast_lookup_engine_cleanup(AvahiMulticastLookupEngine *e) {
-    AvahiMulticastLookup *l, *n;
+void catta_multicast_lookup_engine_cleanup(CattaMulticastLookupEngine *e) {
+    CattaMulticastLookup *l, *n;
     assert(e);
 
     while (e->cleanup_dead) {
@@ -191,15 +191,15 @@ void avahi_multicast_lookup_engine_cleanup(AvahiMulticastLookupEngine *e) {
 }
 
 struct cbdata {
-    AvahiMulticastLookupEngine *engine;
-    AvahiMulticastLookupCallback callback;
+    CattaMulticastLookupEngine *engine;
+    CattaMulticastLookupCallback callback;
     void *userdata;
-    AvahiKey *key, *cname_key;
-    AvahiInterface *interface;
+    CattaKey *key, *cname_key;
+    CattaInterface *interface;
     unsigned n_found;
 };
 
-static void* scan_cache_callback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEntry *e, void* userdata) {
+static void* scan_cache_callback(CattaCache *c, CattaKey *pattern, CattaCacheEntry *e, void* userdata) {
     struct cbdata *cbdata = userdata;
 
     assert(c);
@@ -211,8 +211,8 @@ static void* scan_cache_callback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEnt
         cbdata->engine,
         cbdata->interface->hardware->index,
         cbdata->interface->protocol,
-        AVAHI_BROWSER_NEW,
-        AVAHI_LOOKUP_RESULT_CACHED|AVAHI_LOOKUP_RESULT_MULTICAST,
+        CATTA_BROWSER_NEW,
+        CATTA_LOOKUP_RESULT_CACHED|CATTA_LOOKUP_RESULT_MULTICAST,
         e->record,
         cbdata->userdata);
 
@@ -221,7 +221,7 @@ static void* scan_cache_callback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEnt
     return NULL;
 }
 
-static void scan_interface_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata) {
+static void scan_interface_callback(CattaInterfaceMonitor *m, CattaInterface *i, void* userdata) {
     struct cbdata *cbdata = userdata;
 
     assert(m);
@@ -230,20 +230,20 @@ static void scan_interface_callback(AvahiInterfaceMonitor *m, AvahiInterface *i,
 
     cbdata->interface = i;
 
-    avahi_cache_walk(i->cache, cbdata->key, scan_cache_callback, cbdata);
+    catta_cache_walk(i->cache, cbdata->key, scan_cache_callback, cbdata);
 
     if (cbdata->cname_key)
-        avahi_cache_walk(i->cache, cbdata->cname_key, scan_cache_callback, cbdata);
+        catta_cache_walk(i->cache, cbdata->cname_key, scan_cache_callback, cbdata);
 
     cbdata->interface = NULL;
 }
 
-unsigned avahi_multicast_lookup_engine_scan_cache(
-    AvahiMulticastLookupEngine *e,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiKey *key,
-    AvahiMulticastLookupCallback callback,
+unsigned catta_multicast_lookup_engine_scan_cache(
+    CattaMulticastLookupEngine *e,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaKey *key,
+    CattaMulticastLookupCallback callback,
     void *userdata) {
 
     struct cbdata cbdata;
@@ -252,27 +252,27 @@ unsigned avahi_multicast_lookup_engine_scan_cache(
     assert(key);
     assert(callback);
 
-    assert(AVAHI_IF_VALID(interface));
-    assert(AVAHI_PROTO_VALID(protocol));
+    assert(CATTA_IF_VALID(interface));
+    assert(CATTA_PROTO_VALID(protocol));
 
     cbdata.engine = e;
     cbdata.key = key;
-    cbdata.cname_key = avahi_key_new_cname(key);
+    cbdata.cname_key = catta_key_new_cname(key);
     cbdata.callback = callback;
     cbdata.userdata = userdata;
     cbdata.interface = NULL;
     cbdata.n_found = 0;
 
-    avahi_interface_monitor_walk(e->server->monitor, interface, protocol, scan_interface_callback, &cbdata);
+    catta_interface_monitor_walk(e->server->monitor, interface, protocol, scan_interface_callback, &cbdata);
 
     if (cbdata.cname_key)
-        avahi_key_unref(cbdata.cname_key);
+        catta_key_unref(cbdata.cname_key);
 
     return cbdata.n_found;
 }
 
-void avahi_multicast_lookup_engine_new_interface(AvahiMulticastLookupEngine *e, AvahiInterface *i) {
-    AvahiMulticastLookup *l;
+void catta_multicast_lookup_engine_new_interface(CattaMulticastLookupEngine *e, CattaInterface *i) {
+    CattaMulticastLookup *l;
 
     assert(e);
     assert(i);
@@ -282,69 +282,69 @@ void avahi_multicast_lookup_engine_new_interface(AvahiMulticastLookupEngine *e,
         if (l->dead || !l->callback)
             continue;
 
-        if (l->queriers_added && avahi_interface_match(i, l->interface, l->protocol))
-            avahi_querier_add(i, l->key, NULL);
+        if (l->queriers_added && catta_interface_match(i, l->interface, l->protocol))
+            catta_querier_add(i, l->key, NULL);
     }
 }
 
-void avahi_multicast_lookup_engine_notify(AvahiMulticastLookupEngine *e, AvahiInterface *i, AvahiRecord *record, AvahiBrowserEvent event) {
-    AvahiMulticastLookup *l;
+void catta_multicast_lookup_engine_notify(CattaMulticastLookupEngine *e, CattaInterface *i, CattaRecord *record, CattaBrowserEvent event) {
+    CattaMulticastLookup *l;
 
     assert(e);
     assert(record);
     assert(i);
 
-    for (l = avahi_hashmap_lookup(e->lookups_by_key, record->key); l; l = l->by_key_next) {
+    for (l = catta_hashmap_lookup(e->lookups_by_key, record->key); l; l = l->by_key_next) {
         if (l->dead || !l->callback)
             continue;
 
-        if (avahi_interface_match(i, l->interface, l->protocol))
-            l->callback(e, i->hardware->index, i->protocol, event, AVAHI_LOOKUP_RESULT_MULTICAST, record, l->userdata);
+        if (catta_interface_match(i, l->interface, l->protocol))
+            l->callback(e, i->hardware->index, i->protocol, event, CATTA_LOOKUP_RESULT_MULTICAST, record, l->userdata);
     }
 
 
-    if (record->key->clazz == AVAHI_DNS_CLASS_IN && record->key->type == AVAHI_DNS_TYPE_CNAME) {
+    if (record->key->clazz == CATTA_DNS_CLASS_IN && record->key->type == CATTA_DNS_TYPE_CNAME) {
         /* It's a CNAME record, so we have to scan the all lookups to see if one matches */
 
         for (l = e->lookups; l; l = l->lookups_next) {
-            AvahiKey *key;
+            CattaKey *key;
 
             if (l->dead || !l->callback)
                 continue;
 
-            if ((key = avahi_key_new_cname(l->key))) {
-                if (avahi_key_equal(record->key, key))
-                    l->callback(e, i->hardware->index, i->protocol, event, AVAHI_LOOKUP_RESULT_MULTICAST, record, l->userdata);
+            if ((key = catta_key_new_cname(l->key))) {
+                if (catta_key_equal(record->key, key))
+                    l->callback(e, i->hardware->index, i->protocol, event, CATTA_LOOKUP_RESULT_MULTICAST, record, l->userdata);
 
-                avahi_key_unref(key);
+                catta_key_unref(key);
             }
         }
     }
 }
 
-AvahiMulticastLookupEngine *avahi_multicast_lookup_engine_new(AvahiServer *s) {
-    AvahiMulticastLookupEngine *e;
+CattaMulticastLookupEngine *catta_multicast_lookup_engine_new(CattaServer *s) {
+    CattaMulticastLookupEngine *e;
 
     assert(s);
 
-    e = avahi_new(AvahiMulticastLookupEngine, 1);
+    e = catta_new(CattaMulticastLookupEngine, 1);
     e->server = s;
     e->cleanup_dead = 0;
 
     /* Initialize lookup list */
-    e->lookups_by_key = avahi_hashmap_new((AvahiHashFunc) avahi_key_hash, (AvahiEqualFunc) avahi_key_equal, (AvahiFreeFunc) avahi_key_unref, NULL);
-    AVAHI_LLIST_HEAD_INIT(AvahiWideAreaLookup, e->lookups);
+    e->lookups_by_key = catta_hashmap_new((CattaHashFunc) catta_key_hash, (CattaEqualFunc) catta_key_equal, (CattaFreeFunc) catta_key_unref, NULL);
+    CATTA_LLIST_HEAD_INIT(CattaWideAreaLookup, e->lookups);
 
     return e;
 }
 
-void avahi_multicast_lookup_engine_free(AvahiMulticastLookupEngine *e) {
+void catta_multicast_lookup_engine_free(CattaMulticastLookupEngine *e) {
     assert(e);
 
     while (e->lookups)
         lookup_destroy(e->lookups);
 
-    avahi_hashmap_free(e->lookups_by_key);
-    avahi_free(e);
+    catta_hashmap_free(e->lookups_by_key);
+    catta_free(e);
 }
 
index b7039b16504a79471744bc77b2704f181343cefa..549f68342e8e346e06a7edc681edee9fd55a7b16 100644 (file)
@@ -2,49 +2,49 @@
 #define foomulticastlookuphfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
-#include <avahi/lookup.h>
+#include <catta/lookup.h>
 #include "browse.h"
 
-typedef struct AvahiMulticastLookupEngine AvahiMulticastLookupEngine;
-typedef struct AvahiMulticastLookup AvahiMulticastLookup;
+typedef struct CattaMulticastLookupEngine CattaMulticastLookupEngine;
+typedef struct CattaMulticastLookup CattaMulticastLookup;
 
-typedef void (*AvahiMulticastLookupCallback)(
-    AvahiMulticastLookupEngine *e,
-    AvahiIfIndex idx,
-    AvahiProtocol protocol,
-    AvahiBrowserEvent event,
-    AvahiLookupResultFlags flags,
-    AvahiRecord *r,
+typedef void (*CattaMulticastLookupCallback)(
+    CattaMulticastLookupEngine *e,
+    CattaIfIndex idx,
+    CattaProtocol protocol,
+    CattaBrowserEvent event,
+    CattaLookupResultFlags flags,
+    CattaRecord *r,
     void *userdata);
 
-AvahiMulticastLookupEngine *avahi_multicast_lookup_engine_new(AvahiServer *s);
-void avahi_multicast_lookup_engine_free(AvahiMulticastLookupEngine *e);
+CattaMulticastLookupEngine *catta_multicast_lookup_engine_new(CattaServer *s);
+void catta_multicast_lookup_engine_free(CattaMulticastLookupEngine *e);
 
-unsigned avahi_multicast_lookup_engine_scan_cache(AvahiMulticastLookupEngine *e, AvahiIfIndex idx, AvahiProtocol protocol, AvahiKey *key, AvahiMulticastLookupCallback callback, void *userdata);
-void avahi_multicast_lookup_engine_new_interface(AvahiMulticastLookupEngine *e, AvahiInterface *i);
-void avahi_multicast_lookup_engine_cleanup(AvahiMulticastLookupEngine *e);
-void avahi_multicast_lookup_engine_notify(AvahiMulticastLookupEngine *e, AvahiInterface *i, AvahiRecord *record, AvahiBrowserEvent event);
+unsigned catta_multicast_lookup_engine_scan_cache(CattaMulticastLookupEngine *e, CattaIfIndex idx, CattaProtocol protocol, CattaKey *key, CattaMulticastLookupCallback callback, void *userdata);
+void catta_multicast_lookup_engine_new_interface(CattaMulticastLookupEngine *e, CattaInterface *i);
+void catta_multicast_lookup_engine_cleanup(CattaMulticastLookupEngine *e);
+void catta_multicast_lookup_engine_notify(CattaMulticastLookupEngine *e, CattaInterface *i, CattaRecord *record, CattaBrowserEvent event);
 
-AvahiMulticastLookup *avahi_multicast_lookup_new(AvahiMulticastLookupEngine *e, AvahiIfIndex idx, AvahiProtocol protocol, AvahiKey *key, AvahiMulticastLookupCallback callback, void *userdata);
-void avahi_multicast_lookup_free(AvahiMulticastLookup *q);
+CattaMulticastLookup *catta_multicast_lookup_new(CattaMulticastLookupEngine *e, CattaIfIndex idx, CattaProtocol protocol, CattaKey *key, CattaMulticastLookupCallback callback, void *userdata);
+void catta_multicast_lookup_free(CattaMulticastLookup *q);
 
 
 #endif
index e2f0cebdab61e1a945bc7a18fd9b384337bcbf3b..91df6723bd0d7ecb113c8effbe7afc15c11893a9 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <sys/ioctl.h>
 #include <assert.h>
 
-#include <avahi/malloc.h>
+#include <catta/malloc.h>
 #include "netlink.h"
-#include <avahi/log.h>
+#include <catta/log.h>
 
-struct AvahiNetlink {
+struct CattaNetlink {
     int fd;
     unsigned seq;
-    AvahiNetlinkCallback callback;
+    CattaNetlinkCallback callback;
     void* userdata;
     uint8_t* buffer;
     size_t buffer_length;
 
-    const AvahiPoll *poll_api;
-    AvahiWatch *watch;
+    const CattaPoll *poll_api;
+    CattaWatch *watch;
 };
 
-int avahi_netlink_work(AvahiNetlink *nl, int block) {
+int catta_netlink_work(CattaNetlink *nl, int block) {
     ssize_t bytes;
     struct msghdr smsg;
     struct cmsghdr *cmsg;
@@ -69,14 +69,14 @@ int avahi_netlink_work(AvahiNetlink *nl, int block) {
         if (errno == EAGAIN || errno == EINTR)
             return 0;
 
-        avahi_log_error(__FILE__": recvmsg() failed: %s", strerror(errno));
+        catta_log_error(__FILE__": recvmsg() failed: %s", strerror(errno));
         return -1;
     }
 
     cmsg = CMSG_FIRSTHDR(&smsg);
 
     if (!cmsg || cmsg->cmsg_type != SCM_CREDENTIALS) {
-        avahi_log_warn("No sender credentials received, ignoring data.");
+        catta_log_warn("No sender credentials received, ignoring data.");
         return -1;
     }
 
@@ -91,7 +91,7 @@ int avahi_netlink_work(AvahiNetlink *nl, int block) {
 
     for (; bytes > 0; p = NLMSG_NEXT(p, bytes)) {
         if (!NLMSG_OK(p, (size_t) bytes)) {
-            avahi_log_warn(__FILE__": packet truncated");
+            catta_log_warn(__FILE__": packet truncated");
             return -1;
         }
 
@@ -101,47 +101,47 @@ int avahi_netlink_work(AvahiNetlink *nl, int block) {
     return 0;
 }
 
-static void socket_event(AvahiWatch *w, int fd, AVAHI_GCC_UNUSED AvahiWatchEvent event, void *userdata) {
-    AvahiNetlink *nl = userdata;
+static void socket_event(CattaWatch *w, int fd, CATTA_GCC_UNUSED CattaWatchEvent event, void *userdata) {
+    CattaNetlink *nl = userdata;
 
     assert(w);
     assert(nl);
     assert(fd == nl->fd);
 
-    avahi_netlink_work(nl, 0);
+    catta_netlink_work(nl, 0);
 }
 
-AvahiNetlink *avahi_netlink_new(const AvahiPoll *poll_api, uint32_t groups, void (*cb) (AvahiNetlink *nl, struct nlmsghdr *n, void* userdata), void* userdata) {
+CattaNetlink *catta_netlink_new(const CattaPoll *poll_api, uint32_t groups, void (*cb) (CattaNetlink *nl, struct nlmsghdr *n, void* userdata), void* userdata) {
     int fd = -1;
     const int on = 1;
     struct sockaddr_nl addr;
-    AvahiNetlink *nl = NULL;
+    CattaNetlink *nl = NULL;
 
     assert(poll_api);
     assert(cb);
 
     if ((fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE)) < 0) {
-        avahi_log_error(__FILE__": socket(PF_NETLINK): %s", strerror(errno));
+        catta_log_error(__FILE__": socket(PF_NETLINK): %s", strerror(errno));
         return NULL;
     }
 
     memset(&addr, 0, sizeof(addr));
     addr.nl_family = AF_NETLINK;
     addr.nl_groups = groups;
-    addr.nl_pid = 0; // use 0 instead of getpid() to allow multiple instances of avahi in one process
+    addr.nl_pid = 0; // use 0 instead of getpid() to allow multiple instances of catta in one process
 
     if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
-        avahi_log_error(__FILE__": bind(): %s", strerror(errno));
+        catta_log_error(__FILE__": bind(): %s", strerror(errno));
         goto fail;
     }
 
     if (setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)) < 0) {
-        avahi_log_error(__FILE__": SO_PASSCRED: %s", strerror(errno));
+        catta_log_error(__FILE__": SO_PASSCRED: %s", strerror(errno));
         goto fail;
     }
 
-    if (!(nl = avahi_new(AvahiNetlink, 1))) {
-        avahi_log_error(__FILE__": avahi_new() failed.");
+    if (!(nl = catta_new(CattaNetlink, 1))) {
+        catta_log_error(__FILE__": catta_new() failed.");
         goto fail;
     }
 
@@ -151,13 +151,13 @@ AvahiNetlink *avahi_netlink_new(const AvahiPoll *poll_api, uint32_t groups, void
     nl->callback = cb;
     nl->userdata = userdata;
 
-    if (!(nl->buffer = avahi_new(uint8_t, nl->buffer_length = 64*1024))) {
-        avahi_log_error(__FILE__": avahi_new() failed.");
+    if (!(nl->buffer = catta_new(uint8_t, nl->buffer_length = 64*1024))) {
+        catta_log_error(__FILE__": catta_new() failed.");
         goto fail;
     }
 
-    if (!(nl->watch = poll_api->watch_new(poll_api, fd, AVAHI_WATCH_IN, socket_event, nl))) {
-        avahi_log_error(__FILE__": Failed to create watch.");
+    if (!(nl->watch = poll_api->watch_new(poll_api, fd, CATTA_WATCH_IN, socket_event, nl))) {
+        catta_log_error(__FILE__": Failed to create watch.");
         goto fail;
     }
 
@@ -169,14 +169,14 @@ fail:
         close(fd);
 
     if (nl) {
-        avahi_free(nl->buffer);
-        avahi_free(nl);
+        catta_free(nl->buffer);
+        catta_free(nl);
     }
 
     return NULL;
 }
 
-void avahi_netlink_free(AvahiNetlink *nl) {
+void catta_netlink_free(CattaNetlink *nl) {
     assert(nl);
 
     if (nl->watch)
@@ -185,11 +185,11 @@ void avahi_netlink_free(AvahiNetlink *nl) {
     if (nl->fd >= 0)
         close(nl->fd);
 
-    avahi_free(nl->buffer);
-    avahi_free(nl);
+    catta_free(nl->buffer);
+    catta_free(nl);
 }
 
-int avahi_netlink_send(AvahiNetlink *nl, struct nlmsghdr *m, unsigned *ret_seq) {
+int catta_netlink_send(CattaNetlink *nl, struct nlmsghdr *m, unsigned *ret_seq) {
     assert(nl);
     assert(m);
 
@@ -197,7 +197,7 @@ int avahi_netlink_send(AvahiNetlink *nl, struct nlmsghdr *m, unsigned *ret_seq)
     m->nlmsg_flags |= NLM_F_ACK;
 
     if (send(nl->fd, m, m->nlmsg_len, 0) < 0) {
-        avahi_log_error(__FILE__": send(): %s", strerror(errno));
+        catta_log_error(__FILE__": send(): %s", strerror(errno));
         return -1;
     }
 
index b11e0a4624b9aebaa1d172e0f18672cfefe6a3d7..1dff454a8814f6b4d07eacfd8d4e97c589bcc9ed 100644 (file)
@@ -2,20 +2,20 @@
 #define foonetlinkhfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <linux/netlink.h>
 #include <linux/rtnetlink.h>
 
-#include <avahi/watch.h>
+#include <catta/watch.h>
 
-typedef struct AvahiNetlink AvahiNetlink;
+typedef struct CattaNetlink CattaNetlink;
 
-typedef void (*AvahiNetlinkCallback)(AvahiNetlink *n, struct nlmsghdr *m, void* userdata);
+typedef void (*CattaNetlinkCallback)(CattaNetlink *n, struct nlmsghdr *m, void* userdata);
 
-AvahiNetlink *avahi_netlink_new(const AvahiPoll *poll_api, uint32_t groups, AvahiNetlinkCallback callback, void* userdata);
-void avahi_netlink_free(AvahiNetlink *n);
-int avahi_netlink_send(AvahiNetlink *n, struct nlmsghdr *m, unsigned *ret_seq);
-int avahi_netlink_work(AvahiNetlink *n, int block);
+CattaNetlink *catta_netlink_new(const CattaPoll *poll_api, uint32_t groups, CattaNetlinkCallback callback, void* userdata);
+void catta_netlink_free(CattaNetlink *n);
+int catta_netlink_send(CattaNetlink *n, struct nlmsghdr *m, unsigned *ret_seq);
+int catta_netlink_work(CattaNetlink *n, int block);
 
 #endif
index e4558eedd6e336d49f15bfc75e7ff44639f7c889..40f7ffc9f0ae9527a73a3c1b62ec20b2f02411fd 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <assert.h>
 #include <stdlib.h>
 
-#include <avahi/malloc.h>
+#include <catta/malloc.h>
 
 #include "prioq.h"
 
-AvahiPrioQueue* avahi_prio_queue_new(AvahiPQCompareFunc compare) {
-    AvahiPrioQueue *q;
+CattaPrioQueue* catta_prio_queue_new(CattaPQCompareFunc compare) {
+    CattaPrioQueue *q;
     assert(compare);
 
-    if (!(q = avahi_new(AvahiPrioQueue, 1)))
+    if (!(q = catta_new(CattaPrioQueue, 1)))
         return NULL; /* OOM */
 
     q->root = q->last = NULL;
@@ -42,19 +42,19 @@ AvahiPrioQueue* avahi_prio_queue_new(AvahiPQCompareFunc compare) {
     return q;
 }
 
-void avahi_prio_queue_free(AvahiPrioQueue *q) {
+void catta_prio_queue_free(CattaPrioQueue *q) {
     assert(q);
 
     while (q->last)
-        avahi_prio_queue_remove(q, q->last);
+        catta_prio_queue_remove(q, q->last);
 
     assert(!q->n_nodes);
-    avahi_free(q);
+    catta_free(q);
 }
 
-static AvahiPrioQueueNode* get_node_at_xy(AvahiPrioQueue *q, unsigned x, unsigned y) {
+static CattaPrioQueueNode* get_node_at_xy(CattaPrioQueue *q, unsigned x, unsigned y) {
     unsigned r;
-    AvahiPrioQueueNode *n;
+    CattaPrioQueueNode *n;
     assert(q);
 
     n = q->root;
@@ -75,8 +75,8 @@ static AvahiPrioQueueNode* get_node_at_xy(AvahiPrioQueue *q, unsigned x, unsigne
     return n;
 }
 
-static void exchange_nodes(AvahiPrioQueue *q, AvahiPrioQueueNode *a, AvahiPrioQueueNode *b) {
-    AvahiPrioQueueNode *l, *r, *p, *ap, *an, *bp, *bn;
+static void exchange_nodes(CattaPrioQueue *q, CattaPrioQueueNode *a, CattaPrioQueueNode *b) {
+    CattaPrioQueueNode *l, *r, *p, *ap, *an, *bp, *bn;
     unsigned t;
     assert(q);
     assert(a);
@@ -159,7 +159,7 @@ static void exchange_nodes(AvahiPrioQueue *q, AvahiPrioQueueNode *a, AvahiPrioQu
                 b->left->parent = b;
         }
     } else {
-        AvahiPrioQueueNode *apl = NULL, *bpl = NULL;
+        CattaPrioQueueNode *apl = NULL, *bpl = NULL;
 
         /* Swap parents */
         ap = a->parent;
@@ -255,7 +255,7 @@ static void exchange_nodes(AvahiPrioQueue *q, AvahiPrioQueueNode *a, AvahiPrioQu
 }
 
 /* Move a node to the correct position */
-void avahi_prio_queue_shuffle(AvahiPrioQueue *q, AvahiPrioQueueNode *n) {
+void catta_prio_queue_shuffle(CattaPrioQueue *q, CattaPrioQueueNode *n) {
     assert(q);
     assert(n);
     assert(n->queue == q);
@@ -266,7 +266,7 @@ void avahi_prio_queue_shuffle(AvahiPrioQueue *q, AvahiPrioQueueNode *n) {
 
     /* Move down until the position is OK */
     for (;;) {
-        AvahiPrioQueueNode *min;
+        CattaPrioQueueNode *min;
 
         if (!(min = n->left)) {
             /* No children */
@@ -287,11 +287,11 @@ void avahi_prio_queue_shuffle(AvahiPrioQueue *q, AvahiPrioQueueNode *n) {
     }
 }
 
-AvahiPrioQueueNode* avahi_prio_queue_put(AvahiPrioQueue *q, void* data) {
-    AvahiPrioQueueNode *n;
+CattaPrioQueueNode* catta_prio_queue_put(CattaPrioQueue *q, void* data) {
+    CattaPrioQueueNode *n;
     assert(q);
 
-    if (!(n = avahi_new(AvahiPrioQueueNode, 1)))
+    if (!(n = catta_new(CattaPrioQueueNode, 1)))
         return NULL; /* OOM */
 
     n->queue = q;
@@ -332,21 +332,21 @@ AvahiPrioQueueNode* avahi_prio_queue_put(AvahiPrioQueue *q, void* data) {
     q->last = n;
     q->n_nodes++;
 
-    avahi_prio_queue_shuffle(q, n);
+    catta_prio_queue_shuffle(q, n);
 
     return n;
 }
 
-void avahi_prio_queue_remove(AvahiPrioQueue *q, AvahiPrioQueueNode *n) {
+void catta_prio_queue_remove(CattaPrioQueue *q, CattaPrioQueueNode *n) {
     assert(q);
     assert(n);
     assert(q == n->queue);
 
     if (n != q->last) {
-        AvahiPrioQueueNode *replacement = q->last;
+        CattaPrioQueueNode *replacement = q->last;
         exchange_nodes(q, replacement, n);
-        avahi_prio_queue_remove(q, n);
-        avahi_prio_queue_shuffle(q, replacement);
+        catta_prio_queue_remove(q, n);
+        catta_prio_queue_shuffle(q, replacement);
         return;
     }
 
@@ -380,7 +380,7 @@ void avahi_prio_queue_remove(AvahiPrioQueue *q, AvahiPrioQueueNode *n) {
         q->root = NULL;
     }
 
-    avahi_free(n);
+    catta_free(n);
 
     assert(q->n_nodes > 0);
     q->n_nodes--;
index b3d31eb58b7316030664e3988e68c895f1c202fb..33f411a943789d4d8bd1d09b8840fa1c04865c48 100644 (file)
@@ -2,48 +2,48 @@
 #define fooprioqhfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
-typedef struct AvahiPrioQueue AvahiPrioQueue;
-typedef struct AvahiPrioQueueNode AvahiPrioQueueNode;
+typedef struct CattaPrioQueue CattaPrioQueue;
+typedef struct CattaPrioQueueNode CattaPrioQueueNode;
 
-typedef int (*AvahiPQCompareFunc)(const void* a, const void* b);
+typedef int (*CattaPQCompareFunc)(const void* a, const void* b);
 
-struct AvahiPrioQueue {
-    AvahiPrioQueueNode *root, *last;
+struct CattaPrioQueue {
+    CattaPrioQueueNode *root, *last;
     unsigned n_nodes;
-    AvahiPQCompareFunc compare;
+    CattaPQCompareFunc compare;
 };
 
-struct AvahiPrioQueueNode {
-    AvahiPrioQueue *queue;
+struct CattaPrioQueueNode {
+    CattaPrioQueue *queue;
     void* data;
     unsigned x, y;
-    AvahiPrioQueueNode *left, *right, *parent, *next, *prev;
+    CattaPrioQueueNode *left, *right, *parent, *next, *prev;
 };
 
-AvahiPrioQueue* avahi_prio_queue_new(AvahiPQCompareFunc compare);
-void avahi_prio_queue_free(AvahiPrioQueue *q);
+CattaPrioQueue* catta_prio_queue_new(CattaPQCompareFunc compare);
+void catta_prio_queue_free(CattaPrioQueue *q);
 
-AvahiPrioQueueNode* avahi_prio_queue_put(AvahiPrioQueue *q, void* data);
-void avahi_prio_queue_remove(AvahiPrioQueue *q, AvahiPrioQueueNode *n);
+CattaPrioQueueNode* catta_prio_queue_put(CattaPrioQueue *q, void* data);
+void catta_prio_queue_remove(CattaPrioQueue *q, CattaPrioQueueNode *n);
 
-void avahi_prio_queue_shuffle(AvahiPrioQueue *q, AvahiPrioQueueNode *n);
+void catta_prio_queue_shuffle(CattaPrioQueue *q, CattaPrioQueueNode *n);
 
 #endif
index a93b3695f14e96a984e338a197a11c1aa3c4c551..f59229a66dfbb378b58d0cc3f47644200542ee50 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 #include <stdlib.h>
 
-#include <avahi/domain.h>
-#include <avahi/timeval.h>
-#include <avahi/malloc.h>
+#include <catta/domain.h>
+#include <catta/timeval.h>
+#include <catta/malloc.h>
 
 #include "probe-sched.h"
-#include <avahi/log.h>
+#include <catta/log.h>
 #include "rr-util.h"
 
-#define AVAHI_PROBE_HISTORY_MSEC 150
-#define AVAHI_PROBE_DEFER_MSEC 50
+#define CATTA_PROBE_HISTORY_MSEC 150
+#define CATTA_PROBE_DEFER_MSEC 50
 
-typedef struct AvahiProbeJob AvahiProbeJob;
+typedef struct CattaProbeJob CattaProbeJob;
 
-struct AvahiProbeJob {
-    AvahiProbeScheduler *scheduler;
-    AvahiTimeEvent *time_event;
+struct CattaProbeJob {
+    CattaProbeScheduler *scheduler;
+    CattaTimeEvent *time_event;
 
     int chosen; /* Use for packet assembling */
     int done;
     struct timeval delivery;
 
-    AvahiRecord *record;
+    CattaRecord *record;
 
-    AVAHI_LLIST_FIELDS(AvahiProbeJob, jobs);
+    CATTA_LLIST_FIELDS(CattaProbeJob, jobs);
 };
 
-struct AvahiProbeScheduler {
-    AvahiInterface *interface;
-    AvahiTimeEventQueue *time_event_queue;
+struct CattaProbeScheduler {
+    CattaInterface *interface;
+    CattaTimeEventQueue *time_event_queue;
 
-    AVAHI_LLIST_HEAD(AvahiProbeJob, jobs);
-    AVAHI_LLIST_HEAD(AvahiProbeJob, history);
+    CATTA_LLIST_HEAD(CattaProbeJob, jobs);
+    CATTA_LLIST_HEAD(CattaProbeJob, history);
 };
 
-static AvahiProbeJob* job_new(AvahiProbeScheduler *s, AvahiRecord *record, int done) {
-    AvahiProbeJob *pj;
+static CattaProbeJob* job_new(CattaProbeScheduler *s, CattaRecord *record, int done) {
+    CattaProbeJob *pj;
 
     assert(s);
     assert(record);
 
-    if (!(pj = avahi_new(AvahiProbeJob, 1))) {
-        avahi_log_error(__FILE__": Out of memory");
+    if (!(pj = catta_new(CattaProbeJob, 1))) {
+        catta_log_error(__FILE__": Out of memory");
         return NULL; /* OOM */
     }
 
     pj->scheduler = s;
-    pj->record = avahi_record_ref(record);
+    pj->record = catta_record_ref(record);
     pj->time_event = NULL;
     pj->chosen = 0;
 
     if ((pj->done = done))
-        AVAHI_LLIST_PREPEND(AvahiProbeJob, jobs, s->history, pj);
+        CATTA_LLIST_PREPEND(CattaProbeJob, jobs, s->history, pj);
     else
-        AVAHI_LLIST_PREPEND(AvahiProbeJob, jobs, s->jobs, pj);
+        CATTA_LLIST_PREPEND(CattaProbeJob, jobs, s->jobs, pj);
 
     return pj;
 }
 
-static void job_free(AvahiProbeScheduler *s, AvahiProbeJob *pj) {
+static void job_free(CattaProbeScheduler *s, CattaProbeJob *pj) {
     assert(pj);
 
     if (pj->time_event)
-        avahi_time_event_free(pj->time_event);
+        catta_time_event_free(pj->time_event);
 
     if (pj->done)
-        AVAHI_LLIST_REMOVE(AvahiProbeJob, jobs, s->history, pj);
+        CATTA_LLIST_REMOVE(CattaProbeJob, jobs, s->history, pj);
     else
-        AVAHI_LLIST_REMOVE(AvahiProbeJob, jobs, s->jobs, pj);
+        CATTA_LLIST_REMOVE(CattaProbeJob, jobs, s->jobs, pj);
 
-    avahi_record_unref(pj->record);
-    avahi_free(pj);
+    catta_record_unref(pj->record);
+    catta_free(pj);
 }
 
-static void elapse_callback(AvahiTimeEvent *e, void* data);
+static void elapse_callback(CattaTimeEvent *e, void* data);
 
-static void job_set_elapse_time(AvahiProbeScheduler *s, AvahiProbeJob *pj, unsigned msec, unsigned jitter) {
+static void job_set_elapse_time(CattaProbeScheduler *s, CattaProbeJob *pj, unsigned msec, unsigned jitter) {
     struct timeval tv;
 
     assert(s);
     assert(pj);
 
-    avahi_elapse_time(&tv, msec, jitter);
+    catta_elapse_time(&tv, msec, jitter);
 
     if (pj->time_event)
-        avahi_time_event_update(pj->time_event, &tv);
+        catta_time_event_update(pj->time_event, &tv);
     else
-        pj->time_event = avahi_time_event_new(s->time_event_queue, &tv, elapse_callback, pj);
+        pj->time_event = catta_time_event_new(s->time_event_queue, &tv, elapse_callback, pj);
 }
 
-static void job_mark_done(AvahiProbeScheduler *s, AvahiProbeJob *pj) {
+static void job_mark_done(CattaProbeScheduler *s, CattaProbeJob *pj) {
     assert(s);
     assert(pj);
 
     assert(!pj->done);
 
-    AVAHI_LLIST_REMOVE(AvahiProbeJob, jobs, s->jobs, pj);
-    AVAHI_LLIST_PREPEND(AvahiProbeJob, jobs, s->history, pj);
+    CATTA_LLIST_REMOVE(CattaProbeJob, jobs, s->jobs, pj);
+    CATTA_LLIST_PREPEND(CattaProbeJob, jobs, s->history, pj);
 
     pj->done = 1;
 
-    job_set_elapse_time(s, pj, AVAHI_PROBE_HISTORY_MSEC, 0);
+    job_set_elapse_time(s, pj, CATTA_PROBE_HISTORY_MSEC, 0);
     gettimeofday(&pj->delivery, NULL);
 }
 
-AvahiProbeScheduler *avahi_probe_scheduler_new(AvahiInterface *i) {
-    AvahiProbeScheduler *s;
+CattaProbeScheduler *catta_probe_scheduler_new(CattaInterface *i) {
+    CattaProbeScheduler *s;
 
     assert(i);
 
-    if (!(s = avahi_new(AvahiProbeScheduler, 1))) {
-        avahi_log_error(__FILE__": Out of memory");
+    if (!(s = catta_new(CattaProbeScheduler, 1))) {
+        catta_log_error(__FILE__": Out of memory");
         return NULL;
     }
 
     s->interface = i;
     s->time_event_queue = i->monitor->server->time_event_queue;
 
-    AVAHI_LLIST_HEAD_INIT(AvahiProbeJob, s->jobs);
-    AVAHI_LLIST_HEAD_INIT(AvahiProbeJob, s->history);
+    CATTA_LLIST_HEAD_INIT(CattaProbeJob, s->jobs);
+    CATTA_LLIST_HEAD_INIT(CattaProbeJob, s->history);
 
     return s;
 }
 
-void avahi_probe_scheduler_free(AvahiProbeScheduler *s) {
+void catta_probe_scheduler_free(CattaProbeScheduler *s) {
     assert(s);
 
-    avahi_probe_scheduler_clear(s);
-    avahi_free(s);
+    catta_probe_scheduler_clear(s);
+    catta_free(s);
 }
 
-void avahi_probe_scheduler_clear(AvahiProbeScheduler *s) {
+void catta_probe_scheduler_clear(CattaProbeScheduler *s) {
     assert(s);
 
     while (s->jobs)
@@ -162,9 +162,9 @@ void avahi_probe_scheduler_clear(AvahiProbeScheduler *s) {
         job_free(s, s->history);
 }
 
-static int packet_add_probe_query(AvahiProbeScheduler *s, AvahiDnsPacket *p, AvahiProbeJob *pj) {
+static int packet_add_probe_query(CattaProbeScheduler *s, CattaDnsPacket *p, CattaProbeJob *pj) {
     size_t size;
-    AvahiKey *k;
+    CattaKey *k;
     int b;
 
     assert(s);
@@ -175,18 +175,18 @@ static int packet_add_probe_query(AvahiProbeScheduler *s, AvahiDnsPacket *p, Ava
 
     /* Estimate the size for this record */
     size =
-        avahi_key_get_estimate_size(pj->record->key) +
-        avahi_record_get_estimate_size(pj->record);
+        catta_key_get_estimate_size(pj->record->key) +
+        catta_record_get_estimate_size(pj->record);
 
     /* Too large */
-    if (size > avahi_dns_packet_space(p))
+    if (size > catta_dns_packet_space(p))
         return 0;
 
     /* Create the probe query */
-    if (!(k = avahi_key_new(pj->record->key->name, pj->record->key->clazz, AVAHI_DNS_TYPE_ANY)))
+    if (!(k = catta_key_new(pj->record->key->name, pj->record->key->clazz, CATTA_DNS_TYPE_ANY)))
         return 0; /* OOM */
 
-    b = !!avahi_dns_packet_append_key(p, k, 0);
+    b = !!catta_dns_packet_append_key(p, k, 0);
     assert(b);
 
     /* Mark this job for addition to the packet */
@@ -198,26 +198,26 @@ static int packet_add_probe_query(AvahiProbeScheduler *s, AvahiDnsPacket *p, Ava
             continue;
 
         /* Does the record match the probe? */
-        if (k->clazz != pj->record->key->clazz || !avahi_domain_equal(k->name, pj->record->key->name))
+        if (k->clazz != pj->record->key->clazz || !catta_domain_equal(k->name, pj->record->key->name))
             continue;
 
         /* This job wouldn't fit in */
-        if (avahi_record_get_estimate_size(pj->record) > avahi_dns_packet_space(p))
+        if (catta_record_get_estimate_size(pj->record) > catta_dns_packet_space(p))
             break;
 
         /* Mark this job for addition to the packet */
         pj->chosen = 1;
     }
 
-    avahi_key_unref(k);
+    catta_key_unref(k);
 
     return 1;
 }
 
-static void elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void* data) {
-    AvahiProbeJob *pj = data, *next;
-    AvahiProbeScheduler *s;
-    AvahiDnsPacket *p;
+static void elapse_callback(CATTA_GCC_UNUSED CattaTimeEvent *e, void* data) {
+    CattaProbeJob *pj = data, *next;
+    CattaProbeScheduler *s;
+    CattaDnsPacket *p;
     unsigned n;
 
     assert(pj);
@@ -229,44 +229,44 @@ static void elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void* data) {
         return;
     }
 
-    if (!(p = avahi_dns_packet_new_query(s->interface->hardware->mtu)))
+    if (!(p = catta_dns_packet_new_query(s->interface->hardware->mtu)))
         return; /* OOM */
     n = 1;
 
     /* Add the import probe */
     if (!packet_add_probe_query(s, p, pj)) {
         size_t size;
-        AvahiKey *k;
+        CattaKey *k;
         int b;
 
-        avahi_dns_packet_free(p);
+        catta_dns_packet_free(p);
 
         /* The probe didn't fit in the package, so let's allocate a larger one */
 
         size =
-            avahi_key_get_estimate_size(pj->record->key) +
-            avahi_record_get_estimate_size(pj->record) +
-            AVAHI_DNS_PACKET_HEADER_SIZE;
+            catta_key_get_estimate_size(pj->record->key) +
+            catta_record_get_estimate_size(pj->record) +
+            CATTA_DNS_PACKET_HEADER_SIZE;
 
-        if (!(p = avahi_dns_packet_new_query(size + AVAHI_DNS_PACKET_EXTRA_SIZE)))
+        if (!(p = catta_dns_packet_new_query(size + CATTA_DNS_PACKET_EXTRA_SIZE)))
             return; /* OOM */
 
-        if (!(k = avahi_key_new(pj->record->key->name, pj->record->key->clazz, AVAHI_DNS_TYPE_ANY))) {
-            avahi_dns_packet_free(p);
+        if (!(k = catta_key_new(pj->record->key->name, pj->record->key->clazz, CATTA_DNS_TYPE_ANY))) {
+            catta_dns_packet_free(p);
             return;  /* OOM */
         }
 
-        b = avahi_dns_packet_append_key(p, k, 0) && avahi_dns_packet_append_record(p, pj->record, 0, 0);
-        avahi_key_unref(k);
+        b = catta_dns_packet_append_key(p, k, 0) && catta_dns_packet_append_record(p, pj->record, 0, 0);
+        catta_key_unref(k);
 
         if (b) {
-            avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_NSCOUNT, 1);
-            avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_QDCOUNT, 1);
-            avahi_interface_send_packet(s->interface, p);
+            catta_dns_packet_set_field(p, CATTA_DNS_FIELD_NSCOUNT, 1);
+            catta_dns_packet_set_field(p, CATTA_DNS_FIELD_QDCOUNT, 1);
+            catta_interface_send_packet(s->interface, p);
         } else
-            avahi_log_warn("Probe record too large, cannot send");
+            catta_log_warn("Probe record too large, cannot send");
 
-        avahi_dns_packet_free(p);
+        catta_dns_packet_free(p);
         job_mark_done(s, pj);
 
         return;
@@ -284,7 +284,7 @@ static void elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void* data) {
         n++;
     }
 
-    avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_QDCOUNT, n);
+    catta_dns_packet_set_field(p, CATTA_DNS_FIELD_QDCOUNT, n);
 
     n = 0;
 
@@ -296,8 +296,8 @@ static void elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void* data) {
         if (!pj->chosen)
             continue;
 
-        if (!avahi_dns_packet_append_record(p, pj->record, 0, 0)) {
-/*             avahi_log_warn("Bad probe size estimate!"); */
+        if (!catta_dns_packet_append_record(p, pj->record, 0, 0)) {
+/*             catta_log_warn("Bad probe size estimate!"); */
 
             /* Unmark all following jobs */
             for (; pj; pj = pj->jobs_next)
@@ -311,15 +311,15 @@ static void elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void* data) {
         n ++;
     }
 
-    avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_NSCOUNT, n);
+    catta_dns_packet_set_field(p, CATTA_DNS_FIELD_NSCOUNT, n);
 
     /* Send it now */
-    avahi_interface_send_packet(s->interface, p);
-    avahi_dns_packet_free(p);
+    catta_interface_send_packet(s->interface, p);
+    catta_dns_packet_free(p);
 }
 
-static AvahiProbeJob* find_scheduled_job(AvahiProbeScheduler *s, AvahiRecord *record) {
-    AvahiProbeJob *pj;
+static CattaProbeJob* find_scheduled_job(CattaProbeScheduler *s, CattaRecord *record) {
+    CattaProbeJob *pj;
 
     assert(s);
     assert(record);
@@ -327,15 +327,15 @@ static AvahiProbeJob* find_scheduled_job(AvahiProbeScheduler *s, AvahiRecord *re
     for (pj = s->jobs; pj; pj = pj->jobs_next) {
         assert(!pj->done);
 
-        if (avahi_record_equal_no_ttl(pj->record, record))
+        if (catta_record_equal_no_ttl(pj->record, record))
             return pj;
     }
 
     return NULL;
 }
 
-static AvahiProbeJob* find_history_job(AvahiProbeScheduler *s, AvahiRecord *record) {
-    AvahiProbeJob *pj;
+static CattaProbeJob* find_history_job(CattaProbeScheduler *s, CattaRecord *record) {
+    CattaProbeJob *pj;
 
     assert(s);
     assert(record);
@@ -343,10 +343,10 @@ static AvahiProbeJob* find_history_job(AvahiProbeScheduler *s, AvahiRecord *reco
     for (pj = s->history; pj; pj = pj->jobs_next) {
         assert(pj->done);
 
-        if (avahi_record_equal_no_ttl(pj->record, record)) {
+        if (catta_record_equal_no_ttl(pj->record, record)) {
             /* Check whether this entry is outdated */
 
-            if (avahi_age(&pj->delivery) > AVAHI_PROBE_HISTORY_MSEC*1000) {
+            if (catta_age(&pj->delivery) > CATTA_PROBE_HISTORY_MSEC*1000) {
                 /* it is outdated, so let's remove it */
                 job_free(s, pj);
                 return NULL;
@@ -359,25 +359,25 @@ static AvahiProbeJob* find_history_job(AvahiProbeScheduler *s, AvahiRecord *reco
     return NULL;
 }
 
-int avahi_probe_scheduler_post(AvahiProbeScheduler *s, AvahiRecord *record, int immediately) {
-    AvahiProbeJob *pj;
+int catta_probe_scheduler_post(CattaProbeScheduler *s, CattaRecord *record, int immediately) {
+    CattaProbeJob *pj;
     struct timeval tv;
 
     assert(s);
     assert(record);
-    assert(!avahi_key_is_pattern(record->key));
+    assert(!catta_key_is_pattern(record->key));
 
     if ((pj = find_history_job(s, record)))
         return 0;
 
-    avahi_elapse_time(&tv, immediately ? 0 : AVAHI_PROBE_DEFER_MSEC, 0);
+    catta_elapse_time(&tv, immediately ? 0 : CATTA_PROBE_DEFER_MSEC, 0);
 
     if ((pj = find_scheduled_job(s, record))) {
 
-        if (avahi_timeval_compare(&tv, &pj->delivery) < 0) {
+        if (catta_timeval_compare(&tv, &pj->delivery) < 0) {
             /* If the new entry should be scheduled earlier, update the old entry */
             pj->delivery = tv;
-            avahi_time_event_update(pj->time_event, &pj->delivery);
+            catta_time_event_update(pj->time_event, &pj->delivery);
         }
 
         return 1;
@@ -387,10 +387,10 @@ int avahi_probe_scheduler_post(AvahiProbeScheduler *s, AvahiRecord *record, int
             return 0; /* OOM */
 
         pj->delivery = tv;
-        pj->time_event = avahi_time_event_new(s->time_event_queue, &pj->delivery, elapse_callback, pj);
+        pj->time_event = catta_time_event_new(s->time_event_queue, &pj->delivery, elapse_callback, pj);
 
 
-/*     avahi_log_debug("Accepted new probe job."); */
+/*     catta_log_debug("Accepted new probe job."); */
 
         return 1;
     }
index 4193df840c047998e623609eea79b45d25ffec05..c026860618ed5fb6955c896e8582729a443ee48d 100644 (file)
@@ -2,33 +2,33 @@
 #define fooprobeschedhfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
-typedef struct AvahiProbeScheduler AvahiProbeScheduler;
+typedef struct CattaProbeScheduler CattaProbeScheduler;
 
-#include <avahi/address.h>
+#include <catta/address.h>
 #include "iface.h"
 
-AvahiProbeScheduler *avahi_probe_scheduler_new(AvahiInterface *i);
-void avahi_probe_scheduler_free(AvahiProbeScheduler *s);
-void avahi_probe_scheduler_clear(AvahiProbeScheduler *s);
+CattaProbeScheduler *catta_probe_scheduler_new(CattaInterface *i);
+void catta_probe_scheduler_free(CattaProbeScheduler *s);
+void catta_probe_scheduler_clear(CattaProbeScheduler *s);
 
-int avahi_probe_scheduler_post(AvahiProbeScheduler *s, AvahiRecord *record, int immediately);
+int catta_probe_scheduler_post(CattaProbeScheduler *s, CattaRecord *record, int immediately);
 
 #endif
index 682d52fff3b0e3a671ac3016a67fe24c8fa5b58f..dea1aa41c4e4495a1a7532f12412592b52670fcd 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 #include <stdlib.h>
 
-#include <avahi/timeval.h>
-#include <avahi/malloc.h>
-#include <avahi/error.h>
-#include <avahi/domain.h>
+#include <catta/timeval.h>
+#include <catta/malloc.h>
+#include <catta/error.h>
+#include <catta/domain.h>
 
 #include "querier.h"
-#include <avahi/log.h>
+#include <catta/log.h>
 
-struct AvahiQuerier {
-    AvahiInterface *interface;
+struct CattaQuerier {
+    CattaInterface *interface;
 
-    AvahiKey *key;
+    CattaKey *key;
     int n_used;
 
     unsigned sec_delay;
 
-    AvahiTimeEvent *time_event;
+    CattaTimeEvent *time_event;
 
     struct timeval creation_time;
 
     unsigned post_id;
     int post_id_valid;
 
-    AVAHI_LLIST_FIELDS(AvahiQuerier, queriers);
+    CATTA_LLIST_FIELDS(CattaQuerier, queriers);
 };
 
-void avahi_querier_free(AvahiQuerier *q) {
+void catta_querier_free(CattaQuerier *q) {
     assert(q);
 
-    AVAHI_LLIST_REMOVE(AvahiQuerier, queriers, q->interface->queriers, q);
-    avahi_hashmap_remove(q->interface->queriers_by_key, q->key);
+    CATTA_LLIST_REMOVE(CattaQuerier, queriers, q->interface->queriers, q);
+    catta_hashmap_remove(q->interface->queriers_by_key, q->key);
 
-    avahi_key_unref(q->key);
-    avahi_time_event_free(q->time_event);
+    catta_key_unref(q->key);
+    catta_time_event_free(q->time_event);
 
-    avahi_free(q);
+    catta_free(q);
 }
 
-static void querier_elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void *userdata) {
-    AvahiQuerier *q = userdata;
+static void querier_elapse_callback(CATTA_GCC_UNUSED CattaTimeEvent *e, void *userdata) {
+    CattaQuerier *q = userdata;
     struct timeval tv;
 
     assert(q);
@@ -73,11 +73,11 @@ static void querier_elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void *us
          * ourselves. We should not send out any further queries from
          * this querier object anymore. */
 
-        avahi_querier_free(q);
+        catta_querier_free(q);
         return;
     }
 
-    if (avahi_interface_post_query(q->interface, q->key, 0, &q->post_id)) {
+    if (catta_interface_post_query(q->interface, q->key, 0, &q->post_id)) {
 
         /* The queue accepted our query. We store the query id here,
          * that allows us to drop the query at a later point if the
@@ -91,18 +91,18 @@ static void querier_elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void *us
     if (q->sec_delay >= 60*60)  /* 1h */
         q->sec_delay = 60*60;
 
-    avahi_elapse_time(&tv, q->sec_delay*1000, 0);
-    avahi_time_event_update(q->time_event, &tv);
+    catta_elapse_time(&tv, q->sec_delay*1000, 0);
+    catta_time_event_update(q->time_event, &tv);
 }
 
-void avahi_querier_add(AvahiInterface *i, AvahiKey *key, struct timeval *ret_ctime) {
-    AvahiQuerier *q;
+void catta_querier_add(CattaInterface *i, CattaKey *key, struct timeval *ret_ctime) {
+    CattaQuerier *q;
     struct timeval tv;
 
     assert(i);
     assert(key);
 
-    if ((q = avahi_hashmap_lookup(i->queriers_by_key, key))) {
+    if ((q = catta_hashmap_lookup(i->queriers_by_key, key))) {
 
         /* Someone is already browsing for records of this RR key */
         q->n_used++;
@@ -116,10 +116,10 @@ void avahi_querier_add(AvahiInterface *i, AvahiKey *key, struct timeval *ret_cti
     }
 
     /* No one is browsing for this RR key, so we add a new querier */
-    if (!(q = avahi_new(AvahiQuerier, 1)))
+    if (!(q = catta_new(CattaQuerier, 1)))
         return; /* OOM */
 
-    q->key = avahi_key_ref(key);
+    q->key = catta_key_ref(key);
     q->interface = i;
     q->n_used = 1;
     q->sec_delay = 1;
@@ -127,14 +127,14 @@ void avahi_querier_add(AvahiInterface *i, AvahiKey *key, struct timeval *ret_cti
     gettimeofday(&q->creation_time, NULL);
 
     /* Do the initial query */
-    if (avahi_interface_post_query(i, key, 0, &q->post_id))
+    if (catta_interface_post_query(i, key, 0, &q->post_id))
         q->post_id_valid = 1;
 
     /* Schedule next queries */
-    q->time_event = avahi_time_event_new(i->monitor->server->time_event_queue, avahi_elapse_time(&tv, q->sec_delay*1000, 0), querier_elapse_callback, q);
+    q->time_event = catta_time_event_new(i->monitor->server->time_event_queue, catta_elapse_time(&tv, q->sec_delay*1000, 0), querier_elapse_callback, q);
 
-    AVAHI_LLIST_PREPEND(AvahiQuerier, queriers, i->queriers, q);
-    avahi_hashmap_insert(i->queriers_by_key, q->key, q);
+    CATTA_LLIST_PREPEND(CattaQuerier, queriers, i->queriers, q);
+    catta_hashmap_insert(i->queriers_by_key, q->key, q);
 
     /* Return the creation time. This is used for generating the
      * ALL_FOR_NOW event one second after the querier was initially
@@ -143,24 +143,24 @@ void avahi_querier_add(AvahiInterface *i, AvahiKey *key, struct timeval *ret_cti
         *ret_ctime = q->creation_time;
 }
 
-void avahi_querier_remove(AvahiInterface *i, AvahiKey *key) {
-    AvahiQuerier *q;
+void catta_querier_remove(CattaInterface *i, CattaKey *key) {
+    CattaQuerier *q;
 
     /* There was no querier for this RR key, or it wasn't referenced
      * by anyone. */
-    if (!(q = avahi_hashmap_lookup(i->queriers_by_key, key)) || q->n_used <= 0)
+    if (!(q = catta_hashmap_lookup(i->queriers_by_key, key)) || q->n_used <= 0)
         return;
 
     if ((--q->n_used) <= 0) {
 
         /* Nobody references us anymore. */
 
-        if (q->post_id_valid && avahi_interface_withraw_query(i, q->post_id)) {
+        if (q->post_id_valid && catta_interface_withraw_query(i, q->post_id)) {
 
             /* We succeeded in withdrawing our query from the queue,
              * so let's drop dead. */
 
-            avahi_querier_free(q);
+            catta_querier_free(q);
         }
 
         /* If we failed to withdraw our query from the queue, we stay
@@ -170,28 +170,28 @@ void avahi_querier_remove(AvahiInterface *i, AvahiKey *key) {
     }
 }
 
-static void remove_querier_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata) {
+static void remove_querier_callback(CattaInterfaceMonitor *m, CattaInterface *i, void* userdata) {
     assert(m);
     assert(i);
     assert(userdata);
 
     if (i->announcing)
-        avahi_querier_remove(i, (AvahiKey*) userdata);
+        catta_querier_remove(i, (CattaKey*) userdata);
 }
 
-void avahi_querier_remove_for_all(AvahiServer *s, AvahiIfIndex idx, AvahiProtocol protocol, AvahiKey *key) {
+void catta_querier_remove_for_all(CattaServer *s, CattaIfIndex idx, CattaProtocol protocol, CattaKey *key) {
     assert(s);
     assert(key);
 
-    avahi_interface_monitor_walk(s->monitor, idx, protocol, remove_querier_callback, key);
+    catta_interface_monitor_walk(s->monitor, idx, protocol, remove_querier_callback, key);
 }
 
 struct cbdata {
-    AvahiKey *key;
+    CattaKey *key;
     struct timeval *ret_ctime;
 };
 
-static void add_querier_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata) {
+static void add_querier_callback(CattaInterfaceMonitor *m, CattaInterface *i, void* userdata) {
     struct cbdata *cbdata = userdata;
 
     assert(m);
@@ -200,14 +200,14 @@ static void add_querier_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, vo
 
     if (i->announcing) {
         struct timeval tv;
-        avahi_querier_add(i, cbdata->key, &tv);
+        catta_querier_add(i, cbdata->key, &tv);
 
-        if (cbdata->ret_ctime && avahi_timeval_compare(&tv, cbdata->ret_ctime) > 0)
+        if (cbdata->ret_ctime && catta_timeval_compare(&tv, cbdata->ret_ctime) > 0)
             *cbdata->ret_ctime = tv;
     }
 }
 
-void avahi_querier_add_for_all(AvahiServer *s, AvahiIfIndex idx, AvahiProtocol protocol, AvahiKey *key, struct timeval *ret_ctime) {
+void catta_querier_add_for_all(CattaServer *s, CattaIfIndex idx, CattaProtocol protocol, CattaKey *key, struct timeval *ret_ctime) {
     struct cbdata cbdata;
 
     assert(s);
@@ -219,18 +219,18 @@ void avahi_querier_add_for_all(AvahiServer *s, AvahiIfIndex idx, AvahiProtocol p
     if (ret_ctime)
         ret_ctime->tv_sec = ret_ctime->tv_usec = 0;
 
-    avahi_interface_monitor_walk(s->monitor, idx, protocol, add_querier_callback, &cbdata);
+    catta_interface_monitor_walk(s->monitor, idx, protocol, add_querier_callback, &cbdata);
 }
 
-int avahi_querier_shall_refresh_cache(AvahiInterface *i, AvahiKey *key) {
-    AvahiQuerier *q;
+int catta_querier_shall_refresh_cache(CattaInterface *i, CattaKey *key) {
+    CattaQuerier *q;
 
     assert(i);
     assert(key);
 
     /* Called by the cache maintainer */
 
-    if (!(q = avahi_hashmap_lookup(i->queriers_by_key, key)))
+    if (!(q = catta_hashmap_lookup(i->queriers_by_key, key)))
         /* This key is currently not subscribed at all, so no cache
          * refresh is needed */
         return 0;
@@ -242,7 +242,7 @@ int avahi_querier_shall_refresh_cache(AvahiInterface *i, AvahiKey *key) {
 
         /* Remove this querier since it is referenced by nobody
          * and the cached data will soon be out of date */
-        avahi_querier_free(q);
+        catta_querier_free(q);
 
         /* Tell the cache that no refresh is needed */
         return 0;
@@ -252,17 +252,17 @@ int avahi_querier_shall_refresh_cache(AvahiInterface *i, AvahiKey *key) {
 
         /* We can defer our query a little, since the cache will now
          * issue a refresh query anyway. */
-        avahi_elapse_time(&tv, q->sec_delay*1000, 0);
-        avahi_time_event_update(q->time_event, &tv);
+        catta_elapse_time(&tv, q->sec_delay*1000, 0);
+        catta_time_event_update(q->time_event, &tv);
 
         /* Tell the cache that a refresh should be issued */
         return 1;
     }
 }
 
-void avahi_querier_free_all(AvahiInterface *i) {
+void catta_querier_free_all(CattaInterface *i) {
     assert(i);
 
     while (i->queriers)
-        avahi_querier_free(i->queriers);
+        catta_querier_free(i->queriers);
 }
index 6a32a3b2fb165db67316aae6842f6701d5b8df55..e054e5734abb938f6fd39c0f29866a28826f1af2 100644 (file)
@@ -2,47 +2,47 @@
 #define fooquerierhfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
-typedef struct AvahiQuerier AvahiQuerier;
+typedef struct CattaQuerier CattaQuerier;
 
 #include "iface.h"
 
 /** Add querier for the specified key to the specified interface */
-void avahi_querier_add(AvahiInterface *i, AvahiKey *key, struct timeval *ret_ctime);
+void catta_querier_add(CattaInterface *i, CattaKey *key, struct timeval *ret_ctime);
 
 /** Remove a querier for the specified key from the specified interface */
-void avahi_querier_remove(AvahiInterface *i, AvahiKey *key);
+void catta_querier_remove(CattaInterface *i, CattaKey *key);
 
 /** Add a querier for the specified key on all interfaces that mach */
-void avahi_querier_add_for_all(AvahiServer *s, AvahiIfIndex idx, AvahiProtocol protocol, AvahiKey *key, struct timeval *ret_ctime);
+void catta_querier_add_for_all(CattaServer *s, CattaIfIndex idx, CattaProtocol protocol, CattaKey *key, struct timeval *ret_ctime);
 
 /** Remove a querier for the specified key on all interfaces that mach */
-void avahi_querier_remove_for_all(AvahiServer *s, AvahiIfIndex idx, AvahiProtocol protocol, AvahiKey *key);
+void catta_querier_remove_for_all(CattaServer *s, CattaIfIndex idx, CattaProtocol protocol, CattaKey *key);
 
 /** Free all queriers */
-void avahi_querier_free(AvahiQuerier *q);
+void catta_querier_free(CattaQuerier *q);
 
 /** Free all queriers on the specified interface */
-void avahi_querier_free_all(AvahiInterface *i);
+void catta_querier_free_all(CattaInterface *i);
 
 /** Return 1 if there is a querier for the specified key on the specified interface */
-int avahi_querier_shall_refresh_cache(AvahiInterface *i, AvahiKey *key);
+int catta_querier_shall_refresh_cache(CattaInterface *i, CattaKey *key);
 
 #endif
index 7b059a665580eb1bcbc5674ba72ed3f22d82b225..18c89719c8039e3657e79812573e9edbda739818 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 #include <stdlib.h>
 
-#include <avahi/timeval.h>
-#include <avahi/malloc.h>
+#include <catta/timeval.h>
+#include <catta/malloc.h>
 
 #include "query-sched.h"
-#include <avahi/log.h>
+#include <catta/log.h>
 
-#define AVAHI_QUERY_HISTORY_MSEC 100
-#define AVAHI_QUERY_DEFER_MSEC 100
+#define CATTA_QUERY_HISTORY_MSEC 100
+#define CATTA_QUERY_DEFER_MSEC 100
 
-typedef struct AvahiQueryJob AvahiQueryJob;
-typedef struct AvahiKnownAnswer AvahiKnownAnswer;
+typedef struct CattaQueryJob CattaQueryJob;
+typedef struct CattaKnownAnswer CattaKnownAnswer;
 
-struct AvahiQueryJob {
+struct CattaQueryJob {
     unsigned id;
     int n_posted;
 
-    AvahiQueryScheduler *scheduler;
-    AvahiTimeEvent *time_event;
+    CattaQueryScheduler *scheduler;
+    CattaTimeEvent *time_event;
 
     int done;
     struct timeval delivery;
 
-    AvahiKey *key;
+    CattaKey *key;
 
     /* Jobs are stored in a simple linked list. It might turn out in
      * the future that this list grows too long and we must switch to
@@ -55,105 +55,105 @@ struct AvahiQueryJob {
      * assumption, especially on setups where traffic reflection is
      * involved. */
 
-    AVAHI_LLIST_FIELDS(AvahiQueryJob, jobs);
+    CATTA_LLIST_FIELDS(CattaQueryJob, jobs);
 };
 
-struct AvahiKnownAnswer {
-    AvahiQueryScheduler *scheduler;
-    AvahiRecord *record;
+struct CattaKnownAnswer {
+    CattaQueryScheduler *scheduler;
+    CattaRecord *record;
 
-    AVAHI_LLIST_FIELDS(AvahiKnownAnswer, known_answer);
+    CATTA_LLIST_FIELDS(CattaKnownAnswer, known_answer);
 };
 
-struct AvahiQueryScheduler {
-    AvahiInterface *interface;
-    AvahiTimeEventQueue *time_event_queue;
+struct CattaQueryScheduler {
+    CattaInterface *interface;
+    CattaTimeEventQueue *time_event_queue;
 
     unsigned next_id;
 
-    AVAHI_LLIST_HEAD(AvahiQueryJob, jobs);
-    AVAHI_LLIST_HEAD(AvahiQueryJob, history);
-    AVAHI_LLIST_HEAD(AvahiKnownAnswer, known_answers);
+    CATTA_LLIST_HEAD(CattaQueryJob, jobs);
+    CATTA_LLIST_HEAD(CattaQueryJob, history);
+    CATTA_LLIST_HEAD(CattaKnownAnswer, known_answers);
 };
 
-static AvahiQueryJob* job_new(AvahiQueryScheduler *s, AvahiKey *key, int done) {
-    AvahiQueryJob *qj;
+static CattaQueryJob* job_new(CattaQueryScheduler *s, CattaKey *key, int done) {
+    CattaQueryJob *qj;
 
     assert(s);
     assert(key);
 
-    if (!(qj = avahi_new(AvahiQueryJob, 1))) {
-        avahi_log_error(__FILE__": Out of memory");
+    if (!(qj = catta_new(CattaQueryJob, 1))) {
+        catta_log_error(__FILE__": Out of memory");
         return NULL;
     }
 
     qj->scheduler = s;
-    qj->key = avahi_key_ref(key);
+    qj->key = catta_key_ref(key);
     qj->time_event = NULL;
     qj->n_posted = 1;
     qj->id = s->next_id++;
 
     if ((qj->done = done))
-        AVAHI_LLIST_PREPEND(AvahiQueryJob, jobs, s->history, qj);
+        CATTA_LLIST_PREPEND(CattaQueryJob, jobs, s->history, qj);
     else
-        AVAHI_LLIST_PREPEND(AvahiQueryJob, jobs, s->jobs, qj);
+        CATTA_LLIST_PREPEND(CattaQueryJob, jobs, s->jobs, qj);
 
     return qj;
 }
 
-static void job_free(AvahiQueryScheduler *s, AvahiQueryJob *qj) {
+static void job_free(CattaQueryScheduler *s, CattaQueryJob *qj) {
     assert(s);
     assert(qj);
 
     if (qj->time_event)
-        avahi_time_event_free(qj->time_event);
+        catta_time_event_free(qj->time_event);
 
     if (qj->done)
-        AVAHI_LLIST_REMOVE(AvahiQueryJob, jobs, s->history, qj);
+        CATTA_LLIST_REMOVE(CattaQueryJob, jobs, s->history, qj);
     else
-        AVAHI_LLIST_REMOVE(AvahiQueryJob, jobs, s->jobs, qj);
+        CATTA_LLIST_REMOVE(CattaQueryJob, jobs, s->jobs, qj);
 
-    avahi_key_unref(qj->key);
-    avahi_free(qj);
+    catta_key_unref(qj->key);
+    catta_free(qj);
 }
 
-static void elapse_callback(AvahiTimeEvent *e, void* data);
+static void elapse_callback(CattaTimeEvent *e, void* data);
 
-static void job_set_elapse_time(AvahiQueryScheduler *s, AvahiQueryJob *qj, unsigned msec, unsigned jitter) {
+static void job_set_elapse_time(CattaQueryScheduler *s, CattaQueryJob *qj, unsigned msec, unsigned jitter) {
     struct timeval tv;
 
     assert(s);
     assert(qj);
 
-    avahi_elapse_time(&tv, msec, jitter);
+    catta_elapse_time(&tv, msec, jitter);
 
     if (qj->time_event)
-        avahi_time_event_update(qj->time_event, &tv);
+        catta_time_event_update(qj->time_event, &tv);
     else
-        qj->time_event = avahi_time_event_new(s->time_event_queue, &tv, elapse_callback, qj);
+        qj->time_event = catta_time_event_new(s->time_event_queue, &tv, elapse_callback, qj);
 }
 
-static void job_mark_done(AvahiQueryScheduler *s, AvahiQueryJob *qj) {
+static void job_mark_done(CattaQueryScheduler *s, CattaQueryJob *qj) {
     assert(s);
     assert(qj);
 
     assert(!qj->done);
 
-    AVAHI_LLIST_REMOVE(AvahiQueryJob, jobs, s->jobs, qj);
-    AVAHI_LLIST_PREPEND(AvahiQueryJob, jobs, s->history, qj);
+    CATTA_LLIST_REMOVE(CattaQueryJob, jobs, s->jobs, qj);
+    CATTA_LLIST_PREPEND(CattaQueryJob, jobs, s->history, qj);
 
     qj->done = 1;
 
-    job_set_elapse_time(s, qj, AVAHI_QUERY_HISTORY_MSEC, 0);
+    job_set_elapse_time(s, qj, CATTA_QUERY_HISTORY_MSEC, 0);
     gettimeofday(&qj->delivery, NULL);
 }
 
-AvahiQueryScheduler *avahi_query_scheduler_new(AvahiInterface *i) {
-    AvahiQueryScheduler *s;
+CattaQueryScheduler *catta_query_scheduler_new(CattaInterface *i) {
+    CattaQueryScheduler *s;
     assert(i);
 
-    if (!(s = avahi_new(AvahiQueryScheduler, 1))) {
-        avahi_log_error(__FILE__": Out of memory");
+    if (!(s = catta_new(CattaQueryScheduler, 1))) {
+        catta_log_error(__FILE__": Out of memory");
         return NULL; /* OOM */
     }
 
@@ -161,22 +161,22 @@ AvahiQueryScheduler *avahi_query_scheduler_new(AvahiInterface *i) {
     s->time_event_queue = i->monitor->server->time_event_queue;
     s->next_id = 0;
 
-    AVAHI_LLIST_HEAD_INIT(AvahiQueryJob, s->jobs);
-    AVAHI_LLIST_HEAD_INIT(AvahiQueryJob, s->history);
-    AVAHI_LLIST_HEAD_INIT(AvahiKnownAnswer, s->known_answers);
+    CATTA_LLIST_HEAD_INIT(CattaQueryJob, s->jobs);
+    CATTA_LLIST_HEAD_INIT(CattaQueryJob, s->history);
+    CATTA_LLIST_HEAD_INIT(CattaKnownAnswer, s->known_answers);
 
     return s;
 }
 
-void avahi_query_scheduler_free(AvahiQueryScheduler *s) {
+void catta_query_scheduler_free(CattaQueryScheduler *s) {
     assert(s);
 
     assert(!s->known_answers);
-    avahi_query_scheduler_clear(s);
-    avahi_free(s);
+    catta_query_scheduler_clear(s);
+    catta_free(s);
 }
 
-void avahi_query_scheduler_clear(AvahiQueryScheduler *s) {
+void catta_query_scheduler_clear(CattaQueryScheduler *s) {
     assert(s);
 
     while (s->jobs)
@@ -185,48 +185,48 @@ void avahi_query_scheduler_clear(AvahiQueryScheduler *s) {
         job_free(s, s->history);
 }
 
-static void* known_answer_walk_callback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEntry *e, void* userdata) {
-    AvahiQueryScheduler *s = userdata;
-    AvahiKnownAnswer *ka;
+static void* known_answer_walk_callback(CattaCache *c, CattaKey *pattern, CattaCacheEntry *e, void* userdata) {
+    CattaQueryScheduler *s = userdata;
+    CattaKnownAnswer *ka;
 
     assert(c);
     assert(pattern);
     assert(e);
     assert(s);
 
-    if (avahi_cache_entry_half_ttl(c, e))
+    if (catta_cache_entry_half_ttl(c, e))
         return NULL;
 
-    if (!(ka = avahi_new0(AvahiKnownAnswer, 1))) {
-        avahi_log_error(__FILE__": Out of memory");
+    if (!(ka = catta_new0(CattaKnownAnswer, 1))) {
+        catta_log_error(__FILE__": Out of memory");
         return NULL;
     }
 
     ka->scheduler = s;
-    ka->record = avahi_record_ref(e->record);
+    ka->record = catta_record_ref(e->record);
 
-    AVAHI_LLIST_PREPEND(AvahiKnownAnswer, known_answer, s->known_answers, ka);
+    CATTA_LLIST_PREPEND(CattaKnownAnswer, known_answer, s->known_answers, ka);
     return NULL;
 }
 
-static int packet_add_query_job(AvahiQueryScheduler *s, AvahiDnsPacket *p, AvahiQueryJob *qj) {
+static int packet_add_query_job(CattaQueryScheduler *s, CattaDnsPacket *p, CattaQueryJob *qj) {
     assert(s);
     assert(p);
     assert(qj);
 
-    if (!avahi_dns_packet_append_key(p, qj->key, 0))
+    if (!catta_dns_packet_append_key(p, qj->key, 0))
         return 0;
 
     /* Add all matching known answers to the list */
-    avahi_cache_walk(s->interface->cache, qj->key, known_answer_walk_callback, s);
+    catta_cache_walk(s->interface->cache, qj->key, known_answer_walk_callback, s);
 
     job_mark_done(s, qj);
 
     return 1;
 }
 
-static void append_known_answers_and_send(AvahiQueryScheduler *s, AvahiDnsPacket *p) {
-    AvahiKnownAnswer *ka;
+static void append_known_answers_and_send(CattaQueryScheduler *s, CattaDnsPacket *p) {
+    CattaKnownAnswer *ka;
     unsigned n;
     assert(s);
     assert(p);
@@ -236,9 +236,9 @@ static void append_known_answers_and_send(AvahiQueryScheduler *s, AvahiDnsPacket
     while ((ka = s->known_answers)) {
         int too_large = 0;
 
-        while (!avahi_dns_packet_append_record(p, ka->record, 0, 0)) {
+        while (!catta_dns_packet_append_record(p, ka->record, 0, 0)) {
 
-            if (avahi_dns_packet_is_empty(p)) {
+            if (catta_dns_packet_is_empty(p)) {
                 /* The record is too large to fit into one packet, so
                    there's no point in sending it. Better is letting
                    the owner of the record send it as a response. This
@@ -248,32 +248,32 @@ static void append_known_answers_and_send(AvahiQueryScheduler *s, AvahiDnsPacket
                 break;
             }
 
-            avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_FLAGS, avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_FLAGS) | AVAHI_DNS_FLAG_TC);
-            avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_ANCOUNT, n);
-            avahi_interface_send_packet(s->interface, p);
-            avahi_dns_packet_free(p);
+            catta_dns_packet_set_field(p, CATTA_DNS_FIELD_FLAGS, catta_dns_packet_get_field(p, CATTA_DNS_FIELD_FLAGS) | CATTA_DNS_FLAG_TC);
+            catta_dns_packet_set_field(p, CATTA_DNS_FIELD_ANCOUNT, n);
+            catta_interface_send_packet(s->interface, p);
+            catta_dns_packet_free(p);
 
-            p = avahi_dns_packet_new_query(s->interface->hardware->mtu);
+            p = catta_dns_packet_new_query(s->interface->hardware->mtu);
             n = 0;
         }
 
-        AVAHI_LLIST_REMOVE(AvahiKnownAnswer, known_answer, s->known_answers, ka);
-        avahi_record_unref(ka->record);
-        avahi_free(ka);
+        CATTA_LLIST_REMOVE(CattaKnownAnswer, known_answer, s->known_answers, ka);
+        catta_record_unref(ka->record);
+        catta_free(ka);
 
         if (!too_large)
             n++;
     }
 
-    avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_ANCOUNT, n);
-    avahi_interface_send_packet(s->interface, p);
-    avahi_dns_packet_free(p);
+    catta_dns_packet_set_field(p, CATTA_DNS_FIELD_ANCOUNT, n);
+    catta_interface_send_packet(s->interface, p);
+    catta_dns_packet_free(p);
 }
 
-static void elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void* data) {
-    AvahiQueryJob *qj = data;
-    AvahiQueryScheduler *s;
-    AvahiDnsPacket *p;
+static void elapse_callback(CATTA_GCC_UNUSED CattaTimeEvent *e, void* data) {
+    CattaQueryJob *qj = data;
+    CattaQueryScheduler *s;
+    CattaDnsPacket *p;
     unsigned n;
     int b;
 
@@ -288,7 +288,7 @@ static void elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void* data) {
 
     assert(!s->known_answers);
 
-    if (!(p = avahi_dns_packet_new_query(s->interface->hardware->mtu)))
+    if (!(p = catta_dns_packet_new_query(s->interface->hardware->mtu)))
         return; /* OOM */
 
     b = packet_add_query_job(s, p, qj);
@@ -304,14 +304,14 @@ static void elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void* data) {
         n++;
     }
 
-    avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_QDCOUNT, n);
+    catta_dns_packet_set_field(p, CATTA_DNS_FIELD_QDCOUNT, n);
 
     /* Now add known answers */
     append_known_answers_and_send(s, p);
 }
 
-static AvahiQueryJob* find_scheduled_job(AvahiQueryScheduler *s, AvahiKey *key) {
-    AvahiQueryJob *qj;
+static CattaQueryJob* find_scheduled_job(CattaQueryScheduler *s, CattaKey *key) {
+    CattaQueryJob *qj;
 
     assert(s);
     assert(key);
@@ -319,15 +319,15 @@ static AvahiQueryJob* find_scheduled_job(AvahiQueryScheduler *s, AvahiKey *key)
     for (qj = s->jobs; qj; qj = qj->jobs_next) {
         assert(!qj->done);
 
-        if (avahi_key_equal(qj->key, key))
+        if (catta_key_equal(qj->key, key))
             return qj;
     }
 
     return NULL;
 }
 
-static AvahiQueryJob* find_history_job(AvahiQueryScheduler *s, AvahiKey *key) {
-    AvahiQueryJob *qj;
+static CattaQueryJob* find_history_job(CattaQueryScheduler *s, CattaKey *key) {
+    CattaQueryJob *qj;
 
     assert(s);
     assert(key);
@@ -335,10 +335,10 @@ static AvahiQueryJob* find_history_job(AvahiQueryScheduler *s, AvahiKey *key) {
     for (qj = s->history; qj; qj = qj->jobs_next) {
         assert(qj->done);
 
-        if (avahi_key_equal(qj->key, key)) {
+        if (catta_key_equal(qj->key, key)) {
             /* Check whether this entry is outdated */
 
-            if (avahi_age(&qj->delivery) > AVAHI_QUERY_HISTORY_MSEC*1000) {
+            if (catta_age(&qj->delivery) > CATTA_QUERY_HISTORY_MSEC*1000) {
                 /* it is outdated, so let's remove it */
                 job_free(s, qj);
                 return NULL;
@@ -351,9 +351,9 @@ static AvahiQueryJob* find_history_job(AvahiQueryScheduler *s, AvahiKey *key) {
     return NULL;
 }
 
-int avahi_query_scheduler_post(AvahiQueryScheduler *s, AvahiKey *key, int immediately, unsigned *ret_id) {
+int catta_query_scheduler_post(CattaQueryScheduler *s, CattaKey *key, int immediately, unsigned *ret_id) {
     struct timeval tv;
-    AvahiQueryJob *qj;
+    CattaQueryJob *qj;
 
     assert(s);
     assert(key);
@@ -361,16 +361,16 @@ int avahi_query_scheduler_post(AvahiQueryScheduler *s, AvahiKey *key, int immedi
     if ((qj = find_history_job(s, key)))
         return 0;
 
-    avahi_elapse_time(&tv, immediately ? 0 : AVAHI_QUERY_DEFER_MSEC, 0);
+    catta_elapse_time(&tv, immediately ? 0 : CATTA_QUERY_DEFER_MSEC, 0);
 
     if ((qj = find_scheduled_job(s, key))) {
         /* Duplicate questions suppression */
 
-        if (avahi_timeval_compare(&tv, &qj->delivery) < 0) {
+        if (catta_timeval_compare(&tv, &qj->delivery) < 0) {
             /* If the new entry should be scheduled earlier,
              * update the old entry */
             qj->delivery = tv;
-            avahi_time_event_update(qj->time_event, &qj->delivery);
+            catta_time_event_update(qj->time_event, &qj->delivery);
         }
 
         qj->n_posted++;
@@ -381,7 +381,7 @@ int avahi_query_scheduler_post(AvahiQueryScheduler *s, AvahiKey *key, int immedi
             return 0; /* OOM */
 
         qj->delivery = tv;
-        qj->time_event = avahi_time_event_new(s->time_event_queue, &qj->delivery, elapse_callback, qj);
+        qj->time_event = catta_time_event_new(s->time_event_queue, &qj->delivery, elapse_callback, qj);
     }
 
     if (ret_id)
@@ -390,8 +390,8 @@ int avahi_query_scheduler_post(AvahiQueryScheduler *s, AvahiKey *key, int immedi
     return 1;
 }
 
-void avahi_query_scheduler_incoming(AvahiQueryScheduler *s, AvahiKey *key) {
-    AvahiQueryJob *qj;
+void catta_query_scheduler_incoming(CattaQueryScheduler *s, CattaKey *key) {
+    CattaQueryJob *qj;
 
     assert(s);
     assert(key);
@@ -412,17 +412,17 @@ void avahi_query_scheduler_incoming(AvahiQueryScheduler *s, AvahiKey *key) {
             return; /* OOM */
 
     gettimeofday(&qj->delivery, NULL);
-    job_set_elapse_time(s, qj, AVAHI_QUERY_HISTORY_MSEC, 0);
+    job_set_elapse_time(s, qj, CATTA_QUERY_HISTORY_MSEC, 0);
 }
 
-int avahi_query_scheduler_withdraw_by_id(AvahiQueryScheduler *s, unsigned id) {
-    AvahiQueryJob *qj;
+int catta_query_scheduler_withdraw_by_id(CattaQueryScheduler *s, unsigned id) {
+    CattaQueryJob *qj;
 
     assert(s);
 
     /* Very short lived queries can withdraw an already scheduled item
      * from the queue using this function, simply by passing the id
-     * returned by avahi_query_scheduler_post(). */
+     * returned by catta_query_scheduler_post(). */
 
     for (qj = s->jobs; qj; qj = qj->jobs_next) {
         assert(!qj->done);
index 9dfe3b5f5c0cf2aeb7ad31617888bf358d10f063..4447868ab33be4100a5ae0232099c55c720b87aa 100644 (file)
@@ -2,35 +2,35 @@
 #define fooqueryschedhfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
-typedef struct AvahiQueryScheduler AvahiQueryScheduler;
+typedef struct CattaQueryScheduler CattaQueryScheduler;
 
-#include <avahi/address.h>
+#include <catta/address.h>
 #include "iface.h"
 
-AvahiQueryScheduler *avahi_query_scheduler_new(AvahiInterface *i);
-void avahi_query_scheduler_free(AvahiQueryScheduler *s);
-void avahi_query_scheduler_clear(AvahiQueryScheduler *s);
+CattaQueryScheduler *catta_query_scheduler_new(CattaInterface *i);
+void catta_query_scheduler_free(CattaQueryScheduler *s);
+void catta_query_scheduler_clear(CattaQueryScheduler *s);
 
-int avahi_query_scheduler_post(AvahiQueryScheduler *s, AvahiKey *key, int immediately, unsigned *ret_id);
-int avahi_query_scheduler_withdraw_by_id(AvahiQueryScheduler *s, unsigned id);
-void avahi_query_scheduler_incoming(AvahiQueryScheduler *s, AvahiKey *key);
+int catta_query_scheduler_post(CattaQueryScheduler *s, CattaKey *key, int immediately, unsigned *ret_id);
+int catta_query_scheduler_withdraw_by_id(CattaQueryScheduler *s, unsigned id);
+void catta_query_scheduler_incoming(CattaQueryScheduler *s, CattaKey *key);
 
 #endif
index f24bee95753fdfbfc6a0dedd4577e76fceca4b95..48dba8d0da488eb4e4f97c1c6ddbc5597ce399be 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 #include <stdlib.h>
 
-#include <avahi/timeval.h>
-#include <avahi/malloc.h>
-#include <avahi/error.h>
-#include <avahi/domain.h>
+#include <catta/timeval.h>
+#include <catta/malloc.h>
+#include <catta/error.h>
+#include <catta/domain.h>
 
 #include "browse.h"
 
 #define TIMEOUT_MSEC 5000
 
-struct AvahiSAddressResolver {
-    AvahiServer *server;
-    AvahiAddress address;
+struct CattaSAddressResolver {
+    CattaServer *server;
+    CattaAddress address;
 
-    AvahiSRecordBrowser *record_browser;
+    CattaSRecordBrowser *record_browser;
 
-    AvahiSAddressResolverCallback callback;
+    CattaSAddressResolverCallback callback;
     void* userdata;
 
-    AvahiRecord *ptr_record;
-    AvahiIfIndex interface;
-    AvahiProtocol protocol;
-    AvahiLookupResultFlags flags;
+    CattaRecord *ptr_record;
+    CattaIfIndex interface;
+    CattaProtocol protocol;
+    CattaLookupResultFlags flags;
 
     int retry_with_multicast;
-    AvahiKey *key;
+    CattaKey *key;
 
-    AvahiTimeEvent *time_event;
+    CattaTimeEvent *time_event;
 
-    AVAHI_LLIST_FIELDS(AvahiSAddressResolver, resolver);
+    CATTA_LLIST_FIELDS(CattaSAddressResolver, resolver);
 };
 
-static void finish(AvahiSAddressResolver *r, AvahiResolverEvent event) {
+static void finish(CattaSAddressResolver *r, CattaResolverEvent event) {
     assert(r);
 
     if (r->time_event) {
-        avahi_time_event_free(r->time_event);
+        catta_time_event_free(r->time_event);
         r->time_event = NULL;
     }
 
     switch (event) {
-        case AVAHI_RESOLVER_FAILURE:
+        case CATTA_RESOLVER_FAILURE:
             r->callback(r, r->interface, r->protocol, event, &r->address, NULL, r->flags, r->userdata);
             break;
 
-        case AVAHI_RESOLVER_FOUND:
+        case CATTA_RESOLVER_FOUND:
             assert(r->ptr_record);
             r->callback(r, r->interface, r->protocol, event, &r->address, r->ptr_record->data.ptr.name, r->flags, r->userdata);
             break;
     }
 }
 
-static void time_event_callback(AvahiTimeEvent *e, void *userdata) {
-    AvahiSAddressResolver *r = userdata;
+static void time_event_callback(CattaTimeEvent *e, void *userdata) {
+    CattaSAddressResolver *r = userdata;
 
     assert(e);
     assert(r);
 
-    avahi_server_set_errno(r->server, AVAHI_ERR_TIMEOUT);
-    finish(r, AVAHI_RESOLVER_FAILURE);
+    catta_server_set_errno(r->server, CATTA_ERR_TIMEOUT);
+    finish(r, CATTA_RESOLVER_FAILURE);
 }
 
-static void start_timeout(AvahiSAddressResolver *r) {
+static void start_timeout(CattaSAddressResolver *r) {
     struct timeval tv;
     assert(r);
 
     if (r->time_event)
         return;
 
-    avahi_elapse_time(&tv, TIMEOUT_MSEC, 0);
-    r->time_event = avahi_time_event_new(r->server->time_event_queue, &tv, time_event_callback, r);
+    catta_elapse_time(&tv, TIMEOUT_MSEC, 0);
+    r->time_event = catta_time_event_new(r->server->time_event_queue, &tv, time_event_callback, r);
 }
 
 static void record_browser_callback(
-    AvahiSRecordBrowser*rr,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiBrowserEvent event,
-    AvahiRecord *record,
-    AvahiLookupResultFlags flags,
+    CattaSRecordBrowser*rr,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaBrowserEvent event,
+    CattaRecord *record,
+    CattaLookupResultFlags flags,
     void* userdata) {
 
-    AvahiSAddressResolver *r = userdata;
+    CattaSAddressResolver *r = userdata;
 
     assert(rr);
     assert(r);
 
     switch (event) {
-        case AVAHI_BROWSER_NEW:
+        case CATTA_BROWSER_NEW:
             assert(record);
-            assert(record->key->type == AVAHI_DNS_TYPE_PTR);
+            assert(record->key->type == CATTA_DNS_TYPE_PTR);
 
             if (r->interface > 0 && interface != r->interface)
                 return;
 
-            if (r->protocol != AVAHI_PROTO_UNSPEC && protocol != r->protocol)
+            if (r->protocol != CATTA_PROTO_UNSPEC && protocol != r->protocol)
                 return;
 
             if (r->interface <= 0)
                 r->interface = interface;
 
-            if (r->protocol == AVAHI_PROTO_UNSPEC)
+            if (r->protocol == CATTA_PROTO_UNSPEC)
                 r->protocol = protocol;
 
             if (!r->ptr_record) {
-                r->ptr_record = avahi_record_ref(record);
+                r->ptr_record = catta_record_ref(record);
                 r->flags = flags;
 
-                finish(r, AVAHI_RESOLVER_FOUND);
+                finish(r, CATTA_RESOLVER_FOUND);
             }
             break;
 
-        case AVAHI_BROWSER_REMOVE:
+        case CATTA_BROWSER_REMOVE:
             assert(record);
-            assert(record->key->type == AVAHI_DNS_TYPE_PTR);
+            assert(record->key->type == CATTA_DNS_TYPE_PTR);
 
-            if (r->ptr_record && avahi_record_equal_no_ttl(record, r->ptr_record)) {
-                avahi_record_unref(r->ptr_record);
+            if (r->ptr_record && catta_record_equal_no_ttl(record, r->ptr_record)) {
+                catta_record_unref(r->ptr_record);
                 r->ptr_record = NULL;
                 r->flags = flags;
 
                 /** Look for a replacement */
-                avahi_s_record_browser_restart(r->record_browser);
+                catta_s_record_browser_restart(r->record_browser);
                 start_timeout(r);
             }
 
             break;
 
-        case AVAHI_BROWSER_CACHE_EXHAUSTED:
-        case AVAHI_BROWSER_ALL_FOR_NOW:
+        case CATTA_BROWSER_CACHE_EXHAUSTED:
+        case CATTA_BROWSER_ALL_FOR_NOW:
             break;
 
-        case AVAHI_BROWSER_FAILURE:
+        case CATTA_BROWSER_FAILURE:
 
             if (r->retry_with_multicast) {
                 r->retry_with_multicast = 0;
 
-                avahi_s_record_browser_free(r->record_browser);
-                r->record_browser = avahi_s_record_browser_new(r->server, r->interface, r->protocol, r->key, AVAHI_LOOKUP_USE_MULTICAST, record_browser_callback, r);
+                catta_s_record_browser_free(r->record_browser);
+                r->record_browser = catta_s_record_browser_new(r->server, r->interface, r->protocol, r->key, CATTA_LOOKUP_USE_MULTICAST, record_browser_callback, r);
 
                 if (r->record_browser) {
                     start_timeout(r);
@@ -169,43 +169,43 @@ static void record_browser_callback(
             }
 
             r->flags = flags;
-            finish(r, AVAHI_RESOLVER_FAILURE);
+            finish(r, CATTA_RESOLVER_FAILURE);
             break;
     }
 }
 
-AvahiSAddressResolver *avahi_s_address_resolver_new(
-    AvahiServer *server,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    const AvahiAddress *address,
-    AvahiLookupFlags flags,
-    AvahiSAddressResolverCallback callback,
+CattaSAddressResolver *catta_s_address_resolver_new(
+    CattaServer *server,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    const CattaAddress *address,
+    CattaLookupFlags flags,
+    CattaSAddressResolverCallback callback,
     void* userdata) {
 
-    AvahiSAddressResolver *r;
-    AvahiKey *k;
-    char n[AVAHI_DOMAIN_NAME_MAX];
+    CattaSAddressResolver *r;
+    CattaKey *k;
+    char n[CATTA_DOMAIN_NAME_MAX];
 
     assert(server);
     assert(address);
     assert(callback);
 
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, address->proto == AVAHI_PROTO_INET || address->proto == AVAHI_PROTO_INET6, AVAHI_ERR_INVALID_PROTOCOL);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_FLAGS_VALID(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, address->proto == CATTA_PROTO_INET || address->proto == CATTA_PROTO_INET6, CATTA_ERR_INVALID_PROTOCOL);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_FLAGS_VALID(flags, CATTA_LOOKUP_USE_WIDE_AREA|CATTA_LOOKUP_USE_MULTICAST), CATTA_ERR_INVALID_FLAGS);
 
-    avahi_reverse_lookup_name(address, n, sizeof(n));
+    catta_reverse_lookup_name(address, n, sizeof(n));
 
-    if (!(k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR))) {
-        avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
+    if (!(k = catta_key_new(n, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_PTR))) {
+        catta_server_set_errno(server, CATTA_ERR_NO_MEMORY);
         return NULL;
     }
 
-    if (!(r = avahi_new(AvahiSAddressResolver, 1))) {
-        avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
-        avahi_key_unref(k);
+    if (!(r = catta_new(CattaSAddressResolver, 1))) {
+        catta_server_set_errno(server, CATTA_ERR_NO_MEMORY);
+        catta_key_unref(k);
         return NULL;
     }
 
@@ -221,24 +221,24 @@ AvahiSAddressResolver *avahi_s_address_resolver_new(
     r->key = k;
 
     r->record_browser = NULL;
-    AVAHI_LLIST_PREPEND(AvahiSAddressResolver, resolver, server->address_resolvers, r);
+    CATTA_LLIST_PREPEND(CattaSAddressResolver, resolver, server->address_resolvers, r);
 
     r->time_event = NULL;
 
-    if (!(flags & (AVAHI_LOOKUP_USE_MULTICAST|AVAHI_LOOKUP_USE_WIDE_AREA))) {
+    if (!(flags & (CATTA_LOOKUP_USE_MULTICAST|CATTA_LOOKUP_USE_WIDE_AREA))) {
 
-        if (!server->wide_area_lookup_engine || !avahi_wide_area_has_servers(server->wide_area_lookup_engine))
-            flags |= AVAHI_LOOKUP_USE_MULTICAST;
+        if (!server->wide_area_lookup_engine || !catta_wide_area_has_servers(server->wide_area_lookup_engine))
+            flags |= CATTA_LOOKUP_USE_MULTICAST;
         else {
-            flags |= AVAHI_LOOKUP_USE_WIDE_AREA;
+            flags |= CATTA_LOOKUP_USE_WIDE_AREA;
             r->retry_with_multicast = 1;
         }
     }
 
-    r->record_browser = avahi_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, r);
+    r->record_browser = catta_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, r);
 
     if (!r->record_browser) {
-        avahi_s_address_resolver_free(r);
+        catta_s_address_resolver_free(r);
         return NULL;
     }
 
@@ -247,22 +247,22 @@ AvahiSAddressResolver *avahi_s_address_resolver_new(
     return r;
 }
 
-void avahi_s_address_resolver_free(AvahiSAddressResolver *r) {
+void catta_s_address_resolver_free(CattaSAddressResolver *r) {
     assert(r);
 
-    AVAHI_LLIST_REMOVE(AvahiSAddressResolver, resolver, r->server->address_resolvers, r);
+    CATTA_LLIST_REMOVE(CattaSAddressResolver, resolver, r->server->address_resolvers, r);
 
     if (r->record_browser)
-        avahi_s_record_browser_free(r->record_browser);
+        catta_s_record_browser_free(r->record_browser);
 
     if (r->time_event)
-        avahi_time_event_free(r->time_event);
+        catta_time_event_free(r->time_event);
 
     if (r->ptr_record)
-        avahi_record_unref(r->ptr_record);
+        catta_record_unref(r->ptr_record);
 
     if (r->key)
-        avahi_key_unref(r->key);
+        catta_key_unref(r->key);
 
-    avahi_free(r);
+    catta_free(r);
 }
index cf685ad362e9b53ce790edf6b10b9ef52ba8d4ec..24629bcc180e4d54723f43a72b9dafc32f75ecfc 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 #include <stdlib.h>
 
-#include <avahi/domain.h>
-#include <avahi/timeval.h>
-#include <avahi/malloc.h>
-#include <avahi/error.h>
+#include <catta/domain.h>
+#include <catta/timeval.h>
+#include <catta/malloc.h>
+#include <catta/error.h>
 
 #include "browse.h"
-#include <avahi/log.h>
+#include <catta/log.h>
 
 #define TIMEOUT_MSEC 5000
 
-struct AvahiSHostNameResolver {
-    AvahiServer *server;
+struct CattaSHostNameResolver {
+    CattaServer *server;
     char *host_name;
 
-    AvahiSRecordBrowser *record_browser_a;
-    AvahiSRecordBrowser *record_browser_aaaa;
+    CattaSRecordBrowser *record_browser_a;
+    CattaSRecordBrowser *record_browser_aaaa;
 
-    AvahiSHostNameResolverCallback callback;
+    CattaSHostNameResolverCallback callback;
     void* userdata;
 
-    AvahiRecord *address_record;
-    AvahiIfIndex interface;
-    AvahiProtocol protocol;
-    AvahiLookupResultFlags flags;
+    CattaRecord *address_record;
+    CattaIfIndex interface;
+    CattaProtocol protocol;
+    CattaLookupResultFlags flags;
 
-    AvahiTimeEvent *time_event;
+    CattaTimeEvent *time_event;
 
-    AVAHI_LLIST_FIELDS(AvahiSHostNameResolver, resolver);
+    CATTA_LLIST_FIELDS(CattaSHostNameResolver, resolver);
 };
 
-static void finish(AvahiSHostNameResolver *r, AvahiResolverEvent event) {
+static void finish(CattaSHostNameResolver *r, CattaResolverEvent event) {
     assert(r);
 
     if (r->time_event) {
-        avahi_time_event_free(r->time_event);
+        catta_time_event_free(r->time_event);
         r->time_event = NULL;
     }
 
     switch (event) {
-        case AVAHI_RESOLVER_FOUND: {
-            AvahiAddress a;
+        case CATTA_RESOLVER_FOUND: {
+            CattaAddress a;
 
             assert(r->address_record);
 
             switch (r->address_record->key->type) {
-                case AVAHI_DNS_TYPE_A:
-                    a.proto = AVAHI_PROTO_INET;
+                case CATTA_DNS_TYPE_A:
+                    a.proto = CATTA_PROTO_INET;
                     a.data.ipv4 = r->address_record->data.a.address;
                     break;
 
-                case AVAHI_DNS_TYPE_AAAA:
-                    a.proto = AVAHI_PROTO_INET6;
+                case CATTA_DNS_TYPE_AAAA:
+                    a.proto = CATTA_PROTO_INET6;
                     a.data.ipv6 = r->address_record->data.aaaa.address;
                     break;
 
@@ -82,87 +82,87 @@ static void finish(AvahiSHostNameResolver *r, AvahiResolverEvent event) {
                     abort();
             }
 
-            r->callback(r, r->interface, r->protocol, AVAHI_RESOLVER_FOUND, r->address_record->key->name, &a, r->flags, r->userdata);
+            r->callback(r, r->interface, r->protocol, CATTA_RESOLVER_FOUND, r->address_record->key->name, &a, r->flags, r->userdata);
             break;
 
         }
 
-        case AVAHI_RESOLVER_FAILURE:
+        case CATTA_RESOLVER_FAILURE:
 
             r->callback(r, r->interface, r->protocol, event, r->host_name, NULL, r->flags, r->userdata);
             break;
     }
 }
 
-static void time_event_callback(AvahiTimeEvent *e, void *userdata) {
-    AvahiSHostNameResolver *r = userdata;
+static void time_event_callback(CattaTimeEvent *e, void *userdata) {
+    CattaSHostNameResolver *r = userdata;
 
     assert(e);
     assert(r);
 
-    avahi_server_set_errno(r->server, AVAHI_ERR_TIMEOUT);
-    finish(r, AVAHI_RESOLVER_FAILURE);
+    catta_server_set_errno(r->server, CATTA_ERR_TIMEOUT);
+    finish(r, CATTA_RESOLVER_FAILURE);
 }
 
-static void start_timeout(AvahiSHostNameResolver *r) {
+static void start_timeout(CattaSHostNameResolver *r) {
     struct timeval tv;
     assert(r);
 
     if (r->time_event)
         return;
 
-    avahi_elapse_time(&tv, TIMEOUT_MSEC, 0);
+    catta_elapse_time(&tv, TIMEOUT_MSEC, 0);
 
-    r->time_event = avahi_time_event_new(r->server->time_event_queue, &tv, time_event_callback, r);
+    r->time_event = catta_time_event_new(r->server->time_event_queue, &tv, time_event_callback, r);
 }
 
 static void record_browser_callback(
-    AvahiSRecordBrowser*rr,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiBrowserEvent event,
-    AvahiRecord *record,
-    AvahiLookupResultFlags flags,
+    CattaSRecordBrowser*rr,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaBrowserEvent event,
+    CattaRecord *record,
+    CattaLookupResultFlags flags,
     void* userdata) {
 
-    AvahiSHostNameResolver *r = userdata;
+    CattaSHostNameResolver *r = userdata;
 
     assert(rr);
     assert(r);
 
 
     switch (event) {
-        case AVAHI_BROWSER_NEW:
+        case CATTA_BROWSER_NEW:
             assert(record);
-            assert(record->key->type == AVAHI_DNS_TYPE_A || record->key->type == AVAHI_DNS_TYPE_AAAA);
+            assert(record->key->type == CATTA_DNS_TYPE_A || record->key->type == CATTA_DNS_TYPE_AAAA);
 
             if (r->interface > 0 && interface != r->interface)
                 return;
 
-            if (r->protocol != AVAHI_PROTO_UNSPEC && protocol != r->protocol)
+            if (r->protocol != CATTA_PROTO_UNSPEC && protocol != r->protocol)
                 return;
 
             if (r->interface <= 0)
                 r->interface = interface;
 
-            if (r->protocol == AVAHI_PROTO_UNSPEC)
+            if (r->protocol == CATTA_PROTO_UNSPEC)
                 r->protocol = protocol;
 
             if (!r->address_record) {
-                r->address_record = avahi_record_ref(record);
+                r->address_record = catta_record_ref(record);
                 r->flags = flags;
 
-                finish(r, AVAHI_RESOLVER_FOUND);
+                finish(r, CATTA_RESOLVER_FOUND);
             }
 
             break;
 
-        case AVAHI_BROWSER_REMOVE:
+        case CATTA_BROWSER_REMOVE:
             assert(record);
-            assert(record->key->type == AVAHI_DNS_TYPE_A || record->key->type == AVAHI_DNS_TYPE_AAAA);
+            assert(record->key->type == CATTA_DNS_TYPE_A || record->key->type == CATTA_DNS_TYPE_AAAA);
 
-            if (r->address_record && avahi_record_equal_no_ttl(record, r->address_record)) {
-                avahi_record_unref(r->address_record);
+            if (r->address_record && catta_record_equal_no_ttl(record, r->address_record)) {
+                catta_record_unref(r->address_record);
                 r->address_record = NULL;
 
                 r->flags = flags;
@@ -170,67 +170,67 @@ static void record_browser_callback(
 
                 /** Look for a replacement */
                 if (r->record_browser_aaaa)
-                    avahi_s_record_browser_restart(r->record_browser_aaaa);
+                    catta_s_record_browser_restart(r->record_browser_aaaa);
                 if (r->record_browser_a)
-                    avahi_s_record_browser_restart(r->record_browser_a);
+                    catta_s_record_browser_restart(r->record_browser_a);
 
                 start_timeout(r);
             }
 
             break;
 
-        case AVAHI_BROWSER_CACHE_EXHAUSTED:
-        case AVAHI_BROWSER_ALL_FOR_NOW:
+        case CATTA_BROWSER_CACHE_EXHAUSTED:
+        case CATTA_BROWSER_ALL_FOR_NOW:
             /* Ignore */
             break;
 
-        case AVAHI_BROWSER_FAILURE:
+        case CATTA_BROWSER_FAILURE:
 
             /* Stop browsers */
 
             if (r->record_browser_aaaa)
-                avahi_s_record_browser_free(r->record_browser_aaaa);
+                catta_s_record_browser_free(r->record_browser_aaaa);
             if (r->record_browser_a)
-                avahi_s_record_browser_free(r->record_browser_a);
+                catta_s_record_browser_free(r->record_browser_a);
 
             r->record_browser_a = r->record_browser_aaaa = NULL;
             r->flags = flags;
 
-            finish(r, AVAHI_RESOLVER_FAILURE);
+            finish(r, CATTA_RESOLVER_FAILURE);
             break;
     }
 }
 
-AvahiSHostNameResolver *avahi_s_host_name_resolver_new(
-    AvahiServer *server,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
+CattaSHostNameResolver *catta_s_host_name_resolver_new(
+    CattaServer *server,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
     const char *host_name,
-    AvahiProtocol aprotocol,
-    AvahiLookupFlags flags,
-    AvahiSHostNameResolverCallback callback,
+    CattaProtocol aprotocol,
+    CattaLookupFlags flags,
+    CattaSHostNameResolverCallback callback,
     void* userdata) {
 
-    AvahiSHostNameResolver *r;
-    AvahiKey *k;
+    CattaSHostNameResolver *r;
+    CattaKey *k;
 
     assert(server);
     assert(host_name);
     assert(callback);
 
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, avahi_is_valid_fqdn(host_name), AVAHI_ERR_INVALID_HOST_NAME);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_PROTO_VALID(aprotocol), AVAHI_ERR_INVALID_PROTOCOL);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_FLAGS_VALID(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, catta_is_valid_fqdn(host_name), CATTA_ERR_INVALID_HOST_NAME);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_PROTO_VALID(aprotocol), CATTA_ERR_INVALID_PROTOCOL);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_FLAGS_VALID(flags, CATTA_LOOKUP_USE_WIDE_AREA|CATTA_LOOKUP_USE_MULTICAST), CATTA_ERR_INVALID_FLAGS);
 
-    if (!(r = avahi_new(AvahiSHostNameResolver, 1))) {
-        avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
+    if (!(r = catta_new(CattaSHostNameResolver, 1))) {
+        catta_server_set_errno(server, CATTA_ERR_NO_MEMORY);
         return NULL;
     }
 
     r->server = server;
-    r->host_name = avahi_normalize_name_strdup(host_name);
+    r->host_name = catta_normalize_name_strdup(host_name);
     r->callback = callback;
     r->userdata = userdata;
     r->address_record = NULL;
@@ -242,23 +242,23 @@ AvahiSHostNameResolver *avahi_s_host_name_resolver_new(
 
     r->time_event = NULL;
 
-    AVAHI_LLIST_PREPEND(AvahiSHostNameResolver, resolver, server->host_name_resolvers, r);
+    CATTA_LLIST_PREPEND(CattaSHostNameResolver, resolver, server->host_name_resolvers, r);
 
     r->record_browser_aaaa = r->record_browser_a = NULL;
 
-    if (aprotocol == AVAHI_PROTO_INET || aprotocol == AVAHI_PROTO_UNSPEC) {
-        k = avahi_key_new(host_name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_A);
-        r->record_browser_a = avahi_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, r);
-        avahi_key_unref(k);
+    if (aprotocol == CATTA_PROTO_INET || aprotocol == CATTA_PROTO_UNSPEC) {
+        k = catta_key_new(host_name, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_A);
+        r->record_browser_a = catta_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, r);
+        catta_key_unref(k);
 
         if (!r->record_browser_a)
             goto fail;
     }
 
-    if (aprotocol == AVAHI_PROTO_INET6 || aprotocol == AVAHI_PROTO_UNSPEC) {
-        k = avahi_key_new(host_name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_AAAA);
-        r->record_browser_aaaa = avahi_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, r);
-        avahi_key_unref(k);
+    if (aprotocol == CATTA_PROTO_INET6 || aprotocol == CATTA_PROTO_UNSPEC) {
+        k = catta_key_new(host_name, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_AAAA);
+        r->record_browser_aaaa = catta_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, r);
+        catta_key_unref(k);
 
         if (!r->record_browser_aaaa)
             goto fail;
@@ -271,27 +271,27 @@ AvahiSHostNameResolver *avahi_s_host_name_resolver_new(
     return r;
 
 fail:
-    avahi_s_host_name_resolver_free(r);
+    catta_s_host_name_resolver_free(r);
     return NULL;
 }
 
-void avahi_s_host_name_resolver_free(AvahiSHostNameResolver *r) {
+void catta_s_host_name_resolver_free(CattaSHostNameResolver *r) {
     assert(r);
 
-    AVAHI_LLIST_REMOVE(AvahiSHostNameResolver, resolver, r->server->host_name_resolvers, r);
+    CATTA_LLIST_REMOVE(CattaSHostNameResolver, resolver, r->server->host_name_resolvers, r);
 
     if (r->record_browser_a)
-        avahi_s_record_browser_free(r->record_browser_a);
+        catta_s_record_browser_free(r->record_browser_a);
 
     if (r->record_browser_aaaa)
-        avahi_s_record_browser_free(r->record_browser_aaaa);
+        catta_s_record_browser_free(r->record_browser_aaaa);
 
     if (r->time_event)
-        avahi_time_event_free(r->time_event);
+        catta_time_event_free(r->time_event);
 
     if (r->address_record)
-        avahi_record_unref(r->address_record);
+        catta_record_unref(r->address_record);
 
-    avahi_free(r->host_name);
-    avahi_free(r);
+    catta_free(r->host_name);
+    catta_free(r);
 }
index 6625c285a54e362907beb68acf52809763bf9d12..683c85d124b6d60e73a6c677961622f7e53ae6ea 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <avahi/domain.h>
-#include <avahi/timeval.h>
-#include <avahi/malloc.h>
-#include <avahi/error.h>
+#include <catta/domain.h>
+#include <catta/timeval.h>
+#include <catta/malloc.h>
+#include <catta/error.h>
 
 #include "browse.h"
-#include <avahi/log.h>
+#include <catta/log.h>
 
 #define TIMEOUT_MSEC 5000
 
-struct AvahiSServiceResolver {
-    AvahiServer *server;
+struct CattaSServiceResolver {
+    CattaServer *server;
     char *service_name;
     char *service_type;
     char *domain_name;
-    AvahiProtocol address_protocol;
+    CattaProtocol address_protocol;
 
-    AvahiIfIndex interface;
-    AvahiProtocol protocol;
+    CattaIfIndex interface;
+    CattaProtocol protocol;
 
-    AvahiSRecordBrowser *record_browser_srv;
-    AvahiSRecordBrowser *record_browser_txt;
-    AvahiSRecordBrowser *record_browser_a;
-    AvahiSRecordBrowser *record_browser_aaaa;
+    CattaSRecordBrowser *record_browser_srv;
+    CattaSRecordBrowser *record_browser_txt;
+    CattaSRecordBrowser *record_browser_a;
+    CattaSRecordBrowser *record_browser_aaaa;
 
-    AvahiRecord *srv_record, *txt_record, *address_record;
-    AvahiLookupResultFlags srv_flags, txt_flags, address_flags;
+    CattaRecord *srv_record, *txt_record, *address_record;
+    CattaLookupResultFlags srv_flags, txt_flags, address_flags;
 
-    AvahiSServiceResolverCallback callback;
+    CattaSServiceResolverCallback callback;
     void* userdata;
-    AvahiLookupFlags user_flags;
+    CattaLookupFlags user_flags;
 
-    AvahiTimeEvent *time_event;
+    CattaTimeEvent *time_event;
 
-    AVAHI_LLIST_FIELDS(AvahiSServiceResolver, resolver);
+    CATTA_LLIST_FIELDS(CattaSServiceResolver, resolver);
 };
 
-static void finish(AvahiSServiceResolver *r, AvahiResolverEvent event) {
-    AvahiLookupResultFlags flags;
+static void finish(CattaSServiceResolver *r, CattaResolverEvent event) {
+    CattaLookupResultFlags flags;
 
     assert(r);
 
     if (r->time_event) {
-        avahi_time_event_free(r->time_event);
+        catta_time_event_free(r->time_event);
         r->time_event = NULL;
     }
 
@@ -78,7 +78,7 @@ static void finish(AvahiSServiceResolver *r, AvahiResolverEvent event) {
         r->address_flags;
 
     switch (event) {
-        case AVAHI_RESOLVER_FAILURE:
+        case CATTA_RESOLVER_FAILURE:
 
             r->callback(
                 r,
@@ -97,22 +97,22 @@ static void finish(AvahiSServiceResolver *r, AvahiResolverEvent event) {
 
             break;
 
-        case AVAHI_RESOLVER_FOUND: {
-            AvahiAddress a;
+        case CATTA_RESOLVER_FOUND: {
+            CattaAddress a;
 
-            assert(event == AVAHI_RESOLVER_FOUND);
+            assert(event == CATTA_RESOLVER_FOUND);
 
             assert(r->srv_record);
 
             if (r->address_record) {
                 switch (r->address_record->key->type) {
-                    case AVAHI_DNS_TYPE_A:
-                        a.proto = AVAHI_PROTO_INET;
+                    case CATTA_DNS_TYPE_A:
+                        a.proto = CATTA_PROTO_INET;
                         a.data.ipv4 = r->address_record->data.a.address;
                         break;
 
-                    case AVAHI_DNS_TYPE_AAAA:
-                        a.proto = AVAHI_PROTO_INET6;
+                    case CATTA_DNS_TYPE_AAAA:
+                        a.proto = CATTA_PROTO_INET6;
                         a.data.ipv6 = r->address_record->data.aaaa.address;
                         break;
 
@@ -141,38 +141,38 @@ static void finish(AvahiSServiceResolver *r, AvahiResolverEvent event) {
     }
 }
 
-static void time_event_callback(AvahiTimeEvent *e, void *userdata) {
-    AvahiSServiceResolver *r = userdata;
+static void time_event_callback(CattaTimeEvent *e, void *userdata) {
+    CattaSServiceResolver *r = userdata;
 
     assert(e);
     assert(r);
 
-    avahi_server_set_errno(r->server, AVAHI_ERR_TIMEOUT);
-    finish(r, AVAHI_RESOLVER_FAILURE);
+    catta_server_set_errno(r->server, CATTA_ERR_TIMEOUT);
+    finish(r, CATTA_RESOLVER_FAILURE);
 }
 
-static void start_timeout(AvahiSServiceResolver *r) {
+static void start_timeout(CattaSServiceResolver *r) {
     struct timeval tv;
     assert(r);
 
     if (r->time_event)
         return;
 
-    avahi_elapse_time(&tv, TIMEOUT_MSEC, 0);
+    catta_elapse_time(&tv, TIMEOUT_MSEC, 0);
 
-    r->time_event = avahi_time_event_new(r->server->time_event_queue, &tv, time_event_callback, r);
+    r->time_event = catta_time_event_new(r->server->time_event_queue, &tv, time_event_callback, r);
 }
 
 static void record_browser_callback(
-    AvahiSRecordBrowser*rr,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiBrowserEvent event,
-    AvahiRecord *record,
-    AvahiLookupResultFlags flags,
+    CattaSRecordBrowser*rr,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaBrowserEvent event,
+    CattaRecord *record,
+    CattaLookupResultFlags flags,
     void* userdata) {
 
-    AvahiSServiceResolver *r = userdata;
+    CattaSServiceResolver *r = userdata;
 
     assert(rr);
     assert(r);
@@ -186,72 +186,72 @@ static void record_browser_callback(
 
     switch (event) {
 
-        case AVAHI_BROWSER_NEW: {
+        case CATTA_BROWSER_NEW: {
             int changed = 0;
             assert(record);
 
             if (r->interface > 0 && interface > 0 &&  interface != r->interface)
                 return;
 
-            if (r->protocol != AVAHI_PROTO_UNSPEC && protocol != AVAHI_PROTO_UNSPEC && protocol != r->protocol)
+            if (r->protocol != CATTA_PROTO_UNSPEC && protocol != CATTA_PROTO_UNSPEC && protocol != r->protocol)
                 return;
 
             if (r->interface <= 0)
                 r->interface = interface;
 
-            if (r->protocol == AVAHI_PROTO_UNSPEC)
+            if (r->protocol == CATTA_PROTO_UNSPEC)
                 r->protocol = protocol;
 
             switch (record->key->type) {
-                case AVAHI_DNS_TYPE_SRV:
+                case CATTA_DNS_TYPE_SRV:
                     if (!r->srv_record) {
-                        r->srv_record = avahi_record_ref(record);
+                        r->srv_record = catta_record_ref(record);
                         changed = 1;
 
                         if (r->record_browser_a) {
-                            avahi_s_record_browser_free(r->record_browser_a);
+                            catta_s_record_browser_free(r->record_browser_a);
                             r->record_browser_a = NULL;
                         }
 
                         if (r->record_browser_aaaa) {
-                            avahi_s_record_browser_free(r->record_browser_aaaa);
+                            catta_s_record_browser_free(r->record_browser_aaaa);
                             r->record_browser_aaaa = NULL;
                         }
 
-                        if (!(r->user_flags & AVAHI_LOOKUP_NO_ADDRESS)) {
+                        if (!(r->user_flags & CATTA_LOOKUP_NO_ADDRESS)) {
 
-                            if (r->address_protocol == AVAHI_PROTO_INET || r->address_protocol == AVAHI_PROTO_UNSPEC) {
-                                AvahiKey *k = avahi_key_new(r->srv_record->data.srv.name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_A);
-                                r->record_browser_a = avahi_s_record_browser_new(r->server, r->interface, r->protocol, k, r->user_flags & ~(AVAHI_LOOKUP_NO_TXT|AVAHI_LOOKUP_NO_ADDRESS), record_browser_callback, r);
-                                avahi_key_unref(k);
+                            if (r->address_protocol == CATTA_PROTO_INET || r->address_protocol == CATTA_PROTO_UNSPEC) {
+                                CattaKey *k = catta_key_new(r->srv_record->data.srv.name, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_A);
+                                r->record_browser_a = catta_s_record_browser_new(r->server, r->interface, r->protocol, k, r->user_flags & ~(CATTA_LOOKUP_NO_TXT|CATTA_LOOKUP_NO_ADDRESS), record_browser_callback, r);
+                                catta_key_unref(k);
                             }
 
-                            if (r->address_protocol == AVAHI_PROTO_INET6 || r->address_protocol == AVAHI_PROTO_UNSPEC) {
-                                AvahiKey *k = avahi_key_new(r->srv_record->data.srv.name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_AAAA);
-                                r->record_browser_aaaa = avahi_s_record_browser_new(r->server, r->interface, r->protocol, k, r->user_flags & ~(AVAHI_LOOKUP_NO_TXT|AVAHI_LOOKUP_NO_ADDRESS), record_browser_callback, r);
-                                avahi_key_unref(k);
+                            if (r->address_protocol == CATTA_PROTO_INET6 || r->address_protocol == CATTA_PROTO_UNSPEC) {
+                                CattaKey *k = catta_key_new(r->srv_record->data.srv.name, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_AAAA);
+                                r->record_browser_aaaa = catta_s_record_browser_new(r->server, r->interface, r->protocol, k, r->user_flags & ~(CATTA_LOOKUP_NO_TXT|CATTA_LOOKUP_NO_ADDRESS), record_browser_callback, r);
+                                catta_key_unref(k);
                             }
                         }
                     }
                     break;
 
-                case AVAHI_DNS_TYPE_TXT:
+                case CATTA_DNS_TYPE_TXT:
 
-                    assert(!(r->user_flags & AVAHI_LOOKUP_NO_TXT));
+                    assert(!(r->user_flags & CATTA_LOOKUP_NO_TXT));
 
                     if (!r->txt_record) {
-                        r->txt_record = avahi_record_ref(record);
+                        r->txt_record = catta_record_ref(record);
                         changed = 1;
                     }
                     break;
 
-                case AVAHI_DNS_TYPE_A:
-                case AVAHI_DNS_TYPE_AAAA:
+                case CATTA_DNS_TYPE_A:
+                case CATTA_DNS_TYPE_AAAA:
 
-                    assert(!(r->user_flags & AVAHI_LOOKUP_NO_ADDRESS));
+                    assert(!(r->user_flags & CATTA_LOOKUP_NO_ADDRESS));
 
                     if (!r->address_record) {
-                        r->address_record = avahi_record_ref(record);
+                        r->address_record = catta_record_ref(record);
                         changed = 1;
                     }
                     break;
@@ -263,70 +263,70 @@ static void record_browser_callback(
 
             if (changed &&
                 r->srv_record &&
-                (r->txt_record || (r->user_flags & AVAHI_LOOKUP_NO_TXT)) &&
-                (r->address_record || (r->user_flags & AVAHI_LOOKUP_NO_ADDRESS)))
-                finish(r, AVAHI_RESOLVER_FOUND);
+                (r->txt_record || (r->user_flags & CATTA_LOOKUP_NO_TXT)) &&
+                (r->address_record || (r->user_flags & CATTA_LOOKUP_NO_ADDRESS)))
+                finish(r, CATTA_RESOLVER_FOUND);
 
             break;
 
         }
 
-        case AVAHI_BROWSER_REMOVE:
+        case CATTA_BROWSER_REMOVE:
 
             assert(record);
 
             switch (record->key->type) {
-                case AVAHI_DNS_TYPE_SRV:
+                case CATTA_DNS_TYPE_SRV:
 
-                    if (r->srv_record && avahi_record_equal_no_ttl(record, r->srv_record)) {
-                        avahi_record_unref(r->srv_record);
+                    if (r->srv_record && catta_record_equal_no_ttl(record, r->srv_record)) {
+                        catta_record_unref(r->srv_record);
                         r->srv_record = NULL;
 
                         if (r->record_browser_a) {
-                            avahi_s_record_browser_free(r->record_browser_a);
+                            catta_s_record_browser_free(r->record_browser_a);
                             r->record_browser_a = NULL;
                         }
 
                         if (r->record_browser_aaaa) {
-                            avahi_s_record_browser_free(r->record_browser_aaaa);
+                            catta_s_record_browser_free(r->record_browser_aaaa);
                             r->record_browser_aaaa = NULL;
                         }
 
                         /** Look for a replacement */
-                        avahi_s_record_browser_restart(r->record_browser_srv);
+                        catta_s_record_browser_restart(r->record_browser_srv);
                         start_timeout(r);
                     }
 
                     break;
 
-                case AVAHI_DNS_TYPE_TXT:
+                case CATTA_DNS_TYPE_TXT:
 
-                    assert(!(r->user_flags & AVAHI_LOOKUP_NO_TXT));
+                    assert(!(r->user_flags & CATTA_LOOKUP_NO_TXT));
 
-                    if (r->txt_record && avahi_record_equal_no_ttl(record, r->txt_record)) {
-                        avahi_record_unref(r->txt_record);
+                    if (r->txt_record && catta_record_equal_no_ttl(record, r->txt_record)) {
+                        catta_record_unref(r->txt_record);
                         r->txt_record = NULL;
 
                         /** Look for a replacement */
-                        avahi_s_record_browser_restart(r->record_browser_txt);
+                        catta_s_record_browser_restart(r->record_browser_txt);
                         start_timeout(r);
                     }
                     break;
 
-                case AVAHI_DNS_TYPE_A:
-                case AVAHI_DNS_TYPE_AAAA:
+                case CATTA_DNS_TYPE_A:
+                case CATTA_DNS_TYPE_AAAA:
 
-                    assert(!(r->user_flags & AVAHI_LOOKUP_NO_ADDRESS));
+                    assert(!(r->user_flags & CATTA_LOOKUP_NO_ADDRESS));
 
-                    if (r->address_record && avahi_record_equal_no_ttl(record, r->address_record)) {
-                        avahi_record_unref(r->address_record);
+                    if (r->address_record && catta_record_equal_no_ttl(record, r->address_record)) {
+                        catta_record_unref(r->address_record);
                         r->address_record = NULL;
 
                         /** Look for a replacement */
                         if (r->record_browser_aaaa)
-                            avahi_s_record_browser_restart(r->record_browser_aaaa);
+                            catta_s_record_browser_restart(r->record_browser_aaaa);
                         if (r->record_browser_a)
-                            avahi_s_record_browser_restart(r->record_browser_a);
+                            catta_s_record_browser_restart(r->record_browser_a);
                         start_timeout(r);
                     }
                     break;
@@ -337,22 +337,22 @@ static void record_browser_callback(
 
             break;
 
-        case AVAHI_BROWSER_CACHE_EXHAUSTED:
-        case AVAHI_BROWSER_ALL_FOR_NOW:
+        case CATTA_BROWSER_CACHE_EXHAUSTED:
+        case CATTA_BROWSER_ALL_FOR_NOW:
             break;
 
-        case AVAHI_BROWSER_FAILURE:
+        case CATTA_BROWSER_FAILURE:
 
             if (rr == r->record_browser_a && r->record_browser_aaaa) {
                 /* We were looking for both AAAA and A, and the other query is still living, so we'll not die */
-                avahi_s_record_browser_free(r->record_browser_a);
+                catta_s_record_browser_free(r->record_browser_a);
                 r->record_browser_a = NULL;
                 break;
             }
 
             if (rr == r->record_browser_aaaa && r->record_browser_a) {
                 /* We were looking for both AAAA and A, and the other query is still living, so we'll not die */
-                avahi_s_record_browser_free(r->record_browser_aaaa);
+                catta_s_record_browser_free(r->record_browser_aaaa);
                 r->record_browser_aaaa = NULL;
                 break;
             }
@@ -360,67 +360,67 @@ static void record_browser_callback(
             /* Hmm, everything's lost, tell the user */
 
             if (r->record_browser_srv)
-                avahi_s_record_browser_free(r->record_browser_srv);
+                catta_s_record_browser_free(r->record_browser_srv);
             if (r->record_browser_txt)
-                avahi_s_record_browser_free(r->record_browser_txt);
+                catta_s_record_browser_free(r->record_browser_txt);
             if (r->record_browser_a)
-                avahi_s_record_browser_free(r->record_browser_a);
+                catta_s_record_browser_free(r->record_browser_a);
             if (r->record_browser_aaaa)
-                avahi_s_record_browser_free(r->record_browser_aaaa);
+                catta_s_record_browser_free(r->record_browser_aaaa);
 
             r->record_browser_srv = r->record_browser_txt = r->record_browser_a = r->record_browser_aaaa = NULL;
 
-            finish(r, AVAHI_RESOLVER_FAILURE);
+            finish(r, CATTA_RESOLVER_FAILURE);
             break;
     }
 }
 
-AvahiSServiceResolver *avahi_s_service_resolver_new(
-    AvahiServer *server,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
+CattaSServiceResolver *catta_s_service_resolver_new(
+    CattaServer *server,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
     const char *name,
     const char *type,
     const char *domain,
-    AvahiProtocol aprotocol,
-    AvahiLookupFlags flags,
-    AvahiSServiceResolverCallback callback,
+    CattaProtocol aprotocol,
+    CattaLookupFlags flags,
+    CattaSServiceResolverCallback callback,
     void* userdata) {
 
-    AvahiSServiceResolver *r;
-    AvahiKey *k;
-    char n[AVAHI_DOMAIN_NAME_MAX];
+    CattaSServiceResolver *r;
+    CattaKey *k;
+    char n[CATTA_DOMAIN_NAME_MAX];
     int ret;
 
     assert(server);
     assert(type);
     assert(callback);
 
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_PROTO_VALID(aprotocol), AVAHI_ERR_INVALID_PROTOCOL);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, !name || avahi_is_valid_service_name(name), AVAHI_ERR_INVALID_SERVICE_NAME);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, avahi_is_valid_service_type_strict(type), AVAHI_ERR_INVALID_SERVICE_TYPE);
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_FLAGS_VALID(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST|AVAHI_LOOKUP_NO_TXT|AVAHI_LOOKUP_NO_ADDRESS), AVAHI_ERR_INVALID_FLAGS);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_PROTO_VALID(aprotocol), CATTA_ERR_INVALID_PROTOCOL);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, !domain || catta_is_valid_domain_name(domain), CATTA_ERR_INVALID_DOMAIN_NAME);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, !name || catta_is_valid_service_name(name), CATTA_ERR_INVALID_SERVICE_NAME);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, catta_is_valid_service_type_strict(type), CATTA_ERR_INVALID_SERVICE_TYPE);
+    CATTA_CHECK_VALIDITY_RETURN_NULL(server, CATTA_FLAGS_VALID(flags, CATTA_LOOKUP_USE_WIDE_AREA|CATTA_LOOKUP_USE_MULTICAST|CATTA_LOOKUP_NO_TXT|CATTA_LOOKUP_NO_ADDRESS), CATTA_ERR_INVALID_FLAGS);
 
     if (!domain)
         domain = server->domain_name;
 
-    if ((ret = avahi_service_name_join(n, sizeof(n), name, type, domain)) < 0) {
-        avahi_server_set_errno(server, ret);
+    if ((ret = catta_service_name_join(n, sizeof(n), name, type, domain)) < 0) {
+        catta_server_set_errno(server, ret);
         return NULL;
     }
 
-    if (!(r = avahi_new(AvahiSServiceResolver, 1))) {
-        avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
+    if (!(r = catta_new(CattaSServiceResolver, 1))) {
+        catta_server_set_errno(server, CATTA_ERR_NO_MEMORY);
         return NULL;
     }
 
     r->server = server;
-    r->service_name = avahi_strdup(name);
-    r->service_type = avahi_normalize_name_strdup(type);
-    r->domain_name = avahi_normalize_name_strdup(domain);
+    r->service_name = catta_strdup(name);
+    r->service_type = catta_normalize_name_strdup(type);
+    r->domain_name = catta_normalize_name_strdup(domain);
     r->callback = callback;
     r->userdata = userdata;
     r->address_protocol = aprotocol;
@@ -431,24 +431,24 @@ AvahiSServiceResolver *avahi_s_service_resolver_new(
     r->user_flags = flags;
     r->record_browser_a = r->record_browser_aaaa = r->record_browser_srv = r->record_browser_txt = NULL;
     r->time_event = NULL;
-    AVAHI_LLIST_PREPEND(AvahiSServiceResolver, resolver, server->service_resolvers, r);
+    CATTA_LLIST_PREPEND(CattaSServiceResolver, resolver, server->service_resolvers, r);
 
-    k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_SRV);
-    r->record_browser_srv = avahi_s_record_browser_new(server, interface, protocol, k, flags & ~(AVAHI_LOOKUP_NO_TXT|AVAHI_LOOKUP_NO_ADDRESS), record_browser_callback, r);
-    avahi_key_unref(k);
+    k = catta_key_new(n, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_SRV);
+    r->record_browser_srv = catta_s_record_browser_new(server, interface, protocol, k, flags & ~(CATTA_LOOKUP_NO_TXT|CATTA_LOOKUP_NO_ADDRESS), record_browser_callback, r);
+    catta_key_unref(k);
 
     if (!r->record_browser_srv) {
-        avahi_s_service_resolver_free(r);
+        catta_s_service_resolver_free(r);
         return NULL;
     }
 
-    if (!(flags & AVAHI_LOOKUP_NO_TXT)) {
-        k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_TXT);
-        r->record_browser_txt = avahi_s_record_browser_new(server, interface, protocol, k, flags & ~(AVAHI_LOOKUP_NO_TXT|AVAHI_LOOKUP_NO_ADDRESS),  record_browser_callback, r);
-        avahi_key_unref(k);
+    if (!(flags & CATTA_LOOKUP_NO_TXT)) {
+        k = catta_key_new(n, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_TXT);
+        r->record_browser_txt = catta_s_record_browser_new(server, interface, protocol, k, flags & ~(CATTA_LOOKUP_NO_TXT|CATTA_LOOKUP_NO_ADDRESS),  record_browser_callback, r);
+        catta_key_unref(k);
 
         if (!r->record_browser_txt) {
-            avahi_s_service_resolver_free(r);
+            catta_s_service_resolver_free(r);
             return NULL;
         }
     }
@@ -458,32 +458,32 @@ AvahiSServiceResolver *avahi_s_service_resolver_new(
     return r;
 }
 
-void avahi_s_service_resolver_free(AvahiSServiceResolver *r) {
+void catta_s_service_resolver_free(CattaSServiceResolver *r) {
     assert(r);
 
-    AVAHI_LLIST_REMOVE(AvahiSServiceResolver, resolver, r->server->service_resolvers, r);
+    CATTA_LLIST_REMOVE(CattaSServiceResolver, resolver, r->server->service_resolvers, r);
 
     if (r->time_event)
-        avahi_time_event_free(r->time_event);
+        catta_time_event_free(r->time_event);
 
     if (r->record_browser_srv)
-        avahi_s_record_browser_free(r->record_browser_srv);
+        catta_s_record_browser_free(r->record_browser_srv);
     if (r->record_browser_txt)
-        avahi_s_record_browser_free(r->record_browser_txt);
+        catta_s_record_browser_free(r->record_browser_txt);
     if (r->record_browser_a)
-        avahi_s_record_browser_free(r->record_browser_a);
+        catta_s_record_browser_free(r->record_browser_a);
     if (r->record_browser_aaaa)
-        avahi_s_record_browser_free(r->record_browser_aaaa);
+        catta_s_record_browser_free(r->record_browser_aaaa);
 
     if (r->srv_record)
-        avahi_record_unref(r->srv_record);
+        catta_record_unref(r->srv_record);
     if (r->txt_record)
-        avahi_record_unref(r->txt_record);
+        catta_record_unref(r->txt_record);
     if (r->address_record)
-        avahi_record_unref(r->address_record);
+        catta_record_unref(r->address_record);
 
-    avahi_free(r->service_name);
-    avahi_free(r->service_type);
-    avahi_free(r->domain_name);
-    avahi_free(r);
+    catta_free(r->service_name);
+    catta_free(r->service_type);
+    catta_free(r->domain_name);
+    catta_free(r);
 }
index 3d73ed4e0b41c148ae05281c298b8f90e6feb36f..fc3630d0413be9719ba1001d01f584bf56490db7 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 #include <stdlib.h>
 
-#include <avahi/timeval.h>
-#include <avahi/malloc.h>
+#include <catta/timeval.h>
+#include <catta/malloc.h>
 
 #include "response-sched.h"
-#include <avahi/log.h>
+#include <catta/log.h>
 #include "rr-util.h"
 
 /* Local packets are supressed this long after sending them */
-#define AVAHI_RESPONSE_HISTORY_MSEC 500
+#define CATTA_RESPONSE_HISTORY_MSEC 500
 
 /* Local packets are deferred this long before sending them */
-#define AVAHI_RESPONSE_DEFER_MSEC 20
+#define CATTA_RESPONSE_DEFER_MSEC 20
 
 /* Additional jitter for deferred packets */
-#define AVAHI_RESPONSE_JITTER_MSEC 100
+#define CATTA_RESPONSE_JITTER_MSEC 100
 
 /* Remote packets can suppress local traffic as long as this value */
-#define AVAHI_RESPONSE_SUPPRESS_MSEC 700
+#define CATTA_RESPONSE_SUPPRESS_MSEC 700
 
-typedef struct AvahiResponseJob AvahiResponseJob;
+typedef struct CattaResponseJob CattaResponseJob;
 
 typedef enum {
-    AVAHI_SCHEDULED,
-    AVAHI_DONE,
-    AVAHI_SUPPRESSED
-} AvahiResponseJobState;
+    CATTA_SCHEDULED,
+    CATTA_DONE,
+    CATTA_SUPPRESSED
+} CattaResponseJobState;
 
-struct AvahiResponseJob {
-    AvahiResponseScheduler *scheduler;
-    AvahiTimeEvent *time_event;
+struct CattaResponseJob {
+    CattaResponseScheduler *scheduler;
+    CattaTimeEvent *time_event;
 
-    AvahiResponseJobState state;
+    CattaResponseJobState state;
     struct timeval delivery;
 
-    AvahiRecord *record;
+    CattaRecord *record;
     int flush_cache;
-    AvahiAddress querier;
+    CattaAddress querier;
     int querier_valid;
 
-    AVAHI_LLIST_FIELDS(AvahiResponseJob, jobs);
+    CATTA_LLIST_FIELDS(CattaResponseJob, jobs);
 };
 
-struct AvahiResponseScheduler {
-    AvahiInterface *interface;
-    AvahiTimeEventQueue *time_event_queue;
+struct CattaResponseScheduler {
+    CattaInterface *interface;
+    CattaTimeEventQueue *time_event_queue;
 
-    AVAHI_LLIST_HEAD(AvahiResponseJob, jobs);
-    AVAHI_LLIST_HEAD(AvahiResponseJob, history);
-    AVAHI_LLIST_HEAD(AvahiResponseJob, suppressed);
+    CATTA_LLIST_HEAD(CattaResponseJob, jobs);
+    CATTA_LLIST_HEAD(CattaResponseJob, history);
+    CATTA_LLIST_HEAD(CattaResponseJob, suppressed);
 };
 
-static AvahiResponseJob* job_new(AvahiResponseScheduler *s, AvahiRecord *record, AvahiResponseJobState state) {
-    AvahiResponseJob *rj;
+static CattaResponseJob* job_new(CattaResponseScheduler *s, CattaRecord *record, CattaResponseJobState state) {
+    CattaResponseJob *rj;
 
     assert(s);
     assert(record);
 
-    if (!(rj = avahi_new(AvahiResponseJob, 1))) {
-        avahi_log_error(__FILE__": Out of memory");
+    if (!(rj = catta_new(CattaResponseJob, 1))) {
+        catta_log_error(__FILE__": Out of memory");
         return NULL;
     }
 
     rj->scheduler = s;
-    rj->record = avahi_record_ref(record);
+    rj->record = catta_record_ref(record);
     rj->time_event = NULL;
     rj->flush_cache = 0;
     rj->querier_valid = 0;
 
-    if ((rj->state = state) == AVAHI_SCHEDULED)
-        AVAHI_LLIST_PREPEND(AvahiResponseJob, jobs, s->jobs, rj);
-    else if (rj->state == AVAHI_DONE)
-        AVAHI_LLIST_PREPEND(AvahiResponseJob, jobs, s->history, rj);
-    else  /* rj->state == AVAHI_SUPPRESSED */
-        AVAHI_LLIST_PREPEND(AvahiResponseJob, jobs, s->suppressed, rj);
+    if ((rj->state = state) == CATTA_SCHEDULED)
+        CATTA_LLIST_PREPEND(CattaResponseJob, jobs, s->jobs, rj);
+    else if (rj->state == CATTA_DONE)
+        CATTA_LLIST_PREPEND(CattaResponseJob, jobs, s->history, rj);
+    else  /* rj->state == CATTA_SUPPRESSED */
+        CATTA_LLIST_PREPEND(CattaResponseJob, jobs, s->suppressed, rj);
 
     return rj;
 }
 
-static void job_free(AvahiResponseScheduler *s, AvahiResponseJob *rj) {
+static void job_free(CattaResponseScheduler *s, CattaResponseJob *rj) {
     assert(s);
     assert(rj);
 
     if (rj->time_event)
-        avahi_time_event_free(rj->time_event);
+        catta_time_event_free(rj->time_event);
 
-    if (rj->state == AVAHI_SCHEDULED)
-        AVAHI_LLIST_REMOVE(AvahiResponseJob, jobs, s->jobs, rj);
-    else if (rj->state == AVAHI_DONE)
-        AVAHI_LLIST_REMOVE(AvahiResponseJob, jobs, s->history, rj);
-    else /* rj->state == AVAHI_SUPPRESSED */
-        AVAHI_LLIST_REMOVE(AvahiResponseJob, jobs, s->suppressed, rj);
+    if (rj->state == CATTA_SCHEDULED)
+        CATTA_LLIST_REMOVE(CattaResponseJob, jobs, s->jobs, rj);
+    else if (rj->state == CATTA_DONE)
+        CATTA_LLIST_REMOVE(CattaResponseJob, jobs, s->history, rj);
+    else /* rj->state == CATTA_SUPPRESSED */
+        CATTA_LLIST_REMOVE(CattaResponseJob, jobs, s->suppressed, rj);
 
-    avahi_record_unref(rj->record);
-    avahi_free(rj);
+    catta_record_unref(rj->record);
+    catta_free(rj);
 }
 
-static void elapse_callback(AvahiTimeEvent *e, void* data);
+static void elapse_callback(CattaTimeEvent *e, void* data);
 
-static void job_set_elapse_time(AvahiResponseScheduler *s, AvahiResponseJob *rj, unsigned msec, unsigned jitter) {
+static void job_set_elapse_time(CattaResponseScheduler *s, CattaResponseJob *rj, unsigned msec, unsigned jitter) {
     struct timeval tv;
 
     assert(s);
     assert(rj);
 
-    avahi_elapse_time(&tv, msec, jitter);
+    catta_elapse_time(&tv, msec, jitter);
 
     if (rj->time_event)
-        avahi_time_event_update(rj->time_event, &tv);
+        catta_time_event_update(rj->time_event, &tv);
     else
-        rj->time_event = avahi_time_event_new(s->time_event_queue, &tv, elapse_callback, rj);
+        rj->time_event = catta_time_event_new(s->time_event_queue, &tv, elapse_callback, rj);
 }
 
-static void job_mark_done(AvahiResponseScheduler *s, AvahiResponseJob *rj) {
+static void job_mark_done(CattaResponseScheduler *s, CattaResponseJob *rj) {
     assert(s);
     assert(rj);
 
-    assert(rj->state == AVAHI_SCHEDULED);
+    assert(rj->state == CATTA_SCHEDULED);
 
-    AVAHI_LLIST_REMOVE(AvahiResponseJob, jobs, s->jobs, rj);
-    AVAHI_LLIST_PREPEND(AvahiResponseJob, jobs, s->history, rj);
+    CATTA_LLIST_REMOVE(CattaResponseJob, jobs, s->jobs, rj);
+    CATTA_LLIST_PREPEND(CattaResponseJob, jobs, s->history, rj);
 
-    rj->state = AVAHI_DONE;
+    rj->state = CATTA_DONE;
 
-    job_set_elapse_time(s, rj, AVAHI_RESPONSE_HISTORY_MSEC, 0);
+    job_set_elapse_time(s, rj, CATTA_RESPONSE_HISTORY_MSEC, 0);
 
     gettimeofday(&rj->delivery, NULL);
 }
 
-AvahiResponseScheduler *avahi_response_scheduler_new(AvahiInterface *i) {
-    AvahiResponseScheduler *s;
+CattaResponseScheduler *catta_response_scheduler_new(CattaInterface *i) {
+    CattaResponseScheduler *s;
     assert(i);
 
-    if (!(s = avahi_new(AvahiResponseScheduler, 1))) {
-        avahi_log_error(__FILE__": Out of memory");
+    if (!(s = catta_new(CattaResponseScheduler, 1))) {
+        catta_log_error(__FILE__": Out of memory");
         return NULL;
     }
 
     s->interface = i;
     s->time_event_queue = i->monitor->server->time_event_queue;
 
-    AVAHI_LLIST_HEAD_INIT(AvahiResponseJob, s->jobs);
-    AVAHI_LLIST_HEAD_INIT(AvahiResponseJob, s->history);
-    AVAHI_LLIST_HEAD_INIT(AvahiResponseJob, s->suppressed);
+    CATTA_LLIST_HEAD_INIT(CattaResponseJob, s->jobs);
+    CATTA_LLIST_HEAD_INIT(CattaResponseJob, s->history);
+    CATTA_LLIST_HEAD_INIT(CattaResponseJob, s->suppressed);
 
     return s;
 }
 
-void avahi_response_scheduler_free(AvahiResponseScheduler *s) {
+void catta_response_scheduler_free(CattaResponseScheduler *s) {
     assert(s);
 
-    avahi_response_scheduler_clear(s);
-    avahi_free(s);
+    catta_response_scheduler_clear(s);
+    catta_free(s);
 }
 
-void avahi_response_scheduler_clear(AvahiResponseScheduler *s) {
+void catta_response_scheduler_clear(CattaResponseScheduler *s) {
     assert(s);
 
     while (s->jobs)
@@ -188,40 +188,40 @@ void avahi_response_scheduler_clear(AvahiResponseScheduler *s) {
         job_free(s, s->suppressed);
 }
 
-static void enumerate_aux_records_callback(AVAHI_GCC_UNUSED AvahiServer *s, AvahiRecord *r, int flush_cache, void* userdata) {
-    AvahiResponseJob *rj = userdata;
+static void enumerate_aux_records_callback(CATTA_GCC_UNUSED CattaServer *s, CattaRecord *r, int flush_cache, void* userdata) {
+    CattaResponseJob *rj = userdata;
 
     assert(r);
     assert(rj);
 
-    avahi_response_scheduler_post(rj->scheduler, r, flush_cache, rj->querier_valid ? &rj->querier : NULL, 0);
+    catta_response_scheduler_post(rj->scheduler, r, flush_cache, rj->querier_valid ? &rj->querier : NULL, 0);
 }
 
-static int packet_add_response_job(AvahiResponseScheduler *s, AvahiDnsPacket *p, AvahiResponseJob *rj) {
+static int packet_add_response_job(CattaResponseScheduler *s, CattaDnsPacket *p, CattaResponseJob *rj) {
     assert(s);
     assert(p);
     assert(rj);
 
     /* Try to add this record to the packet */
-    if (!avahi_dns_packet_append_record(p, rj->record, rj->flush_cache, 0))
+    if (!catta_dns_packet_append_record(p, rj->record, rj->flush_cache, 0))
         return 0;
 
     /* Ok, this record will definitely be sent, so schedule the
      * auxilliary packets, too */
-    avahi_server_enumerate_aux_records(s->interface->monitor->server, s->interface, rj->record, enumerate_aux_records_callback, rj);
+    catta_server_enumerate_aux_records(s->interface->monitor->server, s->interface, rj->record, enumerate_aux_records_callback, rj);
     job_mark_done(s, rj);
 
     return 1;
 }
 
-static void send_response_packet(AvahiResponseScheduler *s, AvahiResponseJob *rj) {
-    AvahiDnsPacket *p;
+static void send_response_packet(CattaResponseScheduler *s, CattaResponseJob *rj) {
+    CattaDnsPacket *p;
     unsigned n;
 
     assert(s);
     assert(rj);
 
-    if (!(p = avahi_dns_packet_new_response(s->interface->hardware->mtu, 1)))
+    if (!(p = catta_dns_packet_new_response(s->interface->hardware->mtu, 1)))
         return; /* OOM */
     n = 1;
 
@@ -240,70 +240,70 @@ static void send_response_packet(AvahiResponseScheduler *s, AvahiResponseJob *rj
     } else {
         size_t size;
 
-        avahi_dns_packet_free(p);
+        catta_dns_packet_free(p);
 
         /* OK, the packet was too small, so create one that fits */
-        size = avahi_record_get_estimate_size(rj->record) + AVAHI_DNS_PACKET_HEADER_SIZE;
+        size = catta_record_get_estimate_size(rj->record) + CATTA_DNS_PACKET_HEADER_SIZE;
 
-        if (!(p = avahi_dns_packet_new_response(size + AVAHI_DNS_PACKET_EXTRA_SIZE, 1)))
+        if (!(p = catta_dns_packet_new_response(size + CATTA_DNS_PACKET_EXTRA_SIZE, 1)))
             return; /* OOM */
 
         if (!packet_add_response_job(s, p, rj)) {
-            avahi_dns_packet_free(p);
+            catta_dns_packet_free(p);
 
-            avahi_log_warn("Record too large, cannot send");
+            catta_log_warn("Record too large, cannot send");
             job_mark_done(s, rj);
             return;
         }
     }
 
-    avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_ANCOUNT, n);
-    avahi_interface_send_packet(s->interface, p);
-    avahi_dns_packet_free(p);
+    catta_dns_packet_set_field(p, CATTA_DNS_FIELD_ANCOUNT, n);
+    catta_interface_send_packet(s->interface, p);
+    catta_dns_packet_free(p);
 }
 
-static void elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void* data) {
-    AvahiResponseJob *rj = data;
+static void elapse_callback(CATTA_GCC_UNUSED CattaTimeEvent *e, void* data) {
+    CattaResponseJob *rj = data;
 
     assert(rj);
 
-    if (rj->state == AVAHI_DONE || rj->state == AVAHI_SUPPRESSED)
+    if (rj->state == CATTA_DONE || rj->state == CATTA_SUPPRESSED)
         job_free(rj->scheduler, rj);         /* Lets drop this entry */
     else
         send_response_packet(rj->scheduler, rj);
 }
 
-static AvahiResponseJob* find_scheduled_job(AvahiResponseScheduler *s, AvahiRecord *record) {
-    AvahiResponseJob *rj;
+static CattaResponseJob* find_scheduled_job(CattaResponseScheduler *s, CattaRecord *record) {
+    CattaResponseJob *rj;
 
     assert(s);
     assert(record);
 
     for (rj = s->jobs; rj; rj = rj->jobs_next) {
-        assert(rj->state == AVAHI_SCHEDULED);
+        assert(rj->state == CATTA_SCHEDULED);
 
-        if (avahi_record_equal_no_ttl(rj->record, record))
+        if (catta_record_equal_no_ttl(rj->record, record))
             return rj;
     }
 
     return NULL;
 }
 
-static AvahiResponseJob* find_history_job(AvahiResponseScheduler *s, AvahiRecord *record) {
-    AvahiResponseJob *rj;
+static CattaResponseJob* find_history_job(CattaResponseScheduler *s, CattaRecord *record) {
+    CattaResponseJob *rj;
 
     assert(s);
     assert(record);
 
     for (rj = s->history; rj; rj = rj->jobs_next) {
-        assert(rj->state == AVAHI_DONE);
+        assert(rj->state == CATTA_DONE);
 
-        if (avahi_record_equal_no_ttl(rj->record, record)) {
+        if (catta_record_equal_no_ttl(rj->record, record)) {
             /* Check whether this entry is outdated */
 
-/*             avahi_log_debug("history age: %u", (unsigned) (avahi_age(&rj->delivery)/1000)); */
+/*             catta_log_debug("history age: %u", (unsigned) (catta_age(&rj->delivery)/1000)); */
 
-            if (avahi_age(&rj->delivery)/1000 > AVAHI_RESPONSE_HISTORY_MSEC) {
+            if (catta_age(&rj->delivery)/1000 > CATTA_RESPONSE_HISTORY_MSEC) {
                 /* it is outdated, so let's remove it */
                 job_free(s, rj);
                 return NULL;
@@ -316,22 +316,22 @@ static AvahiResponseJob* find_history_job(AvahiResponseScheduler *s, AvahiRecord
     return NULL;
 }
 
-static AvahiResponseJob* find_suppressed_job(AvahiResponseScheduler *s, AvahiRecord *record, const AvahiAddress *querier) {
-    AvahiResponseJob *rj;
+static CattaResponseJob* find_suppressed_job(CattaResponseScheduler *s, CattaRecord *record, const CattaAddress *querier) {
+    CattaResponseJob *rj;
 
     assert(s);
     assert(record);
     assert(querier);
 
     for (rj = s->suppressed; rj; rj = rj->jobs_next) {
-        assert(rj->state == AVAHI_SUPPRESSED);
+        assert(rj->state == CATTA_SUPPRESSED);
         assert(rj->querier_valid);
 
-        if (avahi_record_equal_no_ttl(rj->record, record) &&
-            avahi_address_cmp(&rj->querier, querier) == 0) {
+        if (catta_record_equal_no_ttl(rj->record, record) &&
+            catta_address_cmp(&rj->querier, querier) == 0) {
             /* Check whether this entry is outdated */
 
-            if (avahi_age(&rj->delivery) > AVAHI_RESPONSE_SUPPRESS_MSEC*1000) {
+            if (catta_age(&rj->delivery) > CATTA_RESPONSE_SUPPRESS_MSEC*1000) {
                 /* it is outdated, so let's remove it */
                 job_free(s, rj);
                 return NULL;
@@ -344,37 +344,37 @@ static AvahiResponseJob* find_suppressed_job(AvahiResponseScheduler *s, AvahiRec
     return NULL;
 }
 
-int avahi_response_scheduler_post(AvahiResponseScheduler *s, AvahiRecord *record, int flush_cache, const AvahiAddress *querier, int immediately) {
-    AvahiResponseJob *rj;
+int catta_response_scheduler_post(CattaResponseScheduler *s, CattaRecord *record, int flush_cache, const CattaAddress *querier, int immediately) {
+    CattaResponseJob *rj;
     struct timeval tv;
 /*     char *t; */
 
     assert(s);
     assert(record);
 
-    assert(!avahi_key_is_pattern(record->key));
+    assert(!catta_key_is_pattern(record->key));
 
-/*     t = avahi_record_to_string(record); */
-/*     avahi_log_debug("post %i %s", immediately, t); */
-/*     avahi_free(t); */
+/*     t = catta_record_to_string(record); */
+/*     catta_log_debug("post %i %s", immediately, t); */
+/*     catta_free(t); */
 
     /* Check whether this response is suppressed */
     if (querier &&
         (rj = find_suppressed_job(s, record, querier)) &&
-        avahi_record_is_goodbye(record) == avahi_record_is_goodbye(rj->record) &&
+        catta_record_is_goodbye(record) == catta_record_is_goodbye(rj->record) &&
         rj->record->ttl >= record->ttl/2) {
 
-/*         avahi_log_debug("Response suppressed by known answer suppression.");  */
+/*         catta_log_debug("Response suppressed by known answer suppression.");  */
         return 0;
     }
 
     /* Check if we already sent this response recently */
     if ((rj = find_history_job(s, record))) {
 
-        if (avahi_record_is_goodbye(record) == avahi_record_is_goodbye(rj->record) &&
+        if (catta_record_is_goodbye(record) == catta_record_is_goodbye(rj->record) &&
             rj->record->ttl >= record->ttl/2 &&
             (rj->flush_cache || !flush_cache)) {
-/*             avahi_log_debug("Response suppressed by local duplicate suppression (history)");  */
+/*             catta_log_debug("Response suppressed by local duplicate suppression (history)");  */
             return 0;
         }
 
@@ -382,17 +382,17 @@ int avahi_response_scheduler_post(AvahiResponseScheduler *s, AvahiRecord *record
         job_free(s, rj);
     }
 
-    avahi_elapse_time(&tv, immediately ? 0 : AVAHI_RESPONSE_DEFER_MSEC, immediately ? 0 : AVAHI_RESPONSE_JITTER_MSEC);
+    catta_elapse_time(&tv, immediately ? 0 : CATTA_RESPONSE_DEFER_MSEC, immediately ? 0 : CATTA_RESPONSE_JITTER_MSEC);
 
     if ((rj = find_scheduled_job(s, record))) {
-/*          avahi_log_debug("Response suppressed by local duplicate suppression (scheduled)"); */
+/*          catta_log_debug("Response suppressed by local duplicate suppression (scheduled)"); */
 
         /* Update a little ... */
 
         /* Update the time if the new is prior to the old */
-        if (avahi_timeval_compare(&tv, &rj->delivery) < 0) {
+        if (catta_timeval_compare(&tv, &rj->delivery) < 0) {
             rj->delivery = tv;
-            avahi_time_event_update(rj->time_event, &rj->delivery);
+            catta_time_event_update(rj->time_event, &rj->delivery);
         }
 
         /* Update the flush cache bit */
@@ -400,23 +400,23 @@ int avahi_response_scheduler_post(AvahiResponseScheduler *s, AvahiRecord *record
             rj->flush_cache = 1;
 
         /* Update the querier field */
-        if (!querier || (rj->querier_valid && avahi_address_cmp(querier, &rj->querier) != 0))
+        if (!querier || (rj->querier_valid && catta_address_cmp(querier, &rj->querier) != 0))
             rj->querier_valid = 0;
 
         /* Update record data (just for the TTL) */
-        avahi_record_unref(rj->record);
-        rj->record = avahi_record_ref(record);
+        catta_record_unref(rj->record);
+        rj->record = catta_record_ref(record);
 
         return 1;
     } else {
-/*         avahi_log_debug("Accepted new response job.");  */
+/*         catta_log_debug("Accepted new response job.");  */
 
         /* Create a new job and schedule it */
-        if (!(rj = job_new(s, record, AVAHI_SCHEDULED)))
+        if (!(rj = job_new(s, record, CATTA_SCHEDULED)))
             return 0; /* OOM */
 
         rj->delivery = tv;
-        rj->time_event = avahi_time_event_new(s->time_event_queue, &rj->delivery, elapse_callback, rj);
+        rj->time_event = catta_time_event_new(s->time_event_queue, &rj->delivery, elapse_callback, rj);
         rj->flush_cache = flush_cache;
 
         if ((rj->querier_valid = !!querier))
@@ -426,8 +426,8 @@ int avahi_response_scheduler_post(AvahiResponseScheduler *s, AvahiRecord *record
     }
 }
 
-void avahi_response_scheduler_incoming(AvahiResponseScheduler *s, AvahiRecord *record, int flush_cache) {
-    AvahiResponseJob *rj;
+void catta_response_scheduler_incoming(CattaResponseScheduler *s, CattaRecord *record, int flush_cache) {
+    CattaResponseJob *rj;
     assert(s);
 
     /* This function is called whenever an incoming response was
@@ -437,11 +437,11 @@ void avahi_response_scheduler_incoming(AvahiResponseScheduler *s, AvahiRecord *r
     if ((rj = find_scheduled_job(s, record))) {
 
         if ((!rj->flush_cache || flush_cache) &&    /* flush cache bit was set correctly */
-            avahi_record_is_goodbye(record) == avahi_record_is_goodbye(rj->record) &&   /* both goodbye packets, or both not */
+            catta_record_is_goodbye(record) == catta_record_is_goodbye(rj->record) &&   /* both goodbye packets, or both not */
             record->ttl >= rj->record->ttl/2) {     /* sensible TTL */
 
             /* A matching entry was found, so let's mark it done */
-/*             avahi_log_debug("Response suppressed by distributed duplicate suppression"); */
+/*             catta_log_debug("Response suppressed by distributed duplicate suppression"); */
             job_mark_done(s, rj);
         }
 
@@ -450,22 +450,22 @@ void avahi_response_scheduler_incoming(AvahiResponseScheduler *s, AvahiRecord *r
 
     if ((rj = find_history_job(s, record))) {
         /* Found a history job, let's update it */
-        avahi_record_unref(rj->record);
-        rj->record = avahi_record_ref(record);
+        catta_record_unref(rj->record);
+        rj->record = catta_record_ref(record);
     } else
         /* Found no existing history job, so let's create a new one */
-        if (!(rj = job_new(s, record, AVAHI_DONE)))
+        if (!(rj = job_new(s, record, CATTA_DONE)))
             return; /* OOM */
 
     rj->flush_cache = flush_cache;
     rj->querier_valid = 0;
 
     gettimeofday(&rj->delivery, NULL);
-    job_set_elapse_time(s, rj, AVAHI_RESPONSE_HISTORY_MSEC, 0);
+    job_set_elapse_time(s, rj, CATTA_RESPONSE_HISTORY_MSEC, 0);
 }
 
-void avahi_response_scheduler_suppress(AvahiResponseScheduler *s, AvahiRecord *record, const AvahiAddress *querier) {
-    AvahiResponseJob *rj;
+void catta_response_scheduler_suppress(CattaResponseScheduler *s, CattaRecord *record, const CattaAddress *querier) {
+    CattaResponseJob *rj;
 
     assert(s);
     assert(record);
@@ -473,12 +473,12 @@ void avahi_response_scheduler_suppress(AvahiResponseScheduler *s, AvahiRecord *r
 
     if ((rj = find_scheduled_job(s, record))) {
 
-        if (rj->querier_valid && avahi_address_cmp(querier, &rj->querier) == 0 && /* same originator */
-            avahi_record_is_goodbye(record) == avahi_record_is_goodbye(rj->record) && /* both goodbye packets, or both not */
+        if (rj->querier_valid && catta_address_cmp(querier, &rj->querier) == 0 && /* same originator */
+            catta_record_is_goodbye(record) == catta_record_is_goodbye(rj->record) && /* both goodbye packets, or both not */
             record->ttl >= rj->record->ttl/2) {                                  /* sensible TTL */
 
             /* A matching entry was found, so let's drop it */
-/*             avahi_log_debug("Known answer suppression active!"); */
+/*             catta_log_debug("Known answer suppression active!"); */
             job_free(s, rj);
         }
     }
@@ -486,23 +486,23 @@ void avahi_response_scheduler_suppress(AvahiResponseScheduler *s, AvahiRecord *r
     if ((rj = find_suppressed_job(s, record, querier))) {
 
         /* Let's update the old entry */
-        avahi_record_unref(rj->record);
-        rj->record = avahi_record_ref(record);
+        catta_record_unref(rj->record);
+        rj->record = catta_record_ref(record);
 
     } else {
 
         /* Create a new entry */
-        if (!(rj = job_new(s, record, AVAHI_SUPPRESSED)))
+        if (!(rj = job_new(s, record, CATTA_SUPPRESSED)))
             return; /* OOM */
         rj->querier_valid = 1;
         rj->querier = *querier;
     }
 
     gettimeofday(&rj->delivery, NULL);
-    job_set_elapse_time(s, rj, AVAHI_RESPONSE_SUPPRESS_MSEC, 0);
+    job_set_elapse_time(s, rj, CATTA_RESPONSE_SUPPRESS_MSEC, 0);
 }
 
-void avahi_response_scheduler_force(AvahiResponseScheduler *s) {
+void catta_response_scheduler_force(CattaResponseScheduler *s) {
     assert(s);
 
     /* Send all scheduled responses immediately */
index a3eb60864e137853fec1243292208f6ed90ffca0..4283377a4104bd6eafd5a59b5b50688c8c873e88 100644 (file)
@@ -2,36 +2,36 @@
 #define fooresponseschedhfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
-typedef struct AvahiResponseScheduler AvahiResponseScheduler;
+typedef struct CattaResponseScheduler CattaResponseScheduler;
 
-#include <avahi/address.h>
+#include <catta/address.h>
 #include "iface.h"
 
-AvahiResponseScheduler *avahi_response_scheduler_new(AvahiInterface *i);
-void avahi_response_scheduler_free(AvahiResponseScheduler *s);
-void avahi_response_scheduler_clear(AvahiResponseScheduler *s);
-void avahi_response_scheduler_force(AvahiResponseScheduler *s);
+CattaResponseScheduler *catta_response_scheduler_new(CattaInterface *i);
+void catta_response_scheduler_free(CattaResponseScheduler *s);
+void catta_response_scheduler_clear(CattaResponseScheduler *s);
+void catta_response_scheduler_force(CattaResponseScheduler *s);
 
-int avahi_response_scheduler_post(AvahiResponseScheduler *s, AvahiRecord *record, int flush_cache, const AvahiAddress *querier, int immediately);
-void avahi_response_scheduler_incoming(AvahiResponseScheduler *s, AvahiRecord *record, int flush_cache);
-void avahi_response_scheduler_suppress(AvahiResponseScheduler *s, AvahiRecord *record, const AvahiAddress *querier);
+int catta_response_scheduler_post(CattaResponseScheduler *s, CattaRecord *record, int flush_cache, const CattaAddress *querier, int immediately);
+void catta_response_scheduler_incoming(CattaResponseScheduler *s, CattaRecord *record, int flush_cache);
+void catta_response_scheduler_suppress(CattaResponseScheduler *s, CattaRecord *record, const CattaAddress *querier);
 
 #endif
index c29b4ee8e34302c3cafa77e86003bf24db8ab097..847832211d6687e4a0ff3212f7af600b345e108c 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 #include <stdlib.h>
 
-#include <avahi/rlist.h>
-#include <avahi/malloc.h>
+#include <catta/rlist.h>
+#include <catta/malloc.h>
 
-AvahiRList* avahi_rlist_prepend(AvahiRList *r, void *data) {
-    AvahiRList *n;
+CattaRList* catta_rlist_prepend(CattaRList *r, void *data) {
+    CattaRList *n;
 
-    if (!(n = avahi_new(AvahiRList, 1)))
+    if (!(n = catta_new(CattaRList, 1)))
         return NULL;
 
     n->data = data;
 
-    AVAHI_LLIST_PREPEND(AvahiRList, rlist, r, n);
+    CATTA_LLIST_PREPEND(CattaRList, rlist, r, n);
     return r;
 }
 
-AvahiRList* avahi_rlist_remove(AvahiRList *r, void *data) {
-    AvahiRList *n;
+CattaRList* catta_rlist_remove(CattaRList *r, void *data) {
+    CattaRList *n;
 
     for (n = r; n; n = n->rlist_next)
 
         if (n->data == data) {
-            AVAHI_LLIST_REMOVE(AvahiRList, rlist, r, n);
-            avahi_free(n);
+            CATTA_LLIST_REMOVE(CattaRList, rlist, r, n);
+            catta_free(n);
             break;
         }
 
     return r;
 }
 
-AvahiRList* avahi_rlist_remove_by_link(AvahiRList *r, AvahiRList *n) {
+CattaRList* catta_rlist_remove_by_link(CattaRList *r, CattaRList *n) {
     assert(n);
 
-    AVAHI_LLIST_REMOVE(AvahiRList, rlist, r, n);
-    avahi_free(n);
+    CATTA_LLIST_REMOVE(CattaRList, rlist, r, n);
+    catta_free(n);
 
     return r;
 }
index 402f93696d0cce877b11db8205e9436ca91e5310..16871a162396b25c3d6ae7d42094cba681b732e3 100644 (file)
@@ -2,61 +2,61 @@
 #define foorrutilhfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
-#include <avahi/rr.h>
+#include <catta/rr.h>
 
-AVAHI_C_DECL_BEGIN
+CATTA_C_DECL_BEGIN
 
-/** Creaze new AvahiKey object based on an existing key but replaceing the type by CNAME */
-AvahiKey *avahi_key_new_cname(AvahiKey *key);
+/** Creaze new CattaKey object based on an existing key but replaceing the type by CNAME */
+CattaKey *catta_key_new_cname(CattaKey *key);
 
 /** Match a key to a key pattern. The pattern has a type of
-AVAHI_DNS_CLASS_ANY, the classes are taken to be equal. Same for the
+CATTA_DNS_CLASS_ANY, the classes are taken to be equal. Same for the
 type. If the pattern has neither class nor type with ANY constants,
-this function is identical to avahi_key_equal(). In contrast to
-avahi_equal() this function is not commutative. */
-int avahi_key_pattern_match(const AvahiKey *pattern, const AvahiKey *k);
+this function is identical to catta_key_equal(). In contrast to
+catta_equal() this function is not commutative. */
+int catta_key_pattern_match(const CattaKey *pattern, const CattaKey *k);
 
 /** Check whether a key is a pattern key, i.e. the class/type has a
- * value of AVAHI_DNS_CLASS_ANY/AVAHI_DNS_TYPE_ANY */
-int avahi_key_is_pattern(const AvahiKey *k);
+ * value of CATTA_DNS_CLASS_ANY/CATTA_DNS_TYPE_ANY */
+int catta_key_is_pattern(const CattaKey *k);
 
 /** Returns a maximum estimate for the space that is needed to store
  * this key in a DNS packet. */
-size_t avahi_key_get_estimate_size(AvahiKey *k);
+size_t catta_key_get_estimate_size(CattaKey *k);
 
 /** Returns a maximum estimate for the space that is needed to store
  * the record in a DNS packet. */
-size_t avahi_record_get_estimate_size(AvahiRecord *r);
+size_t catta_record_get_estimate_size(CattaRecord *r);
 
 /** Do a mDNS spec conforming lexicographical comparison of the two
  * records. Return a negative value if a < b, a positive if a > b,
  * zero if equal. */
-int avahi_record_lexicographical_compare(AvahiRecord *a, AvahiRecord *b);
+int catta_record_lexicographical_compare(CattaRecord *a, CattaRecord *b);
 
 /** Return 1 if the specified record is an mDNS goodbye record. i.e. TTL is zero. */
-int avahi_record_is_goodbye(AvahiRecord *r);
+int catta_record_is_goodbye(CattaRecord *r);
 
-/** Make a deep copy of an AvahiRecord object */
-AvahiRecord *avahi_record_copy(AvahiRecord *r);
+/** Make a deep copy of an CattaRecord object */
+CattaRecord *catta_record_copy(CattaRecord *r);
 
-AVAHI_C_DECL_END
+CATTA_C_DECL_END
 
 #endif
index efab1ce6846aecd3b1116c01397e6969a9ed042c..eeab99a208cd1196a0310344557cdc192e536317 100644 (file)
--- a/src/rr.c
+++ b/src/rr.c
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <arpa/inet.h>
 #include <assert.h>
 
-#include <avahi/domain.h>
-#include <avahi/malloc.h>
-#include <avahi/defs.h>
+#include <catta/domain.h>
+#include <catta/malloc.h>
+#include <catta/defs.h>
 
-#include <avahi/rr.h>
-#include <avahi/log.h>
+#include <catta/rr.h>
+#include <catta/log.h>
 #include "util.h"
 #include "hashmap.h"
 #include "domain-util.h"
 #include "rr-util.h"
 #include "addr-util.h"
 
-AvahiKey *avahi_key_new(const char *name, uint16_t class, uint16_t type) {
-    AvahiKey *k;
+CattaKey *catta_key_new(const char *name, uint16_t class, uint16_t type) {
+    CattaKey *k;
     assert(name);
 
-    if (!(k = avahi_new(AvahiKey, 1))) {
-        avahi_log_error("avahi_new() failed.");
+    if (!(k = catta_new(CattaKey, 1))) {
+        catta_log_error("catta_new() failed.");
         return NULL;
     }
 
-    if (!(k->name = avahi_normalize_name_strdup(name))) {
-        avahi_log_error("avahi_normalize_name() failed.");
-        avahi_free(k);
+    if (!(k->name = catta_normalize_name_strdup(name))) {
+        catta_log_error("catta_normalize_name() failed.");
+        catta_free(k);
         return NULL;
     }
 
@@ -62,19 +62,19 @@ AvahiKey *avahi_key_new(const char *name, uint16_t class, uint16_t type) {
     return k;
 }
 
-AvahiKey *avahi_key_new_cname(AvahiKey *key) {
+CattaKey *catta_key_new_cname(CattaKey *key) {
     assert(key);
 
-    if (key->clazz != AVAHI_DNS_CLASS_IN)
+    if (key->clazz != CATTA_DNS_CLASS_IN)
         return NULL;
 
-    if (key->type == AVAHI_DNS_TYPE_CNAME)
+    if (key->type == CATTA_DNS_TYPE_CNAME)
         return NULL;
 
-    return avahi_key_new(key->name, key->clazz, AVAHI_DNS_TYPE_CNAME);
+    return catta_key_new(key->name, key->clazz, CATTA_DNS_TYPE_CNAME);
 }
 
-AvahiKey *avahi_key_ref(AvahiKey *k) {
+CattaKey *catta_key_ref(CattaKey *k) {
     assert(k);
     assert(k->ref >= 1);
 
@@ -83,59 +83,59 @@ AvahiKey *avahi_key_ref(AvahiKey *k) {
     return k;
 }
 
-void avahi_key_unref(AvahiKey *k) {
+void catta_key_unref(CattaKey *k) {
     assert(k);
     assert(k->ref >= 1);
 
     if ((--k->ref) <= 0) {
-        avahi_free(k->name);
-        avahi_free(k);
+        catta_free(k->name);
+        catta_free(k);
     }
 }
 
-AvahiRecord *avahi_record_new(AvahiKey *k, uint32_t ttl) {
-    AvahiRecord *r;
+CattaRecord *catta_record_new(CattaKey *k, uint32_t ttl) {
+    CattaRecord *r;
 
     assert(k);
 
-    if (!(r = avahi_new(AvahiRecord, 1))) {
-        avahi_log_error("avahi_new() failed.");
+    if (!(r = catta_new(CattaRecord, 1))) {
+        catta_log_error("catta_new() failed.");
         return NULL;
     }
 
     r->ref = 1;
-    r->key = avahi_key_ref(k);
+    r->key = catta_key_ref(k);
 
     memset(&r->data, 0, sizeof(r->data));
 
-    r->ttl = ttl != (uint32_t) -1 ? ttl : AVAHI_DEFAULT_TTL;
+    r->ttl = ttl != (uint32_t) -1 ? ttl : CATTA_DEFAULT_TTL;
 
     return r;
 }
 
-AvahiRecord *avahi_record_new_full(const char *name, uint16_t class, uint16_t type, uint32_t ttl) {
-    AvahiRecord *r;
-    AvahiKey *k;
+CattaRecord *catta_record_new_full(const char *name, uint16_t class, uint16_t type, uint32_t ttl) {
+    CattaRecord *r;
+    CattaKey *k;
 
     assert(name);
 
-    if (!(k = avahi_key_new(name, class, type))) {
-        avahi_log_error("avahi_key_new() failed.");
+    if (!(k = catta_key_new(name, class, type))) {
+        catta_log_error("catta_key_new() failed.");
         return NULL;
     }
 
-    r = avahi_record_new(k, ttl);
-    avahi_key_unref(k);
+    r = catta_record_new(k, ttl);
+    catta_key_unref(k);
 
     if (!r) {
-        avahi_log_error("avahi_record_new() failed.");
+        catta_log_error("catta_record_new() failed.");
         return NULL;
     }
 
     return r;
 }
 
-AvahiRecord *avahi_record_ref(AvahiRecord *r) {
+CattaRecord *catta_record_ref(CattaRecord *r) {
     assert(r);
     assert(r->ref >= 1);
 
@@ -143,87 +143,87 @@ AvahiRecord *avahi_record_ref(AvahiRecord *r) {
     return r;
 }
 
-void avahi_record_unref(AvahiRecord *r) {
+void catta_record_unref(CattaRecord *r) {
     assert(r);
     assert(r->ref >= 1);
 
     if ((--r->ref) <= 0) {
         switch (r->key->type) {
 
-            case AVAHI_DNS_TYPE_SRV:
-                avahi_free(r->data.srv.name);
+            case CATTA_DNS_TYPE_SRV:
+                catta_free(r->data.srv.name);
                 break;
 
-            case AVAHI_DNS_TYPE_PTR:
-            case AVAHI_DNS_TYPE_CNAME:
-            case AVAHI_DNS_TYPE_NS:
-                avahi_free(r->data.ptr.name);
+            case CATTA_DNS_TYPE_PTR:
+            case CATTA_DNS_TYPE_CNAME:
+            case CATTA_DNS_TYPE_NS:
+                catta_free(r->data.ptr.name);
                 break;
 
-            case AVAHI_DNS_TYPE_HINFO:
-                avahi_free(r->data.hinfo.cpu);
-                avahi_free(r->data.hinfo.os);
+            case CATTA_DNS_TYPE_HINFO:
+                catta_free(r->data.hinfo.cpu);
+                catta_free(r->data.hinfo.os);
                 break;
 
-            case AVAHI_DNS_TYPE_TXT:
-                avahi_string_list_free(r->data.txt.string_list);
+            case CATTA_DNS_TYPE_TXT:
+                catta_string_list_free(r->data.txt.string_list);
                 break;
 
-            case AVAHI_DNS_TYPE_A:
-            case AVAHI_DNS_TYPE_AAAA:
+            case CATTA_DNS_TYPE_A:
+            case CATTA_DNS_TYPE_AAAA:
                 break;
 
             default:
-                avahi_free(r->data.generic.data);
+                catta_free(r->data.generic.data);
         }
 
-        avahi_key_unref(r->key);
-        avahi_free(r);
+        catta_key_unref(r->key);
+        catta_free(r);
     }
 }
 
-const char *avahi_dns_class_to_string(uint16_t class) {
-    if (class & AVAHI_DNS_CACHE_FLUSH)
+const char *catta_dns_class_to_string(uint16_t class) {
+    if (class & CATTA_DNS_CACHE_FLUSH)
         return "FLUSH";
 
     switch (class) {
-        case AVAHI_DNS_CLASS_IN:
+        case CATTA_DNS_CLASS_IN:
             return "IN";
-        case AVAHI_DNS_CLASS_ANY:
+        case CATTA_DNS_CLASS_ANY:
             return "ANY";
         default:
             return NULL;
     }
 }
 
-const char *avahi_dns_type_to_string(uint16_t type) {
+const char *catta_dns_type_to_string(uint16_t type) {
     switch (type) {
-        case AVAHI_DNS_TYPE_CNAME:
+        case CATTA_DNS_TYPE_CNAME:
             return "CNAME";
-        case AVAHI_DNS_TYPE_A:
+        case CATTA_DNS_TYPE_A:
             return "A";
-        case AVAHI_DNS_TYPE_AAAA:
+        case CATTA_DNS_TYPE_AAAA:
             return "AAAA";
-        case AVAHI_DNS_TYPE_PTR:
+        case CATTA_DNS_TYPE_PTR:
             return "PTR";
-        case AVAHI_DNS_TYPE_HINFO:
+        case CATTA_DNS_TYPE_HINFO:
             return "HINFO";
-        case AVAHI_DNS_TYPE_TXT:
+        case CATTA_DNS_TYPE_TXT:
             return "TXT";
-        case AVAHI_DNS_TYPE_SRV:
+        case CATTA_DNS_TYPE_SRV:
             return "SRV";
-        case AVAHI_DNS_TYPE_ANY:
+        case CATTA_DNS_TYPE_ANY:
             return "ANY";
-        case AVAHI_DNS_TYPE_SOA:
+        case CATTA_DNS_TYPE_SOA:
             return "SOA";
-        case AVAHI_DNS_TYPE_NS:
+        case CATTA_DNS_TYPE_NS:
             return "NS";
         default:
             return NULL;
     }
 }
 
-char *avahi_key_to_string(const AvahiKey *k) {
+char *catta_key_to_string(const CattaKey *k) {
     char class[16], type[16];
     const char *c, *t;
 
@@ -232,20 +232,20 @@ char *avahi_key_to_string(const AvahiKey *k) {
 
     /* According to RFC3597 */
 
-    if (!(c = avahi_dns_class_to_string(k->clazz))) {
+    if (!(c = catta_dns_class_to_string(k->clazz))) {
         snprintf(class, sizeof(class), "CLASS%u", k->clazz);
         c = class;
     }
 
-    if (!(t = avahi_dns_type_to_string(k->type))) {
+    if (!(t = catta_dns_type_to_string(k->type))) {
         snprintf(type, sizeof(type), "TYPE%u", k->type);
         t = type;
     }
 
-    return avahi_strdup_printf("%s\t%s\t%s", k->name, c, t);
+    return catta_strdup_printf("%s\t%s\t%s", k->name, c, t);
 }
 
-char *avahi_record_to_string(const AvahiRecord *r) {
+char *catta_record_to_string(const CattaRecord *r) {
     char *p, *s;
     char buf[1024], *t = NULL, *d = NULL;
 
@@ -253,31 +253,31 @@ char *avahi_record_to_string(const AvahiRecord *r) {
     assert(r->ref >= 1);
 
     switch (r->key->type) {
-        case AVAHI_DNS_TYPE_A:
+        case CATTA_DNS_TYPE_A:
             inet_ntop(AF_INET, &r->data.a.address.address, t = buf, sizeof(buf));
             break;
 
-        case AVAHI_DNS_TYPE_AAAA:
+        case CATTA_DNS_TYPE_AAAA:
             inet_ntop(AF_INET6, &r->data.aaaa.address.address, t = buf, sizeof(buf));
             break;
 
-        case AVAHI_DNS_TYPE_PTR:
-        case AVAHI_DNS_TYPE_CNAME:
-        case AVAHI_DNS_TYPE_NS:
+        case CATTA_DNS_TYPE_PTR:
+        case CATTA_DNS_TYPE_CNAME:
+        case CATTA_DNS_TYPE_NS:
 
             t = r->data.ptr.name;
             break;
 
-        case AVAHI_DNS_TYPE_TXT:
-            t = d = avahi_string_list_to_string(r->data.txt.string_list);
+        case CATTA_DNS_TYPE_TXT:
+            t = d = catta_string_list_to_string(r->data.txt.string_list);
             break;
 
-        case AVAHI_DNS_TYPE_HINFO:
+        case CATTA_DNS_TYPE_HINFO:
 
             snprintf(t = buf, sizeof(buf), "\"%s\" \"%s\"", r->data.hinfo.cpu, r->data.hinfo.os);
             break;
 
-        case AVAHI_DNS_TYPE_SRV:
+        case CATTA_DNS_TYPE_SRV:
 
             snprintf(t = buf, sizeof(buf), "%u %u %u %s",
                      r->data.srv.priority,
@@ -312,88 +312,88 @@ char *avahi_record_to_string(const AvahiRecord *r) {
         }
     }
 
-    p = avahi_key_to_string(r->key);
-    s = avahi_strdup_printf("%s %s ; ttl=%u", p, t, r->ttl);
-    avahi_free(p);
-    avahi_free(d);
+    p = catta_key_to_string(r->key);
+    s = catta_strdup_printf("%s %s ; ttl=%u", p, t, r->ttl);
+    catta_free(p);
+    catta_free(d);
 
     return s;
 }
 
-int avahi_key_equal(const AvahiKey *a, const AvahiKey *b) {
+int catta_key_equal(const CattaKey *a, const CattaKey *b) {
     assert(a);
     assert(b);
 
     if (a == b)
         return 1;
 
-    return avahi_domain_equal(a->name, b->name) &&
+    return catta_domain_equal(a->name, b->name) &&
         a->type == b->type &&
         a->clazz == b->clazz;
 }
 
-int avahi_key_pattern_match(const AvahiKey *pattern, const AvahiKey *k) {
+int catta_key_pattern_match(const CattaKey *pattern, const CattaKey *k) {
     assert(pattern);
     assert(k);
 
-    assert(!avahi_key_is_pattern(k));
+    assert(!catta_key_is_pattern(k));
 
     if (pattern == k)
         return 1;
 
-    return avahi_domain_equal(pattern->name, k->name) &&
-        (pattern->type == k->type || pattern->type == AVAHI_DNS_TYPE_ANY) &&
-        (pattern->clazz == k->clazz || pattern->clazz == AVAHI_DNS_CLASS_ANY);
+    return catta_domain_equal(pattern->name, k->name) &&
+        (pattern->type == k->type || pattern->type == CATTA_DNS_TYPE_ANY) &&
+        (pattern->clazz == k->clazz || pattern->clazz == CATTA_DNS_CLASS_ANY);
 }
 
-int avahi_key_is_pattern(const AvahiKey *k) {
+int catta_key_is_pattern(const CattaKey *k) {
     assert(k);
 
     return
-        k->type == AVAHI_DNS_TYPE_ANY ||
-        k->clazz == AVAHI_DNS_CLASS_ANY;
+        k->type == CATTA_DNS_TYPE_ANY ||
+        k->clazz == CATTA_DNS_CLASS_ANY;
 }
 
-unsigned avahi_key_hash(const AvahiKey *k) {
+unsigned catta_key_hash(const CattaKey *k) {
     assert(k);
 
     return
-        avahi_domain_hash(k->name) +
+        catta_domain_hash(k->name) +
         k->type +
         k->clazz;
 }
 
-static int rdata_equal(const AvahiRecord *a, const AvahiRecord *b) {
+static int rdata_equal(const CattaRecord *a, const CattaRecord *b) {
     assert(a);
     assert(b);
     assert(a->key->type == b->key->type);
 
     switch (a->key->type) {
-        case AVAHI_DNS_TYPE_SRV:
+        case CATTA_DNS_TYPE_SRV:
             return
                 a->data.srv.priority == b->data.srv.priority &&
                 a->data.srv.weight == b->data.srv.weight &&
                 a->data.srv.port == b->data.srv.port &&
-                avahi_domain_equal(a->data.srv.name, b->data.srv.name);
+                catta_domain_equal(a->data.srv.name, b->data.srv.name);
 
-        case AVAHI_DNS_TYPE_PTR:
-        case AVAHI_DNS_TYPE_CNAME:
-        case AVAHI_DNS_TYPE_NS:
-            return avahi_domain_equal(a->data.ptr.name, b->data.ptr.name);
+        case CATTA_DNS_TYPE_PTR:
+        case CATTA_DNS_TYPE_CNAME:
+        case CATTA_DNS_TYPE_NS:
+            return catta_domain_equal(a->data.ptr.name, b->data.ptr.name);
 
-        case AVAHI_DNS_TYPE_HINFO:
+        case CATTA_DNS_TYPE_HINFO:
             return
                 !strcmp(a->data.hinfo.cpu, b->data.hinfo.cpu) &&
                 !strcmp(a->data.hinfo.os, b->data.hinfo.os);
 
-        case AVAHI_DNS_TYPE_TXT:
-            return avahi_string_list_equal(a->data.txt.string_list, b->data.txt.string_list);
+        case CATTA_DNS_TYPE_TXT:
+            return catta_string_list_equal(a->data.txt.string_list, b->data.txt.string_list);
 
-        case AVAHI_DNS_TYPE_A:
-            return memcmp(&a->data.a.address, &b->data.a.address, sizeof(AvahiIPv4Address)) == 0;
+        case CATTA_DNS_TYPE_A:
+            return memcmp(&a->data.a.address, &b->data.a.address, sizeof(CattaIPv4Address)) == 0;
 
-        case AVAHI_DNS_TYPE_AAAA:
-            return memcmp(&a->data.aaaa.address, &b->data.aaaa.address, sizeof(AvahiIPv6Address)) == 0;
+        case CATTA_DNS_TYPE_AAAA:
+            return memcmp(&a->data.aaaa.address, &b->data.aaaa.address, sizeof(CattaIPv6Address)) == 0;
 
         default:
             return a->data.generic.size == b->data.generic.size &&
@@ -402,7 +402,7 @@ static int rdata_equal(const AvahiRecord *a, const AvahiRecord *b) {
 
 }
 
-int avahi_record_equal_no_ttl(const AvahiRecord *a, const AvahiRecord *b) {
+int catta_record_equal_no_ttl(const CattaRecord *a, const CattaRecord *b) {
     assert(a);
     assert(b);
 
@@ -410,63 +410,63 @@ int avahi_record_equal_no_ttl(const AvahiRecord *a, const AvahiRecord *b) {
         return 1;
 
     return
-        avahi_key_equal(a->key, b->key) &&
+        catta_key_equal(a->key, b->key) &&
         rdata_equal(a, b);
 }
 
 
-AvahiRecord *avahi_record_copy(AvahiRecord *r) {
-    AvahiRecord *copy;
+CattaRecord *catta_record_copy(CattaRecord *r) {
+    CattaRecord *copy;
 
-    if (!(copy = avahi_new(AvahiRecord, 1))) {
-        avahi_log_error("avahi_new() failed.");
+    if (!(copy = catta_new(CattaRecord, 1))) {
+        catta_log_error("catta_new() failed.");
         return NULL;
     }
 
     copy->ref = 1;
-    copy->key = avahi_key_ref(r->key);
+    copy->key = catta_key_ref(r->key);
     copy->ttl = r->ttl;
 
     switch (r->key->type) {
-        case AVAHI_DNS_TYPE_PTR:
-        case AVAHI_DNS_TYPE_CNAME:
-        case AVAHI_DNS_TYPE_NS:
-            if (!(copy->data.ptr.name = avahi_strdup(r->data.ptr.name)))
+        case CATTA_DNS_TYPE_PTR:
+        case CATTA_DNS_TYPE_CNAME:
+        case CATTA_DNS_TYPE_NS:
+            if (!(copy->data.ptr.name = catta_strdup(r->data.ptr.name)))
                 goto fail;
             break;
 
-        case AVAHI_DNS_TYPE_SRV:
+        case CATTA_DNS_TYPE_SRV:
             copy->data.srv.priority = r->data.srv.priority;
             copy->data.srv.weight = r->data.srv.weight;
             copy->data.srv.port = r->data.srv.port;
-            if (!(copy->data.srv.name = avahi_strdup(r->data.srv.name)))
+            if (!(copy->data.srv.name = catta_strdup(r->data.srv.name)))
                 goto fail;
             break;
 
-        case AVAHI_DNS_TYPE_HINFO:
-            if (!(copy->data.hinfo.os = avahi_strdup(r->data.hinfo.os)))
+        case CATTA_DNS_TYPE_HINFO:
+            if (!(copy->data.hinfo.os = catta_strdup(r->data.hinfo.os)))
                 goto fail;
 
-            if (!(copy->data.hinfo.cpu = avahi_strdup(r->data.hinfo.cpu))) {
-                avahi_free(r->data.hinfo.os);
+            if (!(copy->data.hinfo.cpu = catta_strdup(r->data.hinfo.cpu))) {
+                catta_free(r->data.hinfo.os);
                 goto fail;
             }
             break;
 
-        case AVAHI_DNS_TYPE_TXT:
-            copy->data.txt.string_list = avahi_string_list_copy(r->data.txt.string_list);
+        case CATTA_DNS_TYPE_TXT:
+            copy->data.txt.string_list = catta_string_list_copy(r->data.txt.string_list);
             break;
 
-        case AVAHI_DNS_TYPE_A:
+        case CATTA_DNS_TYPE_A:
             copy->data.a.address = r->data.a.address;
             break;
 
-        case AVAHI_DNS_TYPE_AAAA:
+        case CATTA_DNS_TYPE_AAAA:
             copy->data.aaaa.address = r->data.aaaa.address;
             break;
 
         default:
-            if (!(copy->data.generic.data = avahi_memdup(r->data.generic.data, r->data.generic.size)))
+            if (!(copy->data.generic.data = catta_memdup(r->data.generic.data, r->data.generic.size)))
                 goto fail;
             copy->data.generic.size = r->data.generic.size;
             break;
@@ -476,52 +476,52 @@ AvahiRecord *avahi_record_copy(AvahiRecord *r) {
     return copy;
 
 fail:
-    avahi_log_error("Failed to allocate memory");
+    catta_log_error("Failed to allocate memory");
 
-    avahi_key_unref(copy->key);
-    avahi_free(copy);
+    catta_key_unref(copy->key);
+    catta_free(copy);
 
     return NULL;
 }
 
 
-size_t avahi_key_get_estimate_size(AvahiKey *k) {
+size_t catta_key_get_estimate_size(CattaKey *k) {
     assert(k);
 
     return strlen(k->name)+1+4;
 }
 
-size_t avahi_record_get_estimate_size(AvahiRecord *r) {
+size_t catta_record_get_estimate_size(CattaRecord *r) {
     size_t n;
     assert(r);
 
-    n = avahi_key_get_estimate_size(r->key) + 4 + 2;
+    n = catta_key_get_estimate_size(r->key) + 4 + 2;
 
     switch (r->key->type) {
-        case AVAHI_DNS_TYPE_PTR:
-        case AVAHI_DNS_TYPE_CNAME:
-        case AVAHI_DNS_TYPE_NS:
+        case CATTA_DNS_TYPE_PTR:
+        case CATTA_DNS_TYPE_CNAME:
+        case CATTA_DNS_TYPE_NS:
             n += strlen(r->data.ptr.name) + 1;
             break;
 
-        case AVAHI_DNS_TYPE_SRV:
+        case CATTA_DNS_TYPE_SRV:
             n += 6 + strlen(r->data.srv.name) + 1;
             break;
 
-        case AVAHI_DNS_TYPE_HINFO:
+        case CATTA_DNS_TYPE_HINFO:
             n += strlen(r->data.hinfo.os) + 1 + strlen(r->data.hinfo.cpu) + 1;
             break;
 
-        case AVAHI_DNS_TYPE_TXT:
-            n += avahi_string_list_serialize(r->data.txt.string_list, NULL, 0);
+        case CATTA_DNS_TYPE_TXT:
+            n += catta_string_list_serialize(r->data.txt.string_list, NULL, 0);
             break;
 
-        case AVAHI_DNS_TYPE_A:
-            n += sizeof(AvahiIPv4Address);
+        case CATTA_DNS_TYPE_A:
+            n += sizeof(CattaIPv4Address);
             break;
 
-        case AVAHI_DNS_TYPE_AAAA:
-            n += sizeof(AvahiIPv6Address);
+        case CATTA_DNS_TYPE_AAAA:
+            n += sizeof(CattaIPv6Address);
             break;
 
         default:
@@ -552,18 +552,18 @@ static int uint16_cmp(uint16_t a, uint16_t b) {
     return a == b ? 0 : (a < b ? -1 : 1);
 }
 
-int avahi_record_lexicographical_compare(AvahiRecord *a, AvahiRecord *b) {
+int catta_record_lexicographical_compare(CattaRecord *a, CattaRecord *b) {
     int r;
 /*      char *t1, *t2; */
 
     assert(a);
     assert(b);
 
-/*     t1 = avahi_record_to_string(a); */
-/*     t2 = avahi_record_to_string(b); */
+/*     t1 = catta_record_to_string(a); */
+/*     t2 = catta_record_to_string(b); */
 /*     g_message("lexicocmp: %s %s", t1, t2); */
-/*     avahi_free(t1); */
-/*     avahi_free(t2); */
+/*     catta_free(t1); */
+/*     catta_free(t2); */
 
     if (a == b)
         return 0;
@@ -574,21 +574,21 @@ int avahi_record_lexicographical_compare(AvahiRecord *a, AvahiRecord *b) {
 
     switch (a->key->type) {
 
-        case AVAHI_DNS_TYPE_PTR:
-        case AVAHI_DNS_TYPE_CNAME:
-        case AVAHI_DNS_TYPE_NS:
-            return avahi_binary_domain_cmp(a->data.ptr.name, b->data.ptr.name);
+        case CATTA_DNS_TYPE_PTR:
+        case CATTA_DNS_TYPE_CNAME:
+        case CATTA_DNS_TYPE_NS:
+            return catta_binary_domain_cmp(a->data.ptr.name, b->data.ptr.name);
 
-        case AVAHI_DNS_TYPE_SRV: {
+        case CATTA_DNS_TYPE_SRV: {
             if ((r = uint16_cmp(a->data.srv.priority, b->data.srv.priority)) == 0 &&
                 (r = uint16_cmp(a->data.srv.weight, b->data.srv.weight)) == 0 &&
                 (r = uint16_cmp(a->data.srv.port, b->data.srv.port)) == 0)
-                r = avahi_binary_domain_cmp(a->data.srv.name, b->data.srv.name);
+                r = catta_binary_domain_cmp(a->data.srv.name, b->data.srv.name);
 
             return r;
         }
 
-        case AVAHI_DNS_TYPE_HINFO: {
+        case CATTA_DNS_TYPE_HINFO: {
 
             if ((r = strcmp(a->data.hinfo.cpu, b->data.hinfo.cpu)) ||
                 (r = strcmp(a->data.hinfo.os, b->data.hinfo.os)))
@@ -598,24 +598,24 @@ int avahi_record_lexicographical_compare(AvahiRecord *a, AvahiRecord *b) {
 
         }
 
-        case AVAHI_DNS_TYPE_TXT: {
+        case CATTA_DNS_TYPE_TXT: {
 
             uint8_t *ma = NULL, *mb = NULL;
             size_t asize, bsize;
 
-            asize = avahi_string_list_serialize(a->data.txt.string_list, NULL, 0);
-            bsize = avahi_string_list_serialize(b->data.txt.string_list, NULL, 0);
+            asize = catta_string_list_serialize(a->data.txt.string_list, NULL, 0);
+            bsize = catta_string_list_serialize(b->data.txt.string_list, NULL, 0);
 
-            if (asize > 0 && !(ma = avahi_new(uint8_t, asize)))
+            if (asize > 0 && !(ma = catta_new(uint8_t, asize)))
                 goto fail;
 
-            if (bsize > 0 && !(mb = avahi_new(uint8_t, bsize))) {
-                avahi_free(ma);
+            if (bsize > 0 && !(mb = catta_new(uint8_t, bsize))) {
+                catta_free(ma);
                 goto fail;
             }
 
-            avahi_string_list_serialize(a->data.txt.string_list, ma, asize);
-            avahi_string_list_serialize(b->data.txt.string_list, mb, bsize);
+            catta_string_list_serialize(a->data.txt.string_list, ma, asize);
+            catta_string_list_serialize(b->data.txt.string_list, mb, bsize);
 
             if (asize && bsize)
                 r = lexicographical_memcmp(ma, asize, mb, bsize);
@@ -626,17 +626,17 @@ int avahi_record_lexicographical_compare(AvahiRecord *a, AvahiRecord *b) {
             else
                 r = 0;
 
-            avahi_free(ma);
-            avahi_free(mb);
+            catta_free(ma);
+            catta_free(mb);
 
             return r;
         }
 
-        case AVAHI_DNS_TYPE_A:
-            return memcmp(&a->data.a.address, &b->data.a.address, sizeof(AvahiIPv4Address));
+        case CATTA_DNS_TYPE_A:
+            return memcmp(&a->data.a.address, &b->data.a.address, sizeof(CattaIPv4Address));
 
-        case AVAHI_DNS_TYPE_AAAA:
-            return memcmp(&a->data.aaaa.address, &b->data.aaaa.address, sizeof(AvahiIPv6Address));
+        case CATTA_DNS_TYPE_AAAA:
+            return memcmp(&a->data.aaaa.address, &b->data.aaaa.address, sizeof(CattaIPv6Address));
 
         default:
             return lexicographical_memcmp(a->data.generic.data, a->data.generic.size,
@@ -645,49 +645,49 @@ int avahi_record_lexicographical_compare(AvahiRecord *a, AvahiRecord *b) {
 
 
 fail:
-    avahi_log_error(__FILE__": Out of memory");
+    catta_log_error(__FILE__": Out of memory");
     return -1; /* or whatever ... */
 }
 
-int avahi_record_is_goodbye(AvahiRecord *r) {
+int catta_record_is_goodbye(CattaRecord *r) {
     assert(r);
 
     return r->ttl == 0;
 }
 
-int avahi_key_is_valid(AvahiKey *k) {
+int catta_key_is_valid(CattaKey *k) {
     assert(k);
 
-    if (!avahi_is_valid_domain_name(k->name))
+    if (!catta_is_valid_domain_name(k->name))
         return 0;
 
     return 1;
 }
 
-int avahi_record_is_valid(AvahiRecord *r) {
+int catta_record_is_valid(CattaRecord *r) {
     assert(r);
 
-    if (!avahi_key_is_valid(r->key))
+    if (!catta_key_is_valid(r->key))
         return 0;
 
     switch (r->key->type) {
 
-        case AVAHI_DNS_TYPE_PTR:
-        case AVAHI_DNS_TYPE_CNAME:
-        case AVAHI_DNS_TYPE_NS:
-            return avahi_is_valid_domain_name(r->data.ptr.name);
+        case CATTA_DNS_TYPE_PTR:
+        case CATTA_DNS_TYPE_CNAME:
+        case CATTA_DNS_TYPE_NS:
+            return catta_is_valid_domain_name(r->data.ptr.name);
 
-        case AVAHI_DNS_TYPE_SRV:
-            return avahi_is_valid_domain_name(r->data.srv.name);
+        case CATTA_DNS_TYPE_SRV:
+            return catta_is_valid_domain_name(r->data.srv.name);
 
-        case AVAHI_DNS_TYPE_HINFO:
+        case CATTA_DNS_TYPE_HINFO:
             return
                 strlen(r->data.hinfo.os) <= 255 &&
                 strlen(r->data.hinfo.cpu) <= 255;
 
-        case AVAHI_DNS_TYPE_TXT: {
+        case CATTA_DNS_TYPE_TXT: {
 
-            AvahiStringList *strlst;
+            CattaStringList *strlst;
 
             for (strlst = r->data.txt.string_list; strlst; strlst = strlst->next)
                 if (strlst->size > 255 || strlst->size <= 0)
@@ -700,17 +700,17 @@ int avahi_record_is_valid(AvahiRecord *r) {
     return 1;
 }
 
-static AvahiAddress *get_address(const AvahiRecord *r, AvahiAddress *a) {
+static CattaAddress *get_address(const CattaRecord *r, CattaAddress *a) {
     assert(r);
 
     switch (r->key->type) {
-        case AVAHI_DNS_TYPE_A:
-            a->proto = AVAHI_PROTO_INET;
+        case CATTA_DNS_TYPE_A:
+            a->proto = CATTA_PROTO_INET;
             a->data.ipv4 = r->data.a.address;
             break;
 
-        case AVAHI_DNS_TYPE_AAAA:
-            a->proto = AVAHI_PROTO_INET6;
+        case CATTA_DNS_TYPE_AAAA:
+            a->proto = CATTA_PROTO_INET6;
             a->data.ipv6 = r->data.aaaa.address;
             break;
 
@@ -721,13 +721,13 @@ static AvahiAddress *get_address(const AvahiRecord *r, AvahiAddress *a) {
     return a;
 }
 
-int avahi_record_is_link_local_address(const AvahiRecord *r) {
-    AvahiAddress a;
+int catta_record_is_link_local_address(const CattaRecord *r) {
+    CattaAddress a;
 
     assert(r);
 
     if (!get_address(r, &a))
         return 0;
 
-    return avahi_address_is_link_local(&a);
+    return catta_address_is_link_local(&a);
 }
index 04af0fa7464e2789e0938186020952f39139696e..2ccfdf72be4f38d4b15ba6a419a4643208620224 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <stdlib.h>
 #include <assert.h>
 
-#include <avahi/llist.h>
-#include <avahi/malloc.h>
+#include <catta/llist.h>
+#include <catta/malloc.h>
 
 #include "rrlist.h"
-#include <avahi/log.h>
+#include <catta/log.h>
 
-typedef struct AvahiRecordListItem AvahiRecordListItem;
+typedef struct CattaRecordListItem CattaRecordListItem;
 
-struct AvahiRecordListItem {
+struct CattaRecordListItem {
     int read;
-    AvahiRecord *record;
+    CattaRecord *record;
     int unicast_response;
     int flush_cache;
     int auxiliary;
-    AVAHI_LLIST_FIELDS(AvahiRecordListItem, items);
+    CATTA_LLIST_FIELDS(CattaRecordListItem, items);
 };
 
-struct AvahiRecordList {
-    AVAHI_LLIST_HEAD(AvahiRecordListItem, read);
-    AVAHI_LLIST_HEAD(AvahiRecordListItem, unread);
+struct CattaRecordList {
+    CATTA_LLIST_HEAD(CattaRecordListItem, read);
+    CATTA_LLIST_HEAD(CattaRecordListItem, unread);
 
     int all_flush_cache;
 };
 
-AvahiRecordList *avahi_record_list_new(void) {
-    AvahiRecordList *l;
+CattaRecordList *catta_record_list_new(void) {
+    CattaRecordList *l;
 
-    if (!(l = avahi_new(AvahiRecordList, 1))) {
-        avahi_log_error("avahi_new() failed.");
+    if (!(l = catta_new(CattaRecordList, 1))) {
+        catta_log_error("catta_new() failed.");
         return NULL;
     }
 
-    AVAHI_LLIST_HEAD_INIT(AvahiRecordListItem, l->read);
-    AVAHI_LLIST_HEAD_INIT(AvahiRecordListItem, l->unread);
+    CATTA_LLIST_HEAD_INIT(CattaRecordListItem, l->read);
+    CATTA_LLIST_HEAD_INIT(CattaRecordListItem, l->unread);
 
     l->all_flush_cache = 1;
     return l;
 }
 
-void avahi_record_list_free(AvahiRecordList *l) {
+void catta_record_list_free(CattaRecordList *l) {
     assert(l);
 
-    avahi_record_list_flush(l);
-    avahi_free(l);
+    catta_record_list_flush(l);
+    catta_free(l);
 }
 
-static void item_free(AvahiRecordList *l, AvahiRecordListItem *i) {
+static void item_free(CattaRecordList *l, CattaRecordListItem *i) {
     assert(l);
     assert(i);
 
     if (i->read)
-        AVAHI_LLIST_REMOVE(AvahiRecordListItem, items, l->read, i);
+        CATTA_LLIST_REMOVE(CattaRecordListItem, items, l->read, i);
     else
-        AVAHI_LLIST_REMOVE(AvahiRecordListItem, items, l->unread, i);
+        CATTA_LLIST_REMOVE(CattaRecordListItem, items, l->unread, i);
 
-    avahi_record_unref(i->record);
-    avahi_free(i);
+    catta_record_unref(i->record);
+    catta_free(i);
 }
 
-void avahi_record_list_flush(AvahiRecordList *l) {
+void catta_record_list_flush(CattaRecordList *l) {
     assert(l);
 
     while (l->read)
@@ -94,16 +94,16 @@ void avahi_record_list_flush(AvahiRecordList *l) {
     l->all_flush_cache = 1;
 }
 
-AvahiRecord* avahi_record_list_next(AvahiRecordList *l, int *ret_flush_cache, int *ret_unicast_response, int *ret_auxiliary) {
-    AvahiRecord *r;
-    AvahiRecordListItem *i;
+CattaRecord* catta_record_list_next(CattaRecordList *l, int *ret_flush_cache, int *ret_unicast_response, int *ret_auxiliary) {
+    CattaRecord *r;
+    CattaRecordListItem *i;
 
     if (!(i = l->unread))
         return NULL;
 
     assert(!i->read);
 
-    r = avahi_record_ref(i->record);
+    r = catta_record_ref(i->record);
     if (ret_unicast_response)
         *ret_unicast_response = i->unicast_response;
     if (ret_flush_cache)
@@ -111,33 +111,33 @@ AvahiRecord* avahi_record_list_next(AvahiRecordList *l, int *ret_flush_cache, in
     if (ret_auxiliary)
         *ret_auxiliary = i->auxiliary;
 
-    AVAHI_LLIST_REMOVE(AvahiRecordListItem, items, l->unread, i);
-    AVAHI_LLIST_PREPEND(AvahiRecordListItem, items, l->read, i);
+    CATTA_LLIST_REMOVE(CattaRecordListItem, items, l->unread, i);
+    CATTA_LLIST_PREPEND(CattaRecordListItem, items, l->read, i);
 
     i->read = 1;
 
     return r;
 }
 
-static AvahiRecordListItem *get(AvahiRecordList *l, AvahiRecord *r) {
-    AvahiRecordListItem *i;
+static CattaRecordListItem *get(CattaRecordList *l, CattaRecord *r) {
+    CattaRecordListItem *i;
 
     assert(l);
     assert(r);
 
     for (i = l->read; i; i = i->items_next)
-        if (avahi_record_equal_no_ttl(i->record, r))
+        if (catta_record_equal_no_ttl(i->record, r))
             return i;
 
     for (i = l->unread; i; i = i->items_next)
-        if (avahi_record_equal_no_ttl(i->record, r))
+        if (catta_record_equal_no_ttl(i->record, r))
             return i;
 
     return NULL;
 }
 
-void avahi_record_list_push(AvahiRecordList *l, AvahiRecord *r, int flush_cache, int unicast_response, int auxiliary) {
-    AvahiRecordListItem *i;
+void catta_record_list_push(CattaRecordList *l, CattaRecord *r, int flush_cache, int unicast_response, int auxiliary) {
+    CattaRecordListItem *i;
 
     assert(l);
     assert(r);
@@ -145,24 +145,24 @@ void avahi_record_list_push(AvahiRecordList *l, AvahiRecord *r, int flush_cache,
     if (get(l, r))
         return;
 
-    if (!(i = avahi_new(AvahiRecordListItem, 1))) {
-        avahi_log_error("avahi_new() failed.");
+    if (!(i = catta_new(CattaRecordListItem, 1))) {
+        catta_log_error("catta_new() failed.");
         return;
     }
 
     i->unicast_response = unicast_response;
     i->flush_cache = flush_cache;
     i->auxiliary = auxiliary;
-    i->record = avahi_record_ref(r);
+    i->record = catta_record_ref(r);
     i->read = 0;
 
     l->all_flush_cache = l->all_flush_cache && flush_cache;
 
-    AVAHI_LLIST_PREPEND(AvahiRecordListItem, items, l->unread, i);
+    CATTA_LLIST_PREPEND(CattaRecordListItem, items, l->unread, i);
 }
 
-void avahi_record_list_drop(AvahiRecordList *l, AvahiRecord *r) {
-    AvahiRecordListItem *i;
+void catta_record_list_drop(CattaRecordList *l, CattaRecord *r) {
+    CattaRecordListItem *i;
 
     assert(l);
     assert(r);
@@ -173,13 +173,13 @@ void avahi_record_list_drop(AvahiRecordList *l, AvahiRecord *r) {
     item_free(l, i);
 }
 
-int avahi_record_list_is_empty(AvahiRecordList *l) {
+int catta_record_list_is_empty(CattaRecordList *l) {
     assert(l);
 
     return !l->unread && !l->read;
 }
 
-int avahi_record_list_all_flush_cache(AvahiRecordList *l) {
+int catta_record_list_all_flush_cache(CattaRecordList *l) {
     assert(l);
 
     /* Return TRUE if all entries in this list have flush_cache set */
index c6aafe20ed35c9e54d8704c271750c1ce0ab4758..50252cf6963ac7eb604832f709c79152761fdf7a 100644 (file)
@@ -2,39 +2,39 @@
 #define foorrlisthfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 
-#include <avahi/rr.h>
+#include <catta/rr.h>
 
-typedef struct AvahiRecordList AvahiRecordList;
+typedef struct CattaRecordList CattaRecordList;
 
-AvahiRecordList *avahi_record_list_new(void);
-void avahi_record_list_free(AvahiRecordList *l);
-void avahi_record_list_flush(AvahiRecordList *l);
+CattaRecordList *catta_record_list_new(void);
+void catta_record_list_free(CattaRecordList *l);
+void catta_record_list_flush(CattaRecordList *l);
 
-AvahiRecord* avahi_record_list_next(AvahiRecordList *l, int *ret_flush_cache, int *ret_unicast_response, int *ret_auxiliary);
-void avahi_record_list_push(AvahiRecordList *l, AvahiRecord *r, int flush_cache, int unicast_response, int auxiliary);
-void avahi_record_list_drop(AvahiRecordList *l, AvahiRecord *r);
+CattaRecord* catta_record_list_next(CattaRecordList *l, int *ret_flush_cache, int *ret_unicast_response, int *ret_auxiliary);
+void catta_record_list_push(CattaRecordList *l, CattaRecord *r, int flush_cache, int unicast_response, int auxiliary);
+void catta_record_list_drop(CattaRecordList *l, CattaRecord *r);
 
-int avahi_record_list_all_flush_cache(AvahiRecordList *l);
+int catta_record_list_all_flush_cache(CattaRecordList *l);
 
-int avahi_record_list_is_empty(AvahiRecordList *l);
+int catta_record_list_is_empty(CattaRecordList *l);
 
 #endif
index 0d6d993a91f925066b8102ceac8bf7fa1b6f66ba..4dc0dd0a90229883cffdf47be0c65fe22a9a96e5 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <assert.h>
 #include <stdlib.h>
 
-#include <avahi/domain.h>
-#include <avahi/timeval.h>
-#include <avahi/malloc.h>
-#include <avahi/error.h>
-#include <avahi/log.h>
+#include <catta/domain.h>
+#include <catta/timeval.h>
+#include <catta/malloc.h>
+#include <catta/error.h>
+#include <catta/log.h>
 
 #include "internal.h"
 #include "iface.h"
 #include "domain-util.h"
 #include "rr-util.h"
 
-#define AVAHI_DEFAULT_CACHE_ENTRIES_MAX 4096
+#define CATTA_DEFAULT_CACHE_ENTRIES_MAX 4096
 
-static void enum_aux_records(AvahiServer *s, AvahiInterface *i, const char *name, uint16_t type, void (*callback)(AvahiServer *s, AvahiRecord *r, int flush_cache, void* userdata), void* userdata) {
+static void enum_aux_records(CattaServer *s, CattaInterface *i, const char *name, uint16_t type, void (*callback)(CattaServer *s, CattaRecord *r, int flush_cache, void* userdata), void* userdata) {
     assert(s);
     assert(i);
     assert(name);
     assert(callback);
 
-    if (type == AVAHI_DNS_TYPE_ANY) {
-        AvahiEntry *e;
+    if (type == CATTA_DNS_TYPE_ANY) {
+        CattaEntry *e;
 
         for (e = s->entries; e; e = e->entries_next)
             if (!e->dead &&
-                avahi_entry_is_registered(s, e, i) &&
-                e->record->key->clazz == AVAHI_DNS_CLASS_IN &&
-                avahi_domain_equal(name, e->record->key->name))
-                callback(s, e->record, e->flags & AVAHI_PUBLISH_UNIQUE, userdata);
+                catta_entry_is_registered(s, e, i) &&
+                e->record->key->clazz == CATTA_DNS_CLASS_IN &&
+                catta_domain_equal(name, e->record->key->name))
+                callback(s, e->record, e->flags & CATTA_PUBLISH_UNIQUE, userdata);
 
     } else {
-        AvahiEntry *e;
-        AvahiKey *k;
+        CattaEntry *e;
+        CattaKey *k;
 
-        if (!(k = avahi_key_new(name, AVAHI_DNS_CLASS_IN, type)))
+        if (!(k = catta_key_new(name, CATTA_DNS_CLASS_IN, type)))
             return; /** OOM */
 
-        for (e = avahi_hashmap_lookup(s->entries_by_key, k); e; e = e->by_key_next)
-            if (!e->dead && avahi_entry_is_registered(s, e, i))
-                callback(s, e->record, e->flags & AVAHI_PUBLISH_UNIQUE, userdata);
+        for (e = catta_hashmap_lookup(s->entries_by_key, k); e; e = e->by_key_next)
+            if (!e->dead && catta_entry_is_registered(s, e, i))
+                callback(s, e->record, e->flags & CATTA_PUBLISH_UNIQUE, userdata);
 
-        avahi_key_unref(k);
+        catta_key_unref(k);
     }
 }
 
-void avahi_server_enumerate_aux_records(AvahiServer *s, AvahiInterface *i, AvahiRecord *r, void (*callback)(AvahiServer *s, AvahiRecord *r, int flush_cache, void* userdata), void* userdata) {
+void catta_server_enumerate_aux_records(CattaServer *s, CattaInterface *i, CattaRecord *r, void (*callback)(CattaServer *s, CattaRecord *r, int flush_cache, void* userdata), void* userdata) {
     assert(s);
     assert(i);
     assert(r);
@@ -90,68 +90,68 @@ void avahi_server_enumerate_aux_records(AvahiServer *s, AvahiInterface *i, Avahi
 
     /* Call the specified callback far all records referenced by the one specified in *r */
 
-    if (r->key->clazz == AVAHI_DNS_CLASS_IN) {
-        if (r->key->type == AVAHI_DNS_TYPE_PTR) {
-            enum_aux_records(s, i, r->data.ptr.name, AVAHI_DNS_TYPE_SRV, callback, userdata);
-            enum_aux_records(s, i, r->data.ptr.name, AVAHI_DNS_TYPE_TXT, callback, userdata);
-        } else if (r->key->type == AVAHI_DNS_TYPE_SRV) {
-            enum_aux_records(s, i, r->data.srv.name, AVAHI_DNS_TYPE_A, callback, userdata);
-            enum_aux_records(s, i, r->data.srv.name, AVAHI_DNS_TYPE_AAAA, callback, userdata);
-        } else if (r->key->type == AVAHI_DNS_TYPE_CNAME)
-            enum_aux_records(s, i, r->data.cname.name, AVAHI_DNS_TYPE_ANY, callback, userdata);
+    if (r->key->clazz == CATTA_DNS_CLASS_IN) {
+        if (r->key->type == CATTA_DNS_TYPE_PTR) {
+            enum_aux_records(s, i, r->data.ptr.name, CATTA_DNS_TYPE_SRV, callback, userdata);
+            enum_aux_records(s, i, r->data.ptr.name, CATTA_DNS_TYPE_TXT, callback, userdata);
+        } else if (r->key->type == CATTA_DNS_TYPE_SRV) {
+            enum_aux_records(s, i, r->data.srv.name, CATTA_DNS_TYPE_A, callback, userdata);
+            enum_aux_records(s, i, r->data.srv.name, CATTA_DNS_TYPE_AAAA, callback, userdata);
+        } else if (r->key->type == CATTA_DNS_TYPE_CNAME)
+            enum_aux_records(s, i, r->data.cname.name, CATTA_DNS_TYPE_ANY, callback, userdata);
     }
 }
 
-void avahi_server_prepare_response(AvahiServer *s, AvahiInterface *i, AvahiEntry *e, int unicast_response, int auxiliary) {
+void catta_server_prepare_response(CattaServer *s, CattaInterface *i, CattaEntry *e, int unicast_response, int auxiliary) {
     assert(s);
     assert(i);
     assert(e);
 
-    avahi_record_list_push(s->record_list, e->record, e->flags & AVAHI_PUBLISH_UNIQUE, unicast_response, auxiliary);
+    catta_record_list_push(s->record_list, e->record, e->flags & CATTA_PUBLISH_UNIQUE, unicast_response, auxiliary);
 }
 
-void avahi_server_prepare_matching_responses(AvahiServer *s, AvahiInterface *i, AvahiKey *k, int unicast_response) {
+void catta_server_prepare_matching_responses(CattaServer *s, CattaInterface *i, CattaKey *k, int unicast_response) {
     assert(s);
     assert(i);
     assert(k);
 
     /* Push all records that match the specified key to the record list */
 
-    if (avahi_key_is_pattern(k)) {
-        AvahiEntry *e;
+    if (catta_key_is_pattern(k)) {
+        CattaEntry *e;
 
         /* Handle ANY query */
 
         for (e = s->entries; e; e = e->entries_next)
-            if (!e->dead && avahi_key_pattern_match(k, e->record->key) && avahi_entry_is_registered(s, e, i))
-                avahi_server_prepare_response(s, i, e, unicast_response, 0);
+            if (!e->dead && catta_key_pattern_match(k, e->record->key) && catta_entry_is_registered(s, e, i))
+                catta_server_prepare_response(s, i, e, unicast_response, 0);
 
     } else {
-        AvahiEntry *e;
+        CattaEntry *e;
 
         /* Handle all other queries */
 
-        for (e = avahi_hashmap_lookup(s->entries_by_key, k); e; e = e->by_key_next)
-            if (!e->dead && avahi_entry_is_registered(s, e, i))
-                avahi_server_prepare_response(s, i, e, unicast_response, 0);
+        for (e = catta_hashmap_lookup(s->entries_by_key, k); e; e = e->by_key_next)
+            if (!e->dead && catta_entry_is_registered(s, e, i))
+                catta_server_prepare_response(s, i, e, unicast_response, 0);
     }
 
     /* Look for CNAME records */
 
-    if ((k->clazz == AVAHI_DNS_CLASS_IN || k->clazz == AVAHI_DNS_CLASS_ANY)
-        && k->type != AVAHI_DNS_TYPE_CNAME && k->type != AVAHI_DNS_TYPE_ANY) {
+    if ((k->clazz == CATTA_DNS_CLASS_IN || k->clazz == CATTA_DNS_CLASS_ANY)
+        && k->type != CATTA_DNS_TYPE_CNAME && k->type != CATTA_DNS_TYPE_ANY) {
 
-        AvahiKey *cname_key;
+        CattaKey *cname_key;
 
-        if (!(cname_key = avahi_key_new(k->name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_CNAME)))
+        if (!(cname_key = catta_key_new(k->name, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_CNAME)))
             return;
 
-        avahi_server_prepare_matching_responses(s, i, cname_key, unicast_response);
-        avahi_key_unref(cname_key);
+        catta_server_prepare_matching_responses(s, i, cname_key, unicast_response);
+        catta_key_unref(cname_key);
     }
 }
 
-static void withdraw_entry(AvahiServer *s, AvahiEntry *e) {
+static void withdraw_entry(CattaServer *s, CattaEntry *e) {
     assert(s);
     assert(e);
 
@@ -162,39 +162,39 @@ static void withdraw_entry(AvahiServer *s, AvahiEntry *e) {
         return;
 
     if (e->group) {
-        AvahiEntry *k;
+        CattaEntry *k;
 
         for (k = e->group->entries; k; k = k->by_group_next)
             if (!k->dead) {
-                avahi_goodbye_entry(s, k, 0, 1);
+                catta_goodbye_entry(s, k, 0, 1);
                 k->dead = 1;
             }
 
         e->group->n_probing = 0;
 
-        avahi_s_entry_group_change_state(e->group, AVAHI_ENTRY_GROUP_COLLISION);
+        catta_s_entry_group_change_state(e->group, CATTA_ENTRY_GROUP_COLLISION);
     } else {
-        avahi_goodbye_entry(s, e, 0, 1);
+        catta_goodbye_entry(s, e, 0, 1);
         e->dead = 1;
     }
 
     s->need_entry_cleanup = 1;
 }
 
-static void withdraw_rrset(AvahiServer *s, AvahiKey *key) {
-    AvahiEntry *e;
+static void withdraw_rrset(CattaServer *s, CattaKey *key) {
+    CattaEntry *e;
 
     assert(s);
     assert(key);
 
     /* Withdraw an entry RRSset */
 
-    for (e = avahi_hashmap_lookup(s->entries_by_key, key); e; e = e->by_key_next)
+    for (e = catta_hashmap_lookup(s->entries_by_key, key); e; e = e->by_key_next)
         withdraw_entry(s, e);
 }
 
-static void incoming_probe(AvahiServer *s, AvahiRecord *record, AvahiInterface *i) {
-    AvahiEntry *e, *n;
+static void incoming_probe(CattaServer *s, CattaRecord *record, CattaInterface *i) {
+    CattaEntry *e, *n;
     int ours = 0, won = 0, lost = 0;
 
     assert(s);
@@ -203,19 +203,19 @@ static void incoming_probe(AvahiServer *s, AvahiRecord *record, AvahiInterface *
 
     /* Handle incoming probes and check if they conflict our own probes */
 
-    for (e = avahi_hashmap_lookup(s->entries_by_key, record->key); e; e = n) {
+    for (e = catta_hashmap_lookup(s->entries_by_key, record->key); e; e = n) {
         int cmp;
         n = e->by_key_next;
 
         if (e->dead)
             continue;
 
-        if ((cmp = avahi_record_lexicographical_compare(e->record, record)) == 0) {
+        if ((cmp = catta_record_lexicographical_compare(e->record, record)) == 0) {
             ours = 1;
             break;
         } else {
 
-            if (avahi_entry_is_probing(s, e, i)) {
+            if (catta_entry_is_probing(s, e, i)) {
                 if (cmp > 0)
                     won = 1;
                 else /* cmp < 0 */
@@ -225,22 +225,22 @@ static void incoming_probe(AvahiServer *s, AvahiRecord *record, AvahiInterface *
     }
 
     if (!ours) {
-        char *t = avahi_record_to_string(record);
+        char *t = catta_record_to_string(record);
 
         if (won)
-            avahi_log_debug("Received conflicting probe [%s]. Local host won.", t);
+            catta_log_debug("Received conflicting probe [%s]. Local host won.", t);
         else if (lost) {
-            avahi_log_debug("Received conflicting probe [%s]. Local host lost. Withdrawing.", t);
+            catta_log_debug("Received conflicting probe [%s]. Local host lost. Withdrawing.", t);
             withdraw_rrset(s, record->key);
         }
 
-        avahi_free(t);
+        catta_free(t);
     }
 }
 
-static int handle_conflict(AvahiServer *s, AvahiInterface *i, AvahiRecord *record, int unique) {
+static int handle_conflict(CattaServer *s, CattaInterface *i, CattaRecord *record, int unique) {
     int valid = 1, ours = 0, conflict = 0, withdraw_immediately = 0;
-    AvahiEntry *e, *n, *conflicting_entry = NULL;
+    CattaEntry *e, *n, *conflicting_entry = NULL;
 
     assert(s);
     assert(i);
@@ -248,25 +248,25 @@ static int handle_conflict(AvahiServer *s, AvahiInterface *i, AvahiRecord *recor
 
     /* Check whether an incoming record conflicts with one of our own */
 
-    for (e = avahi_hashmap_lookup(s->entries_by_key, record->key); e; e = n) {
+    for (e = catta_hashmap_lookup(s->entries_by_key, record->key); e; e = n) {
         n = e->by_key_next;
 
         if (e->dead)
             continue;
 
         /* Check if the incoming is a goodbye record */
-        if (avahi_record_is_goodbye(record)) {
+        if (catta_record_is_goodbye(record)) {
 
-            if (avahi_record_equal_no_ttl(e->record, record)) {
+            if (catta_record_equal_no_ttl(e->record, record)) {
                 char *t;
 
                 /* Refresh */
-                t = avahi_record_to_string(record);
-                avahi_log_debug("Received goodbye record for one of our records [%s]. Refreshing.", t);
-                avahi_server_prepare_matching_responses(s, i, e->record->key, 0);
+                t = catta_record_to_string(record);
+                catta_log_debug("Received goodbye record for one of our records [%s]. Refreshing.", t);
+                catta_server_prepare_matching_responses(s, i, e->record->key, 0);
 
                 valid = 0;
-                avahi_free(t);
+                catta_free(t);
                 break;
             }
 
@@ -274,26 +274,26 @@ static int handle_conflict(AvahiServer *s, AvahiInterface *i, AvahiRecord *recor
             continue;
         }
 
-        if (!(e->flags & AVAHI_PUBLISH_UNIQUE) && !unique)
+        if (!(e->flags & CATTA_PUBLISH_UNIQUE) && !unique)
             continue;
 
         /* Either our entry or the other is intended to be unique, so let's check */
 
-        if (avahi_record_equal_no_ttl(e->record, record)) {
+        if (catta_record_equal_no_ttl(e->record, record)) {
             ours = 1; /* We have an identical record, so this is no conflict */
 
             /* Check wheter there is a TTL conflict */
             if (record->ttl <= e->record->ttl/2 &&
-                avahi_entry_is_registered(s, e, i)) {
+                catta_entry_is_registered(s, e, i)) {
                 char *t;
                 /* Refresh */
-                t = avahi_record_to_string(record);
+                t = catta_record_to_string(record);
 
-                avahi_log_debug("Received record with bad TTL [%s]. Refreshing.", t);
-                avahi_server_prepare_matching_responses(s, i, e->record->key, 0);
+                catta_log_debug("Received record with bad TTL [%s]. Refreshing.", t);
+                catta_server_prepare_matching_responses(s, i, e->record->key, 0);
                 valid = 0;
 
-                avahi_free(t);
+                catta_free(t);
             }
 
             /* There's no need to check the other entries of this RRset */
@@ -301,13 +301,13 @@ static int handle_conflict(AvahiServer *s, AvahiInterface *i, AvahiRecord *recor
 
         } else {
 
-            if (avahi_entry_is_registered(s, e, i)) {
+            if (catta_entry_is_registered(s, e, i)) {
 
                 /* A conflict => we have to return to probe mode */
                 conflict = 1;
                 conflicting_entry = e;
 
-            } else if (avahi_entry_is_probing(s, e, i)) {
+            } else if (catta_entry_is_probing(s, e, i)) {
 
                 /* We are currently registering a matching record, but
                  * someone else already claimed it, so let's
@@ -323,87 +323,87 @@ static int handle_conflict(AvahiServer *s, AvahiInterface *i, AvahiRecord *recor
 
         valid = 0;
 
-        t = avahi_record_to_string(record);
+        t = catta_record_to_string(record);
 
         if (withdraw_immediately) {
-            avahi_log_debug("Received conflicting record [%s] with local record to be. Withdrawing.", t);
+            catta_log_debug("Received conflicting record [%s] with local record to be. Withdrawing.", t);
             withdraw_rrset(s, record->key);
         } else {
             assert(conflicting_entry);
-            avahi_log_debug("Received conflicting record [%s]. Resetting our record.", t);
-            avahi_entry_return_to_initial_state(s, conflicting_entry, i);
+            catta_log_debug("Received conflicting record [%s]. Resetting our record.", t);
+            catta_entry_return_to_initial_state(s, conflicting_entry, i);
 
             /* Local unique records are returned to probing
              * state. Local shared records are reannounced. */
         }
 
-        avahi_free(t);
+        catta_free(t);
     }
 
     return valid;
 }
 
-static void append_aux_callback(AvahiServer *s, AvahiRecord *r, int flush_cache, void* userdata) {
+static void append_aux_callback(CattaServer *s, CattaRecord *r, int flush_cache, void* userdata) {
     int *unicast_response = userdata;
 
     assert(s);
     assert(r);
     assert(unicast_response);
 
-    avahi_record_list_push(s->record_list, r, flush_cache, *unicast_response, 1);
+    catta_record_list_push(s->record_list, r, flush_cache, *unicast_response, 1);
 }
 
-static void append_aux_records_to_list(AvahiServer *s, AvahiInterface *i, AvahiRecord *r, int unicast_response) {
+static void append_aux_records_to_list(CattaServer *s, CattaInterface *i, CattaRecord *r, int unicast_response) {
     assert(s);
     assert(r);
 
-    avahi_server_enumerate_aux_records(s, i, r, append_aux_callback, &unicast_response);
+    catta_server_enumerate_aux_records(s, i, r, append_aux_callback, &unicast_response);
 }
 
-void avahi_server_generate_response(AvahiServer *s, AvahiInterface *i, AvahiDnsPacket *p, const AvahiAddress *a, uint16_t port, int legacy_unicast, int immediately) {
+void catta_server_generate_response(CattaServer *s, CattaInterface *i, CattaDnsPacket *p, const CattaAddress *a, uint16_t port, int legacy_unicast, int immediately) {
 
     assert(s);
     assert(i);
     assert(!legacy_unicast || (a && port > 0 && p));
 
     if (legacy_unicast) {
-        AvahiDnsPacket *reply;
-        AvahiRecord *r;
+        CattaDnsPacket *reply;
+        CattaRecord *r;
 
-        if (!(reply = avahi_dns_packet_new_reply(p, 512 + AVAHI_DNS_PACKET_EXTRA_SIZE /* unicast DNS maximum packet size is 512 */ , 1, 1)))
+        if (!(reply = catta_dns_packet_new_reply(p, 512 + CATTA_DNS_PACKET_EXTRA_SIZE /* unicast DNS maximum packet size is 512 */ , 1, 1)))
             return; /* OOM */
 
-        while ((r = avahi_record_list_next(s->record_list, NULL, NULL, NULL))) {
+        while ((r = catta_record_list_next(s->record_list, NULL, NULL, NULL))) {
 
             append_aux_records_to_list(s, i, r, 0);
 
-            if (avahi_dns_packet_append_record(reply, r, 0, 10))
-                avahi_dns_packet_inc_field(reply, AVAHI_DNS_FIELD_ANCOUNT);
+            if (catta_dns_packet_append_record(reply, r, 0, 10))
+                catta_dns_packet_inc_field(reply, CATTA_DNS_FIELD_ANCOUNT);
             else {
-                char *t = avahi_record_to_string(r);
-                avahi_log_warn("Record [%s] not fitting in legacy unicast packet, dropping.", t);
-                avahi_free(t);
+                char *t = catta_record_to_string(r);
+                catta_log_warn("Record [%s] not fitting in legacy unicast packet, dropping.", t);
+                catta_free(t);
             }
 
-            avahi_record_unref(r);
+            catta_record_unref(r);
         }
 
-        if (avahi_dns_packet_get_field(reply, AVAHI_DNS_FIELD_ANCOUNT) != 0)
-            avahi_interface_send_packet_unicast(i, reply, a, port);
+        if (catta_dns_packet_get_field(reply, CATTA_DNS_FIELD_ANCOUNT) != 0)
+            catta_interface_send_packet_unicast(i, reply, a, port);
 
-        avahi_dns_packet_free(reply);
+        catta_dns_packet_free(reply);
 
     } else {
         int unicast_response, flush_cache, auxiliary;
-        AvahiDnsPacket *reply = NULL;
-        AvahiRecord *r;
+        CattaDnsPacket *reply = NULL;
+        CattaRecord *r;
 
         /* In case the query packet was truncated never respond
         immediately, because known answer suppression records might be
         contained in later packets */
-        int tc = p && !!(avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_FLAGS) & AVAHI_DNS_FLAG_TC);
+        int tc = p && !!(catta_dns_packet_get_field(p, CATTA_DNS_FIELD_FLAGS) & CATTA_DNS_FLAG_TC);
 
-        while ((r = avahi_record_list_next(s->record_list, &flush_cache, &unicast_response, &auxiliary))) {
+        while ((r = catta_record_list_next(s->record_list, &flush_cache, &unicast_response, &auxiliary))) {
 
             int im = immediately;
 
@@ -412,10 +412,10 @@ void avahi_server_generate_response(AvahiServer *s, AvahiInterface *i, AvahiDnsP
              * packet AND it is not an auxiliary record AND all other
              * responses for this record are unique too. */
 
-            if (flush_cache && !tc && !auxiliary && avahi_record_list_all_flush_cache(s->record_list))
+            if (flush_cache && !tc && !auxiliary && catta_record_list_all_flush_cache(s->record_list))
                 im = 1;
 
-            if (!avahi_interface_post_response(i, r, flush_cache, a, im) && unicast_response) {
+            if (!catta_interface_post_response(i, r, flush_cache, a, im) && unicast_response) {
 
                 /* Due to some reasons the record has not been scheduled.
                  * The client requested an unicast response in that
@@ -428,36 +428,36 @@ void avahi_server_generate_response(AvahiServer *s, AvahiInterface *i, AvahiDnsP
                     if (!reply) {
                         assert(p);
 
-                        if (!(reply = avahi_dns_packet_new_reply(p, i->hardware->mtu, 0, 0)))
+                        if (!(reply = catta_dns_packet_new_reply(p, i->hardware->mtu, 0, 0)))
                             break; /* OOM */
                     }
 
-                    if (avahi_dns_packet_append_record(reply, r, flush_cache, 0)) {
+                    if (catta_dns_packet_append_record(reply, r, flush_cache, 0)) {
 
                         /* Appending this record succeeded, so incremeant
                          * the specific header field, and return to the caller */
 
-                        avahi_dns_packet_inc_field(reply, AVAHI_DNS_FIELD_ANCOUNT);
+                        catta_dns_packet_inc_field(reply, CATTA_DNS_FIELD_ANCOUNT);
                         break;
                     }
 
-                    if (avahi_dns_packet_get_field(reply, AVAHI_DNS_FIELD_ANCOUNT) == 0) {
+                    if (catta_dns_packet_get_field(reply, CATTA_DNS_FIELD_ANCOUNT) == 0) {
                         size_t size;
 
                         /* The record is too large for one packet, so create a larger packet */
 
-                        avahi_dns_packet_free(reply);
-                        size = avahi_record_get_estimate_size(r) + AVAHI_DNS_PACKET_HEADER_SIZE;
+                        catta_dns_packet_free(reply);
+                        size = catta_record_get_estimate_size(r) + CATTA_DNS_PACKET_HEADER_SIZE;
 
-                        if (!(reply = avahi_dns_packet_new_reply(p, size + AVAHI_DNS_PACKET_EXTRA_SIZE, 0, 1)))
+                        if (!(reply = catta_dns_packet_new_reply(p, size + CATTA_DNS_PACKET_EXTRA_SIZE, 0, 1)))
                             break; /* OOM */
 
-                        if (avahi_dns_packet_append_record(reply, r, flush_cache, 0)) {
+                        if (catta_dns_packet_append_record(reply, r, flush_cache, 0)) {
 
                             /* Appending this record succeeded, so incremeant
                              * the specific header field, and return to the caller */
 
-                            avahi_dns_packet_inc_field(reply, AVAHI_DNS_FIELD_ANCOUNT);
+                            catta_dns_packet_inc_field(reply, CATTA_DNS_FIELD_ANCOUNT);
                             break;
 
                         }  else {
@@ -467,37 +467,37 @@ void avahi_server_generate_response(AvahiServer *s, AvahiInterface *i, AvahiDnsP
                              * fit in. Let's ignore it. */
 
                             char *t;
-                            avahi_dns_packet_free(reply);
+                            catta_dns_packet_free(reply);
                             reply = NULL;
-                            t = avahi_record_to_string(r);
-                            avahi_log_warn("Record [%s] too large, doesn't fit in any packet!", t);
-                            avahi_free(t);
+                            t = catta_record_to_string(r);
+                            catta_log_warn("Record [%s] too large, doesn't fit in any packet!", t);
+                            catta_free(t);
                             break;
                         }
                     }
 
                     /* Appending the record didn't succeeed, so let's send this packet, and create a new one */
-                    avahi_interface_send_packet_unicast(i, reply, a, port);
-                    avahi_dns_packet_free(reply);
+                    catta_interface_send_packet_unicast(i, reply, a, port);
+                    catta_dns_packet_free(reply);
                     reply = NULL;
                 }
             }
 
-            avahi_record_unref(r);
+            catta_record_unref(r);
         }
 
         if (reply) {
-            if (avahi_dns_packet_get_field(reply, AVAHI_DNS_FIELD_ANCOUNT) != 0)
-                avahi_interface_send_packet_unicast(i, reply, a, port);
-            avahi_dns_packet_free(reply);
+            if (catta_dns_packet_get_field(reply, CATTA_DNS_FIELD_ANCOUNT) != 0)
+                catta_interface_send_packet_unicast(i, reply, a, port);
+            catta_dns_packet_free(reply);
         }
     }
 
-    avahi_record_list_flush(s->record_list);
+    catta_record_list_flush(s->record_list);
 }
 
-static void reflect_response(AvahiServer *s, AvahiInterface *i, AvahiRecord *r, int flush_cache) {
-    AvahiInterface *j;
+static void reflect_response(CattaServer *s, CattaInterface *i, CattaRecord *r, int flush_cache) {
+    CattaInterface *j;
 
     assert(s);
     assert(i);
@@ -508,12 +508,12 @@ static void reflect_response(AvahiServer *s, AvahiInterface *i, AvahiRecord *r,
 
     for (j = s->monitor->interfaces; j; j = j->interface_next)
         if (j != i && (s->config.reflect_ipv || j->protocol == i->protocol))
-            avahi_interface_post_response(j, r, flush_cache, NULL, 1);
+            catta_interface_post_response(j, r, flush_cache, NULL, 1);
 }
 
-static void* reflect_cache_walk_callback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEntry *e, void* userdata) {
-    AvahiServer *s = userdata;
-    AvahiRecord* r;
+static void* reflect_cache_walk_callback(CattaCache *c, CattaKey *pattern, CattaCacheEntry *e, void* userdata) {
+    CattaServer *s = userdata;
+    CattaRecord* r;
 
     assert(c);
     assert(pattern);
@@ -522,17 +522,17 @@ static void* reflect_cache_walk_callback(AvahiCache *c, AvahiKey *pattern, Avahi
 
     /* Don't reflect cache entry with ipv6 link-local addresses. */
     r = e->record;
-    if ((r->key->type == AVAHI_DNS_TYPE_AAAA) &&
+    if ((r->key->type == CATTA_DNS_TYPE_AAAA) &&
             (r->data.aaaa.address.address[0] == 0xFE) &&
             (r->data.aaaa.address.address[1] == 0x80))
       return NULL;
 
-    avahi_record_list_push(s->record_list, e->record, e->cache_flush, 0, 0);
+    catta_record_list_push(s->record_list, e->record, e->cache_flush, 0, 0);
     return NULL;
 }
 
-static void reflect_query(AvahiServer *s, AvahiInterface *i, AvahiKey *k) {
-    AvahiInterface *j;
+static void reflect_query(CattaServer *s, CattaInterface *i, CattaKey *k) {
+    CattaInterface *j;
 
     assert(s);
     assert(i);
@@ -544,17 +544,17 @@ static void reflect_query(AvahiServer *s, AvahiInterface *i, AvahiKey *k) {
     for (j = s->monitor->interfaces; j; j = j->interface_next)
         if (j != i && (s->config.reflect_ipv || j->protocol == i->protocol)) {
             /* Post the query to other networks */
-            avahi_interface_post_query(j, k, 1, NULL);
+            catta_interface_post_query(j, k, 1, NULL);
 
             /* Reply from caches of other network. This is needed to
              * "work around" known answer suppression. */
 
-            avahi_cache_walk(j->cache, k, reflect_cache_walk_callback, s);
+            catta_cache_walk(j->cache, k, reflect_cache_walk_callback, s);
         }
 }
 
-static void reflect_probe(AvahiServer *s, AvahiInterface *i, AvahiRecord *r) {
-    AvahiInterface *j;
+static void reflect_probe(CattaServer *s, CattaInterface *i, CattaRecord *r) {
+    CattaInterface *j;
 
     assert(s);
     assert(i);
@@ -565,10 +565,10 @@ static void reflect_probe(AvahiServer *s, AvahiInterface *i, AvahiRecord *r) {
 
     for (j = s->monitor->interfaces; j; j = j->interface_next)
         if (j != i && (s->config.reflect_ipv || j->protocol == i->protocol))
-            avahi_interface_post_probe(j, r, 1);
+            catta_interface_post_probe(j, r, 1);
 }
 
-static void handle_query_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInterface *i, const AvahiAddress *a, uint16_t port, int legacy_unicast, int from_local_iface) {
+static void handle_query_packet(CattaServer *s, CattaDnsPacket *p, CattaInterface *i, const CattaAddress *a, uint16_t port, int legacy_unicast, int from_local_iface) {
     size_t n;
     int is_probe;
 
@@ -577,85 +577,85 @@ static void handle_query_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInterfac
     assert(i);
     assert(a);
 
-    assert(avahi_record_list_is_empty(s->record_list));
+    assert(catta_record_list_is_empty(s->record_list));
 
-    is_probe = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_NSCOUNT) > 0;
+    is_probe = catta_dns_packet_get_field(p, CATTA_DNS_FIELD_NSCOUNT) > 0;
 
     /* Handle the questions */
-    for (n = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_QDCOUNT); n > 0; n --) {
-        AvahiKey *key;
+    for (n = catta_dns_packet_get_field(p, CATTA_DNS_FIELD_QDCOUNT); n > 0; n --) {
+        CattaKey *key;
         int unicast_response = 0;
 
-        if (!(key = avahi_dns_packet_consume_key(p, &unicast_response))) {
-            avahi_log_warn(__FILE__": Packet too short or invalid while reading question key. (Maybe a UTF-8 problem?)");
+        if (!(key = catta_dns_packet_consume_key(p, &unicast_response))) {
+            catta_log_warn(__FILE__": Packet too short or invalid while reading question key. (Maybe a UTF-8 problem?)");
             goto fail;
         }
 
         if (!legacy_unicast && !from_local_iface) {
             reflect_query(s, i, key);
             if (!unicast_response)
-              avahi_cache_start_poof(i->cache, key, a);
+              catta_cache_start_poof(i->cache, key, a);
         }
 
-        if (avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ANCOUNT) == 0 &&
-            !(avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_FLAGS) & AVAHI_DNS_FLAG_TC))
+        if (catta_dns_packet_get_field(p, CATTA_DNS_FIELD_ANCOUNT) == 0 &&
+            !(catta_dns_packet_get_field(p, CATTA_DNS_FIELD_FLAGS) & CATTA_DNS_FLAG_TC))
             /* Allow our own queries to be suppressed by incoming
              * queries only when they do not include known answers */
-            avahi_query_scheduler_incoming(i->query_scheduler, key);
+            catta_query_scheduler_incoming(i->query_scheduler, key);
 
-        avahi_server_prepare_matching_responses(s, i, key, unicast_response);
-        avahi_key_unref(key);
+        catta_server_prepare_matching_responses(s, i, key, unicast_response);
+        catta_key_unref(key);
     }
 
     if (!legacy_unicast) {
 
         /* Known Answer Suppression */
-        for (n = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ANCOUNT); n > 0; n --) {
-            AvahiRecord *record;
+        for (n = catta_dns_packet_get_field(p, CATTA_DNS_FIELD_ANCOUNT); n > 0; n --) {
+            CattaRecord *record;
             int unique = 0;
 
-            if (!(record = avahi_dns_packet_consume_record(p, &unique))) {
-                avahi_log_warn(__FILE__": Packet too short or invalid while reading known answer record. (Maybe a UTF-8 problem?)");
+            if (!(record = catta_dns_packet_consume_record(p, &unique))) {
+                catta_log_warn(__FILE__": Packet too short or invalid while reading known answer record. (Maybe a UTF-8 problem?)");
                 goto fail;
             }
 
-            avahi_response_scheduler_suppress(i->response_scheduler, record, a);
-            avahi_record_list_drop(s->record_list, record);
-            avahi_cache_stop_poof(i->cache, record, a);
+            catta_response_scheduler_suppress(i->response_scheduler, record, a);
+            catta_record_list_drop(s->record_list, record);
+            catta_cache_stop_poof(i->cache, record, a);
 
-            avahi_record_unref(record);
+            catta_record_unref(record);
         }
 
         /* Probe record */
-        for (n = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_NSCOUNT); n > 0; n --) {
-            AvahiRecord *record;
+        for (n = catta_dns_packet_get_field(p, CATTA_DNS_FIELD_NSCOUNT); n > 0; n --) {
+            CattaRecord *record;
             int unique = 0;
 
-            if (!(record = avahi_dns_packet_consume_record(p, &unique))) {
-                avahi_log_warn(__FILE__": Packet too short or invalid while reading probe record. (Maybe a UTF-8 problem?)");
+            if (!(record = catta_dns_packet_consume_record(p, &unique))) {
+                catta_log_warn(__FILE__": Packet too short or invalid while reading probe record. (Maybe a UTF-8 problem?)");
                 goto fail;
             }
 
-            if (!avahi_key_is_pattern(record->key)) {
+            if (!catta_key_is_pattern(record->key)) {
                 if (!from_local_iface)
                     reflect_probe(s, i, record);
                 incoming_probe(s, record, i);
             }
 
-            avahi_record_unref(record);
+            catta_record_unref(record);
         }
     }
 
-    if (!avahi_record_list_is_empty(s->record_list))
-        avahi_server_generate_response(s, i, p, a, port, legacy_unicast, is_probe);
+    if (!catta_record_list_is_empty(s->record_list))
+        catta_server_generate_response(s, i, p, a, port, legacy_unicast, is_probe);
 
     return;
 
 fail:
-    avahi_record_list_flush(s->record_list);
+    catta_record_list_flush(s->record_list);
 }
 
-static void handle_response_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInterface *i, const AvahiAddress *a, int from_local_iface) {
+static void handle_response_packet(CattaServer *s, CattaDnsPacket *p, CattaInterface *i, const CattaAddress *a, int from_local_iface) {
     unsigned n;
 
     assert(s);
@@ -663,47 +663,47 @@ static void handle_response_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInter
     assert(i);
     assert(a);
 
-    for (n = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ANCOUNT) +
-             avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ARCOUNT); n > 0; n--) {
-        AvahiRecord *record;
+    for (n = catta_dns_packet_get_field(p, CATTA_DNS_FIELD_ANCOUNT) +
+             catta_dns_packet_get_field(p, CATTA_DNS_FIELD_ARCOUNT); n > 0; n--) {
+        CattaRecord *record;
         int cache_flush = 0;
 
-        if (!(record = avahi_dns_packet_consume_record(p, &cache_flush))) {
-            avahi_log_warn(__FILE__": Packet too short or invalid while reading response record. (Maybe a UTF-8 problem?)");
+        if (!(record = catta_dns_packet_consume_record(p, &cache_flush))) {
+            catta_log_warn(__FILE__": Packet too short or invalid while reading response record. (Maybe a UTF-8 problem?)");
             break;
         }
 
-        if (!avahi_key_is_pattern(record->key)) {
+        if (!catta_key_is_pattern(record->key)) {
 
             if (handle_conflict(s, i, record, cache_flush)) {
-                if (!from_local_iface && !avahi_record_is_link_local_address(record))
+                if (!from_local_iface && !catta_record_is_link_local_address(record))
                     reflect_response(s, i, record, cache_flush);
-                avahi_cache_update(i->cache, record, cache_flush, a);
-                avahi_response_scheduler_incoming(i->response_scheduler, record, cache_flush);
+                catta_cache_update(i->cache, record, cache_flush, a);
+                catta_response_scheduler_incoming(i->response_scheduler, record, cache_flush);
             }
         }
 
-        avahi_record_unref(record);
+        catta_record_unref(record);
     }
 
     /* If the incoming response contained a conflicting record, some
        records have been scheduled for sending. We need to flush them
        here. */
-    if (!avahi_record_list_is_empty(s->record_list))
-        avahi_server_generate_response(s, i, NULL, NULL, 0, 0, 1);
+    if (!catta_record_list_is_empty(s->record_list))
+        catta_server_generate_response(s, i, NULL, NULL, 0, 0, 1);
 }
 
-static AvahiLegacyUnicastReflectSlot* allocate_slot(AvahiServer *s) {
+static CattaLegacyUnicastReflectSlot* allocate_slot(CattaServer *s) {
     unsigned n, idx = (unsigned) -1;
-    AvahiLegacyUnicastReflectSlot *slot;
+    CattaLegacyUnicastReflectSlot *slot;
 
     assert(s);
 
     if (!s->legacy_unicast_reflect_slots)
-        s->legacy_unicast_reflect_slots = avahi_new0(AvahiLegacyUnicastReflectSlot*, AVAHI_LEGACY_UNICAST_REFLECT_SLOTS_MAX);
+        s->legacy_unicast_reflect_slots = catta_new0(CattaLegacyUnicastReflectSlot*, CATTA_LEGACY_UNICAST_REFLECT_SLOTS_MAX);
 
-    for (n = 0; n < AVAHI_LEGACY_UNICAST_REFLECT_SLOTS_MAX; n++, s->legacy_unicast_reflect_id++) {
-        idx = s->legacy_unicast_reflect_id % AVAHI_LEGACY_UNICAST_REFLECT_SLOTS_MAX;
+    for (n = 0; n < CATTA_LEGACY_UNICAST_REFLECT_SLOTS_MAX; n++, s->legacy_unicast_reflect_id++) {
+        idx = s->legacy_unicast_reflect_id % CATTA_LEGACY_UNICAST_REFLECT_SLOTS_MAX;
 
         if (!s->legacy_unicast_reflect_slots[idx])
             break;
@@ -712,7 +712,7 @@ static AvahiLegacyUnicastReflectSlot* allocate_slot(AvahiServer *s) {
     if (idx == (unsigned) -1 || s->legacy_unicast_reflect_slots[idx])
         return NULL;
 
-    if (!(slot = avahi_new(AvahiLegacyUnicastReflectSlot, 1)))
+    if (!(slot = catta_new(CattaLegacyUnicastReflectSlot, 1)))
         return NULL; /* OOM */
 
     s->legacy_unicast_reflect_slots[idx] = slot;
@@ -722,38 +722,38 @@ static AvahiLegacyUnicastReflectSlot* allocate_slot(AvahiServer *s) {
     return slot;
 }
 
-static void deallocate_slot(AvahiServer *s, AvahiLegacyUnicastReflectSlot *slot) {
+static void deallocate_slot(CattaServer *s, CattaLegacyUnicastReflectSlot *slot) {
     unsigned idx;
 
     assert(s);
     assert(slot);
 
-    idx = slot->id % AVAHI_LEGACY_UNICAST_REFLECT_SLOTS_MAX;
+    idx = slot->id % CATTA_LEGACY_UNICAST_REFLECT_SLOTS_MAX;
 
     assert(s->legacy_unicast_reflect_slots[idx] == slot);
 
-    avahi_time_event_free(slot->time_event);
+    catta_time_event_free(slot->time_event);
 
-    avahi_free(slot);
+    catta_free(slot);
     s->legacy_unicast_reflect_slots[idx] = NULL;
 }
 
-static void free_slots(AvahiServer *s) {
+static void free_slots(CattaServer *s) {
     unsigned idx;
     assert(s);
 
     if (!s->legacy_unicast_reflect_slots)
         return;
 
-    for (idx = 0; idx < AVAHI_LEGACY_UNICAST_REFLECT_SLOTS_MAX; idx ++)
+    for (idx = 0; idx < CATTA_LEGACY_UNICAST_REFLECT_SLOTS_MAX; idx ++)
         if (s->legacy_unicast_reflect_slots[idx])
             deallocate_slot(s, s->legacy_unicast_reflect_slots[idx]);
 
-    avahi_free(s->legacy_unicast_reflect_slots);
+    catta_free(s->legacy_unicast_reflect_slots);
     s->legacy_unicast_reflect_slots = NULL;
 }
 
-static AvahiLegacyUnicastReflectSlot* find_slot(AvahiServer *s, uint16_t id) {
+static CattaLegacyUnicastReflectSlot* find_slot(CattaServer *s, uint16_t id) {
     unsigned idx;
 
     assert(s);
@@ -761,7 +761,7 @@ static AvahiLegacyUnicastReflectSlot* find_slot(AvahiServer *s, uint16_t id) {
     if (!s->legacy_unicast_reflect_slots)
         return NULL;
 
-    idx = id % AVAHI_LEGACY_UNICAST_REFLECT_SLOTS_MAX;
+    idx = id % CATTA_LEGACY_UNICAST_REFLECT_SLOTS_MAX;
 
     if (!s->legacy_unicast_reflect_slots[idx] || s->legacy_unicast_reflect_slots[idx]->id != id)
         return NULL;
@@ -769,8 +769,8 @@ static AvahiLegacyUnicastReflectSlot* find_slot(AvahiServer *s, uint16_t id) {
     return s->legacy_unicast_reflect_slots[idx];
 }
 
-static void legacy_unicast_reflect_slot_timeout(AvahiTimeEvent *e, void *userdata) {
-    AvahiLegacyUnicastReflectSlot *slot = userdata;
+static void legacy_unicast_reflect_slot_timeout(CattaTimeEvent *e, void *userdata) {
+    CattaLegacyUnicastReflectSlot *slot = userdata;
 
     assert(e);
     assert(slot);
@@ -779,9 +779,9 @@ static void legacy_unicast_reflect_slot_timeout(AvahiTimeEvent *e, void *userdat
     deallocate_slot(slot->server, slot);
 }
 
-static void reflect_legacy_unicast_query_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInterface *i, const AvahiAddress *a, uint16_t port) {
-    AvahiLegacyUnicastReflectSlot *slot;
-    AvahiInterface *j;
+static void reflect_legacy_unicast_query_packet(CattaServer *s, CattaDnsPacket *p, CattaInterface *i, const CattaAddress *a, uint16_t port) {
+    CattaLegacyUnicastReflectSlot *slot;
+    CattaInterface *j;
 
     assert(s);
     assert(p);
@@ -803,37 +803,37 @@ static void reflect_legacy_unicast_query_packet(AvahiServer *s, AvahiDnsPacket *
 
     if (!(slot = allocate_slot(s))) {
         /* No slot available, we drop this legacy unicast query */
-        avahi_log_warn("No slot available for legacy unicast reflection, dropping query packet.");
+        catta_log_warn("No slot available for legacy unicast reflection, dropping query packet.");
         return;
     }
 
-    slot->original_id = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ID);
+    slot->original_id = catta_dns_packet_get_field(p, CATTA_DNS_FIELD_ID);
     slot->address = *a;
     slot->port = port;
     slot->interface = i->hardware->index;
 
-    avahi_elapse_time(&slot->elapse_time, 2000, 0);
-    slot->time_event = avahi_time_event_new(s->time_event_queue, &slot->elapse_time, legacy_unicast_reflect_slot_timeout, slot);
+    catta_elapse_time(&slot->elapse_time, 2000, 0);
+    slot->time_event = catta_time_event_new(s->time_event_queue, &slot->elapse_time, legacy_unicast_reflect_slot_timeout, slot);
 
     /* Patch the packet with our new locally generatet id */
-    avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_ID, slot->id);
+    catta_dns_packet_set_field(p, CATTA_DNS_FIELD_ID, slot->id);
 
     for (j = s->monitor->interfaces; j; j = j->interface_next)
         if (j->announcing &&
             j != i &&
             (s->config.reflect_ipv || j->protocol == i->protocol)) {
 
-            if (j->protocol == AVAHI_PROTO_INET && s->fd_legacy_unicast_ipv4 >= 0) {
-                avahi_send_dns_packet_ipv4(s->fd_legacy_unicast_ipv4, j->hardware->index, p, NULL, NULL, 0);
-            } else if (j->protocol == AVAHI_PROTO_INET6 && s->fd_legacy_unicast_ipv6 >= 0)
-                avahi_send_dns_packet_ipv6(s->fd_legacy_unicast_ipv6, j->hardware->index, p, NULL, NULL, 0);
+            if (j->protocol == CATTA_PROTO_INET && s->fd_legacy_unicast_ipv4 >= 0) {
+                catta_send_dns_packet_ipv4(s->fd_legacy_unicast_ipv4, j->hardware->index, p, NULL, NULL, 0);
+            } else if (j->protocol == CATTA_PROTO_INET6 && s->fd_legacy_unicast_ipv6 >= 0)
+                catta_send_dns_packet_ipv6(s->fd_legacy_unicast_ipv6, j->hardware->index, p, NULL, NULL, 0);
         }
 
     /* Reset the id */
-    avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_ID, slot->original_id);
+    catta_dns_packet_set_field(p, CATTA_DNS_FIELD_ID, slot->original_id);
 }
 
-static int originates_from_local_legacy_unicast_socket(AvahiServer *s, const AvahiAddress *address, uint16_t port) {
+static int originates_from_local_legacy_unicast_socket(CattaServer *s, const CattaAddress *address, uint16_t port) {
     assert(s);
     assert(address);
     assert(port > 0);
@@ -841,55 +841,55 @@ static int originates_from_local_legacy_unicast_socket(AvahiServer *s, const Ava
     if (!s->config.enable_reflector)
         return 0;
 
-    if (!avahi_address_is_local(s->monitor, address))
+    if (!catta_address_is_local(s->monitor, address))
         return 0;
 
-    if (address->proto == AVAHI_PROTO_INET && s->fd_legacy_unicast_ipv4 >= 0) {
+    if (address->proto == CATTA_PROTO_INET && s->fd_legacy_unicast_ipv4 >= 0) {
         struct sockaddr_in lsa;
         socklen_t l = sizeof(lsa);
 
         if (getsockname(s->fd_legacy_unicast_ipv4, (struct sockaddr*) &lsa, &l) != 0)
-            avahi_log_warn("getsockname(): %s", strerror(errno));
+            catta_log_warn("getsockname(): %s", strerror(errno));
         else
-            return avahi_port_from_sockaddr((struct sockaddr*) &lsa) == port;
+            return catta_port_from_sockaddr((struct sockaddr*) &lsa) == port;
 
     }
 
-    if (address->proto == AVAHI_PROTO_INET6 && s->fd_legacy_unicast_ipv6 >= 0) {
+    if (address->proto == CATTA_PROTO_INET6 && s->fd_legacy_unicast_ipv6 >= 0) {
         struct sockaddr_in6 lsa;
         socklen_t l = sizeof(lsa);
 
         if (getsockname(s->fd_legacy_unicast_ipv6, (struct sockaddr*) &lsa, &l) != 0)
-            avahi_log_warn("getsockname(): %s", strerror(errno));
+            catta_log_warn("getsockname(): %s", strerror(errno));
         else
-            return avahi_port_from_sockaddr((struct sockaddr*) &lsa) == port;
+            return catta_port_from_sockaddr((struct sockaddr*) &lsa) == port;
     }
 
     return 0;
 }
 
-static int is_mdns_mcast_address(const AvahiAddress *a) {
-    AvahiAddress b;
+static int is_mdns_mcast_address(const CattaAddress *a) {
+    CattaAddress b;
     assert(a);
 
-    avahi_address_parse(a->proto == AVAHI_PROTO_INET ? AVAHI_IPV4_MCAST_GROUP : AVAHI_IPV6_MCAST_GROUP, a->proto, &b);
-    return avahi_address_cmp(a, &b) == 0;
+    catta_address_parse(a->proto == CATTA_PROTO_INET ? CATTA_IPV4_MCAST_GROUP : CATTA_IPV6_MCAST_GROUP, a->proto, &b);
+    return catta_address_cmp(a, &b) == 0;
 }
 
-static int originates_from_local_iface(AvahiServer *s, AvahiIfIndex iface, const AvahiAddress *a, uint16_t port) {
+static int originates_from_local_iface(CattaServer *s, CattaIfIndex iface, const CattaAddress *a, uint16_t port) {
     assert(s);
-    assert(iface != AVAHI_IF_UNSPEC);
+    assert(iface != CATTA_IF_UNSPEC);
     assert(a);
 
     /* If it isn't the MDNS port it can't be generated by us */
-    if (port != AVAHI_MDNS_PORT)
+    if (port != CATTA_MDNS_PORT)
         return 0;
 
-    return avahi_interface_has_address(s->monitor, iface, a);
+    return catta_interface_has_address(s->monitor, iface, a);
 }
 
-static void dispatch_packet(AvahiServer *s, AvahiDnsPacket *p, const AvahiAddress *src_address, uint16_t port, const AvahiAddress *dst_address, AvahiIfIndex iface, int ttl) {
-    AvahiInterface *i;
+static void dispatch_packet(CattaServer *s, CattaDnsPacket *p, const CattaAddress *src_address, uint16_t port, const CattaAddress *dst_address, CattaIfIndex iface, int ttl) {
+    CattaInterface *i;
     int from_local_iface = 0;
 
     assert(s);
@@ -899,19 +899,19 @@ static void dispatch_packet(AvahiServer *s, AvahiDnsPacket *p, const AvahiAddres
     assert(iface > 0);
     assert(src_address->proto == dst_address->proto);
 
-    if (!(i = avahi_interface_monitor_get_interface(s->monitor, iface, src_address->proto)) ||
+    if (!(i = catta_interface_monitor_get_interface(s->monitor, iface, src_address->proto)) ||
         !i->announcing) {
-        avahi_log_warn("Received packet from invalid interface.");
+        catta_log_warn("Received packet from invalid interface.");
         return;
     }
 
     if (port <= 0) {
         /* This fixes RHBZ #475394 */
-        avahi_log_warn("Received packet from invalid source port %u.", (unsigned) port);
+        catta_log_warn("Received packet from invalid source port %u.", (unsigned) port);
         return;
     }
 
-    if (avahi_address_is_ipv4_in_ipv6(src_address))
+    if (catta_address_is_ipv4_in_ipv6(src_address))
         /* This is an IPv4 address encapsulated in IPv6, so let's ignore it. */
         return;
 
@@ -923,24 +923,24 @@ static void dispatch_packet(AvahiServer *s, AvahiDnsPacket *p, const AvahiAddres
     if (s->config.enable_reflector)
         from_local_iface = originates_from_local_iface(s, iface, src_address, port);
 
-    if (avahi_dns_packet_check_valid_multicast(p) < 0) {
-        avahi_log_warn("Received invalid packet.");
+    if (catta_dns_packet_check_valid_multicast(p) < 0) {
+        catta_log_warn("Received invalid packet.");
         return;
     }
 
-    if (avahi_dns_packet_is_query(p)) {
+    if (catta_dns_packet_is_query(p)) {
         int legacy_unicast = 0;
 
         /* For queries EDNS0 might allow ARCOUNT != 0. We ignore the
          * AR section completely here, so far. Until the day we add
          * EDNS0 support. */
 
-        if (port != AVAHI_MDNS_PORT) {
+        if (port != CATTA_MDNS_PORT) {
             /* Legacy Unicast */
 
-            if ((avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ANCOUNT) != 0 ||
-                 avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_NSCOUNT) != 0)) {
-                avahi_log_warn("Invalid legacy unicast query packet.");
+            if ((catta_dns_packet_get_field(p, CATTA_DNS_FIELD_ANCOUNT) != 0 ||
+                 catta_dns_packet_get_field(p, CATTA_DNS_FIELD_NSCOUNT) != 0)) {
+                catta_log_warn("Invalid legacy unicast query packet.");
                 return;
             }
 
@@ -953,30 +953,30 @@ static void dispatch_packet(AvahiServer *s, AvahiDnsPacket *p, const AvahiAddres
         handle_query_packet(s, p, i, src_address, port, legacy_unicast, from_local_iface);
 
     } else {
-        char t[AVAHI_ADDRESS_STR_MAX];
+        char t[CATTA_ADDRESS_STR_MAX];
 
-        if (port != AVAHI_MDNS_PORT) {
-            avahi_log_warn("Received response from host %s with invalid source port %u on interface '%s.%i'", avahi_address_snprint(t, sizeof(t), src_address), port, i->hardware->name, i->protocol);
+        if (port != CATTA_MDNS_PORT) {
+            catta_log_warn("Received response from host %s with invalid source port %u on interface '%s.%i'", catta_address_snprint(t, sizeof(t), src_address), port, i->hardware->name, i->protocol);
             return;
         }
 
         if (ttl != 255 && s->config.check_response_ttl) {
-            avahi_log_warn("Received response from host %s with invalid TTL %u on interface '%s.%i'.", avahi_address_snprint(t, sizeof(t), src_address), ttl, i->hardware->name, i->protocol);
+            catta_log_warn("Received response from host %s with invalid TTL %u on interface '%s.%i'.", catta_address_snprint(t, sizeof(t), src_address), ttl, i->hardware->name, i->protocol);
             return;
         }
 
         if (!is_mdns_mcast_address(dst_address) &&
-            !avahi_interface_address_on_link(i, src_address)) {
+            !catta_interface_address_on_link(i, src_address)) {
 
-            avahi_log_warn("Received non-local response from host %s on interface '%s.%i'.", avahi_address_snprint(t, sizeof(t), src_address), i->hardware->name, i->protocol);
+            catta_log_warn("Received non-local response from host %s on interface '%s.%i'.", catta_address_snprint(t, sizeof(t), src_address), i->hardware->name, i->protocol);
             return;
         }
 
-        if (avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_QDCOUNT) != 0 ||
-            avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ANCOUNT) == 0 ||
-            avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_NSCOUNT) != 0) {
+        if (catta_dns_packet_get_field(p, CATTA_DNS_FIELD_QDCOUNT) != 0 ||
+            catta_dns_packet_get_field(p, CATTA_DNS_FIELD_ANCOUNT) == 0 ||
+            catta_dns_packet_get_field(p, CATTA_DNS_FIELD_NSCOUNT) != 0) {
 
-            avahi_log_warn("Invalid response packet from host %s.", avahi_address_snprint(t, sizeof(t), src_address));
+            catta_log_warn("Invalid response packet from host %s.", catta_address_snprint(t, sizeof(t), src_address));
             return;
         }
 
@@ -984,97 +984,97 @@ static void dispatch_packet(AvahiServer *s, AvahiDnsPacket *p, const AvahiAddres
     }
 }
 
-static void dispatch_legacy_unicast_packet(AvahiServer *s, AvahiDnsPacket *p) {
-    AvahiInterface *j;
-    AvahiLegacyUnicastReflectSlot *slot;
+static void dispatch_legacy_unicast_packet(CattaServer *s, CattaDnsPacket *p) {
+    CattaInterface *j;
+    CattaLegacyUnicastReflectSlot *slot;
 
     assert(s);
     assert(p);
 
-    if (avahi_dns_packet_check_valid(p) < 0 || avahi_dns_packet_is_query(p)) {
-        avahi_log_warn("Received invalid packet.");
+    if (catta_dns_packet_check_valid(p) < 0 || catta_dns_packet_is_query(p)) {
+        catta_log_warn("Received invalid packet.");
         return;
     }
 
-    if (!(slot = find_slot(s, avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ID)))) {
-        avahi_log_warn("Received legacy unicast response with unknown id");
+    if (!(slot = find_slot(s, catta_dns_packet_get_field(p, CATTA_DNS_FIELD_ID)))) {
+        catta_log_warn("Received legacy unicast response with unknown id");
         return;
     }
 
-    if (!(j = avahi_interface_monitor_get_interface(s->monitor, slot->interface, slot->address.proto)) ||
+    if (!(j = catta_interface_monitor_get_interface(s->monitor, slot->interface, slot->address.proto)) ||
         !j->announcing)
         return;
 
     /* Patch the original ID into this response */
-    avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_ID, slot->original_id);
+    catta_dns_packet_set_field(p, CATTA_DNS_FIELD_ID, slot->original_id);
 
     /* Forward the response to the correct client */
-    avahi_interface_send_packet_unicast(j, p, &slot->address, slot->port);
+    catta_interface_send_packet_unicast(j, p, &slot->address, slot->port);
 
     /* Undo changes to packet */
-    avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_ID, slot->id);
+    catta_dns_packet_set_field(p, CATTA_DNS_FIELD_ID, slot->id);
 }
 
-static void mcast_socket_event(AvahiWatch *w, int fd, AvahiWatchEvent events, void *userdata) {
-    AvahiServer *s = userdata;
-    AvahiAddress dest, src;
-    AvahiDnsPacket *p = NULL;
-    AvahiIfIndex iface;
+static void mcast_socket_event(CattaWatch *w, int fd, CattaWatchEvent events, void *userdata) {
+    CattaServer *s = userdata;
+    CattaAddress dest, src;
+    CattaDnsPacket *p = NULL;
+    CattaIfIndex iface;
     uint16_t port;
     uint8_t ttl;
 
     assert(w);
     assert(fd >= 0);
-    assert(events & AVAHI_WATCH_IN);
+    assert(events & CATTA_WATCH_IN);
 
     if (fd == s->fd_ipv4) {
-        dest.proto = src.proto = AVAHI_PROTO_INET;
-        p = avahi_recv_dns_packet_ipv4(s->fd_ipv4, &src.data.ipv4, &port, &dest.data.ipv4, &iface, &ttl);
+        dest.proto = src.proto = CATTA_PROTO_INET;
+        p = catta_recv_dns_packet_ipv4(s->fd_ipv4, &src.data.ipv4, &port, &dest.data.ipv4, &iface, &ttl);
     } else {
         assert(fd == s->fd_ipv6);
-        dest.proto = src.proto = AVAHI_PROTO_INET6;
-        p = avahi_recv_dns_packet_ipv6(s->fd_ipv6, &src.data.ipv6, &port, &dest.data.ipv6, &iface, &ttl);
+        dest.proto = src.proto = CATTA_PROTO_INET6;
+        p = catta_recv_dns_packet_ipv6(s->fd_ipv6, &src.data.ipv6, &port, &dest.data.ipv6, &iface, &ttl);
     }
 
     if (p) {
-        if (iface == AVAHI_IF_UNSPEC)
-            iface = avahi_find_interface_for_address(s->monitor, &dest);
+        if (iface == CATTA_IF_UNSPEC)
+            iface = catta_find_interface_for_address(s->monitor, &dest);
 
-        if (iface != AVAHI_IF_UNSPEC)
+        if (iface != CATTA_IF_UNSPEC)
             dispatch_packet(s, p, &src, port, &dest, iface, ttl);
         else
-            avahi_log_error("Incoming packet received on address that isn't local.");
+            catta_log_error("Incoming packet received on address that isn't local.");
 
-        avahi_dns_packet_free(p);
+        catta_dns_packet_free(p);
 
-        avahi_cleanup_dead_entries(s);
+        catta_cleanup_dead_entries(s);
     }
 }
 
-static void legacy_unicast_socket_event(AvahiWatch *w, int fd, AvahiWatchEvent events, void *userdata) {
-    AvahiServer *s = userdata;
-    AvahiDnsPacket *p = NULL;
+static void legacy_unicast_socket_event(CattaWatch *w, int fd, CattaWatchEvent events, void *userdata) {
+    CattaServer *s = userdata;
+    CattaDnsPacket *p = NULL;
 
     assert(w);
     assert(fd >= 0);
-    assert(events & AVAHI_WATCH_IN);
+    assert(events & CATTA_WATCH_IN);
 
     if (fd == s->fd_legacy_unicast_ipv4)
-        p = avahi_recv_dns_packet_ipv4(s->fd_legacy_unicast_ipv4, NULL, NULL, NULL, NULL, NULL);
+        p = catta_recv_dns_packet_ipv4(s->fd_legacy_unicast_ipv4, NULL, NULL, NULL, NULL, NULL);
     else {
         assert(fd == s->fd_legacy_unicast_ipv6);
-        p = avahi_recv_dns_packet_ipv6(s->fd_legacy_unicast_ipv6, NULL, NULL, NULL, NULL, NULL);
+        p = catta_recv_dns_packet_ipv6(s->fd_legacy_unicast_ipv6, NULL, NULL, NULL, NULL, NULL);
     }
 
     if (p) {
         dispatch_legacy_unicast_packet(s, p);
-        avahi_dns_packet_free(p);
+        catta_dns_packet_free(p);
 
-        avahi_cleanup_dead_entries(s);
+        catta_cleanup_dead_entries(s);
     }
 }
 
-static void server_set_state(AvahiServer *s, AvahiServerState state) {
+static void server_set_state(CattaServer *s, CattaServerState state) {
     assert(s);
 
     if (s->state == state)
@@ -1082,55 +1082,55 @@ static void server_set_state(AvahiServer *s, AvahiServerState state) {
 
     s->state = state;
 
-    avahi_interface_monitor_update_rrs(s->monitor, 0);
+    catta_interface_monitor_update_rrs(s->monitor, 0);
 
     if (s->callback)
         s->callback(s, state, s->userdata);
 }
 
-static void withdraw_host_rrs(AvahiServer *s) {
+static void withdraw_host_rrs(CattaServer *s) {
     assert(s);
 
     if (s->hinfo_entry_group)
-        avahi_s_entry_group_reset(s->hinfo_entry_group);
+        catta_s_entry_group_reset(s->hinfo_entry_group);
 
     if (s->browse_domain_entry_group)
-        avahi_s_entry_group_reset(s->browse_domain_entry_group);
+        catta_s_entry_group_reset(s->browse_domain_entry_group);
 
-    avahi_interface_monitor_update_rrs(s->monitor, 1);
+    catta_interface_monitor_update_rrs(s->monitor, 1);
     s->n_host_rr_pending = 0;
 }
 
-void avahi_server_decrease_host_rr_pending(AvahiServer *s) {
+void catta_server_decrease_host_rr_pending(CattaServer *s) {
     assert(s);
 
     assert(s->n_host_rr_pending > 0);
 
     if (--s->n_host_rr_pending == 0)
-        server_set_state(s, AVAHI_SERVER_RUNNING);
+        server_set_state(s, CATTA_SERVER_RUNNING);
 }
 
-void avahi_host_rr_entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntryGroupState state, AVAHI_GCC_UNUSED void *userdata) {
+void catta_host_rr_entry_group_callback(CattaServer *s, CattaSEntryGroup *g, CattaEntryGroupState state, CATTA_GCC_UNUSED void *userdata) {
     assert(s);
     assert(g);
 
-    if (state == AVAHI_ENTRY_GROUP_REGISTERING &&
-        s->state == AVAHI_SERVER_REGISTERING)
+    if (state == CATTA_ENTRY_GROUP_REGISTERING &&
+        s->state == CATTA_SERVER_REGISTERING)
         s->n_host_rr_pending ++;
 
-    else if (state == AVAHI_ENTRY_GROUP_COLLISION &&
-        (s->state == AVAHI_SERVER_REGISTERING || s->state == AVAHI_SERVER_RUNNING)) {
+    else if (state == CATTA_ENTRY_GROUP_COLLISION &&
+        (s->state == CATTA_SERVER_REGISTERING || s->state == CATTA_SERVER_RUNNING)) {
         withdraw_host_rrs(s);
-        server_set_state(s, AVAHI_SERVER_COLLISION);
+        server_set_state(s, CATTA_SERVER_COLLISION);
 
-    } else if (state == AVAHI_ENTRY_GROUP_ESTABLISHED &&
-               s->state == AVAHI_SERVER_REGISTERING)
-        avahi_server_decrease_host_rr_pending(s);
+    } else if (state == CATTA_ENTRY_GROUP_ESTABLISHED &&
+               s->state == CATTA_SERVER_REGISTERING)
+        catta_server_decrease_host_rr_pending(s);
 }
 
-static void register_hinfo(AvahiServer *s) {
+static void register_hinfo(CattaServer *s) {
     struct utsname utsname;
-    AvahiRecord *r;
+    CattaRecord *r;
 
     assert(s);
 
@@ -1138,206 +1138,206 @@ static void register_hinfo(AvahiServer *s) {
         return;
 
     if (s->hinfo_entry_group)
-        assert(avahi_s_entry_group_is_empty(s->hinfo_entry_group));
+        assert(catta_s_entry_group_is_empty(s->hinfo_entry_group));
     else
-        s->hinfo_entry_group = avahi_s_entry_group_new(s, avahi_host_rr_entry_group_callback, NULL);
+        s->hinfo_entry_group = catta_s_entry_group_new(s, catta_host_rr_entry_group_callback, NULL);
 
     if (!s->hinfo_entry_group) {
-        avahi_log_warn("Failed to create HINFO entry group: %s", avahi_strerror(s->error));
+        catta_log_warn("Failed to create HINFO entry group: %s", catta_strerror(s->error));
         return;
     }
 
     /* Fill in HINFO rr */
-    if ((r = avahi_record_new_full(s->host_name_fqdn, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_HINFO, AVAHI_DEFAULT_TTL_HOST_NAME))) {
+    if ((r = catta_record_new_full(s->host_name_fqdn, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_HINFO, CATTA_DEFAULT_TTL_HOST_NAME))) {
 
         if (uname(&utsname) < 0)
-            avahi_log_warn("uname() failed: %s\n", avahi_strerror(errno));
+            catta_log_warn("uname() failed: %s\n", catta_strerror(errno));
         else {
 
-            r->data.hinfo.cpu = avahi_strdup(avahi_strup(utsname.machine));
-            r->data.hinfo.os = avahi_strdup(avahi_strup(utsname.sysname));
+            r->data.hinfo.cpu = catta_strdup(catta_strup(utsname.machine));
+            r->data.hinfo.os = catta_strdup(catta_strup(utsname.sysname));
 
-            avahi_log_info("Registering HINFO record with values '%s'/'%s'.", r->data.hinfo.cpu, r->data.hinfo.os);
+            catta_log_info("Registering HINFO record with values '%s'/'%s'.", r->data.hinfo.cpu, r->data.hinfo.os);
 
-            if (avahi_server_add(s, s->hinfo_entry_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_PUBLISH_UNIQUE, r) < 0) {
-                avahi_log_warn("Failed to add HINFO RR: %s", avahi_strerror(s->error));
+            if (catta_server_add(s, s->hinfo_entry_group, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, CATTA_PUBLISH_UNIQUE, r) < 0) {
+                catta_log_warn("Failed to add HINFO RR: %s", catta_strerror(s->error));
                 return;
             }
         }
 
-        avahi_record_unref(r);
+        catta_record_unref(r);
     }
 
-    if (avahi_s_entry_group_commit(s->hinfo_entry_group) < 0)
-        avahi_log_warn("Failed to commit HINFO entry group: %s", avahi_strerror(s->error));
+    if (catta_s_entry_group_commit(s->hinfo_entry_group) < 0)
+        catta_log_warn("Failed to commit HINFO entry group: %s", catta_strerror(s->error));
 
 }
 
-static void register_localhost(AvahiServer *s) {
-    AvahiAddress a;
+static void register_localhost(CattaServer *s) {
+    CattaAddress a;
     assert(s);
 
     /* Add localhost entries */
-    avahi_address_parse("127.0.0.1", AVAHI_PROTO_INET, &a);
-    avahi_server_add_address(s, NULL, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_PUBLISH_NO_PROBE|AVAHI_PUBLISH_NO_ANNOUNCE, "localhost", &a);
+    catta_address_parse("127.0.0.1", CATTA_PROTO_INET, &a);
+    catta_server_add_address(s, NULL, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, CATTA_PUBLISH_NO_PROBE|CATTA_PUBLISH_NO_ANNOUNCE, "localhost", &a);
 
-    avahi_address_parse("::1", AVAHI_PROTO_INET6, &a);
-    avahi_server_add_address(s, NULL, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_PUBLISH_NO_PROBE|AVAHI_PUBLISH_NO_ANNOUNCE, "ip6-localhost", &a);
+    catta_address_parse("::1", CATTA_PROTO_INET6, &a);
+    catta_server_add_address(s, NULL, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, CATTA_PUBLISH_NO_PROBE|CATTA_PUBLISH_NO_ANNOUNCE, "ip6-localhost", &a);
 }
 
-static void register_browse_domain(AvahiServer *s) {
+static void register_browse_domain(CattaServer *s) {
     assert(s);
 
     if (!s->config.publish_domain)
         return;
 
-    if (avahi_domain_equal(s->domain_name, "local"))
+    if (catta_domain_equal(s->domain_name, "local"))
         return;
 
     if (s->browse_domain_entry_group)
-        assert(avahi_s_entry_group_is_empty(s->browse_domain_entry_group));
+        assert(catta_s_entry_group_is_empty(s->browse_domain_entry_group));
     else
-        s->browse_domain_entry_group = avahi_s_entry_group_new(s, NULL, NULL);
+        s->browse_domain_entry_group = catta_s_entry_group_new(s, NULL, NULL);
 
     if (!s->browse_domain_entry_group) {
-        avahi_log_warn("Failed to create browse domain entry group: %s", avahi_strerror(s->error));
+        catta_log_warn("Failed to create browse domain entry group: %s", catta_strerror(s->error));
         return;
     }
 
-    if (avahi_server_add_ptr(s, s->browse_domain_entry_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, AVAHI_DEFAULT_TTL, "b._dns-sd._udp.local", s->domain_name) < 0) {
-        avahi_log_warn("Failed to add browse domain RR: %s", avahi_strerror(s->error));
+    if (catta_server_add_ptr(s, s->browse_domain_entry_group, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, 0, CATTA_DEFAULT_TTL, "b._dns-sd._udp.local", s->domain_name) < 0) {
+        catta_log_warn("Failed to add browse domain RR: %s", catta_strerror(s->error));
         return;
     }
 
-    if (avahi_s_entry_group_commit(s->browse_domain_entry_group) < 0)
-        avahi_log_warn("Failed to commit browse domain entry group: %s", avahi_strerror(s->error));
+    if (catta_s_entry_group_commit(s->browse_domain_entry_group) < 0)
+        catta_log_warn("Failed to commit browse domain entry group: %s", catta_strerror(s->error));
 }
 
-static void register_stuff(AvahiServer *s) {
+static void register_stuff(CattaServer *s) {
     assert(s);
 
-    server_set_state(s, AVAHI_SERVER_REGISTERING);
-    s->n_host_rr_pending ++; /** Make sure that the state isn't changed tp AVAHI_SERVER_RUNNING too early */
+    server_set_state(s, CATTA_SERVER_REGISTERING);
+    s->n_host_rr_pending ++; /** Make sure that the state isn't changed tp CATTA_SERVER_RUNNING too early */
 
     register_hinfo(s);
     register_browse_domain(s);
-    avahi_interface_monitor_update_rrs(s->monitor, 0);
+    catta_interface_monitor_update_rrs(s->monitor, 0);
 
     assert(s->n_host_rr_pending > 0);
     s->n_host_rr_pending --;
 
     if (s->n_host_rr_pending == 0)
-        server_set_state(s, AVAHI_SERVER_RUNNING);
+        server_set_state(s, CATTA_SERVER_RUNNING);
 }
 
-static void update_fqdn(AvahiServer *s) {
+static void update_fqdn(CattaServer *s) {
     char *n;
 
     assert(s);
     assert(s->host_name);
     assert(s->domain_name);
 
-    if (!(n = avahi_strdup_printf("%s.%s", s->host_name, s->domain_name)))
+    if (!(n = catta_strdup_printf("%s.%s", s->host_name, s->domain_name)))
         return; /* OOM */
 
-    avahi_free(s->host_name_fqdn);
+    catta_free(s->host_name_fqdn);
     s->host_name_fqdn = n;
 }
 
-int avahi_server_set_host_name(AvahiServer *s, const char *host_name) {
+int catta_server_set_host_name(CattaServer *s, const char *host_name) {
     char *hn = NULL;
     assert(s);
 
-    AVAHI_CHECK_VALIDITY(s, !host_name || avahi_is_valid_host_name(host_name), AVAHI_ERR_INVALID_HOST_NAME);
+    CATTA_CHECK_VALIDITY(s, !host_name || catta_is_valid_host_name(host_name), CATTA_ERR_INVALID_HOST_NAME);
 
     if (!host_name)
-        hn = avahi_get_host_name_strdup();
+        hn = catta_get_host_name_strdup();
     else
-        hn = avahi_normalize_name_strdup(host_name);
+        hn = catta_normalize_name_strdup(host_name);
 
     hn[strcspn(hn, ".")] = 0;
 
-    if (avahi_domain_equal(s->host_name, hn) && s->state != AVAHI_SERVER_COLLISION) {
-        avahi_free(hn);
-        return avahi_server_set_errno(s, AVAHI_ERR_NO_CHANGE);
+    if (catta_domain_equal(s->host_name, hn) && s->state != CATTA_SERVER_COLLISION) {
+        catta_free(hn);
+        return catta_server_set_errno(s, CATTA_ERR_NO_CHANGE);
     }
 
     withdraw_host_rrs(s);
 
-    avahi_free(s->host_name);
+    catta_free(s->host_name);
     s->host_name = hn;
 
     update_fqdn(s);
 
     register_stuff(s);
-    return AVAHI_OK;
+    return CATTA_OK;
 }
 
-int avahi_server_set_domain_name(AvahiServer *s, const char *domain_name) {
+int catta_server_set_domain_name(CattaServer *s, const char *domain_name) {
     char *dn = NULL;
     assert(s);
 
-    AVAHI_CHECK_VALIDITY(s, !domain_name || avahi_is_valid_domain_name(domain_name), AVAHI_ERR_INVALID_DOMAIN_NAME);
+    CATTA_CHECK_VALIDITY(s, !domain_name || catta_is_valid_domain_name(domain_name), CATTA_ERR_INVALID_DOMAIN_NAME);
 
     if (!domain_name)
-        dn = avahi_strdup("local");
+        dn = catta_strdup("local");
     else
-        dn = avahi_normalize_name_strdup(domain_name);
+        dn = catta_normalize_name_strdup(domain_name);
 
-    if (avahi_domain_equal(s->domain_name, domain_name)) {
-        avahi_free(dn);
-        return avahi_server_set_errno(s, AVAHI_ERR_NO_CHANGE);
+    if (catta_domain_equal(s->domain_name, domain_name)) {
+        catta_free(dn);
+        return catta_server_set_errno(s, CATTA_ERR_NO_CHANGE);
     }
 
     withdraw_host_rrs(s);
 
-    avahi_free(s->domain_name);
+    catta_free(s->domain_name);
     s->domain_name = dn;
     update_fqdn(s);
 
     register_stuff(s);
 
-    avahi_free(dn);
-    return AVAHI_OK;
+    catta_free(dn);
+    return CATTA_OK;
 }
 
-static int valid_server_config(const AvahiServerConfig *sc) {
-    AvahiStringList *l;
+static int valid_server_config(const CattaServerConfig *sc) {
+    CattaStringList *l;
 
     assert(sc);
 
-    if (sc->n_wide_area_servers > AVAHI_WIDE_AREA_SERVERS_MAX)
-        return AVAHI_ERR_INVALID_CONFIG;
+    if (sc->n_wide_area_servers > CATTA_WIDE_AREA_SERVERS_MAX)
+        return CATTA_ERR_INVALID_CONFIG;
 
-    if (sc->host_name && !avahi_is_valid_host_name(sc->host_name))
-        return AVAHI_ERR_INVALID_HOST_NAME;
+    if (sc->host_name && !catta_is_valid_host_name(sc->host_name))
+        return CATTA_ERR_INVALID_HOST_NAME;
 
-    if (sc->domain_name && !avahi_is_valid_domain_name(sc->domain_name))
-        return AVAHI_ERR_INVALID_DOMAIN_NAME;
+    if (sc->domain_name && !catta_is_valid_domain_name(sc->domain_name))
+        return CATTA_ERR_INVALID_DOMAIN_NAME;
 
     for (l = sc->browse_domains; l; l = l->next)
-        if (!avahi_is_valid_domain_name((char*) l->text))
-            return AVAHI_ERR_INVALID_DOMAIN_NAME;
+        if (!catta_is_valid_domain_name((char*) l->text))
+            return CATTA_ERR_INVALID_DOMAIN_NAME;
 
-    return AVAHI_OK;
+    return CATTA_OK;
 }
 
-static int setup_sockets(AvahiServer *s) {
+static int setup_sockets(CattaServer *s) {
     assert(s);
 
-    s->fd_ipv4 = s->config.use_ipv4 ? avahi_open_socket_ipv4(s->config.disallow_other_stacks) : -1;
-    s->fd_ipv6 = s->config.use_ipv6 ? avahi_open_socket_ipv6(s->config.disallow_other_stacks) : -1;
+    s->fd_ipv4 = s->config.use_ipv4 ? catta_open_socket_ipv4(s->config.disallow_other_stacks) : -1;
+    s->fd_ipv6 = s->config.use_ipv6 ? catta_open_socket_ipv6(s->config.disallow_other_stacks) : -1;
 
     if (s->fd_ipv6 < 0 && s->fd_ipv4 < 0)
-        return AVAHI_ERR_NO_NETWORK;
+        return CATTA_ERR_NO_NETWORK;
 
     if (s->fd_ipv4 < 0 && s->config.use_ipv4)
-        avahi_log_notice("Failed to create IPv4 socket, proceeding in IPv6 only mode");
+        catta_log_notice("Failed to create IPv4 socket, proceeding in IPv6 only mode");
     else if (s->fd_ipv6 < 0 && s->config.use_ipv6)
-        avahi_log_notice("Failed to create IPv6 socket, proceeding in IPv4 only mode");
+        catta_log_notice("Failed to create IPv6 socket, proceeding in IPv4 only mode");
 
-    s->fd_legacy_unicast_ipv4 = s->fd_ipv4 >= 0 && s->config.enable_reflector ? avahi_open_unicast_socket_ipv4() : -1;
-    s->fd_legacy_unicast_ipv6 = s->fd_ipv6 >= 0 && s->config.enable_reflector ? avahi_open_unicast_socket_ipv6() : -1;
+    s->fd_legacy_unicast_ipv4 = s->fd_ipv4 >= 0 && s->config.enable_reflector ? catta_open_unicast_socket_ipv4() : -1;
+    s->fd_legacy_unicast_ipv6 = s->fd_ipv6 >= 0 && s->config.enable_reflector ? catta_open_unicast_socket_ipv6() : -1;
 
     s->watch_ipv4 =
         s->watch_ipv6 =
@@ -1345,20 +1345,20 @@ static int setup_sockets(AvahiServer *s) {
         s->watch_legacy_unicast_ipv6 = NULL;
 
     if (s->fd_ipv4 >= 0)
-        s->watch_ipv4 = s->poll_api->watch_new(s->poll_api, s->fd_ipv4, AVAHI_WATCH_IN, mcast_socket_event, s);
+        s->watch_ipv4 = s->poll_api->watch_new(s->poll_api, s->fd_ipv4, CATTA_WATCH_IN, mcast_socket_event, s);
     if (s->fd_ipv6 >= 0)
-        s->watch_ipv6 = s->poll_api->watch_new(s->poll_api, s->fd_ipv6, AVAHI_WATCH_IN, mcast_socket_event, s);
+        s->watch_ipv6 = s->poll_api->watch_new(s->poll_api, s->fd_ipv6, CATTA_WATCH_IN, mcast_socket_event, s);
 
     if (s->fd_legacy_unicast_ipv4 >= 0)
-        s->watch_legacy_unicast_ipv4 = s->poll_api->watch_new(s->poll_api, s->fd_legacy_unicast_ipv4, AVAHI_WATCH_IN, legacy_unicast_socket_event, s);
+        s->watch_legacy_unicast_ipv4 = s->poll_api->watch_new(s->poll_api, s->fd_legacy_unicast_ipv4, CATTA_WATCH_IN, legacy_unicast_socket_event, s);
     if (s->fd_legacy_unicast_ipv6 >= 0)
-        s->watch_legacy_unicast_ipv6 = s->poll_api->watch_new(s->poll_api, s->fd_legacy_unicast_ipv6, AVAHI_WATCH_IN, legacy_unicast_socket_event, s);
+        s->watch_legacy_unicast_ipv6 = s->poll_api->watch_new(s->poll_api, s->fd_legacy_unicast_ipv6, CATTA_WATCH_IN, legacy_unicast_socket_event, s);
 
     return 0;
 }
 
-AvahiServer *avahi_server_new(const AvahiPoll *poll_api, const AvahiServerConfig *sc, AvahiServerCallback callback, void* userdata, int *error) {
-    AvahiServer *s;
+CattaServer *catta_server_new(const CattaPoll *poll_api, const CattaServerConfig *sc, CattaServerCallback callback, void* userdata, int *error) {
+    CattaServer *s;
     int e;
 
     if (sc && (e = valid_server_config(sc)) < 0) {
@@ -1367,9 +1367,9 @@ AvahiServer *avahi_server_new(const AvahiPoll *poll_api, const AvahiServerConfig
         return NULL;
     }
 
-    if (!(s = avahi_new(AvahiServer, 1))) {
+    if (!(s = catta_new(CattaServer, 1))) {
         if (error)
-            *error = AVAHI_ERR_NO_MEMORY;
+            *error = CATTA_ERR_NO_MEMORY;
 
         return NULL;
     }
@@ -1377,16 +1377,16 @@ AvahiServer *avahi_server_new(const AvahiPoll *poll_api, const AvahiServerConfig
     s->poll_api = poll_api;
 
     if (sc)
-        avahi_server_config_copy(&s->config, sc);
+        catta_server_config_copy(&s->config, sc);
     else
-        avahi_server_config_init(&s->config);
+        catta_server_config_init(&s->config);
 
     if ((e = setup_sockets(s)) < 0) {
         if (error)
             *error = e;
 
-        avahi_server_config_free(&s->config);
-        avahi_free(s);
+        catta_server_config_free(&s->config);
+        catta_free(s);
 
         return NULL;
     }
@@ -1398,54 +1398,54 @@ AvahiServer *avahi_server_new(const AvahiPoll *poll_api, const AvahiServerConfig
     s->cleanup_time_event = NULL;
     s->hinfo_entry_group = NULL;
     s->browse_domain_entry_group = NULL;
-    s->error = AVAHI_OK;
-    s->state = AVAHI_SERVER_INVALID;
+    s->error = CATTA_OK;
+    s->state = CATTA_SERVER_INVALID;
 
     s->callback = callback;
     s->userdata = userdata;
 
-    s->time_event_queue = avahi_time_event_queue_new(poll_api);
+    s->time_event_queue = catta_time_event_queue_new(poll_api);
 
-    s->entries_by_key = avahi_hashmap_new((AvahiHashFunc) avahi_key_hash, (AvahiEqualFunc) avahi_key_equal, NULL, NULL);
-    AVAHI_LLIST_HEAD_INIT(AvahiEntry, s->entries);
-    AVAHI_LLIST_HEAD_INIT(AvahiGroup, s->groups);
+    s->entries_by_key = catta_hashmap_new((CattaHashFunc) catta_key_hash, (CattaEqualFunc) catta_key_equal, NULL, NULL);
+    CATTA_LLIST_HEAD_INIT(CattaEntry, s->entries);
+    CATTA_LLIST_HEAD_INIT(CattaGroup, s->groups);
 
-    s->record_browser_hashmap = avahi_hashmap_new((AvahiHashFunc) avahi_key_hash, (AvahiEqualFunc) avahi_key_equal, NULL, NULL);
-    AVAHI_LLIST_HEAD_INIT(AvahiSRecordBrowser, s->record_browsers);
-    AVAHI_LLIST_HEAD_INIT(AvahiSHostNameResolver, s->host_name_resolvers);
-    AVAHI_LLIST_HEAD_INIT(AvahiSAddressResolver, s->address_resolvers);
-    AVAHI_LLIST_HEAD_INIT(AvahiSDomainBrowser, s->domain_browsers);
-    AVAHI_LLIST_HEAD_INIT(AvahiSServiceTypeBrowser, s->service_type_browsers);
-    AVAHI_LLIST_HEAD_INIT(AvahiSServiceBrowser, s->service_browsers);
-    AVAHI_LLIST_HEAD_INIT(AvahiSServiceResolver, s->service_resolvers);
-    AVAHI_LLIST_HEAD_INIT(AvahiSDNSServerBrowser, s->dns_server_browsers);
+    s->record_browser_hashmap = catta_hashmap_new((CattaHashFunc) catta_key_hash, (CattaEqualFunc) catta_key_equal, NULL, NULL);
+    CATTA_LLIST_HEAD_INIT(CattaSRecordBrowser, s->record_browsers);
+    CATTA_LLIST_HEAD_INIT(CattaSHostNameResolver, s->host_name_resolvers);
+    CATTA_LLIST_HEAD_INIT(CattaSAddressResolver, s->address_resolvers);
+    CATTA_LLIST_HEAD_INIT(CattaSDomainBrowser, s->domain_browsers);
+    CATTA_LLIST_HEAD_INIT(CattaSServiceTypeBrowser, s->service_type_browsers);
+    CATTA_LLIST_HEAD_INIT(CattaSServiceBrowser, s->service_browsers);
+    CATTA_LLIST_HEAD_INIT(CattaSServiceResolver, s->service_resolvers);
+    CATTA_LLIST_HEAD_INIT(CattaSDNSServerBrowser, s->dns_server_browsers);
 
     s->legacy_unicast_reflect_slots = NULL;
     s->legacy_unicast_reflect_id = 0;
 
-    s->record_list = avahi_record_list_new();
+    s->record_list = catta_record_list_new();
 
     /* Get host name */
-    s->host_name = s->config.host_name ? avahi_normalize_name_strdup(s->config.host_name) : avahi_get_host_name_strdup();
+    s->host_name = s->config.host_name ? catta_normalize_name_strdup(s->config.host_name) : catta_get_host_name_strdup();
     s->host_name[strcspn(s->host_name, ".")] = 0;
-    s->domain_name = s->config.domain_name ? avahi_normalize_name_strdup(s->config.domain_name) : avahi_strdup("local");
+    s->domain_name = s->config.domain_name ? catta_normalize_name_strdup(s->config.domain_name) : catta_strdup("local");
     s->host_name_fqdn = NULL;
     update_fqdn(s);
 
     do {
         s->local_service_cookie = (uint32_t) rand() * (uint32_t) rand();
-    } while (s->local_service_cookie == AVAHI_SERVICE_COOKIE_INVALID);
+    } while (s->local_service_cookie == CATTA_SERVICE_COOKIE_INVALID);
 
     if (s->config.enable_wide_area) {
-        s->wide_area_lookup_engine = avahi_wide_area_engine_new(s);
-        avahi_wide_area_set_servers(s->wide_area_lookup_engine, s->config.wide_area_servers, s->config.n_wide_area_servers);
+        s->wide_area_lookup_engine = catta_wide_area_engine_new(s);
+        catta_wide_area_set_servers(s->wide_area_lookup_engine, s->config.wide_area_servers, s->config.n_wide_area_servers);
     } else
         s->wide_area_lookup_engine = NULL;
 
-    s->multicast_lookup_engine = avahi_multicast_lookup_engine_new(s);
+    s->multicast_lookup_engine = catta_multicast_lookup_engine_new(s);
 
-    s->monitor = avahi_interface_monitor_new(s);
-    avahi_interface_monitor_sync(s->monitor);
+    s->monitor = catta_interface_monitor_new(s);
+    catta_interface_monitor_sync(s->monitor);
 
     register_localhost(s);
     register_stuff(s);
@@ -1453,52 +1453,52 @@ AvahiServer *avahi_server_new(const AvahiPoll *poll_api, const AvahiServerConfig
     return s;
 }
 
-void avahi_server_free(AvahiServer* s) {
+void catta_server_free(CattaServer* s) {
     assert(s);
 
     /* Remove all browsers */
 
     while (s->dns_server_browsers)
-        avahi_s_dns_server_browser_free(s->dns_server_browsers);
+        catta_s_dns_server_browser_free(s->dns_server_browsers);
     while (s->host_name_resolvers)
-        avahi_s_host_name_resolver_free(s->host_name_resolvers);
+        catta_s_host_name_resolver_free(s->host_name_resolvers);
     while (s->address_resolvers)
-        avahi_s_address_resolver_free(s->address_resolvers);
+        catta_s_address_resolver_free(s->address_resolvers);
     while (s->domain_browsers)
-        avahi_s_domain_browser_free(s->domain_browsers);
+        catta_s_domain_browser_free(s->domain_browsers);
     while (s->service_type_browsers)
-        avahi_s_service_type_browser_free(s->service_type_browsers);
+        catta_s_service_type_browser_free(s->service_type_browsers);
     while (s->service_browsers)
-        avahi_s_service_browser_free(s->service_browsers);
+        catta_s_service_browser_free(s->service_browsers);
     while (s->service_resolvers)
-        avahi_s_service_resolver_free(s->service_resolvers);
+        catta_s_service_resolver_free(s->service_resolvers);
     while (s->record_browsers)
-        avahi_s_record_browser_destroy(s->record_browsers);
+        catta_s_record_browser_destroy(s->record_browsers);
 
     /* Remove all locally rgeistered stuff */
 
     while(s->entries)
-        avahi_entry_free(s, s->entries);
+        catta_entry_free(s, s->entries);
 
-    avahi_interface_monitor_free(s->monitor);
+    catta_interface_monitor_free(s->monitor);
 
     while (s->groups)
-        avahi_entry_group_free(s, s->groups);
+        catta_entry_group_free(s, s->groups);
 
     free_slots(s);
 
-    avahi_hashmap_free(s->entries_by_key);
-    avahi_record_list_free(s->record_list);
-    avahi_hashmap_free(s->record_browser_hashmap);
+    catta_hashmap_free(s->entries_by_key);
+    catta_record_list_free(s->record_list);
+    catta_hashmap_free(s->record_browser_hashmap);
 
     if (s->wide_area_lookup_engine)
-        avahi_wide_area_engine_free(s->wide_area_lookup_engine);
-    avahi_multicast_lookup_engine_free(s->multicast_lookup_engine);
+        catta_wide_area_engine_free(s->wide_area_lookup_engine);
+    catta_multicast_lookup_engine_free(s->multicast_lookup_engine);
 
     if (s->cleanup_time_event)
-        avahi_time_event_free(s->cleanup_time_event);
+        catta_time_event_free(s->cleanup_time_event);
 
-    avahi_time_event_queue_free(s->time_event_queue);
+    catta_time_event_queue_free(s->time_event_queue);
 
     /* Free watches */
 
@@ -1526,55 +1526,55 @@ void avahi_server_free(AvahiServer* s) {
 
     /* Free other stuff */
 
-    avahi_free(s->host_name);
-    avahi_free(s->domain_name);
-    avahi_free(s->host_name_fqdn);
+    catta_free(s->host_name);
+    catta_free(s->domain_name);
+    catta_free(s->host_name_fqdn);
 
-    avahi_server_config_free(&s->config);
+    catta_server_config_free(&s->config);
 
-    avahi_free(s);
+    catta_free(s);
 }
 
-const char* avahi_server_get_domain_name(AvahiServer *s) {
+const char* catta_server_get_domain_name(CattaServer *s) {
     assert(s);
 
     return s->domain_name;
 }
 
-const char* avahi_server_get_host_name(AvahiServer *s) {
+const char* catta_server_get_host_name(CattaServer *s) {
     assert(s);
 
     return s->host_name;
 }
 
-const char* avahi_server_get_host_name_fqdn(AvahiServer *s) {
+const char* catta_server_get_host_name_fqdn(CattaServer *s) {
     assert(s);
 
     return s->host_name_fqdn;
 }
 
-void* avahi_server_get_data(AvahiServer *s) {
+void* catta_server_get_data(CattaServer *s) {
     assert(s);
 
     return s->userdata;
 }
 
-void avahi_server_set_data(AvahiServer *s, void* userdata) {
+void catta_server_set_data(CattaServer *s, void* userdata) {
     assert(s);
 
     s->userdata = userdata;
 }
 
-AvahiServerState avahi_server_get_state(AvahiServer *s) {
+CattaServerState catta_server_get_state(CattaServer *s) {
     assert(s);
 
     return s->state;
 }
 
-AvahiServerConfig* avahi_server_config_init(AvahiServerConfig *c) {
+CattaServerConfig* catta_server_config_init(CattaServerConfig *c) {
     assert(c);
 
-    memset(c, 0, sizeof(AvahiServerConfig));
+    memset(c, 0, sizeof(CattaServerConfig));
     c->use_ipv6 = 1;
     c->use_ipv4 = 1;
     c->allow_interfaces = NULL;
@@ -1599,57 +1599,57 @@ AvahiServerConfig* avahi_server_config_init(AvahiServerConfig *c) {
     c->allow_point_to_point = 0;
     c->publish_aaaa_on_ipv4 = 1;
     c->publish_a_on_ipv6 = 0;
-    c->n_cache_entries_max = AVAHI_DEFAULT_CACHE_ENTRIES_MAX;
+    c->n_cache_entries_max = CATTA_DEFAULT_CACHE_ENTRIES_MAX;
     c->ratelimit_interval = 0;
     c->ratelimit_burst = 0;
 
     return c;
 }
 
-void avahi_server_config_free(AvahiServerConfig *c) {
+void catta_server_config_free(CattaServerConfig *c) {
     assert(c);
 
-    avahi_free(c->host_name);
-    avahi_free(c->domain_name);
-    avahi_string_list_free(c->browse_domains);
-    avahi_string_list_free(c->allow_interfaces);
-    avahi_string_list_free(c->deny_interfaces);
+    catta_free(c->host_name);
+    catta_free(c->domain_name);
+    catta_string_list_free(c->browse_domains);
+    catta_string_list_free(c->allow_interfaces);
+    catta_string_list_free(c->deny_interfaces);
 }
 
-AvahiServerConfig* avahi_server_config_copy(AvahiServerConfig *ret, const AvahiServerConfig *c) {
+CattaServerConfig* catta_server_config_copy(CattaServerConfig *ret, const CattaServerConfig *c) {
     char *d = NULL, *h = NULL;
-    AvahiStringList *browse = NULL, *allow = NULL, *deny = NULL;
+    CattaStringList *browse = NULL, *allow = NULL, *deny = NULL;
     assert(ret);
     assert(c);
 
     if (c->host_name)
-        if (!(h = avahi_strdup(c->host_name)))
+        if (!(h = catta_strdup(c->host_name)))
             return NULL;
 
     if (c->domain_name)
-        if (!(d = avahi_strdup(c->domain_name))) {
-            avahi_free(h);
+        if (!(d = catta_strdup(c->domain_name))) {
+            catta_free(h);
             return NULL;
         }
 
-    if (!(browse = avahi_string_list_copy(c->browse_domains)) && c->browse_domains) {
-        avahi_free(h);
-        avahi_free(d);
+    if (!(browse = catta_string_list_copy(c->browse_domains)) && c->browse_domains) {
+        catta_free(h);
+        catta_free(d);
         return NULL;
     }
 
-    if (!(allow = avahi_string_list_copy(c->allow_interfaces)) && c->allow_interfaces) {
-        avahi_string_list_free(browse);
-        avahi_free(h);
-        avahi_free(d);
+    if (!(allow = catta_string_list_copy(c->allow_interfaces)) && c->allow_interfaces) {
+        catta_string_list_free(browse);
+        catta_free(h);
+        catta_free(d);
         return NULL;
     }
 
-    if (!(deny = avahi_string_list_copy(c->deny_interfaces)) && c->deny_interfaces) {
-        avahi_string_list_free(allow);
-        avahi_string_list_free(browse);
-        avahi_free(h);
-        avahi_free(d);
+    if (!(deny = catta_string_list_copy(c->deny_interfaces)) && c->deny_interfaces) {
+        catta_string_list_free(allow);
+        catta_string_list_free(browse);
+        catta_free(h);
+        catta_free(d);
         return NULL;
     }
 
@@ -1663,79 +1663,79 @@ AvahiServerConfig* avahi_server_config_copy(AvahiServerConfig *ret, const AvahiS
     return ret;
 }
 
-int avahi_server_errno(AvahiServer *s) {
+int catta_server_errno(CattaServer *s) {
     assert(s);
 
     return s->error;
 }
 
 /* Just for internal use */
-int avahi_server_set_errno(AvahiServer *s, int error) {
+int catta_server_set_errno(CattaServer *s, int error) {
     assert(s);
 
     return s->error = error;
 }
 
-uint32_t avahi_server_get_local_service_cookie(AvahiServer *s) {
+uint32_t catta_server_get_local_service_cookie(CattaServer *s) {
     assert(s);
 
     return s->local_service_cookie;
 }
 
-static AvahiEntry *find_entry(AvahiServer *s, AvahiIfIndex interface, AvahiProtocol protocol, AvahiKey *key) {
-    AvahiEntry *e;
+static CattaEntry *find_entry(CattaServer *s, CattaIfIndex interface, CattaProtocol protocol, CattaKey *key) {
+    CattaEntry *e;
 
     assert(s);
     assert(key);
 
-    for (e = avahi_hashmap_lookup(s->entries_by_key, key); e; e = e->by_key_next)
+    for (e = catta_hashmap_lookup(s->entries_by_key, key); e; e = e->by_key_next)
 
         if ((e->interface == interface || e->interface <= 0 || interface <= 0) &&
-            (e->protocol == protocol || e->protocol == AVAHI_PROTO_UNSPEC || protocol == AVAHI_PROTO_UNSPEC) &&
-            (!e->group || e->group->state == AVAHI_ENTRY_GROUP_ESTABLISHED || e->group->state == AVAHI_ENTRY_GROUP_REGISTERING))
+            (e->protocol == protocol || e->protocol == CATTA_PROTO_UNSPEC || protocol == CATTA_PROTO_UNSPEC) &&
+            (!e->group || e->group->state == CATTA_ENTRY_GROUP_ESTABLISHED || e->group->state == CATTA_ENTRY_GROUP_REGISTERING))
 
             return e;
 
     return NULL;
 }
 
-int avahi_server_get_group_of_service(AvahiServer *s, AvahiIfIndex interface, AvahiProtocol protocol, const char *name, const char *type, const char *domain, AvahiSEntryGroup** ret_group) {
-    AvahiKey *key = NULL;
-    AvahiEntry *e;
+int catta_server_get_group_of_service(CattaServer *s, CattaIfIndex interface, CattaProtocol protocol, const char *name, const char *type, const char *domain, CattaSEntryGroup** ret_group) {
+    CattaKey *key = NULL;
+    CattaEntry *e;
     int ret;
-    char n[AVAHI_DOMAIN_NAME_MAX];
+    char n[CATTA_DOMAIN_NAME_MAX];
 
     assert(s);
     assert(name);
     assert(type);
     assert(ret_group);
 
-    AVAHI_CHECK_VALIDITY(s, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
-    AVAHI_CHECK_VALIDITY(s, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL);
-    AVAHI_CHECK_VALIDITY(s, avahi_is_valid_service_name(name), AVAHI_ERR_INVALID_SERVICE_NAME);
-    AVAHI_CHECK_VALIDITY(s, avahi_is_valid_service_type_strict(type), AVAHI_ERR_INVALID_SERVICE_TYPE);
-    AVAHI_CHECK_VALIDITY(s, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME);
+    CATTA_CHECK_VALIDITY(s, CATTA_IF_VALID(interface), CATTA_ERR_INVALID_INTERFACE);
+    CATTA_CHECK_VALIDITY(s, CATTA_PROTO_VALID(protocol), CATTA_ERR_INVALID_PROTOCOL);
+    CATTA_CHECK_VALIDITY(s, catta_is_valid_service_name(name), CATTA_ERR_INVALID_SERVICE_NAME);
+    CATTA_CHECK_VALIDITY(s, catta_is_valid_service_type_strict(type), CATTA_ERR_INVALID_SERVICE_TYPE);
+    CATTA_CHECK_VALIDITY(s, !domain || catta_is_valid_domain_name(domain), CATTA_ERR_INVALID_DOMAIN_NAME);
 
-    if ((ret = avahi_service_name_join(n, sizeof(n), name, type, domain) < 0))
-        return avahi_server_set_errno(s, ret);
+    if ((ret = catta_service_name_join(n, sizeof(n), name, type, domain) < 0))
+        return catta_server_set_errno(s, ret);
 
-    if (!(key = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_SRV)))
-        return avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
+    if (!(key = catta_key_new(n, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_SRV)))
+        return catta_server_set_errno(s, CATTA_ERR_NO_MEMORY);
 
     e = find_entry(s, interface, protocol, key);
-    avahi_key_unref(key);
+    catta_key_unref(key);
 
     if (e) {
         *ret_group = e->group;
-        return AVAHI_OK;
+        return CATTA_OK;
     }
 
-    return avahi_server_set_errno(s, AVAHI_ERR_NOT_FOUND);
+    return catta_server_set_errno(s, CATTA_ERR_NOT_FOUND);
 }
 
-int avahi_server_is_service_local(AvahiServer *s, AvahiIfIndex interface, AvahiProtocol protocol, const char *name) {
-    AvahiKey *key = NULL;
-    AvahiEntry *e;
+int catta_server_is_service_local(CattaServer *s, CattaIfIndex interface, CattaProtocol protocol, const char *name) {
+    CattaKey *key = NULL;
+    CattaEntry *e;
 
     assert(s);
     assert(name);
@@ -1743,64 +1743,64 @@ int avahi_server_is_service_local(AvahiServer *s, AvahiIfIndex interface, AvahiP
     if (!s->host_name_fqdn)
         return 0;
 
-    if (!(key = avahi_key_new(name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_SRV)))
+    if (!(key = catta_key_new(name, CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_SRV)))
         return 0;
 
     e = find_entry(s, interface, protocol, key);
-    avahi_key_unref(key);
+    catta_key_unref(key);
 
     if (!e)
         return 0;
 
-    return avahi_domain_equal(s->host_name_fqdn, e->record->data.srv.name);
+    return catta_domain_equal(s->host_name_fqdn, e->record->data.srv.name);
 }
 
-int avahi_server_is_record_local(AvahiServer *s, AvahiIfIndex interface, AvahiProtocol protocol, AvahiRecord *record) {
-    AvahiEntry *e;
+int catta_server_is_record_local(CattaServer *s, CattaIfIndex interface, CattaProtocol protocol, CattaRecord *record) {
+    CattaEntry *e;
 
     assert(s);
     assert(record);
 
-    for (e = avahi_hashmap_lookup(s->entries_by_key, record->key); e; e = e->by_key_next)
+    for (e = catta_hashmap_lookup(s->entries_by_key, record->key); e; e = e->by_key_next)
 
         if ((e->interface == interface || e->interface <= 0 || interface <= 0) &&
-            (e->protocol == protocol || e->protocol == AVAHI_PROTO_UNSPEC || protocol == AVAHI_PROTO_UNSPEC) &&
-            (!e->group || e->group->state == AVAHI_ENTRY_GROUP_ESTABLISHED || e->group->state == AVAHI_ENTRY_GROUP_REGISTERING) &&
-            avahi_record_equal_no_ttl(record, e->record))
+            (e->protocol == protocol || e->protocol == CATTA_PROTO_UNSPEC || protocol == CATTA_PROTO_UNSPEC) &&
+            (!e->group || e->group->state == CATTA_ENTRY_GROUP_ESTABLISHED || e->group->state == CATTA_ENTRY_GROUP_REGISTERING) &&
+            catta_record_equal_no_ttl(record, e->record))
             return 1;
 
     return 0;
 }
 
 /** Set the wide area DNS servers */
-int avahi_server_set_wide_area_servers(AvahiServer *s, const AvahiAddress *a, unsigned n) {
+int catta_server_set_wide_area_servers(CattaServer *s, const CattaAddress *a, unsigned n) {
     assert(s);
 
     if (!s->wide_area_lookup_engine)
-        return avahi_server_set_errno(s, AVAHI_ERR_INVALID_CONFIG);
+        return catta_server_set_errno(s, CATTA_ERR_INVALID_CONFIG);
 
-    avahi_wide_area_set_servers(s->wide_area_lookup_engine, a, n);
-    return AVAHI_OK;
+    catta_wide_area_set_servers(s->wide_area_lookup_engine, a, n);
+    return CATTA_OK;
 }
 
-const AvahiServerConfig* avahi_server_get_config(AvahiServer *s) {
+const CattaServerConfig* catta_server_get_config(CattaServer *s) {
     assert(s);
 
     return &s->config;
 }
 
 /** Set the browsing domains */
-int avahi_server_set_browse_domains(AvahiServer *s, AvahiStringList *domains) {
-    AvahiStringList *l;
+int catta_server_set_browse_domains(CattaServer *s, CattaStringList *domains) {
+    CattaStringList *l;
 
     assert(s);
 
     for (l = s->config.browse_domains; l; l = l->next)
-        if (!avahi_is_valid_domain_name((char*) l->text))
-            return avahi_server_set_errno(s, AVAHI_ERR_INVALID_DOMAIN_NAME);
+        if (!catta_is_valid_domain_name((char*) l->text))
+            return catta_server_set_errno(s, CATTA_ERR_INVALID_DOMAIN_NAME);
 
-    avahi_string_list_free(s->config.browse_domains);
-    s->config.browse_domains = avahi_string_list_copy(domains);
+    catta_string_list_free(s->config.browse_domains);
+    s->config.browse_domains = catta_string_list_copy(domains);
 
-    return AVAHI_OK;
+    return CATTA_OK;
 }
index 5fcbfbe709befdd9440351751e36c08ce1674fd5..253ad501533282b0c8b48db64d31340d426fba77 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <fcntl.h>
 #include <stdio.h>
 
-#include <avahi/llist.h>
-#include <avahi/malloc.h>
-#include <avahi/timeval.h>
-#include <avahi/simple-watch.h>
+#include <catta/llist.h>
+#include <catta/malloc.h>
+#include <catta/timeval.h>
+#include <catta/simple-watch.h>
 
-struct AvahiWatch {
-    AvahiSimplePoll *simple_poll;
+struct CattaWatch {
+    CattaSimplePoll *simple_poll;
     int dead;
 
     int idx;
     struct pollfd pollfd;
 
-    AvahiWatchCallback callback;
+    CattaWatchCallback callback;
     void *userdata;
 
-    AVAHI_LLIST_FIELDS(AvahiWatch, watches);
+    CATTA_LLIST_FIELDS(CattaWatch, watches);
 };
 
-struct AvahiTimeout {
-    AvahiSimplePoll *simple_poll;
+struct CattaTimeout {
+    CattaSimplePoll *simple_poll;
     int dead;
 
     int enabled;
     struct timeval expiry;
 
-    AvahiTimeoutCallback callback;
+    CattaTimeoutCallback callback;
     void  *userdata;
 
-    AVAHI_LLIST_FIELDS(AvahiTimeout, timeouts);
+    CATTA_LLIST_FIELDS(CattaTimeout, timeouts);
 };
 
-struct AvahiSimplePoll {
-    AvahiPoll api;
-    AvahiPollFunc poll_func;
+struct CattaSimplePoll {
+    CattaPoll api;
+    CattaPollFunc poll_func;
     void *poll_func_userdata;
 
     struct pollfd* pollfds;
@@ -73,8 +73,8 @@ struct AvahiSimplePoll {
     int events_valid;
 
     int n_watches;
-    AVAHI_LLIST_HEAD(AvahiWatch, watches);
-    AVAHI_LLIST_HEAD(AvahiTimeout, timeouts);
+    CATTA_LLIST_HEAD(CattaWatch, watches);
+    CATTA_LLIST_HEAD(CattaTimeout, timeouts);
 
     int wakeup_pipe[2];
     int wakeup_issued;
@@ -94,7 +94,7 @@ struct AvahiSimplePoll {
     } state;
 };
 
-void avahi_simple_poll_wakeup(AvahiSimplePoll *s) {
+void catta_simple_poll_wakeup(CattaSimplePoll *s) {
     char c = 'W';
     assert(s);
 
@@ -102,7 +102,7 @@ void avahi_simple_poll_wakeup(AvahiSimplePoll *s) {
     s->wakeup_issued = 1;
 }
 
-static void clear_wakeup(AvahiSimplePoll *s) {
+static void clear_wakeup(CattaSimplePoll *s) {
     char c[10]; /* Read ten at a time */
 
     if (!s->wakeup_issued)
@@ -129,9 +129,9 @@ static int set_nonblock(int fd) {
     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;
+static CattaWatch* watch_new(const CattaPoll *api, int fd, CattaWatchEvent event, CattaWatchCallback callback, void *userdata) {
+    CattaWatch *w;
+    CattaSimplePoll *s;
 
     assert(api);
     assert(fd >= 0);
@@ -140,11 +140,11 @@ static AvahiWatch* watch_new(const AvahiPoll *api, int fd, AvahiWatchEvent event
     s = api->userdata;
     assert(s);
 
-    if (!(w = avahi_new(AvahiWatch, 1)))
+    if (!(w = catta_new(CattaWatch, 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);
+    catta_simple_poll_wakeup(s);
 
     w->simple_poll = s;
     w->dead = 0;
@@ -159,18 +159,18 @@ static AvahiWatch* watch_new(const AvahiPoll *api, int fd, AvahiWatchEvent event
     w->idx = -1;
     s->rebuild_pollfds = 1;
 
-    AVAHI_LLIST_PREPEND(AvahiWatch, watches, s->watches, w);
+    CATTA_LLIST_PREPEND(CattaWatch, watches, s->watches, w);
     s->n_watches++;
 
     return w;
 }
 
-static void watch_update(AvahiWatch *w, AvahiWatchEvent events) {
+static void watch_update(CattaWatch *w, CattaWatchEvent 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);
+    catta_simple_poll_wakeup(w->simple_poll);
 
     w->pollfd.events = events;
 
@@ -181,7 +181,7 @@ static void watch_update(AvahiWatch *w, AvahiWatchEvent events) {
         w->simple_poll->rebuild_pollfds = 1;
 }
 
-static AvahiWatchEvent watch_get_events(AvahiWatch *w) {
+static CattaWatchEvent watch_get_events(CattaWatch *w) {
     assert(w);
     assert(!w->dead);
 
@@ -191,7 +191,7 @@ static AvahiWatchEvent watch_get_events(AvahiWatch *w) {
     return 0;
 }
 
-static void remove_pollfd(AvahiWatch *w) {
+static void remove_pollfd(CattaWatch *w) {
     assert(w);
 
     if (w->idx == -1)
@@ -200,13 +200,13 @@ static void remove_pollfd(AvahiWatch *w) {
     w->simple_poll->rebuild_pollfds = 1;
 }
 
-static void watch_free(AvahiWatch *w) {
+static void watch_free(CattaWatch *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);
+    catta_simple_poll_wakeup(w->simple_poll);
 
     remove_pollfd(w);
 
@@ -215,20 +215,20 @@ static void watch_free(AvahiWatch *w) {
     w->simple_poll->watch_req_cleanup = 1;
 }
 
-static void destroy_watch(AvahiWatch *w) {
+static void destroy_watch(CattaWatch *w) {
     assert(w);
 
     remove_pollfd(w);
-    AVAHI_LLIST_REMOVE(AvahiWatch, watches, w->simple_poll->watches, w);
+    CATTA_LLIST_REMOVE(CattaWatch, watches, w->simple_poll->watches, w);
 
     if (!w->dead)
         w->simple_poll->n_watches --;
 
-    avahi_free(w);
+    catta_free(w);
 }
 
-static void cleanup_watches(AvahiSimplePoll *s, int all) {
-    AvahiWatch *w, *next;
+static void cleanup_watches(CattaSimplePoll *s, int all) {
+    CattaWatch *w, *next;
     assert(s);
 
     for (w = s->watches; w; w = next) {
@@ -241,9 +241,9 @@ static void cleanup_watches(AvahiSimplePoll *s, int all) {
     s->timeout_req_cleanup = 0;
 }
 
-static AvahiTimeout* timeout_new(const AvahiPoll *api, const struct timeval *tv, AvahiTimeoutCallback callback, void *userdata) {
-    AvahiTimeout *t;
-    AvahiSimplePoll *s;
+static CattaTimeout* timeout_new(const CattaPoll *api, const struct timeval *tv, CattaTimeoutCallback callback, void *userdata) {
+    CattaTimeout *t;
+    CattaSimplePoll *s;
 
     assert(api);
     assert(callback);
@@ -251,11 +251,11 @@ static AvahiTimeout* timeout_new(const AvahiPoll *api, const struct timeval *tv,
     s = api->userdata;
     assert(s);
 
-    if (!(t = avahi_new(AvahiTimeout, 1)))
+    if (!(t = catta_new(CattaTimeout, 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);
+    catta_simple_poll_wakeup(s);
 
     t->simple_poll = s;
     t->dead = 0;
@@ -266,43 +266,43 @@ static AvahiTimeout* timeout_new(const AvahiPoll *api, const struct timeval *tv,
     t->callback = callback;
     t->userdata = userdata;
 
-    AVAHI_LLIST_PREPEND(AvahiTimeout, timeouts, s->timeouts, t);
+    CATTA_LLIST_PREPEND(CattaTimeout, timeouts, s->timeouts, t);
     return t;
 }
 
-static void timeout_update(AvahiTimeout *t, const struct timeval *tv) {
+static void timeout_update(CattaTimeout *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);
+    catta_simple_poll_wakeup(t->simple_poll);
 
     if ((t->enabled = !!tv))
         t->expiry = *tv;
 }
 
-static void timeout_free(AvahiTimeout *t) {
+static void timeout_free(CattaTimeout *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);
+    catta_simple_poll_wakeup(t->simple_poll);
 
     t->dead = 1;
     t->simple_poll->timeout_req_cleanup = 1;
 }
 
 
-static void destroy_timeout(AvahiTimeout *t) {
+static void destroy_timeout(CattaTimeout *t) {
     assert(t);
 
-    AVAHI_LLIST_REMOVE(AvahiTimeout, timeouts, t->simple_poll->timeouts, t);
+    CATTA_LLIST_REMOVE(CattaTimeout, timeouts, t->simple_poll->timeouts, t);
 
-    avahi_free(t);
+    catta_free(t);
 }
 
-static void cleanup_timeouts(AvahiSimplePoll *s, int all) {
-    AvahiTimeout *t, *next;
+static void cleanup_timeouts(CattaSimplePoll *s, int all) {
+    CattaTimeout *t, *next;
     assert(s);
 
     for (t = s->timeouts; t; t = next) {
@@ -315,14 +315,14 @@ static void cleanup_timeouts(AvahiSimplePoll *s, int all) {
     s->timeout_req_cleanup = 0;
 }
 
-AvahiSimplePoll *avahi_simple_poll_new(void) {
-    AvahiSimplePoll *s;
+CattaSimplePoll *catta_simple_poll_new(void) {
+    CattaSimplePoll *s;
 
-    if (!(s = avahi_new(AvahiSimplePoll, 1)))
+    if (!(s = catta_new(CattaSimplePoll, 1)))
         return NULL;
 
     if (pipe(s->wakeup_pipe) < 0) {
-        avahi_free(s);
+        catta_free(s);
         return NULL;
     }
 
@@ -356,22 +356,22 @@ AvahiSimplePoll *avahi_simple_poll_new(void) {
 
     s->wakeup_issued = 0;
 
-    avahi_simple_poll_set_func(s, NULL, NULL);
+    catta_simple_poll_set_func(s, NULL, NULL);
 
-    AVAHI_LLIST_HEAD_INIT(AvahiWatch, s->watches);
-    AVAHI_LLIST_HEAD_INIT(AvahiTimeout, s->timeouts);
+    CATTA_LLIST_HEAD_INIT(CattaWatch, s->watches);
+    CATTA_LLIST_HEAD_INIT(CattaTimeout, s->timeouts);
 
     return s;
 }
 
-void avahi_simple_poll_free(AvahiSimplePoll *s) {
+void catta_simple_poll_free(CattaSimplePoll *s) {
     assert(s);
 
     cleanup_timeouts(s, 1);
     cleanup_watches(s, 1);
     assert(s->n_watches == 0);
 
-    avahi_free(s->pollfds);
+    catta_free(s->pollfds);
 
     if (s->wakeup_pipe[0] >= 0)
         close(s->wakeup_pipe[0]);
@@ -379,11 +379,11 @@ void avahi_simple_poll_free(AvahiSimplePoll *s) {
     if (s->wakeup_pipe[1] >= 0)
         close(s->wakeup_pipe[1]);
 
-    avahi_free(s);
+    catta_free(s);
 }
 
-static int rebuild(AvahiSimplePoll *s) {
-    AvahiWatch *w;
+static int rebuild(CattaSimplePoll *s) {
+    CattaWatch *w;
     int idx;
 
     assert(s);
@@ -393,7 +393,7 @@ static int rebuild(AvahiSimplePoll *s) {
 
         s->max_pollfds = s->n_watches + 10;
 
-        if (!(n = avahi_realloc(s->pollfds, sizeof(struct pollfd) * s->max_pollfds)))
+        if (!(n = catta_realloc(s->pollfds, sizeof(struct pollfd) * s->max_pollfds)))
             return -1;
 
         s->pollfds = n;
@@ -422,8 +422,8 @@ static int rebuild(AvahiSimplePoll *s) {
     return 0;
 }
 
-static AvahiTimeout* find_next_timeout(AvahiSimplePoll *s) {
-    AvahiTimeout *t, *n = NULL;
+static CattaTimeout* find_next_timeout(CattaSimplePoll *s) {
+    CattaTimeout *t, *n = NULL;
     assert(s);
 
     for (t = s->timeouts; t; t = t->timeouts_next) {
@@ -431,14 +431,14 @@ static AvahiTimeout* find_next_timeout(AvahiSimplePoll *s) {
         if (t->dead || !t->enabled)
             continue;
 
-        if (!n || avahi_timeval_compare(&t->expiry, &n->expiry) < 0)
+        if (!n || catta_timeval_compare(&t->expiry, &n->expiry) < 0)
             n = t;
     }
 
     return n;
 }
 
-static void timeout_callback(AvahiTimeout *t) {
+static void timeout_callback(CattaTimeout *t) {
     assert(t);
     assert(!t->dead);
     assert(t->enabled);
@@ -447,8 +447,8 @@ static void timeout_callback(AvahiTimeout *t) {
     t->callback(t, t->userdata);
 }
 
-int avahi_simple_poll_prepare(AvahiSimplePoll *s, int timeout) {
-    AvahiTimeout *next_timeout;
+int catta_simple_poll_prepare(CattaSimplePoll *s, int timeout) {
+    CattaTimeout *next_timeout;
 
     assert(s);
     assert(s->state == STATE_INIT || s->state == STATE_DISPATCHED || s->state == STATE_FAILURE);
@@ -481,7 +481,7 @@ int avahi_simple_poll_prepare(AvahiSimplePoll *s, int timeout) {
     if ((next_timeout = find_next_timeout(s))) {
         struct timeval now;
         int t;
-        AvahiUsec usec;
+        CattaUsec usec;
 
         if (next_timeout->expiry.tv_sec == 0 &&
             next_timeout->expiry.tv_usec == 0) {
@@ -492,7 +492,7 @@ int avahi_simple_poll_prepare(AvahiSimplePoll *s, int timeout) {
         }
 
         gettimeofday(&now, NULL);
-        usec = avahi_timeval_diff(&next_timeout->expiry, &now);
+        usec = catta_timeval_diff(&next_timeout->expiry, &now);
 
         if (usec <= 0) {
             /* Timeout elapsed */
@@ -515,7 +515,7 @@ finish:
     return 0;
 }
 
-int avahi_simple_poll_run(AvahiSimplePoll *s) {
+int catta_simple_poll_run(CattaSimplePoll *s) {
     assert(s);
     assert(s->state == STATE_PREPARED || s->state == STATE_FAILURE);
 
@@ -544,9 +544,9 @@ int avahi_simple_poll_run(AvahiSimplePoll *s) {
     return 0;
 }
 
-int avahi_simple_poll_dispatch(AvahiSimplePoll *s) {
-    AvahiTimeout *next_timeout;
-    AvahiWatch *w;
+int catta_simple_poll_dispatch(CattaSimplePoll *s) {
+    CattaTimeout *next_timeout;
+    CattaWatch *w;
 
     assert(s);
     assert(s->state == STATE_RAN);
@@ -564,7 +564,7 @@ int avahi_simple_poll_dispatch(AvahiSimplePoll *s) {
             goto finish;
         }
 
-        if (avahi_age(&next_timeout->expiry) >= 0) {
+        if (catta_age(&next_timeout->expiry) >= 0) {
 
             /* Timeout elapsed */
             timeout_callback(next_timeout);
@@ -593,57 +593,57 @@ finish:
     return 0;
 }
 
-int avahi_simple_poll_iterate(AvahiSimplePoll *s, int timeout) {
+int catta_simple_poll_iterate(CattaSimplePoll *s, int timeout) {
     int r;
 
-    if ((r = avahi_simple_poll_prepare(s, timeout)) != 0)
+    if ((r = catta_simple_poll_prepare(s, timeout)) != 0)
         return r;
 
-    if ((r = avahi_simple_poll_run(s)) != 0)
+    if ((r = catta_simple_poll_run(s)) != 0)
         return r;
 
-    if ((r = avahi_simple_poll_dispatch(s)) != 0)
+    if ((r = catta_simple_poll_dispatch(s)) != 0)
         return r;
 
     return 0;
 }
 
-void avahi_simple_poll_quit(AvahiSimplePoll *s) {
+void catta_simple_poll_quit(CattaSimplePoll *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);
+    catta_simple_poll_wakeup(s);
 }
 
-const AvahiPoll* avahi_simple_poll_get(AvahiSimplePoll *s) {
+const CattaPoll* catta_simple_poll_get(CattaSimplePoll *s) {
     assert(s);
 
     return &s->api;
 }
 
-static int system_poll(struct pollfd *ufds, unsigned int nfds, int timeout, AVAHI_GCC_UNUSED void *userdata) {
+static int system_poll(struct pollfd *ufds, unsigned int nfds, int timeout, CATTA_GCC_UNUSED void *userdata) {
     return poll(ufds, nfds, timeout);
 }
 
-void avahi_simple_poll_set_func(AvahiSimplePoll *s, AvahiPollFunc func, void *userdata) {
+void catta_simple_poll_set_func(CattaSimplePoll *s, CattaPollFunc 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);
+    catta_simple_poll_wakeup(s);
 }
 
-int avahi_simple_poll_loop(AvahiSimplePoll *s) {
+int catta_simple_poll_loop(CattaSimplePoll *s) {
     int r;
 
     assert(s);
 
     for (;;)
-        if ((r = avahi_simple_poll_iterate(s, -1)) != 0)
+        if ((r = catta_simple_poll_iterate(s, -1)) != 0)
             if (r >= 0 || errno != EINTR)
                 return r;
 }
index 151625aea5ce6e2fa1e27a563abd04a573069b06..a6dd588c7052416f06d391b910c6c454f48a2b66 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
@@ -45,7 +45,7 @@
 #include <net/if_dl.h>
 #endif
 
-#include <avahi/log.h>
+#include <catta/log.h>
 #include "dns.h"
 #include "fdutil.h"
 #include "socket.h"
@@ -69,8 +69,8 @@ static void mdns_mcast_group_ipv4(struct sockaddr_in *ret_sa) {
 
     memset(ret_sa, 0, sizeof(struct sockaddr_in));
     ret_sa->sin_family = AF_INET;
-    ret_sa->sin_port = htons(AVAHI_MDNS_PORT);
-    inet_pton(AF_INET, AVAHI_IPV4_MCAST_GROUP, &ret_sa->sin_addr);
+    ret_sa->sin_port = htons(CATTA_MDNS_PORT);
+    inet_pton(AF_INET, CATTA_IPV4_MCAST_GROUP, &ret_sa->sin_addr);
 }
 
 static void mdns_mcast_group_ipv6(struct sockaddr_in6 *ret_sa) {
@@ -78,11 +78,11 @@ static void mdns_mcast_group_ipv6(struct sockaddr_in6 *ret_sa) {
 
     memset(ret_sa, 0, sizeof(struct sockaddr_in6));
     ret_sa->sin6_family = AF_INET6;
-    ret_sa->sin6_port = htons(AVAHI_MDNS_PORT);
-    inet_pton(AF_INET6, AVAHI_IPV6_MCAST_GROUP, &ret_sa->sin6_addr);
+    ret_sa->sin6_port = htons(CATTA_MDNS_PORT);
+    inet_pton(AF_INET6, CATTA_IPV6_MCAST_GROUP, &ret_sa->sin6_addr);
 }
 
-static void ipv4_address_to_sockaddr(struct sockaddr_in *ret_sa, const AvahiIPv4Address *a, uint16_t port) {
+static void ipv4_address_to_sockaddr(struct sockaddr_in *ret_sa, const CattaIPv4Address *a, uint16_t port) {
     assert(ret_sa);
     assert(a);
     assert(port > 0);
@@ -90,10 +90,10 @@ static void ipv4_address_to_sockaddr(struct sockaddr_in *ret_sa, const AvahiIPv4
     memset(ret_sa, 0, sizeof(struct sockaddr_in));
     ret_sa->sin_family = AF_INET;
     ret_sa->sin_port = htons(port);
-    memcpy(&ret_sa->sin_addr, a, sizeof(AvahiIPv4Address));
+    memcpy(&ret_sa->sin_addr, a, sizeof(CattaIPv4Address));
 }
 
-static void ipv6_address_to_sockaddr(struct sockaddr_in6 *ret_sa, const AvahiIPv6Address *a, uint16_t port) {
+static void ipv6_address_to_sockaddr(struct sockaddr_in6 *ret_sa, const CattaIPv6Address *a, uint16_t port) {
     assert(ret_sa);
     assert(a);
     assert(port > 0);
@@ -101,10 +101,10 @@ static void ipv6_address_to_sockaddr(struct sockaddr_in6 *ret_sa, const AvahiIPv
     memset(ret_sa, 0, sizeof(struct sockaddr_in6));
     ret_sa->sin6_family = AF_INET6;
     ret_sa->sin6_port = htons(port);
-    memcpy(&ret_sa->sin6_addr, a, sizeof(AvahiIPv6Address));
+    memcpy(&ret_sa->sin6_addr, a, sizeof(CattaIPv6Address));
 }
 
-int avahi_mdns_mcast_join_ipv4(int fd, const AvahiIPv4Address *a, int idx, int join) {
+int catta_mdns_mcast_join_ipv4(int fd, const CattaIPv4Address *a, int idx, int join) {
 #ifdef HAVE_STRUCT_IP_MREQN
     struct ip_mreqn mreq;
 #else
@@ -133,14 +133,14 @@ int avahi_mdns_mcast_join_ipv4(int fd, const AvahiIPv4Address *a, int idx, int j
         setsockopt(fd, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq));
 
     if (setsockopt(fd, IPPROTO_IP, join ? IP_ADD_MEMBERSHIP : IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) {
-        avahi_log_warn("%s failed: %s", join ? "IP_ADD_MEMBERSHIP" : "IP_DROP_MEMBERSHIP", strerror(errno));
+        catta_log_warn("%s failed: %s", join ? "IP_ADD_MEMBERSHIP" : "IP_DROP_MEMBERSHIP", strerror(errno));
         return -1;
     }
 
     return 0;
 }
 
-int avahi_mdns_mcast_join_ipv6(int fd, const AvahiIPv6Address *a, int idx, int join) {
+int catta_mdns_mcast_join_ipv6(int fd, const CattaIPv6Address *a, int idx, int join) {
     struct ipv6_mreq mreq6;
     struct sockaddr_in6 sa6;
 
@@ -157,7 +157,7 @@ int avahi_mdns_mcast_join_ipv6(int fd, const AvahiIPv6Address *a, int idx, int j
         setsockopt(fd, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, &mreq6, sizeof(mreq6));
 
     if (setsockopt(fd, IPPROTO_IPV6, join ? IPV6_ADD_MEMBERSHIP : IPV6_DROP_MEMBERSHIP, &mreq6, sizeof(mreq6)) < 0) {
-        avahi_log_warn("%s failed: %s", join ? "IPV6_ADD_MEMBERSHIP" : "IPV6_DROP_MEMBERSHIP", strerror(errno));
+        catta_log_warn("%s failed: %s", join ? "IPV6_ADD_MEMBERSHIP" : "IPV6_DROP_MEMBERSHIP", strerror(errno));
         return -1;
     }
 
@@ -169,14 +169,14 @@ static int reuseaddr(int fd) {
 
     yes = 1;
     if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) {
-        avahi_log_warn("SO_REUSEADDR failed: %s", strerror(errno));
+        catta_log_warn("SO_REUSEADDR failed: %s", strerror(errno));
         return -1;
     }
 
 #ifdef SO_REUSEPORT
     yes = 1;
     if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof(yes)) < 0) {
-        avahi_log_warn("SO_REUSEPORT failed: %s", strerror(errno));
+        catta_log_warn("SO_REUSEPORT failed: %s", strerror(errno));
         return -1;
     }
 #endif
@@ -193,11 +193,11 @@ static int bind_with_warn(int fd, const struct sockaddr *sa, socklen_t l) {
     if (bind(fd, sa, l) < 0) {
 
         if (errno != EADDRINUSE) {
-            avahi_log_warn("bind() failed: %s", strerror(errno));
+            catta_log_warn("bind() failed: %s", strerror(errno));
             return -1;
         }
 
-        avahi_log_warn("*** WARNING: Detected another %s mDNS stack running on this host. This makes mDNS unreliable and is thus not recommended. ***",
+        catta_log_warn("*** WARNING: Detected another %s mDNS stack running on this host. This makes mDNS unreliable and is thus not recommended. ***",
                        sa->sa_family == AF_INET ? "IPv4" : "IPv6");
 
         /* Try again, this time with SO_REUSEADDR set */
@@ -205,7 +205,7 @@ static int bind_with_warn(int fd, const struct sockaddr *sa, socklen_t l) {
             return -1;
 
         if (bind(fd, sa, l) < 0) {
-            avahi_log_warn("bind() failed: %s", strerror(errno));
+            catta_log_warn("bind() failed: %s", strerror(errno));
             return -1;
         }
     } else {
@@ -227,7 +227,7 @@ static int ipv4_pktinfo(int fd) {
 #ifdef IP_PKTINFO
     yes = 1;
     if (setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &yes, sizeof(yes)) < 0) {
-        avahi_log_warn("IP_PKTINFO failed: %s", strerror(errno));
+        catta_log_warn("IP_PKTINFO failed: %s", strerror(errno));
         return -1;
     }
 #else
@@ -235,13 +235,13 @@ static int ipv4_pktinfo(int fd) {
 #ifdef IP_RECVINTERFACE
     yes = 1;
     if (setsockopt (fd, IPPROTO_IP, IP_RECVINTERFACE, &yes, sizeof(yes)) < 0) {
-        avahi_log_warn("IP_RECVINTERFACE failed: %s", strerror(errno));
+        catta_log_warn("IP_RECVINTERFACE failed: %s", strerror(errno));
         return -1;
     }
 #elif defined(IP_RECVIF)
     yes = 1;
     if (setsockopt (fd, IPPROTO_IP, IP_RECVIF, &yes, sizeof(yes)) < 0) {
-        avahi_log_warn("IP_RECVIF failed: %s", strerror(errno));
+        catta_log_warn("IP_RECVIF failed: %s", strerror(errno));
         return -1;
     }
 #endif
@@ -249,7 +249,7 @@ static int ipv4_pktinfo(int fd) {
 #ifdef IP_RECVDSTADDR
     yes = 1;
     if (setsockopt (fd, IPPROTO_IP, IP_RECVDSTADDR, &yes, sizeof(yes)) < 0) {
-        avahi_log_warn("IP_RECVDSTADDR failed: %s", strerror(errno));
+        catta_log_warn("IP_RECVDSTADDR failed: %s", strerror(errno));
         return -1;
     }
 #endif
@@ -259,7 +259,7 @@ static int ipv4_pktinfo(int fd) {
 #ifdef IP_RECVTTL
     yes = 1;
     if (setsockopt(fd, IPPROTO_IP, IP_RECVTTL, &yes, sizeof(yes)) < 0) {
-        avahi_log_warn("IP_RECVTTL failed: %s", strerror(errno));
+        catta_log_warn("IP_RECVTTL failed: %s", strerror(errno));
         return -1;
     }
 #endif
@@ -273,13 +273,13 @@ static int ipv6_pktinfo(int fd) {
 #ifdef IPV6_RECVPKTINFO
     yes = 1;
     if (setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &yes, sizeof(yes)) < 0) {
-        avahi_log_warn("IPV6_RECVPKTINFO failed: %s", strerror(errno));
+        catta_log_warn("IPV6_RECVPKTINFO failed: %s", strerror(errno));
         return -1;
     }
 #elif defined(IPV6_PKTINFO)
     yes = 1;
     if (setsockopt(fd, IPPROTO_IPV6, IPV6_PKTINFO, &yes, sizeof(yes)) < 0) {
-        avahi_log_warn("IPV6_PKTINFO failed: %s", strerror(errno));
+        catta_log_warn("IPV6_PKTINFO failed: %s", strerror(errno));
         return -1;
     }
 #endif
@@ -287,19 +287,19 @@ static int ipv6_pktinfo(int fd) {
 #ifdef IPV6_RECVHOPS
     yes = 1;
     if (setsockopt(fd, IPPROTO_IPV6, IPV6_RECVHOPS, &yes, sizeof(yes)) < 0) {
-        avahi_log_warn("IPV6_RECVHOPS failed: %s", strerror(errno));
+        catta_log_warn("IPV6_RECVHOPS failed: %s", strerror(errno));
         return -1;
     }
 #elif defined(IPV6_RECVHOPLIMIT)
     yes = 1;
     if (setsockopt(fd, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &yes, sizeof(yes)) < 0) {
-        avahi_log_warn("IPV6_RECVHOPLIMIT failed: %s", strerror(errno));
+        catta_log_warn("IPV6_RECVHOPLIMIT failed: %s", strerror(errno));
         return -1;
     }
 #elif defined(IPV6_HOPLIMIT)
     yes = 1;
     if (setsockopt(fd, IPPROTO_IPV6, IPV6_HOPLIMIT, &yes, sizeof(yes)) < 0) {
-        avahi_log_warn("IPV6_HOPLIMIT failed: %s", strerror(errno));
+        catta_log_warn("IPV6_HOPLIMIT failed: %s", strerror(errno));
         return -1;
     }
 #endif
@@ -307,37 +307,37 @@ static int ipv6_pktinfo(int fd) {
     return 0;
 }
 
-int avahi_open_socket_ipv4(int no_reuse) {
+int catta_open_socket_ipv4(int no_reuse) {
     struct sockaddr_in local;
     int fd = -1, r, ittl;
     uint8_t ttl, cyes;
 
     if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
-        avahi_log_warn("socket() failed: %s", strerror(errno));
+        catta_log_warn("socket() failed: %s", strerror(errno));
         goto fail;
     }
 
     ttl = 255;
     if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)) < 0) {
-        avahi_log_warn("IP_MULTICAST_TTL failed: %s", strerror(errno));
+        catta_log_warn("IP_MULTICAST_TTL failed: %s", strerror(errno));
         goto fail;
     }
 
     ittl = 255;
     if (setsockopt(fd, IPPROTO_IP, IP_TTL, &ittl, sizeof(ittl)) < 0) {
-        avahi_log_warn("IP_TTL failed: %s", strerror(errno));
+        catta_log_warn("IP_TTL failed: %s", strerror(errno));
         goto fail;
     }
 
     cyes = 1;
     if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, &cyes, sizeof(cyes)) < 0) {
-        avahi_log_warn("IP_MULTICAST_LOOP failed: %s", strerror(errno));
+        catta_log_warn("IP_MULTICAST_LOOP failed: %s", strerror(errno));
         goto fail;
     }
 
     memset(&local, 0, sizeof(local));
     local.sin_family = AF_INET;
-    local.sin_port = htons(AVAHI_MDNS_PORT);
+    local.sin_port = htons(CATTA_MDNS_PORT);
 
     if (no_reuse)
         r = bind(fd, (struct sockaddr*) &local, sizeof(local));
@@ -350,13 +350,13 @@ int avahi_open_socket_ipv4(int no_reuse) {
     if (ipv4_pktinfo (fd) < 0)
          goto fail;
 
-    if (avahi_set_cloexec(fd) < 0) {
-        avahi_log_warn("FD_CLOEXEC failed: %s", strerror(errno));
+    if (catta_set_cloexec(fd) < 0) {
+        catta_log_warn("FD_CLOEXEC failed: %s", strerror(errno));
         goto fail;
     }
 
-    if (avahi_set_nonblock(fd) < 0) {
-        avahi_log_warn("O_NONBLOCK failed: %s", strerror(errno));
+    if (catta_set_nonblock(fd) < 0) {
+        catta_log_warn("O_NONBLOCK failed: %s", strerror(errno));
         goto fail;
     }
 
@@ -369,7 +369,7 @@ fail:
     return -1;
 }
 
-int avahi_open_socket_ipv6(int no_reuse) {
+int catta_open_socket_ipv6(int no_reuse) {
     struct sockaddr_in6 sa, local;
     int fd = -1, yes, r;
     int ttl;
@@ -377,37 +377,37 @@ int avahi_open_socket_ipv6(int no_reuse) {
     mdns_mcast_group_ipv6(&sa);
 
     if ((fd = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
-        avahi_log_warn("socket() failed: %s", strerror(errno));
+        catta_log_warn("socket() failed: %s", strerror(errno));
         goto fail;
     }
 
     ttl = 255;
     if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &ttl, sizeof(ttl)) < 0) {
-        avahi_log_warn("IPV6_MULTICAST_HOPS failed: %s", strerror(errno));
+        catta_log_warn("IPV6_MULTICAST_HOPS failed: %s", strerror(errno));
         goto fail;
     }
 
     ttl = 255;
     if (setsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &ttl, sizeof(ttl)) < 0) {
-        avahi_log_warn("IPV6_UNICAST_HOPS failed: %s", strerror(errno));
+        catta_log_warn("IPV6_UNICAST_HOPS failed: %s", strerror(errno));
         goto fail;
     }
 
     yes = 1;
     if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &yes, sizeof(yes)) < 0) {
-        avahi_log_warn("IPV6_V6ONLY failed: %s", strerror(errno));
+        catta_log_warn("IPV6_V6ONLY failed: %s", strerror(errno));
         goto fail;
     }
 
     yes = 1;
     if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) {
-        avahi_log_warn("IPV6_MULTICAST_LOOP failed: %s", strerror(errno));
+        catta_log_warn("IPV6_MULTICAST_LOOP failed: %s", strerror(errno));
         goto fail;
     }
 
     memset(&local, 0, sizeof(local));
     local.sin6_family = AF_INET6;
-    local.sin6_port = htons(AVAHI_MDNS_PORT);
+    local.sin6_port = htons(CATTA_MDNS_PORT);
 
     if (no_reuse)
         r = bind(fd, (struct sockaddr*) &local, sizeof(local));
@@ -420,13 +420,13 @@ int avahi_open_socket_ipv6(int no_reuse) {
     if (ipv6_pktinfo(fd) < 0)
         goto fail;
 
-    if (avahi_set_cloexec(fd) < 0) {
-        avahi_log_warn("FD_CLOEXEC failed: %s", strerror(errno));
+    if (catta_set_cloexec(fd) < 0) {
+        catta_log_warn("FD_CLOEXEC failed: %s", strerror(errno));
         goto fail;
     }
 
-    if (avahi_set_nonblock(fd) < 0) {
-        avahi_log_warn("O_NONBLOCK failed: %s", strerror(errno));
+    if (catta_set_nonblock(fd) < 0) {
+        catta_log_warn("O_NONBLOCK failed: %s", strerror(errno));
         goto fail;
     }
 
@@ -456,23 +456,23 @@ static int sendmsg_loop(int fd, struct msghdr *msg, int flags) {
             struct sockaddr_in *sin = msg->msg_name;
 
             inet_ntop(sin->sin_family, &sin->sin_addr, where, sizeof(where));
-            avahi_log_debug("sendmsg() to %s failed: %s", where, strerror(errno));
+            catta_log_debug("sendmsg() to %s failed: %s", where, strerror(errno));
             return -1;
         }
 
-        if (avahi_wait_for_write(fd) < 0)
+        if (catta_wait_for_write(fd) < 0)
             return -1;
     }
 
     return 0;
 }
 
-int avahi_send_dns_packet_ipv4(
+int catta_send_dns_packet_ipv4(
         int fd,
-        AvahiIfIndex interface,
-        AvahiDnsPacket *p,
-        const AvahiIPv4Address *src_address,
-        const AvahiIPv4Address *dst_address,
+        CattaIfIndex interface,
+        CattaDnsPacket *p,
+        const CattaIPv4Address *src_address,
+        const CattaIPv4Address *dst_address,
         uint16_t dst_port) {
 
     struct sockaddr_in sa;
@@ -488,7 +488,7 @@ int avahi_send_dns_packet_ipv4(
 
     assert(fd >= 0);
     assert(p);
-    assert(avahi_dns_packet_check_valid(p) >= 0);
+    assert(catta_dns_packet_check_valid(p) >= 0);
     assert(!dst_address || dst_port > 0);
 
     if (!dst_address)
@@ -497,7 +497,7 @@ int avahi_send_dns_packet_ipv4(
         ipv4_address_to_sockaddr(&sa, dst_address, dst_port);
 
     memset(&io, 0, sizeof(io));
-    io.iov_base = AVAHI_DNS_PACKET_DATA(p);
+    io.iov_base = CATTA_DNS_PACKET_DATA(p);
     io.iov_len = p->size;
 
     memset(&msg, 0, sizeof(msg));
@@ -534,7 +534,7 @@ int avahi_send_dns_packet_ipv4(
     if (src_address) {
         struct in_addr any = { INADDR_ANY };
         if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF, src_address ? &src_address->address : &any, sizeof(struct in_addr)) < 0) {
-            avahi_log_warn("IP_MULTICAST_IF failed: %s", strerror(errno));
+            catta_log_warn("IP_MULTICAST_IF failed: %s", strerror(errno));
             return -1;
         }
     }
@@ -561,12 +561,12 @@ int avahi_send_dns_packet_ipv4(
     return sendmsg_loop(fd, &msg, 0);
 }
 
-int avahi_send_dns_packet_ipv6(
+int catta_send_dns_packet_ipv6(
         int fd,
-        AvahiIfIndex interface,
-        AvahiDnsPacket *p,
-        const AvahiIPv6Address *src_address,
-        const AvahiIPv6Address *dst_address,
+        CattaIfIndex interface,
+        CattaDnsPacket *p,
+        const CattaIPv6Address *src_address,
+        const CattaIPv6Address *dst_address,
         uint16_t dst_port) {
 
     struct sockaddr_in6 sa;
@@ -577,7 +577,7 @@ int avahi_send_dns_packet_ipv6(
 
     assert(fd >= 0);
     assert(p);
-    assert(avahi_dns_packet_check_valid(p) >= 0);
+    assert(catta_dns_packet_check_valid(p) >= 0);
     assert(!dst_address || dst_port > 0);
 
     if (!dst_address)
@@ -586,7 +586,7 @@ int avahi_send_dns_packet_ipv6(
         ipv6_address_to_sockaddr(&sa, dst_address, dst_port);
 
     memset(&io, 0, sizeof(io));
-    io.iov_base = AVAHI_DNS_PACKET_DATA(p);
+    io.iov_base = CATTA_DNS_PACKET_DATA(p);
     io.iov_len = p->size;
 
     memset(&msg, 0, sizeof(msg));
@@ -623,15 +623,15 @@ int avahi_send_dns_packet_ipv6(
     return sendmsg_loop(fd, &msg, 0);
 }
 
-AvahiDnsPacket *avahi_recv_dns_packet_ipv4(
+CattaDnsPacket *catta_recv_dns_packet_ipv4(
         int fd,
-        AvahiIPv4Address *ret_src_address,
+        CattaIPv4Address *ret_src_address,
         uint16_t *ret_src_port,
-        AvahiIPv4Address *ret_dst_address,
-        AvahiIfIndex *ret_iface,
+        CattaIPv4Address *ret_dst_address,
+        CattaIfIndex *ret_iface,
         uint8_t *ret_ttl) {
 
-    AvahiDnsPacket *p= NULL;
+    CattaDnsPacket *p= NULL;
     struct msghdr msg;
     struct iovec io;
     size_t aux[1024 / sizeof(size_t)]; /* for alignment on ia64 ! */
@@ -644,18 +644,18 @@ AvahiDnsPacket *avahi_recv_dns_packet_ipv4(
     assert(fd >= 0);
 
     if (ioctl(fd, FIONREAD, &ms) < 0) {
-        avahi_log_warn("ioctl(): %s", strerror(errno));
+        catta_log_warn("ioctl(): %s", strerror(errno));
         goto fail;
     }
 
     if (ms < 0) {
-        avahi_log_warn("FIONREAD returned negative value.");
+        catta_log_warn("FIONREAD returned negative value.");
         goto fail;
     }
 
-    p = avahi_dns_packet_new(ms + AVAHI_DNS_PACKET_EXTRA_SIZE);
+    p = catta_dns_packet_new(ms + CATTA_DNS_PACKET_EXTRA_SIZE);
 
-    io.iov_base = AVAHI_DNS_PACKET_DATA(p);
+    io.iov_base = CATTA_DNS_PACKET_DATA(p);
     io.iov_len = p->max_size;
 
     memset(&msg, 0, sizeof(msg));
@@ -674,7 +674,7 @@ AvahiDnsPacket *avahi_recv_dns_packet_ipv4(
         links. (See #60) */
 
         if (errno != EAGAIN)
-            avahi_log_warn("recvmsg(): %s", strerror(errno));
+            catta_log_warn("recvmsg(): %s", strerror(errno));
 
         goto fail;
     }
@@ -694,11 +694,11 @@ AvahiDnsPacket *avahi_recv_dns_packet_ipv4(
     p->size = (size_t) l;
 
     if (ret_src_port)
-        *ret_src_port = avahi_port_from_sockaddr((struct sockaddr*) &sa);
+        *ret_src_port = catta_port_from_sockaddr((struct sockaddr*) &sa);
 
     if (ret_src_address) {
-        AvahiAddress a;
-        avahi_address_from_sockaddr((struct sockaddr*) &sa, &a);
+        CattaAddress a;
+        catta_address_from_sockaddr((struct sockaddr*) &sa, &a);
         *ret_src_address = a.data.ipv4;
     }
 
@@ -706,7 +706,7 @@ AvahiDnsPacket *avahi_recv_dns_packet_ipv4(
         *ret_ttl = 255;
 
     if (ret_iface)
-        *ret_iface = AVAHI_IF_UNSPEC;
+        *ret_iface = CATTA_IF_UNSPEC;
 
     for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
 
@@ -767,7 +767,7 @@ AvahiDnsPacket *avahi_recv_dns_packet_ipv4(
 #endif
 
                 default:
-                    avahi_log_warn("Unhandled cmsg_type: %d", cmsg->cmsg_type);
+                    catta_log_warn("Unhandled cmsg_type: %d", cmsg->cmsg_type);
                     break;
             }
         }
@@ -779,20 +779,20 @@ AvahiDnsPacket *avahi_recv_dns_packet_ipv4(
 
 fail:
     if (p)
-        avahi_dns_packet_free(p);
+        catta_dns_packet_free(p);
 
     return NULL;
 }
 
-AvahiDnsPacket *avahi_recv_dns_packet_ipv6(
+CattaDnsPacket *catta_recv_dns_packet_ipv6(
         int fd,
-        AvahiIPv6Address *ret_src_address,
+        CattaIPv6Address *ret_src_address,
         uint16_t *ret_src_port,
-        AvahiIPv6Address *ret_dst_address,
-        AvahiIfIndex *ret_iface,
+        CattaIPv6Address *ret_dst_address,
+        CattaIfIndex *ret_iface,
         uint8_t *ret_ttl) {
 
-    AvahiDnsPacket *p = NULL;
+    CattaDnsPacket *p = NULL;
     struct msghdr msg;
     struct iovec io;
     size_t aux[1024 / sizeof(size_t)];
@@ -805,18 +805,18 @@ AvahiDnsPacket *avahi_recv_dns_packet_ipv6(
     assert(fd >= 0);
 
     if (ioctl(fd, FIONREAD, &ms) < 0) {
-        avahi_log_warn("ioctl(): %s", strerror(errno));
+        catta_log_warn("ioctl(): %s", strerror(errno));
         goto fail;
     }
 
     if (ms < 0) {
-        avahi_log_warn("FIONREAD returned negative value.");
+        catta_log_warn("FIONREAD returned negative value.");
         goto fail;
     }
 
-    p = avahi_dns_packet_new(ms + AVAHI_DNS_PACKET_EXTRA_SIZE);
+    p = catta_dns_packet_new(ms + CATTA_DNS_PACKET_EXTRA_SIZE);
 
-    io.iov_base = AVAHI_DNS_PACKET_DATA(p);
+    io.iov_base = CATTA_DNS_PACKET_DATA(p);
     io.iov_len = p->max_size;
 
     memset(&msg, 0, sizeof(msg));
@@ -836,7 +836,7 @@ AvahiDnsPacket *avahi_recv_dns_packet_ipv6(
         links. (See #60) */
 
         if (errno != EAGAIN)
-            avahi_log_warn("recvmsg(): %s", strerror(errno));
+            catta_log_warn("recvmsg(): %s", strerror(errno));
 
         goto fail;
     }
@@ -852,11 +852,11 @@ AvahiDnsPacket *avahi_recv_dns_packet_ipv6(
     p->size = (size_t) l;
 
     if (ret_src_port)
-        *ret_src_port = avahi_port_from_sockaddr((struct sockaddr*) &sa);
+        *ret_src_port = catta_port_from_sockaddr((struct sockaddr*) &sa);
 
     if (ret_src_address) {
-        AvahiAddress a;
-        avahi_address_from_sockaddr((struct sockaddr*) &sa, &a);
+        CattaAddress a;
+        catta_address_from_sockaddr((struct sockaddr*) &sa, &a);
         *ret_src_address = a.data.ipv6;
     }
 
@@ -889,7 +889,7 @@ AvahiDnsPacket *avahi_recv_dns_packet_ipv6(
                 }
 
                 default:
-                    avahi_log_warn("Unhandled cmsg_type: %d", cmsg->cmsg_type);
+                    catta_log_warn("Unhandled cmsg_type: %d", cmsg->cmsg_type);
                     break;
             }
         }
@@ -902,17 +902,17 @@ AvahiDnsPacket *avahi_recv_dns_packet_ipv6(
 
 fail:
     if (p)
-        avahi_dns_packet_free(p);
+        catta_dns_packet_free(p);
 
     return NULL;
 }
 
-int avahi_open_unicast_socket_ipv4(void) {
+int catta_open_unicast_socket_ipv4(void) {
     struct sockaddr_in local;
     int fd = -1;
 
     if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
-        avahi_log_warn("socket() failed: %s", strerror(errno));
+        catta_log_warn("socket() failed: %s", strerror(errno));
         goto fail;
     }
 
@@ -920,7 +920,7 @@ int avahi_open_unicast_socket_ipv4(void) {
     local.sin_family = AF_INET;
 
     if (bind(fd, (struct sockaddr*) &local, sizeof(local)) < 0) {
-        avahi_log_warn("bind() failed: %s", strerror(errno));
+        catta_log_warn("bind() failed: %s", strerror(errno));
         goto fail;
     }
 
@@ -928,13 +928,13 @@ int avahi_open_unicast_socket_ipv4(void) {
          goto fail;
     }
 
-    if (avahi_set_cloexec(fd) < 0) {
-        avahi_log_warn("FD_CLOEXEC failed: %s", strerror(errno));
+    if (catta_set_cloexec(fd) < 0) {
+        catta_log_warn("FD_CLOEXEC failed: %s", strerror(errno));
         goto fail;
     }
 
-    if (avahi_set_nonblock(fd) < 0) {
-        avahi_log_warn("O_NONBLOCK failed: %s", strerror(errno));
+    if (catta_set_nonblock(fd) < 0) {
+        catta_log_warn("O_NONBLOCK failed: %s", strerror(errno));
         goto fail;
     }
 
@@ -947,18 +947,18 @@ fail:
     return -1;
 }
 
-int avahi_open_unicast_socket_ipv6(void) {
+int catta_open_unicast_socket_ipv6(void) {
     struct sockaddr_in6 local;
     int fd = -1, yes;
 
     if ((fd = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
-        avahi_log_warn("socket() failed: %s", strerror(errno));
+        catta_log_warn("socket() failed: %s", strerror(errno));
         goto fail;
     }
 
     yes = 1;
     if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &yes, sizeof(yes)) < 0) {
-        avahi_log_warn("IPV6_V6ONLY failed: %s", strerror(errno));
+        catta_log_warn("IPV6_V6ONLY failed: %s", strerror(errno));
         goto fail;
     }
 
@@ -966,20 +966,20 @@ int avahi_open_unicast_socket_ipv6(void) {
     local.sin6_family = AF_INET6;
 
     if (bind(fd, (struct sockaddr*) &local, sizeof(local)) < 0) {
-        avahi_log_warn("bind() failed: %s", strerror(errno));
+        catta_log_warn("bind() failed: %s", strerror(errno));
         goto fail;
     }
 
     if (ipv6_pktinfo(fd) < 0)
         goto fail;
 
-    if (avahi_set_cloexec(fd) < 0) {
-        avahi_log_warn("FD_CLOEXEC failed: %s", strerror(errno));
+    if (catta_set_cloexec(fd) < 0) {
+        catta_log_warn("FD_CLOEXEC failed: %s", strerror(errno));
         goto fail;
     }
 
-    if (avahi_set_nonblock(fd) < 0) {
-        avahi_log_warn("O_NONBLOCK failed: %s", strerror(errno));
+    if (catta_set_nonblock(fd) < 0) {
+        catta_log_warn("O_NONBLOCK failed: %s", strerror(errno));
         goto fail;
     }
 
index 92f12d74113f6694908b0158b2990b2aff66c2d7..59da2a8441d572d2cd8aaa3efa2b1e551d8b60e8 100644 (file)
@@ -2,20 +2,20 @@
 #define foosockethfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 #include "dns.h"
 
-#define AVAHI_MDNS_PORT 5353
-#define AVAHI_DNS_PORT 53
-#define AVAHI_IPV4_MCAST_GROUP "224.0.0.251"
-#define AVAHI_IPV6_MCAST_GROUP "ff02::fb"
+#define CATTA_MDNS_PORT 5353
+#define CATTA_DNS_PORT 53
+#define CATTA_IPV4_MCAST_GROUP "224.0.0.251"
+#define CATTA_IPV6_MCAST_GROUP "ff02::fb"
 
-int avahi_open_socket_ipv4(int no_reuse);
-int avahi_open_socket_ipv6(int no_reuse);
+int catta_open_socket_ipv4(int no_reuse);
+int catta_open_socket_ipv6(int no_reuse);
 
-int avahi_open_unicast_socket_ipv4(void);
-int avahi_open_unicast_socket_ipv6(void);
+int catta_open_unicast_socket_ipv4(void);
+int catta_open_unicast_socket_ipv6(void);
 
-int avahi_send_dns_packet_ipv4(int fd, AvahiIfIndex iface, AvahiDnsPacket *p, const AvahiIPv4Address *src_address, const AvahiIPv4Address *dst_address, uint16_t dst_port);
-int avahi_send_dns_packet_ipv6(int fd, AvahiIfIndex iface, AvahiDnsPacket *p, const AvahiIPv6Address *src_address, const AvahiIPv6Address *dst_address, uint16_t dst_port);
+int catta_send_dns_packet_ipv4(int fd, CattaIfIndex iface, CattaDnsPacket *p, const CattaIPv4Address *src_address, const CattaIPv4Address *dst_address, uint16_t dst_port);
+int catta_send_dns_packet_ipv6(int fd, CattaIfIndex iface, CattaDnsPacket *p, const CattaIPv6Address *src_address, const CattaIPv6Address *dst_address, uint16_t dst_port);
 
-AvahiDnsPacket *avahi_recv_dns_packet_ipv4(int fd, AvahiIPv4Address *ret_src_address, uint16_t *ret_src_port, AvahiIPv4Address *ret_dst_address, AvahiIfIndex *ret_iface, uint8_t *ret_ttl);
-AvahiDnsPacket *avahi_recv_dns_packet_ipv6(int fd, AvahiIPv6Address *ret_src_address, uint16_t *ret_src_port, AvahiIPv6Address *ret_dst_address, AvahiIfIndex *ret_iface, uint8_t *ret_ttl);
+CattaDnsPacket *catta_recv_dns_packet_ipv4(int fd, CattaIPv4Address *ret_src_address, uint16_t *ret_src_port, CattaIPv4Address *ret_dst_address, CattaIfIndex *ret_iface, uint8_t *ret_ttl);
+CattaDnsPacket *catta_recv_dns_packet_ipv6(int fd, CattaIPv6Address *ret_src_address, uint16_t *ret_src_port, CattaIPv6Address *ret_dst_address, CattaIfIndex *ret_iface, uint8_t *ret_ttl);
 
-int avahi_mdns_mcast_join_ipv4(int fd, const AvahiIPv4Address *local_address, int iface, int join);
-int avahi_mdns_mcast_join_ipv6(int fd, const AvahiIPv6Address *local_address, int iface, int join);
+int catta_mdns_mcast_join_ipv4(int fd, const CattaIPv4Address *local_address, int iface, int join);
+int catta_mdns_mcast_join_ipv6(int fd, const CattaIPv6Address *local_address, int iface, int join);
 
 #endif
index bba4a2d1a3519676743e3a6e1d5b0624914c5683..084f67ad2dfad7465afcd34678764c2825eb86cf 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <avahi/strlst.h>
-#include <avahi/malloc.h>
-#include <avahi/defs.h>
+#include <catta/strlst.h>
+#include <catta/malloc.h>
+#include <catta/defs.h>
 
-AvahiStringList*avahi_string_list_add_anonymous(AvahiStringList *l, size_t size) {
-    AvahiStringList *n;
+CattaStringList*catta_string_list_add_anonymous(CattaStringList *l, size_t size) {
+    CattaStringList *n;
 
-    if (!(n = avahi_malloc(sizeof(AvahiStringList) + size)))
+    if (!(n = catta_malloc(sizeof(CattaStringList) + size)))
         return NULL;
 
     n->next = l;
@@ -46,12 +46,12 @@ AvahiStringList*avahi_string_list_add_anonymous(AvahiStringList *l, size_t size)
     return n;
 }
 
-AvahiStringList *avahi_string_list_add_arbitrary(AvahiStringList *l, const uint8_t*text, size_t size) {
-    AvahiStringList *n;
+CattaStringList *catta_string_list_add_arbitrary(CattaStringList *l, const uint8_t*text, size_t size) {
+    CattaStringList *n;
 
     assert(size == 0 || text);
 
-    if (!(n = avahi_string_list_add_anonymous(l, size)))
+    if (!(n = catta_string_list_add_anonymous(l, size)))
         return NULL;
 
     if (size > 0)
@@ -60,15 +60,15 @@ AvahiStringList *avahi_string_list_add_arbitrary(AvahiStringList *l, const uint8
     return n;
 }
 
-AvahiStringList *avahi_string_list_add(AvahiStringList *l, const char *text) {
+CattaStringList *catta_string_list_add(CattaStringList *l, const char *text) {
     assert(text);
 
-    return avahi_string_list_add_arbitrary(l, (const uint8_t*) text, strlen(text));
+    return catta_string_list_add_arbitrary(l, (const uint8_t*) text, strlen(text));
 }
 
-int avahi_string_list_parse(const void* data, size_t size, AvahiStringList **ret) {
+int catta_string_list_parse(const void* data, size_t size, CattaStringList **ret) {
     const uint8_t *c;
-    AvahiStringList *r = NULL;
+    CattaStringList *r = NULL;
 
     assert(data);
     assert(ret);
@@ -84,9 +84,9 @@ int avahi_string_list_parse(const void* data, size_t size, AvahiStringList **ret
             goto fail; /* Overflow */
 
         if (k > 0) { /* Ignore empty strings */
-            AvahiStringList *n;
+            CattaStringList *n;
 
-            if (!(n = avahi_string_list_add_arbitrary(r, c, k)))
+            if (!(n = catta_string_list_add_arbitrary(r, c, k)))
                 goto fail; /* OOM */
 
             r = n;
@@ -101,22 +101,22 @@ int avahi_string_list_parse(const void* data, size_t size, AvahiStringList **ret
     return 0;
 
 fail:
-    avahi_string_list_free(r);
+    catta_string_list_free(r);
     return -1;
 }
 
-void avahi_string_list_free(AvahiStringList *l) {
-    AvahiStringList *n;
+void catta_string_list_free(CattaStringList *l) {
+    CattaStringList *n;
 
     while (l) {
         n = l->next;
-        avahi_free(l);
+        catta_free(l);
         l = n;
     }
 }
 
-AvahiStringList* avahi_string_list_reverse(AvahiStringList *l) {
-    AvahiStringList *r = NULL, *n;
+CattaStringList* catta_string_list_reverse(CattaStringList *l) {
+    CattaStringList *r = NULL, *n;
 
     while (l) {
         n = l->next;
@@ -128,8 +128,8 @@ AvahiStringList* avahi_string_list_reverse(AvahiStringList *l) {
     return r;
 }
 
-char* avahi_string_list_to_string(AvahiStringList *l) {
-    AvahiStringList *n;
+char* catta_string_list_to_string(CattaStringList *l) {
+    CattaStringList *n;
     size_t s = 0;
     char *t, *e;
 
@@ -140,10 +140,10 @@ char* avahi_string_list_to_string(AvahiStringList *l) {
         s += n->size+2;
     }
 
-    if (!(t = e = avahi_new(char, s+1)))
+    if (!(t = e = catta_new(char, s+1)))
         return NULL;
 
-    l = avahi_string_list_reverse(l);
+    l = catta_string_list_reverse(l);
 
     for (n = l; n; n = n->next) {
         if (n != l)
@@ -158,21 +158,21 @@ char* avahi_string_list_to_string(AvahiStringList *l) {
         assert(e);
     }
 
-    l = avahi_string_list_reverse(l);
+    l = catta_string_list_reverse(l);
 
     *e = 0;
 
     return t;
 }
 
-size_t avahi_string_list_serialize(AvahiStringList *l, void *data, size_t size) {
+size_t catta_string_list_serialize(CattaStringList *l, void *data, size_t size) {
     size_t used = 0;
 
     if (data) {
-        AvahiStringList *n;
+        CattaStringList *n;
         uint8_t *c;
 
-        l = avahi_string_list_reverse(l);
+        l = catta_string_list_reverse(l);
         c = data;
 
         for (n = l; size > 1 && n; n = n->next) {
@@ -198,7 +198,7 @@ size_t avahi_string_list_serialize(AvahiStringList *l, void *data, size_t size)
             size -= 1 + k;
         }
 
-        l = avahi_string_list_reverse(l);
+        l = catta_string_list_reverse(l);
 
         if (used == 0 && size > 0) {
 
@@ -211,7 +211,7 @@ size_t avahi_string_list_serialize(AvahiStringList *l, void *data, size_t size)
         }
 
     } else {
-        AvahiStringList *n;
+        CattaStringList *n;
 
         for (n = l; n; n = n->next) {
             size_t k;
@@ -232,7 +232,7 @@ size_t avahi_string_list_serialize(AvahiStringList *l, void *data, size_t size)
     return used;
 }
 
-int avahi_string_list_equal(const AvahiStringList *a, const AvahiStringList *b) {
+int catta_string_list_equal(const CattaStringList *a, const CattaStringList *b) {
 
     for (;;) {
         if (!a && !b)
@@ -252,69 +252,69 @@ int avahi_string_list_equal(const AvahiStringList *a, const AvahiStringList *b)
     }
 }
 
-AvahiStringList *avahi_string_list_add_many(AvahiStringList *r, ...) {
+CattaStringList *catta_string_list_add_many(CattaStringList *r, ...) {
     va_list va;
 
     va_start(va, r);
-    r = avahi_string_list_add_many_va(r, va);
+    r = catta_string_list_add_many_va(r, va);
     va_end(va);
 
     return r;
 }
 
-AvahiStringList *avahi_string_list_add_many_va(AvahiStringList *r, va_list va) {
+CattaStringList *catta_string_list_add_many_va(CattaStringList *r, va_list va) {
     const char *txt;
 
     while ((txt = va_arg(va, const char*)))
-        r = avahi_string_list_add(r, txt);
+        r = catta_string_list_add(r, txt);
 
     return r;
 }
 
-AvahiStringList *avahi_string_list_new(const char *txt, ...) {
+CattaStringList *catta_string_list_new(const char *txt, ...) {
     va_list va;
-    AvahiStringList *r = NULL;
+    CattaStringList *r = NULL;
 
     if (txt) {
-        r = avahi_string_list_add(r, txt);
+        r = catta_string_list_add(r, txt);
 
         va_start(va, txt);
-        r = avahi_string_list_add_many_va(r, va);
+        r = catta_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);
+CattaStringList *catta_string_list_new_va(va_list va) {
+    return catta_string_list_add_many_va(NULL, va);
 }
 
-AvahiStringList *avahi_string_list_copy(const AvahiStringList *l) {
-    AvahiStringList *r = NULL;
+CattaStringList *catta_string_list_copy(const CattaStringList *l) {
+    CattaStringList *r = NULL;
 
     for (; l; l = l->next)
-        if (!(r = avahi_string_list_add_arbitrary(r, l->text, l->size))) {
-            avahi_string_list_free(r);
+        if (!(r = catta_string_list_add_arbitrary(r, l->text, l->size))) {
+            catta_string_list_free(r);
             return NULL;
         }
 
-    return avahi_string_list_reverse(r);
+    return catta_string_list_reverse(r);
 }
 
-AvahiStringList *avahi_string_list_new_from_array(const char *array[], int length) {
-    AvahiStringList *r = NULL;
+CattaStringList *catta_string_list_new_from_array(const char *array[], int length) {
+    CattaStringList *r = NULL;
     int i;
 
     assert(array);
 
     for (i = 0; length >= 0 ? i < length : !!array[i]; i++)
-        r = avahi_string_list_add(r, array[i]);
+        r = catta_string_list_add(r, array[i]);
 
     return r;
 }
 
-unsigned avahi_string_list_length(const AvahiStringList *l) {
+unsigned catta_string_list_length(const CattaStringList *l) {
     unsigned n = 0;
 
     for (; l; l = l->next)
@@ -323,18 +323,18 @@ unsigned avahi_string_list_length(const AvahiStringList *l) {
     return n;
 }
 
-AvahiStringList *avahi_string_list_add_vprintf(AvahiStringList *l, const char *format, va_list va) {
+CattaStringList *catta_string_list_add_vprintf(CattaStringList *l, const char *format, va_list va) {
     size_t len = 80;
-    AvahiStringList *r;
+    CattaStringList *r;
 
     assert(format);
 
-    if (!(r = avahi_malloc(sizeof(AvahiStringList) + len)))
+    if (!(r = catta_malloc(sizeof(CattaStringList) + len)))
         return NULL;
 
     for (;;) {
         int n;
-        AvahiStringList *nr;
+        CattaStringList *nr;
         va_list va2;
 
         va_copy(va2, va);
@@ -349,8 +349,8 @@ AvahiStringList *avahi_string_list_add_vprintf(AvahiStringList *l, const char *f
         else
             len *= 2;
 
-        if (!(nr = avahi_realloc(r, sizeof(AvahiStringList) + len))) {
-            avahi_free(r);
+        if (!(nr = catta_realloc(r, sizeof(CattaStringList) + len))) {
+            catta_free(r);
             return NULL;
         }
 
@@ -363,19 +363,19 @@ AvahiStringList *avahi_string_list_add_vprintf(AvahiStringList *l, const char *f
     return r;
 }
 
-AvahiStringList *avahi_string_list_add_printf(AvahiStringList *l, const char *format, ...) {
+CattaStringList *catta_string_list_add_printf(CattaStringList *l, const char *format, ...) {
     va_list va;
 
     assert(format);
 
     va_start(va, format);
-    l  = avahi_string_list_add_vprintf(l, format, va);
+    l  = catta_string_list_add_vprintf(l, format, va);
     va_end(va);
 
     return l;
 }
 
-AvahiStringList *avahi_string_list_find(AvahiStringList *l, const char *key) {
+CattaStringList *catta_string_list_find(CattaStringList *l, const char *key) {
     size_t n;
 
     assert(key);
@@ -392,25 +392,25 @@ AvahiStringList *avahi_string_list_find(AvahiStringList *l, const char *key) {
     return NULL;
 }
 
-AvahiStringList *avahi_string_list_add_pair(AvahiStringList *l, const char *key, const char *value) {
+CattaStringList *catta_string_list_add_pair(CattaStringList *l, const char *key, const char *value) {
     assert(key);
 
     if (value)
-        return avahi_string_list_add_printf(l, "%s=%s", key, value);
+        return catta_string_list_add_printf(l, "%s=%s", key, value);
     else
-        return avahi_string_list_add(l, key);
+        return catta_string_list_add(l, key);
 }
 
-AvahiStringList *avahi_string_list_add_pair_arbitrary(AvahiStringList *l, const char *key, const uint8_t *value, size_t size) {
+CattaStringList *catta_string_list_add_pair_arbitrary(CattaStringList *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);
+        return catta_string_list_add(l, key);
 
     n = strlen(key);
 
-    if (!(l = avahi_string_list_add_anonymous(l, n + 1 + size)))
+    if (!(l = catta_string_list_add_anonymous(l, n + 1 + size)))
         return NULL;
 
     memcpy(l->text, key, n);
@@ -420,7 +420,7 @@ AvahiStringList *avahi_string_list_add_pair_arbitrary(AvahiStringList *l, const
     return l;
 }
 
-int avahi_string_list_get_pair(AvahiStringList *l, char **key, char **value, size_t *size) {
+int catta_string_list_get_pair(CattaStringList *l, char **key, char **value, size_t *size) {
     char *e;
 
     assert(l);
@@ -428,7 +428,7 @@ int avahi_string_list_get_pair(AvahiStringList *l, char **key, char **value, siz
     if (!(e = memchr(l->text, '=', l->size))) {
 
         if (key)
-            if (!(*key = avahi_strdup((char*) l->text)))
+            if (!(*key = catta_strdup((char*) l->text)))
                 return -1;
 
         if (value)
@@ -441,7 +441,7 @@ int avahi_string_list_get_pair(AvahiStringList *l, char **key, char **value, siz
         size_t n;
 
         if (key)
-            if (!(*key = avahi_strndup((char*) l->text, e - (char *) l->text)))
+            if (!(*key = catta_strndup((char*) l->text, e - (char *) l->text)))
                 return -1;
 
         e++; /* Advance after '=' */
@@ -450,9 +450,9 @@ int avahi_string_list_get_pair(AvahiStringList *l, char **key, char **value, siz
 
         if (value) {
 
-            if (!(*value = avahi_memdup(e, n+1))) {
+            if (!(*value = catta_memdup(e, n+1))) {
                 if (key)
-                    avahi_free(*key);
+                    catta_free(*key);
                 return -1;
             }
 
@@ -466,40 +466,40 @@ int avahi_string_list_get_pair(AvahiStringList *l, char **key, char **value, siz
     return 0;
 }
 
-AvahiStringList *avahi_string_list_get_next(AvahiStringList *l) {
+CattaStringList *catta_string_list_get_next(CattaStringList *l) {
     assert(l);
     return l->next;
 }
 
-uint8_t *avahi_string_list_get_text(AvahiStringList *l) {
+uint8_t *catta_string_list_get_text(CattaStringList *l) {
     assert(l);
     return l->text;
 }
 
-size_t avahi_string_list_get_size(AvahiStringList *l) {
+size_t catta_string_list_get_size(CattaStringList *l) {
     assert(l);
     return l->size;
 }
 
-uint32_t avahi_string_list_get_service_cookie(AvahiStringList *l) {
-    AvahiStringList *f;
+uint32_t catta_string_list_get_service_cookie(CattaStringList *l) {
+    CattaStringList *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 (!(f = catta_string_list_find(l, CATTA_SERVICE_COOKIE)))
+        return CATTA_SERVICE_COOKIE_INVALID;
 
-    if (avahi_string_list_get_pair(f, NULL, &value, NULL) < 0 || !value)
-        return AVAHI_SERVICE_COOKIE_INVALID;
+    if (catta_string_list_get_pair(f, NULL, &value, NULL) < 0 || !value)
+        return CATTA_SERVICE_COOKIE_INVALID;
 
     ret = (uint32_t) strtoll(value, &end, 0);
 
     if (*value && end && *end != 0) {
-        avahi_free(value);
-        return AVAHI_SERVICE_COOKIE_INVALID;
+        catta_free(value);
+        return CATTA_SERVICE_COOKIE_INVALID;
     }
 
-    avahi_free(value);
+    catta_free(value);
 
     return ret;
 }
index 42e2cdd1213c6c9d69ec8d52d14c8f34a271c8c8..aa22bf993205c065747a559866c4fdc706c0b6af 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <pthread.h>
 #include <signal.h>
 
-#include <avahi/llist.h>
-#include <avahi/malloc.h>
-#include <avahi/timeval.h>
-#include <avahi/simple-watch.h>
-#include <avahi/thread-watch.h>
+#include <catta/llist.h>
+#include <catta/malloc.h>
+#include <catta/timeval.h>
+#include <catta/simple-watch.h>
+#include <catta/thread-watch.h>
 
-struct AvahiThreadedPoll {
-    AvahiSimplePoll *simple_poll;
+struct CattaThreadedPoll {
+    CattaSimplePoll *simple_poll;
     pthread_t thread_id;
     pthread_mutex_t mutex;
     int thread_running;
@@ -50,7 +50,7 @@ static int poll_func(struct pollfd *ufds, unsigned int nfds, int timeout, void *
     int r;
 
     /* Before entering poll() we unlock the mutex, so that
-     * avahi_simple_poll_quit() can succeed from another thread. */
+     * catta_simple_poll_quit() can succeed from another thread. */
 
     pthread_mutex_unlock(mutex);
     r = poll(ufds, nfds, timeout);
@@ -60,7 +60,7 @@ static int poll_func(struct pollfd *ufds, unsigned int nfds, int timeout, void *
 }
 
 static void* thread(void *userdata){
-    AvahiThreadedPoll *p = userdata;
+    CattaThreadedPoll *p = userdata;
     sigset_t mask;
 
     /* Make sure that signals are delivered to the main thread */
@@ -68,24 +68,24 @@ static void* thread(void *userdata){
     pthread_sigmask(SIG_BLOCK, &mask, NULL);
 
     pthread_mutex_lock(&p->mutex);
-    p->retval = avahi_simple_poll_loop(p->simple_poll);
+    p->retval = catta_simple_poll_loop(p->simple_poll);
     pthread_mutex_unlock(&p->mutex);
 
     return NULL;
 }
 
-AvahiThreadedPoll *avahi_threaded_poll_new(void) {
-    AvahiThreadedPoll *p;
+CattaThreadedPoll *catta_threaded_poll_new(void) {
+    CattaThreadedPoll *p;
 
-    if (!(p = avahi_new(AvahiThreadedPoll, 1)))
+    if (!(p = catta_new(CattaThreadedPoll, 1)))
         goto fail; /* OOM */
 
-    if (!(p->simple_poll = avahi_simple_poll_new()))
+    if (!(p->simple_poll = catta_simple_poll_new()))
         goto fail;
 
     pthread_mutex_init(&p->mutex, NULL);
 
-    avahi_simple_poll_set_func(p->simple_poll, poll_func, &p->mutex);
+    catta_simple_poll_set_func(p->simple_poll, poll_func, &p->mutex);
 
     p->thread_running = 0;
 
@@ -94,39 +94,39 @@ AvahiThreadedPoll *avahi_threaded_poll_new(void) {
 fail:
     if (p) {
         if (p->simple_poll) {
-            avahi_simple_poll_free(p->simple_poll);
+            catta_simple_poll_free(p->simple_poll);
             pthread_mutex_destroy(&p->mutex);
         }
 
-        avahi_free(p);
+        catta_free(p);
     }
 
     return NULL;
 }
 
-void avahi_threaded_poll_free(AvahiThreadedPoll *p) {
+void catta_threaded_poll_free(CattaThreadedPoll *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);
+        catta_threaded_poll_stop(p);
 
     if (p->simple_poll)
-        avahi_simple_poll_free(p->simple_poll);
+        catta_simple_poll_free(p->simple_poll);
 
     pthread_mutex_destroy(&p->mutex);
-    avahi_free(p);
+    catta_free(p);
 }
 
-const AvahiPoll* avahi_threaded_poll_get(AvahiThreadedPoll *p) {
+const CattaPoll* catta_threaded_poll_get(CattaThreadedPoll *p) {
     assert(p);
 
-    return avahi_simple_poll_get(p->simple_poll);
+    return catta_simple_poll_get(p->simple_poll);
 }
 
-int avahi_threaded_poll_start(AvahiThreadedPoll *p) {
+int catta_threaded_poll_start(CattaThreadedPoll *p) {
     assert(p);
 
     assert(!p->thread_running);
@@ -139,7 +139,7 @@ int avahi_threaded_poll_start(AvahiThreadedPoll *p) {
     return 0;
 }
 
-int avahi_threaded_poll_stop(AvahiThreadedPoll *p) {
+int catta_threaded_poll_stop(CattaThreadedPoll *p) {
     assert(p);
 
     if (!p->thread_running)
@@ -149,7 +149,7 @@ int avahi_threaded_poll_stop(AvahiThreadedPoll *p) {
     assert(!pthread_equal(pthread_self(), p->thread_id));
 
     pthread_mutex_lock(&p->mutex);
-    avahi_simple_poll_quit(p->simple_poll);
+    catta_simple_poll_quit(p->simple_poll);
     pthread_mutex_unlock(&p->mutex);
 
     pthread_join(p->thread_id, NULL);
@@ -158,16 +158,16 @@ int avahi_threaded_poll_stop(AvahiThreadedPoll *p) {
     return p->retval;
 }
 
-void avahi_threaded_poll_quit(AvahiThreadedPoll *p) {
+void catta_threaded_poll_quit(CattaThreadedPoll *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);
+    catta_simple_poll_quit(p->simple_poll);
 }
 
-void avahi_threaded_poll_lock(AvahiThreadedPoll *p) {
+void catta_threaded_poll_lock(CattaThreadedPoll *p) {
     assert(p);
 
     /* Make sure that this function is not called from the helper thread */
@@ -176,7 +176,7 @@ void avahi_threaded_poll_lock(AvahiThreadedPoll *p) {
     pthread_mutex_lock(&p->mutex);
 }
 
-void avahi_threaded_poll_unlock(AvahiThreadedPoll *p) {
+void catta_threaded_poll_unlock(CattaThreadedPoll *p) {
     assert(p);
 
     /* Make sure that this function is not called from the helper thread */
index d7ae12f49babf31aa29956ab0d08b176c728a099..51f8b5fde786d65e6de751d09078257eb08d2560 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <assert.h>
 #include <stdlib.h>
 
-#include <avahi/timeval.h>
-#include <avahi/malloc.h>
-#include <avahi/log.h>
+#include <catta/timeval.h>
+#include <catta/malloc.h>
+#include <catta/log.h>
 
 #include "timeeventq.h"
 
-struct AvahiTimeEvent {
-    AvahiTimeEventQueue *queue;
-    AvahiPrioQueueNode *node;
+struct CattaTimeEvent {
+    CattaTimeEventQueue *queue;
+    CattaPrioQueueNode *node;
     struct timeval expiry;
     struct timeval last_run;
-    AvahiTimeEventCallback callback;
+    CattaTimeEventCallback callback;
     void* userdata;
 };
 
-struct AvahiTimeEventQueue {
-    const AvahiPoll *poll_api;
-    AvahiPrioQueue *prioq;
-    AvahiTimeout *timeout;
+struct CattaTimeEventQueue {
+    const CattaPoll *poll_api;
+    CattaPrioQueue *prioq;
+    CattaTimeout *timeout;
 };
 
 static int compare(const void* _a, const void* _b) {
-    const AvahiTimeEvent *a = _a,  *b = _b;
+    const CattaTimeEvent *a = _a,  *b = _b;
     int ret;
 
-    if ((ret = avahi_timeval_compare(&a->expiry, &b->expiry)) != 0)
+    if ((ret = catta_timeval_compare(&a->expiry, &b->expiry)) != 0)
         return ret;
 
     /* If both exevents are scheduled for the same time, put the entry
      * that has been run earlier the last time first. */
-    return avahi_timeval_compare(&a->last_run, &b->last_run);
+    return catta_timeval_compare(&a->last_run, &b->last_run);
 }
 
-static AvahiTimeEvent* time_event_queue_root(AvahiTimeEventQueue *q) {
+static CattaTimeEvent* time_event_queue_root(CattaTimeEventQueue *q) {
     assert(q);
 
     return q->prioq->root ? q->prioq->root->data : NULL;
 }
 
-static void update_timeout(AvahiTimeEventQueue *q) {
-    AvahiTimeEvent *e;
+static void update_timeout(CattaTimeEventQueue *q) {
+    CattaTimeEvent *e;
     assert(q);
 
     if ((e = time_event_queue_root(q)))
@@ -73,9 +73,9 @@ static void update_timeout(AvahiTimeEventQueue *q) {
         q->poll_api->timeout_update(q->timeout, NULL);
 }
 
-static void expiration_event(AVAHI_GCC_UNUSED AvahiTimeout *timeout, void *userdata) {
-    AvahiTimeEventQueue *q = userdata;
-    AvahiTimeEvent *e;
+static void expiration_event(CATTA_GCC_UNUSED CattaTimeout *timeout, void *userdata) {
+    CattaTimeEventQueue *q = userdata;
+    CattaTimeEvent *e;
 
     if ((e = time_event_queue_root(q))) {
         struct timeval now;
@@ -83,11 +83,11 @@ static void expiration_event(AVAHI_GCC_UNUSED AvahiTimeout *timeout, void *userd
         gettimeofday(&now, NULL);
 
         /* Check if expired */
-        if (avahi_timeval_compare(&now, &e->expiry) >= 0) {
+        if (catta_timeval_compare(&now, &e->expiry) >= 0) {
 
             /* Make sure to move the entry away from the front */
             e->last_run = now;
-            avahi_prio_queue_shuffle(q->prioq, e->node);
+            catta_prio_queue_shuffle(q->prioq, e->node);
 
             /* Run it */
             assert(e->callback);
@@ -98,11 +98,11 @@ static void expiration_event(AVAHI_GCC_UNUSED AvahiTimeout *timeout, void *userd
         }
     }
 
-    avahi_log_debug(__FILE__": Strange, expiration_event() called, but nothing really happened.");
+    catta_log_debug(__FILE__": Strange, expiration_event() called, but nothing really happened.");
     update_timeout(q);
 }
 
-static void fix_expiry_time(AvahiTimeEvent *e) {
+static void fix_expiry_time(CattaTimeEvent *e) {
     struct timeval now;
     assert(e);
 
@@ -110,21 +110,21 @@ static void fix_expiry_time(AvahiTimeEvent *e) {
 
     gettimeofday(&now, NULL);
 
-    if (avahi_timeval_compare(&now, &e->expiry) > 0)
+    if (catta_timeval_compare(&now, &e->expiry) > 0)
         e->expiry = now;
 }
 
-AvahiTimeEventQueue* avahi_time_event_queue_new(const AvahiPoll *poll_api) {
-    AvahiTimeEventQueue *q;
+CattaTimeEventQueue* catta_time_event_queue_new(const CattaPoll *poll_api) {
+    CattaTimeEventQueue *q;
 
-    if (!(q = avahi_new(AvahiTimeEventQueue, 1))) {
-        avahi_log_error(__FILE__": Out of memory");
+    if (!(q = catta_new(CattaTimeEventQueue, 1))) {
+        catta_log_error(__FILE__": Out of memory");
         goto oom;
     }
 
     q->poll_api = poll_api;
 
-    if (!(q->prioq = avahi_prio_queue_new(compare)))
+    if (!(q->prioq = catta_prio_queue_new(compare)))
         goto oom;
 
     if (!(q->timeout = poll_api->timeout_new(poll_api, NULL, expiration_event, q)))
@@ -135,43 +135,43 @@ AvahiTimeEventQueue* avahi_time_event_queue_new(const AvahiPoll *poll_api) {
 oom:
 
     if (q) {
-        avahi_free(q);
+        catta_free(q);
 
         if (q->prioq)
-            avahi_prio_queue_free(q->prioq);
+            catta_prio_queue_free(q->prioq);
     }
 
     return NULL;
 }
 
-void avahi_time_event_queue_free(AvahiTimeEventQueue *q) {
-    AvahiTimeEvent *e;
+void catta_time_event_queue_free(CattaTimeEventQueue *q) {
+    CattaTimeEvent *e;
 
     assert(q);
 
     while ((e = time_event_queue_root(q)))
-        avahi_time_event_free(e);
-    avahi_prio_queue_free(q->prioq);
+        catta_time_event_free(e);
+    catta_prio_queue_free(q->prioq);
 
     q->poll_api->timeout_free(q->timeout);
 
-    avahi_free(q);
+    catta_free(q);
 }
 
-AvahiTimeEvent* avahi_time_event_new(
-    AvahiTimeEventQueue *q,
+CattaTimeEvent* catta_time_event_new(
+    CattaTimeEventQueue *q,
     const struct timeval *timeval,
-    AvahiTimeEventCallback callback,
+    CattaTimeEventCallback callback,
     void* userdata) {
 
-    AvahiTimeEvent *e;
+    CattaTimeEvent *e;
 
     assert(q);
     assert(callback);
     assert(userdata);
 
-    if (!(e = avahi_new(AvahiTimeEvent, 1))) {
-        avahi_log_error(__FILE__": Out of memory");
+    if (!(e = catta_new(CattaTimeEvent, 1))) {
+        catta_log_error(__FILE__": Out of memory");
         return NULL; /* OOM */
     }
 
@@ -191,8 +191,8 @@ AvahiTimeEvent* avahi_time_event_new(
     e->last_run.tv_sec = 0;
     e->last_run.tv_usec = 0;
 
-    if (!(e->node = avahi_prio_queue_put(q->prioq, e))) {
-        avahi_free(e);
+    if (!(e->node = catta_prio_queue_put(q->prioq, e))) {
+        catta_free(e);
         return NULL;
     }
 
@@ -200,25 +200,25 @@ AvahiTimeEvent* avahi_time_event_new(
     return e;
 }
 
-void avahi_time_event_free(AvahiTimeEvent *e) {
-    AvahiTimeEventQueue *q;
+void catta_time_event_free(CattaTimeEvent *e) {
+    CattaTimeEventQueue *q;
     assert(e);
 
     q = e->queue;
 
-    avahi_prio_queue_remove(q->prioq, e->node);
-    avahi_free(e);
+    catta_prio_queue_remove(q->prioq, e->node);
+    catta_free(e);
 
     update_timeout(q);
 }
 
-void avahi_time_event_update(AvahiTimeEvent *e, const struct timeval *timeval) {
+void catta_time_event_update(CattaTimeEvent *e, const struct timeval *timeval) {
     assert(e);
     assert(timeval);
 
     e->expiry = *timeval;
     fix_expiry_time(e);
-    avahi_prio_queue_shuffle(e->queue->prioq, e->node);
+    catta_prio_queue_shuffle(e->queue->prioq, e->node);
 
     update_timeout(e->queue);
 }
index 14ad3935c192dc9dab14f21559cf3b279ea5c37f..e613bc208e329630da3e50ca239c51df81cc7db6 100644 (file)
@@ -2,45 +2,45 @@
 #define footimeeventqhfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 #include <sys/types.h>
 
-typedef struct AvahiTimeEventQueue AvahiTimeEventQueue;
-typedef struct AvahiTimeEvent AvahiTimeEvent;
+typedef struct CattaTimeEventQueue CattaTimeEventQueue;
+typedef struct CattaTimeEvent CattaTimeEvent;
 
-#include <avahi/watch.h>
+#include <catta/watch.h>
 
 #include "prioq.h"
 
-typedef void (*AvahiTimeEventCallback)(AvahiTimeEvent *e, void* userdata);
+typedef void (*CattaTimeEventCallback)(CattaTimeEvent *e, void* userdata);
 
-AvahiTimeEventQueue* avahi_time_event_queue_new(const AvahiPoll *poll_api);
-void avahi_time_event_queue_free(AvahiTimeEventQueue *q);
+CattaTimeEventQueue* catta_time_event_queue_new(const CattaPoll *poll_api);
+void catta_time_event_queue_free(CattaTimeEventQueue *q);
 
-AvahiTimeEvent* avahi_time_event_new(
-    AvahiTimeEventQueue *q,
+CattaTimeEvent* catta_time_event_new(
+    CattaTimeEventQueue *q,
     const struct timeval *timeval,
-    AvahiTimeEventCallback callback,
+    CattaTimeEventCallback callback,
     void* userdata);
 
-void avahi_time_event_free(AvahiTimeEvent *e);
-void avahi_time_event_update(AvahiTimeEvent *e, const struct timeval *timeval);
+void catta_time_event_free(CattaTimeEvent *e);
+void catta_time_event_update(CattaTimeEvent *e, const struct timeval *timeval);
 
 #endif
index 9e92086bba6837efa4a93ac846a14cffd6b3d60f..5ed395fbc12afb0db7671481066e88f7a29fe010 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
@@ -25,9 +25,9 @@
 #include <stdlib.h>
 #include <assert.h>
 
-#include <avahi/timeval.h>
+#include <catta/timeval.h>
 
-int avahi_timeval_compare(const struct timeval *a, const struct timeval *b) {
+int catta_timeval_compare(const struct timeval *a, const struct timeval *b) {
     assert(a);
     assert(b);
 
@@ -46,18 +46,18 @@ int avahi_timeval_compare(const struct timeval *a, const struct timeval *b) {
     return 0;
 }
 
-AvahiUsec avahi_timeval_diff(const struct timeval *a, const struct timeval *b) {
+CattaUsec catta_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);
+    if (catta_timeval_compare(a, b) < 0)
+        return - catta_timeval_diff(b, a);
 
-    return ((AvahiUsec) a->tv_sec - b->tv_sec)*1000000 + a->tv_usec - b->tv_usec;
+    return ((CattaUsec) 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;
+struct timeval* catta_timeval_add(struct timeval *a, CattaUsec usec) {
+    CattaUsec u;
     assert(a);
 
     u = usec + a->tv_usec;
@@ -73,23 +73,23 @@ struct timeval* avahi_timeval_add(struct timeval *a, AvahiUsec usec) {
     return a;
 }
 
-AvahiUsec avahi_age(const struct timeval *a) {
+CattaUsec catta_age(const struct timeval *a) {
     struct timeval now;
 
     assert(a);
 
     gettimeofday(&now, NULL);
 
-    return avahi_timeval_diff(&now, a);
+    return catta_timeval_diff(&now, a);
 }
 
-struct timeval *avahi_elapse_time(struct timeval *tv, unsigned msec, unsigned jitter) {
+struct timeval *catta_elapse_time(struct timeval *tv, unsigned msec, unsigned jitter) {
     assert(tv);
 
     gettimeofday(tv, NULL);
 
     if (msec)
-        avahi_timeval_add(tv, (AvahiUsec) msec*1000);
+        catta_timeval_add(tv, (CattaUsec) msec*1000);
 
     if (jitter) {
         static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -115,7 +115,7 @@ struct timeval *avahi_elapse_time(struct timeval *tv, unsigned msec, unsigned ji
          * 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)));
+        catta_timeval_add(tv, (CattaUsec) (jitter*1000.0*r/(RAND_MAX+1.0)));
     }
 
     return tv;
index ab10ba06a05238ab8c505fb43939f13c9fb75387..1f6cbe50b513e7f536048f0274c0b163b48df2a5 100644 (file)
@@ -47,7 +47,7 @@
 
 
 const char *
-avahi_utf8_valid (const char *str)
+catta_utf8_valid (const char *str)
 
 {
   unsigned val = 0;
index 42ed288853e396023364c53c8efc5d92d2c906d8..43952911480defb303ec5a39f750c0d9d7ce0c9e 100644 (file)
@@ -2,32 +2,32 @@
 #define fooutf8hfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 #include <inttypes.h>
 
-#include <avahi/cdecl.h>
+#include <catta/cdecl.h>
 
-AVAHI_C_DECL_BEGIN
+CATTA_C_DECL_BEGIN
 
-const char *avahi_utf8_valid(const char *str);
+const char *catta_utf8_valid(const char *str);
 
-AVAHI_C_DECL_END
+CATTA_C_DECL_END
 
 #endif
index 8f4c43587f56a383cebc21c1b98a1ef1ed3400df..c3bb77a949b70ff38c119a60be793becd61537b7 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <assert.h>
 #include <ctype.h>
 
-#include <avahi/malloc.h>
+#include <catta/malloc.h>
 #include "util.h"
 
-void avahi_hexdump(const void* p, size_t size) {
+void catta_hexdump(const void* p, size_t size) {
     const uint8_t *c = p;
     assert(p);
 
@@ -64,7 +64,7 @@ void avahi_hexdump(const void* p, size_t size) {
     }
 }
 
-char *avahi_format_mac_address(char *r, size_t l, const uint8_t* mac, size_t size) {
+char *catta_format_mac_address(char *r, size_t l, const uint8_t* mac, size_t size) {
     char *t = r;
     unsigned i;
     static const char hex[] = "0123456789abcdef";
@@ -99,7 +99,7 @@ char *avahi_format_mac_address(char *r, size_t l, const uint8_t* mac, size_t siz
     return r;
 }
 
-char *avahi_strup(char *s) {
+char *catta_strup(char *s) {
     char *c;
     assert(s);
 
@@ -109,7 +109,7 @@ char *avahi_strup(char *s) {
     return s;
 }
 
-char *avahi_strdown(char *s) {
+char *catta_strdown(char *s) {
     char *c;
     assert(s);
 
index 787aa89c1a9b76896fd8c6aa14e904c98ce56ef7..8ffa08e1e9a568879c5726cc7028ea3fdf6a9a8f 100644 (file)
@@ -2,40 +2,40 @@
 #define fooutilhfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 #include <inttypes.h>
 
-#include <avahi/cdecl.h>
+#include <catta/cdecl.h>
 
-AVAHI_C_DECL_BEGIN
+CATTA_C_DECL_BEGIN
 
-void avahi_hexdump(const void *p, size_t size);
+void catta_hexdump(const void *p, size_t size);
 
-char *avahi_format_mac_address(char *t, size_t l, const uint8_t* mac, size_t size);
+char *catta_format_mac_address(char *t, size_t l, const uint8_t* mac, size_t size);
 
 /** Change every character in the string to upper case (ASCII), return a pointer to the string */
-char *avahi_strup(char *s);
+char *catta_strup(char *s);
 
 /** Change every character in the string to lower case (ASCII), return a pointer to the string */
-char *avahi_strdown(char *s);
+char *catta_strdown(char *s);
 
-AVAHI_C_DECL_END
+CATTA_C_DECL_END
 
 #endif
index ab4c7e415aef5c8c86b76fdcecc40680b32ad83b..2ae6d2d655dd691ef41ab0d43bdbf52f6e4bcf2e 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <stdlib.h>
 #include <netinet/in.h>
 
-#include <avahi/malloc.h>
-#include <avahi/error.h>
-#include <avahi/timeval.h>
+#include <catta/malloc.h>
+#include <catta/error.h>
+#include <catta/timeval.h>
 
 #include "internal.h"
 #include "browse.h"
 #include "socket.h"
-#include <avahi/log.h>
+#include <catta/log.h>
 #include "hashmap.h"
 #include "wide-area.h"
 #include "addr-util.h"
 
 #define CACHE_ENTRIES_MAX 500
 
-typedef struct AvahiWideAreaCacheEntry AvahiWideAreaCacheEntry;
+typedef struct CattaWideAreaCacheEntry CattaWideAreaCacheEntry;
 
-struct AvahiWideAreaCacheEntry {
-    AvahiWideAreaLookupEngine *engine;
+struct CattaWideAreaCacheEntry {
+    CattaWideAreaLookupEngine *engine;
 
-    AvahiRecord *record;
+    CattaRecord *record;
     struct timeval timestamp;
     struct timeval expiry;
 
-    AvahiTimeEvent *time_event;
+    CattaTimeEvent *time_event;
 
-    AVAHI_LLIST_FIELDS(AvahiWideAreaCacheEntry, by_key);
-    AVAHI_LLIST_FIELDS(AvahiWideAreaCacheEntry, cache);
+    CATTA_LLIST_FIELDS(CattaWideAreaCacheEntry, by_key);
+    CATTA_LLIST_FIELDS(CattaWideAreaCacheEntry, cache);
 };
 
-struct AvahiWideAreaLookup {
-    AvahiWideAreaLookupEngine *engine;
+struct CattaWideAreaLookup {
+    CattaWideAreaLookupEngine *engine;
     int dead;
 
     uint32_t id;  /* effectively just an uint16_t, but we need it as an index for a hash table */
-    AvahiTimeEvent *time_event;
+    CattaTimeEvent *time_event;
 
-    AvahiKey *key, *cname_key;
+    CattaKey *key, *cname_key;
 
     int n_send;
-    AvahiDnsPacket *packet;
+    CattaDnsPacket *packet;
 
-    AvahiWideAreaLookupCallback callback;
+    CattaWideAreaLookupCallback callback;
     void *userdata;
 
-    AvahiAddress dns_server_used;
+    CattaAddress dns_server_used;
 
-    AVAHI_LLIST_FIELDS(AvahiWideAreaLookup, lookups);
-    AVAHI_LLIST_FIELDS(AvahiWideAreaLookup, by_key);
+    CATTA_LLIST_FIELDS(CattaWideAreaLookup, lookups);
+    CATTA_LLIST_FIELDS(CattaWideAreaLookup, by_key);
 };
 
-struct AvahiWideAreaLookupEngine {
-    AvahiServer *server;
+struct CattaWideAreaLookupEngine {
+    CattaServer *server;
 
     int fd_ipv4, fd_ipv6;
-    AvahiWatch *watch_ipv4, *watch_ipv6;
+    CattaWatch *watch_ipv4, *watch_ipv6;
 
     uint16_t next_id;
 
     /* Cache */
-    AVAHI_LLIST_HEAD(AvahiWideAreaCacheEntry, cache);
-    AvahiHashmap *cache_by_key;
+    CATTA_LLIST_HEAD(CattaWideAreaCacheEntry, cache);
+    CattaHashmap *cache_by_key;
     unsigned cache_n_entries;
 
     /* Lookups */
-    AVAHI_LLIST_HEAD(AvahiWideAreaLookup, lookups);
-    AvahiHashmap *lookups_by_id;
-    AvahiHashmap *lookups_by_key;
+    CATTA_LLIST_HEAD(CattaWideAreaLookup, lookups);
+    CattaHashmap *lookups_by_id;
+    CattaHashmap *lookups_by_key;
 
     int cleanup_dead;
 
-    AvahiAddress dns_servers[AVAHI_WIDE_AREA_SERVERS_MAX];
+    CattaAddress dns_servers[CATTA_WIDE_AREA_SERVERS_MAX];
     unsigned n_dns_servers;
     unsigned current_dns_server;
 };
 
-static AvahiWideAreaLookup* find_lookup(AvahiWideAreaLookupEngine *e, uint16_t id) {
-    AvahiWideAreaLookup *l;
+static CattaWideAreaLookup* find_lookup(CattaWideAreaLookupEngine *e, uint16_t id) {
+    CattaWideAreaLookup *l;
     int i = (int) id;
 
     assert(e);
 
-    if (!(l = avahi_hashmap_lookup(e->lookups_by_id, &i)))
+    if (!(l = catta_hashmap_lookup(e->lookups_by_id, &i)))
         return NULL;
 
     assert(l->id == id);
@@ -120,8 +120,8 @@ static AvahiWideAreaLookup* find_lookup(AvahiWideAreaLookupEngine *e, uint16_t i
     return l;
 }
 
-static int send_to_dns_server(AvahiWideAreaLookup *l, AvahiDnsPacket *p) {
-    AvahiAddress *a;
+static int send_to_dns_server(CattaWideAreaLookup *l, CattaDnsPacket *p) {
+    CattaAddress *a;
 
     assert(l);
     assert(p);
@@ -134,24 +134,24 @@ static int send_to_dns_server(AvahiWideAreaLookup *l, AvahiDnsPacket *p) {
     a = &l->engine->dns_servers[l->engine->current_dns_server];
     l->dns_server_used = *a;
 
-    if (a->proto == AVAHI_PROTO_INET) {
+    if (a->proto == CATTA_PROTO_INET) {
 
         if (l->engine->fd_ipv4 < 0)
             return -1;
 
-        return avahi_send_dns_packet_ipv4(l->engine->fd_ipv4, AVAHI_IF_UNSPEC, p, NULL, &a->data.ipv4, AVAHI_DNS_PORT);
+        return catta_send_dns_packet_ipv4(l->engine->fd_ipv4, CATTA_IF_UNSPEC, p, NULL, &a->data.ipv4, CATTA_DNS_PORT);
 
     } else {
-        assert(a->proto == AVAHI_PROTO_INET6);
+        assert(a->proto == CATTA_PROTO_INET6);
 
         if (l->engine->fd_ipv6 < 0)
             return -1;
 
-        return avahi_send_dns_packet_ipv6(l->engine->fd_ipv6, AVAHI_IF_UNSPEC, p, NULL, &a->data.ipv6, AVAHI_DNS_PORT);
+        return catta_send_dns_packet_ipv6(l->engine->fd_ipv6, CATTA_IF_UNSPEC, p, NULL, &a->data.ipv6, CATTA_DNS_PORT);
     }
 }
 
-static void next_dns_server(AvahiWideAreaLookupEngine *e) {
+static void next_dns_server(CattaWideAreaLookupEngine *e) {
     assert(e);
 
     e->current_dns_server++;
@@ -160,36 +160,36 @@ static void next_dns_server(AvahiWideAreaLookupEngine *e) {
         e->current_dns_server = 0;
 }
 
-static void lookup_stop(AvahiWideAreaLookup *l) {
+static void lookup_stop(CattaWideAreaLookup *l) {
     assert(l);
 
     l->callback = NULL;
 
     if (l->time_event) {
-        avahi_time_event_free(l->time_event);
+        catta_time_event_free(l->time_event);
         l->time_event = NULL;
     }
 }
 
-static void sender_timeout_callback(AvahiTimeEvent *e, void *userdata) {
-    AvahiWideAreaLookup *l = userdata;
+static void sender_timeout_callback(CattaTimeEvent *e, void *userdata) {
+    CattaWideAreaLookup *l = userdata;
     struct timeval tv;
 
     assert(l);
 
     /* Try another DNS server after three retries */
-    if (l->n_send >= 3 && avahi_address_cmp(&l->engine->dns_servers[l->engine->current_dns_server], &l->dns_server_used) == 0) {
+    if (l->n_send >= 3 && catta_address_cmp(&l->engine->dns_servers[l->engine->current_dns_server], &l->dns_server_used) == 0) {
         next_dns_server(l->engine);
 
-        if (avahi_address_cmp(&l->engine->dns_servers[l->engine->current_dns_server], &l->dns_server_used) == 0)
+        if (catta_address_cmp(&l->engine->dns_servers[l->engine->current_dns_server], &l->dns_server_used) == 0)
             /* There is no other DNS server, fail */
             l->n_send = 1000;
     }
 
     if (l->n_send >= 6) {
-        avahi_log_warn(__FILE__": Query timed out.");
-        avahi_server_set_errno(l->engine->server, AVAHI_ERR_TIMEOUT);
-        l->callback(l->engine, AVAHI_BROWSER_FAILURE, AVAHI_LOOKUP_RESULT_WIDE_AREA, NULL, l->userdata);
+        catta_log_warn(__FILE__": Query timed out.");
+        catta_server_set_errno(l->engine->server, CATTA_ERR_TIMEOUT);
+        l->callback(l->engine, CATTA_BROWSER_FAILURE, CATTA_LOOKUP_RESULT_WIDE_AREA, NULL, l->userdata);
         lookup_stop(l);
         return;
     }
@@ -198,17 +198,17 @@ static void sender_timeout_callback(AvahiTimeEvent *e, void *userdata) {
     send_to_dns_server(l, l->packet);
     l->n_send++;
 
-    avahi_time_event_update(e, avahi_elapse_time(&tv, 1000, 0));
+    catta_time_event_update(e, catta_elapse_time(&tv, 1000, 0));
 }
 
-AvahiWideAreaLookup *avahi_wide_area_lookup_new(
-    AvahiWideAreaLookupEngine *e,
-    AvahiKey *key,
-    AvahiWideAreaLookupCallback callback,
+CattaWideAreaLookup *catta_wide_area_lookup_new(
+    CattaWideAreaLookupEngine *e,
+    CattaKey *key,
+    CattaWideAreaLookupCallback callback,
     void *userdata) {
 
     struct timeval tv;
-    AvahiWideAreaLookup *l, *t;
+    CattaWideAreaLookup *l, *t;
     uint8_t *p;
 
     assert(e);
@@ -216,11 +216,11 @@ AvahiWideAreaLookup *avahi_wide_area_lookup_new(
     assert(callback);
     assert(userdata);
 
-    l = avahi_new(AvahiWideAreaLookup, 1);
+    l = catta_new(CattaWideAreaLookup, 1);
     l->engine = e;
     l->dead = 0;
-    l->key = avahi_key_ref(key);
-    l->cname_key = avahi_key_new_cname(l->key);
+    l->key = catta_key_ref(key);
+    l->cname_key = catta_key_new_cname(l->key);
     l->callback = callback;
     l->userdata = userdata;
 
@@ -234,69 +234,69 @@ AvahiWideAreaLookup *avahi_wide_area_lookup_new(
     l->id = e->next_id++;
 
     /* We keep the packet around in case we need to repeat our query */
-    l->packet = avahi_dns_packet_new(0);
+    l->packet = catta_dns_packet_new(0);
 
-    avahi_dns_packet_set_field(l->packet, AVAHI_DNS_FIELD_ID, (uint16_t) l->id);
-    avahi_dns_packet_set_field(l->packet, AVAHI_DNS_FIELD_FLAGS, AVAHI_DNS_FLAGS(0, 0, 0, 0, 1, 0, 0, 0, 0, 0));
+    catta_dns_packet_set_field(l->packet, CATTA_DNS_FIELD_ID, (uint16_t) l->id);
+    catta_dns_packet_set_field(l->packet, CATTA_DNS_FIELD_FLAGS, CATTA_DNS_FLAGS(0, 0, 0, 0, 1, 0, 0, 0, 0, 0));
 
-    p = avahi_dns_packet_append_key(l->packet, key, 0);
+    p = catta_dns_packet_append_key(l->packet, key, 0);
     assert(p);
 
-    avahi_dns_packet_set_field(l->packet, AVAHI_DNS_FIELD_QDCOUNT, 1);
+    catta_dns_packet_set_field(l->packet, CATTA_DNS_FIELD_QDCOUNT, 1);
 
     if (send_to_dns_server(l, l->packet) < 0) {
-        avahi_log_error(__FILE__": Failed to send packet.");
-        avahi_dns_packet_free(l->packet);
-        avahi_key_unref(l->key);
+        catta_log_error(__FILE__": Failed to send packet.");
+        catta_dns_packet_free(l->packet);
+        catta_key_unref(l->key);
         if (l->cname_key)
-            avahi_key_unref(l->cname_key);
-        avahi_free(l);
+            catta_key_unref(l->cname_key);
+        catta_free(l);
         return NULL;
     }
 
     l->n_send = 1;
 
-    l->time_event = avahi_time_event_new(e->server->time_event_queue, avahi_elapse_time(&tv, 500, 0), sender_timeout_callback, l);
+    l->time_event = catta_time_event_new(e->server->time_event_queue, catta_elapse_time(&tv, 500, 0), sender_timeout_callback, l);
 
-    avahi_hashmap_insert(e->lookups_by_id, &l->id, l);
+    catta_hashmap_insert(e->lookups_by_id, &l->id, l);
 
-    t = avahi_hashmap_lookup(e->lookups_by_key, l->key);
-    AVAHI_LLIST_PREPEND(AvahiWideAreaLookup, by_key, t, l);
-    avahi_hashmap_replace(e->lookups_by_key, avahi_key_ref(l->key), t);
+    t = catta_hashmap_lookup(e->lookups_by_key, l->key);
+    CATTA_LLIST_PREPEND(CattaWideAreaLookup, by_key, t, l);
+    catta_hashmap_replace(e->lookups_by_key, catta_key_ref(l->key), t);
 
-    AVAHI_LLIST_PREPEND(AvahiWideAreaLookup, lookups, e->lookups, l);
+    CATTA_LLIST_PREPEND(CattaWideAreaLookup, lookups, e->lookups, l);
 
     return l;
 }
 
-static void lookup_destroy(AvahiWideAreaLookup *l) {
-    AvahiWideAreaLookup *t;
+static void lookup_destroy(CattaWideAreaLookup *l) {
+    CattaWideAreaLookup *t;
     assert(l);
 
     lookup_stop(l);
 
-    t = avahi_hashmap_lookup(l->engine->lookups_by_key, l->key);
-    AVAHI_LLIST_REMOVE(AvahiWideAreaLookup, by_key, t, l);
+    t = catta_hashmap_lookup(l->engine->lookups_by_key, l->key);
+    CATTA_LLIST_REMOVE(CattaWideAreaLookup, by_key, t, l);
     if (t)
-        avahi_hashmap_replace(l->engine->lookups_by_key, avahi_key_ref(l->key), t);
+        catta_hashmap_replace(l->engine->lookups_by_key, catta_key_ref(l->key), t);
     else
-        avahi_hashmap_remove(l->engine->lookups_by_key, l->key);
+        catta_hashmap_remove(l->engine->lookups_by_key, l->key);
 
-    AVAHI_LLIST_REMOVE(AvahiWideAreaLookup, lookups, l->engine->lookups, l);
+    CATTA_LLIST_REMOVE(CattaWideAreaLookup, lookups, l->engine->lookups, l);
 
-    avahi_hashmap_remove(l->engine->lookups_by_id, &l->id);
-    avahi_dns_packet_free(l->packet);
+    catta_hashmap_remove(l->engine->lookups_by_id, &l->id);
+    catta_dns_packet_free(l->packet);
 
     if (l->key)
-        avahi_key_unref(l->key);
+        catta_key_unref(l->key);
 
     if (l->cname_key)
-        avahi_key_unref(l->cname_key);
+        catta_key_unref(l->cname_key);
 
-    avahi_free(l);
+    catta_free(l);
 }
 
-void avahi_wide_area_lookup_free(AvahiWideAreaLookup *l) {
+void catta_wide_area_lookup_free(CattaWideAreaLookup *l) {
     assert(l);
 
     if (l->dead)
@@ -307,8 +307,8 @@ void avahi_wide_area_lookup_free(AvahiWideAreaLookup *l) {
     lookup_stop(l);
 }
 
-void avahi_wide_area_cleanup(AvahiWideAreaLookupEngine *e) {
-    AvahiWideAreaLookup *l, *n;
+void catta_wide_area_cleanup(CattaWideAreaLookupEngine *e) {
+    CattaWideAreaLookup *l, *n;
     assert(e);
 
     while (e->cleanup_dead) {
@@ -323,30 +323,30 @@ void avahi_wide_area_cleanup(AvahiWideAreaLookupEngine *e) {
     }
 }
 
-static void cache_entry_free(AvahiWideAreaCacheEntry *c) {
-    AvahiWideAreaCacheEntry *t;
+static void cache_entry_free(CattaWideAreaCacheEntry *c) {
+    CattaWideAreaCacheEntry *t;
     assert(c);
 
     if (c->time_event)
-        avahi_time_event_free(c->time_event);
+        catta_time_event_free(c->time_event);
 
-    AVAHI_LLIST_REMOVE(AvahiWideAreaCacheEntry, cache, c->engine->cache, c);
+    CATTA_LLIST_REMOVE(CattaWideAreaCacheEntry, cache, c->engine->cache, c);
 
-    t = avahi_hashmap_lookup(c->engine->cache_by_key, c->record->key);
-    AVAHI_LLIST_REMOVE(AvahiWideAreaCacheEntry, by_key, t, c);
+    t = catta_hashmap_lookup(c->engine->cache_by_key, c->record->key);
+    CATTA_LLIST_REMOVE(CattaWideAreaCacheEntry, by_key, t, c);
     if (t)
-        avahi_hashmap_replace(c->engine->cache_by_key, avahi_key_ref(c->record->key), t);
+        catta_hashmap_replace(c->engine->cache_by_key, catta_key_ref(c->record->key), t);
     else
-        avahi_hashmap_remove(c->engine->cache_by_key, c->record->key);
+        catta_hashmap_remove(c->engine->cache_by_key, c->record->key);
 
     c->engine->cache_n_entries --;
 
-    avahi_record_unref(c->record);
-    avahi_free(c);
+    catta_record_unref(c->record);
+    catta_free(c);
 }
 
-static void expiry_event(AvahiTimeEvent *te, void *userdata) {
-    AvahiWideAreaCacheEntry *e = userdata;
+static void expiry_event(CattaTimeEvent *te, void *userdata) {
+    CattaWideAreaCacheEntry *e = userdata;
 
     assert(te);
     assert(e);
@@ -354,53 +354,53 @@ static void expiry_event(AvahiTimeEvent *te, void *userdata) {
     cache_entry_free(e);
 }
 
-static AvahiWideAreaCacheEntry* find_record_in_cache(AvahiWideAreaLookupEngine *e, AvahiRecord *r) {
-    AvahiWideAreaCacheEntry *c;
+static CattaWideAreaCacheEntry* find_record_in_cache(CattaWideAreaLookupEngine *e, CattaRecord *r) {
+    CattaWideAreaCacheEntry *c;
 
     assert(e);
     assert(r);
 
-    for (c = avahi_hashmap_lookup(e->cache_by_key, r->key); c; c = c->by_key_next)
-        if (avahi_record_equal_no_ttl(r, c->record))
+    for (c = catta_hashmap_lookup(e->cache_by_key, r->key); c; c = c->by_key_next)
+        if (catta_record_equal_no_ttl(r, c->record))
             return c;
 
     return NULL;
 }
 
-static void run_callbacks(AvahiWideAreaLookupEngine *e, AvahiRecord *r) {
-    AvahiWideAreaLookup *l;
+static void run_callbacks(CattaWideAreaLookupEngine *e, CattaRecord *r) {
+    CattaWideAreaLookup *l;
 
     assert(e);
     assert(r);
 
-    for (l = avahi_hashmap_lookup(e->lookups_by_key, r->key); l; l = l->by_key_next) {
+    for (l = catta_hashmap_lookup(e->lookups_by_key, r->key); l; l = l->by_key_next) {
         if (l->dead || !l->callback)
             continue;
 
-        l->callback(e, AVAHI_BROWSER_NEW, AVAHI_LOOKUP_RESULT_WIDE_AREA, r, l->userdata);
+        l->callback(e, CATTA_BROWSER_NEW, CATTA_LOOKUP_RESULT_WIDE_AREA, r, l->userdata);
     }
 
-    if (r->key->clazz == AVAHI_DNS_CLASS_IN && r->key->type == AVAHI_DNS_TYPE_CNAME) {
+    if (r->key->clazz == CATTA_DNS_CLASS_IN && r->key->type == CATTA_DNS_TYPE_CNAME) {
         /* It's a CNAME record, so we have to scan the all lookups to see if one matches */
 
         for (l = e->lookups; l; l = l->lookups_next) {
-            AvahiKey *key;
+            CattaKey *key;
 
             if (l->dead || !l->callback)
                 continue;
 
-            if ((key = avahi_key_new_cname(l->key))) {
-                if (avahi_key_equal(r->key, key))
-                    l->callback(e, AVAHI_BROWSER_NEW, AVAHI_LOOKUP_RESULT_WIDE_AREA, r, l->userdata);
+            if ((key = catta_key_new_cname(l->key))) {
+                if (catta_key_equal(r->key, key))
+                    l->callback(e, CATTA_BROWSER_NEW, CATTA_LOOKUP_RESULT_WIDE_AREA, r, l->userdata);
 
-                avahi_key_unref(key);
+                catta_key_unref(key);
             }
         }
     }
 }
 
-static void add_to_cache(AvahiWideAreaLookupEngine *e, AvahiRecord *r) {
-    AvahiWideAreaCacheEntry *c;
+static void add_to_cache(CattaWideAreaLookupEngine *e, CattaRecord *r) {
+    CattaWideAreaCacheEntry *c;
     int is_new;
 
     assert(e);
@@ -410,9 +410,9 @@ static void add_to_cache(AvahiWideAreaLookupEngine *e, AvahiRecord *r) {
         is_new = 0;
 
         /* Update the existing entry */
-        avahi_record_unref(c->record);
+        catta_record_unref(c->record);
     } else {
-        AvahiWideAreaCacheEntry *t;
+        CattaWideAreaCacheEntry *t;
 
         is_new = 1;
 
@@ -421,30 +421,30 @@ static void add_to_cache(AvahiWideAreaLookupEngine *e, AvahiRecord *r) {
             /* Eventually we should improve the caching algorithm here */
             goto finish;
 
-        c = avahi_new(AvahiWideAreaCacheEntry, 1);
+        c = catta_new(CattaWideAreaCacheEntry, 1);
         c->engine = e;
         c->time_event = NULL;
 
-        AVAHI_LLIST_PREPEND(AvahiWideAreaCacheEntry, cache, e->cache, c);
+        CATTA_LLIST_PREPEND(CattaWideAreaCacheEntry, cache, e->cache, c);
 
         /* Add the new entry to the cache entry hash table */
-        t = avahi_hashmap_lookup(e->cache_by_key, r->key);
-        AVAHI_LLIST_PREPEND(AvahiWideAreaCacheEntry, by_key, t, c);
-        avahi_hashmap_replace(e->cache_by_key, avahi_key_ref(r->key), t);
+        t = catta_hashmap_lookup(e->cache_by_key, r->key);
+        CATTA_LLIST_PREPEND(CattaWideAreaCacheEntry, by_key, t, c);
+        catta_hashmap_replace(e->cache_by_key, catta_key_ref(r->key), t);
 
         e->cache_n_entries ++;
     }
 
-    c->record = avahi_record_ref(r);
+    c->record = catta_record_ref(r);
 
     gettimeofday(&c->timestamp, NULL);
     c->expiry = c->timestamp;
-    avahi_timeval_add(&c->expiry, r->ttl * 1000000);
+    catta_timeval_add(&c->expiry, r->ttl * 1000000);
 
     if (c->time_event)
-        avahi_time_event_update(c->time_event, &c->expiry);
+        catta_time_event_update(c->time_event, &c->expiry);
     else
-        c->time_event = avahi_time_event_new(e->server->time_event_queue, &c->expiry, expiry_event, c);
+        c->time_event = catta_time_event_new(e->server->time_event_queue, &c->expiry, expiry_event, c);
 
 finish:
 
@@ -454,22 +454,22 @@ finish:
 
 static int map_dns_error(uint16_t error) {
     static const int table[16] = {
-        AVAHI_OK,
-        AVAHI_ERR_DNS_FORMERR,
-        AVAHI_ERR_DNS_SERVFAIL,
-        AVAHI_ERR_DNS_NXDOMAIN,
-        AVAHI_ERR_DNS_NOTIMP,
-        AVAHI_ERR_DNS_REFUSED,
-        AVAHI_ERR_DNS_YXDOMAIN,
-        AVAHI_ERR_DNS_YXRRSET,
-        AVAHI_ERR_DNS_NXRRSET,
-        AVAHI_ERR_DNS_NOTAUTH,
-        AVAHI_ERR_DNS_NOTZONE,
-        AVAHI_ERR_INVALID_DNS_ERROR,
-        AVAHI_ERR_INVALID_DNS_ERROR,
-        AVAHI_ERR_INVALID_DNS_ERROR,
-        AVAHI_ERR_INVALID_DNS_ERROR,
-        AVAHI_ERR_INVALID_DNS_ERROR
+        CATTA_OK,
+        CATTA_ERR_DNS_FORMERR,
+        CATTA_ERR_DNS_SERVFAIL,
+        CATTA_ERR_DNS_NXDOMAIN,
+        CATTA_ERR_DNS_NOTIMP,
+        CATTA_ERR_DNS_REFUSED,
+        CATTA_ERR_DNS_YXDOMAIN,
+        CATTA_ERR_DNS_YXRRSET,
+        CATTA_ERR_DNS_NXRRSET,
+        CATTA_ERR_DNS_NOTAUTH,
+        CATTA_ERR_DNS_NOTZONE,
+        CATTA_ERR_INVALID_DNS_ERROR,
+        CATTA_ERR_INVALID_DNS_ERROR,
+        CATTA_ERR_INVALID_DNS_ERROR,
+        CATTA_ERR_INVALID_DNS_ERROR,
+        CATTA_ERR_INVALID_DNS_ERROR
     };
 
     assert(error <= 15);
@@ -477,111 +477,111 @@ static int map_dns_error(uint16_t error) {
     return table[error];
 }
 
-static void handle_packet(AvahiWideAreaLookupEngine *e, AvahiDnsPacket *p) {
-    AvahiWideAreaLookup *l = NULL;
+static void handle_packet(CattaWideAreaLookupEngine *e, CattaDnsPacket *p) {
+    CattaWideAreaLookup *l = NULL;
     int i, r;
 
-    AvahiBrowserEvent final_event = AVAHI_BROWSER_ALL_FOR_NOW;
+    CattaBrowserEvent final_event = CATTA_BROWSER_ALL_FOR_NOW;
 
     assert(e);
     assert(p);
 
     /* Some superficial validity tests */
-    if (avahi_dns_packet_check_valid(p) < 0 || avahi_dns_packet_is_query(p)) {
-        avahi_log_warn(__FILE__": Ignoring invalid response for wide area datagram.");
+    if (catta_dns_packet_check_valid(p) < 0 || catta_dns_packet_is_query(p)) {
+        catta_log_warn(__FILE__": Ignoring invalid response for wide area datagram.");
         goto finish;
     }
 
     /* Look for the lookup that issued this query */
-    if (!(l = find_lookup(e, avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ID))) || l->dead)
+    if (!(l = find_lookup(e, catta_dns_packet_get_field(p, CATTA_DNS_FIELD_ID))) || l->dead)
         goto finish;
 
     /* Check whether this a packet indicating a failure */
-    if ((r = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_FLAGS) & 15) != 0 ||
-        avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ANCOUNT) == 0) {
+    if ((r = catta_dns_packet_get_field(p, CATTA_DNS_FIELD_FLAGS) & 15) != 0 ||
+        catta_dns_packet_get_field(p, CATTA_DNS_FIELD_ANCOUNT) == 0) {
 
-        avahi_server_set_errno(e->server, r == 0 ? AVAHI_ERR_NOT_FOUND : map_dns_error(r));
+        catta_server_set_errno(e->server, r == 0 ? CATTA_ERR_NOT_FOUND : map_dns_error(r));
         /* Tell the user about the failure */
-        final_event = AVAHI_BROWSER_FAILURE;
+        final_event = CATTA_BROWSER_FAILURE;
 
         /* We go on here, since some of the records contained in the
            reply might be interesting in some way */
     }
 
     /* Skip over the question */
-    for (i = (int) avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_QDCOUNT); i > 0; i--) {
-        AvahiKey *k;
+    for (i = (int) catta_dns_packet_get_field(p, CATTA_DNS_FIELD_QDCOUNT); i > 0; i--) {
+        CattaKey *k;
 
-        if (!(k = avahi_dns_packet_consume_key(p, NULL))) {
-            avahi_log_warn(__FILE__": Wide area response packet too short or invalid while reading question key. (Maybe a UTF-8 problem?)");
-            avahi_server_set_errno(e->server, AVAHI_ERR_INVALID_PACKET);
-            final_event = AVAHI_BROWSER_FAILURE;
+        if (!(k = catta_dns_packet_consume_key(p, NULL))) {
+            catta_log_warn(__FILE__": Wide area response packet too short or invalid while reading question key. (Maybe a UTF-8 problem?)");
+            catta_server_set_errno(e->server, CATTA_ERR_INVALID_PACKET);
+            final_event = CATTA_BROWSER_FAILURE;
             goto finish;
         }
 
-        avahi_key_unref(k);
+        catta_key_unref(k);
     }
 
     /* Process responses */
-    for (i = (int) avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ANCOUNT) +
-             (int) avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_NSCOUNT) +
-             (int) avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ARCOUNT); i > 0; i--) {
+    for (i = (int) catta_dns_packet_get_field(p, CATTA_DNS_FIELD_ANCOUNT) +
+             (int) catta_dns_packet_get_field(p, CATTA_DNS_FIELD_NSCOUNT) +
+             (int) catta_dns_packet_get_field(p, CATTA_DNS_FIELD_ARCOUNT); i > 0; i--) {
 
-        AvahiRecord *rr;
+        CattaRecord *rr;
 
-        if (!(rr = avahi_dns_packet_consume_record(p, NULL))) {
-            avahi_log_warn(__FILE__": Wide area response packet too short or invalid while reading response record. (Maybe a UTF-8 problem?)");
-            avahi_server_set_errno(e->server, AVAHI_ERR_INVALID_PACKET);
-            final_event = AVAHI_BROWSER_FAILURE;
+        if (!(rr = catta_dns_packet_consume_record(p, NULL))) {
+            catta_log_warn(__FILE__": Wide area response packet too short or invalid while reading response record. (Maybe a UTF-8 problem?)");
+            catta_server_set_errno(e->server, CATTA_ERR_INVALID_PACKET);
+            final_event = CATTA_BROWSER_FAILURE;
             goto finish;
         }
 
         add_to_cache(e, rr);
-        avahi_record_unref(rr);
+        catta_record_unref(rr);
     }
 
 finish:
 
     if (l && !l->dead) {
         if (l->callback)
-            l->callback(e, final_event, AVAHI_LOOKUP_RESULT_WIDE_AREA, NULL, l->userdata);
+            l->callback(e, final_event, CATTA_LOOKUP_RESULT_WIDE_AREA, NULL, l->userdata);
 
         lookup_stop(l);
     }
 }
 
-static void socket_event(AVAHI_GCC_UNUSED AvahiWatch *w, int fd, AVAHI_GCC_UNUSED AvahiWatchEvent events, void *userdata) {
-    AvahiWideAreaLookupEngine *e = userdata;
-    AvahiDnsPacket *p = NULL;
+static void socket_event(CATTA_GCC_UNUSED CattaWatch *w, int fd, CATTA_GCC_UNUSED CattaWatchEvent events, void *userdata) {
+    CattaWideAreaLookupEngine *e = userdata;
+    CattaDnsPacket *p = NULL;
 
     if (fd == e->fd_ipv4)
-        p = avahi_recv_dns_packet_ipv4(e->fd_ipv4, NULL, NULL, NULL, NULL, NULL);
+        p = catta_recv_dns_packet_ipv4(e->fd_ipv4, NULL, NULL, NULL, NULL, NULL);
     else {
         assert(fd == e->fd_ipv6);
-        p = avahi_recv_dns_packet_ipv6(e->fd_ipv6, NULL, NULL, NULL, NULL, NULL);
+        p = catta_recv_dns_packet_ipv6(e->fd_ipv6, NULL, NULL, NULL, NULL, NULL);
     }
 
     if (p) {
         handle_packet(e, p);
-        avahi_dns_packet_free(p);
+        catta_dns_packet_free(p);
     }
 }
 
-AvahiWideAreaLookupEngine *avahi_wide_area_engine_new(AvahiServer *s) {
-    AvahiWideAreaLookupEngine *e;
+CattaWideAreaLookupEngine *catta_wide_area_engine_new(CattaServer *s) {
+    CattaWideAreaLookupEngine *e;
 
     assert(s);
 
-    e = avahi_new(AvahiWideAreaLookupEngine, 1);
+    e = catta_new(CattaWideAreaLookupEngine, 1);
     e->server = s;
     e->cleanup_dead = 0;
 
     /* Create sockets */
-    e->fd_ipv4 = s->config.use_ipv4 ? avahi_open_unicast_socket_ipv4() : -1;
-    e->fd_ipv6 = s->config.use_ipv6 ? avahi_open_unicast_socket_ipv6() : -1;
+    e->fd_ipv4 = s->config.use_ipv4 ? catta_open_unicast_socket_ipv4() : -1;
+    e->fd_ipv6 = s->config.use_ipv6 ? catta_open_unicast_socket_ipv6() : -1;
 
     if (e->fd_ipv4 < 0 && e->fd_ipv6 < 0) {
-        avahi_log_error(__FILE__": Failed to create wide area sockets: %s", strerror(errno));
+        catta_log_error(__FILE__": Failed to create wide area sockets: %s", strerror(errno));
 
         if (e->fd_ipv6 >= 0)
             close(e->fd_ipv6);
@@ -589,7 +589,7 @@ AvahiWideAreaLookupEngine *avahi_wide_area_engine_new(AvahiServer *s) {
         if (e->fd_ipv4 >= 0)
             close(e->fd_ipv4);
 
-        avahi_free(e);
+        catta_free(e);
         return NULL;
     }
 
@@ -598,37 +598,37 @@ AvahiWideAreaLookupEngine *avahi_wide_area_engine_new(AvahiServer *s) {
     e->watch_ipv4 = e->watch_ipv6 = NULL;
 
     if (e->fd_ipv4 >= 0)
-        e->watch_ipv4 = s->poll_api->watch_new(e->server->poll_api, e->fd_ipv4, AVAHI_WATCH_IN, socket_event, e);
+        e->watch_ipv4 = s->poll_api->watch_new(e->server->poll_api, e->fd_ipv4, CATTA_WATCH_IN, socket_event, e);
     if (e->fd_ipv6 >= 0)
-        e->watch_ipv6 = s->poll_api->watch_new(e->server->poll_api, e->fd_ipv6, AVAHI_WATCH_IN, socket_event, e);
+        e->watch_ipv6 = s->poll_api->watch_new(e->server->poll_api, e->fd_ipv6, CATTA_WATCH_IN, socket_event, e);
 
     e->n_dns_servers = e->current_dns_server = 0;
     e->next_id = (uint16_t) rand();
 
     /* Initialize cache */
-    AVAHI_LLIST_HEAD_INIT(AvahiWideAreaCacheEntry, e->cache);
-    e->cache_by_key = avahi_hashmap_new((AvahiHashFunc) avahi_key_hash, (AvahiEqualFunc) avahi_key_equal, (AvahiFreeFunc) avahi_key_unref, NULL);
+    CATTA_LLIST_HEAD_INIT(CattaWideAreaCacheEntry, e->cache);
+    e->cache_by_key = catta_hashmap_new((CattaHashFunc) catta_key_hash, (CattaEqualFunc) catta_key_equal, (CattaFreeFunc) catta_key_unref, NULL);
     e->cache_n_entries = 0;
 
     /* Initialize lookup list */
-    e->lookups_by_id = avahi_hashmap_new((AvahiHashFunc) avahi_int_hash, (AvahiEqualFunc) avahi_int_equal, NULL, NULL);
-    e->lookups_by_key = avahi_hashmap_new((AvahiHashFunc) avahi_key_hash, (AvahiEqualFunc) avahi_key_equal, (AvahiFreeFunc) avahi_key_unref, NULL);
-    AVAHI_LLIST_HEAD_INIT(AvahiWideAreaLookup, e->lookups);
+    e->lookups_by_id = catta_hashmap_new((CattaHashFunc) catta_int_hash, (CattaEqualFunc) catta_int_equal, NULL, NULL);
+    e->lookups_by_key = catta_hashmap_new((CattaHashFunc) catta_key_hash, (CattaEqualFunc) catta_key_equal, (CattaFreeFunc) catta_key_unref, NULL);
+    CATTA_LLIST_HEAD_INIT(CattaWideAreaLookup, e->lookups);
 
     return e;
 }
 
-void avahi_wide_area_engine_free(AvahiWideAreaLookupEngine *e) {
+void catta_wide_area_engine_free(CattaWideAreaLookupEngine *e) {
     assert(e);
 
-    avahi_wide_area_clear_cache(e);
+    catta_wide_area_clear_cache(e);
 
     while (e->lookups)
         lookup_destroy(e->lookups);
 
-    avahi_hashmap_free(e->cache_by_key);
-    avahi_hashmap_free(e->lookups_by_id);
-    avahi_hashmap_free(e->lookups_by_key);
+    catta_hashmap_free(e->cache_by_key);
+    catta_hashmap_free(e->lookups_by_id);
+    catta_hashmap_free(e->lookups_by_key);
 
     if (e->watch_ipv4)
         e->server->poll_api->watch_free(e->watch_ipv4);
@@ -642,10 +642,10 @@ void avahi_wide_area_engine_free(AvahiWideAreaLookupEngine *e) {
     if (e->fd_ipv4 >= 0)
         close(e->fd_ipv4);
 
-    avahi_free(e);
+    catta_free(e);
 }
 
-void avahi_wide_area_clear_cache(AvahiWideAreaLookupEngine *e) {
+void catta_wide_area_clear_cache(CattaWideAreaLookupEngine *e) {
     assert(e);
 
     while (e->cache)
@@ -654,12 +654,12 @@ void avahi_wide_area_clear_cache(AvahiWideAreaLookupEngine *e) {
     assert(e->cache_n_entries == 0);
 }
 
-void avahi_wide_area_set_servers(AvahiWideAreaLookupEngine *e, const AvahiAddress *a, unsigned n) {
+void catta_wide_area_set_servers(CattaWideAreaLookupEngine *e, const CattaAddress *a, unsigned n) {
     assert(e);
 
     if (a) {
-        for (e->n_dns_servers = 0; n > 0 && e->n_dns_servers < AVAHI_WIDE_AREA_SERVERS_MAX; a++, n--)
-            if ((a->proto == AVAHI_PROTO_INET && e->fd_ipv4 >= 0) || (a->proto == AVAHI_PROTO_INET6 && e->fd_ipv6 >= 0))
+        for (e->n_dns_servers = 0; n > 0 && e->n_dns_servers < CATTA_WIDE_AREA_SERVERS_MAX; a++, n--)
+            if ((a->proto == CATTA_PROTO_INET && e->fd_ipv4 >= 0) || (a->proto == CATTA_PROTO_INET6 && e->fd_ipv6 >= 0))
                 e->dns_servers[e->n_dns_servers++] = *a;
     } else {
         assert(n == 0);
@@ -668,11 +668,11 @@ void avahi_wide_area_set_servers(AvahiWideAreaLookupEngine *e, const AvahiAddres
 
     e->current_dns_server = 0;
 
-    avahi_wide_area_clear_cache(e);
+    catta_wide_area_clear_cache(e);
 }
 
-void avahi_wide_area_cache_dump(AvahiWideAreaLookupEngine *e, AvahiDumpCallback callback, void* userdata) {
-    AvahiWideAreaCacheEntry *c;
+void catta_wide_area_cache_dump(CattaWideAreaLookupEngine *e, CattaDumpCallback callback, void* userdata) {
+    CattaWideAreaCacheEntry *c;
 
     assert(e);
     assert(callback);
@@ -680,40 +680,40 @@ void avahi_wide_area_cache_dump(AvahiWideAreaLookupEngine *e, AvahiDumpCallback
     callback(";; WIDE AREA CACHE ;;; ", userdata);
 
     for (c = e->cache; c; c = c->cache_next) {
-        char *t = avahi_record_to_string(c->record);
+        char *t = catta_record_to_string(c->record);
         callback(t, userdata);
-        avahi_free(t);
+        catta_free(t);
     }
 }
 
-unsigned avahi_wide_area_scan_cache(AvahiWideAreaLookupEngine *e, AvahiKey *key, AvahiWideAreaLookupCallback callback, void *userdata) {
-    AvahiWideAreaCacheEntry *c;
-    AvahiKey *cname_key;
+unsigned catta_wide_area_scan_cache(CattaWideAreaLookupEngine *e, CattaKey *key, CattaWideAreaLookupCallback callback, void *userdata) {
+    CattaWideAreaCacheEntry *c;
+    CattaKey *cname_key;
     unsigned n = 0;
 
     assert(e);
     assert(key);
     assert(callback);
 
-    for (c = avahi_hashmap_lookup(e->cache_by_key, key); c; c = c->by_key_next) {
-        callback(e, AVAHI_BROWSER_NEW, AVAHI_LOOKUP_RESULT_WIDE_AREA|AVAHI_LOOKUP_RESULT_CACHED, c->record, userdata);
+    for (c = catta_hashmap_lookup(e->cache_by_key, key); c; c = c->by_key_next) {
+        callback(e, CATTA_BROWSER_NEW, CATTA_LOOKUP_RESULT_WIDE_AREA|CATTA_LOOKUP_RESULT_CACHED, c->record, userdata);
         n++;
     }
 
-    if ((cname_key = avahi_key_new_cname(key))) {
+    if ((cname_key = catta_key_new_cname(key))) {
 
-        for (c = avahi_hashmap_lookup(e->cache_by_key, cname_key); c; c = c->by_key_next) {
-            callback(e, AVAHI_BROWSER_NEW, AVAHI_LOOKUP_RESULT_WIDE_AREA|AVAHI_LOOKUP_RESULT_CACHED, c->record, userdata);
+        for (c = catta_hashmap_lookup(e->cache_by_key, cname_key); c; c = c->by_key_next) {
+            callback(e, CATTA_BROWSER_NEW, CATTA_LOOKUP_RESULT_WIDE_AREA|CATTA_LOOKUP_RESULT_CACHED, c->record, userdata);
             n++;
         }
 
-        avahi_key_unref(cname_key);
+        catta_key_unref(cname_key);
     }
 
     return n;
 }
 
-int avahi_wide_area_has_servers(AvahiWideAreaLookupEngine *e) {
+int catta_wide_area_has_servers(CattaWideAreaLookupEngine *e) {
     assert(e);
 
     return e->n_dns_servers > 0;
index 8bd01db6793beb29cb4bfd01562ded0fdbb9ddca..9d190c73f069ac3a947c5ca0bf5ba273e70dddd7 100644 (file)
@@ -2,49 +2,49 @@
 #define foowideareahfoo
 
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
-#include <avahi/lookup.h>
+#include <catta/lookup.h>
 #include "browse.h"
 
-typedef struct AvahiWideAreaLookupEngine AvahiWideAreaLookupEngine;
-typedef struct AvahiWideAreaLookup AvahiWideAreaLookup;
+typedef struct CattaWideAreaLookupEngine CattaWideAreaLookupEngine;
+typedef struct CattaWideAreaLookup CattaWideAreaLookup;
 
-typedef void (*AvahiWideAreaLookupCallback)(
-    AvahiWideAreaLookupEngine *e,
-    AvahiBrowserEvent event,
-    AvahiLookupResultFlags flags,
-    AvahiRecord *r,
+typedef void (*CattaWideAreaLookupCallback)(
+    CattaWideAreaLookupEngine *e,
+    CattaBrowserEvent event,
+    CattaLookupResultFlags flags,
+    CattaRecord *r,
     void *userdata);
 
-AvahiWideAreaLookupEngine *avahi_wide_area_engine_new(AvahiServer *s);
-void avahi_wide_area_engine_free(AvahiWideAreaLookupEngine *e);
+CattaWideAreaLookupEngine *catta_wide_area_engine_new(CattaServer *s);
+void catta_wide_area_engine_free(CattaWideAreaLookupEngine *e);
 
-unsigned avahi_wide_area_scan_cache(AvahiWideAreaLookupEngine *e, AvahiKey *key, AvahiWideAreaLookupCallback callback, void *userdata);
-void avahi_wide_area_cache_dump(AvahiWideAreaLookupEngine *e, AvahiDumpCallback callback, void* userdata);
-void avahi_wide_area_set_servers(AvahiWideAreaLookupEngine *e, const AvahiAddress *a, unsigned n);
-void avahi_wide_area_clear_cache(AvahiWideAreaLookupEngine *e);
-void avahi_wide_area_cleanup(AvahiWideAreaLookupEngine *e);
-int avahi_wide_area_has_servers(AvahiWideAreaLookupEngine *e);
+unsigned catta_wide_area_scan_cache(CattaWideAreaLookupEngine *e, CattaKey *key, CattaWideAreaLookupCallback callback, void *userdata);
+void catta_wide_area_cache_dump(CattaWideAreaLookupEngine *e, CattaDumpCallback callback, void* userdata);
+void catta_wide_area_set_servers(CattaWideAreaLookupEngine *e, const CattaAddress *a, unsigned n);
+void catta_wide_area_clear_cache(CattaWideAreaLookupEngine *e);
+void catta_wide_area_cleanup(CattaWideAreaLookupEngine *e);
+int catta_wide_area_has_servers(CattaWideAreaLookupEngine *e);
 
-AvahiWideAreaLookup *avahi_wide_area_lookup_new(AvahiWideAreaLookupEngine *e, AvahiKey *key, AvahiWideAreaLookupCallback callback, void *userdata);
-void avahi_wide_area_lookup_free(AvahiWideAreaLookup *q);
+CattaWideAreaLookup *catta_wide_area_lookup_new(CattaWideAreaLookupEngine *e, CattaKey *key, CattaWideAreaLookupCallback callback, void *userdata);
+void catta_wide_area_lookup_free(CattaWideAreaLookup *q);
 
 
 
index 2aab96f236044873b80a23f90e01dcace6907bca..dd6ab21034ae7e3ba4a04abd9660d9933c9bb6a0 100644 (file)
@@ -5,8 +5,8 @@ timeval-test
 utf8-test
 watch-test
 watch-test-thread
-avahi-reflector
-avahi-test
+catta-reflector
+catta-test
 conformance-test
 dns-spin-test
 dns-test
index 9e05868b98b16ac89f2d4b28d2176c8eb11cf50c..8cd35c3b5db552db7019e5ce4f1186eb05cc965e 100644 (file)
@@ -1,22 +1,22 @@
-# This file is part of avahi.
+# This file is part of catta.
 #
-# avahi is free software; you can redistribute it and/or modify it
+# catta 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
+# catta 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
+# License along with catta; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 # USA.
 
 AM_CFLAGS=-I$(top_srcdir)/include
-AM_LDADD=$(top_srcdir)/src/libavahi.la
+AM_LDADD=$(top_srcdir)/src/libcatta.la
 
 # This cool debug trap works on i386/gcc only
 AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")'
@@ -31,9 +31,9 @@ noinst_PROGRAMS = \
        watch-test-thread \
        utf8-test \
        prioq-test \
-       avahi-test \
+       catta-test \
        conformance-test \
-       avahi-reflector \
+       catta-reflector \
        dns-test \
        dns-spin-test \
        timeeventq-test \
@@ -80,9 +80,9 @@ prioq_test_SOURCES = prioq-test.c
 prioq_test_CFLAGS = $(AM_CFLAGS)
 prioq_test_LDADD = $(AM_LDADD)
 
-avahi_test_SOURCES = avahi-test.c
-avahi_test_CFLAGS = $(AM_CFLAGS)
-avahi_test_LDADD = $(AM_LDADD)
+catta_test_SOURCES = catta-test.c
+catta_test_CFLAGS = $(AM_CFLAGS)
+catta_test_LDADD = $(AM_LDADD)
 
 update_test_SOURCES = update-test.c
 update_test_CFLAGS = $(AM_CFLAGS)
@@ -96,9 +96,9 @@ conformance_test_SOURCES = conformance-test.c
 conformance_test_CFLAGS = $(AM_CFLAGS)
 conformance_test_LDADD = $(AM_LDADD)
 
-avahi_reflector_SOURCES = avahi-reflector.c
-avahi_reflector_CFLAGS = $(AM_CFLAGS)
-avahi_reflector_LDADD = $(AM_LDADD)
+catta_reflector_SOURCES = catta-reflector.c
+catta_reflector_CFLAGS = $(AM_CFLAGS)
+catta_reflector_LDADD = $(AM_LDADD)
 
 dns_test_SOURCES = dns-test.c
 dns_test_CFLAGS = $(AM_CFLAGS)
@@ -116,8 +116,8 @@ hashmap_test_SOURCES = hashmap-test.c
 hashmap_test_CFLAGS = $(AM_CFLAGS)
 hashmap_test_LDADD = $(AM_LDADD)
 
-valgrind: avahi-test
-       libtool --mode=execute valgrind ./avahi-test
+valgrind: catta-test
+       libtool --mode=execute valgrind ./catta-test
 
-gdb: avahi-test
-       libtool --mode=execute gdb ./avahi-test
+gdb: catta-test
+       libtool --mode=execute gdb ./catta-test
index 96361896b7cbd5a0e5fb4bbec5f8faf1c8339cfe..448b18271b53908f235e295edeea318d1311b3e3 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 #include <stdio.h>
 
-#include <avahi/alternative.h>
-#include <avahi/malloc.h>
-#include <avahi/domain.h>
+#include <catta/alternative.h>
+#include <catta/malloc.h>
+#include <catta/domain.h>
 
-int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
+int main(CATTA_GCC_UNUSED int argc, CATTA_GCC_UNUSED char *argv[]) {
     const char* const test_strings[] = {
         "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
         "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXüüüüüüü",
@@ -71,20 +71,20 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
             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);
+                n = i == 0 ? catta_strdup(test_strings[k]) : (j ? catta_alternative_service_name(r) : catta_alternative_host_name(r));
+                catta_free(r);
                 r = n;
 
                 if (j)
-                    assert(avahi_is_valid_service_name(n));
+                    assert(catta_is_valid_service_name(n));
                 else
-                    assert(avahi_is_valid_host_name(n));
+                    assert(catta_is_valid_host_name(n));
 
                 printf("%s\n", r);
             }
         }
     }
 
-    avahi_free(r);
+    catta_free(r);
     return 0;
 }
diff --git a/tests/avahi-reflector.c b/tests/avahi-reflector.c
deleted file mode 100644 (file)
index 97032c2..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/***
-  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 <config.h>
-#endif
-
-#include <stdlib.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include <avahi/simple-watch.h>
-#include <avahi/core.h>
-
-int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char*argv[]) {
-    AvahiServer *server;
-    AvahiServerConfig config;
-    int error;
-    AvahiSimplePoll *simple_poll;
-
-    simple_poll = avahi_simple_poll_new();
-
-    avahi_server_config_init(&config);
-    config.publish_hinfo = 0;
-    config.publish_addresses = 0;
-    config.publish_workstation = 0;
-    config.publish_domain = 0;
-    config.use_ipv6 = 0;
-    config.enable_reflector = 1;
-
-    server = avahi_server_new(avahi_simple_poll_get(simple_poll), &config, NULL, NULL, &error);
-    avahi_server_config_free(&config);
-
-    for (;;)
-        if (avahi_simple_poll_iterate(simple_poll, -1) != 0)
-            break;
-
-    avahi_server_free(server);
-    avahi_simple_poll_free(simple_poll);
-
-    return 0;
-}
diff --git a/tests/avahi-test.c b/tests/avahi-test.c
deleted file mode 100644 (file)
index 50680ab..0000000
+++ /dev/null
@@ -1,402 +0,0 @@
-/***
-  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 <config.h>
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <assert.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include <avahi/malloc.h>
-#include <avahi/simple-watch.h>
-#include <avahi/alternative.h>
-#include <avahi/timeval.h>
-
-#include <avahi/core.h>
-#include <avahi/log.h>
-#include <avahi/publish.h>
-#include <avahi/lookup.h>
-#include "../src/dns-srv-rr.h"
-
-static AvahiSEntryGroup *group = NULL;
-static AvahiServer *server = NULL;
-static char *service_name = NULL;
-
-static const AvahiPoll *poll_api;
-
-static void quit_timeout_callback(AVAHI_GCC_UNUSED AvahiTimeout *timeout, void* userdata) {
-    AvahiSimplePoll *simple_poll = userdata;
-
-    avahi_simple_poll_quit(simple_poll);
-}
-
-static void dump_line(const char *text, AVAHI_GCC_UNUSED void* userdata) {
-    printf("%s\n", text);
-}
-
-static void dump_timeout_callback(AvahiTimeout *timeout, void* userdata) {
-    struct timeval tv;
-
-    AvahiServer *avahi = userdata;
-    avahi_server_dump(avahi, dump_line, NULL);
-
-    avahi_elapse_time(&tv, 5000, 0);
-    poll_api->timeout_update(timeout, &tv);
-}
-
-static const char *browser_event_to_string(AvahiBrowserEvent event) {
-    switch (event) {
-        case AVAHI_BROWSER_NEW : return "NEW";
-        case AVAHI_BROWSER_REMOVE : return "REMOVE";
-        case AVAHI_BROWSER_CACHE_EXHAUSTED : return "CACHE_EXHAUSTED";
-        case AVAHI_BROWSER_ALL_FOR_NOW : return "ALL_FOR_NOW";
-        case AVAHI_BROWSER_FAILURE : return "FAILURE";
-    }
-
-    abort();
-}
-
-static const char *resolver_event_to_string(AvahiResolverEvent event) {
-    switch (event) {
-        case AVAHI_RESOLVER_FOUND: return "FOUND";
-        case AVAHI_RESOLVER_FAILURE: return "FAILURE";
-    }
-    abort();
-}
-
-static void record_browser_callback(
-    AvahiSRecordBrowser *r,
-    AvahiIfIndex interface,
-    AvahiProtocol protocol,
-    AvahiBrowserEvent event,
-    AvahiRecord *record,
-    AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
-    AVAHI_GCC_UNUSED void* userdata) {
-    char *t;
-
-    assert(r);
-
-    if (record) {
-        avahi_log_debug("RB: record [%s] on %i.%i is %s", t = avahi_record_to_string(record), interface, protocol, browser_event_to_string(event));
-        avahi_free(t);
-    } else
-        avahi_log_debug("RB: [%s]", browser_event_to_string(event));
-
-}
-
-static void remove_entries(void);
-static void create_entries(int new_name);
-
-static void entry_group_callback(AVAHI_GCC_UNUSED AvahiServer *s, AVAHI_GCC_UNUSED AvahiSEntryGroup *g, AvahiEntryGroupState state, AVAHI_GCC_UNUSED void* userdata) {
-    avahi_log_debug("entry group state: %i", state);
-
-    if (state == AVAHI_ENTRY_GROUP_COLLISION) {
-        remove_entries();
-        create_entries(1);
-        avahi_log_debug("Service name conflict, retrying with <%s>", service_name);
-    } else if (state == AVAHI_ENTRY_GROUP_ESTABLISHED) {
-        avahi_log_debug("Service established under name <%s>", service_name);
-    }
-}
-
-static void server_callback(AvahiServer *s, AvahiServerState state, AVAHI_GCC_UNUSED void* userdata) {
-
-    server = s;
-    avahi_log_debug("server state: %i", state);
-
-    if (state == AVAHI_SERVER_RUNNING) {
-        avahi_log_debug("Server startup complete. Host name is <%s>. Service cookie is %u", avahi_server_get_host_name_fqdn(s), avahi_server_get_local_service_cookie(s));
-        create_entries(0);
-    } else if (state == AVAHI_SERVER_COLLISION) {
-        char *n;
-        remove_entries();
-
-        n = avahi_alternative_host_name(avahi_server_get_host_name(s));
-
-        avahi_log_debug("Host name conflict, retrying with <%s>", n);
-        avahi_server_set_host_name(s, n);
-        avahi_free(n);
-    }
-}
-
-static void remove_entries(void) {
-    if (group)
-        avahi_s_entry_group_reset(group);
-}
-
-static void create_entries(int new_name) {
-    AvahiAddress a;
-    AvahiRecord *r;
-
-    remove_entries();
-
-    if (!group)
-        group = avahi_s_entry_group_new(server, entry_group_callback, NULL);
-
-    assert(avahi_s_entry_group_is_empty(group));
-
-    if (!service_name)
-        service_name = avahi_strdup("Test Service");
-    else if (new_name) {
-        char *n = avahi_alternative_service_name(service_name);
-        avahi_free(service_name);
-        service_name = n;
-    }
-
-    if (avahi_server_add_service(server, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, service_name, "_http._tcp", NULL, NULL, 80, "foo", NULL) < 0) {
-        avahi_log_error("Failed to add HTTP service");
-        goto fail;
-    }
-
-    if (avahi_server_add_service(server, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, service_name, "_ftp._tcp", NULL, NULL, 21, "foo", NULL) < 0) {
-        avahi_log_error("Failed to add FTP service");
-        goto fail;
-    }
-
-    if (avahi_server_add_service(server, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0,service_name, "_webdav._tcp", NULL, NULL, 80, "foo", NULL) < 0) {
-        avahi_log_error("Failed to add WEBDAV service");
-        goto fail;
-    }
-
-    if (avahi_server_add_dns_server_address(server, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, NULL, AVAHI_DNS_SERVER_RESOLVE, avahi_address_parse("192.168.50.1", AVAHI_PROTO_UNSPEC, &a), 53) < 0) {
-        avahi_log_error("Failed to add new DNS Server address");
-        goto fail;
-    }
-
-    r = avahi_record_new_full("cname.local", AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_CNAME, AVAHI_DEFAULT_TTL);
-    r->data.cname.name = avahi_strdup("cocaine.local");
-
-    if (avahi_server_add(server, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, r) < 0) {
-        avahi_record_unref(r);
-        avahi_log_error("Failed to add CNAME record");
-        goto fail;
-    }
-    avahi_record_unref(r);
-
-    avahi_s_entry_group_commit(group);
-    return;
-
-fail:
-    if (group)
-        avahi_s_entry_group_free(group);
-
-    group = NULL;
-}
-
-static void hnr_callback(
-    AVAHI_GCC_UNUSED AvahiSHostNameResolver *r,
-    AvahiIfIndex iface,
-    AvahiProtocol protocol,
-    AvahiResolverEvent event,
-    const char *hostname,
-    const AvahiAddress *a,
-    AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
-    AVAHI_GCC_UNUSED void* userdata) {
-    char t[AVAHI_ADDRESS_STR_MAX];
-
-    if (a)
-        avahi_address_snprint(t, sizeof(t), a);
-
-    avahi_log_debug("HNR: (%i.%i) <%s> -> %s [%s]", iface, protocol, hostname, a ? t : "n/a", resolver_event_to_string(event));
-}
-
-static void ar_callback(
-    AVAHI_GCC_UNUSED AvahiSAddressResolver *r,
-    AvahiIfIndex iface,
-    AvahiProtocol protocol,
-    AvahiResolverEvent event,
-    const AvahiAddress *a,
-    const char *hostname,
-    AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
-    AVAHI_GCC_UNUSED void* userdata) {
-    char t[AVAHI_ADDRESS_STR_MAX];
-
-    avahi_address_snprint(t, sizeof(t), a);
-
-    avahi_log_debug("AR: (%i.%i) %s -> <%s> [%s]", iface, protocol, t, hostname ? hostname : "n/a", resolver_event_to_string(event));
-}
-
-static void db_callback(
-    AVAHI_GCC_UNUSED AvahiSDomainBrowser *b,
-    AvahiIfIndex iface,
-    AvahiProtocol protocol,
-    AvahiBrowserEvent event,
-    const char *domain,
-    AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
-    AVAHI_GCC_UNUSED void* userdata) {
-
-    avahi_log_debug("DB: (%i.%i) <%s> [%s]", iface, protocol, domain ? domain : "NULL", browser_event_to_string(event));
-}
-
-static void stb_callback(
-    AVAHI_GCC_UNUSED AvahiSServiceTypeBrowser *b,
-    AvahiIfIndex iface,
-    AvahiProtocol protocol,
-    AvahiBrowserEvent event,
-    const char *service_type,
-    const char *domain,
-    AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
-    AVAHI_GCC_UNUSED void* userdata) {
-
-    avahi_log_debug("STB: (%i.%i) %s in <%s> [%s]", iface, protocol, service_type ? service_type : "NULL", domain ? domain : "NULL", browser_event_to_string(event));
-}
-
-static void sb_callback(
-    AVAHI_GCC_UNUSED AvahiSServiceBrowser *b,
-    AvahiIfIndex iface,
-    AvahiProtocol protocol,
-    AvahiBrowserEvent event,
-    const char *name,
-    const char *service_type,
-    const char *domain,
-    AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
-    AVAHI_GCC_UNUSED void* userdata) {
-    avahi_log_debug("SB: (%i.%i) <%s> as %s in <%s> [%s]", iface, protocol, name ? name : "NULL", service_type ? service_type : "NULL", domain ? domain : "NULL", browser_event_to_string(event));
-}
-
-static void sr_callback(
-    AVAHI_GCC_UNUSED AvahiSServiceResolver *r,
-    AvahiIfIndex iface,
-    AvahiProtocol protocol,
-    AvahiResolverEvent event,
-    const char *name,
-    const char*service_type,
-    const char*domain_name,
-    const char*hostname,
-    const AvahiAddress *a,
-    uint16_t port,
-    AvahiStringList *txt,
-    AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
-    AVAHI_GCC_UNUSED void* userdata) {
-
-    if (event != AVAHI_RESOLVER_FOUND)
-        avahi_log_debug("SR: (%i.%i) <%s> as %s in <%s> [%s]", iface, protocol, name, service_type, domain_name, resolver_event_to_string(event));
-    else {
-        char t[AVAHI_ADDRESS_STR_MAX], *s;
-
-        avahi_address_snprint(t, sizeof(t), a);
-
-        s = avahi_string_list_to_string(txt);
-        avahi_log_debug("SR: (%i.%i) <%s> as %s in <%s>: %s/%s:%i (%s) [%s]", iface, protocol, name, service_type, domain_name, hostname, t, port, s, resolver_event_to_string(event));
-        avahi_free(s);
-    }
-}
-
-static void dsb_callback(
-    AVAHI_GCC_UNUSED AvahiSDNSServerBrowser *b,
-    AvahiIfIndex iface,
-    AvahiProtocol protocol,
-    AvahiBrowserEvent event,
-    const char*hostname,
-    const AvahiAddress *a,
-    uint16_t port,
-    AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
-    AVAHI_GCC_UNUSED void* userdata) {
-
-    char t[AVAHI_ADDRESS_STR_MAX] = "n/a";
-
-    if (a)
-        avahi_address_snprint(t, sizeof(t), a);
-
-    avahi_log_debug("DSB: (%i.%i): %s/%s:%i [%s]", iface, protocol, hostname ? hostname : "NULL", t, port, browser_event_to_string(event));
-}
-
-int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
-    AvahiSRecordBrowser *r;
-    AvahiSHostNameResolver *hnr;
-    AvahiSAddressResolver *ar;
-    AvahiKey *k;
-    AvahiServerConfig config;
-    AvahiAddress a;
-    AvahiSDomainBrowser *db;
-    AvahiSServiceTypeBrowser *stb;
-    AvahiSServiceBrowser *sb;
-    AvahiSServiceResolver *sr;
-    AvahiSDNSServerBrowser *dsb;
-    AvahiSimplePoll *simple_poll;
-    int error;
-    struct timeval tv;
-
-    simple_poll = avahi_simple_poll_new();
-    poll_api = avahi_simple_poll_get(simple_poll);
-
-    avahi_server_config_init(&config);
-
-    avahi_address_parse("192.168.50.1", AVAHI_PROTO_UNSPEC, &config.wide_area_servers[0]);
-    config.n_wide_area_servers = 1;
-    config.enable_wide_area = 1;
-
-    server = avahi_server_new(poll_api, &config, server_callback, NULL, &error);
-    avahi_server_config_free(&config);
-
-    k = avahi_key_new("_http._tcp.0pointer.de", AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR);
-    r = avahi_s_record_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, k, 0, record_browser_callback, NULL);
-    avahi_key_unref(k);
-
-    hnr = avahi_s_host_name_resolver_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "cname.local", AVAHI_PROTO_UNSPEC, 0, hnr_callback, NULL);
-
-    ar = avahi_s_address_resolver_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, avahi_address_parse("192.168.50.1", AVAHI_PROTO_INET, &a), 0, ar_callback, NULL);
-
-    db = avahi_s_domain_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DOMAIN_BROWSER_BROWSE, 0, db_callback, NULL);
-
-    stb = avahi_s_service_type_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, 0, stb_callback, NULL);
-
-    sb = avahi_s_service_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_http._tcp", NULL, 0, sb_callback, NULL);
-
-    sr = avahi_s_service_resolver_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "Ecstasy HTTP", "_http._tcp", "local", AVAHI_PROTO_UNSPEC, 0, sr_callback, NULL);
-
-    dsb = avahi_s_dns_server_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "local", AVAHI_DNS_SERVER_RESOLVE, AVAHI_PROTO_UNSPEC, 0, dsb_callback, NULL);
-
-    avahi_elapse_time(&tv, 1000*5, 0);
-    poll_api->timeout_new(poll_api, &tv, dump_timeout_callback, server);
-
-    avahi_elapse_time(&tv, 1000*60, 0);
-    poll_api->timeout_new(poll_api, &tv, quit_timeout_callback, simple_poll);
-
-    avahi_simple_poll_loop(simple_poll);
-
-    avahi_s_record_browser_free(r);
-    avahi_s_host_name_resolver_free(hnr);
-    avahi_s_address_resolver_free(ar);
-    avahi_s_domain_browser_free(db);
-    avahi_s_service_type_browser_free(stb);
-    avahi_s_service_browser_free(sb);
-    avahi_s_service_resolver_free(sr);
-    avahi_s_dns_server_browser_free(dsb);
-
-    if (group)
-        avahi_s_entry_group_free(group);
-
-    if (server)
-        avahi_server_free(server);
-
-    if (simple_poll)
-        avahi_simple_poll_free(simple_poll);
-
-    avahi_free(service_name);
-
-    return 0;
-}
diff --git a/tests/catta-reflector.c b/tests/catta-reflector.c
new file mode 100644 (file)
index 0000000..1cbfcb7
--- /dev/null
@@ -0,0 +1,61 @@
+/***
+  This file is part of catta.
+
+  catta 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.
+
+  catta 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 catta; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <catta/simple-watch.h>
+#include <catta/core.h>
+
+int main(CATTA_GCC_UNUSED int argc, CATTA_GCC_UNUSED char*argv[]) {
+    CattaServer *server;
+    CattaServerConfig config;
+    int error;
+    CattaSimplePoll *simple_poll;
+
+    simple_poll = catta_simple_poll_new();
+
+    catta_server_config_init(&config);
+    config.publish_hinfo = 0;
+    config.publish_addresses = 0;
+    config.publish_workstation = 0;
+    config.publish_domain = 0;
+    config.use_ipv6 = 0;
+    config.enable_reflector = 1;
+
+    server = catta_server_new(catta_simple_poll_get(simple_poll), &config, NULL, NULL, &error);
+    catta_server_config_free(&config);
+
+    for (;;)
+        if (catta_simple_poll_iterate(simple_poll, -1) != 0)
+            break;
+
+    catta_server_free(server);
+    catta_simple_poll_free(simple_poll);
+
+    return 0;
+}
diff --git a/tests/catta-test.c b/tests/catta-test.c
new file mode 100644 (file)
index 0000000..0008282
--- /dev/null
@@ -0,0 +1,402 @@
+/***
+  This file is part of catta.
+
+  catta 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.
+
+  catta 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 catta; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <catta/malloc.h>
+#include <catta/simple-watch.h>
+#include <catta/alternative.h>
+#include <catta/timeval.h>
+
+#include <catta/core.h>
+#include <catta/log.h>
+#include <catta/publish.h>
+#include <catta/lookup.h>
+#include "../src/dns-srv-rr.h"
+
+static CattaSEntryGroup *group = NULL;
+static CattaServer *server = NULL;
+static char *service_name = NULL;
+
+static const CattaPoll *poll_api;
+
+static void quit_timeout_callback(CATTA_GCC_UNUSED CattaTimeout *timeout, void* userdata) {
+    CattaSimplePoll *simple_poll = userdata;
+
+    catta_simple_poll_quit(simple_poll);
+}
+
+static void dump_line(const char *text, CATTA_GCC_UNUSED void* userdata) {
+    printf("%s\n", text);
+}
+
+static void dump_timeout_callback(CattaTimeout *timeout, void* userdata) {
+    struct timeval tv;
+
+    CattaServer *catta = userdata;
+    catta_server_dump(catta, dump_line, NULL);
+
+    catta_elapse_time(&tv, 5000, 0);
+    poll_api->timeout_update(timeout, &tv);
+}
+
+static const char *browser_event_to_string(CattaBrowserEvent event) {
+    switch (event) {
+        case CATTA_BROWSER_NEW : return "NEW";
+        case CATTA_BROWSER_REMOVE : return "REMOVE";
+        case CATTA_BROWSER_CACHE_EXHAUSTED : return "CACHE_EXHAUSTED";
+        case CATTA_BROWSER_ALL_FOR_NOW : return "ALL_FOR_NOW";
+        case CATTA_BROWSER_FAILURE : return "FAILURE";
+    }
+
+    abort();
+}
+
+static const char *resolver_event_to_string(CattaResolverEvent event) {
+    switch (event) {
+        case CATTA_RESOLVER_FOUND: return "FOUND";
+        case CATTA_RESOLVER_FAILURE: return "FAILURE";
+    }
+    abort();
+}
+
+static void record_browser_callback(
+    CattaSRecordBrowser *r,
+    CattaIfIndex interface,
+    CattaProtocol protocol,
+    CattaBrowserEvent event,
+    CattaRecord *record,
+    CATTA_GCC_UNUSED CattaLookupResultFlags flags,
+    CATTA_GCC_UNUSED void* userdata) {
+    char *t;
+
+    assert(r);
+
+    if (record) {
+        catta_log_debug("RB: record [%s] on %i.%i is %s", t = catta_record_to_string(record), interface, protocol, browser_event_to_string(event));
+        catta_free(t);
+    } else
+        catta_log_debug("RB: [%s]", browser_event_to_string(event));
+
+}
+
+static void remove_entries(void);
+static void create_entries(int new_name);
+
+static void entry_group_callback(CATTA_GCC_UNUSED CattaServer *s, CATTA_GCC_UNUSED CattaSEntryGroup *g, CattaEntryGroupState state, CATTA_GCC_UNUSED void* userdata) {
+    catta_log_debug("entry group state: %i", state);
+
+    if (state == CATTA_ENTRY_GROUP_COLLISION) {
+        remove_entries();
+        create_entries(1);
+        catta_log_debug("Service name conflict, retrying with <%s>", service_name);
+    } else if (state == CATTA_ENTRY_GROUP_ESTABLISHED) {
+        catta_log_debug("Service established under name <%s>", service_name);
+    }
+}
+
+static void server_callback(CattaServer *s, CattaServerState state, CATTA_GCC_UNUSED void* userdata) {
+
+    server = s;
+    catta_log_debug("server state: %i", state);
+
+    if (state == CATTA_SERVER_RUNNING) {
+        catta_log_debug("Server startup complete. Host name is <%s>. Service cookie is %u", catta_server_get_host_name_fqdn(s), catta_server_get_local_service_cookie(s));
+        create_entries(0);
+    } else if (state == CATTA_SERVER_COLLISION) {
+        char *n;
+        remove_entries();
+
+        n = catta_alternative_host_name(catta_server_get_host_name(s));
+
+        catta_log_debug("Host name conflict, retrying with <%s>", n);
+        catta_server_set_host_name(s, n);
+        catta_free(n);
+    }
+}
+
+static void remove_entries(void) {
+    if (group)
+        catta_s_entry_group_reset(group);
+}
+
+static void create_entries(int new_name) {
+    CattaAddress a;
+    CattaRecord *r;
+
+    remove_entries();
+
+    if (!group)
+        group = catta_s_entry_group_new(server, entry_group_callback, NULL);
+
+    assert(catta_s_entry_group_is_empty(group));
+
+    if (!service_name)
+        service_name = catta_strdup("Test Service");
+    else if (new_name) {
+        char *n = catta_alternative_service_name(service_name);
+        catta_free(service_name);
+        service_name = n;
+    }
+
+    if (catta_server_add_service(server, group, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, 0, service_name, "_http._tcp", NULL, NULL, 80, "foo", NULL) < 0) {
+        catta_log_error("Failed to add HTTP service");
+        goto fail;
+    }
+
+    if (catta_server_add_service(server, group, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, 0, service_name, "_ftp._tcp", NULL, NULL, 21, "foo", NULL) < 0) {
+        catta_log_error("Failed to add FTP service");
+        goto fail;
+    }
+
+    if (catta_server_add_service(server, group, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, 0,service_name, "_webdav._tcp", NULL, NULL, 80, "foo", NULL) < 0) {
+        catta_log_error("Failed to add WEBDAV service");
+        goto fail;
+    }
+
+    if (catta_server_add_dns_server_address(server, group, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, 0, NULL, CATTA_DNS_SERVER_RESOLVE, catta_address_parse("192.168.50.1", CATTA_PROTO_UNSPEC, &a), 53) < 0) {
+        catta_log_error("Failed to add new DNS Server address");
+        goto fail;
+    }
+
+    r = catta_record_new_full("cname.local", CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_CNAME, CATTA_DEFAULT_TTL);
+    r->data.cname.name = catta_strdup("cocaine.local");
+
+    if (catta_server_add(server, group, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, 0, r) < 0) {
+        catta_record_unref(r);
+        catta_log_error("Failed to add CNAME record");
+        goto fail;
+    }
+    catta_record_unref(r);
+
+    catta_s_entry_group_commit(group);
+    return;
+
+fail:
+    if (group)
+        catta_s_entry_group_free(group);
+
+    group = NULL;
+}
+
+static void hnr_callback(
+    CATTA_GCC_UNUSED CattaSHostNameResolver *r,
+    CattaIfIndex iface,
+    CattaProtocol protocol,
+    CattaResolverEvent event,
+    const char *hostname,
+    const CattaAddress *a,
+    CATTA_GCC_UNUSED CattaLookupResultFlags flags,
+    CATTA_GCC_UNUSED void* userdata) {
+    char t[CATTA_ADDRESS_STR_MAX];
+
+    if (a)
+        catta_address_snprint(t, sizeof(t), a);
+
+    catta_log_debug("HNR: (%i.%i) <%s> -> %s [%s]", iface, protocol, hostname, a ? t : "n/a", resolver_event_to_string(event));
+}
+
+static void ar_callback(
+    CATTA_GCC_UNUSED CattaSAddressResolver *r,
+    CattaIfIndex iface,
+    CattaProtocol protocol,
+    CattaResolverEvent event,
+    const CattaAddress *a,
+    const char *hostname,
+    CATTA_GCC_UNUSED CattaLookupResultFlags flags,
+    CATTA_GCC_UNUSED void* userdata) {
+    char t[CATTA_ADDRESS_STR_MAX];
+
+    catta_address_snprint(t, sizeof(t), a);
+
+    catta_log_debug("AR: (%i.%i) %s -> <%s> [%s]", iface, protocol, t, hostname ? hostname : "n/a", resolver_event_to_string(event));
+}
+
+static void db_callback(
+    CATTA_GCC_UNUSED CattaSDomainBrowser *b,
+    CattaIfIndex iface,
+    CattaProtocol protocol,
+    CattaBrowserEvent event,
+    const char *domain,
+    CATTA_GCC_UNUSED CattaLookupResultFlags flags,
+    CATTA_GCC_UNUSED void* userdata) {
+
+    catta_log_debug("DB: (%i.%i) <%s> [%s]", iface, protocol, domain ? domain : "NULL", browser_event_to_string(event));
+}
+
+static void stb_callback(
+    CATTA_GCC_UNUSED CattaSServiceTypeBrowser *b,
+    CattaIfIndex iface,
+    CattaProtocol protocol,
+    CattaBrowserEvent event,
+    const char *service_type,
+    const char *domain,
+    CATTA_GCC_UNUSED CattaLookupResultFlags flags,
+    CATTA_GCC_UNUSED void* userdata) {
+
+    catta_log_debug("STB: (%i.%i) %s in <%s> [%s]", iface, protocol, service_type ? service_type : "NULL", domain ? domain : "NULL", browser_event_to_string(event));
+}
+
+static void sb_callback(
+    CATTA_GCC_UNUSED CattaSServiceBrowser *b,
+    CattaIfIndex iface,
+    CattaProtocol protocol,
+    CattaBrowserEvent event,
+    const char *name,
+    const char *service_type,
+    const char *domain,
+    CATTA_GCC_UNUSED CattaLookupResultFlags flags,
+    CATTA_GCC_UNUSED void* userdata) {
+    catta_log_debug("SB: (%i.%i) <%s> as %s in <%s> [%s]", iface, protocol, name ? name : "NULL", service_type ? service_type : "NULL", domain ? domain : "NULL", browser_event_to_string(event));
+}
+
+static void sr_callback(
+    CATTA_GCC_UNUSED CattaSServiceResolver *r,
+    CattaIfIndex iface,
+    CattaProtocol protocol,
+    CattaResolverEvent event,
+    const char *name,
+    const char*service_type,
+    const char*domain_name,
+    const char*hostname,
+    const CattaAddress *a,
+    uint16_t port,
+    CattaStringList *txt,
+    CATTA_GCC_UNUSED CattaLookupResultFlags flags,
+    CATTA_GCC_UNUSED void* userdata) {
+
+    if (event != CATTA_RESOLVER_FOUND)
+        catta_log_debug("SR: (%i.%i) <%s> as %s in <%s> [%s]", iface, protocol, name, service_type, domain_name, resolver_event_to_string(event));
+    else {
+        char t[CATTA_ADDRESS_STR_MAX], *s;
+
+        catta_address_snprint(t, sizeof(t), a);
+
+        s = catta_string_list_to_string(txt);
+        catta_log_debug("SR: (%i.%i) <%s> as %s in <%s>: %s/%s:%i (%s) [%s]", iface, protocol, name, service_type, domain_name, hostname, t, port, s, resolver_event_to_string(event));
+        catta_free(s);
+    }
+}
+
+static void dsb_callback(
+    CATTA_GCC_UNUSED CattaSDNSServerBrowser *b,
+    CattaIfIndex iface,
+    CattaProtocol protocol,
+    CattaBrowserEvent event,
+    const char*hostname,
+    const CattaAddress *a,
+    uint16_t port,
+    CATTA_GCC_UNUSED CattaLookupResultFlags flags,
+    CATTA_GCC_UNUSED void* userdata) {
+
+    char t[CATTA_ADDRESS_STR_MAX] = "n/a";
+
+    if (a)
+        catta_address_snprint(t, sizeof(t), a);
+
+    catta_log_debug("DSB: (%i.%i): %s/%s:%i [%s]", iface, protocol, hostname ? hostname : "NULL", t, port, browser_event_to_string(event));
+}
+
+int main(CATTA_GCC_UNUSED int argc, CATTA_GCC_UNUSED char *argv[]) {
+    CattaSRecordBrowser *r;
+    CattaSHostNameResolver *hnr;
+    CattaSAddressResolver *ar;
+    CattaKey *k;
+    CattaServerConfig config;
+    CattaAddress a;
+    CattaSDomainBrowser *db;
+    CattaSServiceTypeBrowser *stb;
+    CattaSServiceBrowser *sb;
+    CattaSServiceResolver *sr;
+    CattaSDNSServerBrowser *dsb;
+    CattaSimplePoll *simple_poll;
+    int error;
+    struct timeval tv;
+
+    simple_poll = catta_simple_poll_new();
+    poll_api = catta_simple_poll_get(simple_poll);
+
+    catta_server_config_init(&config);
+
+    catta_address_parse("192.168.50.1", CATTA_PROTO_UNSPEC, &config.wide_area_servers[0]);
+    config.n_wide_area_servers = 1;
+    config.enable_wide_area = 1;
+
+    server = catta_server_new(poll_api, &config, server_callback, NULL, &error);
+    catta_server_config_free(&config);
+
+    k = catta_key_new("_http._tcp.0pointer.de", CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_PTR);
+    r = catta_s_record_browser_new(server, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, k, 0, record_browser_callback, NULL);
+    catta_key_unref(k);
+
+    hnr = catta_s_host_name_resolver_new(server, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, "cname.local", CATTA_PROTO_UNSPEC, 0, hnr_callback, NULL);
+
+    ar = catta_s_address_resolver_new(server, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, catta_address_parse("192.168.50.1", CATTA_PROTO_INET, &a), 0, ar_callback, NULL);
+
+    db = catta_s_domain_browser_new(server, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, NULL, CATTA_DOMAIN_BROWSER_BROWSE, 0, db_callback, NULL);
+
+    stb = catta_s_service_type_browser_new(server, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, NULL, 0, stb_callback, NULL);
+
+    sb = catta_s_service_browser_new(server, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, "_http._tcp", NULL, 0, sb_callback, NULL);
+
+    sr = catta_s_service_resolver_new(server, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, "Ecstasy HTTP", "_http._tcp", "local", CATTA_PROTO_UNSPEC, 0, sr_callback, NULL);
+
+    dsb = catta_s_dns_server_browser_new(server, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, "local", CATTA_DNS_SERVER_RESOLVE, CATTA_PROTO_UNSPEC, 0, dsb_callback, NULL);
+
+    catta_elapse_time(&tv, 1000*5, 0);
+    poll_api->timeout_new(poll_api, &tv, dump_timeout_callback, server);
+
+    catta_elapse_time(&tv, 1000*60, 0);
+    poll_api->timeout_new(poll_api, &tv, quit_timeout_callback, simple_poll);
+
+    catta_simple_poll_loop(simple_poll);
+
+    catta_s_record_browser_free(r);
+    catta_s_host_name_resolver_free(hnr);
+    catta_s_address_resolver_free(ar);
+    catta_s_domain_browser_free(db);
+    catta_s_service_type_browser_free(stb);
+    catta_s_service_browser_free(sb);
+    catta_s_service_resolver_free(sr);
+    catta_s_dns_server_browser_free(dsb);
+
+    if (group)
+        catta_s_entry_group_free(group);
+
+    if (server)
+        catta_server_free(server);
+
+    if (simple_poll)
+        catta_simple_poll_free(simple_poll);
+
+    catta_free(service_name);
+
+    return 0;
+}
index d2b40d417b8e3ae9fde536c29eeacba06f9d9ea0..9f0bd1c30f2c5879bb5eaca4e49d8034640bf06b 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
-#include <avahi/alternative.h>
-#include <avahi/malloc.h>
-#include <avahi/simple-watch.h>
-#include <avahi/timeval.h>
+#include <catta/alternative.h>
+#include <catta/malloc.h>
+#include <catta/simple-watch.h>
+#include <catta/timeval.h>
 
-#include <avahi/core.h>
-#include <avahi/log.h>
-#include <avahi/lookup.h>
-#include <avahi/publish.h>
+#include <catta/core.h>
+#include <catta/log.h>
+#include <catta/lookup.h>
+#include <catta/publish.h>
 
 static char *name = NULL;
-static AvahiSEntryGroup *group = NULL;
+static CattaSEntryGroup *group = NULL;
 static int try = 0;
-static AvahiServer *avahi = NULL;
-static const AvahiPoll *poll_api;
+static CattaServer *catta = NULL;
+static const CattaPoll *poll_api;
 
-static void dump_line(const char *text, AVAHI_GCC_UNUSED void* userdata) {
+static void dump_line(const char *text, CATTA_GCC_UNUSED void* userdata) {
     printf("%s\n", text);
 }
 
-static void dump_timeout_callback(AvahiTimeout *timeout, AVAHI_GCC_UNUSED void* userdata) {
+static void dump_timeout_callback(CattaTimeout *timeout, CATTA_GCC_UNUSED void* userdata) {
     struct timeval tv;
 
-    avahi_server_dump(avahi, dump_line, NULL);
+    catta_server_dump(catta, dump_line, NULL);
 
-    avahi_elapse_time(&tv, 5000, 0);
+    catta_elapse_time(&tv, 5000, 0);
     poll_api->timeout_update(timeout, &tv);
 }
 
-static void entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntryGroupState state, void* userdata);
+static void entry_group_callback(CattaServer *s, CattaSEntryGroup *g, CattaEntryGroupState state, void* userdata);
 
 static void create_service(const char *t) {
     char *n;
 
     assert(t || name);
 
-    n = t ? avahi_strdup(t) : avahi_alternative_service_name(name);
-    avahi_free(name);
+    n = t ? catta_strdup(t) : catta_alternative_service_name(name);
+    catta_free(name);
     name = n;
 
     if (group)
-        avahi_s_entry_group_reset(group);
+        catta_s_entry_group_reset(group);
     else
-        group = avahi_s_entry_group_new(avahi, entry_group_callback, NULL);
+        group = catta_s_entry_group_new(catta, entry_group_callback, NULL);
 
-    avahi_server_add_service(avahi, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, name, "_http._tcp", NULL, NULL, 80, "foo", NULL);
-    avahi_s_entry_group_commit(group);
+    catta_server_add_service(catta, group, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, 0, name, "_http._tcp", NULL, NULL, 80, "foo", NULL);
+    catta_s_entry_group_commit(group);
 
     try++;
 }
 
-static void rename_timeout_callback(AvahiTimeout *timeout, AVAHI_GCC_UNUSED void *userdata) {
+static void rename_timeout_callback(CattaTimeout *timeout, CATTA_GCC_UNUSED void *userdata) {
     struct timeval tv;
 
     if (access("flag", F_OK) == 0) {
@@ -90,69 +90,69 @@ static void rename_timeout_callback(AvahiTimeout *timeout, AVAHI_GCC_UNUSED void
         return;
     }
 
-    avahi_elapse_time(&tv, 5000, 0);
+    catta_elapse_time(&tv, 5000, 0);
     poll_api->timeout_update(timeout, &tv);
 }
 
-static void entry_group_callback(AVAHI_GCC_UNUSED AvahiServer *s, AVAHI_GCC_UNUSED AvahiSEntryGroup *g, AvahiEntryGroupState state, AVAHI_GCC_UNUSED void* userdata) {
-    if (state == AVAHI_ENTRY_GROUP_COLLISION)
+static void entry_group_callback(CATTA_GCC_UNUSED CattaServer *s, CATTA_GCC_UNUSED CattaSEntryGroup *g, CattaEntryGroupState state, CATTA_GCC_UNUSED void* userdata) {
+    if (state == CATTA_ENTRY_GROUP_COLLISION)
         create_service(NULL);
-    else if (state == AVAHI_ENTRY_GROUP_ESTABLISHED) {
-        avahi_log_debug("ESTABLISHED !!!!");
+    else if (state == CATTA_ENTRY_GROUP_ESTABLISHED) {
+        catta_log_debug("ESTABLISHED !!!!");
         try = 0;
     }
 }
 
-static void server_callback(AvahiServer *s, AvahiServerState state, AVAHI_GCC_UNUSED void* userdata) {
-    avahi_log_debug("server state: %i", state);
+static void server_callback(CattaServer *s, CattaServerState state, CATTA_GCC_UNUSED void* userdata) {
+    catta_log_debug("server state: %i", state);
 
-    if (state == AVAHI_SERVER_RUNNING) {
-        avahi_server_dump(avahi, dump_line, NULL);
-    } else if (state == AVAHI_SERVER_COLLISION) {
+    if (state == CATTA_SERVER_RUNNING) {
+        catta_server_dump(catta, dump_line, NULL);
+    } else if (state == CATTA_SERVER_COLLISION) {
         char *n;
 
-        n = avahi_alternative_host_name(avahi_server_get_host_name(s));
-        avahi_log_warn("Host name conflict, retrying with <%s>", n);
-        avahi_server_set_host_name(s, n);
-        avahi_free(n);
+        n = catta_alternative_host_name(catta_server_get_host_name(s));
+        catta_log_warn("Host name conflict, retrying with <%s>", n);
+        catta_server_set_host_name(s, n);
+        catta_free(n);
 
     }
 }
 
-int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
+int main(CATTA_GCC_UNUSED int argc, CATTA_GCC_UNUSED char *argv[]) {
     int error;
-    AvahiSimplePoll *simple_poll;
+    CattaSimplePoll *simple_poll;
     struct timeval tv;
-    struct AvahiServerConfig config;
+    struct CattaServerConfig config;
 
-    simple_poll = avahi_simple_poll_new();
-    poll_api = avahi_simple_poll_get(simple_poll);
+    simple_poll = catta_simple_poll_new();
+    poll_api = catta_simple_poll_get(simple_poll);
 
-    avahi_server_config_init(&config);
+    catta_server_config_init(&config);
     config.publish_workstation = 0;
     config.use_ipv6 = 0;
     config.publish_domain = 0;
     config.publish_hinfo = 0;
-    avahi = avahi_server_new(poll_api, &config, server_callback, NULL, &error);
-    avahi_server_config_free(&config);
+    catta = catta_server_new(poll_api, &config, server_callback, NULL, &error);
+    catta_server_config_free(&config);
 
-    avahi_elapse_time(&tv, 5000, 0);
-    poll_api->timeout_new(poll_api, &tv, dump_timeout_callback, avahi);
+    catta_elapse_time(&tv, 5000, 0);
+    poll_api->timeout_new(poll_api, &tv, dump_timeout_callback, catta);
 
-    avahi_elapse_time(&tv, 5000, 0);
-    poll_api->timeout_new(poll_api, &tv, rename_timeout_callback, avahi);
+    catta_elapse_time(&tv, 5000, 0);
+    poll_api->timeout_new(poll_api, &tv, rename_timeout_callback, catta);
 
     /* Evil, but the conformace test requires that*/
     create_service("gurke");
 
 
-    avahi_simple_poll_loop(simple_poll);
+    catta_simple_poll_loop(simple_poll);
 
     if (group)
-        avahi_s_entry_group_free(group);
-    avahi_server_free(avahi);
+        catta_s_entry_group_free(group);
+    catta_server_free(catta);
 
-    avahi_simple_poll_free(simple_poll);
+    catta_simple_poll_free(simple_poll);
 
     return 0;
 }
index ebc5dd373dfa279e68c99f66446bf03077167dd5..f47e8ec0c4838b85931d60644ee495c8521df16c 100644 (file)
@@ -1,26 +1,26 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
-/* Regression test for Avahi bug #84.
- * This program tests whether the avahi_dns_packet_consume_name function
+/* Regression test for Catta bug #84.
+ * This program tests whether the catta_dns_packet_consume_name function
  * returns (rather than spinning forever). For a function as simple as
- * avahi_dns_packet_consume_name, we assume that 1 second of CPU time ≈ forever
+ * catta_dns_packet_consume_name, we assume that 1 second of CPU time ≈ forever
  */
 
 #ifdef HAVE_CONFIG_H
@@ -76,7 +76,7 @@ void fail(const char *fmt, ...) {
     exit(EXIT_FAILURE);
 }
 
-void handle(AVAHI_GCC_UNUSED int sig) {
+void handle(CATTA_GCC_UNUSED int sig) {
     fail("Interrupted after %d second of CPU time", MAX_CPU_SECONDS);
 }
 
@@ -86,13 +86,13 @@ void handle(AVAHI_GCC_UNUSED int sig) {
             unresolved("%s returned %s", #cmd, #badresult); \
     } while (0)
 
-int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
+int main(CATTA_GCC_UNUSED int argc, CATTA_GCC_UNUSED char *argv[]) {
     struct itimerval itval;
-    AvahiDnsPacket *packet;
+    CattaDnsPacket *packet;
     char name[512];
     int ret;
     uint8_t badrr[] = {
-        0xC0, AVAHI_DNS_PACKET_HEADER_SIZE, /* self-referential QNAME pointer */
+        0xC0, CATTA_DNS_PACKET_HEADER_SIZE, /* self-referential QNAME pointer */
         0, 1, /* QTYPE A (host addr) */
         0, 1, /* QCLASS IN (internet/ipv4) */
     };
@@ -106,14 +106,14 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
     if (setitimer(ITIMER_VIRTUAL, &itval, NULL) == -1)
         stdlib_fail("setitimer()");
 
-    TRY_EXCEPT(packet = avahi_dns_packet_new_query(512), NULL);
-    TRY_EXCEPT(avahi_dns_packet_append_bytes(packet, badrr, sizeof(badrr)), NULL);
+    TRY_EXCEPT(packet = catta_dns_packet_new_query(512), NULL);
+    TRY_EXCEPT(catta_dns_packet_append_bytes(packet, badrr, sizeof(badrr)), NULL);
 
     /* This is expected to fail (if it returns) */
-    ret = avahi_dns_packet_consume_name(packet, name, sizeof(name));
+    ret = catta_dns_packet_consume_name(packet, name, sizeof(name));
 
     if (ret != -1)
-        fail("avahi_dns_packet_consume_name() returned %d; -1 was expected", ret);
+        fail("catta_dns_packet_consume_name() returned %d; -1 was expected", ret);
 
     return EXIT_SUCCESS;
 }
index eba12c8721c85e8f4498ad0ecff48bac9c8c981a..c782e63eb5b0766e5f8ad9eb035afe1f77a94d01 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
-#include <avahi/domain.h>
-#include <avahi/defs.h>
-#include <avahi/malloc.h>
-#include <avahi/log.h>
+#include <catta/domain.h>
+#include <catta/defs.h>
+#include <catta/malloc.h>
+#include <catta/log.h>
 
 #include "../src/dns.h"
 #include "../src/util.h"
 
-int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
-    char t[AVAHI_DOMAIN_NAME_MAX], *m;
+int main(CATTA_GCC_UNUSED int argc, CATTA_GCC_UNUSED char *argv[]) {
+    char t[CATTA_DOMAIN_NAME_MAX], *m;
     const char *a, *b, *c, *d;
-    AvahiDnsPacket *p;
-    AvahiRecord *r, *r2;
-    uint8_t rdata[AVAHI_DNS_RDATA_MAX];
+    CattaDnsPacket *p;
+    CattaRecord *r, *r2;
+    uint8_t rdata[CATTA_DNS_RDATA_MAX];
     size_t l;
 
-    p = avahi_dns_packet_new(0);
+    p = catta_dns_packet_new(0);
 
-    assert(avahi_dns_packet_append_name(p, a = "Ahello.hello.hello.de."));
-    assert(avahi_dns_packet_append_name(p, b = "Bthis is a test.hello.de."));
-    assert(avahi_dns_packet_append_name(p, c = "Cthis\\.is\\.a\\.test\\.with\\.dots.hello.de."));
-    assert(avahi_dns_packet_append_name(p, d = "Dthis\\\\is another test.hello.de."));
+    assert(catta_dns_packet_append_name(p, a = "Ahello.hello.hello.de."));
+    assert(catta_dns_packet_append_name(p, b = "Bthis is a test.hello.de."));
+    assert(catta_dns_packet_append_name(p, c = "Cthis\\.is\\.a\\.test\\.with\\.dots.hello.de."));
+    assert(catta_dns_packet_append_name(p, d = "Dthis\\\\is another test.hello.de."));
 
-    avahi_hexdump(AVAHI_DNS_PACKET_DATA(p), p->size);
+    catta_hexdump(CATTA_DNS_PACKET_DATA(p), p->size);
 
-    assert(avahi_dns_packet_consume_name(p, t, sizeof(t)) == 0);
-    avahi_log_debug(">%s<", t);
-    assert(avahi_domain_equal(a, t));
+    assert(catta_dns_packet_consume_name(p, t, sizeof(t)) == 0);
+    catta_log_debug(">%s<", t);
+    assert(catta_domain_equal(a, t));
 
-    assert(avahi_dns_packet_consume_name(p, t, sizeof(t)) == 0);
-    avahi_log_debug(">%s<", t);
-    assert(avahi_domain_equal(b, t));
+    assert(catta_dns_packet_consume_name(p, t, sizeof(t)) == 0);
+    catta_log_debug(">%s<", t);
+    assert(catta_domain_equal(b, t));
 
-    assert(avahi_dns_packet_consume_name(p, t, sizeof(t)) == 0);
-    avahi_log_debug(">%s<", t);
-    assert(avahi_domain_equal(c, t));
+    assert(catta_dns_packet_consume_name(p, t, sizeof(t)) == 0);
+    catta_log_debug(">%s<", t);
+    assert(catta_domain_equal(c, t));
 
-    assert(avahi_dns_packet_consume_name(p, t, sizeof(t)) == 0);
-    avahi_log_debug(">%s<", t);
-    assert(avahi_domain_equal(d, t));
+    assert(catta_dns_packet_consume_name(p, t, sizeof(t)) == 0);
+    catta_log_debug(">%s<", t);
+    assert(catta_domain_equal(d, t));
 
-    avahi_dns_packet_free(p);
+    catta_dns_packet_free(p);
 
     /* RDATA PARSING AND SERIALIZATION */
 
-    /* Create an AvahiRecord with some usful data */
-    r = avahi_record_new_full("foobar.local", AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_HINFO, AVAHI_DEFAULT_TTL);
+    /* Create an CattaRecord with some usful data */
+    r = catta_record_new_full("foobar.local", CATTA_DNS_CLASS_IN, CATTA_DNS_TYPE_HINFO, CATTA_DEFAULT_TTL);
     assert(r);
-    r->data.hinfo.cpu = avahi_strdup("FOO");
-    r->data.hinfo.os = avahi_strdup("BAR");
+    r->data.hinfo.cpu = catta_strdup("FOO");
+    r->data.hinfo.os = catta_strdup("BAR");
 
     /* Serialize it into a blob */
-    assert((l = avahi_rdata_serialize(r, rdata, sizeof(rdata))) != (size_t) -1);
+    assert((l = catta_rdata_serialize(r, rdata, sizeof(rdata))) != (size_t) -1);
 
     /* Print it */
-    avahi_hexdump(rdata, l);
+    catta_hexdump(rdata, l);
 
     /* Create a new record and fill in the data from the blob */
-    r2 = avahi_record_new(r->key, AVAHI_DEFAULT_TTL);
+    r2 = catta_record_new(r->key, CATTA_DEFAULT_TTL);
     assert(r2);
-    assert(avahi_rdata_parse(r2, rdata, l) >= 0);
+    assert(catta_rdata_parse(r2, rdata, l) >= 0);
 
     /* Compare both versions */
-    assert(avahi_record_equal_no_ttl(r, r2));
+    assert(catta_record_equal_no_ttl(r, r2));
 
     /* Free the records */
-    avahi_record_unref(r);
-    avahi_record_unref(r2);
+    catta_record_unref(r);
+    catta_record_unref(r2);
 
-    r = avahi_record_new_full("foobar", 77, 77, AVAHI_DEFAULT_TTL);
+    r = catta_record_new_full("foobar", 77, 77, CATTA_DEFAULT_TTL);
     assert(r);
 
-    assert(r->data.generic.data = avahi_memdup("HALLO", r->data.generic.size = 5));
+    assert(r->data.generic.data = catta_memdup("HALLO", r->data.generic.size = 5));
 
-    m = avahi_record_to_string(r);
+    m = catta_record_to_string(r);
     assert(m);
 
-    avahi_log_debug(">%s<", m);
+    catta_log_debug(">%s<", m);
 
-    avahi_free(m);
-    avahi_record_unref(r);
+    catta_free(m);
+    catta_record_unref(r);
 
     return 0;
 }
index 445c05176aa332f7c267c2ca06c5a8807ef04d0e..1826fad9397665ed97026f50edbb9a0382bd707a 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <string.h>
 #include <assert.h>
 
-#include <avahi/domain.h>
-#include <avahi/malloc.h>
+#include <catta/domain.h>
+#include <catta/malloc.h>
 
-int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
+int main(CATTA_GCC_UNUSED int argc, CATTA_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];
+    char name[64], type[CATTA_DOMAIN_NAME_MAX], domain[CATTA_DOMAIN_NAME_MAX];
 
-    printf("%s\n", s = avahi_normalize_name_strdup("foo.foo\\046."));
-    avahi_free(s);
+    printf("%s\n", s = catta_normalize_name_strdup("foo.foo\\046."));
+    catta_free(s);
 
-    printf("%s\n", s = avahi_normalize_name_strdup("foo.foo\\.foo."));
-    avahi_free(s);
+    printf("%s\n", s = catta_normalize_name_strdup("foo.foo\\.foo."));
+    catta_free(s);
 
 
-    printf("%s\n", s = avahi_normalize_name_strdup("fo\\\\o\\..f oo."));
-    avahi_free(s);
+    printf("%s\n", s = catta_normalize_name_strdup("fo\\\\o\\..f oo."));
+    catta_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", catta_domain_equal("\\065aa bbb\\.\\046cc.cc\\\\.dee.fff.", "Aaa BBB\\.\\.cc.cc\\\\.dee.fff"));
+    printf("%i\n", catta_domain_equal("A", "a"));
 
-    printf("%i\n", avahi_domain_equal("a", "aaa"));
+    printf("%i\n", catta_domain_equal("a", "aaa"));
 
-    printf("%u = %u\n", avahi_domain_hash("ccc\\065aa.aa\\.b\\\\."), avahi_domain_hash("cccAaa.aa\\.b\\\\"));
+    printf("%u = %u\n", catta_domain_hash("ccc\\065aa.aa\\.b\\\\."), catta_domain_hash("cccAaa.aa\\.b\\\\"));
 
 
-    avahi_service_name_join(t, sizeof(t), "foo.foo.foo \\.", "_http._tcp", "test.local");
+    catta_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));
+    catta_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");
+    catta_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));
+    catta_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);
+    printf("unescaped: <%s>, rest: %s\n", catta_unescape_label(&p, t, sizeof(t)), p);
 
     size = sizeof(r);
     s = r;
 
-    printf("escaped: <%s>\n", avahi_escape_label(t, strlen(t), &s, &size));
+    printf("escaped: <%s>\n", catta_escape_label(t, strlen(t), &s, &size));
 
     p = r;
-    printf("unescaped: <%s>\n", avahi_unescape_label(&p, t, sizeof(t)));
+    printf("unescaped: <%s>\n", catta_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(catta_is_valid_service_type_generic("_foo._bar._waldo"));
+    assert(!catta_is_valid_service_type_strict("_foo._bar._waldo"));
+    assert(!catta_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(catta_is_valid_service_type_generic("_foo._tcp"));
+    assert(catta_is_valid_service_type_strict("_foo._tcp"));
+    assert(!catta_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(!catta_is_valid_service_type_generic("_foo._bar.waldo"));
+    assert(!catta_is_valid_service_type_strict("_foo._bar.waldo"));
+    assert(!catta_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(!catta_is_valid_service_type_generic(""));
+    assert(!catta_is_valid_service_type_strict(""));
+    assert(!catta_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"));
+    assert(catta_is_valid_service_type_generic("_foo._sub._bar._tcp"));
+    assert(!catta_is_valid_service_type_strict("_foo._sub._bar._tcp"));
+    assert(catta_is_valid_service_subtype("_foo._sub._bar._tcp"));
 
-    printf("%s\n", avahi_get_type_from_subtype("_foo._sub._bar._tcp"));
+    printf("%s\n", catta_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(!catta_is_valid_host_name("sf.ooo."));
+    assert(catta_is_valid_host_name("sfooo."));
+    assert(catta_is_valid_host_name("sfooo"));
 
-    assert(avahi_is_valid_domain_name("."));
-    assert(avahi_is_valid_domain_name(""));
+    assert(catta_is_valid_domain_name("."));
+    assert(catta_is_valid_domain_name(""));
 
-    assert(avahi_normalize_name(".", t, sizeof(t)));
-    assert(avahi_normalize_name("", t, sizeof(t)));
+    assert(catta_normalize_name(".", t, sizeof(t)));
+    assert(catta_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."));
+    assert(!catta_is_valid_fqdn("."));
+    assert(!catta_is_valid_fqdn(""));
+    assert(!catta_is_valid_fqdn("foo"));
+    assert(catta_is_valid_fqdn("foo.bar"));
+    assert(catta_is_valid_fqdn("foo.bar."));
+    assert(catta_is_valid_fqdn("gnurz.foo.bar."));
+    assert(!catta_is_valid_fqdn("192.168.50.1"));
+    assert(!catta_is_valid_fqdn("::1"));
+    assert(!catta_is_valid_fqdn(".192.168.50.1."));
 
     return 0;
 }
index 14ba43d0446eef62de5703bd5a12bd7d9bb1a869..c43820acfd116295f6b6e356cddd85954d941d4f 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 #include <stdio.h>
 
-#include <avahi/domain.h>
-#include <avahi/malloc.h>
+#include <catta/domain.h>
+#include <catta/malloc.h>
 
 #include "../src/hashmap.h"
 #include "../src/util.h"
 
-int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
+int main(CATTA_GCC_UNUSED int argc, CATTA_GCC_UNUSED char *argv[]) {
     unsigned n;
-    AvahiHashmap *m;
+    CattaHashmap *m;
     const char *t;
 
-    m = avahi_hashmap_new(avahi_string_hash, avahi_string_equal, avahi_free, avahi_free);
+    m = catta_hashmap_new(catta_string_hash, catta_string_equal, catta_free, catta_free);
 
-    avahi_hashmap_insert(m, avahi_strdup("bla"), avahi_strdup("#1"));
-    avahi_hashmap_insert(m, avahi_strdup("bla2"), avahi_strdup("asdf"));
-    avahi_hashmap_insert(m, avahi_strdup("gurke"), avahi_strdup("ffsdf"));
-    avahi_hashmap_insert(m, avahi_strdup("blubb"), avahi_strdup("sadfsd"));
-    avahi_hashmap_insert(m, avahi_strdup("bla"), avahi_strdup("#2"));
+    catta_hashmap_insert(m, catta_strdup("bla"), catta_strdup("#1"));
+    catta_hashmap_insert(m, catta_strdup("bla2"), catta_strdup("asdf"));
+    catta_hashmap_insert(m, catta_strdup("gurke"), catta_strdup("ffsdf"));
+    catta_hashmap_insert(m, catta_strdup("blubb"), catta_strdup("sadfsd"));
+    catta_hashmap_insert(m, catta_strdup("bla"), catta_strdup("#2"));
 
     for (n = 0; n < 1000; n ++)
-        avahi_hashmap_insert(m, avahi_strdup_printf("key %u", n), avahi_strdup_printf("value %u", n));
+        catta_hashmap_insert(m, catta_strdup_printf("key %u", n), catta_strdup_printf("value %u", n));
 
-    printf("%s\n", (const char*) avahi_hashmap_lookup(m, "bla"));
+    printf("%s\n", (const char*) catta_hashmap_lookup(m, "bla"));
 
-    avahi_hashmap_replace(m, avahi_strdup("bla"), avahi_strdup("#3"));
+    catta_hashmap_replace(m, catta_strdup("bla"), catta_strdup("#3"));
 
-    printf("%s\n", (const char*) avahi_hashmap_lookup(m, "bla"));
+    printf("%s\n", (const char*) catta_hashmap_lookup(m, "bla"));
 
-    avahi_hashmap_remove(m, "bla");
+    catta_hashmap_remove(m, "bla");
 
-    t = (const char*) avahi_hashmap_lookup(m, "bla");
+    t = (const char*) catta_hashmap_lookup(m, "bla");
     printf("%s\n", t ? t : "(null)");
 
-    avahi_hashmap_free(m);
+    catta_hashmap_free(m);
 
     return 0;
 }
index 579c75d0af5dd51322fd86e5ed4d12f73b6b135f..b01068cf9a192b4d7c684a0b42052b6d58f0f2ac 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
@@ -26,7 +26,7 @@
 #include <stdio.h>
 #include <assert.h>
 
-#include <avahi/gccmacro.h>
+#include <catta/gccmacro.h>
 
 #include "../src/prioq.h"
 
@@ -43,7 +43,7 @@ static int compare_ptr(const void* a, const void* b) {
     return a < b ? -1 : (a > b ? 1 : 0);
 }
 
-static void rec(AvahiPrioQueueNode *n) {
+static void rec(CattaPrioQueueNode *n) {
     if (!n)
         return;
 
@@ -80,17 +80,17 @@ static void rec(AvahiPrioQueueNode *n) {
     rec(n->right);
 }
 
-int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
-    AvahiPrioQueue *q, *q2;
+int main(CATTA_GCC_UNUSED int argc, CATTA_GCC_UNUSED char *argv[]) {
+    CattaPrioQueue *q, *q2;
     int i;
 
-    q = avahi_prio_queue_new(compare_int);
-    q2 = avahi_prio_queue_new(compare_ptr);
+    q = catta_prio_queue_new(compare_int);
+    q2 = catta_prio_queue_new(compare_ptr);
 
     srand(time(NULL));
 
     for (i = 0; i < 10000; i++)
-        avahi_prio_queue_put(q2, avahi_prio_queue_put(q, INT_TO_POINTER(random() & 0xFFFF)));
+        catta_prio_queue_put(q2, catta_prio_queue_put(q, INT_TO_POINTER(random() & 0xFFFF)));
 
     while (q2->root) {
         rec(q->root);
@@ -98,10 +98,10 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
 
         assert(q->n_nodes == q2->n_nodes);
 
-        printf("%i\n", POINTER_TO_INT(((AvahiPrioQueueNode*)q2->root->data)->data));
+        printf("%i\n", POINTER_TO_INT(((CattaPrioQueueNode*)q2->root->data)->data));
 
-        avahi_prio_queue_remove(q, q2->root->data);
-        avahi_prio_queue_remove(q2, q2->root);
+        catta_prio_queue_remove(q, q2->root->data);
+        catta_prio_queue_remove(q2, q2->root);
     }
 
 
@@ -110,11 +110,11 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
 /*         int v = GPOINTER_TO_INT(q->root->data); */
 /*         rec(q->root); */
 /*         printf("%i\n", v); */
-/*         avahi_prio_queue_remove(q, q->root); */
+/*         catta_prio_queue_remove(q, q->root); */
 /*         assert(v >= prev); */
 /*         prev = v; */
 /*     } */
 
-    avahi_prio_queue_free(q);
+    catta_prio_queue_free(q);
     return 0;
 }
index a6f16ac80ee861ec05a523e6fd5fca9c56e5cc6b..3f48c4508ccce72c6789a4f2a1baaf0b31ac4f31 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <stdlib.h>
 #include <assert.h>
 
-#include <avahi/malloc.h>
-#include <avahi/simple-watch.h>
-#include <avahi/alternative.h>
-#include <avahi/timeval.h>
+#include <catta/malloc.h>
+#include <catta/simple-watch.h>
+#include <catta/alternative.h>
+#include <catta/timeval.h>
 
-#include <avahi/core.h>
-#include <avahi/log.h>
-#include <avahi/publish.h>
-#include <avahi/lookup.h>
+#include <catta/core.h>
+#include <catta/log.h>
+#include <catta/publish.h>
+#include <catta/lookup.h>
 
 #define DOMAIN NULL
 #define SERVICE_TYPE "_http._tcp"
 
-static AvahiSServiceBrowser *service_browser1 = NULL, *service_browser2 = NULL;
-static const AvahiPoll * poll_api = NULL;
-static AvahiServer *server = NULL;
-static AvahiSimplePoll *simple_poll;
+static CattaSServiceBrowser *service_browser1 = NULL, *service_browser2 = NULL;
+static const CattaPoll * poll_api = NULL;
+static CattaServer *server = NULL;
+static CattaSimplePoll *simple_poll;
 
-static const char *browser_event_to_string(AvahiBrowserEvent event) {
+static const char *browser_event_to_string(CattaBrowserEvent event) {
     switch (event) {
-        case AVAHI_BROWSER_NEW : return "NEW";
-        case AVAHI_BROWSER_REMOVE : return "REMOVE";
-        case AVAHI_BROWSER_CACHE_EXHAUSTED : return "CACHE_EXHAUSTED";
-        case AVAHI_BROWSER_ALL_FOR_NOW : return "ALL_FOR_NOW";
-        case AVAHI_BROWSER_FAILURE : return "FAILURE";
+        case CATTA_BROWSER_NEW : return "NEW";
+        case CATTA_BROWSER_REMOVE : return "REMOVE";
+        case CATTA_BROWSER_CACHE_EXHAUSTED : return "CACHE_EXHAUSTED";
+        case CATTA_BROWSER_ALL_FOR_NOW : return "ALL_FOR_NOW";
+        case CATTA_BROWSER_FAILURE : return "FAILURE";
     }
 
     abort();
 }
 
 static void sb_callback(
-    AvahiSServiceBrowser *b,
-    AvahiIfIndex iface,
-    AvahiProtocol protocol,
-    AvahiBrowserEvent event,
+    CattaSServiceBrowser *b,
+    CattaIfIndex iface,
+    CattaProtocol protocol,
+    CattaBrowserEvent event,
     const char *name,
     const char *service_type,
     const char *domain,
-    AvahiLookupResultFlags flags,
-    AVAHI_GCC_UNUSED void* userdata) {
-    avahi_log_debug("SB%i: (%i.%s) <%s> as <%s> in <%s> [%s] cached=%i", b == service_browser1 ? 1 : 2, iface, avahi_proto_to_string(protocol), name, service_type, domain, browser_event_to_string(event), !!(flags & AVAHI_LOOKUP_RESULT_CACHED));
+    CattaLookupResultFlags flags,
+    CATTA_GCC_UNUSED void* userdata) {
+    catta_log_debug("SB%i: (%i.%s) <%s> as <%s> in <%s> [%s] cached=%i", b == service_browser1 ? 1 : 2, iface, catta_proto_to_string(protocol), name, service_type, domain, browser_event_to_string(event), !!(flags & CATTA_LOOKUP_RESULT_CACHED));
 }
 
-static void create_second_service_browser(AvahiTimeout *timeout, AVAHI_GCC_UNUSED void* userdata) {
+static void create_second_service_browser(CattaTimeout *timeout, CATTA_GCC_UNUSED void* userdata) {
 
-    service_browser2 = avahi_s_service_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, SERVICE_TYPE, DOMAIN, 0, sb_callback, NULL);
+    service_browser2 = catta_s_service_browser_new(server, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, SERVICE_TYPE, DOMAIN, 0, sb_callback, NULL);
     assert(service_browser2);
 
     poll_api->timeout_free(timeout);
 }
 
-static void quit(AVAHI_GCC_UNUSED AvahiTimeout *timeout, AVAHI_GCC_UNUSED void *userdata) {
-    avahi_simple_poll_quit(simple_poll);
+static void quit(CATTA_GCC_UNUSED CattaTimeout *timeout, CATTA_GCC_UNUSED void *userdata) {
+    catta_simple_poll_quit(simple_poll);
 }
 
-int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
+int main(CATTA_GCC_UNUSED int argc, CATTA_GCC_UNUSED char *argv[]) {
     struct timeval tv;
-    AvahiServerConfig config;
+    CattaServerConfig config;
 
-    simple_poll = avahi_simple_poll_new();
+    simple_poll = catta_simple_poll_new();
     assert(simple_poll);
 
-    poll_api = avahi_simple_poll_get(simple_poll);
+    poll_api = catta_simple_poll_get(simple_poll);
     assert(poll_api);
 
-    avahi_server_config_init(&config);
+    catta_server_config_init(&config);
     config.publish_hinfo = 0;
     config.publish_addresses = 0;
     config.publish_workstation = 0;
     config.publish_domain = 0;
 
-    avahi_address_parse("192.168.50.1", AVAHI_PROTO_UNSPEC, &config.wide_area_servers[0]);
+    catta_address_parse("192.168.50.1", CATTA_PROTO_UNSPEC, &config.wide_area_servers[0]);
     config.n_wide_area_servers = 1;
     config.enable_wide_area = 1;
 
-    server = avahi_server_new(poll_api, &config, NULL, NULL, NULL);
+    server = catta_server_new(poll_api, &config, NULL, NULL, NULL);
     assert(server);
-    avahi_server_config_free(&config);
+    catta_server_config_free(&config);
 
-    service_browser1 = avahi_s_service_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, SERVICE_TYPE, DOMAIN, 0, sb_callback, NULL);
+    service_browser1 = catta_s_service_browser_new(server, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, SERVICE_TYPE, DOMAIN, 0, sb_callback, NULL);
     assert(service_browser1);
 
-    poll_api->timeout_new(poll_api, avahi_elapse_time(&tv, 10000, 0), create_second_service_browser, NULL);
+    poll_api->timeout_new(poll_api, catta_elapse_time(&tv, 10000, 0), create_second_service_browser, NULL);
 
-    poll_api->timeout_new(poll_api, avahi_elapse_time(&tv, 60000, 0), quit, NULL);
+    poll_api->timeout_new(poll_api, catta_elapse_time(&tv, 60000, 0), quit, NULL);
 
 
     for (;;)
-        if (avahi_simple_poll_iterate(simple_poll, -1) != 0)
+        if (catta_simple_poll_iterate(simple_poll, -1) != 0)
             break;
 
-    avahi_server_free(server);
-    avahi_simple_poll_free(simple_poll);
+    catta_server_free(server);
+    catta_simple_poll_free(simple_poll);
 
     return 0;
 }
index dbfe269cb371047267aa187c88387968c789f0f9..496f80a6f460f7fc32a5c7c80b778ff6fc95dc9a 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <stdio.h>
 #include <assert.h>
 
-#include <avahi/strlst.h>
-#include <avahi/malloc.h>
+#include <catta/strlst.h>
+#include <catta/malloc.h>
 
-int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
+int main(CATTA_GCC_UNUSED int argc, CATTA_GCC_UNUSED char *argv[]) {
     char *t, *v;
     uint8_t data[1024];
-    AvahiStringList *a = NULL, *b, *p;
+    CattaStringList *a = NULL, *b, *p;
     size_t size, n;
     int r;
 
-    a = avahi_string_list_new("prefix", "a", "b", NULL);
+    a = catta_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 = catta_string_list_add(a, "start");
+    a = catta_string_list_add(a, "foo=99");
+    a = catta_string_list_add(a, "bar");
+    a = catta_string_list_add(a, "");
+    a = catta_string_list_add(a, "");
+    a = catta_string_list_add(a, "quux");
+    a = catta_string_list_add(a, "");
+    a = catta_string_list_add_arbitrary(a, (const uint8_t*) "null\0null", 9);
+    a = catta_string_list_add_printf(a, "seven=%i %c", 7, 'x');
+    a = catta_string_list_add_pair(a, "blubb", "blaa");
+    a = catta_string_list_add_pair(a, "uxknurz", NULL);
+    a = catta_string_list_add_pair_arbitrary(a, "uxknurz2", (const uint8_t*) "blafasel\0oerks", 14);
 
-    a = avahi_string_list_add(a, "end");
+    a = catta_string_list_add(a, "end");
 
-    t = avahi_string_list_to_string(a);
+    t = catta_string_list_to_string(a);
     printf("--%s--\n", t);
-    avahi_free(t);
+    catta_free(t);
 
-    n = avahi_string_list_serialize(a, NULL, 0);
-    size = avahi_string_list_serialize(a, data, sizeof(data));
+    n = catta_string_list_serialize(a, NULL, 0);
+    size = catta_string_list_serialize(a, data, sizeof(data));
     assert(size == n);
 
     printf("%zu\n", size);
@@ -70,57 +70,57 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
 
     printf("\n");
 
-    assert(avahi_string_list_parse(data, size, &b) == 0);
+    assert(catta_string_list_parse(data, size, &b) == 0);
 
-    printf("equal: %i\n", avahi_string_list_equal(a, b));
+    printf("equal: %i\n", catta_string_list_equal(a, b));
 
-    t = avahi_string_list_to_string(b);
+    t = catta_string_list_to_string(b);
     printf("--%s--\n", t);
-    avahi_free(t);
+    catta_free(t);
 
-    avahi_string_list_free(b);
+    catta_string_list_free(b);
 
-    b = avahi_string_list_copy(a);
+    b = catta_string_list_copy(a);
 
-    assert(avahi_string_list_equal(a, b));
+    assert(catta_string_list_equal(a, b));
 
-    t = avahi_string_list_to_string(b);
+    t = catta_string_list_to_string(b);
     printf("--%s--\n", t);
-    avahi_free(t);
+    catta_free(t);
 
-    p = avahi_string_list_find(a, "seven");
+    p = catta_string_list_find(a, "seven");
     assert(p);
 
-    r = avahi_string_list_get_pair(p, &t, &v, NULL);
+    r = catta_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);
+    catta_free(t);
+    catta_free(v);
 
-    p = avahi_string_list_find(a, "quux");
+    p = catta_string_list_find(a, "quux");
     assert(p);
 
-    r = avahi_string_list_get_pair(p, &t, &v, NULL);
+    r = catta_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);
+    catta_free(t);
+    catta_free(v);
 
-    avahi_string_list_free(a);
-    avahi_string_list_free(b);
+    catta_string_list_free(a);
+    catta_string_list_free(b);
 
-    n = avahi_string_list_serialize(NULL, NULL, 0);
-    size = avahi_string_list_serialize(NULL, data, sizeof(data));
+    n = catta_string_list_serialize(NULL, NULL, 0);
+    size = catta_string_list_serialize(NULL, data, sizeof(data));
     assert(size == 1);
     assert(size == n);
 
-    assert(avahi_string_list_parse(data, size, &a) == 0);
+    assert(catta_string_list_parse(data, size, &a) == 0);
     assert(!a);
 
     return 0;
index dbfc92d06943e535fe64f57419821d2be1d0f103..ab811a8e6e140dedc07b9156e7607c76f44fce67 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <assert.h>
 #include <stdlib.h>
 
-#include <avahi/timeval.h>
-#include <avahi/simple-watch.h>
-#include <avahi/log.h>
+#include <catta/timeval.h>
+#include <catta/simple-watch.h>
+#include <catta/log.h>
 
 #include "../src/timeeventq.h"
 
 #define POINTER_TO_INT(p) ((int) (long) (p))
 #define INT_TO_POINTER(i) ((void*) (long) (i))
 
-static AvahiTimeEventQueue *q = NULL;
+static CattaTimeEventQueue *q = NULL;
 
-static void callback(AvahiTimeEvent*e, void* userdata) {
+static void callback(CattaTimeEvent*e, void* userdata) {
     struct timeval tv = {0, 0};
     assert(e);
-    avahi_log_info("callback(%i)", POINTER_TO_INT(userdata));
-    avahi_elapse_time(&tv, 1000, 100);
-    avahi_time_event_update(e, &tv);
+    catta_log_info("callback(%i)", POINTER_TO_INT(userdata));
+    catta_elapse_time(&tv, 1000, 100);
+    catta_time_event_update(e, &tv);
 }
 
-int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
+int main(CATTA_GCC_UNUSED int argc, CATTA_GCC_UNUSED char *argv[]) {
     struct timeval tv;
-    AvahiSimplePoll *s;
+    CattaSimplePoll *s;
 
-    s = avahi_simple_poll_new();
+    s = catta_simple_poll_new();
 
-    q = avahi_time_event_queue_new(avahi_simple_poll_get(s));
+    q = catta_time_event_queue_new(catta_simple_poll_get(s));
 
-    avahi_time_event_new(q, avahi_elapse_time(&tv, 5000, 100), callback, INT_TO_POINTER(1));
-    avahi_time_event_new(q, avahi_elapse_time(&tv, 5000, 100), callback, INT_TO_POINTER(2));
+    catta_time_event_new(q, catta_elapse_time(&tv, 5000, 100), callback, INT_TO_POINTER(1));
+    catta_time_event_new(q, catta_elapse_time(&tv, 5000, 100), callback, INT_TO_POINTER(2));
 
-    avahi_log_info("starting");
+    catta_log_info("starting");
 
     for (;;)
-        if (avahi_simple_poll_iterate(s, -1) != 0)
+        if (catta_simple_poll_iterate(s, -1) != 0)
             break;
 
-    avahi_time_event_queue_free(q);
-    avahi_simple_poll_free(s);
+    catta_time_event_queue_free(q);
+    catta_simple_poll_free(s);
 
     return 0;
 }
index 461b97f54ac929bd5982a492ce50c54f3af6f12e..75f50d4e3a77db81e4bfadc6b5a8234e3ed40507 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 #include <stdio.h>
 
-#include <avahi/gccmacro.h>
-#include <avahi/timeval.h>
+#include <catta/gccmacro.h>
+#include <catta/timeval.h>
 
-int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
+int main(CATTA_GCC_UNUSED int argc, CATTA_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);
+    catta_timeval_add(&a, -50);
 
     printf("%li.%li\n", a.tv_sec, a.tv_usec);
 
-    printf("%lli\n", (long long) avahi_timeval_diff(&a, &b));
+    printf("%lli\n", (long long) catta_timeval_diff(&a, &b));
 
     return 0;
 }
index dcbba80c1d19b371444eb57417bea161de2d56c1..b9ed3157ac18e27a0c36ac5147354e1d7a8f3e16 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <assert.h>
 #include <stdlib.h>
 
-#include <avahi/error.h>
-#include <avahi/watch.h>
-#include <avahi/simple-watch.h>
-#include <avahi/malloc.h>
-#include <avahi/alternative.h>
-#include <avahi/timeval.h>
+#include <catta/error.h>
+#include <catta/watch.h>
+#include <catta/simple-watch.h>
+#include <catta/malloc.h>
+#include <catta/alternative.h>
+#include <catta/timeval.h>
 
-#include <avahi/core.h>
-#include <avahi/log.h>
-#include <avahi/publish.h>
-#include <avahi/lookup.h>
+#include <catta/core.h>
+#include <catta/log.h>
+#include <catta/publish.h>
+#include <catta/lookup.h>
 
-static AvahiSEntryGroup *group = NULL;
+static CattaSEntryGroup *group = NULL;
 
-static void server_callback(AvahiServer *s, AvahiServerState state, AVAHI_GCC_UNUSED void* userdata) {
+static void server_callback(CattaServer *s, CattaServerState state, CATTA_GCC_UNUSED void* userdata) {
 
-    avahi_log_debug("server state: %i", state);
+    catta_log_debug("server state: %i", state);
 
-    if (state == AVAHI_SERVER_RUNNING) {
+    if (state == CATTA_SERVER_RUNNING) {
         int ret;
 
-        group = avahi_s_entry_group_new(s, NULL, NULL);
+        group = catta_s_entry_group_new(s, NULL, NULL);
         assert(group);
 
-        ret = avahi_server_add_service(s, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "foo", "_http._tcp", NULL, NULL, 80, "test1", NULL);
-        assert(ret == AVAHI_OK);
+        ret = catta_server_add_service(s, group, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, 0, "foo", "_http._tcp", NULL, NULL, 80, "test1", NULL);
+        assert(ret == CATTA_OK);
 
-        avahi_s_entry_group_commit(group);
+        catta_s_entry_group_commit(group);
     }
 }
 
-static void modify_txt_callback(AVAHI_GCC_UNUSED AvahiTimeout *e, void *userdata) {
+static void modify_txt_callback(CATTA_GCC_UNUSED CattaTimeout *e, void *userdata) {
     int ret;
-    AvahiServer *s = userdata;
+    CattaServer *s = userdata;
 
-    avahi_log_debug("modifying");
+    catta_log_debug("modifying");
 
-    ret = avahi_server_update_service_txt(s, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "foo", "_http._tcp", NULL, "test2", NULL);
-    assert(ret == AVAHI_OK);
+    ret = catta_server_update_service_txt(s, group, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, 0, "foo", "_http._tcp", NULL, "test2", NULL);
+    assert(ret == CATTA_OK);
 }
 
-int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
-    AvahiSimplePoll *simple_poll;
-    const AvahiPoll *poll_api;
-    AvahiServer *server;
+int main(CATTA_GCC_UNUSED int argc, CATTA_GCC_UNUSED char *argv[]) {
+    CattaSimplePoll *simple_poll;
+    const CattaPoll *poll_api;
+    CattaServer *server;
     struct timeval tv;
-    AvahiServerConfig config;
+    CattaServerConfig config;
 
-    simple_poll = avahi_simple_poll_new();
+    simple_poll = catta_simple_poll_new();
     assert(simple_poll);
 
-    poll_api = avahi_simple_poll_get(simple_poll);
+    poll_api = catta_simple_poll_get(simple_poll);
     assert(poll_api);
 
-    avahi_server_config_init(&config);
+    catta_server_config_init(&config);
     config.publish_domain = config.publish_workstation = config.use_ipv6 = config.publish_hinfo = 0;
-    server = avahi_server_new(poll_api, &config, server_callback, NULL, NULL);
+    server = catta_server_new(poll_api, &config, server_callback, NULL, NULL);
     assert(server);
-    avahi_server_config_free(&config);
+    catta_server_config_free(&config);
 
-    poll_api->timeout_new(poll_api, avahi_elapse_time(&tv, 1000*10, 0), modify_txt_callback, server);
+    poll_api->timeout_new(poll_api, catta_elapse_time(&tv, 1000*10, 0), modify_txt_callback, server);
 
-    avahi_simple_poll_loop(simple_poll);
+    catta_simple_poll_loop(simple_poll);
     return 0;
 }
index 3ef0af3c9d2e534a8b03ed9ed0d90f3dd3371172..e3c1e489b49a67a852b9e753656948c2fda3e490 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 
 #include <assert.h>
 
-#include <avahi/gccmacro.h>
+#include <catta/gccmacro.h>
 
 #include "../src/utf8.h"
 
-int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
+int main(CATTA_GCC_UNUSED int argc, CATTA_GCC_UNUSED char *argv[]) {
 
-    assert(avahi_utf8_valid("hallo"));
-    assert(!avahi_utf8_valid("üxknürz"));
-    assert(avahi_utf8_valid("üxknürz"));
+    assert(catta_utf8_valid("hallo"));
+    assert(!catta_utf8_valid("üxknürz"));
+    assert(catta_utf8_valid("üxknürz"));
 
     return 0;
 }
index 51e6016a5075e1cac6cdfefbfabe49a456626a3d..8ab5857db8715fc7ef90c7469114311ca8f50939 100644 (file)
@@ -1,18 +1,18 @@
 /***
-  This file is part of avahi.
+  This file is part of catta.
 
-  avahi is free software; you can redistribute it and/or modify it
+  catta 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
+  catta 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
+  License along with catta; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <errno.h>
 #include <string.h>
 
-#include <avahi/watch.h>
-#include <avahi/timeval.h>
-#include <avahi/gccmacro.h>
+#include <catta/watch.h>
+#include <catta/timeval.h>
+#include <catta/gccmacro.h>
 
-static const AvahiPoll *api = NULL;
+static const CattaPoll *api = NULL;
 
 #ifndef USE_THREAD
-#include <avahi/simple-watch.h>
-static AvahiSimplePoll *simple_poll = NULL;
+#include <catta/simple-watch.h>
+static CattaSimplePoll *simple_poll = NULL;
 #else
-#include <avahi/thread-watch.h>
-static AvahiThreadedPoll *threaded_poll = NULL;
+#include <catta/thread-watch.h>
+static CattaThreadedPoll *threaded_poll = NULL;
 #endif
 
-static void callback(AvahiWatch *w, int fd, AvahiWatchEvent event, AVAHI_GCC_UNUSED void *userdata) {
+static void callback(CattaWatch *w, int fd, CattaWatchEvent event, CATTA_GCC_UNUSED void *userdata) {
 
-    if (event & AVAHI_WATCH_IN) {
+    if (event & CATTA_WATCH_IN) {
         ssize_t r;
         char c;
 
@@ -57,7 +57,7 @@ static void callback(AvahiWatch *w, int fd, AvahiWatchEvent event, AVAHI_GCC_UNU
     }
 }
 
-static void wakeup(AvahiTimeout *t, AVAHI_GCC_UNUSED void *userdata) {
+static void wakeup(CattaTimeout *t, CATTA_GCC_UNUSED void *userdata) {
     static int i = 0;
     struct timeval tv;
 
@@ -65,49 +65,49 @@ static void wakeup(AvahiTimeout *t, AVAHI_GCC_UNUSED void *userdata) {
 
     if (i > 10) {
 #ifndef USE_THREAD
-        avahi_simple_poll_quit(simple_poll);
+        catta_simple_poll_quit(simple_poll);
 #else
-        avahi_threaded_poll_quit(threaded_poll);
+        catta_threaded_poll_quit(threaded_poll);
 #endif
     } else {
-        avahi_elapse_time(&tv, 1000, 0);
+        catta_elapse_time(&tv, 1000, 0);
         api->timeout_update(t, &tv);
     }
 }
 
-int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
+int main(CATTA_GCC_UNUSED int argc, CATTA_GCC_UNUSED char *argv[]) {
     struct timeval tv;
 
 #ifndef USE_THREAD
-    simple_poll = avahi_simple_poll_new();
+    simple_poll = catta_simple_poll_new();
     assert(simple_poll);
-    api = avahi_simple_poll_get(simple_poll);
+    api = catta_simple_poll_get(simple_poll);
     assert(api);
 #else
-    threaded_poll = avahi_threaded_poll_new();
+    threaded_poll = catta_threaded_poll_new();
     assert(threaded_poll);
-    api = avahi_threaded_poll_get(threaded_poll);
+    api = catta_threaded_poll_get(threaded_poll);
     assert(api);
 #endif
 
-    api->watch_new(api, 0, AVAHI_WATCH_IN, callback, NULL);
+    api->watch_new(api, 0, CATTA_WATCH_IN, callback, NULL);
 
-    avahi_elapse_time(&tv, 1000, 0);
+    catta_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);
+    catta_simple_poll_loop(simple_poll);
+    catta_simple_poll_free(simple_poll);
 
 #else
-    avahi_threaded_poll_start(threaded_poll);
+    catta_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);
+    catta_threaded_poll_free(threaded_poll);
 
 #endif