summaryrefslogtreecommitdiffabout
path: root/src/debug.c
Side-by-side diff
Diffstat (limited to 'src/debug.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/debug.c137
1 files changed, 0 insertions, 137 deletions
diff --git a/src/debug.c b/src/debug.c
index 00f568c..08957ed 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -136,140 +136,3 @@ gdbm_debug_datum (datum dat, char const *pfx)
}
}
-
-struct hook_list
-{
- struct hook_list *next;
- struct hook_list *prev;
- char *id;
- gdbm_debug_hook hook;
- void *data;
- int retval;
-};
-
-static struct hook_list *hook_head, *hook_tail;
-static struct hook_list *hook_recent;
-
-static struct hook_list *
-hook_lookup_or_install (char const *id, int install)
-{
- struct hook_list *p;
-
- for (p = hook_head; p; p = p->next)
- {
- int res = strcmp (p->id, id);
- if (res == 0)
- return p;
- if (res > 0)
- break;
- }
-
- if (install)
- {
- struct hook_list *elt = malloc (sizeof *elt);
- if (!elt)
- return NULL;
- elt->id = strdup (id);
- if (!elt->id)
- {
- SAVE_ERRNO (free (elt));
- return NULL;
- }
- elt->hook = NULL;
- elt->next = p;
- if (p)
- {
- if (p->prev)
- p->prev->next = elt;
- else
- hook_head = elt;
- elt->prev = p->prev;
- }
- else
- {
- elt->prev = hook_tail;
- if (hook_tail)
- hook_tail->next = elt;
- else
- hook_head = elt;
- hook_tail = elt;
- }
- return elt;
- }
-
- return NULL;
-}
-
-static struct hook_list *
-hook_lookup (char const *id)
-{
- if (!(hook_recent && strcmp (hook_recent->id, id) == 0))
- hook_recent = hook_lookup_or_install (id, FALSE);
- return hook_recent;
-}
-
-static void
-hook_remove (char const *id)
-{
- struct hook_list *p;
-
- p = hook_lookup (id);
- if (!p)
- return;
-
- hook_recent = NULL;
-
- if (p->prev)
- p->prev->next = p->next;
- else
- hook_head = p->next;
-
- if (p->next)
- p->next->prev = p->prev;
- else
- hook_tail = p->prev;
-
- free (p->id);
- free (p);
-}
-
-static int
-default_hook (char const *file, int line, char const *id, void *data)
-{
- fprintf (stderr, "%s:%d: hit debug hook %s\n", file, line, id);
- return 1;
-}
-
-void
-_gdbm_debug_hook_install (char const *id, gdbm_debug_hook hook, void *data)
-{
- struct hook_list *p;
-
- p = hook_lookup_or_install (id, TRUE);
- p->hook = hook ? hook : default_hook;
- p->data = data;
-}
-
-void
-_gdbm_debug_hook_remove (char const *id)
-{
- hook_remove (id);
-}
-
-int
-_gdbm_debug_hook_check (char const *file, int line, char const *id)
-{
- struct hook_list *p = hook_lookup (id);
- if (p)
- return p->retval = p->hook (file, line, id, p->data);
- return 0;
-}
-
-int
-_gdbm_debug_hook_val (char const *id)
-{
- struct hook_list *p = hook_lookup (id);
- if (p)
- return p->retval;
- return 0;
-}

Return to:

Send suggestions and report system problems to the System administrator.