forked from lapo-luchini/asn1js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateOID.sh
executable file
·55 lines (55 loc) · 1.83 KB
/
updateOID.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#/bin/sh
URL='https://www.cs.auckland.ac.nz/~pgut001/dumpasn1.cfg'
if [ -x /usr/bin/fetch ]; then
/usr/bin/fetch -m --no-verify-peer $URL
elif [ -x /usr/bin/wget ]; then
/usr/bin/wget -N --no-check-certificate $URL
elif [ ! -r dumpasn1.cfg ]; then
echo Please download $URL in this directory.
exit 1
fi
cat dumpasn1.cfg | \
tr -d '\r' | \
awk -v apos="'" -v q='"' -v url="$URL" '
function clean() {
oid = "";
comment = "";
description = "";
warning = "";
}
BEGIN {
FS = "= *";
clean();
print "// Converted from: " url;
print "// which is made by Peter Gutmann and whose license states:";
print "// You can use this code in whatever way you want,";
print "// as long as you don" apos "t try to claim you wrote it.";
print "(typeof define != " q "undefined" q " ? define : function (factory) { " q "use strict" q ";";
print " if (typeof module == " q "object" q ") module.exports = factory();";
print " else window.oids = factory();";
print "})(function () {";
print q "use strict" q ";";
print "return {";
}
/^OID/ { oid = $2; }
/^Comment/ { comment = $2; }
/^Description/ { description = $2; }
/^Warning/ { warning = ", \"w\": true"; }
/^$/ {
if (length(oid) > 0) {
gsub(" ", ".", oid);
gsub("\"", "\\\"", description);
gsub("\"", "\\\"", comment);
if (++seen[oid] > 1)
print "Duplicate OID in line " NR ": " oid > "/dev/stderr";
else
printf "\"%s\": { \"d\": \"%s\", \"c\": \"%s\"%s },\n", oid, description, comment, warning;
clean();
}
}
END {
print "\"END\": \"\""
print "};});"
}
' >oids.js
echo Conversion completed.