// Signal handler static void signal_handler(int sig) { // Ctrl + C if (sig == SIGINT) { fp_exit(); exit(1); } }
int main(int argc, char **argv) { int r; r = fp_init(); if (r < 0) return r; gtk_init(&argc, &argv); gtk_window_set_default_icon_name("fprint_demo"); r = setup_pollfds(); if (r < 0) return r; mwin_create(); mwin_populate_devs(); mwin_select_first_dev(); gtk_main(); if (fpdev) fp_dev_close(fpdev); fp_exit(); return 0; }
/** * Enrolls a finger and returns the associated fp-data. * * @param env the Java Environment pointer. * @param obj the jobject of the type jlibfprint/JlibFprint. * @return the jlibfprint/JlibFprint$fp_print_data with the data just given by the scanner. * @throws an enroll_exception is raised is something gone wrong. */ JNIEXPORT jobject JNICALL Java_jlibfprint_JlibFprint_enroll_1finger(JNIEnv* env, jobject ref) { const jclass fpClass = env->FindClass("jlibfprint/JlibFprint$fp_print_data"); const jclass eeClass = env->FindClass("jlibfprint/JlibFprint$EnrollException"); /* Starts the library */ if (fp_init()) // Se differente da 0 => Exception { jobject enrollException = env->AllocObject(eeClass); jfieldID eeExcp_id = env->GetFieldID(eeClass, "enroll_exception", "I"); env->SetIntField(enrollException, eeExcp_id, UNABLE_TO_LOAD_LIBFPRINT); env->Throw((jthrowable)enrollException); return NULL; } fp_dev *device; fp_print_data* pdp; /* Gets the pointer to the device */ if (!get_device_id(env, ref, &device)) { jobject enrollException = env->AllocObject(eeClass); jfieldID eeExcp_id = env->GetFieldID(eeClass, "enroll_exception", "I"); env->SetIntField(enrollException, eeExcp_id, DEVICE_NOT_FOUND); env->Throw((jthrowable)enrollException); return NULL; } /* Enrolls the finger */ int ef = fp_enroll_finger(device, &pdp); /* Create a new obj to store the data */ jobject obj = env->AllocObject(fpClass); /* Raises an exception if the enrollment was not completed */ if (ef != FP_ENROLL_COMPLETE) { jobject enrollException = env->AllocObject(eeClass); jfieldID eeExcp_id = env->GetFieldID(eeClass, "enroll_exception", "I"); env->SetIntField(enrollException, eeExcp_id, ef); env->Throw((jthrowable)enrollException); } else { /* Fills the object with the enrollment data */ cfp2jfp(env, obj, pdp); memset(pdp, 0, sizeof(fp_print_data)); fp_print_data_free(pdp); } fp_dev_close(device); fp_exit(); return obj; }
int main(void) { // Vars struct fp_dev *device; struct fp_driver *driver; struct fp_print_data *print_data; struct fp_img *img; int err; // Init the LCD lcdinit(0x00, 0x12, 0x20); lcd_reset(); // Init libfprint fp_init(); // Init the keypad matrix_init(4, 17, 27, 22, 10, 9, 11, handle_key_press); // Signal handler - does an fp_exit() on SIGINT init_signals(); // Get the first fingerprint device if ((err = get_fingerprint_device(&device)) < 0 || !device) { // Errorz if (err == -1) { error("No devices found"); } else if (err == -2) { error("Couldn't open the device"); } return 1; } // Get driver driver = fp_dev_get_driver(device); // Init message printf("Programme started! Device is %s\n\n", fp_driver_get_full_name(driver)); // Scan the print fp_enroll_finger_img(device, &print_data, &img); // Deinit libfprint fp_exit(); return 0; }
int main(){ //initialize if (fp_init()){ printf("libfprint patladi!\n"); exit(1); //failure } //dev discovery struct fp_dscv_dev** ddevicelist; struct fp_dscv_dev* ddevice; if (!(ddevicelist = fp_discover_devs())){ //listeyi al printf("Device discovery calismadi!\n"); exit(1); //failure } if(!(ddevice = ddevicelist[0])){ //bos? TODO: 2 alet varsa nolacak? printf("Alet nerde?\n"); exit(1); //failure } print_driver_info(ddevice); //open dev struct fp_dev* device; if(!(device = fp_dev_open(ddevice))){ printf("Okuyucu baslamadi!\n"); exit(1); //failure } //get image fp_img_save_to_file(get_image(device), "./parmak.pgm"); //TODO: nasi freelenir lan bu? //cleanup fp_dev_close(device); fp_exit(); return 0; }
int main(int argc, char **argv) { GOptionContext *context; GMainLoop *loop; GError *error = NULL; FprintManager *manager; DBusGProxy *driver_proxy; guint32 request_name_ret; int r = 0; bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); context = g_option_context_new ("Fingerprint handler daemon"); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_type_init(); if (g_option_context_parse (context, &argc, &argv, &error) == FALSE) { g_print ("couldn't parse command-line options: %s\n", error->message); g_error_free (error); return 1; } if (g_fatal_warnings) { GLogLevelFlags fatal_mask; fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK); fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL; g_log_set_always_fatal (fatal_mask); } /* Load the configuration file, * and the default storage plugin */ if (!load_conf()) set_storage_file (); store.init (); r = fp_init(); if (r < 0) { g_error("fprint init failed with error %d\n", r); return r; } loop = g_main_loop_new(NULL, FALSE); r = setup_pollfds(); if (r < 0) { g_print("pollfd setup failed\n"); goto err; } g_print("Launching FprintObject\n"); /* Obtain a connection to the session bus */ fprintd_dbus_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error); if (fprintd_dbus_conn == NULL) g_error("Failed to open connection to bus: %s", error->message); /* create the one instance of the Manager object to be shared between * all fprintd users */ manager = fprint_manager_new(no_timeout); driver_proxy = dbus_g_proxy_new_for_name(fprintd_dbus_conn, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); if (!org_freedesktop_DBus_request_name(driver_proxy, FPRINT_SERVICE_NAME, 0, &request_name_ret, &error)) g_error("Failed to get name: %s", error->message); if (request_name_ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { g_error ("Got result code %u from requesting name", request_name_ret); exit(1); } g_message("D-Bus service launched with name: %s", FPRINT_SERVICE_NAME); g_message("entering main loop"); g_main_loop_run(loop); g_message("main loop completed"); err: fp_exit(); return 0; }
int main(int argc, char *argv[]) { int r = 1, i; int next_option; enum fp_finger finger = RIGHT_INDEX; struct fp_dscv_dev *ddev; struct fp_dscv_dev **discovered_devs; struct fp_dev *dev; struct fp_print_data *data; const char * const short_options = "hf:"; const struct option long_options[] = { { "help", 0, NULL, 'h'}, { "enroll-finger", 1, NULL, 'f'}, { NULL, 0, NULL, 0} }; do { next_option = getopt_long(argc, argv, short_options, long_options, NULL); switch (next_option) { case 'h': /* Printing usage */ printf("Usage: %s options\n", argv[0]); printf(" -h --help Display this usage information.\n" " -f --enroll-finger index Enroll finger with index.\n\n"); printf(" Valid indexes are:\n"); for (i = LEFT_THUMB; i <= RIGHT_LITTLE; i++) { printf(" %d - %s\n", i, finger_names[i]); } exit(1); break; case 'f': sscanf(optarg, "%d", &finger); if (finger < LEFT_THUMB || finger > RIGHT_LITTLE) { printf("%s: Invalid finger index.\n", argv[0]); printf("%s: Valid indexes are:\n", argv[0]); for (i = LEFT_THUMB; i <= RIGHT_LITTLE; i++) { printf("%s: %d - %s\n", argv[0], i, finger_names[i]); } exit(1); } break; case -1: /* Done with options. */ break; default: /* Unexpected option */ exit(1); } } while (next_option != -1); printf("This program will enroll your finger, " "unconditionally overwriting any selected print that was enrolled " "previously. If you want to continue, press enter, otherwise hit " "Ctrl+C\n"); getchar(); r = fp_init(); if (r < 0) { fprintf(stderr, "Failed to initialize libfprint\n"); exit(1); } 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. It's now time to enroll your finger.\n\n"); data = enroll(dev, finger); if (!data) goto out_close; r = fp_print_data_save(data, finger); if (r < 0) fprintf(stderr, "Data save failed, code %d\n", r); fp_print_data_free(data); out_close: fp_dev_close(dev); out: fp_exit(); return r; }
int main(){ //initialize if (fp_init()){ printf("libfprint patladi!\n"); exit(1); //failure } //dev discovery struct fp_dscv_dev** ddevicelist; struct fp_dscv_dev* ddevice; if (!(ddevicelist = fp_discover_devs())){ //listeyi al printf("Device discovery calismadi!\n"); exit(1); //failure } if(!(ddevice = ddevicelist[0])){ //bos? TODO: 2 alet varsa nolacak? printf("Alet nerde?\n"); exit(1); //failure } print_driver_info(ddevice); //open device struct fp_dev* device; if(!(device = fp_dev_open(ddevice))){ printf("Okuyucu baslamadi!\n"); exit(1); //failure } //enroll //printf("%d", fp_dev_get_nr_enroll_stages(device)); //tek olmali, cunku laptop. int done = 0; struct fp_print_data* guvenliparmak = NULL; while(!done){ switch(fp_enroll_finger_img(device, &guvenliparmak, NULL)){ case FP_ENROLL_FAIL: printf("Parmakizi alimi tamamlanamadi!\n"); exit(1); //fail case FP_ENROLL_COMPLETE: done = 1; printf("Parmakizi alimi basariyla tamamlandi.\n"); break; case FP_ENROLL_PASS: printf("Tanima asamasi basarili..\n"); break; default: printf("Yeniden deneyin!\n"); break; } } fp_print_data_free(guvenliparmak); //cleanup fp_dev_close(device); fp_exit(); return 0; }
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. It's now time to enroll your finger.\n\n"); data = enroll(dev); if (!data) goto out_close; printf("Normally we'd save that print to disk, and recall it at some " "point later when we want to authenticate the user who just " "enrolled. In the interests of demonstration, we'll authenticate " "that user immediately.\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 (int argc, char **argv) { int r = 1; struct fp_dscv_dev *ddev; struct fp_dscv_dev **discovered_devs; struct fp_dev *dev; struct fp_print_data *data; int finger; finger = atoi(argv[3]); printf ("This program will enroll your right index finger, " "unconditionally overwriting any right-index print that was enrolled " "previously. If you want to continue, press enter, otherwise hit " "Ctrl+C\n"); getchar (); 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. It's now time to enroll your finger.\n\n"); data = enroll (dev); if (!data) goto out_close; r = fp_print_data_save (data, finger, argv[1], argv[2]); if (r < 0) fprintf (stderr, "Data save failed, code %d\n", r); fp_print_data_free (data); out_close: fp_dev_close (dev); out: fp_exit (); return r; }
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; }