1/* -*- buffer-read-only: t -*- vi: set ro: */ 2/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 3#line 1 4/* Hook for making the close() function extensible. 5 Copyright (C) 2009, 2010 Free Software Foundation, Inc. 6 7 This program is free software: you can redistribute it and/or modify it 8 under the terms of the GNU General Public License as published 9 by the Free Software Foundation; either version 3 of the License, or 10 (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 Lesser General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 19 20 21#ifndef CLOSE_HOOK_H 22#define CLOSE_HOOK_H 23 24#ifdef __cplusplus 25extern "C" { 26#endif 27 28 29/* Currently, this entire code is only needed for the handling of sockets 30 on native Windows platforms. */ 31#if WINDOWS_SOCKETS 32 33 34/* An element of the list of close hooks. 35 The fields of this structure are considered private. */ 36struct close_hook 37{ 38 /* Doubly linked list. */ 39 struct close_hook *private_next; 40 struct close_hook *private_prev; 41 /* Function that treats the types of FD that it knows about and calls 42 execute_close_hooks (FD, REMAINING_LIST) as a fallback. */ 43 int (*private_fn) (int fd, const struct close_hook *remaining_list); 44}; 45 46/* This type of function closes FD, applying special knowledge for the FD 47 types it knows about, and calls execute_close_hooks (FD, REMAINING_LIST) 48 for the other FD types. */ 49typedef int (*close_hook_fn) (int fd, const struct close_hook *remaining_list); 50 51/* Execute the close hooks in REMAINING_LIST. 52 Return 0 or -1, like close() would do. */ 53extern int execute_close_hooks (int fd, const struct close_hook *remaining_list); 54 55/* Execute all close hooks. 56 Return 0 or -1, like close() would do. */ 57extern int execute_all_close_hooks (int fd); 58 59/* Add a function to the list of close hooks. 60 The LINK variable points to a piece of memory which is guaranteed to be 61 accessible until the corresponding call to unregister_close_hook. */ 62extern void register_close_hook (close_hook_fn hook, struct close_hook *link); 63 64/* Removes a function from the list of close hooks. */ 65extern void unregister_close_hook (struct close_hook *link); 66 67 68#endif 69 70 71#ifdef __cplusplus 72} 73#endif 74 75#endif /* CLOSE_HOOK_H */ 76