1 #ifndef SCM_CHOOKS_H
2 #define SCM_CHOOKS_H
3 
4 /* Copyright 1995-1996,1999,2000-2001,2006,2008-2009,2018
5      Free Software Foundation, Inc.
6 
7    This file is part of Guile.
8 
9    Guile is free software: you can redistribute it and/or modify it
10    under the terms of the GNU Lesser General Public License as published
11    by the Free Software Foundation, either version 3 of the License, or
12    (at your option) any later version.
13 
14    Guile is distributed in the hope that it will be useful, but WITHOUT
15    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
17    License for more details.
18 
19    You should have received a copy of the GNU Lesser General Public
20    License along with Guile.  If not, see
21    <https://www.gnu.org/licenses/>.  */
22 
23 
24 
25 #include "libguile/scm.h"
26 
27 /*
28  * C level hooks
29  */
30 
31 /*
32  * The interface is designed for and- and or-type hooks which
33  * both may want to indicate success/failure and return a result.
34  */
35 
36 typedef enum scm_t_c_hook_type {
37   SCM_C_HOOK_NORMAL,
38   SCM_C_HOOK_OR,
39   SCM_C_HOOK_AND
40 } scm_t_c_hook_type;
41 
42 typedef void  *(*scm_t_c_hook_function) (void *hook_data,
43 					 void *fn_data,
44 					 void *data);
45 
46 typedef struct scm_t_c_hook_entry {
47   struct scm_t_c_hook_entry *next;
48   scm_t_c_hook_function func;
49   void *data;
50 } scm_t_c_hook_entry;
51 
52 typedef struct scm_t_c_hook {
53   scm_t_c_hook_entry *first;
54   scm_t_c_hook_type type;
55   void *data;
56 } scm_t_c_hook;
57 
58 SCM_API void scm_c_hook_init (scm_t_c_hook *hook,
59 			      void *hook_data,
60 			      scm_t_c_hook_type type);
61 SCM_API void scm_c_hook_add (scm_t_c_hook *hook,
62 			     scm_t_c_hook_function func,
63 			     void *fn_data,
64 			     int appendp);
65 SCM_API void scm_c_hook_remove (scm_t_c_hook *hook,
66 				scm_t_c_hook_function func,
67 				void *fn_data);
68 SCM_API void *scm_c_hook_run (scm_t_c_hook *hook, void *data);
69 
70 
71 #endif  /* SCM_CHOOKS_H */
72