| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libusb example program to manipulate U.are.U 4000B fingerprint scanner. | 2 * libusbx example program to manipulate U.are.U 4000B fingerprint scanner. |
| 3 * Copyright (C) 2007 Daniel Drake <dsd@gentoo.org> | 3 * Copyright © 2007 Daniel Drake <dsd@gentoo.org> |
| 4 * | 4 * |
| 5 * Basic image capture program only, does not consider the powerup quirks or | 5 * Basic image capture program only, does not consider the powerup quirks or |
| 6 * the fact that image encryption may be enabled. Not expected to work | 6 * the fact that image encryption may be enabled. Not expected to work |
| 7 * flawlessly all of the time. | 7 * flawlessly all of the time. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Lesser General Public | 10 * modify it under the terms of the GNU Lesser General Public |
| 11 * License as published by the Free Software Foundation; either | 11 * License as published by the Free Software Foundation; either |
| 12 * version 2.1 of the License, or (at your option) any later version. | 12 * version 2.1 of the License, or (at your option) any later version. |
| 13 * | 13 * |
| 14 * This library is distributed in the hope that it will be useful, | 14 * This library is distributed in the hope that it will be useful, |
| 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 * Lesser General Public License for more details. | 17 * Lesser General Public License for more details. |
| 18 * | 18 * |
| 19 * You should have received a copy of the GNU Lesser General Public | 19 * You should have received a copy of the GNU Lesser General Public |
| 20 * License along with this library; if not, write to the Free Software | 20 * License along with this library; if not, write to the Free Software |
| 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 22 */ | 22 */ |
| 23 | 23 |
| 24 #include <errno.h> | 24 #include <errno.h> |
| 25 #include <signal.h> | 25 #include <signal.h> |
| 26 #include <string.h> | 26 #include <string.h> |
| 27 #include <stdio.h> | 27 #include <stdio.h> |
| 28 #include <stdlib.h> | 28 #include <stdlib.h> |
| 29 | 29 |
| 30 #include <libusb.h> | 30 #include "libusb.h" |
| 31 | 31 |
| 32 #define EP_INTR (1 | LIBUSB_ENDPOINT_IN) | 32 #define EP_INTR (1 | LIBUSB_ENDPOINT_IN) |
| 33 #define EP_DATA (2 | LIBUSB_ENDPOINT_IN) | 33 #define EP_DATA (2 | LIBUSB_ENDPOINT_IN) |
| 34 #define CTRL_IN (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_IN
) | 34 #define CTRL_IN (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_IN
) |
| 35 #define CTRL_OUT (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_OU
T) | 35 #define CTRL_OUT (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_OU
T) |
| 36 #define USB_RQ 0x04 | 36 #define USB_RQ 0x04 |
| 37 #define INTR_LENGTH 64 | 37 #define INTR_LENGTH 64 |
| 38 | 38 |
| 39 enum { | 39 enum { |
| 40 MODE_INIT = 0x00, | 40 MODE_INIT = 0x00, |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 } | 157 } |
| 158 | 158 |
| 159 printf("async cb_mode_changed length=%d actual_length=%d\n", | 159 printf("async cb_mode_changed length=%d actual_length=%d\n", |
| 160 transfer->length, transfer->actual_length); | 160 transfer->length, transfer->actual_length); |
| 161 if (next_state() < 0) | 161 if (next_state() < 0) |
| 162 do_exit = 2; | 162 do_exit = 2; |
| 163 } | 163 } |
| 164 | 164 |
| 165 static int set_mode_async(unsigned char data) | 165 static int set_mode_async(unsigned char data) |
| 166 { | 166 { |
| 167 » unsigned char *buf = malloc(LIBUSB_CONTROL_SETUP_SIZE + 1); | 167 » unsigned char *buf = (unsigned char*) malloc(LIBUSB_CONTROL_SETUP_SIZE +
1); |
| 168 struct libusb_transfer *transfer; | 168 struct libusb_transfer *transfer; |
| 169 | 169 |
| 170 if (!buf) | 170 if (!buf) |
| 171 return -ENOMEM; | 171 return -ENOMEM; |
| 172 | 172 |
| 173 transfer = libusb_alloc_transfer(0); | 173 transfer = libusb_alloc_transfer(0); |
| 174 if (!transfer) { | 174 if (!transfer) { |
| 175 free(buf); | 175 free(buf); |
| 176 return -ENOMEM; | 176 return -ENOMEM; |
| 177 } | 177 } |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 libusb_free_transfer(irq_transfer); | 497 libusb_free_transfer(irq_transfer); |
| 498 set_mode(0); | 498 set_mode(0); |
| 499 set_hwstat(0x80); | 499 set_hwstat(0x80); |
| 500 out_release: | 500 out_release: |
| 501 libusb_release_interface(devh, 0); | 501 libusb_release_interface(devh, 0); |
| 502 out: | 502 out: |
| 503 libusb_close(devh); | 503 libusb_close(devh); |
| 504 libusb_exit(NULL); | 504 libusb_exit(NULL); |
| 505 return r >= 0 ? r : -r; | 505 return r >= 0 ? r : -r; |
| 506 } | 506 } |
| 507 | |
| OLD | NEW |