"Fossies" - the Fresh Open Source Software Archive

Member "cryptsetup-2.4.3/tests/generate-symbols-list" (13 Jan 2022, 590 Bytes) of package /linux/misc/cryptsetup-2.4.3.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/bash
    2 
    3 function fail()
    4 {
    5     [ -n "$1" ] && echo "$1"
    6     exit 2
    7 }
    8 
    9 function generate() {
   10     local ver=
   11 
   12     while IFS= read -r line; do
   13         local len=${#line}
   14 
   15 
   16         if [ "${line:0:11}" = "CRYPTSETUP_" ]; then
   17             local i=12
   18             while [ $i -lt $len ]; do
   19                 if [ "${line:$i:1}" = "{" ]; then
   20                     ver=${line:0:$i}
   21                     break
   22                 fi
   23                 i=$((i+1))
   24             done
   25         elif [ "${line:0:6}" = "crypt_" -a -n "$ver" ]; then
   26             printf 'CHECK_SYMBOL(%s, %s)\n' $line $ver
   27         fi
   28     done < <(tr -d '[:blank:];' < $1)
   29 }
   30 
   31 test $# -ge 1 || fail "usage: $0 <symbol_file>"
   32 
   33 test -f $1 || fail "$1 is not a file."
   34 
   35 generate $1