chooks.h 1.9 KB

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