diff --git a/examples/test.c b/examples/test.c index fa34ece..31896f6 100644 --- a/examples/test.c +++ b/examples/test.c @@ -11,7 +11,7 @@ static void usage(int argc, char **argv) { } static int answer_phone_version_message(skipstone_message_service *service, - void *buf, uint16_t size, uint16_t id) { + void *buf, uint16_t size, uint16_t id, void *context) { uint8_t response[13] = { 1, 0xff, 0xff, 0xff, 0xff, 0x80, 0, 0, 0, 0, 0, 0, 0x32 }; @@ -24,7 +24,7 @@ static int answer_phone_version_message(skipstone_message_service *service, } static int answer_media_message(skipstone_message_service *service, - void *buf, uint16_t size, uint16_t id) { + void *buf, uint16_t size, uint16_t id, void *context) { struct { uint8_t command; uint8_t artist_len; diff --git a/examples/test.c-e b/examples/test.c-e index fa34ece..31896f6 100644 --- a/examples/test.c-e +++ b/examples/test.c-e @@ -11,7 +11,7 @@ static void usage(int argc, char **argv) { } static int answer_phone_version_message(skipstone_message_service *service, - void *buf, uint16_t size, uint16_t id) { + void *buf, uint16_t size, uint16_t id, void *context) { uint8_t response[13] = { 1, 0xff, 0xff, 0xff, 0xff, 0x80, 0, 0, 0, 0, 0, 0, 0x32 }; @@ -24,7 +24,7 @@ static int answer_phone_version_message(skipstone_message_service *service, } static int answer_media_message(skipstone_message_service *service, - void *buf, uint16_t size, uint16_t id) { + void *buf, uint16_t size, uint16_t id, void *context) { struct { uint8_t command; uint8_t artist_len; diff --git a/include/skipstone/message.h b/include/skipstone/message.h index 208a336..2b912f8 100644 --- a/include/skipstone/message.h +++ b/include/skipstone/message.h @@ -27,7 +27,7 @@ typedef struct _skipstone_message_header { typedef struct _skipstone_message_service skipstone_message_service; typedef int (skipstone_message_handler)(skipstone_message_service *service, - void *buf, uint16_t size, uint16_t id); + void *buf, uint16_t size, uint16_t id, void *context); skipstone_message_service *skipstone_message_service_new(); diff --git a/src/message.c b/src/message.c index ab1fc23..9ce49fd 100644 --- a/src/message.c +++ b/src/message.c @@ -110,7 +110,7 @@ int skipstone_message_service_run(skipstone_message_service *service, } if ((endpoint = skipstone_map_get(service->endpoints, id)) != NULL) { - if (endpoint->handler(service, buf, size, id) < 0) { + if (endpoint->handler(service, buf, size, id, endpoint->context) < 0) { goto error_io; } } diff --git a/src/message.c-e b/src/message.c-e index ab1fc23..9ce49fd 100644 --- a/src/message.c-e +++ b/src/message.c-e @@ -110,7 +110,7 @@ int skipstone_message_service_run(skipstone_message_service *service, } if ((endpoint = skipstone_map_get(service->endpoints, id)) != NULL) { - if (endpoint->handler(service, buf, size, id) < 0) { + if (endpoint->handler(service, buf, size, id, endpoint->context) < 0) { goto error_io; } }