summaryrefslogtreecommitdiffstats
path: root/generate_whitelist.sh
blob: 684248eb90cba85915e09642e935464f48d1dae6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#/bin/sh

# Ensure some files have been passed.
if [ "x$*" == "x" ]; then
    echo "Usage: $0 [whitelist_files+]" >&2
    exit -1
fi

cat << EOF
#include <ipmiwhitelist.hpp>

const std::vector<netfncmd_pair> whitelist = {

EOF

# Output each row of whitelist vector.
# Concatenate all the passed files.
# Remove comments and empty lines.
# Sort the list [numerically].
# Remove any duplicates.
# Turn "a:b //<NetFn>:<Command>" -> "{ a, b }, //<NetFn>:<Command>"
cat $* | sed "s/#.*//" | sed '/^$/d' | sort -n | uniq | sed "s/^/    { /" | \
    sed "s/\:\(....\)\(.*\)/ , \1 }, \2/"

cat << EOF
};
EOF
OpenPOWER on IntegriCloud