X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Ff2fchat.git;a=blobdiff_plain;f=friend.c;fp=friend.c;h=7386f839d8d550aec5be10d867e5c4862d013277;hp=f749b4dc20ece9823e3c9bce528bf4e9a3651712;hb=ec81d19dd18fb4fce9b0fcbe9db73200585ec2f0;hpb=a3de5aacf2ffb1543dc7b43e3cd6e81773d863c8 diff --git a/friend.c b/friend.c index f749b4d..7386f83 100644 --- a/friend.c +++ b/friend.c @@ -60,9 +60,22 @@ struct cache { GList *friends; }; +static struct cache *ucache; + +struct friend *friend_get_by_address(GInetAddress *address) +{ + GList *l; + for (l = g_list_first(ucache->friends); l != NULL; l = g_list_next(l)) { + struct friend *friend = l->data; + if (g_inet_address_equal(g_inet_socket_address_get_address(friend->saddr), address)) + return friend; + } + return NULL; +} + int create_cache(struct cache **cache) { - *cache = g_slice_new0(struct cache); + ucache = *cache = g_slice_new0(struct cache); (*cache)->friends = NULL; return 0; }