[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 101/335: script updates
From: |
gnunet |
Subject: |
[libmicrohttpd] 101/335: script updates |
Date: |
Sat, 27 Jul 2024 21:59:57 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to tag stf-m2
in repository libmicrohttpd.
commit 153ddd5b018ece0bc9d6d38677e5c8e7f838cc78
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Tue Apr 2 16:57:58 2024 +0200
script updates
---
scripts/.gitignore | 2 +
scripts/d_options.rec | 49 ++++--
scripts/d_options.sh | 183 ++++++++++++++++++---
scripts/d_options1.template | 5 -
scripts/d_options2.template | 11 --
...d_options0.template => d_options_enum.template} | 3 +-
scripts/d_options_func.template | 14 ++
scripts/d_options_macro.template | 13 ++
scripts/d_options_union.template | 6 +
9 files changed, 226 insertions(+), 60 deletions(-)
diff --git a/scripts/.gitignore b/scripts/.gitignore
new file mode 100644
index 00000000..c6030aa3
--- /dev/null
+++ b/scripts/.gitignore
@@ -0,0 +1,2 @@
+d_options_preproc.rec
+*_insert.h
diff --git a/scripts/d_options.rec b/scripts/d_options.rec
index a4be47c6..a2cc1961 100644
--- a/scripts/d_options.rec
+++ b/scripts/d_options.rec
@@ -11,25 +11,42 @@
%mandatory: Description1
%constraint: ( Value > 0 )
-Name: suppress_date
+Name: SUPPRESS_DATE_HEADER
Value: 1
-Argument1: bool suppressed
-Description1: some short description
-Comment: Suppresses the date header.
+Argument1: enum MHD_Bool bool_val
+Description1: the value of the parameter
+Comment: Suppresses use of "Date:" header.
++ According to RFC should be used only if the system has no RTC.
-Name: cert_callback
+Name: DISALLOW_SUSPEND_resume
Value: 2
-Comment: Set TLS callback
-Argument1: Callback cb
-Description1: callback
-Member1: opt.cb
-Argument2: void* cls
-Description2: closure
-Member2: opt.cls
+Type: enum MHD_Bool
+Argument1: enum MHD_Bool bool_val
+Description1: the value of the parameter
+Comment: Disable #MHD_action_suspend() functionality.
++
++ You should only use this function if you are sure you do
++ satisfy all of its requirements and need a generally minor
++ boost in performance.
-Name: bind_address
+Name: TURBO
Value: 3
-Comment: Set IPv4 address to bind to
-Argument1: const struct sockaddr *in
-Description1: the address
+Type: enum MHD_Bool
+Argument1: bool_val
+Description1: the value of the parameter
+Comment: Enable `turbo`. Disables certain calls to `shutdown()`,
++ enables aggressive non-blocking optimistic reads and
++ other potentially unsafe optimisations.
++ Most effects only happen with internal threads with epoll.
++ The 'turbo' mode is not enabled (mode is disabled) by default.
+Name: sock addr
+Value: 4
+Comment: Bind to the given socket address.
++ Ineffective in conjunction with #MHD_daemon_listen_socket().
+Argument1: size_t sa_len_val
+Description1: the number of bytes in @a sa
+Member1: sa_len
+Argument2: const struct sockaddr *sa_val
+Description2: the address to bind to; can be IPv4 (AF_INET), IPv6 (AF_INET6)
or even a UNIX domain socket (AF_UNIX)
+Member2: sa
diff --git a/scripts/d_options.sh b/scripts/d_options.sh
index 259754b5..0e4d3eaa 100644
--- a/scripts/d_options.sh
+++ b/scripts/d_options.sh
@@ -1,5 +1,27 @@
#!/bin/bash
+# This file is part of GNU libmicrohttpd
+# Copyright (C) 2024 Karlson2k (Evgeny Grin), Christian Grothoff
+
+# 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 2.1 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
+
+
+export LC_ALL=C
+export LANG=C
+
if command -v recsel >/dev/null 2>&1 ; then : ; else
echo "Error: The command 'recsel' is missing. Please install recutils." >&2
exit 1
@@ -25,10 +47,38 @@ if declare -a ARGS 2>/dev/null ; then : ; else
exit 1
fi
+if [[ "false" ]] ; then : ; else
+ echo "Error: Compound command support is required" >&2
+ exit 1
+fi
+
+test_var="abc ABC Abc"
+if test "${test_var^}" = "Abc ABC Abc" && test "${test_var^^}" = "ABC ABC ABC"
&& test "${test_var,,}" = "abc abc abc"; then : ; else
+ echo "Error: Shell upper- and lowercase variable conversion support
required" >&2
+ exit 1
+fi
+
+if test "${test_var// /_}" = "abc_ABC_Abc" ; then : ; else
+ echo "Error: Shell variable replacement conversion support required" >&2
+ exit 1
+fi
+
+unset test_var
+
# parameters
max_width=79
input_rec="d_options.rec"
tmp_rec="d_options_preproc.rec"
+
+err_exit() {
+ local msg="$1"
+ local err=$2
+
+ [[ -z $msg ]] && msg="Error!"
+ ( [[ -z $err ]] || (( err < 1 )) ) && err=2
+ echo "$msg" >&1
+ exit $err
+}
# cut string to given length at word boundary if possible
cut_str_word () {
@@ -57,18 +107,18 @@ format_param_descr() {
local tmp_str
declare -g format_param_descr_res=''
[[ -z $width ]] && width=$max_width
- prefix1="${prefix1%${prefix1##*[! ]}} " # force single trailing space
+ prefix1="${prefix1%"${prefix1##*[! ]}"} " # force single trailing space
[[ -z $prefix2 ]] && prefix2="$prefix1"
- desc="${desc#${desc%%[! ]*}}"
- desc="${desc%${desc##*[! ]}}" # trim desc
+ desc="${desc#"${desc%%[! ]*}"}"
+ desc="${desc%"${desc##*[! ]}"}" # trim desc
local width_r=$(( width - ${#prefix1} ))
- local tmp_str="${prefix1//?/ }"
+ local tmp_str="${prefix1//?/ }" # Space-only string with the same length
prefix2="
${prefix2}${tmp_str:${#prefix2}}"
cut_str_word "$desc" $width_r || return 1
format_param_descr_res="${prefix1}${cut_str_word_res}"
desc="${desc:${#cut_str_word_res}}"
- desc="${desc#${desc%%[! ]*}}" # trim leading spaces
+ desc="${desc#"${desc%%[! ]*}"}" # trim leading spaces
while [[ -n "$desc" ]]; do
cut_str_word "$desc" $width_r || return 1
format_param_descr_res+="${prefix2}${cut_str_word_res}"
@@ -89,48 +139,126 @@ echo "Processing input file..."
for N in $(recsel -t MHD_Option -R Value "$input_rec")
do
NAME=$(recsel -t MHD_Option -P Name -e "Value=$N" "$input_rec")
- COMMENT=$(recsel -t MHD_Option -P Comment -e "Value=$N" "$input_rec")
- ARGS=( )
- DESCRS=( )
- MEMBRS=( )
if [[ -z $NAME ]]; then
- echo "The name field is empty for 'Value=$N'" >&2
+ echo "The 'Name' field is empty for 'Value=$N'" >&2
exit 2
fi
- EComment=""
- EName=""
- FComment=""
- MArguments=""
- CLBody=""
- SFArguments=""
- SFBody=""
+ echo $N: $NAME
+ COMMENT=$(recsel -t MHD_Option -P Comment -e "Value=$N" "$input_rec")
+ if [[ -z $COMMENT ]]; then
+ echo "The 'Comment' field is empty for '$NAME' ('Value=$N')" >&2
+ exit 2
+ fi
+ TYPE=$(recsel -t MHD_Option -P Type -e "Value=$N" "$input_rec")
+ EComment="" # The doxy comment for enum value
+ EName="" # The final part of the name of the enum value
+ UComment="" # The doxy comment for the union member
+ UName="" # The final part of the name of the union member
+ UType="" # The type of the union member
+ SComment="" # The doxy comment for the value set macro and set function
+ SName="" # The final part of the name of the set macro/function
+ MArguments="" # The arguments for the macro
+ CLBody="" # The Compound Literal body (for the set macro)
+ SFArguments="" # The arguments for the static function
+ SFBody="" # The static function body
+
+ nested='maybe' # The option has nested struct parameters
('yes'/'no'/'maybe')
+
+ clean_name="${NAME//_/ }"
+ clean_name="${clean_name,,}" # Lowercase space-delimited
+
+ EName="${clean_name^^}"
+ EName="${EName// /_}" # Uppercase '_'-joined
+
+ UName="${clean_name// /_}" # lowercase '_'-joined
+
+ SName="${EName}" # Uppercase '_'-joined
+
+ [[ -z $TYPE ]] && nested='no'
+
+ arg_names=( )
+ arg_types=( )
+ arg_descr=( )
+ nest_membr=( )
M=1
while
ARGM=$(recsel -t MHD_Option -P Argument${M} -e "Value=$N" "$input_rec")
[[ -n $ARGM ]]
do
- ARGS+=( "$ARGM" )
DESCRM=$(recsel -t MHD_Option -P Description${M} -e "Value=$N"
"$input_rec")
if [[ -z $DESCRM ]]; then
- echo "Empty Description${M} for argument \"$ARGM\" for $NAME" >&2
+ echo "Empty Description${M} for argument \"$ARGM\" for '$NAME'
('Value=$N')" >&2
exit 2
fi
- DESCRS+=( "$DESCRM" )
MEMBRM=$(recsel -t MHD_Option -P Member${M} -e "Value=$N" "$input_rec")
- [[ -z $MEMBRM ]] && MEMBRM="$ARGM"
- MEMBRS+=( "$MEMBRM" )
+
arg_name="${ARGM##* }"
arg_name="${arg_name#\*}"
arg_type="${ARGM%${arg_name}}"
arg_type="${arg_type% }"
+
+ if [[ -z $arg_type ]]; then
+ if [[ $M -eq 1 ]]; then
+ if [[ -z $TYPE ]]; then
+ echo "No argument type for $NAME ('Value=$N')" >&2
+ exit 2
+ else
+ arg_type="$TYPE"
+ nested='no'
+ fi
+ else
+ echo "No argument type found in 'Argument${M}' (\"$ARGM\") for
'$NAME' ('Value=$N')" >&2
+ exit 2
+ fi
+ else
+ if [[ -z $TYPE ]]; then
+ if [[ $M -eq 1 ]]; then
+ TYPE="$arg_type"
+ nested='no'
+ else
+ echo "Empty 'Type' for '$NAME' ('Value=$N') with multiple
parameters" >&2
+ exit 2
+ fi
+ else
+ if [[ $TYPE = $arg_type ]]; then
+ if [[ $M -eq 1 ]]; then
+ nested='no'
+ else
+ echo "The same 'Type' and type for in 'Argument${M}'
(\"$ARGM\") used for '$NAME' ('Value=$N')" >&2
+ exit 2
+ fi
+ else
+ nested='yes'
+ fi
+ fi
+ fi
+ [[ $nested = 'maybe' ]] && err_exit "Internal error"
+ if [[ $M -gt 1 ]]; then
+ if [[ $nested = 'no' ]]; then
+ echo "The 'Argument${M}' (\"$ARGM\") is specified for flat
(non-nested) '$NAME' ('Value=$N')" >&2
+ exit 2
+ elif [[ $nested = 'maybe' ]]; then
+ nested='yes'
+ fi
+ fi
(( M++ ))
done
- echo $N - $NAME
+ if (( M < 2 )); then
+ [[ -z $TYPE ]] && err_exit "No 'Argument1' is specified for '$NAME'
('Value=$N') without 'Type'" >&2
+ [[ $nested = 'yes' ]] && err_exit "No 'Argument1' is specified for
non-flat (nested) '$NAME' ('Value=$N')" >&2
+ fi
+ UType="$TYPE"
+
recins -t MHD_Option_preproc \
- -f Value -v "$N" \
-f Name -v "$NAME" \
+ -f Value -v "$N" \
-f EComment -v "$EComment" \
-f EName -v "$EName" \
+ -f UComment -v "$UComment" \
+ -f UName -v "$UName" \
+ -f UType -v "$UType" \
+ -f SComment -v "$SComment" \
+ -f SName -v "$SName" \
-f MArguments -v "$MArguments" \
-f CLBody -v "$CLBody" \
-f SFArguments -v "$SFArguments" \
@@ -140,8 +268,9 @@ done
echo "finished."
echo "Generating output files..."
-# recfmt -f d_option0.template "$tmp_rec"
-# recfmt -f d_option1.template "$tmp_rec"
-# recfmt -f d_option2.template "$tmp_rec"
+recfmt -f d_options_enum.template <"$tmp_rec" > enum_insert.h
+recfmt -f d_options_union.template <"$tmp_rec" > union_insert.h
+recfmt -f d_options_macro.template <"$tmp_rec" > macro_insert.h
+recfmt -f d_options_func.template <"$tmp_rec" > func_insert.h
# rm "$tmp_rec"
echo "finished."
diff --git a/scripts/d_options1.template b/scripts/d_options1.template
deleted file mode 100644
index 95d5a5a6..00000000
--- a/scripts/d_options1.template
+++ /dev/null
@@ -1,5 +0,0 @@
-/**
-{{Comment}}
- */
-#define MHD_daemon_set_{{Name}}({{MArguments}}) \
- (struct MHD_Option){ {{CLBody}} }
diff --git a/scripts/d_options2.template b/scripts/d_options2.template
deleted file mode 100644
index ebe491a5..00000000
--- a/scripts/d_options2.template
+++ /dev/null
@@ -1,11 +0,0 @@
-/**
-{{Comment}}
- */
-inline static enum MHD_Option
-MHD_daemon_set_{{Name}} ({{SFArguments}}) {
- struct MHD_Option opt;
-
- {{SFBody}}
- return opt;
-}
-
diff --git a/scripts/d_options0.template b/scripts/d_options_enum.template
similarity index 85%
rename from scripts/d_options0.template
rename to scripts/d_options_enum.template
index ff955bc2..3ff5be28 100644
--- a/scripts/d_options0.template
+++ b/scripts/d_options_enum.template
@@ -2,4 +2,5 @@
{{EComment}}
*/
MHD_D_O_{{EName}} = {{Value}}
-{{EComma}}
\ No newline at end of file
+ ,
+
diff --git a/scripts/d_options_func.template b/scripts/d_options_func.template
new file mode 100644
index 00000000..3b4308fb
--- /dev/null
+++ b/scripts/d_options_func.template
@@ -0,0 +1,14 @@
+/**
+{{SComment}}
+ * @return the object of struct MHD_DaemonOptionAndValue with requested values
+ */
+static MHD_INLINE struct MHD_DaemonOptionAndValue
+MHD_DAEMON_OPTION_{{SName}} ({{SFArguments}})
+{
+ struct MHD_DaemonOptionAndValue opt_val;
+
+ opt_val.opt = MHD_D_O_{{EName}};
+ {{SFBody}}
+ return opt_val;
+}
+
diff --git a/scripts/d_options_macro.template b/scripts/d_options_macro.template
new file mode 100644
index 00000000..247a9129
--- /dev/null
+++ b/scripts/d_options_macro.template
@@ -0,0 +1,13 @@
+/**
+{{SComment}}
+ * @return the object of struct MHD_DaemonOptionAndValue with requested values
+ */
+#define MHD_DAEMON_OPTION_{{SName}}({{MArguments}}) \
+ MHD_NOWARN_COMPOUND_LITERALS_ \
+ (const struct MHD_DaemonOptionAndValue) \
+ { \
+ .opt = (MHD_D_O_{{EName}}), \
+ {{CLBody}} \
+ } \
+ MHD_RESTORE_WARN_COMPOUND_LITERALS_
+
diff --git a/scripts/d_options_union.template b/scripts/d_options_union.template
new file mode 100644
index 00000000..79bfb4c2
--- /dev/null
+++ b/scripts/d_options_union.template
@@ -0,0 +1,6 @@
+ /**
+{{UComment}}
+ */
+ {{UType}} v_{{UName}};
+
+
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] 107/335: script and Daemon Options updates, (continued)
- [libmicrohttpd] 107/335: script and Daemon Options updates, gnunet, 2024/07/27
- [libmicrohttpd] 100/335: script updates, gnunet, 2024/07/27
- [libmicrohttpd] 89/335: edits, gnunet, 2024/07/27
- [libmicrohttpd] 94/335: microhttpd2.h: edits, gnunet, 2024/07/27
- [libmicrohttpd] 109/335: script and daemon options DB update, gnunet, 2024/07/27
- [libmicrohttpd] 87/335: -example, gnunet, 2024/07/27
- [libmicrohttpd] 104/335: mark script executable, gnunet, 2024/07/27
- [libmicrohttpd] 93/335: microhttpd2.h: edits, gnunet, 2024/07/27
- [libmicrohttpd] 91/335: microhttpd2.h: edits, gnunet, 2024/07/27
- [libmicrohttpd] 106/335: Sorted Daemon Option values, added missing values, gnunet, 2024/07/27
- [libmicrohttpd] 101/335: script updates,
gnunet <=
- [libmicrohttpd] 102/335: script updates, gnunet, 2024/07/27
- [libmicrohttpd] 112/335: microhttpd2.h: daemon options cleanup, gnunet, 2024/07/27
- [libmicrohttpd] 120/335: microhttpd2.h: converted connection options, gnunet, 2024/07/27
- [libmicrohttpd] 105/335: script updates, gnunet, 2024/07/27
- [libmicrohttpd] 125/335: microhttpd2.h: added missing setting for large pool, gnunet, 2024/07/27
- [libmicrohttpd] 108/335: microhttpd2.h: preparation, gnunet, 2024/07/27
- [libmicrohttpd] 97/335: microhttpd.h: fixed feature name, gnunet, 2024/07/27
- [libmicrohttpd] 118/335: wip, gnunet, 2024/07/27
- [libmicrohttpd] 114/335: scripts: improved code style, gnunet, 2024/07/27
- [libmicrohttpd] 121/335: script: added response options, gnunet, 2024/07/27