|
|
@ -153,7 +153,7 @@ ASN1._stringify = function(asn1) { |
|
|
|
ASN1.tpl = function (asn1) { |
|
|
|
//console.log(JSON.stringify(asn1, null, 2));
|
|
|
|
//console.log(asn1);
|
|
|
|
var ws = ''; |
|
|
|
var ws = '\t'; |
|
|
|
var i = 0; |
|
|
|
var vars = []; |
|
|
|
var str = ws; |
|
|
@ -177,12 +177,12 @@ ASN1.tpl = function (asn1) { |
|
|
|
if (0x05 !== asn1.type) { |
|
|
|
if (0x06 !== asn1.type) { |
|
|
|
val = Buffer.from(asn1.value || ''); |
|
|
|
vars.push("// 0x" + Enc.numToHex(val.byteLength) + " (" + val.byteLength + " bytes)\nvar tpl" + i + " = '" |
|
|
|
vars.push("// 0x" + Enc.numToHex(val.byteLength) + " (" + val.byteLength + " bytes)\nopts.tpl" + i + " = '" |
|
|
|
+ Enc.bufToHex(val) + "';"); |
|
|
|
if (0x02 !== asn1.type && 0x03 !== asn1.type) { |
|
|
|
str += ", "; |
|
|
|
} |
|
|
|
str += "tpl" + i; |
|
|
|
str += "opts.tpl" + i; |
|
|
|
} else { |
|
|
|
str += ", " + Enc.bufToHex(asn1.value); |
|
|
|
} |
|
|
@ -200,8 +200,12 @@ ASN1.tpl = function (asn1) { |
|
|
|
} |
|
|
|
|
|
|
|
write(asn1); |
|
|
|
console.log('var opts = {};'); |
|
|
|
console.log(vars.join('\n') + '\n'); |
|
|
|
console.log(str + ';'); |
|
|
|
console.log(); |
|
|
|
console.log('function buildSchema(opts) {'); |
|
|
|
console.log('\treturn ' + str.slice(3) + ';'); |
|
|
|
console.log('}'); |
|
|
|
}; |
|
|
|
|
|
|
|
module.exports = ASN1; |
|
|
|