summaryrefslogtreecommitdiff
path: root/core/friend_requests.c
diff options
context:
space:
mode:
authoralek900 <alek900@gmail.com>2013-08-12 14:23:46 +0200
committeralek900 <alek900@gmail.com>2013-08-12 14:23:46 +0200
commit8d3e68b74d8ff0fad398617ea37eb4e5422f3718 (patch)
tree3f6a986915b116af51f438f656bce3d6709a267e /core/friend_requests.c
parent33e104f32ff2852da31dbcff1441ea4bdc47fe95 (diff)
Added support for userdata in callbacks
Diffstat (limited to 'core/friend_requests.c')
-rw-r--r--core/friend_requests.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/core/friend_requests.c b/core/friend_requests.c
index 422cc028..5e9b447c 100644
--- a/core/friend_requests.c
+++ b/core/friend_requests.c
@@ -57,14 +57,15 @@ int send_friendrequest(uint8_t * public_key, uint8_t * data, uint32_t length)
57 return num; 57 return num;
58} 58}
59 59
60static void (*handle_friendrequest)(uint8_t *, uint8_t *, uint16_t); 60static void (*handle_friendrequest)(uint8_t *, uint8_t *, uint16_t, void*);
61static uint8_t handle_friendrequest_isset = 0; 61static uint8_t handle_friendrequest_isset = 0;
62 62static void* handle_friendrequest_userdata;
63/* set the function that will be executed when a friend request is received. */ 63/* set the function that will be executed when a friend request is received. */
64void callback_friendrequest(void (*function)(uint8_t *, uint8_t *, uint16_t)) 64void callback_friendrequest(void (*function)(uint8_t *, uint8_t *, uint16_t, void*), void* userdata)
65{ 65{
66 handle_friendrequest = function; 66 handle_friendrequest = function;
67 handle_friendrequest_isset = 1; 67 handle_friendrequest_isset = 1;
68 handle_friendrequest_userdata = userdata;
68} 69}
69 70
70 71
@@ -121,7 +122,7 @@ static int friendreq_handlepacket(IP_Port source, uint8_t * packet, uint32_t len
121 return 1; 122 return 1;
122 123
123 addto_receivedlist(public_key); 124 addto_receivedlist(public_key);
124 (*handle_friendrequest)(public_key, data, len); 125 (*handle_friendrequest)(public_key, data, len, handle_friendrequest_userdata);
125 } else { /* if request is not for us, try routing it. */ 126 } else { /* if request is not for us, try routing it. */
126 if(route_packet(packet + 1, packet, length) == length) 127 if(route_packet(packet + 1, packet, length) == length)
127 return 0; 128 return 0;