summaryrefslogtreecommitdiff
path: root/libgphoto2_port/usb
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2008-03-15 21:45:48 +0000
committerMarcus Meissner <marcus@jet.franken.de>2008-03-15 21:45:48 +0000
commit3c26841fa08d4f7c82ea7b4004a954f6fe146f17 (patch)
tree77e49b5d592507d3aa7e03ef5117c4dcd5850e5e /libgphoto2_port/usb
parentf50fb2ec5e87a8538befd8909ae6243711d49baa (diff)
downloadlibgphoto2-3c26841fa08d4f7c82ea7b4004a954f6fe146f17.tar.gz
GPPortInfo struct abstracted into a private struct.
- libgphoto2_port rewritten for new GPPortInfo. - camlibs/directory and camlibs/ptp2 adjusted. - libgphoto2/ adjusted for the changed GPPortInfo list handling. - configure.ac adjusted, NEWS adjusted git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@10990 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'libgphoto2_port/usb')
-rw-r--r--libgphoto2_port/usb/libusb.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/libgphoto2_port/usb/libusb.c b/libgphoto2_port/usb/libusb.c
index 9a173b877..7cf5a9ab6 100644
--- a/libgphoto2_port/usb/libusb.c
+++ b/libgphoto2_port/usb/libusb.c
@@ -83,22 +83,23 @@ gp_port_library_list (GPPortInfoList *list)
int nrofdevices = 0, i, i1, i2, unknownint;
/* default port first */
- info.type = GP_PORT_USB;
- strcpy (info.name, "Universal Serial Bus");
- strcpy (info.path, "usb:");
+ gp_port_info_new (&info);
+ gp_port_info_set_type (info, GP_PORT_USB);
+ gp_port_info_set_name (info, "Universal Serial Bus");
+ gp_port_info_set_path (info, "usb:");
CHECK (gp_port_info_list_append (list, info));
/* generic matcher. This will catch passed XXX,YYY entries for instance. */
- memset (info.name, 0, sizeof(info.name));
- strcpy (info.path, "^usb:");
+ gp_port_info_new (&info);
+ gp_port_info_set_type (info, GP_PORT_USB);
+ gp_port_info_set_name (info, "");
+ gp_port_info_set_path (info, "^usb:");
CHECK (gp_port_info_list_append (list, info));
usb_init ();
usb_find_busses ();
usb_find_devices ();
- strcpy (info.name, "Universal Serial Bus");
-
bus = usb_get_busses();
/* Look and enumerate all USB ports. */
@@ -153,6 +154,7 @@ gp_port_library_list (GPPortInfoList *list)
while (bus) {
for (dev = bus->devices; dev; dev = dev->next) {
char *s;
+ char path[200];
/* Devices which are definitely not cameras. */
if ( (dev->descriptor.bDeviceClass == USB_CLASS_HUB) ||
(dev->descriptor.bDeviceClass == USB_CLASS_HID) ||
@@ -184,9 +186,13 @@ gp_port_library_list (GPPortInfoList *list)
/* Note: We do not skip USB storage. Some devices can support both,
* and the Ricoh erronously reports it.
*/
- sprintf (info.path, "usb:%s,%s", bus->dirname, dev->filename);
+ gp_port_info_new (&info);
+ gp_port_info_set_type (info, GP_PORT_USB);
+ gp_port_info_set_name (info, "Universal Serial Bus");
+ snprintf (path,sizeof(path), "usb:%s,%s", bus->dirname, dev->filename);
/* On MacOS X we might get usb:006,002-04a9-3139-00-00. */
- s = strchr(info.path, '-');if (s) *s='\0';
+ s = strchr(path, '-');if (s) *s='\0';
+ gp_port_info_set_path (info, path);
CHECK (gp_port_info_list_append (list, info));
}
bus = bus->next;