summaryrefslogtreecommitdiff
path: root/support/dktools/dk3srch.c
diff options
context:
space:
mode:
Diffstat (limited to 'support/dktools/dk3srch.c')
-rw-r--r--support/dktools/dk3srch.c215
1 files changed, 0 insertions, 215 deletions
diff --git a/support/dktools/dk3srch.c b/support/dktools/dk3srch.c
deleted file mode 100644
index 71d2514669..0000000000
--- a/support/dktools/dk3srch.c
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
-Copyright (C) 2011-2020, Dirk Krause
-SPDX-License-Identifier: BSD-3-Clause
-*/
-
-/*
- WARNING: This file was generated by the dkct program (see
- http://dktools.sourceforge.net/ for details).
- Changes you make here will be lost if dkct is run again!
- You should modify the original source and run dkct on it.
- Original source: dk3srch.ctr
-*/
-
-/** @file dk3srch.c The dk3srch module.
-*/
-
-
-#line 61 "dk3srch.ctr"
-
-#include "dk3all.h"
-
-
-
-
-
-
-#line 67 "dk3srch.ctr"
-
-
-
-/** One result node.
-*/
-typedef struct _dk3_search_node_t_ {
- unsigned long n; /**< Node number. */
- dkChar const *fn; /**< File name. */
-} dk3_search_node_t;
-
-
-
-/** Compare two line nodes.
- @param l Left node.
- @param r Right node.
- @param cr Comparison criteria.
- @return Comparison result.
-*/
-static
-int
-node_compare(void const *l, void const *r, int cr)
-{
- int back = 0;
- dk3_search_node_t const *pl; /* Left node. */
- dk3_search_node_t const *pr; /* Right node. */
- if(l) {
- if(r) {
- pl = (dk3_search_node_t const *)l;
- pr = (dk3_search_node_t const *)r;
- if(pl->n > pr->n) { back = 1; }
- else { if(pl->n < pr->n) { back = -1; } }
- } else { back = 1; }
- } else {
- if(r) { back = -1; }
- }
- if(cr) { back = 0 - back; }
- return back;
-}
-
-
-
-/** Delete one node, release memory.
- @param n Node to delete.
-*/
-static
-void
-dk3search_node_delete(dk3_search_node_t *n)
-{
- if(n) {
- dk3_release(n->fn);
- n->n = 0UL;
- dk3_delete(n);
- }
-}
-
-
-
-/** Create new node, allocate memory.
- @param n Node number.
- @param fn File name.
- @param app Application structure for diagnostics, may be NULL.
- @return Pointer to new node on success, NULL on error.
-*/
-static
-dk3_search_node_t *
-dk3search_node_new_app(unsigned long n, dkChar const *fn, dk3_app_t *app)
-{
- dk3_search_node_t *back = NULL;
-
-
-#line 136 "dk3srch.ctr"
- back = dk3_new_app(dk3_search_node_t,1,app);
- if(back) {
- back->n = n;
- back->fn = dk3str_dup_app(fn, app);
- if(!(back->fn)) {
-
-#line 141 "dk3srch.ctr"
- dk3search_node_delete(back); back = NULL;
- }
- }
-
-#line 144 "dk3srch.ctr"
- return back;
-}
-
-
-
-void
-dk3search_close(dk3_search_t *sp)
-{
- dk3_search_node_t *n = NULL;
- if(sp) {
- if(sp->s_fn) {
- if(sp->i_fn) {
- dk3sto_it_reset(sp->i_fn);
- while((n = (dk3_search_node_t *)dk3sto_it_next(sp->i_fn)) != NULL) {
- dk3search_node_delete(n);
- }
- dk3sto_it_close(sp->i_fn);
- }
- dk3sto_close(sp->s_fn);
- } sp->s_fn = NULL; sp->i_fn = NULL;
- sp->app = NULL;
- dk3_delete(sp);
- }
-}
-
-
-
-dk3_search_t *
-dk3search_open_app(int i, dk3_app_t *app)
-{
- dk3_search_t *back = NULL;
- back = dk3_new_app(dk3_search_t,1,app);
- if(back) {
- back->s_fn = NULL; back->i_fn = NULL; back->inverted = (i ? 1 : 0);
- back->nf = 0UL; back->app = app;
- back->s_fn = dk3sto_open_app(app);
- if(back->s_fn) {
- back->i_fn = dk3sto_it_open(back->s_fn);
- dk3sto_set_comp(back->s_fn, node_compare, 0);
- }
- if(!((back->s_fn) && (back->i_fn))) {
- dk3search_close(back); back = NULL;
- }
- }
- return back;
-}
-
-
-
-int
-dk3search_add(dk3_search_t *sp, dkChar const *fn)
-{
- int back = 0;
- dk3_search_node_t *n = NULL; /* New node. */
-
-
-#line 199 "dk3srch.ctr"
- if((sp) && (fn)) {
- n = dk3search_node_new_app(sp->nf, fn, sp->app);
- if(n) {
- if(dk3sto_add(sp->s_fn, n)) {
- back = 1;
- sp->nf += 1UL;
- } else {
- dk3search_node_delete(n);
- }
- }
- }
-
-#line 210 "dk3srch.ctr"
- return back;
-}
-
-
-
-void
-dk3search_reset(dk3_search_t *sp)
-{
- if(sp) {
- dk3sto_it_reset(sp->i_fn);
- }
-}
-
-
-
-dkChar const *
-dk3search_next(dk3_search_t *sp)
-{
- dkChar const *back = NULL;
- dk3_search_node_t *node = NULL; /* Next node. */
- if(sp) {
- node = (dk3_search_node_t *)dk3sto_it_next(sp->i_fn);
- if(node) {
- back = node->fn;
- }
- }
-
-#line 236 "dk3srch.ctr"
- return back;
-}
-
-
-
-/* vim: set ai sw=2 : */
-