Mercurial > pidgin
comparison src/protocols/rendezvous/mdns_cache.c @ 8806:8212661dc3cc
[gaim-migrate @ 9568]
I think mDNS records should be caching now... my iBook isn't booting,
so I don't really have a way to test it. I need to fix that.
I change some stuff from GHashTables to GSLists, I think, which
meant changing a lot of code.
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Sun, 25 Apr 2004 16:23:20 +0000 |
| parents | dbbf5470ba05 |
| children | beb7be215db3 |
comparison
equal
deleted
inserted
replaced
| 8805:6ad548495275 | 8806:8212661dc3cc |
|---|---|
| 26 #include "internal.h" | 26 #include "internal.h" |
| 27 #include "debug.h" | 27 #include "debug.h" |
| 28 | 28 |
| 29 #include "mdns.h" | 29 #include "mdns.h" |
| 30 | 30 |
| 31 GSList *resourcerecords = NULL; | 31 /* XXX - Make sure this is freed when we sign off */ |
| 32 GSList *rrs = NULL; | |
| 32 | 33 |
| 33 void mdns_cache_add(ResourceRecord *rr) | 34 void |
| 35 mdns_cache_add(const ResourceRecord *rr) | |
| 36 { | |
| 37 ResourceRecord *new; | |
| 38 | |
| 39 g_return_if_fail(rr != NULL); | |
| 40 | |
| 41 new = mdns_copy_rr(rr); | |
| 42 | |
| 43 rrs = g_slist_prepend(rrs, new); | |
| 44 } | |
| 45 | |
| 46 void | |
| 47 mdns_cache_remove(ResourceRecord *rr) | |
| 34 { | 48 { |
| 35 g_return_if_fail(rr != NULL); | 49 g_return_if_fail(rr != NULL); |
| 36 | 50 |
| 37 resourcerecords = g_slist_prepend(resourcerecords, rr); | 51 rrs = g_slist_remove_all(rrs, rr); |
| 38 } | |
| 39 | |
| 40 void mdns_cache_remove(ResourceRecord *rr) | |
| 41 { | |
| 42 g_return_if_fail(rr != NULL); | |
| 43 | |
| 44 resourcerecords = g_slist_remove_all(resourcerecords, rr); | |
| 45 | 52 |
| 46 mdns_free_rr(rr); | 53 mdns_free_rr(rr); |
| 47 } | 54 } |
| 48 | 55 |
| 49 void mdns_cache_remove_all() | 56 void |
| 57 mdns_cache_remove_all() | |
| 50 { | 58 { |
| 51 while (resourcerecords != NULL) | 59 mdns_free_rrs(rrs); |
| 52 mdns_cache_remove(resourcerecords->data); | |
| 53 } | 60 } |
| 54 | 61 |
| 55 void mdns_cache_respond(int fd, Question *q) | 62 void |
| 63 mdns_cache_respond(int fd, const Question *q) | |
| 56 { | 64 { |
| 57 GSList *slist; | 65 GSList *slist; |
| 58 ResourceRecord *cur; | 66 ResourceRecord *cur; |
| 59 | 67 |
| 60 g_return_if_fail(q != NULL); | 68 g_return_if_fail(q != NULL); |
| 61 | 69 |
| 62 for (slist = resourcerecords; slist != NULL; slist = g_slist_next(slist)) { | 70 for (slist = rrs; slist != NULL; slist = g_slist_next(slist)) { |
| 63 cur = slist->data; | 71 cur = slist->data; |
| 64 if ((q->type == cur->type) && (!strcmp(q->name, cur->name))) | 72 if ((q->type == cur->type) && (!strcmp(q->name, cur->name))) |
| 65 mdns_send_rr(fd, cur); | 73 mdns_send_rr(fd, cur); |
| 66 } | 74 } |
| 67 } | 75 } |
