1#/bin/sh
2RFCs="5280 5208 3369 3161 2986"
3downloadRFC() {
4 URL="https://www.ietf.org/rfc/rfc$1.txt"
5 if [ -x /usr/bin/fetch ]; then
6 /usr/bin/fetch -m --no-verify-peer $URL
7 elif [ -x /usr/bin/wget ]; then
8 /usr/bin/wget -N --no-check-certificate $URL
9 elif [ ! -r dumpasn1.cfg ]; then
10 echo Please download $URL in this directory.
11 exit 1
12 fi
13}
14echo '{}' > rfcdef.json # start from scratch
15mkdir -p rfc
16cd rfc
17for n in $RFCs; do
18 downloadRFC $n
19 ../parseRFC.js rfc$n.txt ../rfcdef.json
20done
21cd ..
22{
23 echo "// content parsed from the following RFCs: $RFCs"
24 cat - <<EOF
25(typeof define != "undefined" ? define : function (factory) { "use strict";
26 if (typeof module == "object") module.exports = factory();
27 else window.rfcdef = factory();
28})(function () {
29"use strict";
30EOF
31 echo -n "return "
32 cat rfcdef.json
33 echo ";});"
34} > rfcdef.js
35echo Conversion completed.