1 /* Hook for making the close() function extensible.
2 Copyright (C) 2009, 2010 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published
6 by the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
26 /* Currently, this entire code is only needed for the handling of sockets
27 on native Windows platforms. */
31 /* An element of the list of close hooks.
32 The fields of this structure are considered private. */
35 /* Doubly linked list. */
36 struct close_hook
*private_next
;
37 struct close_hook
*private_prev
;
38 /* Function that treats the types of FD that it knows about and calls
39 execute_close_hooks (FD, REMAINING_LIST) as a fallback. */
40 int (*private_fn
) (int fd
, const struct close_hook
*remaining_list
);
43 /* This type of function closes FD, applying special knowledge for the FD
44 types it knows about, and calls execute_close_hooks (FD, REMAINING_LIST)
45 for the other FD types. */
46 typedef int (*close_hook_fn
) (int fd
, const struct close_hook
*remaining_list
);
48 /* Execute the close hooks in REMAINING_LIST.
49 Return 0 or -1, like close() would do. */
50 extern int execute_close_hooks (int fd
, const struct close_hook
*remaining_list
);
52 /* Execute all close hooks.
53 Return 0 or -1, like close() would do. */
54 extern int execute_all_close_hooks (int fd
);
56 /* Add a function to the list of close hooks.
57 The LINK variable points to a piece of memory which is guaranteed to be
58 accessible until the corresponding call to unregister_close_hook. */
59 extern void register_close_hook (close_hook_fn hook
, struct close_hook
*link
);
61 /* Removes a function from the list of close hooks. */
62 extern void unregister_close_hook (struct close_hook
*link
);
72 #endif /* CLOSE_HOOK_H */