Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libfprint
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
85
Issues
85
List
Boards
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
libfprint
libfprint
Commits
3ea28e33
Commit
3ea28e33
authored
Feb 26, 2008
by
Daniel Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provide access to fd set
Includes notifications when the set changes.
parent
88e9f4a5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
86 additions
and
6 deletions
+86
-6
libfprint/core.c
libfprint/core.c
+1
-0
libfprint/fp_internal.h
libfprint/fp_internal.h
+1
-0
libfprint/fprint.h
libfprint/fprint.h
+12
-0
libfprint/poll.c
libfprint/poll.c
+72
-6
No files found.
libfprint/core.c
View file @
3ea28e33
...
...
@@ -776,6 +776,7 @@ API_EXPORTED int fp_init(void)
return
r
;
register_drivers
();
fpi_poll_init
();
return
0
;
}
...
...
libfprint/fp_internal.h
View file @
3ea28e33
...
...
@@ -328,6 +328,7 @@ int fpi_img_compare_print_data_to_gallery(struct fp_print_data *print,
/* polling and timeouts */
void
fpi_poll_init
(
void
);
void
fpi_poll_exit
(
void
);
typedef
void
(
*
fpi_timeout_fn
)(
void
*
data
);
...
...
libfprint/fprint.h
View file @
3ea28e33
...
...
@@ -267,8 +267,20 @@ struct fp_minutia **fp_img_get_minutiae(struct fp_img *img, int *nr_minutiae);
void
fp_img_free
(
struct
fp_img
*
img
);
/* Polling and timing */
struct
fp_pollfd
{
int
fd
;
short
events
;
};
int
fp_handle_events_timeout
(
struct
timeval
*
timeout
);
int
fp_handle_events
(
void
);
size_t
fp_get_pollfds
(
struct
fp_pollfd
**
pollfds
);
typedef
void
(
*
fp_pollfd_added_cb
)(
int
fd
,
short
events
);
typedef
void
(
*
fp_pollfd_removed_cb
)(
int
fd
);
void
fp_set_pollfd_notifiers
(
fp_pollfd_added_cb
added_cb
,
fp_pollfd_removed_cb
removed_cb
);
/* Library */
int
fp_init
(
void
);
...
...
libfprint/poll.c
View file @
3ea28e33
...
...
@@ -61,18 +61,16 @@
* is expiring soonest at the head. */
static
GSList
*
active_timers
=
NULL
;
/* notifiers for added or removed poll fds */
static
fp_pollfd_added_cb
fd_added_cb
=
NULL
;
static
fp_pollfd_removed_cb
fd_removed_cb
=
NULL
;
struct
fpi_timeout
{
struct
timeval
expiry
;
fpi_timeout_fn
callback
;
void
*
data
;
};
void
fpi_poll_exit
(
void
)
{
g_slist_free
(
active_timers
);
active_timers
=
NULL
;
}
static
int
timeout_sort_fn
(
gconstpointer
_a
,
gconstpointer
_b
)
{
struct
fpi_timeout
*
a
=
(
struct
fpi_timeout
*
)
_a
;
...
...
@@ -245,3 +243,71 @@ API_EXPORTED int fp_handle_events(void)
return
fp_handle_events_timeout
(
&
tv
);
}
/** \ingroup poll
* Retrieve a list of file descriptors that should be polled for events
* interesting to libfprint. This function is only for users who wish to
* combine libfprint's file descriptor set with other event sources - more
* simplistic users will be able to call fp_handle_events() or a variant
* directly.
*
* \param pollfds output location for a list of pollfds. If non-NULL, must be
* released with free() when done.
* \returns the number of pollfds in the resultant list, or negative on error.
*/
API_EXPORTED
size_t
fp_get_pollfds
(
struct
fp_pollfd
**
pollfds
)
{
struct
libusb_pollfd
*
usbfds
;
struct
fp_pollfd
*
ret
;
size_t
cnt
;
size_t
i
;
cnt
=
libusb_get_pollfds
(
&
usbfds
);
if
(
cnt
<=
0
)
{
*
pollfds
=
NULL
;
return
cnt
;
}
ret
=
g_malloc
(
sizeof
(
struct
libusb_pollfd
)
*
cnt
);
for
(
i
=
0
;
i
<
cnt
;
i
++
)
{
ret
[
i
].
fd
=
usbfds
[
i
].
fd
;
ret
[
i
].
events
=
usbfds
[
i
].
events
;
}
*
pollfds
=
ret
;
return
cnt
;
}
/* FIXME: docs */
API_EXPORTED
void
fp_set_pollfd_notifiers
(
fp_pollfd_added_cb
added_cb
,
fp_pollfd_removed_cb
removed_cb
)
{
fd_added_cb
=
added_cb
;
fd_removed_cb
=
removed_cb
;
}
static
void
add_pollfd
(
int
fd
,
short
events
)
{
if
(
fd_added_cb
)
fd_added_cb
(
fd
,
events
);
}
static
void
remove_pollfd
(
int
fd
)
{
if
(
fd_removed_cb
)
fd_removed_cb
(
fd
);
}
void
fpi_poll_init
(
void
)
{
libusb_set_pollfd_notifiers
(
add_pollfd
,
remove_pollfd
);
}
void
fpi_poll_exit
(
void
)
{
g_slist_free
(
active_timers
);
active_timers
=
NULL
;
fd_added_cb
=
NULL
;
fd_removed_cb
=
NULL
;
libusb_set_pollfd_notifiers
(
NULL
,
NULL
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment