Check-in [89a0098c0d]
Not logged in
Overview
Comment:name verification
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 89a0098c0dd3bce0ae60152029bedfbc016f56ec
User & Date: martin_vahi on 2016-07-16 07:03:04
Other Links: manifest | tags
Context
2016-08-03 04:31
Silktorrent Logo SVG and PNG check-in: 9234f3e5e9 user: martin_vahi tags: trunk
2016-07-16 07:03
name verification check-in: 89a0098c0d user: martin_vahi tags: trunk
2016-06-24 17:29
BSD related bugfix 2 check-in: 8276376b64 user: martin_vahi tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Added milestone_releases/silktorrent_packager_t1_2016_07_16.bash version [6caf32f071].

            1  +#!/usr/bin/env bash
            2  +#==========================================================================
            3  +#
            4  +# Copyright 2016, martin.vahi@softf1.com that has an
            5  +# Estonian personal identification code of 38108050020.
            6  +# All rights reserved.
            7  +#
            8  +# Redistribution and use in source and binary forms, with or
            9  +# without modification, are permitted provided that the following
           10  +# conditions are met:
           11  +#
           12  +# * Redistributions of source code must retain the above copyright
           13  +#   notice, this list of conditions and the following disclaimer.
           14  +# * Redistributions in binary form must reproduce the above copyright
           15  +#   notice, this list of conditions and the following disclaimer
           16  +#   in the documentation and/or other materials provided with the
           17  +#   distribution.
           18  +# * Neither the name of the Martin Vahi nor the names of its
           19  +#   contributors may be used to endorse or promote products derived
           20  +#   from this software without specific prior written permission.
           21  +#
           22  +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
           23  +# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
           24  +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
           25  +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
           26  +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
           27  +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
           28  +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
           29  +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
           30  +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
           31  +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
           32  +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
           33  +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
           34  +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
           35  +#
           36  +#==========================================================================
           37  +S_FP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
           38  +S_FP_ORIG="`pwd`"
           39  +S_TIMESTAMP="`date +%Y`_`date +%m`_`date +%d`_T_`date +%H`h_`date +%M`min_`date +%S`s"
           40  +
           41  +#--------------------------------------------------------------------------
           42  +# Settings:
           43  +S_SCRIPT_VERSION="2016_07_16_a"
           44  +#--------------------------------------------------------------------------
           45  +
           46  +SB_TMP_FOLDER_EXISTS="f" # to omit one useless and slow file system access
           47  +S_FP_TMP_FOLDER=""
           48  +
           49  +
           50  +func_mmmv_silktorrent_packager_t1_exit_without_any_errors() {
           51  +    local S_0=""
           52  +    local S_1=""
           53  +    if [ "$SB_TMP_FOLDER_EXISTS" == "t" ]; then
           54  +       S_0= 
           55  +    fi
           56  +    exit 0 # exit without an error
           57  +} # func_mmmv_silktorrent_packager_t1_exit_without_any_errors
           58  +
           59  +#--------------------------------------------------------------------------
           60  +
           61  +S_FUNC_MMMV_OPERATING_SYSTEM_TYPE_T1_RESULT=""
           62  +func_mmmv_operating_system_type_t1() {
           63  +    if [ "$S_FUNC_MMMV_OPERATING_SYSTEM_TYPE_T1_RESULT" == "" ]; then
           64  +        S_TMP_0="`uname -a | grep -E [Ll]inux`"
           65  +        if [ "$S_TMP_0" != "" ]; then
           66  +            S_FUNC_MMMV_OPERATING_SYSTEM_TYPE_T1_RESULT="Linux"
           67  +        else
           68  +            S_TMP_0="`uname -a | grep BSD `"
           69  +            if [ "$S_TMP_0" != "" ]; then
           70  +                S_FUNC_MMMV_OPERATING_SYSTEM_TYPE_T1_RESULT="BSD"
           71  +            else
           72  +                S_FUNC_MMMV_OPERATING_SYSTEM_TYPE_T1_RESULT="undetermined"
           73  +            fi
           74  +        fi
           75  +    fi
           76  +} # func_mmmv_operating_system_type_t1
           77  +
           78  +#--------------------------------------------------------------------------
           79  +
           80  +func_mmmv_operating_system_type_t1
           81  +if [ "$S_FUNC_MMMV_OPERATING_SYSTEM_TYPE_T1_RESULT" != "Linux" ]; then
           82  +    if [ "$S_FUNC_MMMV_OPERATING_SYSTEM_TYPE_T1_RESULT" != "BSD" ]; then
           83  +        echo ""
           84  +        echo "  The classical command line utilities at "
           85  +        echo "  different operating systems, for example, Linux and BSD,"
           86  +        echo "  differ. This script is designed to run only on "
           87  +        echo "  Linux and some BSD variants."
           88  +        echo "  If You are willing to risk that some of Your data "
           89  +        echo "  is deleted and/or Your operating system instance"
           90  +        echo "  becomes permanently flawed, to the point that "
           91  +        echo "  it will not even boot, then You may edit the Bash script that "
           92  +        echo "  displays this error message by modifying the test that "
           93  +        echo "  checks for the operating system type."
           94  +        echo ""
           95  +        echo "  If You do decide to edit this Bash script, then "
           96  +        echo "  a recommendation is to test Your modifications "
           97  +        echo "  within a virtual machine or, if virtual machines are not"
           98  +        echo "  an option, as some new operating system user that does not have "
           99  +        echo "  any access to the vital data/files."
          100  +        echo "  GUID=='33d63375-7582-49dd-aa88-71b3900170e7'"
          101  +        echo ""
          102  +        echo "  Aborting script without doing anything."
          103  +        echo ""
          104  +        exit 1 # exit with error
          105  +    fi
          106  +fi
          107  +
          108  +
          109  +#--------------------------------------------------------------------------
          110  +
          111  +SB_EXISTS_ON_PATH_T1_RESULT="f"
          112  +func_sb_exists_on_path_t1 () {
          113  +    local S_NAME_OF_THE_EXECUTABLE_1="$1" # first function argument
          114  +    #--------
          115  +    # Function calls like
          116  +    #
          117  +    #     func_sb_exists_on_path_t1 ""
          118  +    #     func_sb_exists_on_path_t1 " "
          119  +    #     func_sb_exists_on_path_t1 "ls ps" # contains a space
          120  +    #
          121  +    # are not allowed.
          122  +    if [ "$S_NAME_OF_THE_EXECUTABLE_1" == "" ] ; then
          123  +        echo ""
          124  +        echo "The Bash function "
          125  +        echo ""
          126  +        echo "    func_sb_exists_on_path_t1 "
          127  +        echo ""
          128  +        echo "is not designed to handle an argument that "
          129  +        echo "equals with an empty string."
          130  +        echo "GUID=='39128b22-8ba8-4037-bb88-71b3900170e7'"
          131  +        echo ""
          132  +        #----
          133  +        cd $S_FP_ORIG
          134  +        exit 1 # exit with error
          135  +    fi
          136  +    local S_TMP_0="`printf \"$S_NAME_OF_THE_EXECUTABLE_1\" | gawk '{gsub(/\s/,"");printf "%s", $1 }'`"
          137  +    if [ "$S_NAME_OF_THE_EXECUTABLE_1" != "$S_TMP_0" ] ; then
          138  +        echo ""
          139  +        echo "The Bash function "
          140  +        echo ""
          141  +        echo "    func_sb_exists_on_path_t1 "
          142  +        echo ""
          143  +        echo "is not designed to handle an argument value that contains "
          144  +        echo "spaces or tabulation characters."
          145  +        echo "The received value in parenthesis:($S_NAME_OF_THE_EXECUTABLE_1)."
          146  +        echo "GUID=='47c83d31-51ea-4119-ae88-71b3900170e7'"
          147  +        echo ""
          148  +        #----
          149  +        cd $S_FP_ORIG
          150  +        exit 1 # exit with error
          151  +    fi
          152  +    #--------
          153  +    S_TMP_0="\`which $S_NAME_OF_THE_EXECUTABLE_1 2>/dev/null\`"
          154  +    local S_TMP_1=""
          155  +    local S_TMP_2="S_TMP_1=$S_TMP_0"
          156  +    eval ${S_TMP_2}
          157  +    #----
          158  +    if [ "$S_TMP_1" == "" ] ; then
          159  +        SB_EXISTS_ON_PATH_T1_RESULT="f"
          160  +    else
          161  +        SB_EXISTS_ON_PATH_T1_RESULT="t"
          162  +    fi
          163  +} # func_sb_exists_on_path_t1 
          164  +
          165  +
          166  +
          167  +func_assert_exists_on_path_t2 () {
          168  +    local S_NAME_OF_THE_EXECUTABLE_1="$1" # first function argument
          169  +    local S_NAME_OF_THE_EXECUTABLE_2="$2" # optional argument
          170  +    local S_NAME_OF_THE_EXECUTABLE_3="$3" # optional argument
          171  +    local S_NAME_OF_THE_EXECUTABLE_4="$4" # optional argument
          172  +    #--------
          173  +    # Function calls like
          174  +    #
          175  +    #     func_assert_exists_on_path_t2  ""    ""  "ls"
          176  +    #     func_assert_exists_on_path_t2  "ls"  ""  "ps"
          177  +    #
          178  +    # are not allowed by the spec of this function, but it's OK to call
          179  +    #
          180  +    #     func_assert_exists_on_path_t2  "ls" "" 
          181  +    #     func_assert_exists_on_path_t2  "ls" "ps" ""
          182  +    #     func_assert_exists_on_path_t2  "ls" ""   "" ""
          183  +    #
          184  +    #
          185  +    local SB_THROW="f"
          186  +    if [ "$S_NAME_OF_THE_EXECUTABLE_1" == "" ] ; then
          187  +        SB_THROW="t"
          188  +    else
          189  +        if [ "$S_NAME_OF_THE_EXECUTABLE_2" == "" ] ; then
          190  +            if [ "$S_NAME_OF_THE_EXECUTABLE_3" != "" ] ; then
          191  +                SB_THROW="t"
          192  +            fi
          193  +            if [ "$S_NAME_OF_THE_EXECUTABLE_4" != "" ] ; then
          194  +                SB_THROW="t"
          195  +            fi
          196  +        else
          197  +            if [ "$S_NAME_OF_THE_EXECUTABLE_3" == "" ] ; then
          198  +                if [ "$S_NAME_OF_THE_EXECUTABLE_4" != "" ] ; then
          199  +                    SB_THROW="t"
          200  +                fi
          201  +            fi
          202  +        fi
          203  +    fi
          204  +    #----
          205  +    if [ "$SB_THROW" == "t" ] ; then
          206  +        echo ""
          207  +        echo "The Bash function "
          208  +        echo ""
          209  +        echo "    func_assert_exists_on_path_t2 "
          210  +        echo ""
          211  +        echo "is not designed to handle series of arguments, where "
          212  +        echo "empty strings preced non-empty strings."
          213  +        echo "GUID=='1ae7a9bd-e472-4344-8188-71b3900170e7'"
          214  +        echo ""
          215  +        #----
          216  +        cd $S_FP_ORIG
          217  +        exit 1 # exit with error
          218  +    fi
          219  +    if [ "$5" != "" ] ; then
          220  +        echo ""
          221  +        echo "This Bash function is designed to work with at most 4 input arguments"
          222  +        echo "GUID=='05af1c56-ee4e-485e-8388-71b3900170e7'"
          223  +        echo ""
          224  +        #----
          225  +        cd $S_FP_ORIG
          226  +        exit 1 # exit with error
          227  +    fi
          228  +    #--------
          229  +    # Function calls like
          230  +    #
          231  +    #     func_assert_exists_on_path_t2 " "
          232  +    #     func_assert_exists_on_path_t2 "ls ps" # contains a space
          233  +    #
          234  +    # are not allowed.
          235  +    SB_THROW="f" 
          236  +    local S_TMP_0=""
          237  +    local S_TMP_1=""
          238  +    local S_TMP_2=""
          239  +    #----
          240  +    if [ "$SB_THROW" == "f" ] ; then
          241  +        S_TMP_0="`printf \"$S_NAME_OF_THE_EXECUTABLE_1\" | gawk '{gsub(/\s/,"");printf "%s", $1 }'`"
          242  +        if [ "$S_NAME_OF_THE_EXECUTABLE_1" != "$S_TMP_0" ] ; then
          243  +            SB_THROW="t" 
          244  +            S_TMP_1="$S_NAME_OF_THE_EXECUTABLE_1"
          245  +            S_TMP_2="GUID=='eb3a821d-b300-4128-8588-71b3900170e7'"
          246  +        fi
          247  +    fi
          248  +    #----
          249  +    if [ "$SB_THROW" == "f" ] ; then
          250  +        S_TMP_0="`printf \"$S_NAME_OF_THE_EXECUTABLE_2\" | gawk '{gsub(/\s/,"");printf "%s", $1 }'`"
          251  +        if [ "$S_NAME_OF_THE_EXECUTABLE_2" != "$S_TMP_0" ] ; then
          252  +            SB_THROW="t" 
          253  +            S_TMP_1="$S_NAME_OF_THE_EXECUTABLE_2"
          254  +            S_TMP_2="GUID=='071590a7-41d2-467f-8888-71b3900170e7'"
          255  +        fi
          256  +    fi
          257  +    #----
          258  +    if [ "$SB_THROW" == "f" ] ; then
          259  +        S_TMP_0="`printf \"$S_NAME_OF_THE_EXECUTABLE_3\" | gawk '{gsub(/\s/,"");printf "%s", $1 }'`"
          260  +        if [ "$S_NAME_OF_THE_EXECUTABLE_3" != "$S_TMP_0" ] ; then
          261  +            SB_THROW="t" 
          262  +            S_TMP_1="$S_NAME_OF_THE_EXECUTABLE_3"
          263  +            S_TMP_2="GUID=='1beff945-939d-48f9-a178-71b3900170e7'"
          264  +        fi
          265  +    fi
          266  +    #----
          267  +    if [ "$SB_THROW" == "f" ] ; then
          268  +        S_TMP_0="`printf \"$S_NAME_OF_THE_EXECUTABLE_4\" | gawk '{gsub(/\s/,"");printf "%s", $1 }'`"
          269  +        if [ "$S_NAME_OF_THE_EXECUTABLE_4" != "$S_TMP_0" ] ; then
          270  +            SB_THROW="t" 
          271  +            S_TMP_1="$S_NAME_OF_THE_EXECUTABLE_4"
          272  +            S_TMP_2="GUID=='9bf9ca59-4c78-4fb6-8378-71b3900170e7'"
          273  +        fi
          274  +    fi
          275  +    #--------
          276  +    if [ "$SB_THROW" == "t" ] ; then
          277  +        echo ""
          278  +        echo "The Bash function "
          279  +        echo ""
          280  +        echo "    func_assert_exists_on_path_t2 "
          281  +        echo ""
          282  +        echo "is not designed to handle an argument value that contains "
          283  +        echo "spaces or tabulation characters."
          284  +        echo "The unaccepted value in parenthesis:($S_TMP_1)."
          285  +        echo "Branch $S_TMP_2."
          286  +        echo "GUID=='24b11e55-b4ea-419c-8578-71b3900170e7'"
          287  +        echo ""
          288  +        #----
          289  +        cd $S_FP_ORIG
          290  +        exit 1 # exit with error
          291  +    fi
          292  +    SB_THROW="f" # Just a reset, should I forget to reset it later.
          293  +    #---------------
          294  +    S_TMP_0="\`which $S_NAME_OF_THE_EXECUTABLE_1 2>/dev/null\`"
          295  +    local S_TMP_1=""
          296  +    local S_TMP_2="S_TMP_1=$S_TMP_0"
          297  +    eval ${S_TMP_2}
          298  +    #----
          299  +    if [ "$S_TMP_1" == "" ] ; then
          300  +        if [ "$S_NAME_OF_THE_EXECUTABLE_2" == "" ] ; then
          301  +        if [ "$S_NAME_OF_THE_EXECUTABLE_3" == "" ] ; then
          302  +        if [ "$S_NAME_OF_THE_EXECUTABLE_4" == "" ] ; then
          303  +            echo ""
          304  +            echo "This bash script requires the \"$S_NAME_OF_THE_EXECUTABLE_1\" to be on the PATH."
          305  +            echo "GUID=='62b54420-f8c0-4d4b-b278-71b3900170e7'"
          306  +            echo ""
          307  +            #----
          308  +            cd $S_FP_ORIG
          309  +            exit 1 # exit with error
          310  +        fi
          311  +        fi
          312  +        fi
          313  +    else
          314  +        return # at least one of the programs was available at the PATH
          315  +    fi
          316  +    #--------
          317  +    S_TMP_0="\`which $S_NAME_OF_THE_EXECUTABLE_2 2>/dev/null\`"
          318  +    S_TMP_1=""
          319  +    S_TMP_2="S_TMP_1=$S_TMP_0"
          320  +    eval ${S_TMP_2}
          321  +    #----
          322  +    if [ "$S_TMP_1" == "" ] ; then
          323  +        if [ "$S_NAME_OF_THE_EXECUTABLE_3" == "" ] ; then
          324  +        if [ "$S_NAME_OF_THE_EXECUTABLE_4" == "" ] ; then
          325  +            echo ""
          326  +            echo "This bash script requires that either \"$S_NAME_OF_THE_EXECUTABLE_1\" or "
          327  +            echo " \"$S_NAME_OF_THE_EXECUTABLE_2\" is available on the PATH."
          328  +            echo "GUID=='aa80d32e-c312-40b0-8478-71b3900170e7'"
          329  +            echo ""
          330  +            #----
          331  +            cd $S_FP_ORIG
          332  +            exit 1 # exit with error
          333  +        fi
          334  +        fi
          335  +    else
          336  +        return # at least one of the programs was available at the PATH
          337  +    fi
          338  +    #--------
          339  +    S_TMP_0="\`which $S_NAME_OF_THE_EXECUTABLE_3 2>/dev/null\`"
          340  +    S_TMP_1=""
          341  +    S_TMP_2="S_TMP_1=$S_TMP_0"
          342  +    eval ${S_TMP_2}
          343  +    #----
          344  +    if [ "$S_TMP_1" == "" ] ; then
          345  +        if [ "$S_NAME_OF_THE_EXECUTABLE_4" == "" ] ; then
          346  +            echo ""
          347  +            echo "This bash script requires that either \"$S_NAME_OF_THE_EXECUTABLE_1\" or "
          348  +            echo " \"$S_NAME_OF_THE_EXECUTABLE_2\" or \"$S_NAME_OF_THE_EXECUTABLE_3\" "
          349  +            echo "is available on the PATH."
          350  +            echo "GUID=='3ae0cfcc-0a10-45c5-8168-71b3900170e7'"
          351  +            echo ""
          352  +            #----
          353  +            cd $S_FP_ORIG
          354  +            exit 1 # exit with error
          355  +        fi
          356  +    else
          357  +        return # at least one of the programs was available at the PATH
          358  +    fi
          359  +    #--------
          360  +    S_TMP_0="\`which $S_NAME_OF_THE_EXECUTABLE_4 2>/dev/null\`"
          361  +    S_TMP_1=""
          362  +    S_TMP_2="S_TMP_1=$S_TMP_0"
          363  +    eval ${S_TMP_2}
          364  +    #----
          365  +    if [ "$S_TMP_1" == "" ] ; then
          366  +        echo ""
          367  +        echo "This bash script requires that either \"$S_NAME_OF_THE_EXECUTABLE_1\" or "
          368  +        echo " \"$S_NAME_OF_THE_EXECUTABLE_2\" or \"$S_NAME_OF_THE_EXECUTABLE_3\" or "
          369  +        echo " \"$S_NAME_OF_THE_EXECUTABLE_4\" is available on the PATH."
          370  +        echo "GUID=='64dba5fe-7564-4666-a468-71b3900170e7'"
          371  +        echo ""
          372  +        #----
          373  +        cd $S_FP_ORIG
          374  +        exit 1 # exit with error
          375  +    else
          376  +        return # at least one of the programs was available at the PATH
          377  +    fi
          378  +    #--------
          379  +} # func_assert_exists_on_path_t2
          380  +
          381  +func_assert_exists_on_path_t2 "bash"     # this is a bash script, but it does not hurt
          382  +func_assert_exists_on_path_t2 "basename" # for extracting file names from full paths
          383  +func_assert_exists_on_path_t2 "cat"    # opposite to split
          384  +func_assert_exists_on_path_t2 "sha256sum" "sha256" "rhash"
          385  +func_assert_exists_on_path_t2 "tigerdeep" "rhash"
          386  +func_assert_exists_on_path_t2 "whirlpooldeep" "rhash"
          387  +func_assert_exists_on_path_t2 "tar"
          388  +#--------
          389  +func_assert_exists_on_path_t2 "file"   # for checking the MIME type of the potential tar file
          390  +func_assert_exists_on_path_t2 "filesize" "ruby"
          391  +func_assert_exists_on_path_t2 "gawk"
          392  +#func_assert_exists_on_path_t2 "grep"
          393  +#func_assert_exists_on_path_t2 "readlink"
          394  +func_assert_exists_on_path_t2 "ruby"  # anything over/equal v.2.1 will probably do
          395  +#func_assert_exists_on_path_t2 "split" # for cutting files
          396  +#func_assert_exists_on_path_t2 "test"
          397  +func_assert_exists_on_path_t2 "uname"  # to check the OS type
          398  +func_assert_exists_on_path_t2 "uuidgen" "uuid" # GUID generation on Linux and BSD
          399  +#func_assert_exists_on_path_t2 "xargs"   
          400  +func_assert_exists_on_path_t2 "wc" # for checking hash lengths   
          401  +
          402  +
          403  +#--------------------------------------------------------------------------
          404  +
          405  +func_mmmv_exc_hash_function_input_verification_t1() { 
          406  +    local S_NAME_OF_THE_BASH_FUNCTION="$1" # The name of the Bash function.
          407  +    local S_FP_2_AN_EXISTING_FILE="$2" # The first argument of the Bash function.
          408  +    #--------
          409  +    if [ "$S_NAME_OF_THE_BASH_FUNCTION" == "" ] ; then
          410  +        echo ""
          411  +        echo "The implementation of the function that "
          412  +        echo "calls the "
          413  +        echo ""
          414  +        echo "    func_mmmv_exc_hash_function_input_verification_t1"
          415  +        echo ""
          416  +        echo "is flawed. The call to the "
          417  +        echo ""
          418  +        echo "    func_mmmv_exc_hash_function_input_verification_t1"
          419  +        echo ""
          420  +        echo "misses the first argument or the first argument is an empty string."
          421  +        echo "GUID=='b91da738-c651-4c2a-8b68-71b3900170e7'"
          422  +        echo ""
          423  +        #----
          424  +        cd $S_FP_ORIG
          425  +        exit 1 # exit with error
          426  +    fi
          427  +    local S_TMP_0="`printf \"$S_NAME_OF_THE_BASH_FUNCTION\" | gawk '{gsub(/\s/,"");printf "%s", $1 }'`"
          428  +    if [ "$S_NAME_OF_THE_BASH_FUNCTION" != "$S_TMP_0" ] ; then
          429  +        echo ""
          430  +        echo "The implementation of the function that "
          431  +        echo "calls the "
          432  +        echo ""
          433  +        echo "    func_mmmv_exc_hash_function_input_verification_t1"
          434  +        echo ""
          435  +        echo "is flawed. Function names are not allowed to contain spaces or tabs."
          436  +        echo "GUID=='405b2523-bd54-463b-9368-71b3900170e7'"
          437  +        echo ""
          438  +        #----
          439  +        cd $S_FP_ORIG
          440  +        exit 1 # exit with error
          441  +    fi
          442  +    #--------
          443  +    # Function calls like
          444  +    #
          445  +    #     <function name> ""
          446  +    #     <function name> " "
          447  +    #
          448  +    # are not allowed.
          449  +    local S_TMP_0="`printf \"$S_FP_2_AN_EXISTING_FILE\" | gawk '{gsub(/\s/,"");printf "%s", $1 }'`"
          450  +    if [ "$S_TMP_0" == "" ] ; then
          451  +        echo ""
          452  +        echo "The Bash function "
          453  +        echo ""
          454  +        echo "    $S_NAME_OF_THE_BASH_FUNCTION"
          455  +        echo ""
          456  +        echo "is not designed to handle an argument that "
          457  +        echo "equals with an empty string or a series of spaces and tabs."
          458  +        echo "GUID=='7118e122-ef7a-43e6-af68-71b3900170e7'"
          459  +        echo ""
          460  +        #----
          461  +        cd $S_FP_ORIG
          462  +        exit 1 # exit with error
          463  +    fi
          464  +    #--------
          465  +    if [ ! -e $S_FP_2_AN_EXISTING_FILE ] ; then
          466  +        echo ""
          467  +        echo "The file "
          468  +        echo ""
          469  +        echo "    $S_FP_2_AN_EXISTING_FILE "
          470  +        echo ""
          471  +        echo "is missing or it is a broken link."
          472  +        echo "GUID=='1c0b3101-7922-42b3-ac68-71b3900170e7'"
          473  +        echo ""
          474  +        #----
          475  +        cd $S_FP_ORIG
          476  +        exit 1 # exit with error
          477  +    fi
          478  +    if [ -d $S_FP_2_AN_EXISTING_FILE ] ; then
          479  +        echo ""
          480  +        echo "The file path "
          481  +        echo ""
          482  +        echo "    $S_FP_2_AN_EXISTING_FILE "
          483  +        echo ""
          484  +        echo "references a folder, but a file is expected."
          485  +        echo "GUID=='04596259-93f4-45f3-8368-71b3900170e7'"
          486  +        echo ""
          487  +        #----
          488  +        cd $S_FP_ORIG
          489  +        exit 1 # exit with error
          490  +    fi
          491  +    #--------------------
          492  +    # At this line the verifications have all passed.
          493  +    #--------------------
          494  +} # func_mmmv_exc_hash_function_input_verification_t1
          495  +
          496  +
          497  +#--------------------------------------------------------------------------
          498  +
          499  +S_FUNC_MMMV_GUID_T1_RESULT="not_yet_set"
          500  +S_FUNC_MMMV_GUID_T1_MODE="" # optim. to skip repeating console tool selection
          501  +func_mmmv_GUID_t1() { 
          502  +    # Does not take any arguments.
          503  +    #--------
          504  +    #func_mmmv_exc_hash_function_input_verification_t1 "func_mmmv_GUID_t1" "$1"
          505  +    #--------------------
          506  +    # Mode selection:
          507  +    if [ "$S_FUNC_MMMV_GUID_T1_MODE" == "" ] ; then
          508  +        SB_EXISTS_ON_PATH_T1_RESULT="f"  # if-block init
          509  +        #----
          510  +        if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "f" ] ; then
          511  +            S_TMP_0="uuidgen" # Linux version
          512  +            func_sb_exists_on_path_t1 "$S_TMP_0" 
          513  +            if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "t" ] ; then
          514  +                 S_FUNC_MMMV_GUID_T1_MODE="$S_TMP_0"
          515  +            fi
          516  +        fi
          517  +        #----
          518  +        if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "f" ] ; then
          519  +            S_TMP_0="uuid"    # BSD version
          520  +            func_sb_exists_on_path_t1 "$S_TMP_0" 
          521  +            if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "t" ] ; then
          522  +                 S_FUNC_MMMV_GUID_T1_MODE="$S_TMP_0"
          523  +            fi
          524  +        fi
          525  +        #--------
          526  +        if [ "$S_FUNC_MMMV_GUID_T1_MODE" == "" ] ; then
          527  +            echo ""
          528  +            echo "All of the GUID generation implementations that this script " 
          529  +            echo "is capable of using (uuidgen, uuid) "
          530  +            echo "are missing from the PATH."
          531  +            echo "GUID=='25286e58-fb76-41f5-8568-71b3900170e7'"
          532  +            echo ""
          533  +            #----
          534  +            cd $S_FP_ORIG
          535  +            exit 1 # exit with error
          536  +        fi
          537  +        #--------
          538  +        if [ "$?" != "0" ]; then
          539  +            echo ""
          540  +            echo "This script is flawed."
          541  +            echo "GUID=='31132449-5de3-431f-a258-71b3900170e7'"
          542  +            echo ""
          543  +            #----
          544  +            cd $S_FP_ORIG
          545  +            exit 1 # exit with error
          546  +        fi
          547  +        #--------
          548  +    fi
          549  +    #--------------------
          550  +    S_FUNC_MMMV_GUID_T1_RESULT=""
          551  +    #--------------------
          552  +    if [ "$S_FUNC_MMMV_GUID_T1_MODE" == "uuidgen" ]; then
          553  +        S_TMP_0="`uuidgen`"
          554  +        if [ "$?" != "0" ]; then
          555  +            echo ""
          556  +            echo "The console application \"uuidgen\" "
          557  +            echo "exited with an error."
          558  +            echo ""
          559  +            echo "----console--outut--citation--start-----"
          560  +            echo "`uuidgen`" # stdout and stderr
          561  +            echo "----console--outut--citation--end-------"
          562  +            echo ""
          563  +            echo "GUID=='2d8df7d1-9ef0-4531-b558-71b3900170e7'"
          564  +            echo ""
          565  +            #----
          566  +            cd $S_FP_ORIG
          567  +            exit 1 # exit with error
          568  +        fi
          569  +        #---- 
          570  +        S_FUNC_MMMV_GUID_T1_RESULT="$S_TMP_0"
          571  +    fi
          572  +    #--------------------
          573  +    if [ "$S_FUNC_MMMV_GUID_T1_MODE" == "uuid" ]; then
          574  +        S_TMP_0="`uuid`"
          575  +        if [ "$?" != "0" ]; then
          576  +            echo ""
          577  +            echo "The console application \"uuid\" "
          578  +            echo "exited with an error."
          579  +            echo ""
          580  +            echo "----console--outut--citation--start-----"
          581  +            echo "`uuid`" # stdout and stderr
          582  +            echo "----console--outut--citation--end-------"
          583  +            echo ""
          584  +            echo "GUID=='7616c855-15e3-4331-a158-71b3900170e7'"
          585  +            echo ""
          586  +            #----
          587  +            cd $S_FP_ORIG
          588  +            exit 1 # exit with error
          589  +        fi
          590  +        #---- 
          591  +        S_FUNC_MMMV_GUID_T1_RESULT="$S_TMP_0"
          592  +    fi
          593  +    #--------------------
          594  +    S_TMP_0="`printf \"$S_FUNC_MMMV_GUID_T1_RESULT\" | wc -m `"
          595  +    S_TMP_1="36"
          596  +    if [ "$S_TMP_0" != "$S_TMP_1" ]; then
          597  +        echo ""
          598  +        echo "According to the GUID specification, IETF RFC 4122,  "
          599  +        echo "the lenght of the GUID is "
          600  +        echo "$S_TMP_1 characters, but the result of the "
          601  +        echo ""
          602  +        echo "    func_mmmv_GUID_t1"
          603  +        echo ""
          604  +        echo "is something else. The flawed GUID candidate in parenthesis:"
          605  +        echo "($S_FUNC_MMMV_GUID_T1_RESULT)"
          606  +        echo ""
          607  +        echo "The lenght candidate of the flawed GUID candidate in parenthesis:"
          608  +        echo "($S_TMP_0)."
          609  +        echo ""
          610  +        echo "GUID=='7a226a41-91ce-4ab9-a258-71b3900170e7'"
          611  +        echo ""
          612  +        #----
          613  +        cd $S_FP_ORIG
          614  +        exit 1 # exit with error
          615  +    fi
          616  +    #--------------------
          617  +} # func_mmmv_GUID_t1
          618  +
          619  +
          620  +#--------------------------------------------------------------------------
          621  +
          622  +S_FUNC_MMMV_SHA256_T1_RESULT="not_yet_set"
          623  +S_FUNC_MMMV_SHA256_T1_MODE="" # optim. to skip repeating console tool selection
          624  +func_mmmv_sha256_t1() { # requires also ruby and gawk 
          625  +    local S_FP_2_AN_EXISTING_FILE="$1" # first function argument
          626  +    #--------
          627  +    func_mmmv_exc_hash_function_input_verification_t1 "func_mmmv_sha256_t1" "$1"
          628  +    #--------------------
          629  +    # Mode selection:
          630  +    if [ "$S_FUNC_MMMV_SHA256_T1_MODE" == "" ] ; then
          631  +        SB_EXISTS_ON_PATH_T1_RESULT="f"  # if-block init
          632  +        #----
          633  +        if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "f" ] ; then
          634  +            S_TMP_0="sha256sum" # usually available on Linux
          635  +            func_sb_exists_on_path_t1 "$S_TMP_0" 
          636  +            if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "t" ] ; then
          637  +                 S_FUNC_MMMV_SHA256_T1_MODE="$S_TMP_0"
          638  +            fi
          639  +        fi
          640  +        #----
          641  +        if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "f" ] ; then
          642  +            S_TMP_0="rhash"    # part of the BSD package collection in 2016
          643  +            func_sb_exists_on_path_t1 "$S_TMP_0" 
          644  +            if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "t" ] ; then
          645  +                 S_FUNC_MMMV_SHA256_T1_MODE="$S_TMP_0"
          646  +            fi
          647  +        fi
          648  +        #----
          649  +        if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "f" ] ; then
          650  +            S_TMP_0="sha256"    # usually available on BSD
          651  +            func_sb_exists_on_path_t1 "$S_TMP_0" 
          652  +            if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "t" ] ; then
          653  +                 S_FUNC_MMMV_SHA256_T1_MODE="$S_TMP_0"
          654  +            fi
          655  +        fi
          656  +        # The console application "rhash" is preferred to the "sha256"
          657  +        # because the "rhash" output can be simply processed with 
          658  +        # "gawk", which takes over 5x less memory than the Ruby interpreter,
          659  +        # not to mention the initialization cost of the Ruby interpreter.
          660  +        #--------
          661  +        if [ "$S_FUNC_MMMV_SHA256_T1_MODE" == "" ] ; then
          662  +            echo ""
          663  +            echo "All of the SHA-256 implementations that this script " 
          664  +            echo "is capable of using (sha256sum, rhash, sha256) "
          665  +            echo "are missing from the PATH."
          666  +            echo "GUID=='4aef5146-0d53-414e-b258-71b3900170e7'"
          667  +            echo ""
          668  +            #----
          669  +            cd $S_FP_ORIG
          670  +            exit 1 # exit with error
          671  +        fi
          672  +        #--------
          673  +        if [ "$?" != "0" ]; then
          674  +            echo ""
          675  +            echo "This script is flawed."
          676  +            echo "GUID=='852b0558-3ebd-4de9-a158-71b3900170e7'"
          677  +            echo ""
          678  +            #----
          679  +            cd $S_FP_ORIG
          680  +            exit 1 # exit with error
          681  +        fi
          682  +        #--------
          683  +    fi
          684  +    #--------------------
          685  +    S_FUNC_MMMV_SHA256_T1_RESULT=""
          686  +    #--------------------
          687  +    if [ "$S_FUNC_MMMV_SHA256_T1_MODE" == "sha256sum" ]; then
          688  +        S_TMP_0="`sha256sum $S_FP_2_AN_EXISTING_FILE 2>/dev/null`"
          689  +        if [ "$?" != "0" ]; then
          690  +            echo ""
          691  +            echo "The console application \"sha256sum\" "
          692  +            echo "exited with an error."
          693  +            echo ""
          694  +            echo "----console--outut--citation--start-----"
          695  +            echo "`sha256sum $S_FP_2_AN_EXISTING_FILE`" # stdout and stderr
          696  +            echo "----console--outut--citation--end-------"
          697  +            echo ""
          698  +            echo "GUID=='611e5732-c1cc-480a-a458-71b3900170e7'"
          699  +            echo ""
          700  +            #----
          701  +            cd $S_FP_ORIG
          702  +            exit 1 # exit with error
          703  +        fi
          704  +        #---- 
          705  +        # The gawk is used for selecting the 1. column because 
          706  +        # according to the
          707  +        #
          708  +        #     echo "aa bb" | time -v gawk '{printf $1}'
          709  +        #
          710  +        # the gawk takes about 3MiB, which is far less than the 
          711  +        #
          712  +        #     time -v ruby -e "puts 'hi'"
          713  +        #
          714  +        # indicated 16MiB
          715  +        #
          716  +        S_FUNC_MMMV_SHA256_T1_RESULT="`echo \"$S_TMP_0\" | gawk '{printf $1}'`"
          717  +    fi
          718  +    #--------------------
          719  +    if [ "$S_FUNC_MMMV_SHA256_T1_MODE" == "rhash" ]; then
          720  +        S_TMP_0="`rhash --sha256 $S_FP_2_AN_EXISTING_FILE 2>/dev/null`"
          721  +        if [ "$?" != "0" ]; then
          722  +            echo ""
          723  +            echo "The console application \"rhash\" "
          724  +            echo "exited with an error."
          725  +            echo ""
          726  +            echo "----console--outut--citation--start-----"
          727  +            echo "`rhash --sha256 $S_FP_2_AN_EXISTING_FILE `"
          728  +            echo "----console--outut--citation--end-------"
          729  +            echo ""
          730  +            echo "GUID=='f377bf45-4ea1-4fe6-9148-71b3900170e7'"
          731  +            echo ""
          732  +            #----
          733  +            cd $S_FP_ORIG
          734  +            exit 1 # exit with error
          735  +        fi
          736  +        S_FUNC_MMMV_SHA256_T1_RESULT="`echo \"$S_TMP_0\" | gawk '{printf $1}'`"
          737  +    fi
          738  +    #--------------------
          739  +    if [ "$S_FUNC_MMMV_SHA256_T1_MODE" == "sha256" ]; then
          740  +        #----
          741  +        S_FUNC_MMMV_SHA256_T1_RESULT=\
          742  +        "`S_TMP_0=\"\`sha256 $S_FP_2_AN_EXISTING_FILE\`\" ruby -e \"s0=ENV['S_TMP_0'].to_s;ix_0=s0.index(') = ');print s0[(ix_0+4)..(-1)]\" 2>/dev/null`"
          743  +        #----
          744  +        if [ "$?" != "0" ]; then
          745  +            echo ""
          746  +            echo "The console application \"sha256\" "
          747  +            echo "exited with an error."
          748  +            echo ""
          749  +            echo "----console--outut--citation--start-----"
          750  +            echo \
          751  +            "`S_TMP_0=\"\`sha256 $S_FP_2_AN_EXISTING_FILE\`\" ruby -e \"s0=ENV['S_TMP_0'].to_s;ix_0=s0.index(') = ');print s0[(ix_0+4)..(-1)]\"`"
          752  +            echo "----console--outut--citation--end-------"
          753  +            echo ""
          754  +            echo "GUID=='22691ef3-f14b-4f46-bb48-71b3900170e7'"
          755  +            echo ""
          756  +            #----
          757  +            cd $S_FP_ORIG
          758  +            exit 1 # exit with error
          759  +        fi
          760  +    fi
          761  +    #--------------------
          762  +    S_TMP_0="`printf \"$S_FUNC_MMMV_SHA256_T1_RESULT\" | wc -m `"
          763  +    S_TMP_1="64"
          764  +    if [ "$S_TMP_0" != "$S_TMP_1" ]; then
          765  +        echo ""
          766  +        echo "According to the specification of the SHA-256 hash algorithm"
          767  +        echo "the lenght of the SHA-256 hash is "
          768  +        echo "$S_TMP_1 hexadecimal characters, but the result of the "
          769  +        echo ""
          770  +        echo "    func_mmmv_sha256_t1"
          771  +        echo ""
          772  +        echo "is something else. The flawed hash candidate in parenthesis:"
          773  +        echo "($S_FUNC_MMMV_SHA256_T1_RESULT)"
          774  +        echo ""
          775  +        echo "The lenght candidate of the flawed hash candidate in parenthesis:"
          776  +        echo "($S_TMP_0)."
          777  +        echo ""
          778  +        echo "GUID=='3e6b48bd-8a81-4f15-b148-71b3900170e7'"
          779  +        echo ""
          780  +        #----
          781  +        cd $S_FP_ORIG
          782  +        exit 1 # exit with error
          783  +    fi
          784  +    #--------------------
          785  +} # func_mmmv_sha256_t1
          786  +
          787  +
          788  +#--------------------------------------------------------------------------
          789  +
          790  +S_FUNC_MMMV_TIGERHASH_T1_RESULT="not_yet_set"
          791  +S_FUNC_MMMV_TIGERHASH_T1_MODE="" # optim. to skip repeating console tool selection
          792  +func_mmmv_tigerhash_t1() { # requires also ruby and gawk 
          793  +    local S_FP_2_AN_EXISTING_FILE="$1" # first function argument
          794  +    #--------
          795  +    func_mmmv_exc_hash_function_input_verification_t1 "func_mmmv_tigerhash_t1" "$1"
          796  +    #--------------------
          797  +    # Mode selection:
          798  +    if [ "$S_FUNC_MMMV_TIGERHASH_T1_MODE" == "" ] ; then
          799  +        SB_EXISTS_ON_PATH_T1_RESULT="f"  # if-block init
          800  +        #----
          801  +        if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "f" ] ; then
          802  +            S_TMP_0="tigerdeep" # usually available on Linux
          803  +            func_sb_exists_on_path_t1 "$S_TMP_0" 
          804  +            if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "t" ] ; then
          805  +                 S_FUNC_MMMV_TIGERHASH_T1_MODE="$S_TMP_0"
          806  +            fi
          807  +        fi
          808  +        #----
          809  +        if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "f" ] ; then
          810  +            S_TMP_0="rhash"    # part of the BSD package collection in 2016
          811  +            func_sb_exists_on_path_t1 "$S_TMP_0" 
          812  +            if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "t" ] ; then
          813  +                 S_FUNC_MMMV_TIGERHASH_T1_MODE="$S_TMP_0"
          814  +            fi
          815  +        fi
          816  +        #--------
          817  +        if [ "$S_FUNC_MMMV_TIGERHASH_T1_MODE" == "" ] ; then
          818  +            echo ""
          819  +            echo "All of the Tiger hash implementations that this script " 
          820  +            echo "is capable of using (tigerdeep, rhash) "
          821  +            echo "are missing from the PATH."
          822  +            echo "GUID=='2bed8ba2-1f17-43d0-8b48-71b3900170e7'"
          823  +            echo ""
          824  +            #----
          825  +            cd $S_FP_ORIG
          826  +            exit 1 # exit with error
          827  +        fi
          828  +        #--------
          829  +        if [ "$?" != "0" ]; then
          830  +            echo ""
          831  +            echo "This script is flawed."
          832  +            echo "GUID=='401fae19-71e9-4c52-b148-71b3900170e7'"
          833  +            echo ""
          834  +            #----
          835  +            cd $S_FP_ORIG
          836  +            exit 1 # exit with error
          837  +        fi
          838  +        #--------
          839  +    fi
          840  +    #--------------------
          841  +    S_FUNC_MMMV_TIGERHASH_T1_RESULT=""
          842  +    #--------------------
          843  +    if [ "$S_FUNC_MMMV_TIGERHASH_T1_MODE" == "tigerdeep" ]; then
          844  +        S_TMP_0="`tigerdeep $S_FP_2_AN_EXISTING_FILE 2>/dev/null`"
          845  +        if [ "$?" != "0" ]; then
          846  +            echo ""
          847  +            echo "The console application \"tigerdeep\" "
          848  +            echo "exited with an error."
          849  +            echo ""
          850  +            echo "----console--outut--citation--start-----"
          851  +            echo "`tigerdeep $S_FP_2_AN_EXISTING_FILE`" # stdout and stderr
          852  +            echo "----console--outut--citation--end-------"
          853  +            echo ""
          854  +            echo "GUID=='2bd1ed5f-5735-45d7-8248-71b3900170e7'"
          855  +            echo ""
          856  +            #----
          857  +            cd $S_FP_ORIG
          858  +            exit 1 # exit with error
          859  +        fi
          860  +        S_FUNC_MMMV_TIGERHASH_T1_RESULT="`echo \"$S_TMP_0\" | gawk '{printf $1}'`"
          861  +    fi
          862  +    #--------------------
          863  +    if [ "$S_FUNC_MMMV_TIGERHASH_T1_MODE" == "rhash" ]; then
          864  +        S_TMP_0="`rhash --tiger $S_FP_2_AN_EXISTING_FILE 2>/dev/null`"
          865  +        if [ "$?" != "0" ]; then
          866  +            echo ""
          867  +            echo "The console application \"rhash\" "
          868  +            echo "exited with an error."
          869  +            echo ""
          870  +            echo "----console--outut--citation--start-----"
          871  +            echo "`rhash --tiger $S_FP_2_AN_EXISTING_FILE `"
          872  +            echo "----console--outut--citation--end-------"
          873  +            echo ""
          874  +            echo "GUID=='51e5a1c5-292f-4bf1-8948-71b3900170e7'"
          875  +            echo ""
          876  +            #----
          877  +            cd $S_FP_ORIG
          878  +            exit 1 # exit with error
          879  +        fi
          880  +        S_FUNC_MMMV_TIGERHASH_T1_RESULT="`echo \"$S_TMP_0\" | gawk '{printf $1}'`"
          881  +    fi
          882  +    #--------------------
          883  +    S_TMP_0="`printf \"$S_FUNC_MMMV_TIGERHASH_T1_RESULT\" | wc -m `"
          884  +    S_TMP_1="48"
          885  +    if [ "$S_TMP_0" != "$S_TMP_1" ]; then
          886  +        echo ""
          887  +        echo "According to the specification of the Tiger hash algorithm"
          888  +        echo "the lenght of the Tiger hash is "
          889  +        echo "$S_TMP_1 hexadecimal characters, but the result of the "
          890  +        echo ""
          891  +        echo "    func_mmmv_tigerhash_t1"
          892  +        echo ""
          893  +        echo "is something else. The flawed hash candidate in parenthesis:"
          894  +        echo "($S_FUNC_MMMV_TIGERHASH_T1_RESULT)"
          895  +        echo ""
          896  +        echo "The lenght candidate of the flawed hash candidate in parenthesis:"
          897  +        echo "($S_TMP_0)."
          898  +        echo ""
          899  +        echo "GUID=='30fcf82d-5cb9-4c96-9148-71b3900170e7'"
          900  +        echo ""
          901  +        #----
          902  +        cd $S_FP_ORIG
          903  +        exit 1 # exit with error
          904  +    fi
          905  +    #--------------------
          906  +} # func_mmmv_tigerhash_t1
          907  +
          908  +
          909  +#--------------------------------------------------------------------------
          910  +
          911  +S_FUNC_MMMV_WHIRLPOOLHASH_T1_RESULT="not_yet_set"
          912  +S_FUNC_MMMV_WHIRLPOOLHASH_T1_MODE="" # optim. to skip repeating console tool selection
          913  +func_mmmv_whirlpoolhash_t1() { # requires also ruby and gawk 
          914  +    local S_FP_2_AN_EXISTING_FILE="$1" # first function argument
          915  +    #--------
          916  +    func_mmmv_exc_hash_function_input_verification_t1 "func_mmmv_whirlpoolhash_t1" "$1"
          917  +    #--------------------
          918  +    # Mode selection:
          919  +    if [ "$S_FUNC_MMMV_WHIRLPOOLHASH_T1_MODE" == "" ] ; then
          920  +        SB_EXISTS_ON_PATH_T1_RESULT="f"  # if-block init
          921  +        #----
          922  +        if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "f" ] ; then
          923  +            S_TMP_0="whirlpooldeep" # usually available on Linux
          924  +            func_sb_exists_on_path_t1 "$S_TMP_0" 
          925  +            if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "t" ] ; then
          926  +                 S_FUNC_MMMV_WHIRLPOOLHASH_T1_MODE="$S_TMP_0"
          927  +            fi
          928  +        fi
          929  +        #----
          930  +        if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "f" ] ; then
          931  +            S_TMP_0="rhash"    # part of the BSD package collection in 2016
          932  +            func_sb_exists_on_path_t1 "$S_TMP_0" 
          933  +            if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "t" ] ; then
          934  +                 S_FUNC_MMMV_WHIRLPOOLHASH_T1_MODE="$S_TMP_0"
          935  +            fi
          936  +        fi
          937  +        #--------
          938  +        if [ "$S_FUNC_MMMV_WHIRLPOOLHASH_T1_MODE" == "" ] ; then
          939  +            echo ""
          940  +            echo "All of the Whirlpool hash implementations that this script " 
          941  +            echo "is capable of using (whirlpooldeep, rhash) "
          942  +            echo "are missing from the PATH."
          943  +            echo "GUID=='2a608859-8310-44b4-8338-71b3900170e7'"
          944  +            echo ""
          945  +            #----
          946  +            cd $S_FP_ORIG
          947  +            exit 1 # exit with error
          948  +        fi
          949  +        #--------
          950  +        if [ "$?" != "0" ]; then
          951  +            echo ""
          952  +            echo "This script is flawed."
          953  +            echo "GUID=='48097a1c-5e76-4dcc-b538-71b3900170e7'"
          954  +            echo ""
          955  +            #----
          956  +            cd $S_FP_ORIG
          957  +            exit 1 # exit with error
          958  +        fi
          959  +        #--------
          960  +    fi
          961  +    #--------------------
          962  +    S_FUNC_MMMV_WHIRLPOOLHASH_T1_RESULT=""
          963  +    #--------------------
          964  +    if [ "$S_FUNC_MMMV_WHIRLPOOLHASH_T1_MODE" == "whirlpooldeep" ]; then
          965  +        S_TMP_0="`whirlpooldeep $S_FP_2_AN_EXISTING_FILE 2>/dev/null`"
          966  +        if [ "$?" != "0" ]; then
          967  +            echo ""
          968  +            echo "The console application \"whirlpooldeep\" "
          969  +            echo "exited with an error."
          970  +            echo ""
          971  +            echo "----console--outut--citation--start-----"
          972  +            echo "`whirlpooldeep $S_FP_2_AN_EXISTING_FILE`" # stdout and stderr
          973  +            echo "----console--outut--citation--end-------"
          974  +            echo ""
          975  +            echo "GUID=='46922d93-033d-44be-a438-71b3900170e7'"
          976  +            echo ""
          977  +            #----
          978  +            cd $S_FP_ORIG
          979  +            exit 1 # exit with error
          980  +        fi
          981  +        S_FUNC_MMMV_WHIRLPOOLHASH_T1_RESULT="`echo \"$S_TMP_0\" | gawk '{printf $1}'`"
          982  +    fi
          983  +    #--------------------
          984  +    if [ "$S_FUNC_MMMV_WHIRLPOOLHASH_T1_MODE" == "rhash" ]; then
          985  +        S_TMP_0="`rhash --whirlpool $S_FP_2_AN_EXISTING_FILE 2>/dev/null`"
          986  +        if [ "$?" != "0" ]; then
          987  +            echo ""
          988  +            echo "The console application \"rhash\" "
          989  +            echo "exited with an error."
          990  +            echo ""
          991  +            echo "----console--outut--citation--start-----"
          992  +            echo "`rhash --whirlpool $S_FP_2_AN_EXISTING_FILE `"
          993  +            echo "----console--outut--citation--end-------"
          994  +            echo ""
          995  +            echo "GUID=='22eb6a73-6762-4aa1-9538-71b3900170e7'"
          996  +            echo ""
          997  +            #----
          998  +            cd $S_FP_ORIG
          999  +            exit 1 # exit with error
         1000  +        fi
         1001  +        S_FUNC_MMMV_WHIRLPOOLHASH_T1_RESULT="`echo \"$S_TMP_0\" | gawk '{printf $1}'`"
         1002  +    fi
         1003  +    #--------------------
         1004  +    S_TMP_0="`printf \"$S_FUNC_MMMV_WHIRLPOOLHASH_T1_RESULT\" | wc -m `"
         1005  +    S_TMP_1="128"
         1006  +    if [ "$S_TMP_0" != "$S_TMP_1" ]; then
         1007  +        echo ""
         1008  +        echo "According to the specification of the Whirlpool hash algorithm"
         1009  +        echo "the lenght of the Tiger hash is "
         1010  +        echo "$S_TMP_1 hexadecimal characters, but the result of the "
         1011  +        echo ""
         1012  +        echo "    func_mmmv_whirlpoolhash_t1"
         1013  +        echo ""
         1014  +        echo "is something else. The flawed hash candidate in parenthesis:"
         1015  +        echo "($S_FUNC_MMMV_WHIRLPOOLHASH_T1_RESULT)"
         1016  +        echo ""
         1017  +        echo "The lenght candidate of the flawed hash candidate in parenthesis:"
         1018  +        echo "($S_TMP_0)."
         1019  +        echo ""
         1020  +        echo "GUID=='712dc4a3-3fc9-40ca-9338-71b3900170e7'"
         1021  +        echo ""
         1022  +        #----
         1023  +        cd $S_FP_ORIG
         1024  +        exit 1 # exit with error
         1025  +    fi
         1026  +    #--------------------
         1027  +} # func_mmmv_whirlpoolhash_t1
         1028  +
         1029  +
         1030  +#--------------------------------------------------------------------------
         1031  +
         1032  +S_FUNC_MMMV_FILESIZE_T1_RESULT="not_yet_set"
         1033  +S_FUNC_MMMV_FILESIZE_T1_MODE="" # optim. to skip repeating console tool selection
         1034  +func_mmmv_filesize_t1() { 
         1035  +    local S_FP_2_AN_EXISTING_FILE="$1" # first function argument
         1036  +    #--------
         1037  +    func_mmmv_exc_hash_function_input_verification_t1 "func_mmmv_filesize_t1" "$1"
         1038  +    #--------------------
         1039  +    # Mode selection:
         1040  +    if [ "$S_FUNC_MMMV_FILESIZE_T1_MODE" == "" ] ; then
         1041  +        SB_EXISTS_ON_PATH_T1_RESULT="f"  # if-block init
         1042  +        #----
         1043  +        if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "f" ] ; then
         1044  +            S_TMP_0="filesize" # usually available on Linux
         1045  +            func_sb_exists_on_path_t1 "$S_TMP_0" 
         1046  +            if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "t" ] ; then
         1047  +                 S_FUNC_MMMV_FILESIZE_T1_MODE="$S_TMP_0"
         1048  +            fi
         1049  +        fi
         1050  +        #----
         1051  +        if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "f" ] ; then
         1052  +            S_TMP_0="ruby"    # helps on BSD
         1053  +            func_sb_exists_on_path_t1 "$S_TMP_0" 
         1054  +            if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "t" ] ; then
         1055  +                 S_FUNC_MMMV_FILESIZE_T1_MODE="$S_TMP_0"
         1056  +            fi
         1057  +        fi
         1058  +        #--------
         1059  +        if [ "$S_FUNC_MMMV_FILESIZE_T1_MODE" == "" ] ; then
         1060  +            echo ""
         1061  +            echo "All of the applications that this function is " 
         1062  +            echo "capable of using for finding out file size (filesize, ruby)"
         1063  +            echo "are missing from the PATH."
         1064  +            echo "GUID=='3c1c971a-a8b6-4c5f-a238-71b3900170e7'"
         1065  +            echo ""
         1066  +            #----
         1067  +            cd $S_FP_ORIG
         1068  +            exit 1 # exit with error
         1069  +        fi
         1070  +        #--------
         1071  +        if [ "$?" != "0" ]; then
         1072  +            echo ""
         1073  +            echo "This script is flawed."
         1074  +            echo "GUID=='a54cc438-f608-4e38-b138-71b3900170e7'"
         1075  +            echo ""
         1076  +            #----
         1077  +            cd $S_FP_ORIG
         1078  +            exit 1 # exit with error
         1079  +        fi
         1080  +        #--------
         1081  +    fi
         1082  +    #--------------------
         1083  +    S_FUNC_MMMV_FILESIZE_T1_RESULT=""
         1084  +    #--------------------
         1085  +    if [ "$S_FUNC_MMMV_FILESIZE_T1_MODE" == "filesize" ]; then
         1086  +        S_TMP_0="`filesize $S_FP_2_AN_EXISTING_FILE 2>/dev/null`"
         1087  +        if [ "$?" != "0" ]; then
         1088  +            echo ""
         1089  +            echo "The console application \"filesize\" "
         1090  +            echo "exited with an error."
         1091  +            echo ""
         1092  +            echo "----console--outut--citation--start-----"
         1093  +            echo "`filesize $S_FP_2_AN_EXISTING_FILE`" # stdout and stderr
         1094  +            echo "----console--outut--citation--end-------"
         1095  +            echo ""
         1096  +            echo "GUID=='556a2e84-9d18-4e09-a338-71b3900170e7'"
         1097  +            echo ""
         1098  +            #----
         1099  +            cd $S_FP_ORIG
         1100  +            exit 1 # exit with error
         1101  +        fi
         1102  +        S_FUNC_MMMV_FILESIZE_T1_RESULT="`echo \"$S_TMP_0\" | gawk '{printf $1}'`"
         1103  +    fi
         1104  +    #--------------------
         1105  +    if [ "$S_FUNC_MMMV_FILESIZE_T1_MODE" == "ruby" ]; then
         1106  +        S_TMP_0="`ruby -e \"printf(File.size('$S_FP_2_AN_EXISTING_FILE').to_s)\" 2>/dev/null`"
         1107  +        if [ "$?" != "0" ]; then
         1108  +            echo ""
         1109  +            echo "The console application \"ruby\" "
         1110  +            echo "exited with an error."
         1111  +            echo ""
         1112  +            echo "----console--outut--citation--start-----"
         1113  +            echo "`ruby -e \"printf(File.size('$S_FP_2_AN_EXISTING_FILE').to_s)\"`"
         1114  +            echo "----console--outut--citation--end-------"
         1115  +            echo ""
         1116  +            echo "GUID=='855f9c25-6bb5-4f85-9428-71b3900170e7'"
         1117  +            echo ""
         1118  +            #----
         1119  +            cd $S_FP_ORIG
         1120  +            exit 1 # exit with error
         1121  +        fi
         1122  +        S_FUNC_MMMV_FILESIZE_T1_RESULT="$S_TMP_0"
         1123  +    fi
         1124  +    #--------------------
         1125  +    S_TMP_0="`printf \"$S_FUNC_MMMV_FILESIZE_T1_RESULT\" | gawk '{gsub(/\s/,"");printf "%s", $1 }'`"
         1126  +    local SB_THROW="f"
         1127  +    if [ "$S_TMP_0" != "$S_FUNC_MMMV_FILESIZE_T1_RESULT" ]; then
         1128  +        SB_THROW="t"
         1129  +    else
         1130  +        if [ "$S_FUNC_MMMV_FILESIZE_T1_RESULT" == "" ]; then
         1131  +            SB_THROW="t"
         1132  +        fi
         1133  +    fi
         1134  +    #----
         1135  +    if [ "$SB_THROW" == "t" ]; then
         1136  +        echo ""
         1137  +        echo "The result of the "
         1138  +        echo ""
         1139  +        echo "    func_mmmv_filesize_t1"
         1140  +        echo ""
         1141  +        echo "for "
         1142  +        echo ""
         1143  +        echo "($S_FUNC_MMMV_FILESIZE_T1_RESULT)"
         1144  +        echo ""
         1145  +        echo "either contain spaces, tabs or is an empty string," 
         1146  +        echo "which is wrong, because even a file with the size of 0 "
         1147  +        echo "should have a file size of \"0\", which is not an empty string."
         1148  +        echo "GUID=='1b8bc205-8c7e-40a4-a528-71b3900170e7'"
         1149  +        echo ""
         1150  +        #----
         1151  +        cd $S_FP_ORIG
         1152  +        exit 1 # exit with error
         1153  +    fi
         1154  +    #--------------------
         1155  +} # func_mmmv_filesize_t1
         1156  +
         1157  +
         1158  +#--------------------------------------------------------------------------
         1159  +
         1160  +func_mmmv_silktorrent_packager_t1_bash_print_help_msg_t1() { 
         1161  +    echo ""
         1162  +    echo "Command line format: "
         1163  +    echo ""
         1164  +    echo "<the name of this script>  ARGLIST "
         1165  +    echo ""
         1166  +    echo "  ARGLIST :== help | WRAP | UNWRAP | RUN_SELFTEST | VERIFY |"
         1167  +    echo "              VERIFY_PACKET_NAME_FORMAT_V1 | version "
         1168  +    echo ""
         1169  +    echo "                   WRAP :== wrap         <file path> "
         1170  +    echo "                 UNWRAP :== unwrap       <file path> "
         1171  +    echo "           RUN_SELFTEST :== test_hash_t1 <file path> "
         1172  +    echo "                 VERIFY :== verify       <file path> "
         1173  +    echo ""
         1174  +    echo "  VERIFY_PACKET_NAME_FORMAT_V1 :== verify_packet_name_format_v1 X<packet name "
         1175  +    echo "                                                                 candidate string>X"
         1176  +    echo ""
         1177  +    echo ""
         1178  +    echo "If this API is used correctly and there are no other "
         1179  +    echo "reasons for the failure of this script, then "
         1180  +    echo "all of the verification commands exit with error code 0 "
         1181  +    echo "regardless of whether the verification fails or passes."
         1182  +    echo "All verification commands return a string that "
         1183  +    echo "belongs to the set {\"verification_passed\", "
         1184  +    echo "                    \"verification_failed\"}."
         1185  +    echo ""
         1186  +    echo ""
         1187  +    echo ""
         1188  +} # func_mmmv_silktorrent_packager_t1_bash_print_help_msg_t1
         1189  +
         1190  +#--------------------------------------------------------------------------
         1191  +
         1192  +func_mmmv_silktorrent_packager_t1_bash_exc_assert_wrappable_file_exists_t1() { 
         1193  +    local S_FP_0="$1" # Path to the file. 
         1194  +    #--------
         1195  +    if [ "$S_FP_0" == "" ]; then
         1196  +        echo ""
         1197  +        echo "The 2. console argument is expected to be "
         1198  +        echo "a path to a file, but currently "
         1199  +        echo "the 2. console argument is missing."
         1200  +        echo "GUID=='1eee6d46-d91c-4bfb-a228-71b3900170e7'"
         1201  +        echo ""
         1202  +        #----
         1203  +        cd $S_FP_ORIG
         1204  +        exit 1 # exit with error
         1205  +    fi
         1206  +    #--------
         1207  +    if [ ! -e "$S_FP_0" ]; then
         1208  +        if [ -h "$S_FP_0" ]; then
         1209  +            echo ""
         1210  +            echo "The file path "
         1211  +            echo ""
         1212  +            echo "    $S_FP_0"
         1213  +            echo ""
         1214  +            echo "is a path of a broken symlink, but symlinks "
         1215  +            echo "are not supported at all."
         1216  +            echo "The reason, why symlinks to files are not supported is that "
         1217  +            echo "the file size of symlinks can differ from "
         1218  +            echo "the file size of the target of the symlink."
         1219  +            echo "GUID=='4c68cb15-2c2b-49fd-9218-71b3900170e7'"
         1220  +            echo ""
         1221  +        else
         1222  +            echo ""
         1223  +            echo "The file with the path of "
         1224  +            echo ""
         1225  +            echo "    $S_FP_0"
         1226  +            echo ""
         1227  +            echo "does not exist."
         1228  +            echo "GUID=='428ff042-efd8-4566-a318-71b3900170e7'"
         1229  +            echo ""
         1230  +        fi
         1231  +        #----
         1232  +        cd $S_FP_ORIG
         1233  +        exit 1 # exit with error
         1234  +    fi
         1235  +    #--------
         1236  +    if [ -d "$S_FP_0" ]; then
         1237  +        if [ -h "$S_FP_0" ]; then
         1238  +            echo ""
         1239  +            echo "The path "
         1240  +            echo ""
         1241  +            echo "    $S_FP_0"
         1242  +            echo ""
         1243  +            echo "references a symlink that references folder, but "
         1244  +            echo "a file is expected."
         1245  +            echo "GUID=='b2d2a237-9fcb-46fe-8318-71b3900170e7'"
         1246  +            echo ""
         1247  +        else
         1248  +            echo ""
         1249  +            echo "The path "
         1250  +            echo ""
         1251  +            echo "    $S_FP_0"
         1252  +            echo ""
         1253  +            echo "references a folder, but it is expected to "
         1254  +            echo "to reference a file."
         1255  +            echo "GUID=='1dd79224-6a1e-44fd-b118-71b3900170e7'"
         1256  +            echo ""
         1257  +        fi
         1258  +        #----
         1259  +        cd $S_FP_ORIG
         1260  +        exit 1 # exit with error
         1261  +    fi
         1262  +    #--------
         1263  +    if [ -h "$S_FP_0" ]; then
         1264  +        echo ""
         1265  +        echo "The path "
         1266  +        echo ""
         1267  +        echo "    $S_FP_0"
         1268  +        echo ""
         1269  +        echo "references a symlink, a file is expected."
         1270  +        echo "The reason, why symlinks to files are not supported is that "
         1271  +        echo "the file size of symlinks can differ from "
         1272  +        echo "the file size of the target of the symlink."
         1273  +        echo "GUID=='7afe9e27-cee1-4ad1-b218-71b3900170e7'"
         1274  +        echo ""
         1275  +        #----
         1276  +        cd $S_FP_ORIG
         1277  +        exit 1 # exit with error
         1278  +    fi
         1279  +} # func_mmmv_silktorrent_packager_t1_bash_exc_assert_wrappable_file_exists_t1
         1280  +
         1281  +
         1282  +#--------------------------------------------------------------------------
         1283  +
         1284  +func_mmmv_silktorrent_packager_t1_bash_exc_assert_packet_name_candidate_exists_t1() { 
         1285  +    local S_FP_0="$1" # Path to the file. 
         1286  +    #--------
         1287  +    if [ "$S_FP_0" == "" ]; then
         1288  +        echo ""
         1289  +        echo "The 2. console argument is expected to be "
         1290  +        echo "a Silktorrent packet name candidate, but currently "
         1291  +        echo "the 2. console argument is missing."
         1292  +        echo "GUID=='227d93c4-61a6-42b7-b118-71b3900170e7'"
         1293  +        echo ""
         1294  +        #----
         1295  +        cd $S_FP_ORIG
         1296  +        exit 1 # exit with error
         1297  +    fi
         1298  +} # func_mmmv_silktorrent_packager_t1_bash_exc_assert_packet_name_candidate_exists_t1
         1299  +
         1300  +
         1301  +#--------------------------------------------------------------------------
         1302  +
         1303  +S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_REVERSE_STRING_REGISTER="for input and output"
         1304  +S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_REVERSE_STRING_MODE="" # optim.  hack
         1305  +func_mmmv_silktorrent_packager_t1_bash_reverse_string() { 
         1306  +    local S_IN="$S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_REVERSE_STRING_REGISTER"
         1307  +    #--------------------
         1308  +    local S_TMP_0="not set"
         1309  +    # Mode selection:
         1310  +    if [ "$S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_REVERSE_STRING_MODE" == "" ] ; then
         1311  +        SB_EXISTS_ON_PATH_T1_RESULT="f"  # if-block init
         1312  +        #----
         1313  +        if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "f" ] ; then
         1314  +            S_TMP_0="gawk" # usually available on Linux
         1315  +            func_sb_exists_on_path_t1 "$S_TMP_0" 
         1316  +            if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "t" ] ; then
         1317  +                 S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_REVERSE_STRING_MODE="$S_TMP_0"
         1318  +            fi
         1319  +        fi
         1320  +        #----
         1321  +        if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "f" ] ; then
         1322  +            S_TMP_0="ruby"    # helps on BSD
         1323  +            func_sb_exists_on_path_t1 "$S_TMP_0" 
         1324  +            if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "t" ] ; then
         1325  +                 S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_REVERSE_STRING_MODE="$S_TMP_0"
         1326  +            fi
         1327  +        fi
         1328  +        #--------
         1329  +        if [ "$S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_REVERSE_STRING_MODE" == "" ] ; then
         1330  +            echo ""
         1331  +            echo "All of the applications that this function is " 
         1332  +            echo "capable of using for finding out file size (gawk, ruby)"
         1333  +            echo "are missing from the PATH."
         1334  +            echo "GUID=='b55b1414-6247-47f6-9118-71b3900170e7'"
         1335  +            echo ""
         1336  +            #----
         1337  +            cd $S_FP_ORIG
         1338  +            exit 1 # exit with error
         1339  +        fi
         1340  +        #--------
         1341  +        if [ "$?" != "0" ]; then
         1342  +            echo ""
         1343  +            echo "This script is flawed."
         1344  +            echo "GUID=='109b82e1-8efb-49a4-b408-71b3900170e7'"
         1345  +            echo ""
         1346  +            #----
         1347  +            cd $S_FP_ORIG
         1348  +            exit 1 # exit with error
         1349  +        fi
         1350  +        #--------
         1351  +    fi
         1352  +    #--------------------
         1353  +    #--------------------
         1354  +    S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_REVERSE_STRING_REGISTER=""
         1355  +    #--------
         1356  +    if [ "$S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_REVERSE_STRING_MODE" == "gawk" ]; then
         1357  +        # The awk code example originates from 
         1358  +        # http://www.linuxandlife.com/2013/06/how-to-reverse-string.html
         1359  +        # archival copy: https://archive.is/Cx0xF
         1360  +        #----
         1361  +        S_TMP_0="`printf "$S_IN" | \
         1362  +            awk '{ for(i=length;i!=0;i--)x=x substr($0,i,1);}END{printf  x}'`"
         1363  +        if [ "$?" != "0" ]; then
         1364  +            echo ""
         1365  +            echo "The console application \"gawk\" "
         1366  +            echo "exited with an error."
         1367  +            echo ""
         1368  +            echo "----console--outut--citation--start-----"
         1369  +            echo "`printf "$S_IN" | awk '{ for(i=length;i!=0;i--)x=x substr($0,i,1);}END{printf  x}'`"
         1370  +            echo "----console--outut--citation--end-------"
         1371  +            echo ""
         1372  +            echo "GUID=='95dcc43d-90b7-4bfd-8408-71b3900170e7'"
         1373  +            echo ""
         1374  +            #----
         1375  +            cd $S_FP_ORIG
         1376  +            exit 1 # exit with error
         1377  +        fi
         1378  +        S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_REVERSE_STRING_REGISTER="$S_TMP_0"
         1379  +    fi
         1380  +    #--------
         1381  +    if [ "$S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_REVERSE_STRING_MODE" == "ruby" ]; then
         1382  +        #----
         1383  +        S_TMP_0="`ruby -e \"puts(ARGV[0].to_s.reverse)\" "$S_IN" 2>/dev/null`"
         1384  +        if [ "$?" != "0" ]; then
         1385  +            echo ""
         1386  +            echo "The console application \"ruby\" "
         1387  +            echo "exited with an error."
         1388  +            echo ""
         1389  +            echo "----console--outut--citation--start-----"
         1390  +            echo "`ruby -e \"puts('$S_IN'.reverse)\"`" # with the stderr
         1391  +            echo "----console--outut--citation--end-------"
         1392  +            echo ""
         1393  +            echo "GUID=='59c56443-ab6c-4899-9408-71b3900170e7'"
         1394  +            echo ""
         1395  +            #----
         1396  +            cd $S_FP_ORIG
         1397  +            exit 1 # exit with error
         1398  +        fi
         1399  +        S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_REVERSE_STRING_REGISTER="$S_TMP_0"
         1400  +    fi
         1401  +    #--------------------
         1402  +} # func_mmmv_silktorrent_packager_t1_bash_reverse_string
         1403  +
         1404  +
         1405  +#--------------------------------------------------------------------------
         1406  +
         1407  +# As of 2016 the maximum file name length on Linux is 255 characters.
         1408  +# At
         1409  +#
         1410  +#    http://unix.stackexchange.com/questions/32795/what-is-the-maximum-allowed-filename-and-folder-size-with-ecryptfs
         1411  +#
         1412  +# the eCryptfs related recommendation is to keep the lengths
         1413  +# of file names to less than 140 characters. 
         1414  +#
         1415  +# A citation from 
         1416  +# http://windows.microsoft.com/en-us/windows/file-names-extensions-faq#1TC=windows-7
         1417  +# archieval copy: https://archive.is/UKBmd
         1418  +#     "Windows limits a single path to 260 characters."
         1419  +#
         1420  +# A citation from CygWin mailing list:
         1421  +# https://cygwin.com/ml/cygwin/2004-10/msg01323.html
         1422  +# archival copy: https://archive.is/GRvFK
         1423  +#     "The Unicode versions of several functions permit a 
         1424  +#     maximum path length of 32,767 characters, 
         1425  +#     composed of components up to 255 characters in length. 
         1426  +#     To specify such a path, use the "\\?\" prefix. For example, 
         1427  +#     "\\?\D:\<path>". To specify such a UNC path, use the "\\?\UNC\" 
         1428  +#     prefix. For example, "\\?\UNC\<server>\<share>". 
         1429  +#     Note that these prefixes are not used as part of the path 
         1430  +#     itself. They indicate that the path should be passed to the 
         1431  +#     system with minimal modification. An implication of this is 
         1432  +#     that you cannot use forward slashes to represent path separators 
         1433  +#     or a period to represent the current directory."
         1434  +# Related pages:
         1435  +# https://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx
         1436  +# archival copy: https://archive.is/p891y
         1437  +#
         1438  +# To allow database indexes that store the 
         1439  +# file names of the blogs 
         1440  +# to work as efficiently as possible, the first
         1441  +# characters of the file name should be as 
         1442  +# uniformly random set of characters as possible.
         1443  +# If file name starts with a secure hash, then 
         1444  +# that requirement is met. 
         1445  +#
         1446  +# The parser that dismantles the file name to relevant components 
         1447  +# should be implementable in different programming languages
         1448  +# without investing considerable amount of development time.
         1449  +# The syntax of the file name should also allow the
         1450  +# file name to be parsed computationally cheaply.
         1451  +#
         1452  +# As of 2016_05 the file extension  .stblob seems to be unused.
         1453  +# Therefore the "silktorrent blob", .stblob, can be used for the 
         1454  +# extension of the blob files.
         1455  +#
         1456  +# Compression of the blobs IS NOT ALLOWED, because the 
         1457  +# blobs must be extractable without becoming a victim 
         1458  +# of an attack, where 100GiB of zeros is packed to a
         1459  +# small file. The container format is the tar format,
         1460  +# without any compression.
         1461  +S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_BLOB2FILENAME_T1_RESULT="not set"
         1462  +func_mmmv_silktorrent_packager_t1_bash_blob2filename_t1() { 
         1463  +    local S_FP_0="$1" # Path to the file. 
         1464  +    #----
         1465  +    func_mmmv_silktorrent_packager_t1_bash_exc_assert_wrappable_file_exists_t1 "$S_FP_0"
         1466  +    #--------
         1467  +    # The Tiger     hash has  48 characters.
         1468  +    # The Whirlpool hash has 128 characters.
         1469  +    # The SHA-256   hash has  64 characters.
         1470  +    #
         1471  +    # A file size of 1TiB is ~10^12 ~ 13 characters
         1472  +    # A file size of 1PiB is ~10^15 ~ 14 characters
         1473  +    # A file size of 1EiB is ~10^18 ~ 19 characters
         1474  +    # A file size of 1ZiB is ~10^21 ~ 22 characters
         1475  +    # A file size of 1YiB is ~10^24 ~ 25 characters
         1476  +    # 
         1477  +    # The max. file name length on Linux and 
         1478  +    # Windows (Unicode API) is 255 characters.
         1479  +    #----
         1480  +    # The character budget:
         1481  +    #        6 characters --- file name format type ID 
         1482  +    #                         rgx_in_ruby=/v[\d]{4}[_]/
         1483  +    # echo "v0034_s2342_" | gawk '{ gsub(/_/, "_\n"); print }' | \
         1484  +    #                       gawk '/^v[0-9]{4}_/ {printf "%s",$1 }' | \
         1485  +    #                       gawk '{gsub(/[v_]/,"");printf "%s", $1 }'
         1486  +    #
         1487  +    #   max 32 characters --- file size    
         1488  +    #                         rgx_in_ruby=/s[\d]+[_]/
         1489  +    #                         echo "v0034_" | gawk '/^v[0-9]{4}_/ {printf "%s",$1 }'
         1490  +    # echo "v0034_s2342_" | gawk '{ gsub(/_/, "_\n"); print }' | \
         1491  +    #                       gawk '/^s[0-9]+_/ {printf "%s",$1 }' | \
         1492  +    #                       gawk '{gsub(/[s_]/,"");printf "%s", $1 }'
         1493  +    #
         1494  +    #
         1495  +    #       66 characters --- SHA-256  
         1496  +    #                         rgx_in_ruby=/h[\dabcdef]{64}[_]/
         1497  +    # echo "h`sha256sum /dev/null | gawk '/[0-9abcdef]/ {printf "%s",$1}'`_" | \
         1498  +    #                               gawk '/^h[0-9abcdef]+_/ {printf "%s",$1 }' | \
         1499  +    #                               gawk '{gsub(/[h_]/,"");printf "%s", $1 }'
         1500  +    #
         1501  +    #
         1502  +    #       50 characters --- Tiger
         1503  +    #                         rgx_in_ruby=/i[\dabcdef]{48}$/   # lacks the ending "_" 
         1504  +    #                                                          # for db index optimization
         1505  +    #                         The gawk code is as with the sha256, 
         1506  +    #                         except that sha256sum-> tigerdeep, "^h"->"^i",
         1507  +    #                         "[h_]"->"[i_]"
         1508  +    #
         1509  +    #--------
         1510  +    # As the current version of this script depends on Ruby anyway,
         1511  +    # the gawk regex based branches that are really
         1512  +    # complex and require multiple gawk calls can be left unimplemented.
         1513  +    # That way this script becomes more succinct.
         1514  +    #--------------------
         1515  +    func_mmmv_tigerhash_t1 "$S_FP_0"
         1516  +    #echo "       Tiger: $S_FUNC_MMMV_TIGERHASH_T1_RESULT"
         1517  +    #func_mmmv_whirlpoolhash_t1 "$S_FP_0"
         1518  +    #echo "   Whirlpool: $S_FUNC_MMMV_WHIRLPOOLHASH_T1_RESULT"
         1519  +    func_mmmv_sha256_t1 "$S_FP_0"
         1520  +    #echo "      SHA256: $S_FUNC_MMMV_SHA256_T1_RESULT"
         1521  +    func_mmmv_filesize_t1 "$S_FP_0"
         1522  +    #echo "   file size: $S_FUNC_MMMV_FILESIZE_T1_RESULT"
         1523  +    #--------
         1524  +    local S_NAME_REVERSED="bolbts." # ".stblob".reverse
         1525  +    local S_0="v0001_s$S_FUNC_MMMV_FILESIZE_T1_RESULT"
         1526  +    S_NAME_REVERSED="$S_NAME_REVERSED$S_0"
         1527  +    S_0="_h$S_FUNC_MMMV_SHA256_T1_RESULT"
         1528  +    S_NAME_REVERSED="$S_NAME_REVERSED$S_0"
         1529  +    S_0="_i$S_FUNC_MMMV_TIGERHASH_T1_RESULT"
         1530  +    S_NAME_REVERSED="$S_NAME_REVERSED$S_0"
         1531  +    #----
         1532  +    S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_REVERSE_STRING_REGISTER="$S_NAME_REVERSED"
         1533  +    func_mmmv_silktorrent_packager_t1_bash_reverse_string
         1534  +    S_0="$S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_REVERSE_STRING_REGISTER"
         1535  +    S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_BLOB2FILENAME_T1_RESULT="$S_0"
         1536  +} # func_mmmv_silktorrent_packager_t1_bash_blob2filename_t1
         1537  +
         1538  +
         1539  +#--------------------------------------------------------------------------
         1540  +
         1541  +func_mmmv_delete_tmp_folder_t1(){
         1542  +    local S_FP_0="$1" # folder path
         1543  +    #--------
         1544  +    if [ ! -e "$S_FP_0" ]; then
         1545  +        echo ""
         1546  +        echo "This script is flawed. The folder "
         1547  +        echo "    $S_FP_0"
         1548  +        echo "is expected to exist during the "
         1549  +        echo "call to this function."
         1550  +        echo "GUID=='aa3a281b-e603-44e0-9208-71b3900170e7'"
         1551  +        echo ""
         1552  +        #----
         1553  +        cd $S_FP_ORIG
         1554  +        exit 1 # exit with error
         1555  +    fi
         1556  +    #--------
         1557  +    # To avoid a situation, where due to some 
         1558  +    # flaw the home folder or something else important 
         1559  +    # gets accidentally recursively deleted, 
         1560  +    # the following test transforms the path from 
         1561  +    # /tmp/../home/blabla
         1562  +    # to a full path without the dots and then studies, whether
         1563  +    # the full path points to somehwere in the /tmp
         1564  +    local S_FP_1="`cd $S_FP_0; pwd`"
         1565  +    if [ ! -e "$S_FP_1" ]; then
         1566  +        echo ""
         1567  +        echo "This script is flawed. The folder "
         1568  +        echo "    $S_FP_1"
         1569  +        echo "is missing."
         1570  +        echo "GUID=='f1c9d550-72d2-407d-9208-71b3900170e7'"
         1571  +        echo ""
         1572  +        #----
         1573  +        cd $S_FP_ORIG
         1574  +        exit 1 # exit with error
         1575  +    fi
         1576  +    local S_TMP_0="`echo \"$S_FP_1\" | grep -E ^/home `"
         1577  +    if [ "$S_TMP_0" != "" ]; then
         1578  +        echo ""
         1579  +        echo "This script is flawed."
         1580  +        echo "The temporary sandbox folder must reside in /tmp."
         1581  +        echo ""
         1582  +        echo "S_FP_0==$S_FP_0"
         1583  +        echo ""
         1584  +        echo "S_FP_1==$S_FP_1"
         1585  +        echo ""
         1586  +        echo "S_TMP_0==$S_TMP_0"
         1587  +        echo ""
         1588  +        echo "GUID=='ef812232-9359-4769-9208-71b3900170e7'"
         1589  +        echo ""
         1590  +        #----
         1591  +        cd $S_FP_ORIG
         1592  +        exit 1 # exit with error
         1593  +    fi
         1594  +    # Just to be sure, the same thing is checked by a slightly 
         1595  +    # different regex and using the "==" in stead of the "!=".
         1596  +    S_TMP_0="`echo \"$S_FP_1\" | grep -E ^/tmp/`" 
         1597  +    if [ "$S_TMP_0" == "" ]; then
         1598  +        echo ""
         1599  +        echo "This script is flawed."
         1600  +        echo "The temporary sandbox folder must reside in /tmp."
         1601  +        echo ""
         1602  +        echo "S_FP_0==$S_FP_0"
         1603  +        echo ""
         1604  +        echo "S_FP_1==$S_FP_1"
         1605  +        echo ""
         1606  +        echo "S_TMP_0==$S_TMP_0"
         1607  +        echo ""
         1608  +        echo "GUID=='4604f696-2a07-4943-b508-71b3900170e7'"
         1609  +        echo ""
         1610  +        #----
         1611  +        cd $S_FP_ORIG
         1612  +        exit 1 # exit with error
         1613  +    fi
         1614  +    #--------
         1615  +    rm -fr $S_FP_1
         1616  +    if [ -e "$S_FP_1" ]; then
         1617  +        echo ""
         1618  +        echo "Something went wrong. The recursive deletion of the temporary folder, "
         1619  +        echo "    $S_FP_1"
         1620  +        echo "failed."
         1621  +        echo "GUID=='5e2970b5-eda5-4371-a208-71b3900170e7'"
         1622  +        echo ""
         1623  +        #----
         1624  +        cd $S_FP_ORIG
         1625  +        exit 1 # exit with error
         1626  +    fi
         1627  +} # func_mmmv_delete_tmp_folder_t1
         1628  +
         1629  +
         1630  +#--------------------------------------------------------------------------
         1631  +
         1632  +# Throws, if there exists a file with the same path.
         1633  +func_mmmv_create_folder_if_it_does_not_already_exist_t1(){
         1634  +    local S_FP_0="$1" # folder path
         1635  +    #--------
         1636  +    if [ "$S_FP_0" == "" ]; then
         1637  +        # Using gawk and alike to cover also cases, where
         1638  +        # $S_FP_0=="  "
         1639  +        # is intentionally left out to avoid the overhead, but
         1640  +        # due to some luck the mkdir exits with an error code greater than 0,
         1641  +        # if it misses a path argument. 
         1642  +        echo ""
         1643  +        echo "S_FP_0==\"\""
         1644  +        echo "GUID=='24c43d27-d0bf-4114-b5f7-71b3900170e7'"
         1645  +        echo ""
         1646  +        #----
         1647  +        cd $S_FP_ORIG
         1648  +        exit 1 # exit with error
         1649  +    fi
         1650  +    #--------------------
         1651  +    if [ -e "$S_FP_0" ]; then
         1652  +        if [ ! -d "$S_FP_0" ]; then
         1653  +            echo ""
         1654  +            echo "The path that is suppose to reference either "
         1655  +            echo "an existing folder or a non-existent folder, "
         1656  +            echo "references a file."
         1657  +            echo "GUID=='658b0135-9bb2-4a53-82f7-71b3900170e7'"
         1658  +            echo ""
         1659  +            #----
         1660  +            cd $S_FP_ORIG
         1661  +            exit 1 # exit with error
         1662  +        fi
         1663  +    fi
         1664  +    #--------
         1665  +    mkdir -p $S_FP_0
         1666  +    if [ "$?" != "0" ]; then 
         1667  +        echo ""
         1668  +        echo "mkdir for path "
         1669  +        echo "    $S_FP_0"
         1670  +        echo "failed."
         1671  +        echo "GUID=='75439f3e-59f7-4751-b2f7-71b3900170e7'"
         1672  +        echo ""
         1673  +        #----
         1674  +        cd $S_FP_ORIG
         1675  +        exit 1 # exit with error
         1676  +    fi
         1677  +    #----
         1678  +    if [ ! -e "$S_FP_0" ]; then
         1679  +        echo ""
         1680  +        echo "mkdir execution succeeded, but for some other reason the folder "
         1681  +        echo "    $S_FP_0"
         1682  +        echo "does not exist."
         1683  +        echo "GUID=='92a90266-13b1-4468-b5f7-71b3900170e7'"
         1684  +        echo ""
         1685  +        #----
         1686  +        cd $S_FP_ORIG
         1687  +        exit 1 # exit with error
         1688  +    fi
         1689  +} # func_mmmv_create_folder_if_it_does_not_already_exist_t1
         1690  +
         1691  +
         1692  +#--------------------------------------------------------------------------
         1693  +
         1694  +S_FUNC_FUNC_MMMV_CREATE_TMP_FOLDER_T1_RESULT="" # == "" on failure
         1695  +                                                # otherwise full file path
         1696  +func_mmmv_create_tmp_folder_t1(){
         1697  +    # Does not take any arguments.
         1698  +    #--------
         1699  +    #func_mmmv_exc_hash_function_input_verification_t1 "func_mmmv_GUID_t1" "$1"
         1700  +    #--------------------
         1701  +    S_FUNC_FUNC_MMMV_CREATE_TMP_FOLDER_T1_RESULT="" # value for failure
         1702  +    func_mmmv_GUID_t1
         1703  +    if [ "$S_FUNC_MMMV_GUID_T1_RESULT" == "" ]; then
         1704  +        echo ""
         1705  +        echo "This script is flawed. GUID generation failed and "
         1706  +        echo "the GUID generation function did not throw despite "
         1707  +        echo "the fact that it should have detected its own failure."
         1708  +        echo "GUID=='4c3fc054-3af8-4cb4-94f7-71b3900170e7'"
         1709  +        echo ""
         1710  +        #----
         1711  +        cd $S_FP_ORIG
         1712  +        exit 1 # exit with error
         1713  +    fi
         1714  +    #----
         1715  +    local S_TMP_0="/tmp/tmp_silktorrent_$S_FUNC_MMMV_GUID_T1_RESULT"
         1716  +    # The following few if-clauses form a short unrolled loop. The unrolling 
         1717  +    # is for simplicity, because it is Bash, where loops are nasty.
         1718  +    if [ -e "$S_TMP_0" ]; then
         1719  +        func_mmmv_GUID_t1
         1720  +        S_TMP_0="/tmp/tmp_silktorrent_$S_FUNC_MMMV_GUID_T1_RESULT"
         1721  +    fi
         1722  +    if [ -e "$S_TMP_0" ]; then
         1723  +        func_mmmv_GUID_t1
         1724  +        S_TMP_0="/tmp/tmp_silktorrent_$S_FUNC_MMMV_GUID_T1_RESULT"
         1725  +    fi
         1726  +    if [ -e "$S_TMP_0" ]; then
         1727  +        func_mmmv_GUID_t1
         1728  +        S_TMP_0="/tmp/tmp_silktorrent_$S_FUNC_MMMV_GUID_T1_RESULT"
         1729  +    fi
         1730  +    if [ -e "$S_TMP_0" ]; then
         1731  +        func_mmmv_GUID_t1
         1732  +        S_TMP_0="/tmp/tmp_silktorrent_$S_FUNC_MMMV_GUID_T1_RESULT"
         1733  +    fi
         1734  +    #----
         1735  +    if [ -e "$S_TMP_0" ]; then
         1736  +        echo ""
         1737  +        echo "This script failed to generate a locally unique path."
         1738  +        echo "GUID=='864ea729-ebeb-488b-82f7-71b3900170e7'"
         1739  +        echo ""
         1740  +        #----
         1741  +        cd $S_FP_ORIG
         1742  +        exit 1 # exit with error
         1743  +    fi
         1744  +    func_mmmv_create_folder_if_it_does_not_already_exist_t1 "$S_TMP_0"
         1745  +    if [ ! -e "$S_TMP_0" ]; then
         1746  +        echo ""
         1747  +        echo "mkdir for path "
         1748  +        echo "    $S_TMP_0"
         1749  +        echo "failed."
         1750  +        echo "GUID=='54add286-d3ba-4fc9-81f7-71b3900170e7'"
         1751  +        echo ""
         1752  +        #----
         1753  +        cd $S_FP_ORIG
         1754  +        exit 1 # exit with error
         1755  +    fi
         1756  +    S_FUNC_FUNC_MMMV_CREATE_TMP_FOLDER_T1_RESULT="$S_TMP_0"
         1757  +} # func_mmmv_create_tmp_folder_t1 
         1758  +
         1759  +
         1760  +#--------------------------------------------------------------------------
         1761  +
         1762  +S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_GET_PACKET_FORMAT_VERSION_T1_RESULT="not set"
         1763  +func_mmmv_silktorrent_packager_t1_bash_get_packet_format_version_t1() { 
         1764  +    local S_FP_0="$1" # Path to the file. 
         1765  +    #----
         1766  +    # It's not necessary for the file to actually exist,
         1767  +    # because this function only analyzes the file path string.
         1768  +    # func_mmmv_silktorrent_packager_t1_bash_exc_assert_wrappable_file_exists_t1 "$S_FP_0"
         1769  +    if [ "$S_FP_0" == "" ]; then
         1770  +        echo ""
         1771  +        echo "The file path candidate must not be an empty string."
         1772  +        echo "GUID=='636ea139-ea1a-44ec-b1e7-71b3900170e7'"
         1773  +        echo ""
         1774  +        #----
         1775  +        cd $S_FP_ORIG
         1776  +        exit 1 # exit with error
         1777  +    fi 
         1778  +    #----
         1779  +    # The 
         1780  +    #
         1781  +    #     basename /tmp/foo/
         1782  +    #
         1783  +    # returns
         1784  +    #
         1785  +    #     foo
         1786  +    #
         1787  +    # That is to say, the "basename" ignores the rightmost slash.
         1788  +    #----
         1789  +    local S_TMP_0="`ruby -e \"\
         1790  +        s='noslash';\
         1791  +        if(('$S_FP_0'.reverse)[0..0]=='/') then \
         1792  +            s='slash_present';\
         1793  +        end;\
         1794  +        puts(s);\
         1795  +        \"`"
         1796  +    if [ "$S_TMP_0" != "noslash" ]; then
         1797  +        echo ""
         1798  +        echo "The path candidate must not end with a slash."
         1799  +        echo ""
         1800  +        echo "    S_FP_0==$S_FP_0"
         1801  +        echo ""
         1802  +        echo "    S_TMP_0==$S_TMP_0"
         1803  +        echo ""
         1804  +        echo "GUID=='27e5ea85-56d2-40d2-93e7-71b3900170e7'"
         1805  +        echo ""
         1806  +        #----
         1807  +        cd $S_FP_ORIG
         1808  +        exit 1 # exit with error
         1809  +    fi
         1810  +    basename $S_FP_0 1>/dev/null # to set a value to the $? in this scope 
         1811  +    if [ "$?" != "0" ]; then
         1812  +        echo ""
         1813  +        echo "The command "
         1814  +        echo ""
         1815  +        echo "    basename $S_FP_0 "
         1816  +        echo ""
         1817  +        echo "exited with an error."
         1818  +        echo "GUID=='72ca4146-50f7-41ee-92e7-71b3900170e7'"
         1819  +        echo ""
         1820  +        #----
         1821  +        cd $S_FP_ORIG
         1822  +        exit 1 # exit with error
         1823  +    fi 
         1824  +    S_TMP_0="`basename $S_FP_0`"
         1825  +    if [ "$S_TMP_0" == "" ]; then
         1826  +        echo ""
         1827  +        echo "The file path candidate must be a string that "
         1828  +        echo "is not an empty string after "
         1829  +        echo "all of the spaces and tabs have been removed from it."
         1830  +        echo "GUID=='36dee451-756e-49de-83e7-71b3900170e7'"
         1831  +        echo ""
         1832  +        #----
         1833  +        cd $S_FP_ORIG
         1834  +        exit 1 # exit with error
         1835  +    fi 
         1836  +    #--------
         1837  +    S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_GET_PACKET_FORMAT_VERSION_T1_RESULT=""
         1838  +    local S_OUT="unsupported_by_this_script_version"
         1839  +    #--------
         1840  +    # In Ruby
         1841  +    #     "foo.stblob"[0..(-8)]=="foo"
         1842  +    #     "foo.stblob"[(-99)..(-1)]==nil
         1843  +    # 
         1844  +    local S_TMP_1="`ruby -e \"\
         1845  +        x='$S_TMP_0'[0..(-8)];\
         1846  +        if(x!=nil) then\
         1847  +            md=x.reverse.match(/v[\\d]+/);\
         1848  +            if(md!=nil) then\
         1849  +                s_0=(md[0].to_s)[1..(-1)];\
         1850  +                print(s_0.sub(/^[0]+/,''));\
         1851  +            end;\
         1852  +        end;\
         1853  +        \"`"
         1854  +    # echo "$S_TMP_0"
         1855  +    # echo "$S_TMP_1"
         1856  +    #----
         1857  +    if [ "$S_TMP_1" != "" ]; then
         1858  +        S_OUT="silktorrent_packet_format_version_$S_TMP_1"
         1859  +    fi 
         1860  +    S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_GET_PACKET_FORMAT_VERSION_T1_RESULT="$S_OUT"
         1861  +} # func_mmmv_silktorrent_packager_t1_bash_get_packet_format_version_t1
         1862  +
         1863  +
         1864  +#--------------------------------------------------------------------------
         1865  +
         1866  +S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_VERIFY_FILE_NAME_T1_RESULT="not set"
         1867  +func_mmmv_silktorrent_packager_t1_bash_verify_file_name_t1() { 
         1868  +    local S_FP_0="$1" # Path to the file. 
         1869  +    #----
         1870  +    func_mmmv_silktorrent_packager_t1_bash_exc_assert_wrappable_file_exists_t1 "$S_FP_0"
         1871  +    #--------
         1872  +    func_mmmv_silktorrent_packager_t1_bash_get_packet_format_version_t1 "$S_FP_0"
         1873  +    local S_PACKET_FORMAT="$S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_GET_PACKET_FORMAT_VERSION_T1_RESULT"
         1874  +    if [ "$S_PACKET_FORMAT" == "unsupported_by_this_script_version" ]; then
         1875  +        echo ""
         1876  +        echo "There exists a possibility that the "
         1877  +        echo "Silktorrent packet candidate is actually OK, but "
         1878  +        echo "this is an older version of the Silktorrent implementaiton and "
         1879  +        echo "the older version does not support "
         1880  +        echo "newer Silktorrent packet formats. "
         1881  +        echo "The file path of the Silktorrent packet candidate:"
         1882  +        echo ""
         1883  +        echo "    $S_FP_0"
         1884  +        echo ""
         1885  +        echo "GUID=='1158d282-b615-4c4c-93e7-71b3900170e7'"
         1886  +        echo ""
         1887  +        #----
         1888  +        cd $S_FP_ORIG
         1889  +        exit 1 # exit with error
         1890  +    fi
         1891  +    #--------
         1892  +    local S_TMP_1=""
         1893  +    if [ "$S_PACKET_FORMAT" == "silktorrent_packet_format_version_1" ]; then
         1894  +        func_mmmv_silktorrent_packager_t1_bash_blob2filename_t1 "$S_FP_0"
         1895  +        #echo "$S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_BLOB2FILENAME_T1_RESULT"
         1896  +        S_TMP_1="$S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_BLOB2FILENAME_T1_RESULT"
         1897  +    fi
         1898  +    #----
         1899  +    if [ "$S_TMP_1" == "" ]; then
         1900  +        echo ""
         1901  +        echo "This script is flawed."
         1902  +        echo "It should have thrown before the control flow reaches this line."
         1903  +        echo "GUID=='3aa4bc43-bbe8-440f-a2e7-71b3900170e7'"
         1904  +        echo ""
         1905  +        #----
         1906  +        cd $S_FP_ORIG
         1907  +        exit 1 # exit with error
         1908  +    fi
         1909  +    #--------
         1910  +    local S_TMP_0="`basename $S_FP_0`" # The S_TMP_0 must be evaluated 
         1911  +                                       # after the various functions to 
         1912  +                                       # counter a situation, where 
         1913  +                                       # the S_TMP_0 is overwritten 
         1914  +                                       # by the name-calc function 
         1915  +                                       # or by one of the sub-functions
         1916  +                                       # of the name-calc function.
         1917  +                                       # The flaw occurs, when the 
         1918  +                                       # S_TMP_0 is used within the 
         1919  +                                       # name-calc function without  
         1920  +                                       # declaring it to be a local
         1921  +                                       # variable.
         1922  +    #--------
         1923  +    #echo "S_FP_0==$S_FP_0"
         1924  +    #echo "S_TMP_0==$S_TMP_0"
         1925  +    #echo "S_TMP_1==$S_TMP_1"
         1926  +    local S_OUT=""
         1927  +    if [ "$S_TMP_1" == "$S_TMP_0" ]; then
         1928  +        S_OUT="verification_passed"
         1929  +    else
         1930  +        S_OUT="verification_failed"
         1931  +    fi
         1932  +    S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_VERIFY_FILE_NAME_T1_RESULT="$S_OUT"
         1933  +} # func_mmmv_silktorrent_packager_t1_bash_verify_file_name_t1
         1934  +
         1935  +
         1936  +#--------------------------------------------------------------------------
         1937  +
         1938  +func_mmmv_silktorrent_packager_t1_bash_test_1() { 
         1939  +    local S_FP_0="$1" # Path to the file. 
         1940  +    #----
         1941  +    func_mmmv_silktorrent_packager_t1_bash_exc_assert_wrappable_file_exists_t1 "$S_FP_0"
         1942  +    #--------
         1943  +    echo ""
         1944  +    #----
         1945  +    func_mmmv_tigerhash_t1 "$S_FP_0"
         1946  +    echo "       Tiger: $S_FUNC_MMMV_TIGERHASH_T1_RESULT"
         1947  +    func_mmmv_whirlpoolhash_t1 "$S_FP_0"
         1948  +    echo "   Whirlpool: $S_FUNC_MMMV_WHIRLPOOLHASH_T1_RESULT"
         1949  +    func_mmmv_sha256_t1 "$S_FP_0"
         1950  +    echo "      SHA256: $S_FUNC_MMMV_SHA256_T1_RESULT"
         1951  +    func_mmmv_filesize_t1 "$S_FP_0"
         1952  +    echo "   file size: $S_FUNC_MMMV_FILESIZE_T1_RESULT"
         1953  +    #----
         1954  +    echo ""
         1955  +} # func_mmmv_silktorrent_packager_t1_bash_test_1
         1956  +
         1957  +
         1958  +#--------------------------------------------------------------------------
         1959  +
         1960  +func_mmmv_silktorrent_packager_t1_bash_wrap_t1() {
         1961  +    local S_FP_0="$1" # Path to the file. 
         1962  +    #----
         1963  +    func_mmmv_silktorrent_packager_t1_bash_exc_assert_wrappable_file_exists_t1 "$S_FP_0"
         1964  +    #--------
         1965  +    func_mmmv_create_tmp_folder_t1
         1966  +    if [ "$S_FUNC_FUNC_MMMV_CREATE_TMP_FOLDER_T1_RESULT" == "" ]; then
         1967  +        echo "This script is flawed, because the folder "
         1968  +        echo "creation function should have thrown "
         1969  +        echo "before the control flow reaches this branch." 
         1970  +        echo "GUID=='726a8332-1505-4018-b2e7-71b3900170e7'"
         1971  +        #----
         1972  +        cd $S_FP_ORIG
         1973  +        exit 1 # exit with error
         1974  +    fi
         1975  +    local S_FP_TMP_0="$S_FUNC_FUNC_MMMV_CREATE_TMP_FOLDER_T1_RESULT"
         1976  +    if [ ! -e "$S_FP_TMP_0" ]; then
         1977  +        echo "This script is flawed."
         1978  +        echo "May be some other thread deleted the folder or"
         1979  +        echo "the folder creation function returned a valid path, but"
         1980  +        echo "did not actually create the folder that it was supposed create."
         1981  +        echo "S_FP_TMP_0==$S_FP_TMP_0"
         1982  +        echo "GUID=='f8fc342c-18e1-40b4-a3d7-71b3900170e7'"
         1983  +        #----
         1984  +        cd $S_FP_ORIG
         1985  +        exit 1 # exit with error
         1986  +    fi
         1987  +    #--------
         1988  +    local S_FP_TMP_SILKTORRENT_PACKET="$S_FP_TMP_0/silktorrent_packet"
         1989  +    local S_FP_TMP_SILKTORRENT_PACKET_TAR="$S_FP_TMP_0/silktorrent_packet.tar"
         1990  +    local S_FP_TMP_PAYLOAD="$S_FP_TMP_SILKTORRENT_PACKET/payload"
         1991  +    local S_FP_TMP_HEADER="$S_FP_TMP_SILKTORRENT_PACKET/header"
         1992  +    local S_FP_TMP_HEADER_SALT_TXT="$S_FP_TMP_HEADER/silktorrent_salt.txt"
         1993  +    func_mmmv_create_folder_if_it_does_not_already_exist_t1 "$S_FP_TMP_PAYLOAD" # uses mkdir -p
         1994  +    func_mmmv_create_folder_if_it_does_not_already_exist_t1 "$S_FP_TMP_HEADER"
         1995  +    #--------
         1996  +    # Salting makes sure that it is not possible to 
         1997  +    # conclude the payload bitstream from the 
         1998  +    # Silktorrent packet (file) name, forcing censoring
         1999  +    # parties to download packages 
         2000  +    # that they are not looking for and allowing
         2001  +    # censorship dodgers to publish the same payload bitstream
         2002  +    # in multiple, differet, Silktorrent packages.
         2003  +    func_mmmv_GUID_t1
         2004  +    echo "$S_FUNC_MMMV_GUID_T1_RESULT" >> $S_FP_TMP_HEADER_SALT_TXT
         2005  +    func_mmmv_GUID_t1
         2006  +    echo "$S_FUNC_MMMV_GUID_T1_RESULT" >> $S_FP_TMP_HEADER_SALT_TXT
         2007  +    func_mmmv_GUID_t1
         2008  +    echo "$S_FUNC_MMMV_GUID_T1_RESULT" >> $S_FP_TMP_HEADER_SALT_TXT
         2009  +    func_mmmv_GUID_t1
         2010  +    echo "$S_FUNC_MMMV_GUID_T1_RESULT" >> $S_FP_TMP_HEADER_SALT_TXT
         2011  +    func_mmmv_GUID_t1
         2012  +    echo "$S_FUNC_MMMV_GUID_T1_RESULT" >> $S_FP_TMP_HEADER_SALT_TXT
         2013  +    func_mmmv_GUID_t1
         2014  +    echo "$S_FUNC_MMMV_GUID_T1_RESULT" >> $S_FP_TMP_HEADER_SALT_TXT
         2015  +    #--------
         2016  +    # The file size/Silktorrent pakcket size must also be salted.
         2017  +    ruby -e \
         2018  +        "Random.new_seed;i=0;\
         2019  +         puts '';\
         2020  +         rand(10**6).times{\
         2021  +             i=i+1;\
         2022  +             print(rand(10**6).to_s(16));\
         2023  +             if((i%10)==0) then \
         2024  +                 puts '';\
         2025  +                 i=0;\
         2026  +             end;\
         2027  +         }" \
         2028  +         >> $S_FP_TMP_HEADER_SALT_TXT
         2029  +    #--------
         2030  +    cp -f $S_FP_0 $S_FP_TMP_PAYLOAD/
         2031  +    if [ "$?" != "0" ]; then
         2032  +        echo ""
         2033  +        echo "The command "
         2034  +        echo ""
         2035  +        echo "    cp -f \$S_FP_0 \$S_FP_TMP_PAYLOAD/ "
         2036  +        echo ""
         2037  +        echo "failed. Either this script is flawed or something else went wrong. "
         2038  +        echo ""
         2039  +        echo "    S_FP_0==$S_FP_0"
         2040  +        echo ""
         2041  +        echo "    S_FP_TMP_PAYLOAD=$S_FP_TMP_PAYLOAD"
         2042  +        echo ""
         2043  +        echo "GUID=='214ba8b2-3cff-420c-a4d7-71b3900170e7'"
         2044  +        echo ""
         2045  +        #----
         2046  +        cd $S_FP_ORIG
         2047  +        exit 1 # exit with error
         2048  +    fi
         2049  +    #--------
         2050  +    local S_FP_TMP_ORIG_0="`pwd`"
         2051  +    cd $S_FP_TMP_SILKTORRENT_PACKET/.. 
         2052  +    tar -cf $S_FP_TMP_SILKTORRENT_PACKET_TAR ./`basename $S_FP_TMP_SILKTORRENT_PACKET` 2>/dev/null
         2053  +    cd $S_FP_TMP_ORIG_0
         2054  +    if [ "$?" != "0" ]; then
         2055  +        echo ""
         2056  +        echo "The command "
         2057  +        echo ""
         2058  +        echo "    tar -cf \$S_FP_TMP_SILKTORRENT_PACKET_TAR \$S_FP_TMP_SILKTORRENT_PACKET "
         2059  +        echo ""
         2060  +        echo "failed. Either this script is flawed or something else went wrong. "
         2061  +        echo ""
         2062  +        echo "    S_FP_TMP_SILKTORRENT_PACKET=$S_FP_TMP_SILKTORRENT_PACKET"
         2063  +        echo ""
         2064  +        echo "    S_FP_TMP_SILKTORRENT_PACKET_TAR==$S_FP_TMP_SILKTORRENT_PACKET_TAR"
         2065  +        echo ""
         2066  +        echo "GUID=='68428819-d399-43c8-a2d7-71b3900170e7'"
         2067  +        echo ""
         2068  +        #----
         2069  +        cd $S_FP_ORIG
         2070  +        exit 1 # exit with error
         2071  +    fi
         2072  +    #----
         2073  +    func_mmmv_silktorrent_packager_t1_bash_blob2filename_t1 "$S_FP_TMP_SILKTORRENT_PACKET_TAR"
         2074  +    local S_FP_TMP_SILKTORRENT_PACKET_PUBLISHINGNAME="$S_FP_ORIG/$S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_BLOB2FILENAME_T1_RESULT"
         2075  +    mv $S_FP_TMP_SILKTORRENT_PACKET_TAR $S_FP_TMP_SILKTORRENT_PACKET_PUBLISHINGNAME
         2076  +    if [ "$?" != "0" ]; then
         2077  +        echo ""
         2078  +        echo "Something went wrong."
         2079  +        echo "The renaming and copying of "
         2080  +        echo "    $S_FP_TMP_SILKTORRENT_PACKET_TAR "
         2081  +        echo "to "
         2082  +        echo "    $S_FP_TMP_SILKTORRENT_PACKET_PUBLISHINGNAME "
         2083  +        echo "failed."
         2084  +        echo "GUID=='c158ce46-9e8d-4bb9-a2d7-71b3900170e7'"
         2085  +        echo ""
         2086  +        #----
         2087  +        cd $S_FP_ORIG
         2088  +        exit 1 # exit with error
         2089  +    fi
         2090  +    if [ ! -e "$S_FP_TMP_SILKTORRENT_PACKET_PUBLISHINGNAME" ]; then
         2091  +        echo ""
         2092  +        echo "Something went wrong."
         2093  +        echo "The renaming and copying of "
         2094  +        echo ""
         2095  +        echo "    $S_FP_TMP_SILKTORRENT_PACKET_TAR "
         2096  +        echo ""
         2097  +        echo "to "
         2098  +        echo ""
         2099  +        echo "    $S_FP_TMP_SILKTORRENT_PACKET_PUBLISHINGNAME "
         2100  +        echo ""
         2101  +        echo "failed. The mv command succeed, but for some reason "
         2102  +        echo "the destination file does not exist."
         2103  +        echo "GUID=='7f7e1258-7c19-451f-91d7-71b3900170e7'"
         2104  +        echo ""
         2105  +        #----
         2106  +        cd $S_FP_ORIG
         2107  +        exit 1 # exit with error
         2108  +    fi
         2109  +    #--------
         2110  +    func_mmmv_delete_tmp_folder_t1 "$S_FP_TMP_0"
         2111  +    if [ -e "$S_FP_TMP_0" ]; then
         2112  +        echo ""
         2113  +        echo "Something went wrong."
         2114  +        echo "The deletion of the temporary folder, "
         2115  +        echo ""
         2116  +        echo "    $S_FP_TMP_0"
         2117  +        echo ""
         2118  +        echo "failed."
         2119  +        echo "GUID=='23b56e4e-b7c4-4668-85d7-71b3900170e7'"
         2120  +        echo ""
         2121  +        #----
         2122  +        cd $S_FP_ORIG
         2123  +        exit 1 # exit with error
         2124  +    fi
         2125  +} # func_mmmv_silktorrent_packager_t1_bash_wrap_t1
         2126  +
         2127  +
         2128  +#--------------------------------------------------------------------------
         2129  +
         2130  +func_mmmv_silktorrent_packager_t1_bash_unwrap_t1() {
         2131  +    local S_FP_0="$1" # Path to the file. 
         2132  +    #----
         2133  +    func_mmmv_silktorrent_packager_t1_bash_exc_assert_wrappable_file_exists_t1 "$S_FP_0"
         2134  +    #--------
         2135  +    func_mmmv_silktorrent_packager_t1_bash_verify_file_name_t1 "$S_FP_0"
         2136  +    local S_PACKET_FORMAT="$S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_GET_PACKET_FORMAT_VERSION_T1_RESULT"
         2137  +    if [ "$S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_VERIFY_FILE_NAME_T1_RESULT" != "verification_passed" ]; then
         2138  +        echo ""
         2139  +        echo "The Silktorrent packet candidate, "
         2140  +        echo ""
         2141  +        echo "    $S_FP_0"
         2142  +        echo ""
         2143  +        echo "failed Silktorrent packet name verification."
         2144  +        echo "There exists a possibility that the "
         2145  +        echo "Silktorrent packet candidate is actually OK, but "
         2146  +        echo "this is an older version of the Silktorrent implementaiton and "
         2147  +        echo "this, the older, version does not support "
         2148  +        echo "newer Silktorrent packet formats. "
         2149  +        echo "GUID=='1ea93ef2-0fb7-4cbb-8fd7-71b3900170e7'"
         2150  +        echo ""
         2151  +        #----
         2152  +        cd $S_FP_ORIG
         2153  +        exit 1 # exit with error
         2154  +    fi
         2155  +    #--------
         2156  +    local SB_FORMAT_BRANCH_EXISTS_IN_THIS_FUNCTION="f"
         2157  +    if [ "$S_PACKET_FORMAT" == "silktorrent_packet_format_version_1" ]; then
         2158  +        SB_FORMAT_BRANCH_EXISTS_IN_THIS_FUNCTION="t"
         2159  +        #----
         2160  +        local S_FP_TMP_SILKTORRENT_PACKET="`pwd`/silktorrent_packet"
         2161  +        if [ -e $S_FP_TMP_SILKTORRENT_PACKET ]; then
         2162  +            echo ""
         2163  +            echo "To avoid accidental deletion of files, "
         2164  +            echo "and some other types of flaws, "
         2165  +            echo "there is a requirement that the folder "
         2166  +            echo ""
         2167  +            echo "    ./silktorrent_packet"
         2168  +            echo ""
         2169  +            echo "must be explicitly deleted before calling this script."
         2170  +            echo "GUID=='df3e4c6e-045b-4163-bfc7-71b3900170e7'"
         2171  +            echo ""
         2172  +            #----
         2173  +            cd $S_FP_ORIG
         2174  +            exit 1 # exit with error
         2175  +        fi
         2176  +        #----
         2177  +        tar -xf $S_FP_0 2>/dev/null
         2178  +        if [ "$?" != "0" ]; then
         2179  +            echo ""
         2180  +            echo "Something went wrong. The command "
         2181  +            echo ""
         2182  +            echo "    tar -xf $S_FP_0"
         2183  +            echo ""
         2184  +            echo "exited with an error code, which is $? ."
         2185  +            echo "GUID=='07dfbc27-b793-4b68-93c7-71b3900170e7'"
         2186  +            echo ""
         2187  +            #----
         2188  +            cd $S_FP_ORIG
         2189  +            exit 1 # exit with error
         2190  +        fi
         2191  +        rm -f $S_FP_TMP_SILKTORRENT_PACKET/header/silktorrent_salt.txt
         2192  +        #----
         2193  +        if [ ! -e $S_FP_TMP_SILKTORRENT_PACKET ]; then
         2194  +            echo ""
         2195  +            echo "Something went wrong. "
         2196  +            echo "The unpacking of the Silktorrent packet with the path of "
         2197  +            echo ""
         2198  +            echo "    $S_FP_0"
         2199  +            echo ""
         2200  +            echo "failed. The folder \"silktorrent_packet\" "
         2201  +            echo "is missing after the \"tar\" exited without any errors."
         2202  +            echo "GUID=='39c08e15-9cab-4585-8fc7-71b3900170e7'"
         2203  +            echo ""
         2204  +            #----
         2205  +            cd $S_FP_ORIG
         2206  +            exit 1 # exit with error
         2207  +        fi
         2208  +    fi # silktorrent_packet_format_version_1
         2209  +    #--------
         2210  +    if [ "$SB_FORMAT_BRANCH_EXISTS_IN_THIS_FUNCTION" != "t" ]; then
         2211  +        echo ""
         2212  +        echo "This script is flawed."
         2213  +        echo "There is at least one branch missing from this function."
         2214  +        echo "GUID=='b9f42610-010a-4a35-a1c7-71b3900170e7'"
         2215  +        echo ""
         2216  +        #----
         2217  +        cd $S_FP_ORIG
         2218  +        exit 1 # exit with error
         2219  +    fi
         2220  +    #--------
         2221  +} # func_mmmv_silktorrent_packager_t1_bash_unwrap_t1
         2222  +
         2223  +
         2224  +#--------------------------------------------------------------------------
         2225  +
         2226  +func_mmmv_silktorrent_packager_t1_bash_verify_packet_name_format_v1(){
         2227  +    local S_PACKET_NAME_CANDIDATE="$1" 
         2228  +    if [ "$S_PACKET_NAME_CANDIDATE" == "" ]; then
         2229  +        echo ""
         2230  +        echo "This script is flawed."
         2231  +        echo "Input verification should have cauht the "
         2232  +        echo "\"\" case before the control flow reaches this line."
         2233  +        echo "GUID=='eb6d4411-292c-40b6-a4c7-71b3900170e7'"
         2234  +        echo ""
         2235  +        #----
         2236  +        cd $S_FP_ORIG
         2237  +        exit 1 # exit with error
         2238  +    fi
         2239  +    #--------
         2240  +    local S_OUT="verification_failed" # opposite: "verification_passed"
         2241  +
         2242  +    #                         rgx_in_ruby=/v[\d]{4}[_]/
         2243  +    #                         rgx_in_ruby=/s[\d]+[_]/
         2244  +    #                         rgx_in_ruby=/h[\dabcdef]{64}[_]/
         2245  +    #                         rgx_in_ruby=/i[\dabcdef]{48}$/   # lacks the ending "_" 
         2246  +    #                                                          # for db index optimization
         2247  +    local S_RUBY_REGEX="/^X[\\dabcdef]{48}i[_][\\dabcdef]{64}h[_][\\d]+s[_][\\d]{4}v.stblobX\$/"
         2248  +    #                            Tiger             SHA-256       size     version
         2249  +    # test cases: 
         2250  +    #     ruby -e "puts(ARGV[0])" aa\ bb
         2251  +    #     printf "%q" "AA BB CC $^ \ / '\`\" <>()[];.{}" | xargs ruby -e "puts(ARGV[0])"
         2252  +    # 
         2253  +    # The S_PACKET_NAME_CANDIDATE might contain various quotation marks.
         2254  +    # If it does, then hopefully it crashes at least something so that
         2255  +    # the crash can be detected from the "$?". 
         2256  +    # The surrounding X-es, X<packet name candidate string>X, 
         2257  +    # are to counter a situation, where the file name candidate ends
         2258  +    # with a pspace, like "foo " and the Bash reads the console
         2259  +    # argument in as "foo" in stead of the "foo ". 
         2260  +    #----
         2261  +    #local S_TMP_0="`printf \"%q\" \"'$S_PACKET_NAME_CANDIDATE'\" | xargs ruby -e \" \
         2262  +    local S_TMP_0="`ruby -e \" \
         2263  +        s_in=ARGV[0];\
         2264  +        rgx=$S_RUBY_REGEX;\
         2265  +        md=s_in.match(rgx);\
         2266  +        s_out='no_match';\
         2267  +        if(md!=nil) then \
         2268  +            s_out='match';\
         2269  +        end;\
         2270  +        printf(s_out);\
         2271  +        \" \"$S_PACKET_NAME_CANDIDATE\" `"
         2272  +    #----
         2273  +    if [ "$?" != "0" ]; then
         2274  +        echo ""
         2275  +        echo "Something went wrong. \$?==$? "
         2276  +        echo "    S_PACKET_NAME_CANDIDATE==$S_PACKET_NAME_CANDIDATE"
         2277  +        echo "GUID=='41352353-e739-4fd1-b1c7-71b3900170e7'"
         2278  +        echo ""
         2279  +        #----
         2280  +        cd $S_FP_ORIG
         2281  +        exit 1 # exit with error
         2282  +    fi
         2283  +    #--------
         2284  +    # If the file name starts like "./foo" in stead of "foo", 
         2285  +    # then the verification also fails, 
         2286  +    # exactly as expected and demanded by the spec.
         2287  +    if [ "$S_TMP_0" == "match" ]; then
         2288  +        S_OUT="verification_passed" # opposite: "verification_failed"
         2289  +    fi
         2290  +    #--------
         2291  +    echo "$S_OUT"
         2292  +} # func_mmmv_silktorrent_packager_t1_bash_verify_packet_name_format_v1
         2293  +
         2294  +
         2295  +#--------------------------------------------------------------------------
         2296  +
         2297  +# The 
         2298  +S_SILKTORRENT_PACKAGER_T1_ACTION="" # is global to allow it to be used
         2299  +# in the error messages of different functions.
         2300  +
         2301  +func_mmmv_silktorrent_packager_t1_bash_determine_action() { 
         2302  +    local S_ARGV_0="$1" # Ruby style ARGV, 0 is the first command line argument.
         2303  +    local S_ARGV_1="$2" 
         2304  +    local S_ARGV_2="$3" 
         2305  +    local S_ARGV_3="$4" 
         2306  +    #--------
         2307  +    if [ "$S_ARGV_0" == "" ]; then
         2308  +        func_mmmv_silktorrent_packager_t1_bash_print_help_msg_t1
         2309  +        #----
         2310  +        cd $S_FP_ORIG
         2311  +        exit 1 # exit with an error
         2312  +    fi
         2313  +    #----
         2314  +    local SB_0="f"
         2315  +    if [ "$S_ARGV_0" == "help" ]; then
         2316  +        SB_0="t"
         2317  +    fi
         2318  +    if [ "$S_ARGV_0" == "--help" ]; then
         2319  +        SB_0="t"
         2320  +    fi
         2321  +    if [ "$S_ARGV_0" == "-?" ]; then
         2322  +        SB_0="t"
         2323  +    fi
         2324  +    if [ "$S_ARGV_0" == "-h" ]; then
         2325  +        SB_0="t"
         2326  +    fi
         2327  +    #----
         2328  +    if [ "$SB_0" == "t" ]; then
         2329  +        func_mmmv_silktorrent_packager_t1_bash_print_help_msg_t1
         2330  +        #----
         2331  +        cd $S_FP_ORIG
         2332  +        exit 0 # exit without an error
         2333  +    fi
         2334  +    #--------------------------
         2335  +    if [ "$S_ARGV_0" == "version" ]; then
         2336  +        SB_0="t"
         2337  +    fi
         2338  +    if [ "$S_ARGV_0" == "--version" ]; then
         2339  +        SB_0="t"
         2340  +    fi
         2341  +    if [ "$S_ARGV_0" == "-version" ]; then
         2342  +        SB_0="t"
         2343  +    fi
         2344  +    if [ "$S_ARGV_0" == "-v" ]; then
         2345  +        SB_0="t"
         2346  +    fi
         2347  +    #----
         2348  +    if [ "$SB_0" == "t" ]; then
         2349  +        echo "$S_SCRIPT_VERSION"
         2350  +        #----
         2351  +        cd $S_FP_ORIG
         2352  +        exit 0 # exit without an error
         2353  +    fi
         2354  +    #--------------------------
         2355  +    # Start of actions that require the existance of at least one file.
         2356  +    local SB_FILE_REQUIRED="t"
         2357  +    local SB_REQUESTED_ACTION_EXISTS="f"
         2358  +    local S_TMP_0=""
         2359  +    local S_TMP_1=""
         2360  +    #----
         2361  +    S_TMP_0="wrap" 
         2362  +    if [ "$S_ARGV_0" == "$S_TMP_0" ]; then
         2363  +        S_SILKTORRENT_PACKAGER_T1_ACTION="$S_TMP_0"
         2364  +        SB_REQUESTED_ACTION_EXISTS="t"
         2365  +    fi
         2366  +    if [ "$S_ARGV_0" == "pack" ]; then   # alias
         2367  +        S_SILKTORRENT_PACKAGER_T1_ACTION="$S_TMP_0"
         2368  +        SB_REQUESTED_ACTION_EXISTS="t"
         2369  +    fi
         2370  +    #----
         2371  +    S_TMP_0="unwrap" 
         2372  +    if [ "$S_ARGV_0" == "$S_TMP_0" ]; then
         2373  +        S_SILKTORRENT_PACKAGER_T1_ACTION="$S_TMP_0"
         2374  +        SB_REQUESTED_ACTION_EXISTS="t"
         2375  +    fi
         2376  +    if [ "$S_ARGV_0" == "unpack" ]; then # alias
         2377  +        S_SILKTORRENT_PACKAGER_T1_ACTION="$S_TMP_0"
         2378  +        SB_REQUESTED_ACTION_EXISTS="t"
         2379  +    fi
         2380  +    #----
         2381  +    S_TMP_0="verify" # checks the matche between the blob and the file name
         2382  +    if [ "$S_ARGV_0" == "$S_TMP_0" ]; then
         2383  +        S_SILKTORRENT_PACKAGER_T1_ACTION="$S_TMP_0"
         2384  +        SB_REQUESTED_ACTION_EXISTS="t"
         2385  +    fi
         2386  +    #----
         2387  +    S_TMP_0="test_hash_t1" 
         2388  +    if [ "$S_ARGV_0" == "$S_TMP_0" ]; then
         2389  +        S_SILKTORRENT_PACKAGER_T1_ACTION="$S_TMP_0"
         2390  +        SB_REQUESTED_ACTION_EXISTS="t"
         2391  +    fi
         2392  +    #--------
         2393  +    # Start of actions that do not require a file:
         2394  +    S_TMP_0="verify_packet_name_format_v1" 
         2395  +    if [ "$S_ARGV_0" == "$S_TMP_0" ]; then
         2396  +        S_SILKTORRENT_PACKAGER_T1_ACTION="$S_TMP_0"
         2397  +        SB_REQUESTED_ACTION_EXISTS="t"
         2398  +        SB_FILE_REQUIRED="f"
         2399  +    fi
         2400  +    if [ "$S_ARGV_0" == "verify_package_name_format_v1" ]; then
         2401  +        S_SILKTORRENT_PACKAGER_T1_ACTION="$S_TMP_0"
         2402  +        SB_REQUESTED_ACTION_EXISTS="t"
         2403  +        SB_FILE_REQUIRED="f"
         2404  +    fi
         2405  +    #--------
         2406  +    if [ "$SB_REQUESTED_ACTION_EXISTS" != "t" ]; then # lack of action included
         2407  +        func_mmmv_silktorrent_packager_t1_bash_print_help_msg_t1
         2408  +        #----
         2409  +        cd $S_FP_ORIG
         2410  +        exit 1 # exit with an error
         2411  +    fi
         2412  +    SB_REQUESTED_ACTION_EXISTS="f" # a reset to anticipate flaws elsewhere
         2413  +    # The action name test above has to be before the 
         2414  +    if [ "$SB_FILE_REQUIRED" == "t" ]; then
         2415  +        func_mmmv_silktorrent_packager_t1_bash_exc_assert_wrappable_file_exists_t1 "$S_ARGV_1"
         2416  +    else 
         2417  +        func_mmmv_silktorrent_packager_t1_bash_exc_assert_packet_name_candidate_exists_t1 "$S_ARGV_1"
         2418  +    fi
         2419  +    # because otherwise the error messages would be incorrect.
         2420  +    #--------
         2421  +    # The following duplicating series of if-clauses is to allow 
         2422  +    # actions to have aliases.
         2423  +    if [ "$S_SILKTORRENT_PACKAGER_T1_ACTION" == "wrap" ]; then
         2424  +        func_mmmv_silktorrent_packager_t1_bash_wrap_t1 "$S_ARGV_1"
         2425  +        #----
         2426  +        cd $S_FP_ORIG
         2427  +        exit 0 # exit without an error
         2428  +    fi
         2429  +    #----
         2430  +    if [ "$S_SILKTORRENT_PACKAGER_T1_ACTION" == "unwrap" ]; then
         2431  +        func_mmmv_silktorrent_packager_t1_bash_unwrap_t1 "$S_ARGV_1"
         2432  +        #----
         2433  +        cd $S_FP_ORIG
         2434  +        exit 0 # exit without an error
         2435  +    fi
         2436  +    #----
         2437  +    if [ "$S_SILKTORRENT_PACKAGER_T1_ACTION" == "verify" ]; then
         2438  +        func_mmmv_silktorrent_packager_t1_bash_verify_file_name_t1 "$S_ARGV_1"
         2439  +        echo "$S_FUNC_MMMV_SILKTORRENT_PACKAGER_T1_BASH_VERIFY_FILE_NAME_T1_RESULT"
         2440  +        #----
         2441  +        cd $S_FP_ORIG
         2442  +        exit 0 # exit without an error
         2443  +    fi
         2444  +    #----
         2445  +    if [ "$S_SILKTORRENT_PACKAGER_T1_ACTION" == "test_hash_t1" ]; then
         2446  +        func_mmmv_silktorrent_packager_t1_bash_test_1 "$S_ARGV_1"
         2447  +        #----
         2448  +        cd $S_FP_ORIG
         2449  +        exit 0 # exit without an error
         2450  +    fi
         2451  +    #--------
         2452  +    # Start of actions that do not require a file:
         2453  +    if [ "$S_SILKTORRENT_PACKAGER_T1_ACTION" == "verify_packet_name_format_v1" ]; then
         2454  +        func_mmmv_silktorrent_packager_t1_bash_verify_packet_name_format_v1 "$S_ARGV_1"
         2455  +        #----
         2456  +        cd $S_FP_ORIG
         2457  +        exit 0 # exit without an error
         2458  +    fi
         2459  +    #--------------------------
         2460  +        echo "" 
         2461  +        echo "This bash script is flawed. The control flow " 
         2462  +        echo "should have never reached this line."
         2463  +        echo "GUID=='e3af811a-93a7-4512-91b7-71b3900170e7'"
         2464  +        echo ""
         2465  +        #----
         2466  +        cd $S_FP_ORIG
         2467  +        exit 1 # exit with an error
         2468  +} # func_mmmv_silktorrent_packager_t1_bash_determine_action
         2469  +
         2470  +func_mmmv_silktorrent_packager_t1_bash_determine_action $1 $2 $3 $4 $5 $6 $7
         2471  +
         2472  +
         2473  +#--------------------------------------------------------------------------
         2474  +
         2475  +
         2476  +#--------------------------------------------------------------------------
         2477  +cd $S_FP_ORIG
         2478  +exit 0 # 
         2479  +
         2480  +#==========================================================================
         2481  +# Fragments of comments and code that might find use some times later:
         2482  +#--------------------------------------------------------------------------
         2483  +#
         2484  +#   max 55 characters --- package suggested deprecation date in nanoseconds
         2485  +#                         relative to the Unix Epoch, 
         2486  +#                         written in base 10. It can be negative.
         2487  +#                         rgx_in_ruby=/t((y[-]?[\d]+)|n)[_]/
         2488  +# echo "v0034_s2342_tn_" | gawk '{ gsub(/_/, "_\n"); print }' | \
         2489  +#                          gawk '/^t(y[-]?[0-9]+|n)_/ {printf "%s",$1 }' |
         2490  +#                          gawk '{gsub(/[tyn_]/,"");printf "%s", $1 }'
         2491  +#                         
         2492  +#
         2493  +
         2494  +
         2495  +#==========================================================================
         2496  +