Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function put1Internal() {
if (isLocked(jsQueueManager._hConn)) {
return setImmediate(put1Internal);
} else {
lock(jsQueueManager._hConn);
}
var mqRc = ref.alloc(MQT.LONG);
var mqCc = ref.alloc(MQT.LONG);
var mqMd = MQMD._copyMDtoC(jsmd);
var mqOd = MQOD._copyODtoC(jsod);
var mqPmo = MQPMO._copyPMOtoC(jspmo);
// If it's a string, then we need to create a Buffer from it.
// We also set the MQMD Format
// TODO: Are there any string codepage conversions we should look at here?
if (buf) {
if (typeof buf == "string") {
buf = Buffer.from(buf);
u.setMQIString(mqMd.Format,"MQSTR");
} else {
checkParam(buf,Buffer,'Buffer');
}
}
function putInternal() {
if (isLocked(jsObject._mqQueueManager._hConn)) {
return setImmediate(putInternal);
} else {
lock(jsObject._mqQueueManager._hConn);
}
var mqRc = ref.alloc(MQT.LONG);
var mqCc = ref.alloc(MQT.LONG);
var mqMd = MQMD._copyMDtoC(jsmd);
var mqPmo = MQPMO._copyPMOtoC(jspmo);
// If it's a string, then we need to create a Buffer from it.
// We also set the MQMD Format
// TODO: Are there any string codepage conversions we should look at here?
// Do we need to set the CCSID in some way?
if (buf) {
if (typeof buf == "string") {
buf = Buffer.from(buf);
u.setMQIString(mqMd.Format,"MQSTR");
} else {
checkParam(buf,Buffer,'Buffer');
}
}
function openInternal () {
// check if hConn is already being used
if (isLocked(jsQueueManager._hConn)) {
return setImmediate(openInternal);
} else {
lock(jsQueueManager._hConn);
}
var mqHObj = ref.alloc(MQT.HOBJ);
var mqRc = ref.alloc(MQT.LONG);
var mqCc = ref.alloc(MQT.LONG);
var mqOd = MQOD._copyODtoC(jsod);
var err;
if (useAsync) {
libmqm.MQOPEN.async(jsQueueManager._hConn,mqOd.ref(),jsOpenOptions,mqHObj,mqCc,mqRc, function(error,resp) {
unlock(jsQueueManager._hConn);
MQOD._copyODfromC(mqOd,jsod);
var jsHObj = mqHObj.deref();
var jsRc = mqRc.deref();
var jsCc = mqCc.deref();
var jsObject = new MQObject(jsHObj,jsQueueManager,jsod.ObjectName);
err = new MQError(jsCc,jsRc,"OPEN");
exports.Inq = function(jsObject,jsSelectors,cb) {
checkParamCB(cb);
checkParam(jsObject, MQObject, 'MQObject',true);
checkArray(jsSelectors);
var mqRc = ref.alloc(MQT.LONG);
var mqCc = ref.alloc(MQT.LONG);
var jsRc;
var jsCc;
var i;
var charAttrLen = 0;
var charLen;
var badSelector = false;
var selector;
var mqSelectors = new mqLongArray(jsSelectors.length);
for (i=0;i= MQC.MQIA_FIRST && selector <= MQC.MQIA_LAST) {
// Do nothing.
} else if (selector >= MQC.MQCA_FIRST && selector <= MQC.MQCA_LAST) {
exports.SetMp = function(jsQueueManager,jsHMsg,jssmpo,name,jspd,value,cb) {
checkParamCB(cb);
checkParam(jsQueueManager, MQQueueManager, 'MQQueueManager');
checkParam(jssmpo, MQMPO.MQSMPO, 'MQSMPO');
checkParam(jspd , MQMPO.MQPD , 'MQPD');
checkParam(name, 'string', 'string');
var mqHMsg = jsHMsg;
var mqRc = ref.alloc(MQT.LONG);
var mqCc = ref.alloc(MQT.LONG);
var mqSmpo = MQMPO._copySMPOtoC(jssmpo);
var mqPd = MQMPO._copyPDtoC(jspd);
var vsName = new MQT.CHARV();
var ptr;
var len;
var type;
u.defaultCharV(vsName);
u.setMQICharV(vsName,name);
// TODO: Handle all the possible MQTYPE values including FLOAT and
// different sized ints
if (typeof value == 'string') {
ptr = Buffer.from(value,'utf8');
len = value.length;
exports.Cmit = function(jsQueueManager, cb) {
checkParamCB(cb);
checkParam(jsQueueManager, MQQueueManager, 'MQQueueManager');
var mqRc = ref.alloc(MQT.LONG);
var mqCc = ref.alloc(MQT.LONG);
libmqm.MQCMIT(jsQueueManager._hConn,mqCc,mqRc);
var jsRc = mqRc.deref();
var jsCc = mqCc.deref();
var err = new MQError(jsCc,jsRc,"CMIT");
if (cb) {
if (jsCc != MQC.MQCC_OK) {
cb(err);
} else {
cb(null);
}
} else {
if (jsCc != MQC.MQCC_OK) {
exports.GetSync = function(jsObject,jsmd,jsgmo,buf,cb) {
checkParamCB(cb);
checkParam(jsObject,MQObject, 'MQObject');
checkParam(jsmd, MQMD.MQMD, 'MQMD');
checkParam(jsgmo, MQGMO.MQGMO, 'MQGMO');
checkParam(buf,Buffer,'Buffer');
var mqRc = ref.alloc(MQT.LONG);
var mqCc = ref.alloc(MQT.LONG);
var datalen = ref.alloc(MQT.LONG);
var mqMd = MQMD._copyMDtoC(jsmd);
var mqGmo = MQGMO._copyGMOtoC(jsgmo);
var bufflen = 0;
var ptr = ref.NULL_POINTER;
if (buf) {
bufflen = buf.length;
}
if (bufflen > 0) {
ptr = buf;
}
exports.Stat = function(jsQueueManager, jsType, cb) {
checkParamCB(cb);
checkParam(jsQueueManager, MQQueueManager, 'MQQueueManager');
checkParam(jsType,'number','number');
var jsRc = MQC.MQCC_OK;
var jsCc = MQC.MQRC_NONE;
var mqRc = ref.alloc(MQT.LONG);
var mqCc = ref.alloc(MQT.LONG);
var jssts = new MQSTS.MQSTS();
var mqsts = MQSTS._copySTStoC(jssts);
libmqm.MQSTAT(jsQueueManager._hConn,jsType,mqsts.ref(), mqCc,mqRc);
jsRc = mqRc.deref();
jsCc = mqCc.deref();
if (jsCc == MQC.MQCC_OK) {
MQSTS._copySTSfromC(mqsts,jssts);
}
var err = new MQError(jsCc,jsRc,"STAT");
if (cb) {
function sub(jsQueueManager,jsQueueObject,jssd,useAsync,cb) {
checkParam(jsQueueManager, MQQueueManager, 'MQQueueManager');
checkParamRequired(jsQueueObject, MQObject,'MQObject',false);
checkParam(jssd, MQSD.MQSD, 'MQSD');
var jsHObjQ = MQC.MQHO_UNUSABLE_HOBJ;
if (jsQueueObject) {
jsHObjQ = jsQueueObject._jshObj;
}
var mqRc = ref.alloc(MQT.LONG);
var mqCc = ref.alloc(MQT.LONG);
var mqHObjQ = ref.alloc(MQT.HOBJ, jsHObjQ);
var mqHObjSub = ref.alloc(MQT.HOBJ);
subInternal();
function subInternal() {
if (isLocked(jsQueueManager._hConn)) {
return setImmediate(subInternal);
} else {
lock(jsQueueManager._hConn);
}
var mqSd = MQSD._copySDtoC(jssd);
if (useAsync) {
libmqm.MQSUB.async(jsQueueManager._hConn,
mqSd.ref(),
mqHObjQ,
mqHObjSub,
function sub(jsQueueManager,jsQueueObject,jssd,useAsync,cb) {
checkParam(jsQueueManager, MQQueueManager, 'MQQueueManager');
checkParamRequired(jsQueueObject, MQObject,'MQObject',false);
checkParam(jssd, MQSD.MQSD, 'MQSD');
var jsHObjQ = MQC.MQHO_UNUSABLE_HOBJ;
if (jsQueueObject) {
jsHObjQ = jsQueueObject._jshObj;
}
var mqRc = ref.alloc(MQT.LONG);
var mqCc = ref.alloc(MQT.LONG);
var mqHObjQ = ref.alloc(MQT.HOBJ, jsHObjQ);
var mqHObjSub = ref.alloc(MQT.HOBJ);
subInternal();
function subInternal() {
if (isLocked(jsQueueManager._hConn)) {
return setImmediate(subInternal);
} else {
lock(jsQueueManager._hConn);
}
var mqSd = MQSD._copySDtoC(jssd);
if (useAsync) {
libmqm.MQSUB.async(jsQueueManager._hConn,
mqSd.ref(),
mqHObjQ,
mqHObjSub,
mqCc,