From 568cf3bfa8019da5f81453debbadab46d1cd8908 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Thu, 22 Feb 2024 17:58:39 +0100 Subject: [PATCH] use db23 from cgilite --- db23.sh | 111 ------------------------------------------ handlers/40_search.sh | 2 +- macros/pagelist | 2 +- 3 files changed, 2 insertions(+), 113 deletions(-) delete mode 100755 db23.sh diff --git a/db23.sh b/db23.sh deleted file mode 100755 index ea64483..0000000 --- a/db23.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/sh - -# Copyright 2023, 2024 Paul Hänsch -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -# IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -. "$_EXEC/cgilite/storage.sh" - -DB2() { - local call data file key val seq - data="${BR}${1}${BR}" call="$2" - shift 2 - - case $call in - new|discard) - printf '' - ;; - open|load) file="$1" - cat "$file" || return 1 - ;; - check|contains) key="$(STRING "$1")" val='' - val="${data##*"${BR}${key}" }" val="${val%%"${BR}"*}" - [ "$val" = '' ] && return 1 - ;; - count) key="$(STRING "$1")" val='' seq=0 - val="${data##*"${BR}${key}" }" val="${val%%"${BR}"*}" - [ "$val" = '' ] || val="${val} " - while [ "$val" != '' ]; do - seq=$((seq + 1)) val="${val#* }" - done - printf "%i\n" "$seq" - [ $seq = 0 ] && return 1 - ;; - get) key="$(STRING "$1")" seq="${2:-1}" - val="${data##*"${BR}${key}" }" val="${val%%"${BR}"*}" - [ "$val" = '' ] && return 1 || val="${val} " - while [ $seq -gt 1 ]; do - seq=$((seq - 1)) val="${val#* }" - done - [ "$val" = '' ] && return 1 - UNSTRING "${val%% *}" - ;; - iterate|raw) key="$(STRING "$1")" - val="${data##*"${BR}${key}" }" val="${val%%"${BR}"*}" - [ "$val" = '' ] && return 1 - printf '%s\n' $val - ;; - delete|remove) key="$(STRING "$1")" - val="${data#*"${BR}${key}" *"${BR}"}" - key="${data%"${BR}${key}" *"${BR}"*}" - [ "${key}${BR}${val}" = "${data}" ] && return 1 - printf '%s' "${key#"${BR}"}${BR}${val%"${BR}"}" - ;; - set|store) key="$(STRING "$1")" val="" - shift 1 - val="$(for v in "$@"; do STRING "$v"; printf \\t; done)" - if [ "${data#*"${BR}${key}" *}" != "$data" ]; then - data="${data%"${BR}${key}" *"${BR}"*}${BR}${key} ${val% }${BR}${data#*"${BR}${key}" *"${BR}"}" - data="${data#"${BR}"}" data="${data%"${BR}"}" - else - data="${data#"${BR}"}${key} ${val% }${BR}" - data="${data#"${BR}"}" - fi - printf %s\\n "${data}" - ;; - append) key="$(STRING "$1")" val="" - val="${data##*"${BR}${key}" }" val="${val%%"${BR}"*}" - if [ "$val" = '' ]; then - printf %s\\n "${data}" - return 1 - else - shift 1 - val="${val}$(for v in "$@"; do printf \\t; STRING "$v"; done)" - data="${data%"${BR}${key}" *"${BR}"*}${BR}${key} ${val% }${BR}${data#*"${BR}${key}" *"${BR}"}" - data="${data#"${BR}"}" data="${data%"${BR}"}" - printf %s\\n "${data}" - fi - ;; - flush|save|write) file="$1" - data="${data#"${BR}"}" data="${data%"${BR}"}" - printf '%s\n' "$data" >"$file" || return 1 - ;; - esac - return 0 -} - -DB3() { - # wrapper function that allows easyer use of DB2 - # by always keeping file data in $db3_data - - case "$1" in - new|discard|open|load|delete|remove|set|store|append) - db3_data="$(DB2 "$db3_data" "$@")" - return "$?" - ;; - get|count|check|contains|iterate|raw|flush|save|write) - DB2 "$db3_data" "$@" - return "$?" - ;; - esac -} diff --git a/handlers/40_search.sh b/handlers/40_search.sh index 5b14843..1e33019 100644 --- a/handlers/40_search.sh +++ b/handlers/40_search.sh @@ -18,7 +18,7 @@ [ "${PATH_INFO%\[search\]}" = "$PATH_INFO" ] && return 1 . "$_EXEC/cgilite/storage.sh" -. "$_EXEC/db23.sh" +. "$_EXEC/cgilite/db23.sh" I="$_DATA/index" words="$( GET q | awk ' diff --git a/macros/pagelist b/macros/pagelist index 178a9a0..35263fe 100755 --- a/macros/pagelist +++ b/macros/pagelist @@ -17,7 +17,7 @@ . "$_EXEC/cgilite/cgilite.sh" . "$_EXEC/acl.sh" . "$_EXEC/tools.sh" -. "$_EXEC/db23.sh" +. "$_EXEC/cgilite/db23.sh" tags='' ntags='' dir='' depth='' glob_system_pages=false label='' labeltype='' altlabel='' titles='' db3_data='' -- 2.39.2