First commit
[anna.git] / source / diameter / stack / setups / flags.sh
1 #!/bin/ksh
2
3
4 _exit() {
5    echo
6    echo $1
7    echo
8    exit
9 }
10
11 _print() {
12    result=
13    must=-
14    may=-
15    shouldnot=-
16    mustnot=-
17    enc=-
18    [[ "$V" = "must" ]] && must="$must,V"
19    [[ "$M" = "must" ]] && must="$must,M"
20    [[ "$P" = "must" ]] && must="$must,P"
21    [[ "$V" = "may" ]] && may="$may,V"
22    [[ "$M" = "may" ]] && may="$may,M"
23    [[ "$P" = "may" ]] && may="$may,P"
24    [[ "$V" = "shouldnot" ]] && shouldnot="$shouldnot,V"
25    [[ "$M" = "shouldnot" ]] && shouldnot="$shouldnot,M"
26    [[ "$P" = "shouldnot" ]] && shouldnot="$shouldnot,P"
27    [[ "$V" = "mustnot" ]] && mustnot="$mustnot,V"
28    [[ "$M" = "mustnot" ]] && mustnot="$mustnot,M"
29    [[ "$P" = "mustnot" ]] && mustnot="$mustnot,P"
30    [[ "$ENC" = "yes" ]] && enc="$enc,Y"
31    [[ "$ENC" = "no" ]] && enc="$enc,N"
32
33    _must=$(echo $must | cut -d',' -f2-)
34    _may=$(echo $may | cut -d',' -f2-)
35    _shouldnot=$(echo $shouldnot | cut -d',' -f2-)
36    _mustnot=$(echo $mustnot | cut -d',' -f2-)
37    _enc=$(echo $enc | cut -d',' -f2-)
38
39    printf "%50s %2s %10s %2s %10s %2s %10s %2s %10s %2s %10s\n" $AVP "|" $_must "|" $_may "|" $_shouldnot "|" $_mustnot "|" $_enc
40 }
41
42
43 [[ "$1" = "" ]] && _exit "Use: $0 <avps dictionary>, i.e.: $0 avps_ietf.xml"
44 FILE=$1
45 BN_FILE=`basename $FILE`
46 TMP_FILE=.${BN_FILE}.tmp
47
48 grep "<avp name=" $FILE > $TMP_FILE
49
50 printf "%50s %2s %10s %2s %10s %2s %10s %2s %10s %2s %10s\n" AVP "|" Must "|" May "|" "Should Not" "|" "Must Not" "|" "May Encrypt"
51 echo "-------------------------------------------------------------------------------------------------------------------------"
52
53 while read -r line
54 do
55    AVP=$(echo $line | awk -F'avp name=' '{ print $2 }' | cut -d'"' -f2)
56    V=$(echo $line | awk -F'v-bit=' '{ print $2 }' | cut -d'"' -f2)
57    M=$(echo $line | awk -F'm-bit=' '{ print $2 }' | cut -d'"' -f2)
58    P=$(echo $line | awk -F'p-bit=' '{ print $2 }' | cut -d'"' -f2)
59    ENC=$(echo $line | awk -F'may-encrypt=' '{ print $2 }' | cut -d'"' -f2)
60
61    _print
62
63 done < $TMP_FILE
64
65
66
67 rm $TMP_FILE