summaryrefslogtreecommitdiff
path: root/libguile/hooks.c
diff options
context:
space:
mode:
Diffstat (limited to 'libguile/hooks.c')
-rw-r--r--libguile/hooks.c141
1 files changed, 30 insertions, 111 deletions
diff --git a/libguile/hooks.c b/libguile/hooks.c
index 2a953a9b7..bc1bf93e4 100644
--- a/libguile/hooks.c
+++ b/libguile/hooks.c
@@ -1,119 +1,44 @@
-/* Copyright (C) 1995,1996,1998,1999,2000,2001, 2003, 2006, 2008, 2009, 2011 Free Software Foundation, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of
- * the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA
- */
+/* Copyright 1995-1996,1998-2001,2003,2006,2008-2009,2011,2018
+ Free Software Foundation, Inc.
+ This file is part of Guile.
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
+ Guile is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
-#include <stdio.h>
-#include "libguile/_scm.h"
+ Guile is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
-#include "libguile/eval.h"
-#include "libguile/ports.h"
-#include "libguile/procprop.h"
-#include "libguile/smob.h"
-#include "libguile/strings.h"
+ You should have received a copy of the GNU Lesser General Public
+ License along with Guile. If not, see
+ <https://www.gnu.org/licenses/>. */
-#include "libguile/validate.h"
-#include "libguile/hooks.h"
-/* C level hooks
- *
- * Currently, this implementation is separate from the Scheme level
- * hooks. The possibility exists to implement the Scheme level hooks
- * using C level hooks.
- */
-/* Hint for `scm_gc_malloc ()' and friends. */
-static const char hook_entry_gc_hint[] = "hook entry";
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
-void
-scm_c_hook_init (scm_t_c_hook *hook, void *hook_data, scm_t_c_hook_type type)
-{
- hook->first = 0;
- hook->type = type;
- hook->data = hook_data;
-}
+#include <stdio.h>
-void
-scm_c_hook_add (scm_t_c_hook *hook,
- scm_t_c_hook_function func,
- void *fn_data,
- int appendp)
-{
- scm_t_c_hook_entry *entry;
- scm_t_c_hook_entry **loc = &hook->first;
-
- entry = scm_gc_malloc (sizeof (scm_t_c_hook_entry), hook_entry_gc_hint);
- if (appendp)
- while (*loc)
- loc = &(*loc)->next;
- entry->next = *loc;
- entry->func = func;
- entry->data = fn_data;
- *loc = entry;
-}
+#include "boolean.h"
+#include "eval.h"
+#include "gsubr.h"
+#include "list.h"
+#include "numbers.h"
+#include "pairs.h"
+#include "ports.h"
+#include "procprop.h"
+#include "smob.h"
+#include "strings.h"
-void
-scm_c_hook_remove (scm_t_c_hook *hook,
- scm_t_c_hook_function func,
- void *fn_data)
-{
- scm_t_c_hook_entry **loc = &hook->first;
- while (*loc)
- {
- if ((*loc)->func == func && (*loc)->data == fn_data)
- {
- *loc = (*loc)->next;
- return;
- }
- loc = &(*loc)->next;
- }
- fprintf (stderr, "Attempt to remove non-existent hook function\n");
- abort ();
-}
+#include "hooks.h"
-void *
-scm_c_hook_run (scm_t_c_hook *hook, void *data)
-{
- scm_t_c_hook_entry *entry = hook->first;
- scm_t_c_hook_type type = hook->type;
- void *res = 0;
- while (entry)
- {
- res = (entry->func) (hook->data, entry->data, data);
- if (res)
- {
- if (type == SCM_C_HOOK_OR)
- break;
- }
- else
- {
- if (type == SCM_C_HOOK_AND)
- break;
- }
- entry = entry->next;
- }
- return res;
-}
/* Scheme level hooks
@@ -305,11 +230,5 @@ scm_init_hooks ()
{
scm_tc16_hook = scm_make_smob_type ("hook", 0);
scm_set_smob_print (scm_tc16_hook, hook_print);
-#include "libguile/hooks.x"
+#include "hooks.x"
}
-
-/*
- Local Variables:
- c-file-style: "gnu"
- End:
-*/