1#!/bin/sh 2 3# Ensure some files have been passed. 4if [ -z "$*" ]; then 5 echo "Usage: $0 [whitelist_files+]" >&2 6 exit 1 7fi 8 9cat << EOF 10#include <ipmiwhitelist.hpp> 11 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>" 22sed "s/#.*//" "$*" | sed '/^$/d' | sort -n | uniq | sed "s/^/ { /" | \ 23 sed "s/\:\(....\)\(.*\)/ , \1 }, \2/" 24 25cat << EOF 26}; 27EOF 28