blob: 223ef755dd1c5769c35b08c8f99f059263b6f4f5 [file] [log] [blame]
Patrick Williams064f0392022-12-03 06:29:12 -06001#!/bin/sh
Tom Joseph9a61b4f2016-07-11 06:56:11 -05002
3# Ensure some files have been passed.
Patrick Williams064f0392022-12-03 06:29:12 -06004if [ -z "$*" ]; then
Tom Joseph9a61b4f2016-07-11 06:56:11 -05005 echo "Usage: $0 [whitelist_files+]" >&2
Patrick Williams064f0392022-12-03 06:29:12 -06006 exit 1
Tom Joseph9a61b4f2016-07-11 06:56:11 -05007fi
8
9cat << EOF
Matt Simmering68d9d402023-11-09 14:22:11 -080010#include <ipmiallowlist.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>"
Patrick Williams064f0392022-12-03 06:29:12 -060022sed "s/#.*//" "$*" | sed '/^$/d' | sort -n | uniq | sed "s/^/ { /" | \
Tom Joseph9a61b4f2016-07-11 06:56:11 -050023 sed "s/\:\(....\)\(.*\)/ , \1 }, \2/"
24
25cat << EOF
26};
27EOF