Full libfprint interface for Pascal:{
* Main definitions for libfprint
* Copyright (C) 2007 Daniel Drake <dsd@gentoo.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
}
// FreePascal conversion by TCH of EverLink
unit fprint;
interface
{$LINKLIB libfprint}
{$inline on}
uses unixtype;
{ structs that applications are not allowed to peek into }
type
fp_dscv_dev = record end;
fp_dscv_print = record end;
fp_dev = record end;
fp_driver = record end;
fp_print_data = record end;
fp_img = record end;
pfp_dscv_dev = ^fp_dscv_dev;
pfp_dscv_print = ^fp_dscv_print;
pfp_dev = ^fp_dev;
pfp_driver = ^fp_driver;
pfp_print_data = ^fp_print_data;
pfp_img = ^fp_img;
ppfp_dscv_dev = ^pfp_dscv_dev;
ppfp_dscv_print = ^pfp_dscv_print;
ppfp_dev = ^pfp_dev;
ppfp_driver = ^pfp_driver;
ppfp_print_data = ^pfp_print_data;
ppfp_img = ^pfp_img;
{ misc/general stuff }
{* \ingroup print_data
* Numeric codes used to refer to fingers (and thumbs) of a human. These are
* purposely not available as strings, to avoid getting the library tangled up
* in localization efforts.
}
const
LEFT_THUMB = 01; {* thumb (left hand) }
LEFT_INDEX = 02; {* index finger (left hand) }
LEFT_MIDDLE = 03; {* middle finger (left hand) }
LEFT_RING = 04; {* ring finger (left hand) }
LEFT_LITTLE = 05; {* little finger (left hand) }
RIGHT_THUMB = 06; {* thumb (right hand) }
RIGHT_INDEX = 07; {* index finger (right hand) }
RIGHT_MIDDLE = 08; {* middle finger (right hand) }
RIGHT_RING = 09; {* ring finger (right hand) }
RIGHT_LITTLE = 10; {* little finger (right hand) }
{* \ingroup dev
* Numeric codes used to refer to the scan type of the device. Devices require
* either swiping or pressing the finger on the device. This is useful for
* front-ends.
}
const
FP_SCAN_TYPE_PRESS = 0; {* press }
FP_SCAN_TYPE_SWIPE = 1; {* swipe }
{ Drivers }
function fp_driver_get_name(dev: pfp_driver): pchar; cdecl; external;
function fp_driver_get_full_name(dev: pfp_driver): pchar; cdecl; external;
function fp_driver_get_driver_id(dev: pfp_driver): word; cdecl; external;
function fp_driver_get_scan_type(dev: pfp_driver): longint; cdecl; external;
{ Device discovery }
function fp_discover_devs: ppfp_dscv_dev; cdecl; external;
procedure fp_dscv_devs_free(devs: ppfp_dscv_dev); cdecl; external;
function fp_dscv_dev_get_driver(dev: pfp_dscv_dev): pfp_driver; cdecl; external;
function fp_dscv_dev_get_devtype(dev: pfp_dscv_dev): longword; cdecl; external;
function fp_dscv_dev_supports_print_data(dev: pfp_dscv_dev; print: pfp_print_data): longint; cdecl; external;
function fp_dscv_dev_supports_dscv_print(dev: pfp_dscv_dev; print: pfp_dscv_print): longint; cdecl; external;
function fp_dscv_dev_for_print_data(devs: ppfp_dscv_dev; print: pfp_print_data): pfp_dscv_dev; cdecl; external;
function fp_dscv_dev_for_dscv_print(devs: ppfp_dscv_dev; print: pfp_dscv_print): pfp_dscv_dev; cdecl; external;
function fp_dscv_dev_get_driver_id(dev: pfp_dscv_dev): word; inline;
{ Print discovery }
function fp_discover_prints: ppfp_dscv_print; cdecl; external;
procedure fp_dscv_prints_free(prints: ppfp_dscv_print); cdecl; external;
function fp_dscv_print_get_driver_id(print: pfp_dscv_print): word; cdecl; external;
function fp_dscv_print_get_devtype(print: pfp_dscv_print): longword; cdecl; external;
function fp_dscv_print_get_finger(print: pfp_dscv_print): longint; cdecl; external;
function fp_dscv_print_delete(print: pfp_dscv_print): longint; cdecl; external;
{ Device handling }
function fp_dev_open(ddev: pfp_dscv_dev): pfp_dev; cdecl; external;
procedure fp_dev_close(dev: pfp_dev); cdecl; external;
function fp_dev_get_driver(dev: pfp_dev): pfp_driver; cdecl; external;
function fp_dev_get_nr_enroll_stages(dev: pfp_dev): longint; cdecl; external;
function fp_dev_get_devtype(dev: pfp_dev): longword; cdecl; external;
function fp_dev_supports_print_data(dev: pfp_dev; data: pfp_print_data): longint; cdecl; external;
function fp_dev_supports_dscv_print(dev: pfp_dev; print: pfp_dscv_print): longint; cdecl; external;
function fp_dev_supports_imaging(dev: pfp_dev): longint; cdecl; external;
function fp_dev_img_capture(dev: pfp_dev; unconditional: longint; image: ppfp_img): longint; cdecl; external;
function fp_dev_get_img_width(dev: pfp_dev): longint; cdecl; external;
function fp_dev_get_img_height(dev: pfp_dev): longint; cdecl; external;
{* \ingroup dev
* Enrollment result codes returned from fp_enroll_finger().
* Result codes with RETRY in the name suggest that the scan failed due to
* user error. Applications will generally want to inform the user of the
* problem and then retry the enrollment stage. For more info on the semantics
* of interpreting these result codes and tracking enrollment process, see
* \ref enrolling.
}
const
{* Enrollment completed successfully, the enrollment data has been
* returned to the caller. }
FP_ENROLL_COMPLETE = 001;
{* Enrollment failed due to incomprehensible data; this may occur when
* the user scans a different finger on each enroll stage. }
FP_ENROLL_FAIL = 002;
{* Enroll stage passed; more stages are need to complete the process. }
FP_ENROLL_PASS = 003;
{* The enrollment scan did not succeed due to poor scan quality or
* other general user scanning problem. }
FP_ENROLL_RETRY = 100;
{* The enrollment scan did not succeed because the finger swipe was
* too short. }
FP_ENROLL_RETRY_TOO_SHORT = 101;
{* The enrollment scan did not succeed because the finger was not
* centered on the scanner. }
FP_ENROLL_RETRY_CENTER_FINGER = 102;
{* The verification scan did not succeed due to quality or pressure
* problems; the user should remove their finger from the scanner before
* retrying. }
FP_ENROLL_RETRY_REMOVE_FINGER = 103;
function fp_enroll_finger_img(dev: pfp_dev; print_data: ppfp_print_data; img: ppfp_img): longint; cdecl; external;
{* \ingroup dev
* Performs an enroll stage. See \ref enrolling for an explanation of enroll
* stages. This function is just a shortcut to calling fp_enroll_finger_img()
* with a NULL image parameter. Be sure to read the description of
* fp_enroll_finger_img() in order to understand its behaviour.
*
* \param dev the device
* \param print_data a location to return the resultant enrollment data from
* the final stage. Must be freed with fp_print_data_free() after use.
* \return negative code on error, otherwise a code from #fp_enroll_result
}
function fp_enroll_finger(dev: pfp_dev; print_data: ppfp_print_data): longint; inline;
{* \ingroup dev
* Verification result codes returned from fp_verify_finger(). Return codes
* are also shared with fp_identify_finger().
* Result codes with RETRY in the name suggest that the scan failed due to
* user error. Applications will generally want to inform the user of the
* problem and then retry the verify operation.
}
const
{* The scan completed successfully, but the newly scanned fingerprint
* does not match the fingerprint being verified against.
* In the case of identification, this return code indicates that the
* scanned finger could not be found in the print gallery. }
FP_VERIFY_NO_MATCH = 0;
{* The scan completed successfully and the newly scanned fingerprint does
* match the fingerprint being verified, or in the case of identification,
* the scanned fingerprint was found in the print gallery. }
FP_VERIFY_MATCH = 1;
{* The scan did not succeed due to poor scan quality or other general
* user scanning problem. }
FP_VERIFY_RETRY = FP_ENROLL_RETRY;
{* The scan did not succeed because the finger swipe was too short. }
FP_VERIFY_RETRY_TOO_SHORT = FP_ENROLL_RETRY_TOO_SHORT;
{* The scan did not succeed because the finger was not centered on the
* scanner. }
FP_VERIFY_RETRY_CENTER_FINGER = FP_ENROLL_RETRY_CENTER_FINGER;
{* The scan did not succeed due to quality or pressure problems; the user
* should remove their finger from the scanner before retrying. }
FP_VERIFY_RETRY_REMOVE_FINGER = FP_ENROLL_RETRY_REMOVE_FINGER;
function fp_verify_finger_img(dev: pfp_dev; enrolled_print: pfp_print_data; img: ppfp_img): longint; cdecl; external;
{* \ingroup dev
* Performs a new scan and verify it against a previously enrolled print. This
* function is just a shortcut to calling fp_verify_finger_img() with a NULL
* image output parameter.
* \param dev the device to perform the scan.
* \param enrolled_print the print to verify against. Must have been previously
* enrolled with a device compatible to the device selected to perform the scan.
* \return negative code on error, otherwise a code from #fp_verify_result
* \sa fp_verify_finger_img()
}
function fp_verify_finger(dev: pfp_dev; enrolled_print: pfp_print_data): longint; inline;
function fp_dev_supports_identification(dev: pfp_dev): longint; cdecl; external;
function fp_identify_finger_img(dev: pfp_dev; print_gallery: ppfp_print_data; match_offset: psize_t; img: ppfp_img): longint; cdecl; external;
{* \ingroup dev
* Performs a new scan and attempts to identify the scanned finger against a
* collection of previously enrolled fingerprints. This function is just a
* shortcut to calling fp_identify_finger_img() with a NULL image output
* parameter.
* \param dev the device to perform the scan.
* \param print_gallery NULL-terminated array of pointers to the prints to
* identify against. Each one must have been previously enrolled with a device
* compatible to the device selected to perform the scan.
* \param match_offset output location to store the array index of the matched
* gallery print (if any was found). Only valid if FP_VERIFY_MATCH was
* returned.
* \return negative code on error, otherwise a code from #fp_verify_result
* \sa fp_identify_finger_img()
}
function fp_identify_finger(dev: pfp_dev; print_gallery: ppfp_print_data; match_offset: psize_t): longint; inline;
{ Data handling }
function fp_print_data_load(dev: pfp_dev; finger: longint; data: ppfp_print_data): longint; cdecl; external;
function fp_print_data_from_dscv_print(print: pfp_dscv_print; data: ppfp_print_data): longint; cdecl; external;
function fp_print_data_save(data: pfp_print_data; finger: longint): longint; cdecl; external;
function fp_print_data_delete(dev: pfp_dev; finger: longint): longint; cdecl; external;
procedure fp_print_data_free(data: pfp_print_data); cdecl; external;
function fp_print_data_get_data(data: pfp_print_data; ret: ppbyte): size_t; cdecl; external;
function fp_print_data_from_data(buf: pbyte; buflen: size_t): pfp_print_data; cdecl; external;
function fp_print_data_get_driver_id(data: pfp_print_data): word; cdecl; external;
function fp_print_data_get_devtype(data: pfp_print_data): longword; cdecl; external;
{ Image handling }
{* \ingroup img }
type
fp_minutia = record
x: longint;
y: longint;
ex: longint;
ey: longint;
direction: longint;
reliability: double;
type_: longint;
appearing: longint;
feature_id: longint;
nbrs: plongint;
ridge_counts: plongint;
num_nbrs: longint;
end;
pfp_minutia = ^fp_minutia;
ppfp_minutia = ^pfp_minutia;
function fp_img_get_height(img: pfp_img): longint; cdecl; external;
function fp_img_get_width(img: pfp_img): longint; cdecl; external;
function fp_img_get_data(img: pfp_img): pbyte; cdecl; external;
function fp_img_save_to_file(img: pfp_img; path: pchar): longint; cdecl; external;
procedure fp_img_standardize(img: pfp_img); cdecl; external;
function fp_img_binarize(img: pfp_img): pfp_img; cdecl; external;
function fp_img_get_minutiae(img: pfp_img; nr_minutiae: plongint): ppfp_minutia; cdecl; external;
procedure fp_img_free(img: pfp_img); cdecl; external;
{ Polling and timing }
type
fp_pollfd = record
fd: longint;
events: smallint;
end;
pfp_pollfd = ^fp_pollfd;
ppfp_pollfd = ^pfp_pollfd;
function fp_handle_events_timeout(timeout: ptimeval): longint; cdecl; external;
function fp_handle_events: longint; cdecl; external;
function fp_get_pollfds(pollfds: ppfp_pollfd): size_t; cdecl; external;
function fp_get_next_timeout(tv: ptimeval): longint; cdecl; external;
type tfp_pollfd_added_cb = procedure (fd: longint; events: smallint);
type tfp_pollfd_removed_cb = procedure (fd: longint);
procedure fp_set_pollfd_notifiers(added_cb: tfp_pollfd_added_cb; removed_cb: tfp_pollfd_removed_cb); cdecl; external;
{ Library }
function fp_init: longint; cdecl; external;
procedure fp_exit; cdecl; external;
procedure fp_set_debug(level: longint); cdecl; external;
{ Asynchronous I/O }
type tfp_dev_open_cb = procedure (dev: pfp_dev; status: longint; user_data: pointer);
function fp_async_dev_open(ddev: pfp_dscv_dev; callback: tfp_dev_open_cb; user_data: pointer): longint; cdecl; external;
type tfp_dev_close_cb = procedure (dev: pfp_dev; user_data: pointer);
procedure fp_async_dev_close(dev: pfp_dev; callback: tfp_dev_close_cb; user_data: pointer); cdecl; external;
type tfp_enroll_stage_cb = procedure (dev: pfp_dev; result: longint; print: pfp_print_data; img: pfp_img; user_data: pointer);
function fp_async_enroll_start(dev: pfp_dev; callback: tfp_enroll_stage_cb; user_data: pointer): longint; cdecl; external;
type tfp_enroll_stop_cb = procedure (dev: pfp_dev; user_data: pointer);
function fp_async_enroll_stop(dev: pfp_dev; callback: tfp_enroll_stop_cb; user_data: pointer): longint; cdecl; external;
type tfp_verify_cb = procedure (dev: pfp_dev; result: longint; img: pfp_img; user_data: pointer);
function fp_async_verify_start(dev: pfp_dev; data: pfp_print_data; callback: tfp_verify_cb; user_data: pointer): longint; cdecl; external;
type tfp_verify_stop_cb = procedure (dev: pfp_dev; user_data: pointer);
function fp_async_verify_stop(dev: pfp_dev; callback: tfp_verify_stop_cb; user_data: pointer): longint; cdecl; external;
type tfp_identify_cb = procedure (dev: pfp_dev; result: longint; match_offset: size_t; img: pfp_img; user_data: pointer);
function fp_async_identify_start(dev: pfp_dev; gallery: ppfp_print_data; callback: tfp_identify_cb; user_data: pointer): longint; cdecl; external;
type tfp_identify_stop_cb = procedure (dev: pfp_dev; user_data: pointer);
function fp_async_identify_stop(dev: pfp_dev; callback: tfp_identify_stop_cb; user_data: pointer): longint; cdecl; external;
implementation
function fp_dscv_dev_get_driver_id(dev: pfp_dscv_dev): word; inline;
begin
fp_dscv_dev_get_driver_id := fp_driver_get_driver_id(fp_dscv_dev_get_driver(dev));
end;
function fp_enroll_finger(dev: pfp_dev; print_data: ppfp_print_data): longint; inline;
begin
fp_enroll_finger := fp_enroll_finger_img(dev, print_data, nil);
end;
function fp_verify_finger(dev: pfp_dev; enrolled_print: pfp_print_data): longint; inline;
begin
fp_verify_finger := fp_verify_finger_img(dev, enrolled_print, nil);
end;
function fp_identify_finger(dev: pfp_dev; print_gallery: ppfp_print_data; match_offset: psize_t): longint; inline;
begin
fp_identify_finger := fp_identify_finger_img(dev, print_gallery, match_offset, nil);
end;
{$inline off}
end. |