Patrick Williams | 064f039 | 2022-12-03 06:29:12 -0600 | [diff] [blame] | 1 | #!/bin/sh |
Tom Joseph | 9a61b4f | 2016-07-11 06:56:11 -0500 | [diff] [blame] | 2 | |
| 3 | # Ensure some files have been passed. |
Patrick Williams | 064f039 | 2022-12-03 06:29:12 -0600 | [diff] [blame] | 4 | if [ -z "$*" ]; then |
Tom Joseph | 9a61b4f | 2016-07-11 06:56:11 -0500 | [diff] [blame] | 5 | echo "Usage: $0 [whitelist_files+]" >&2 |
Patrick Williams | 064f039 | 2022-12-03 06:29:12 -0600 | [diff] [blame] | 6 | exit 1 |
Tom Joseph | 9a61b4f | 2016-07-11 06:56:11 -0500 | [diff] [blame] | 7 | fi |
| 8 | |
| 9 | cat << EOF |
Matt Simmering | 68d9d40 | 2023-11-09 14:22:11 -0800 | [diff] [blame] | 10 | #include <ipmiallowlist.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>" |
Patrick Williams | 064f039 | 2022-12-03 06:29:12 -0600 | [diff] [blame] | 22 | sed "s/#.*//" "$*" | sed '/^$/d' | sort -n | uniq | sed "s/^/ { /" | \ |
Tom Joseph | 9a61b4f | 2016-07-11 06:56:11 -0500 | [diff] [blame] | 23 | sed "s/\:\(....\)\(.*\)/ , \1 }, \2/" |
| 24 | |
| 25 | cat << EOF |
| 26 | }; |
| 27 | EOF |