#!/bin/sh
if [ -z "$1" ]; then
  echo "Usage: $0 pubsuffix.cc"
  exit 1
fi
set -e
echo "Downloading public suffix data and generating $1"
temp=$(mktemp pubsuffixXXXXXX)
trap "rm -f $temp" 0 1 2 3 15
set -e
curl -o $temp -s -S https://publicsuffix.org/list/public_suffix_list.dat
(echo "const char* g_pubsuffix[]={";
	for a in $(grep -v "//" "$temp" | grep \\. | egrep "^[.0-9a-z-]*$")
	do
		echo \"$a\",
	done
echo "0};") > "$1"
