diff options
author | Marcel Mol <marcel@mesa.nl> | 2010-07-20 18:29:39 +0200 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2010-07-21 11:41:46 +0300 |
commit | b13ff7449fdc621a5154c4d299e7706d396a0f1d (patch) | |
tree | 0d1180b41bff076e663789f89afbf087b9a433a8 /src | |
parent | fac085272bd2dbc767cd5f3283ace6a76666a81e (diff) | |
download | obexd-b13ff7449fdc621a5154c4d299e7706d396a0f1d.tar.gz |
Add variable target size support to obex_mime_type_driver_find()
Targets for mime type drivers are not always fixed to TARGET_SIZE.
(fix started by Pierre Ossman)
Diffstat (limited to 'src')
-rw-r--r-- | src/mimetype.c | 14 | ||||
-rw-r--r-- | src/mimetype.h | 2 | ||||
-rw-r--r-- | src/obex.c | 10 |
3 files changed, 18 insertions, 8 deletions
diff --git a/src/mimetype.c b/src/mimetype.c index fa52e75..4a30222 100644 --- a/src/mimetype.c +++ b/src/mimetype.c @@ -118,6 +118,7 @@ static int set_io_watch(void *object, obex_object_io_func func, } static struct obex_mime_type_driver *find_driver(const uint8_t *target, + unsigned int target_size, const char *mimetype, const uint8_t *who, unsigned int who_size) { @@ -126,7 +127,7 @@ static struct obex_mime_type_driver *find_driver(const uint8_t *target, for (l = drivers; l; l = l->next) { struct obex_mime_type_driver *driver = l->data; - if (memncmp0(target, TARGET_SIZE, driver->target, TARGET_SIZE)) + if (memncmp0(target, target_size, driver->target, driver->target_size)) continue; if (memncmp0(who, who_size, driver->who, driver->who_size)) @@ -140,27 +141,28 @@ static struct obex_mime_type_driver *find_driver(const uint8_t *target, } struct obex_mime_type_driver *obex_mime_type_driver_find(const uint8_t *target, + unsigned int target_size, const char *mimetype, const uint8_t *who, unsigned int who_size) { struct obex_mime_type_driver *driver; - driver = find_driver(target, mimetype, who, who_size); + driver = find_driver(target, target_size, mimetype, who, who_size); if (driver == NULL) { if (who != NULL) { /* Fallback to non-who specific */ - driver = find_driver(target, mimetype, NULL, 0); + driver = find_driver(target, target_size, mimetype, NULL, 0); if (driver != NULL) return driver; } if (mimetype != NULL) /* Fallback to target default */ - driver = find_driver(target, NULL, NULL, 0); + driver = find_driver(target, target_size, NULL, NULL, 0); if (driver == NULL) /* Fallback to general default */ - driver = find_driver(NULL, NULL, NULL, 0); + driver = find_driver(NULL, 0, NULL, NULL, 0); } return driver; @@ -173,7 +175,7 @@ int obex_mime_type_driver_register(struct obex_mime_type_driver *driver) return -EINVAL; } - if (find_driver(driver->target, driver->mimetype, + if (find_driver(driver->target, driver->target_size, driver->mimetype, driver->who, driver->who_size)) { error("Permission denied: %s could not be registered", driver->mimetype); diff --git a/src/mimetype.h b/src/mimetype.h index 4cb3156..200b950 100644 --- a/src/mimetype.h +++ b/src/mimetype.h @@ -26,6 +26,7 @@ typedef gboolean (*obex_object_io_func) (void *object, int flags, int err, struct obex_mime_type_driver { const uint8_t *target; + unsigned int target_size; const char *mimetype; const uint8_t *who; unsigned int who_size; @@ -42,6 +43,7 @@ struct obex_mime_type_driver { int obex_mime_type_driver_register(struct obex_mime_type_driver *driver); void obex_mime_type_driver_unregister(struct obex_mime_type_driver *driver); struct obex_mime_type_driver *obex_mime_type_driver_find(const uint8_t *target, + unsigned int target_size, const char *mimetype, const uint8_t *who, unsigned int who_size); @@ -763,7 +763,9 @@ static void cmd_get(struct obex_session *os, obex_t *obex, obex_object_t *obj) os->type = g_strndup((const char *) hd.bs, hlen); DBG("OBEX_HDR_TYPE: %s", os->type); os->driver = obex_mime_type_driver_find( - os->service->target, os->type, + os->service->target, + os->service->target_size, + os->type, os->service->who, os->service->who_size); break; @@ -772,6 +774,7 @@ static void cmd_get(struct obex_session *os, obex_t *obex, obex_object_t *obj) if (os->type == NULL) os->driver = obex_mime_type_driver_find(os->service->target, + os->service->target_size, NULL, os->service->who, os->service->who_size); @@ -977,7 +980,9 @@ static gboolean check_put(obex_t *obex, obex_object_t *obj) os->type = g_strndup((const char *) hd.bs, hlen); DBG("OBEX_HDR_TYPE: %s", os->type); os->driver = obex_mime_type_driver_find( - os->service->target, os->type, + os->service->target, + os->service->target_size, + os->type, os->service->who, os->service->who_size); break; @@ -1001,6 +1006,7 @@ static gboolean check_put(obex_t *obex, obex_object_t *obj) if (os->type == NULL) os->driver = obex_mime_type_driver_find(os->service->target, + os->service->target_size, NULL, os->service->who, os->service->who_size); |