summaryrefslogtreecommitdiffstats
path: root/avahi-core
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-08-12 19:09:50 +0000
committerLennart Poettering <lennart@poettering.net>2005-08-12 19:09:50 +0000
commit5d047523c87ba11aad8c384f7ffde25b4dd746ed (patch)
treeb160aa74a0c9e77db3bc9b864f503771adaa6758 /avahi-core
parentf8c479234af6b676027df4fb6b38ce8e22949049 (diff)
implement new main loop abstraction layer
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@305 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-core')
-rw-r--r--avahi-core/Makefile.am13
-rw-r--r--avahi-core/announce.c2
-rw-r--r--avahi-core/avahi-test.c6
-rw-r--r--avahi-core/browse.c2
-rw-r--r--avahi-core/cache.c4
-rw-r--r--avahi-core/conformance-test.c2
-rw-r--r--avahi-core/iface.h2
-rw-r--r--avahi-core/probe-sched.c2
-rw-r--r--avahi-core/probe-sched.h2
-rw-r--r--avahi-core/query-sched.c2
-rw-r--r--avahi-core/query-sched.h2
-rw-r--r--avahi-core/resolve-address.c2
-rw-r--r--avahi-core/resolve-host-name.c2
-rw-r--r--avahi-core/resolve-service.c2
-rw-r--r--avahi-core/response-sched.c2
-rw-r--r--avahi-core/response-sched.h2
-rw-r--r--avahi-core/server.c6
-rw-r--r--avahi-core/timeeventq-test.c2
-rw-r--r--avahi-core/timeeventq.c2
-rw-r--r--avahi-core/timeval-test.c41
-rw-r--r--avahi-core/timeval.c101
-rw-r--r--avahi-core/timeval.h43
22 files changed, 25 insertions, 219 deletions
diff --git a/avahi-core/Makefile.am b/avahi-core/Makefile.am
index e15f295..c71d6ed 100644
--- a/avahi-core/Makefile.am
+++ b/avahi-core/Makefile.am
@@ -24,7 +24,6 @@ AM_CFLAGS+=$(GLIB20_CFLAGS)
AM_LDADD=$(GLIB20_LIBS)
# Import stuff from avahi-common
-AM_CFLAGS+=-I$(top_srcdir)/avahi-common
COMMON_LDADD=../avahi-common/libavahi-common.la
# This cool debug trap works on i386/gcc only
@@ -46,8 +45,7 @@ noinst_PROGRAMS = \
conformance-test \
avahi-reflector \
dns-test \
- timeeventq-test \
- timeval-test
+ timeeventq-test
libavahi_core_la_SOURCES = \
timeeventq.c timeeventq.h\
@@ -75,8 +73,8 @@ libavahi_core_la_SOURCES = \
log.c log.h \
browse-dns-server.c \
fdutil.h fdutil.c \
- timeval.h timeval.c \
util.c util.h
+
libavahi_core_la_CFLAGS = $(AM_CFLAGS)
libavahi_core_la_LIBADD = $(AM_LDADD) $(COMMON_LDADD)
@@ -113,17 +111,10 @@ dns_test_LDADD = $(AM_LDADD) $(COMMON_LDADD)
timeeventq_test_SOURCES = \
timeeventq-test.c \
timeeventq.h timeeventq.c \
- timeval.c timeval.h \
prioq.h prioq.c
timeeventq_test_CFLAGS = $(AM_CFLAGS)
timeeventq_test_LDADD = $(AM_LDADD) $(COMMON_LDADD)
-timeval_test_SOURCES = \
- timeval.c timeval.h \
- timeval-test.c
-timeval_test_CFLAGS = $(AM_CFLAGS)
-timeval_test_LDADD = $(AM_LDADD)
-
valgrind: avahi-test
libtool --mode=execute valgrind ./avahi-test
diff --git a/avahi-core/announce.c b/avahi-core/announce.c
index 3787f8f..9a6d505 100644
--- a/avahi-core/announce.c
+++ b/avahi-core/announce.c
@@ -23,8 +23,8 @@
#include <config.h>
#endif
+#include <avahi-common/timeval.h>
#include "announce.h"
-#include "timeval.h"
#define AVAHI_ANNOUNCEMENT_JITTER_MSEC 250
#define AVAHI_PROBE_JITTER_MSEC 250
diff --git a/avahi-core/avahi-test.c b/avahi-core/avahi-test.c
index 5db2473..7156d06 100644
--- a/avahi-core/avahi-test.c
+++ b/avahi-core/avahi-test.c
@@ -152,7 +152,7 @@ fail:
group = NULL;
}
-static void hnr_callback(AvahiHostNameResolver *r, AvahiIfIndex iface, AvahiProtocol protocol, AvahiBrowserEvent event, const gchar *hostname, const AvahiAddress *a, gpointer userdata) {
+static void hnr_callback(AvahiHostNameResolver *r, AvahiIfIndex iface, AvahiProtocol protocol, AvahiResolverEvent event, const gchar *hostname, const AvahiAddress *a, gpointer userdata) {
gchar t[64];
if (a)
@@ -161,7 +161,7 @@ static void hnr_callback(AvahiHostNameResolver *r, AvahiIfIndex iface, AvahiProt
avahi_log_debug("HNR: (%i.%i) <%s> -> %s [%s]", iface, protocol, hostname, a ? t : "n/a", event == AVAHI_RESOLVER_FOUND ? "found" : "timeout");
}
-static void ar_callback(AvahiAddressResolver *r, AvahiIfIndex iface, AvahiProtocol protocol, AvahiBrowserEvent event, const AvahiAddress *a, const gchar *hostname, gpointer userdata) {
+static void ar_callback(AvahiAddressResolver *r, AvahiIfIndex iface, AvahiProtocol protocol, AvahiResolverEvent event, const AvahiAddress *a, const gchar *hostname, gpointer userdata) {
gchar t[64];
avahi_address_snprint(t, sizeof(t), a);
@@ -183,7 +183,7 @@ static void sb_callback(AvahiServiceBrowser *b, AvahiIfIndex iface, AvahiProtoco
avahi_log_debug("SB: (%i.%i) <%s> as %s in <%s> [%s]", iface, protocol, name, service_type, domain, event == AVAHI_BROWSER_NEW ? "new" : "remove");
}
-static void sr_callback(AvahiServiceResolver *r, AvahiIfIndex iface, AvahiProtocol protocol, AvahiBrowserEvent event, const gchar *name, const gchar*service_type, const gchar*domain_name, const gchar*hostname, const AvahiAddress *a, guint16 port, AvahiStringList *txt, gpointer userdata) {
+static void sr_callback(AvahiServiceResolver *r, AvahiIfIndex iface, AvahiProtocol protocol, AvahiResolverEvent event, const gchar *name, const gchar*service_type, const gchar*domain_name, const gchar*hostname, const AvahiAddress *a, guint16 port, AvahiStringList *txt, gpointer userdata) {
if (event == AVAHI_RESOLVER_TIMEOUT)
avahi_log_debug("SR: (%i.%i) <%s> as %s in <%s> [timeout]", iface, protocol, name, service_type, domain_name);
diff --git a/avahi-core/browse.c b/avahi-core/browse.c
index e2d996e..6357095 100644
--- a/avahi-core/browse.c
+++ b/avahi-core/browse.c
@@ -23,8 +23,8 @@
#include <config.h>
#endif
+#include <avahi-common/timeval.h>
#include "browse.h"
-#include "timeval.h"
#include "log.h"
struct AvahiRecordBrowser {
diff --git a/avahi-core/cache.c b/avahi-core/cache.c
index dddd5ee..ebe78fc 100644
--- a/avahi-core/cache.c
+++ b/avahi-core/cache.c
@@ -25,7 +25,7 @@
#include <string.h>
-#include "timeval.h"
+#include <avahi-common/timeval.h>
#include "cache.h"
#include "log.h"
@@ -215,10 +215,10 @@ static void update_time_event(AvahiCache *c, AvahiCacheEntry *e) {
}
static void next_expiry(AvahiCache *c, AvahiCacheEntry *e, guint percent) {
+ AvahiUsec usec;
g_assert(c);
g_assert(e);
g_assert(percent > 0 && percent <= 100);
- AvahiUsec usec;
/* gchar *txt; */
usec = ((AvahiUsec) e->record->ttl) * 10000;
diff --git a/avahi-core/conformance-test.c b/avahi-core/conformance-test.c
index 7a4c601..c14a761 100644
--- a/avahi-core/conformance-test.c
+++ b/avahi-core/conformance-test.c
@@ -30,8 +30,8 @@
#include <unistd.h>
#include <stdio.h>
+#include <avahi-common/alternative.h>
#include "core.h"
-#include "alternative.h"
#include "log.h"
static gchar *name = NULL;
diff --git a/avahi-core/iface.h b/avahi-core/iface.h
index cb76359..47c54ba 100644
--- a/avahi-core/iface.h
+++ b/avahi-core/iface.h
@@ -30,7 +30,7 @@ typedef struct AvahiInterface AvahiInterface;
typedef struct AvahiHwInterface AvahiHwInterface;
#include <avahi-common/llist.h>
-#include "address.h"
+#include <avahi-common/address.h>
#include "server.h"
#include "netlink.h"
#include "cache.h"
diff --git a/avahi-core/probe-sched.c b/avahi-core/probe-sched.c
index d7f9ca0..a375c7b 100644
--- a/avahi-core/probe-sched.c
+++ b/avahi-core/probe-sched.c
@@ -24,9 +24,9 @@
#endif
#include <avahi-common/domain.h>
+#include <avahi-common/timeval.h>
#include "probe-sched.h"
-#include "timeval.h"
#include "log.h"
#define AVAHI_PROBE_HISTORY_MSEC 150
diff --git a/avahi-core/probe-sched.h b/avahi-core/probe-sched.h
index 07933a7..aae0f3a 100644
--- a/avahi-core/probe-sched.h
+++ b/avahi-core/probe-sched.h
@@ -24,8 +24,8 @@
typedef struct AvahiProbeScheduler AvahiProbeScheduler;
+#include <avahi-common/address.h>
#include "iface.h"
-#include "address.h"
AvahiProbeScheduler *avahi_probe_scheduler_new(AvahiInterface *i);
void avahi_probe_scheduler_free(AvahiProbeScheduler *s);
diff --git a/avahi-core/query-sched.c b/avahi-core/query-sched.c
index 6e9234f..9a26dba 100644
--- a/avahi-core/query-sched.c
+++ b/avahi-core/query-sched.c
@@ -23,8 +23,8 @@
#include <config.h>
#endif
+#include <avahi-common/timeval.h>
#include "query-sched.h"
-#include "timeval.h"
#define AVAHI_QUERY_HISTORY_MSEC 100
#define AVAHI_QUERY_DEFER_MSEC 100
diff --git a/avahi-core/query-sched.h b/avahi-core/query-sched.h
index b77363c..2c373b1 100644
--- a/avahi-core/query-sched.h
+++ b/avahi-core/query-sched.h
@@ -24,8 +24,8 @@
typedef struct AvahiQueryScheduler AvahiQueryScheduler;
+#include <avahi-common/address.h>
#include "iface.h"
-#include "address.h"
AvahiQueryScheduler *avahi_query_scheduler_new(AvahiInterface *i);
void avahi_query_scheduler_free(AvahiQueryScheduler *s);
diff --git a/avahi-core/resolve-address.c b/avahi-core/resolve-address.c
index fa50c39..6bd7cf2 100644
--- a/avahi-core/resolve-address.c
+++ b/avahi-core/resolve-address.c
@@ -23,8 +23,8 @@
#include <config.h>
#endif
+#include <avahi-common/timeval.h>
#include "browse.h"
-#include "timeval.h"
struct AvahiAddressResolver {
AvahiServer *server;
diff --git a/avahi-core/resolve-host-name.c b/avahi-core/resolve-host-name.c
index f50ddb4..50fbcf8 100644
--- a/avahi-core/resolve-host-name.c
+++ b/avahi-core/resolve-host-name.c
@@ -24,7 +24,7 @@
#endif
#include <avahi-common/domain.h>
-#include "timeval.h"
+#include <avahi-common/timeval.h>
#include "browse.h"
struct AvahiHostNameResolver {
diff --git a/avahi-core/resolve-service.c b/avahi-core/resolve-service.c
index bf4f7b9..0e4e119 100644
--- a/avahi-core/resolve-service.c
+++ b/avahi-core/resolve-service.c
@@ -26,8 +26,8 @@
#include <string.h>
#include <avahi-common/domain.h>
+#include <avahi-common/timeval.h>
#include "browse.h"
-#include "timeval.h"
struct AvahiServiceResolver {
AvahiServer *server;
diff --git a/avahi-core/response-sched.c b/avahi-core/response-sched.c
index 6027287..efb6677 100644
--- a/avahi-core/response-sched.c
+++ b/avahi-core/response-sched.c
@@ -23,8 +23,8 @@
#include <config.h>
#endif
+#include <avahi-common/timeval.h>
#include "response-sched.h"
-#include "timeval.h"
#include "log.h"
#define AVAHI_RESPONSE_HISTORY_MSEC 500
diff --git a/avahi-core/response-sched.h b/avahi-core/response-sched.h
index 10fd821..3760a44 100644
--- a/avahi-core/response-sched.h
+++ b/avahi-core/response-sched.h
@@ -24,8 +24,8 @@
typedef struct AvahiResponseScheduler AvahiResponseScheduler;
+#include <avahi-common/address.h>
#include "iface.h"
-#include "address.h"
AvahiResponseScheduler *avahi_response_scheduler_new(AvahiInterface *i);
void avahi_response_scheduler_free(AvahiResponseScheduler *s);
diff --git a/avahi-core/server.c b/avahi-core/server.c
index d913738..241932f 100644
--- a/avahi-core/server.c
+++ b/avahi-core/server.c
@@ -32,9 +32,9 @@
#include <stdio.h>
#include <avahi-common/domain.h>
+#include <avahi-common/timeval.h>
#include "server.h"
-#include "timeval.h"
#include "iface.h"
#include "socket.h"
#include "browse.h"
@@ -459,9 +459,9 @@ void avahi_server_generate_response(AvahiServer *s, AvahiInterface *i, AvahiDnsP
reply = avahi_dns_packet_new_reply(p, size, FALSE, TRUE);
if (!avahi_dns_packet_append_record(reply, r, flush_cache, 0)) {
+ gchar *t;
avahi_dns_packet_free(reply);
-
- gchar *t = avahi_record_to_string(r);
+ t = avahi_record_to_string(r);
avahi_log_warn("Record [%s] too large, doesn't fit in any packet!", t);
g_free(t);
break;
diff --git a/avahi-core/timeeventq-test.c b/avahi-core/timeeventq-test.c
index 6ac55b8..613d438 100644
--- a/avahi-core/timeeventq-test.c
+++ b/avahi-core/timeeventq-test.c
@@ -25,8 +25,8 @@
#include <glib.h>
+#include <avahi-common/timeval.h>
#include "timeeventq.h"
-#include "timeval.h"
static AvahiTimeEventQueue *q = NULL;
diff --git a/avahi-core/timeeventq.c b/avahi-core/timeeventq.c
index d466cd4..88e1779 100644
--- a/avahi-core/timeeventq.c
+++ b/avahi-core/timeeventq.c
@@ -23,8 +23,8 @@
#include <config.h>
#endif
+#include <avahi-common/timeval.h>
#include "timeeventq.h"
-#include "timeval.h"
static gint compare(gconstpointer _a, gconstpointer _b) {
const AvahiTimeEvent *a = _a, *b = _b;
diff --git a/avahi-core/timeval-test.c b/avahi-core/timeval-test.c
deleted file mode 100644
index 7dedf41..0000000
--- a/avahi-core/timeval-test.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* $Id$ */
-
-/***
- 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 <stdio.h>
-#include "timeval.h"
-
-int main(int argc, char *argv[]) {
-
- struct timeval a = { 5, 5 }, b;
-
- b = a;
-
- printf("%li.%li\n", a.tv_sec, a.tv_usec);
- avahi_timeval_add(&a, -50);
-
- printf("%li.%li\n", a.tv_sec, a.tv_usec);
-
- printf("%lli\n", avahi_timeval_diff(&a, &b));
-}
diff --git a/avahi-core/timeval.c b/avahi-core/timeval.c
deleted file mode 100644
index e5732cd..0000000
--- a/avahi-core/timeval.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/* $Id$ */
-
-/***
- 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 <assert.h>
-
-#include "timeval.h"
-
-int avahi_timeval_compare(const struct timeval *a, const struct timeval *b) {
- assert(a);
- assert(b);
-
- if (a->tv_sec < b->tv_sec)
- return -1;
-
- if (a->tv_sec > b->tv_sec)
- return 1;
-
- if (a->tv_usec < b->tv_usec)
- return -1;
-
- if (a->tv_usec > b->tv_usec)
- return 1;
-
- return 0;
-}
-
-AvahiUsec avahi_timeval_diff(const struct timeval *a, const struct timeval *b) {
- assert(a);
- assert(b);
-
- if (avahi_timeval_compare(a, b) < 0)
- return - avahi_timeval_diff(b, a);
-
- return ((AvahiUsec) a->tv_sec - b->tv_sec)*1000000 + a->tv_usec - b->tv_usec;
-}
-
-struct timeval* avahi_timeval_add(struct timeval *a, AvahiUsec usec) {
- AvahiUsec u;
- assert(a);
-
- u = usec + a->tv_usec;
-
- if (u < 0) {
- a->tv_usec = (long) (1000000 + (u % 1000000));
- a->tv_sec += (long) (-1 + (u / 1000000));
- } else {
- a->tv_usec = (long) (u % 1000000);
- a->tv_sec += (long) (u / 1000000);
- }
-
- return a;
-}
-
-AvahiUsec avahi_age(const struct timeval *a) {
- struct timeval now;
-
- assert(a);
-
- gettimeofday(&now, NULL);
-
- return avahi_timeval_diff(&now, a);
-}
-
-
-struct timeval *avahi_elapse_time(struct timeval *tv, unsigned msec, unsigned jitter) {
- assert(tv);
-
- gettimeofday(tv, NULL);
-
- if (msec)
- avahi_timeval_add(tv, (AvahiUsec) msec*1000);
-
- if (jitter)
- avahi_timeval_add(tv, (AvahiUsec) (jitter*1000.0*rand()/(RAND_MAX+1.0)));
-
- return tv;
-}
-
diff --git a/avahi-core/timeval.h b/avahi-core/timeval.h
deleted file mode 100644
index c046a19..0000000
--- a/avahi-core/timeval.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef footimevalhfoo
-#define footimevalhfoo
-
-/* $Id$ */
-
-/***
- 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 <inttypes.h>
-#include <sys/time.h>
-
-#include <avahi-common/cdecl.h>
-
-AVAHI_C_DECL_BEGIN
-
-typedef int64_t AvahiUsec;
-
-int avahi_timeval_compare(const struct timeval *a, const struct timeval *b);
-AvahiUsec avahi_timeval_diff(const struct timeval *a, const struct timeval *b);
-struct timeval* avahi_timeval_add(struct timeval *a, AvahiUsec usec);
-
-AvahiUsec avahi_age(const struct timeval *a);
-struct timeval *avahi_elapse_time(struct timeval *tv, unsigned msec, unsigned jitter);
-
-AVAHI_C_DECL_END
-
-#endif