--- apps/obex_test.c | 18 ++++++++++-------- include/openobex/obex.h | 3 ++- lib/obex.c | 30 ++++++++++++++++++++++-------- lib/obex.sym | 3 ++- 4 files changed, 36 insertions(+), 18 deletions(-)
diff --git a/apps/obex_test.c b/apps/obex_test.c index 82af2c4..8ce089f 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 -- 1.6.0.6 ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Openobex-users mailing list Openobex-users@lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/openobex-users