4 This file is part of avahi.
6 avahi is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
11 avahi is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14 Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with avahi; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25 typedef struct AvahiRecordListItem AvahiRecordListItem;
27 struct AvahiRecordListItem {
29 gboolean unicast_response;
31 AVAHI_LLIST_FIELDS(AvahiRecordListItem, items);
35 struct AvahiRecordList {
36 AVAHI_LLIST_HEAD(AvahiRecordListItem, items);
39 AvahiRecordList *avahi_record_list_new(void) {
40 AvahiRecordList *l = g_new(AvahiRecordList, 1);
41 AVAHI_LLIST_HEAD_INIT(AvahiRecordListItem, l->items);
45 void avahi_record_list_free(AvahiRecordList *l) {
48 avahi_record_list_flush(l);
52 static void item_free(AvahiRecordList *l, AvahiRecordListItem *i) {
55 AVAHI_LLIST_REMOVE(AvahiRecordListItem, items, l->items, i);
56 avahi_record_unref(i->record);
60 void avahi_record_list_flush(AvahiRecordList *l) {
64 item_free(l, l->items);
67 AvahiRecord* avahi_record_list_pop(AvahiRecordList *l, gboolean *flush_cache, gboolean *unicast_response) {
73 r = avahi_record_ref(l->items->record);
74 if (unicast_response) *unicast_response = l->items->unicast_response;
75 if (flush_cache) *flush_cache = l->items->flush_cache;
77 item_free(l, l->items);
82 void avahi_record_list_push(AvahiRecordList *l, AvahiRecord *r, gboolean flush_cache, gboolean unicast_response) {
83 AvahiRecordListItem *i;
88 for (i = l->items; i; i = i->items_next)
89 if (avahi_record_equal_no_ttl(i->record, r))
92 i = g_new(AvahiRecordListItem, 1);
93 i->unicast_response = unicast_response;
94 i->flush_cache = flush_cache;
95 i->record = avahi_record_ref(r);
96 AVAHI_LLIST_PREPEND(AvahiRecordListItem, items, l->items, i);
99 void avahi_record_list_drop(AvahiRecordList *l, AvahiRecord *r) {
100 AvahiRecordListItem *i;
105 for (i = l->items; i; i = i->items_next)
106 if (avahi_record_equal_no_ttl(i->record, r)) {
113 gboolean avahi_record_list_empty(AvahiRecordList *l) {