2008/12/24 Marcel Holtmann <mar...@holtmann.org>: >> Additionally, for reverting the ABI breakage caused by Alex' patch, revert >> the >> commits >> 978e72d013cf12201c6c3ffc51de90e0b498f736 >> and >> 139683f9ca864a8e4fcfaf3a454c293539547903 >> (in this order) from your master branch (or maybe Alex also some a tree to >> pull this from?). > > Will look into that later today.
Hi Marcel, another option to reverting that patch would be to change the interface discovery API in a way that prevents similar ABI breakage from happening in the future. I think that's a better option because the version which broke the ABI has been out for a while now, therefore reverting the patch, and then reintroducing it later would just further confuse things. I've attached the patch for this, please review. Oh, and there was another patch with fixes for FreeBSD: http://www.mail-archive.com/openobex-users@lists.sourceforge.net/msg01130.html -- Alexander
diff --git a/apps/obex_test.c b/apps/obex_test.c index 82af2c4..2885c92 100644 --- a/apps/obex_test.c +++ b/apps/obex_test.c @@ -157,7 +157,7 @@ int main (int argc, char *argv[]) #endif #ifdef HAVE_USB - obex_interface_t *obex_intf; + obex_interface_t *obex_intf = NULL; #endif struct context global_context = {0,}; @@ -271,12 +271,14 @@ int main (int argc, char *argv[]) perror( "OBEX_Init failed"); exit(0); } - interfaces_number = OBEX_FindInterfaces(handle, &obex_intf); - for (i=0; i < interfaces_number; i++) + interfaces_number = OBEX_EnumerateInterfaces(handle); + for (i=0; i < interfaces_number; i++) { + obex_intf = OBEX_GetInterfaceByIndex(handle, i); printf("Interface %d: %s %s %s\n", i, - obex_intf[i].usb.manufacturer, - obex_intf[i].usb.product, - obex_intf[i].usb.control_interface); + obex_intf->usb.manufacturer, + obex_intf->usb.product, + obex_intf->usb.control_interface); + } printf("Use '%s -u interface_number' to run interactive OBEX test client\n", argv[0]); OBEX_Cleanup(handle); exit(0); @@ -289,12 +291,12 @@ int main (int argc, char *argv[]) exit(0); } - interfaces_number = OBEX_FindInterfaces(handle, &obex_intf); + interfaces_number = OBEX_EnumerateInterfaces(handle); if (intf_num >= interfaces_number) { printf( "Invalid interface number\n"); exit(0); } - obex_intf += intf_num; + obex_intf = OBEX_GetInterfaceByIndex(handle, intf_num); break; default: diff --git a/include/openobex/obex.h b/include/openobex/obex.h index 5488d3b..a24927d 100644 --- a/include/openobex/obex.h +++ b/include/openobex/obex.h @@ -162,7 +162,8 @@ OPENOBEX_SYMBOL(int) FdOBEX_TransportSetup(obex_t *self, int rfd, int wfd, int m /* * OBEX interface discovery API */ -OPENOBEX_SYMBOL(int) OBEX_FindInterfaces(obex_t *self, obex_interface_t **intf); +OPENOBEX_SYMBOL(int) OBEX_EnumerateInterfaces(obex_t *self); +OPENOBEX_SYMBOL(obex_interface_t *) OBEX_GetInterfaceByIndex(obex_t *self, int i); OPENOBEX_SYMBOL(int) OBEX_InterfaceConnect(obex_t *self, obex_interface_t *intf); OPENOBEX_SYMBOL(void) OBEX_FreeInterfaces(obex_t *self); diff --git a/lib/obex.c b/lib/obex.c index 54cba70..22965f1 100644 --- a/lib/obex.c +++ b/lib/obex.c @@ -1292,13 +1292,12 @@ int CALLAPI OBEX_InterfaceConnect(obex_t *self, obex_interface_t *intf) } /** - Get a list of OBEX interfaces on the system. + Find OBEX interfaces on the system. \param self OBEX handle - \param interfaces A list of OBEX interfaces - \return a list of OBEX interfaces, or NULL if there are none. + \return the number of OBEX interfaces. */ LIB_SYMBOL -int CALLAPI OBEX_FindInterfaces(obex_t *self, obex_interface_t **interfaces) +int CALLAPI OBEX_EnumerateInterfaces(obex_t *self) { DEBUG(4, "\n"); @@ -1315,18 +1314,33 @@ int CALLAPI OBEX_FindInterfaces(obex_t *self, obex_interface_t **interfaces) break; } - if (interfaces) - *interfaces = self->interfaces; - return self->interfaces_number; } /** + Get OBEX interface information. + \param self OBEX handle + \param i interface number + \return OBEX interface information. + */ +LIB_SYMBOL +obex_interface_t * CALLAPI OBEX_GetInterfaceByIndex(obex_t *self, int i) +{ + DEBUG(4, "\n"); + + obex_return_val_if_fail(self != NULL, NULL); + + if (i >= self->interfaces_number || i < 0) + return NULL; + return &self->interfaces[i]; +} + +/** Free memory allocated to OBEX interface structures. \param self OBEX handle Frees memory allocated to OBEX interface structures after it has been - allocated by OBEX_FindInterfaces. + allocated by OBEX_EnumerateInterfaces. */ LIB_SYMBOL void CALLAPI OBEX_FreeInterfaces(obex_t *self) diff --git a/lib/obex.sym b/lib/obex.sym index 741a2b0..11cfc0a 100644 --- a/lib/obex.sym +++ b/lib/obex.sym @@ -44,5 +44,6 @@ BtOBEX_ServerRegister BtOBEX_TransportConnect FdOBEX_TransportSetup OBEX_InterfaceConnect -OBEX_FindInterfaces +OBEX_EnumerateInterfaces +OBEX_GetInterfaceByIndex OBEX_FreeInterfaces
------------------------------------------------------------------------------
_______________________________________________ Openobex-users mailing list Openobex-users@lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/openobex-users