Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-firebird

Package Overview
Dependencies
Maintainers
3
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-firebird - npm Package Compare versions

Comparing version 0.7.2 to 0.7.3

222

lib/messages.js
var fs = require('fs');
const
//ISC_MASK = 0x14000000, // Defines the code as a valid ISC code
FAC_MASK = 0x00FF0000, // Specifies the facility where the code is located
CODE_MASK = 0x0000FFFF, // Specifies the code in the message file
CLASS_MASK = 0xF0000000; // Defines the code as warning, error, info, or other
//const ISC_MASK = 0x14000000; // Defines the code as a valid ISC code
const FAC_MASK = 0x00FF0000; // Specifies the facility where the code is located
const CODE_MASK = 0x0000FFFF; // Specifies the code in the message file
const CLASS_MASK = 0xF0000000; // Defines the code as warning, error, info, or other
var msgNumber = exports.msgNumber = function(facility, code) {
return (facility * 10000 + code);
return (facility * 10000 + code);
};
var getCode = exports.getCode = function(code) {
return (code & CODE_MASK)
return (code & CODE_MASK);
};
var getFacility = exports.getFacility = function(code) {
return (code & FAC_MASK) >> 16;
return (code & FAC_MASK) >> 16;
};
exports.getClass = function(code) {
return (code & CLASS_MASK) >> 30
return (code & CLASS_MASK) >> 30;
};
exports.lookupMessages = function(status, callback){
exports.lookupMessages = function(status, callback) {
var handle;
var bucket_size;
var top_tree;
var levels;
var buffer;
var handle;
var bucketSize;
var topTree;
var levels;
var buffer;
function lookup(item, callback) {
function lookup(item, callback) {
var code = msgNumber(getFacility(item.gdscode), getCode(item.gdscode));
var code = msgNumber(getFacility(item.gdscode), getCode(item.gdscode));
function readIndex(stackSize, position) {
function readIndex(stackSize, position) {
function readNode(from) {
var ret = {};
ret.code = buffer.readUInt32LE(from);
ret.seek = buffer.readUInt32LE(from + 4);
return ret;
}
function readNode(from) {
var ret = {};
ret.code = buffer.readUInt32LE(from);
ret.seek = buffer.readUInt32LE(from + 4);
return ret;
}
fs.read(handle, buffer, 0, bucket_size, position, function(err, bufferSize) {
fs.read(handle, buffer, 0, bucketSize, position, function(err, bufferSize) {
if (bufferSize <= 0) {
callback();
return;
}
if (bufferSize <= 0) {
callback();
return;
}
if (stackSize === levels) {
search();
return;
}
if (stackSize === levels) {
search();
return;
}
var from = 0;
var node = readNode(from);
var from = 0;
var node = readNode(from);
while (true) {
while (true) {
if (node.code >= code)
{
readIndex(stackSize + 1, node.seek);
break;
}
if (node.code >= code)
{
readIndex(stackSize + 1, node.seek);
break;
}
from += 8;
if (from >= bufferSize)
{
callback();
break;
}
from += 8;
if (from >= bufferSize)
{
callback();
break;
}
node = readNode(from);
}
});
node = readNode(from);
}
});
}
function search() {
function search() {
function readRec(from) {
function readRec(from) {
function align(v) {
return (v + 3) & ~3;
function align(v) {
return (v + 3) & ~3;
}
var ret = {};
ret.code = buffer.readUInt32LE(from);
ret.length = buffer.readUInt16LE(from + 4);
var ret = {};
ret.code = buffer.readUInt32LE(from);
ret.length = buffer.readUInt16LE(from + 4);
if (ret.code == code){
from += 8;
ret.text = buffer.toString(null, from, from + ret.length);
} else
ret.seek = from + align(8 + ret.length, 4);
from += 8;
if (ret.code == code) {
ret.text = buffer.toString(null, from, from + ret.length);
} else
ret.seek = from + align(8 + ret.length, 4);
return ret;
}
return ret;
}
var rec = readRec(0);
var rec = readRec(0);
while (rec.seek) {
if (rec.seek >= buffer.length)
break;
else
rec = readRec(rec.seek);
}
while (rec.seek) {
if (rec.seek >= buffer.length)
break;
else
rec = readRec(rec.seek);
}
var str = rec.text;
if (item.params) {
for (var i = 0; i < item.params.length; i++)
str = str.replace('@' + String(i+1), item.params[i]);
}
var str = rec.text;
if (item.params) {
for (var i = 0; i < item.params.length; i++)
str = str.replace('@' + String(i + 1), item.params[i]);
}
callback(str);
}
readIndex(1, top_tree);
callback(str);
}
fs.open(__dirname + "/firebird.msg", 'r', function(err, h) {
readIndex(1, topTree);
}
if (!h) {
callback();
return;
}
fs.open(__dirname + '/firebird.msg', 'r', function(err, h) {
buffer = new Buffer(14);
fs.read(h, buffer, 0, 14, 0, function(){
if (!h) {
callback();
return;
handle = h;
bucket_size = buffer.readUInt16LE(2);
top_tree = buffer.readUInt32LE(4);
levels = buffer.readUInt16LE(12);
buffer = new Buffer(bucket_size);
}
var i = 0;
var text;
buffer = new Buffer(14);
fs.read(h, buffer, 0, 14, 0, function() {
function loop() {
lookup(status[i], function(line) {
if (text)
text = text + ', ' + line
else
text = line;
handle = h;
bucketSize = buffer.readUInt16LE(2);
topTree = buffer.readUInt32LE(4);
levels = buffer.readUInt16LE(12);
buffer = new Buffer(bucketSize);
if (i === status.length - 1) {
fs.close(handle);
callback(text);
} else {
i++;
loop();
}
});
}
var i = 0;
var text;
loop(0);
function loop() {
lookup(status[i], function(line) {
if (text)
text = text + ', ' + line;
else
text = line;
if (i === status.length - 1) {
fs.close(handle);
callback(text);
} else {
i++;
loop();
}
});
}
loop(0);
});
};
});
};

@@ -5,3 +5,3 @@

function align(n) {
return (n + 3) & ~3;
return (n + 3) & ~3;
}

@@ -18,116 +18,116 @@

var BlrWriter = exports.BlrWriter = function(size){
this.buffer = new Buffer(size || 32);
this.pos = 0;
var BlrWriter = exports.BlrWriter = function(size) {
this.buffer = new Buffer(size || 32);
this.pos = 0;
};
BlrWriter.prototype.addByte = function (b) {
this.ensure(1);
this.buffer.writeUInt8(b, this.pos);
this.pos++;
BlrWriter.prototype.addByte = function(b) {
this.ensure(1);
this.buffer.writeUInt8(b, this.pos);
this.pos++;
};
BlrWriter.prototype.addShort = function (b) {
this.ensure(1);
this.buffer.writeInt8(b, this.pos);
this.pos++;
BlrWriter.prototype.addShort = function(b) {
this.ensure(1);
this.buffer.writeInt8(b, this.pos);
this.pos++;
};
BlrWriter.prototype.addSmall = function (b) {
this.ensure(2);
this.buffer.writeInt16LE(b, this.pos);
this.pos += 2;
BlrWriter.prototype.addSmall = function(b) {
this.ensure(2);
this.buffer.writeInt16LE(b, this.pos);
this.pos += 2;
};
BlrWriter.prototype.addWord = function (b) {
this.ensure(2);
this.buffer.writeUInt16LE(b, this.pos);
this.pos += 2;
BlrWriter.prototype.addWord = function(b) {
this.ensure(2);
this.buffer.writeUInt16LE(b, this.pos);
this.pos += 2;
};
BlrWriter.prototype.addInt32 = function (b) {
this.ensure(4);
this.buffer.writeUInt32LE(b, this.pos);
this.pos += 4;
BlrWriter.prototype.addInt32 = function(b) {
this.ensure(4);
this.buffer.writeUInt32LE(b, this.pos);
this.pos += 4;
};
BlrWriter.prototype.addByteInt32 = function (c, b) {
this.addByte(c);
this.ensure(4);
this.buffer.writeUInt32LE(b, this.pos);
this.pos += 4;
BlrWriter.prototype.addByteInt32 = function(c, b) {
this.addByte(c);
this.ensure(4);
this.buffer.writeUInt32LE(b, this.pos);
this.pos += 4;
};
BlrWriter.prototype.addNumeric = function (c, v) {
BlrWriter.prototype.addNumeric = function(c, v) {
if (v < 256){
this.ensure(3);
this.buffer.writeUInt8(c, this.pos);
this.pos++;
this.buffer.writeUInt8(1, this.pos);
this.pos++;
this.buffer.writeUInt8(v, this.pos);
this.pos++;
return;
}
this.ensure(6);
if (v < 256) {
this.ensure(3);
this.buffer.writeUInt8(c, this.pos);
this.pos++;
this.buffer.writeUInt8(4, this.pos);
this.buffer.writeUInt8(1, this.pos);
this.pos++;
this.buffer.writeInt32BE(v, this.pos);
this.pos += 4;
this.buffer.writeUInt8(v, this.pos);
this.pos++;
return;
}
this.ensure(6);
this.buffer.writeUInt8(c, this.pos);
this.pos++;
this.buffer.writeUInt8(4, this.pos);
this.pos++;
this.buffer.writeInt32BE(v, this.pos);
this.pos += 4;
};
BlrWriter.prototype.addBytes = function (b) {
BlrWriter.prototype.addBytes = function(b) {
this.ensure(b.length);
for (var i = 0, length = b.length; i < length; i++) {
this.buffer.writeUInt8(b[i], this.pos);
this.pos++;
}
this.ensure(b.length);
for (var i = 0, length = b.length; i < length; i++) {
this.buffer.writeUInt8(b[i], this.pos);
this.pos++;
}
};
BlrWriter.prototype.addString = function (c, s, encoding) {
this.addByte(c);
BlrWriter.prototype.addString = function(c, s, encoding) {
this.addByte(c);
var len = Buffer.byteLength(s, encoding);
if (len > MAX_STRING_SIZE)
throw new Error('blr string is too big');
var len = Buffer.byteLength(s, encoding);
if (len > MAX_STRING_SIZE)
throw new Error('blr string is too big');
this.ensure(len + 1);
this.buffer.writeUInt8(len, this.pos);
this.pos++;
this.buffer.write(s, this.pos, s.length, encoding);
this.pos += len;
this.ensure(len + 1);
this.buffer.writeUInt8(len, this.pos);
this.pos++;
this.buffer.write(s, this.pos, s.length, encoding);
this.pos += len;
};
BlrWriter.prototype.addBuffer = function (b) {
this.addSmall(b.length);
this.ensure(b.length);
b.copy(this.buffer, this.pos);
this.pos += b.length;
BlrWriter.prototype.addBuffer = function(b) {
this.addSmall(b.length);
this.ensure(b.length);
b.copy(this.buffer, this.pos);
this.pos += b.length;
};
BlrWriter.prototype.addString2 = function (c, s, encoding) {
this.addByte(c);
var len = Buffer.byteLength(s, encoding);
if (len > MAX_STRING_SIZE* MAX_STRING_SIZE)
BlrWriter.prototype.addString2 = function(c, s, encoding) {
this.addByte(c);
var len = Buffer.byteLength(s, encoding);
if (len > MAX_STRING_SIZE * MAX_STRING_SIZE)
throw new Error('blr string is too big');
this.ensure(len + 2);
this.buffer.writeUInt16LE(len, this.pos);
this.pos += 2;
this.buffer.write(s, this.pos, s.length, encoding);
this.pos += len;
this.ensure(len + 2);
this.buffer.writeUInt16LE(len, this.pos);
this.pos += 2;
this.buffer.write(s, this.pos, s.length, encoding);
this.pos += len;
};
BlrWriter.prototype.addBuffer = function (b) {
this.addSmall(b.length);
this.ensure(b.length);
b.copy(this.buffer, this.pos);
this.pos += b.length;
BlrWriter.prototype.addBuffer = function(b) {
this.addSmall(b.length);
this.ensure(b.length);
b.copy(this.buffer, this.pos);
this.pos += b.length;
};

@@ -142,46 +142,46 @@

var BlrReader = exports.BlrReader = function(buffer) {
this.buffer = buffer;
this.pos = 0;
this.buffer = buffer;
this.pos = 0;
};
BlrReader.prototype.readByteCode = function(){
return this.buffer.readUInt8(this.pos++);
BlrReader.prototype.readByteCode = function() {
return this.buffer.readUInt8(this.pos++);
};
BlrReader.prototype.readInt32 = function () {
var value = this.buffer.readUInt32LE(this.pos);
this.pos += 4;
return value;
}
BlrReader.prototype.readInt32 = function() {
var value = this.buffer.readUInt32LE(this.pos);
this.pos += 4;
return value;
};
BlrReader.prototype.readInt = function(){
var len = this.buffer.readUInt16LE(this.pos);
this.pos += 2;
var value;
switch (len) {
case 1:
value = this.buffer.readInt8(this.pos);
break;
case 2:
value = this.buffer.readInt16LE(this.pos);
break;
case 4:
value = this.buffer.readInt32LE(this.pos)
}
this.pos += len;
return value;
BlrReader.prototype.readInt = function() {
var len = this.buffer.readUInt16LE(this.pos);
this.pos += 2;
var value;
switch (len) {
case 1:
value = this.buffer.readInt8(this.pos);
break;
case 2:
value = this.buffer.readInt16LE(this.pos);
break;
case 4:
value = this.buffer.readInt32LE(this.pos);
}
this.pos += len;
return value;
};
BlrReader.prototype.readString = function(encoding){
BlrReader.prototype.readString = function(encoding) {
var len = this.buffer.readUInt16LE(this.pos);
var str;
var len = this.buffer.readUInt16LE(this.pos);
var str;
this.pos += 2;
if (len <= 0)
return '';
this.pos += 2;
if (len <= 0)
return '';
str = this.buffer.toString(encoding, this.pos, this.pos + len);
this.pos += len;
return str;
str = this.buffer.toString(encoding, this.pos, this.pos + len);
this.pos += len;
return str;
};

@@ -191,29 +191,30 @@

var ret, tmp;
var len = this.buffer.readUInt16LE(this.pos);
var ret;
var tmp;
var len = this.buffer.readUInt16LE(this.pos);
this.pos += 2;
this.pos += 2;
while (len > 0) {
while (len > 0) {
if (ret) {
tmp = ret;
ret = new Buffer(tmp.length + len);
tmp.copy(ret);
this.buffer.copy(ret, tmp.length, this.pos, this.pos + len);
} else {
ret = new Buffer(len);
this.buffer.copy(ret, 0, this.pos, this.pos + len);
}
if (ret) {
tmp = ret;
ret = new Buffer(tmp.length + len);
tmp.copy(ret);
this.buffer.copy(ret, tmp.length, this.pos, this.pos + len);
} else {
ret = new Buffer(len);
this.buffer.copy(ret, 0, this.pos, this.pos + len);
}
this.pos += len;
this.pos += len;
if (this.pos === this.buffer.length)
if (this.pos === this.buffer.length)
break;
len = this.buffer.readUInt16LE(this.pos);
this.pos += 2;
}
len = this.buffer.readUInt16LE(this.pos);
this.pos += 2;
}
return ret;
return ret;
};

@@ -227,87 +228,87 @@

var XdrWriter = exports.XdrWriter = function(size){
this.buffer = new Buffer(size || 32);
this.pos = 0;
var XdrWriter = exports.XdrWriter = function(size) {
this.buffer = new Buffer(size || 32);
this.pos = 0;
};
XdrWriter.prototype.ensure = BlrWriter.prototype.ensure = function (len) {
var newlen = this.buffer.length;
XdrWriter.prototype.ensure = BlrWriter.prototype.ensure = function(len) {
var newlen = this.buffer.length;
while (newlen < this.pos + len)
newlen *= 2
while (newlen < this.pos + len)
newlen *= 2;
if (this.buffer.length >= newlen)
if (this.buffer.length >= newlen)
return;
var b = new Buffer(newlen);
this.buffer.copy(b);
delete(this.buffer);
this.buffer = b;
var b = new Buffer(newlen);
this.buffer.copy(b);
delete(this.buffer);
this.buffer = b;
};
XdrWriter.prototype.addInt = function (value) {
this.ensure(4);
this.buffer.writeInt32BE(value, this.pos);
this.pos += 4;
XdrWriter.prototype.addInt = function(value) {
this.ensure(4);
this.buffer.writeInt32BE(value, this.pos);
this.pos += 4;
};
XdrWriter.prototype.addInt64 = function (value) {
this.ensure(8);
var l = Long.fromNumber(value);
this.buffer.writeInt32BE(l.high_, this.pos);
this.pos += 4;
this.buffer.writeInt32BE(l.low_, this.pos);
this.pos += 4;
XdrWriter.prototype.addInt64 = function(value) {
this.ensure(8);
var l = Long.fromNumber(value);
this.buffer.writeInt32BE(l.high_, this.pos);
this.pos += 4;
this.buffer.writeInt32BE(l.low_, this.pos);
this.pos += 4;
};
XdrWriter.prototype.addUInt = function (value) {
this.ensure(4);
this.buffer.writeUInt32BE(value, this.pos);
this.pos += 4;
XdrWriter.prototype.addUInt = function(value) {
this.ensure(4);
this.buffer.writeUInt32BE(value, this.pos);
this.pos += 4;
};
XdrWriter.prototype.addString = function(s, encoding) {
var len = Buffer.byteLength(s, encoding);
var alen = align(len);
this.ensure(alen + 4);
this.buffer.writeInt32BE(len, this.pos);
this.pos += 4;
this.buffer.write(s, this.pos, len, encoding);
this.pos += alen;
var len = Buffer.byteLength(s, encoding);
var alen = align(len);
this.ensure(alen + 4);
this.buffer.writeInt32BE(len, this.pos);
this.pos += 4;
this.buffer.write(s, this.pos, len, encoding);
this.pos += alen;
};
XdrWriter.prototype.addText = function(s, encoding) {
var len = Buffer.byteLength(s, encoding);
var alen = align(len);
this.ensure(alen);
this.buffer.write(s, this.pos, len, encoding);
this.pos += alen;
var len = Buffer.byteLength(s, encoding);
var alen = align(len);
this.ensure(alen);
this.buffer.write(s, this.pos, len, encoding);
this.pos += alen;
};
XdrWriter.prototype.addBlr = function(blr) {
var alen = align(blr.pos);
this.ensure(alen + 4);
this.buffer.writeInt32BE(blr.pos, this.pos);
this.pos += 4;
blr.buffer.copy(this.buffer, this.pos);
this.pos += alen;
var alen = align(blr.pos);
this.ensure(alen + 4);
this.buffer.writeInt32BE(blr.pos, this.pos);
this.pos += 4;
blr.buffer.copy(this.buffer, this.pos);
this.pos += alen;
};
XdrWriter.prototype.getData = function() {
return this.buffer.slice(0, this.pos);
return this.buffer.slice(0, this.pos);
};
XdrWriter.prototype.addDouble = function(value) {
this.ensure(8);
this.buffer.writeDoubleBE(value, this.pos);
this.pos += 8;
this.ensure(8);
this.buffer.writeDoubleBE(value, this.pos);
this.pos += 8;
};
XdrWriter.prototype.addQuad = function(quad) {
this.ensure(8);
var b = this.buffer;
b.writeInt32BE(quad.high, this.pos);
this.pos += 4;
b.writeInt32BE(quad.low, this.pos);
this.pos += 4;
this.ensure(8);
var b = this.buffer;
b.writeInt32BE(quad.high, this.pos);
this.pos += 4;
b.writeInt32BE(quad.low, this.pos);
this.pos += 4;
};

@@ -321,87 +322,87 @@

var XdrReader = exports.XdrReader = function(buffer){
this.buffer = buffer;
this.pos = 0;
var XdrReader = exports.XdrReader = function(buffer) {
this.buffer = buffer;
this.pos = 0;
};
XdrReader.prototype.readInt = function () {
var r = this.buffer.readInt32BE(this.pos);
this.pos += 4;
return r;
XdrReader.prototype.readInt = function() {
var r = this.buffer.readInt32BE(this.pos);
this.pos += 4;
return r;
};
XdrReader.prototype.readUInt = function () {
var r = this.buffer.readUInt32BE(this.pos);
this.pos += 4;
return r;
XdrReader.prototype.readUInt = function() {
var r = this.buffer.readUInt32BE(this.pos);
this.pos += 4;
return r;
};
XdrReader.prototype.readInt64 = function () {
var high = this.buffer.readInt32BE(this.pos);
this.pos += 4;
var low = this.buffer.readInt32BE(this.pos);
this.pos += 4;
return new Long(low, high).toNumber();
XdrReader.prototype.readInt64 = function() {
var high = this.buffer.readInt32BE(this.pos);
this.pos += 4;
var low = this.buffer.readInt32BE(this.pos);
this.pos += 4;
return new Long(low, high).toNumber();
};
XdrReader.prototype.readShort = function () {
var r = this.buffer.readInt16BE(this.pos);
this.pos += 2;
return r;
XdrReader.prototype.readShort = function() {
var r = this.buffer.readInt16BE(this.pos);
this.pos += 2;
return r;
};
XdrReader.prototype.readQuad = function () {
var b = this.buffer;
var high = b.readInt32BE(this.pos);
this.pos += 4;
var low = b.readInt32BE(this.pos);
this.pos += 4;
return {low: low, high: high}
XdrReader.prototype.readQuad = function() {
var b = this.buffer;
var high = b.readInt32BE(this.pos);
this.pos += 4;
var low = b.readInt32BE(this.pos);
this.pos += 4;
return {low: low, high: high};
};
XdrReader.prototype.readFloat = function () {
var r = this.buffer.readFloatBE(this.pos);
this.pos += 4;
return r;
XdrReader.prototype.readFloat = function() {
var r = this.buffer.readFloatBE(this.pos);
this.pos += 4;
return r;
};
XdrReader.prototype.readDouble = function () {
var r = this.buffer.readDoubleBE(this.pos);
this.pos += 8;
return r;
XdrReader.prototype.readDouble = function() {
var r = this.buffer.readDoubleBE(this.pos);
this.pos += 8;
return r;
};
XdrReader.prototype.readArray = function () {
var len = this.readInt();
if (!len)
return;
var r = this.buffer.slice(this.pos, this.pos + len);
this.pos += align(len);
return r;
XdrReader.prototype.readArray = function() {
var len = this.readInt();
if (!len)
return;
var r = this.buffer.slice(this.pos, this.pos + len);
this.pos += align(len);
return r;
};
XdrReader.prototype.readBuffer = function (len) {
if (!arguments.length)
XdrReader.prototype.readBuffer = function(len) {
if (!arguments.length)
len = this.readInt();
if (!len)
if (!len)
return;
var r = this.buffer.slice(this.pos, this.pos + len);
this.pos += align(len);
return r;
var r = this.buffer.slice(this.pos, this.pos + len);
this.pos += align(len);
return r;
};
XdrReader.prototype.readString = function (encoding) {
var len = this.readInt();
return this.readText(len, encoding);
XdrReader.prototype.readString = function(encoding) {
var len = this.readInt();
return this.readText(len, encoding);
};
XdrReader.prototype.readText = function (len, encoding) {
if (len <= 0)
XdrReader.prototype.readText = function(len, encoding) {
if (len <= 0)
return '';
var r = this.buffer.toString(encoding, this.pos, this.pos + len);
this.pos += align(len);
return r;
var r = this.buffer.toString(encoding, this.pos, this.pos + len);
this.pos += align(len);
return r;
};
{
"name": "node-firebird",
"version": "0.7.2",
"version": "0.7.3",
"description": "Pure JavaScript and Asynchronous Firebird client for Node.js.",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc