blob: 684248eb90cba85915e09642e935464f48d1dae6 [file] [log] [blame]
Tom Joseph9a61b4f2016-07-11 06:56:11 -05001#/bin/sh
2
3# Ensure some files have been passed.
4if [ "x$*" == "x" ]; then
5 echo "Usage: $0 [whitelist_files+]" >&2
6 exit -1
7fi
8
9cat << EOF
Patrick Williams4b9efaa2016-08-12 21:59:51 -050010#include <ipmiwhitelist.hpp>
Tom Joseph9a61b4f2016-07-11 06:56:11 -050011
12const std::vector<netfncmd_pair> whitelist = {
13
14EOF
15
16# Output each row of whitelist vector.
17# Concatenate all the passed files.
18# Remove comments and empty lines.
19# Sort the list [numerically].
20# Remove any duplicates.
21# Turn "a:b //<NetFn>:<Command>" -> "{ a, b }, //<NetFn>:<Command>"
22cat $* | sed "s/#.*//" | sed '/^$/d' | sort -n | uniq | sed "s/^/ { /" | \
23 sed "s/\:\(....\)\(.*\)/ , \1 }, \2/"
24
25cat << EOF
26};
27EOF