aboutsummaryrefslogtreecommitdiffstats
path: root/src/fdtable.h
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2019-06-07 09:17:53 +0000
committerWerner Koch <[email protected]>2019-06-07 09:17:53 +0000
commit52d8ed8dfb91a2b302c20bee27e9a28b7cb6a518 (patch)
tree427ee906e5d794a4aacaceac7fdfaf3dd79eb180 /src/fdtable.h
parenttests: Minor fix to run-threaded.c. (diff)
downloadgpgme-52d8ed8dfb91a2b302c20bee27e9a28b7cb6a518.tar.gz
gpgme-52d8ed8dfb91a2b302c20bee27e9a28b7cb6a518.zip
core: Replace the posix close notify mechanism by a new generic one.
* src/fdtable.c, src/fdtable.h: New. * src/posix-io.c (notify_table_item_s): Remove. (notify_table, notify_table_size, notify_table_lock): Remove. (_gpgme_io_pipe): Put new fds into the table. (_gpgme_io_dup): Ditto. (_gpgme_io_close): Replace notify stuff by a call to the fdtable. (_gpgme_io_set_close_notify): Remove. Change all callers to to use _gpgme_fdtable_add_close_notify. * src/Makefile.am (main_sources): Add new files. -- This is the first part or a larger change to unify the tracking of file descriptors. Right now this has only been implemented for Posix and thus the code will not yet build for Windows. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'src/fdtable.h')
-rw-r--r--src/fdtable.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/fdtable.h b/src/fdtable.h
new file mode 100644
index 00000000..6038b249
--- /dev/null
+++ b/src/fdtable.h
@@ -0,0 +1,43 @@
+/* fdtable.h - Keep track of file descriptors.
+ * Copyright (C) 2019 g10 Code GmbH
+ *
+ * This file is part of GPGME.
+ *
+ * GPGME 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.
+ *
+ * GPGME 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 program; if not, see <https://gnu.org/licenses/>.
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef GPGME_FDTABLE_H
+#define GPGME_FDTABLE_H
+
+/* The handler type associated with an FD. It is called with the FD
+ * and the registered pointer. The handler may return an error code
+ * but there is no guarantee that this code is used; in particular
+ * errors from close notifications can't inhibit the the closing. */
+typedef gpg_error_t (*fdtable_handler_t) (int, void*);
+
+
+/* Insert a new FD into the table. */
+gpg_error_t _gpgme_fdtable_insert (int fd);
+
+/* Add a close notification handler to the FD item. */
+gpg_error_t _gpgme_fdtable_add_close_notify (int fd,
+ fdtable_handler_t handler,
+ void *value);
+
+/* Remove FD from the table. This also runs the close handlers. */
+gpg_error_t _gpgme_fdtable_remove (int fd);
+
+
+#endif /*GPGME_FDTABLE_H*/