int main(void) { struct fp_dscv_dev *ddev; struct fp_dscv_dev **discovered_devs; struct fp_dev *dev; struct fp_print_data *data; int r = fp_init(); if (r < 0) { fprintf(stderr, "Failed to initialize libfprint\n"); exit(1); } fp_set_debug(3); discovered_devs = fp_discover_devs(); if (!discovered_devs) { fprintf(stderr, "Could not discover devices\n"); goto out; } ddev = discover_device(discovered_devs); if (!ddev) { fprintf(stderr, "No devices detected.\n"); goto out; } dev = fp_dev_open(ddev); fp_dscv_devs_free(discovered_devs); if (!dev) { fprintf(stderr, "Could not open device.\n"); goto out; } printf("Opened device. Loading previously enrolled right index finger " "data...\n"); r = fp_print_data_load(dev, RIGHT_INDEX, &data); if (r != 0) { fprintf(stderr, "Failed to load fingerprint, error %d\n", r); fprintf(stderr, "Did you remember to enroll your right index finger " "first?\n"); goto out_close; } printf("Print loaded. Time to verify!\n"); do { char buffer[20]; verify(dev, data); printf("Verify again? [Y/n]? "); fgets(buffer, sizeof(buffer), stdin); if (buffer[0] != '\n' && buffer[0] != 'y' && buffer[0] != 'Y') break; } while (1); fp_print_data_free(data); out_close: fp_dev_close(dev); out: fp_exit(); return r; }
int main(void) { int r = 1; struct fp_dscv_dev *ddev; struct fp_dscv_dev **discovered_devs; struct fp_dev *dev; struct fp_print_data *data; r = fp_init(); if (r < 0) { printf("Failed to initialize fprint\n"); exit(1); } fp_set_debug(3); discovered_devs = fp_discover_devs(); if (!discovered_devs) { printf("Could not discover devices\n"); goto out; } ddev = discover_device(discovered_devs); if (!ddev) { printf("No devices detected.\n"); goto out; } dev = fp_dev_open(ddev); fp_dscv_devs_free(discovered_devs); if (!dev) { printf("Could not open device.\n"); goto out; } printf("Opened device. " "enrolling...\n"); r = fp_print_data_load(dev, RIGHT_INDEX, &data); if (r != 0) { printf("Failed to load fingerprint,\n"); goto out_close; } printf("Print loaded. Try to verify!\n"); do { char buffer[20]; verify(dev, data); printf("Verify again? [Y/n]? "); fgets(buffer, sizeof(buffer), stdin); if (buffer[0] != '\n' && buffer[0] != 'y' && buffer[0] != 'Y') break; } while (1); fp_print_data_free(data); out_close: fp_dev_close(dev); out: fp_exit(); return r; }