- g_assert(s);
- g_assert(r);
-
- for (e = g_hash_table_lookup(s->entries_by_key, r->key); e; e = e->by_key_next) {
- if (e->dead)
- continue;
-
- if (!(flags & AVAHI_ENTRY_UNIQUE) && !(e->flags & AVAHI_ENTRY_UNIQUE))
- continue;
-
- if ((flags & AVAHI_ENTRY_ALLOWMUTIPLE) && (e->flags & AVAHI_ENTRY_ALLOWMUTIPLE) )
- continue;
-
- if (interface <= 0 ||
- e->interface <= 0 ||
- e->interface == interface ||
- protocol == AVAHI_PROTO_UNSPEC ||
- e->protocol == AVAHI_PROTO_UNSPEC ||
- e->protocol == protocol)
-
- return -1;
-
- }
-
- return 0;
-}
-
-gint avahi_server_add(
- AvahiServer *s,
- AvahiEntryGroup *g,
- gint interface,
- guchar protocol,
- AvahiEntryFlags flags,
- AvahiRecord *r) {
-
- AvahiEntry *e, *t;
-
- g_assert(s);
- g_assert(r);
-
- if (avahi_key_is_pattern(r->key))
- return -1;
-
- if (check_record_conflict(s, interface, protocol, r, flags) < 0)
- return -1;
-
- e = g_new(AvahiEntry, 1);
- e->server = s;
- e->record = avahi_record_ref(r);
- e->group = g;
- e->interface = interface;
- e->protocol = protocol;
- e->flags = flags;
- e->dead = FALSE;
-
- AVAHI_LLIST_HEAD_INIT(AvahiAnnouncement, e->announcements);
-
- AVAHI_LLIST_PREPEND(AvahiEntry, entries, s->entries, e);
-
- /* Insert into hash table indexed by name */
- t = g_hash_table_lookup(s->entries_by_key, e->record->key);
- AVAHI_LLIST_PREPEND(AvahiEntry, by_key, t, e);
- g_hash_table_replace(s->entries_by_key, e->record->key, t);
-
- /* Insert into group list */
- if (g)
- AVAHI_LLIST_PREPEND(AvahiEntry, by_group, g->entries, e);
-
- avahi_announce_entry(s, e);
-
- return 0;
-}
-
-const AvahiRecord *avahi_server_iterate(AvahiServer *s, AvahiEntryGroup *g, void **state) {
- AvahiEntry **e = (AvahiEntry**) state;
- g_assert(s);
- g_assert(e);
-
- if (!*e)
- *e = g ? g->entries : s->entries;