How to use the ref-napi.NULL_POINTER function in ref-napi

To help you get started, we’ve selected a few ref-napi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ibm-messaging / mq-mqi-nodejs / lib / mqi.js View on Github external
exports.Begin = function(jsQueueManager, cb) {
  checkParamCB(cb);
  checkParam(jsQueueManager, MQQueueManager, 'MQQueueManager');

  var mqRc = ref.alloc(MQT.LONG);
  var mqCc = ref.alloc(MQT.LONG);

  // The MQBO structure can be set to NULL as there are no
  // real options defined at the moment.
  libmqm.MQBEGIN(jsQueueManager._hConn,ref.NULL_POINTER,mqCc,mqRc);

  var jsRc = mqRc.deref();
  var jsCc = mqCc.deref();
  var err = new MQError(jsCc,jsRc,"BEGIN");

  if (cb) {
    if (jsCc != MQC.MQCC_OK) {
      cb(err);
    } else {
      cb(null);
    }
  } else {
    if (jsCc != MQC.MQCC_OK) {
      throw err;
    } else {
      return;
github ibm-messaging / mq-mqi-nodejs / lib / mqi.js View on Github external
//       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');
      }
    }

    var bufflen = 0;
    if (buf) {
      bufflen = buf.length;
    }

    var ptr = ref.NULL_POINTER;
    if (bufflen > 0) {
      ptr = buf;
    }

    if (useAsync) {

      libmqm.MQPUT.async(jsObject._mqQueueManager._hConn,
                   jsObject._hObj,
                   mqMd.ref(),
                   mqPmo.ref(),
                   bufflen,
                   ptr,
                   mqCc,
                   mqRc, function(error,resp) {
        unlock(jsObject._mqQueueManager._hConn);
github ibm-messaging / mq-mqi-nodejs / lib / mqi.js View on Github external
if (charLen > 0) {
        charAttrLen += charLen;
      } else {
        badSelector = true;
      }
    } else {
      badSelector = true;
    }
  }

  // Allocate an array of the same length as the selectors in case all
  // are requesting MQIA values. Not all of
  // this array may need to be used, but that's OK.
  var mqIntAttrs = new mqLongArray(jsSelectors.length);

  var ptr = ref.NULL_POINTER;
  if (charAttrLen > 0) {
    ptr = Buffer.alloc(charAttrLen);
  }

  if (!badSelector) {
    libmqm.MQINQ(jsObject._mqQueueManager._hConn, jsObject._hObj,
               mqSelectors.length, mqSelectors,
               mqIntAttrs.length,mqIntAttrs,
               charAttrLen,ptr,mqCc,mqRc);

    jsRc = mqRc.deref();
    jsCc = mqCc.deref();
  } else {
    jsRc = MQC.MQRC_BAD_SELECTOR;
    jsCc = MQC.MQCC_FAILED;
  }
github ibm-messaging / mq-mqi-nodejs / lib / mqi.js View on Github external
// 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');
      }
    }

    var bufflen = 0;
    if (buf) {
      bufflen = buf.length;
    }

    var ptr = ref.NULL_POINTER;
    if (bufflen > 0) {
      ptr = buf;
    }

    if (useAsync) {
      libmqm.MQPUT1.async(jsQueueManager._hConn,
                   mqOd.ref(),
                   mqMd.ref(),
                   mqPmo.ref(),
                   bufflen,
                   ptr,
                   mqCc,
                   mqRc, function(error,resp) {
        unlock(jsQueueManager._hConn);

        MQOD._copyODfromC(mqOd, jsod);
github ibm-messaging / mq-mqi-nodejs / lib / mqcno.js View on Github external
exports._copyCNOfromC = function(mqcno, jscno) {

  if (jscno != null) {
    var jscsp =  jscno.SecurityParms;
    if (jscsp != null) {
      jscsp.UserId   = null;
      jscsp.Password = null;
      mqcno.SecurityParmsPtr.CSPPasswordPtr = ref.NULL_POINTER;
    }
  }

  /* These fields are not exposed in the JS structure so
     do not need to be copied back.
     ...mqcno.ConnTag...
     ...mqcno.ConnectionId...
  */

   if (mqcno.SSLConfigPtr != null && jscno.SSLConfig != null) {
     MQSCO._copySCOfromC(mqcno.SSLConfigPtr,jscno.SSLConfig);
   }
   if (mqcno.ClientConnPtr != null && jscno.ClientConn != null)  {
     MQCD._copyCDfromC(mqcno.ClientConnPtr,jscno.ClientConn);
   }
github ibm-messaging / mq-mqi-nodejs / lib / mqi.js View on Github external
var mqMd = MQMD._copyMDtoC(jsmd);
     var mqGmo = MQGMO._copyGMOtoC(jsgmo);
     mqGmo.WaitInterval = 0; // Always do an immediate MQGET with no wait interval

     // Make sure that the GMO flags are suitable, regardless of the
     // original request by turning off some options.
     mqGmo.Options &= ~(MQC.MQGMO_WAIT | MQC.MQGMO_ACCEPT_TRUNCATED_MSG);

     // Resize the buffer if necessary from a previous attempt
     retryTruncation = false;
     if (c.buf == null || c.buf.length < c.bufSize) {
       c.buf = Buffer.alloc(c.bufSize);
     }
     var bufflen = 0;
     var ptr = ref.NULL_POINTER;
     if (c.buf) {
       bufflen = c.buf.length;
     }

     if (bufflen > 0) {
       ptr = c.buf;
     }

     libmqm.MQGET.async(c.object._mqQueueManager._hConn,
                   c.object._hObj,
                   mqMd.ref(), mqGmo.ref(),
                   bufflen, ptr, datalen,
                   mqCc, mqRc,
                   (error, resp) => {

       unlock(c.object._mqQueueManager._hConn);
github ibm-messaging / mq-mqi-nodejs / lib / mqcsp.js View on Github external
exports._newMQCSPffi = function() {
  var csp = new _MQCSPffi_t();

  u.setMQIString(csp.StrucId,"CSP ");
  csp.Version        = 1;
  csp.AuthenticationType = MQC.MQCSP_AUTH_NONE;
  u.fillMQIString(csp.Reserved1,0);
  csp.CSPUserIdPtr      = ref.NULL_POINTER;
  csp.CSPUserIdOffset   = 0;
  csp.CSPUserIdLength   = 0;
  u.fillMQIString(csp.Reserved2,0);
  csp.CSPPasswordPtr    = ref.NULL_POINTER;
  csp.CSPPasswordOffset = 0;
  csp.CSPPasswordLength = 0;

  return csp;
};
github ibm-messaging / mq-mqi-nodejs / lib / mqcsp.js View on Github external
exports._newMQCSPffi = function() {
  var csp = new _MQCSPffi_t();

  u.setMQIString(csp.StrucId,"CSP ");
  csp.Version        = 1;
  csp.AuthenticationType = MQC.MQCSP_AUTH_NONE;
  u.fillMQIString(csp.Reserved1,0);
  csp.CSPUserIdPtr      = ref.NULL_POINTER;
  csp.CSPUserIdOffset   = 0;
  csp.CSPUserIdLength   = 0;
  u.fillMQIString(csp.Reserved2,0);
  csp.CSPPasswordPtr    = ref.NULL_POINTER;
  csp.CSPPasswordOffset = 0;
  csp.CSPPasswordLength = 0;

  return csp;
};
github ibm-messaging / mq-mqi-nodejs / lib / mqsco.js View on Github external
exports._newMQSCOffi = function() {
  var sco = new _MQSCOffi_t();
  var i;

  u.setMQIString(sco.StrucId,"SCO ");
  sco.Version           = 5;
  u.setMQIString(sco.KeyRepository, "");
  u.setMQIString(sco.CryptoHardware, "");
  sco.AuthInfoRecCount  = 0;
  sco.AuthInfoRecOffset = 0;
  sco.AuthInfoRecPtr    = ref.NULL_POINTER;
  sco.KeyResetCount     = MQC.MQSCO_RESET_COUNT_DEFAULT;
  sco.FipsRequired      = MQC.MQSSL_FIPS_NO;
  sco.EncryptionPolicySuiteB[0] = MQC.MQ_SUITE_B_NONE;
  for (i = 1; i<4;i++) {
    sco.EncryptionPolicySuiteB[i] = MQC.MQ_SUITE_B_NOT_AVAILABLE;
  }
  sco.CertificateValPolicy = MQC.MQ_CERT_VAL_POLICY_DEFAULT;
  u.setMQIString(sco.CertificateLabel , "");
  return sco;
};
github ibm-messaging / mq-mqi-nodejs / lib / mqi.js View on Github external
mqSelectors[i] = selector;
    if (selector >= MQC.MQIA_FIRST && selector <= MQC.MQIA_LAST) {
      mqIntAttrs[mqIntAttrsLen++] = jsSelectors[i].value;
    } else if (selector >= MQC.MQCA_FIRST && selector <= MQC.MQCA_LAST) {
      var charLen = mqcaLen(selector);
      if (charLen > 0) {
        charAttr = charAttr + (jsSelectors[i].value + padding256).slice(0,charLen);
      } else {
        badSelector = true;
      }
    } else {
      badSelector = true;
    }
  }

  var ptr = ref.NULL_POINTER;
  if (charAttr != "") {
    charAttrLen = charAttr.length;
    ptr = Buffer.from(charAttr);
  }

  if (!badSelector) {
    libmqm.MQSET(jsObject._mqQueueManager._hConn, jsObject._hObj,
               mqSelectors.length, mqSelectors,
               mqIntAttrsLen,mqIntAttrs,
               charAttrLen,ptr,mqCc,mqRc);

    jsRc = mqRc.deref();
    jsCc = mqCc.deref();
  } else {
    jsRc = MQC.MQRC_SELECTOR_ERROR;
    jsCc = MQC.MQCC_FAILED;