Back to index

nagios-plugins  1.4.16
close-hook.h
Go to the documentation of this file.
00001 /* Hook for making the close() function extensible.
00002    Copyright (C) 2009, 2010 Free Software Foundation, Inc.
00003 
00004    This program is free software: you can redistribute it and/or modify it
00005    under the terms of the GNU General Public License as published
00006    by the Free Software Foundation; either version 3 of the License, or
00007    (at your option) any later version.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU General Public License
00015    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00016 
00017 
00018 #ifndef CLOSE_HOOK_H
00019 #define CLOSE_HOOK_H
00020 
00021 #ifdef __cplusplus
00022 extern "C" {
00023 #endif
00024 
00025 
00026 /* Currently, this entire code is only needed for the handling of sockets
00027    on native Windows platforms.  */
00028 #if WINDOWS_SOCKETS
00029 
00030 
00031 /* An element of the list of close hooks.
00032    The fields of this structure are considered private.  */
00033 struct close_hook
00034 {
00035   /* Doubly linked list.  */
00036   struct close_hook *private_next;
00037   struct close_hook *private_prev;
00038   /* Function that treats the types of FD that it knows about and calls
00039      execute_close_hooks (FD, REMAINING_LIST) as a fallback.  */
00040   int (*private_fn) (int fd, const struct close_hook *remaining_list);
00041 };
00042 
00043 /* This type of function closes FD, applying special knowledge for the FD
00044    types it knows about, and calls execute_close_hooks (FD, REMAINING_LIST)
00045    for the other FD types.  */
00046 typedef int (*close_hook_fn) (int fd, const struct close_hook *remaining_list);
00047 
00048 /* Execute the close hooks in REMAINING_LIST.
00049    Return 0 or -1, like close() would do.  */
00050 extern int execute_close_hooks (int fd, const struct close_hook *remaining_list);
00051 
00052 /* Execute all close hooks.
00053    Return 0 or -1, like close() would do.  */
00054 extern int execute_all_close_hooks (int fd);
00055 
00056 /* Add a function to the list of close hooks.
00057    The LINK variable points to a piece of memory which is guaranteed to be
00058    accessible until the corresponding call to unregister_close_hook.  */
00059 extern void register_close_hook (close_hook_fn hook, struct close_hook *link);
00060 
00061 /* Removes a function from the list of close hooks.  */
00062 extern void unregister_close_hook (struct close_hook *link);
00063 
00064 
00065 #endif
00066 
00067 
00068 #ifdef __cplusplus
00069 }
00070 #endif
00071 
00072 #endif /* CLOSE_HOOK_H */