forked from lapo-luchini/asn1js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·51 lines (51 loc) · 1.54 KB
/
update.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
#/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 url="$URL" '
function clean() {
oid = "";
comment = "";
description = "";
warning = "false";
}
BEGIN {
FS = "= *";
apos = sprintf("%c", 39);
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 "oids = {";
}
/^OID/ { oid = $2; }
/^Comment/ { comment = $2; }
/^Description/ { description = $2; }
/^Warning/ { warning = "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\", \"w\": %s },\n", oid, description, comment, warning;
clean();
}
}
END {
print "\"END\": \"\""
print "};"
}
' >oids.js
echo Conversion completed.