JavaScript generic ASN.1 parser (mirror)
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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