Tom Joseph | 9a61b4f | 2016-07-11 06:56:11 -0500 | [diff] [blame] | 1 | #/bin/sh |
| 2 | |
| 3 | # Ensure some files have been passed. |
| 4 | if [ "x$*" == "x" ]; then |
| 5 | echo "Usage: $0 [whitelist_files+]" >&2 |
| 6 | exit -1 |
| 7 | fi |
| 8 | |
| 9 | cat << EOF |
Patrick Williams | 4b9efaa | 2016-08-12 21:59:51 -0500 | [diff] [blame] | 10 | #include <ipmiwhitelist.hpp> |
Tom Joseph | 9a61b4f | 2016-07-11 06:56:11 -0500 | [diff] [blame] | 11 | |
| 12 | const std::vector<netfncmd_pair> whitelist = { |
| 13 | |
| 14 | EOF |
| 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>" |
| 22 | cat $* | sed "s/#.*//" | sed '/^$/d' | sort -n | uniq | sed "s/^/ { /" | \ |
| 23 | sed "s/\:\(....\)\(.*\)/ , \1 }, \2/" |
| 24 | |
| 25 | cat << EOF |
| 26 | }; |
| 27 | EOF |