Context clues innit

This commit is contained in:
XANTRONIX Development 2017-11-24 12:28:49 -06:00
parent 93e4445f24
commit f16908e7fb
5 changed files with 7 additions and 7 deletions

View file

@ -11,7 +11,7 @@ static void usage(int argc, char **argv) {
} }
static int answer_phone_version_message(skipstone_message_service *service, 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] = { uint8_t response[13] = {
1, 0xff, 0xff, 0xff, 0xff, 0x80, 0, 0, 0, 0, 0, 0, 0x32 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, 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 { struct {
uint8_t command; uint8_t command;
uint8_t artist_len; uint8_t artist_len;

View file

@ -11,7 +11,7 @@ static void usage(int argc, char **argv) {
} }
static int answer_phone_version_message(skipstone_message_service *service, 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] = { uint8_t response[13] = {
1, 0xff, 0xff, 0xff, 0xff, 0x80, 0, 0, 0, 0, 0, 0, 0x32 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, 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 { struct {
uint8_t command; uint8_t command;
uint8_t artist_len; uint8_t artist_len;

View file

@ -27,7 +27,7 @@ typedef struct _skipstone_message_header {
typedef struct _skipstone_message_service skipstone_message_service; typedef struct _skipstone_message_service skipstone_message_service;
typedef int (skipstone_message_handler)(skipstone_message_service *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(); skipstone_message_service *skipstone_message_service_new();

View file

@ -110,7 +110,7 @@ int skipstone_message_service_run(skipstone_message_service *service,
} }
if ((endpoint = skipstone_map_get(service->endpoints, id)) != NULL) { 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; goto error_io;
} }
} }

View file

@ -110,7 +110,7 @@ int skipstone_message_service_run(skipstone_message_service *service,
} }
if ((endpoint = skipstone_map_get(service->endpoints, id)) != NULL) { 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; goto error_io;
} }
} }