|
|
|
@ -474,7 +474,7 @@ Connection.prototype.parseT = function(msg) {
|
|
|
|
|
msg.fieldCount = this.parseInt16();
|
|
|
|
|
var fields = [];
|
|
|
|
|
for(var i = 0; i < msg.fieldCount; i++){
|
|
|
|
|
fields[i] = this.parseField();
|
|
|
|
|
fields.push(this.parseField());
|
|
|
|
|
}
|
|
|
|
|
msg.fields = fields;
|
|
|
|
|
return msg;
|
|
|
|
@ -498,7 +498,11 @@ Connection.prototype.parseD = function(msg) {
|
|
|
|
|
var fields = [];
|
|
|
|
|
for(var i = 0; i < fieldCount; i++) {
|
|
|
|
|
var length = this.parseInt32();
|
|
|
|
|
fields[i] = (length === -1 ? null : this.readBytes(length));
|
|
|
|
|
var value = null;
|
|
|
|
|
if(length !== -1) {
|
|
|
|
|
value = this.readBytes(length);
|
|
|
|
|
}
|
|
|
|
|
fields.push(value);
|
|
|
|
|
}
|
|
|
|
|
msg.fieldCount = fieldCount;
|
|
|
|
|
msg.fields = fields;
|
|
|
|
@ -553,49 +557,35 @@ Connection.prototype.parseA = function(msg) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Connection.prototype.parseGH = function (msg) {
|
|
|
|
|
msg.binary = Boolean(this.parseInt8());
|
|
|
|
|
var isBinary = this.buffer[this.offset] !== 0;
|
|
|
|
|
this.offset++;
|
|
|
|
|
msg.binary = isBinary;
|
|
|
|
|
var columnCount = this.parseInt16();
|
|
|
|
|
msg.columnTypes = [];
|
|
|
|
|
for(var i = 0; i<columnCount; i++) {
|
|
|
|
|
msg.columnTypes[i] = this.parseInt16();
|
|
|
|
|
msg.columnTypes.push(this.parseInt16());
|
|
|
|
|
}
|
|
|
|
|
return msg;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Connection.prototype.parseInt8 = function () {
|
|
|
|
|
var value = Number(this.buffer[this.offset]);
|
|
|
|
|
this.offset++;
|
|
|
|
|
return value;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Connection.prototype.readChar = function() {
|
|
|
|
|
return Buffer([this.buffer[this.offset++]]).toString(this.encoding);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Connection.prototype.parseInt32 = function() {
|
|
|
|
|
var value = this.peekInt32();
|
|
|
|
|
var value = this.buffer.readInt32BE(this.offset, true);
|
|
|
|
|
this.offset += 4;
|
|
|
|
|
return value;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Connection.prototype.peekInt32 = function(offset) {
|
|
|
|
|
offset = offset || this.offset;
|
|
|
|
|
var buffer = this.buffer;
|
|
|
|
|
return ((buffer[offset++] << 24) +
|
|
|
|
|
(buffer[offset++] << 16) +
|
|
|
|
|
(buffer[offset++] << 8) +
|
|
|
|
|
buffer[offset++]);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Connection.prototype.parseInt16 = function() {
|
|
|
|
|
return ((this.buffer[this.offset++] << 8) +
|
|
|
|
|
(this.buffer[this.offset++] << 0));
|
|
|
|
|
var value = this.buffer.readInt16BE(this.offset, true);
|
|
|
|
|
this.offset += 2;
|
|
|
|
|
return value;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Connection.prototype.readString = function(length) {
|
|
|
|
|
return this.buffer.toString(this.encoding, this.offset,
|
|
|
|
|
(this.offset += length));
|
|
|
|
|
return this.buffer.toString(this.encoding, this.offset, (this.offset += length));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Connection.prototype.readBytes = function(length) {
|
|
|
|
|