How to use the ref-napi.allocCString 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
// executed to clear the hConnsInUse flag.
  if (jsCno == null) {
    copyback = false;
    jsCno = new MQCNO.MQCNO();
  }
  if ((jsCno.Options & (MQC.MQCNO_HANDLE_SHARE_NO_BLOCK |
                       MQC.MQCNO_HANDLE_SHARE_BLOCK)) == 0) {
    jsCno.Options |= MQC.MQCNO_HANDLE_SHARE_BLOCK;
  }

  var mqCno = MQCNO._copyCNOtoC(jsCno);

  // Deal with empty or null qmgrName for default connection
  var mqqMgrName = ref.NULL_POINTER;
  if (jsqMgrName != null && jsqMgrName.length > 0) {
    mqqMgrName = ref.allocCString(jsqMgrName);
  }

  if (useAsync) {
    libmqm.MQCONNX.async(mqqMgrName,mqCno.ref(), mqHConn,mqCc,mqRc, function (error,resp) {

      var jsHConn = mqHConn.deref();
      var jsRc = mqRc.deref();
      var jsCc = mqCc.deref();

      if (copyback) {
        MQCNO._copyCNOfromC(mqCno,jsCno);
      }

      // If it did not work, create an MQError object with the reason codes,
      // otherwise invoke the callback with the hConn-containing object.
      var hConn = new MQQueueManager(jsHConn,jsqMgrName);
github ibm-messaging / mq-mqi-nodejs / lib / mqcno.js View on Github external
// If security options are provided, attach them to the CNO.
  var jscsp =  jscno.SecurityParms;
  if (jscsp != null) {
    if (!(jscsp instanceof MQCSP.MQCSP)) {
      throw new TypeError('Parameter must be of type MQCSP');
    }
    var mqcsp = MQCSP._newMQCSPffi();

    mqcsp.AuthenticationType = jscsp._authenticationType;
    if (jscsp.UserId != null) {
      mqcsp.CSPUserIdPtr = ref.allocCString(jscsp.UserId);
      mqcsp.CSPUserIdOffset = 0;
      mqcsp.CSPUserIdLength = jscsp.UserId.length;
    }
    if (jscsp.Password != null) {
      mqcsp.CSPPasswordPtr  = ref.allocCString(jscsp.Password);
      mqcsp.CSPPasswordOffset = 0;
      mqcsp.CSPPasswordLength = jscsp.Password.length;
    }

    mqcno.SecurityParmsPtr = mqcsp.ref();
    if (mqcno.Version < 5) {
      mqcno.Version = 5;
    }
  }

  if (jscno.CCDTUrl != null) {
    mqcno.CCDTUrlPtr    = ref.allocCString(jscno.CCDTUrl);
    mqcno.CCDTUrlOffset = 0;
    mqcno.CCDTUrlLength = jscno.CCDTUrl.length;
    if (mqcno.Version < 6) {
      mqcno.Version = 6;
github ibm-messaging / mq-mqi-nodejs / lib / mqcno.js View on Github external
if (mqcno.Version < 4) {
      mqcno.Version = 4;
    }
  }

  // If security options are provided, attach them to the CNO.
  var jscsp =  jscno.SecurityParms;
  if (jscsp != null) {
    if (!(jscsp instanceof MQCSP.MQCSP)) {
      throw new TypeError('Parameter must be of type MQCSP');
    }
    var mqcsp = MQCSP._newMQCSPffi();

    mqcsp.AuthenticationType = jscsp._authenticationType;
    if (jscsp.UserId != null) {
      mqcsp.CSPUserIdPtr = ref.allocCString(jscsp.UserId);
      mqcsp.CSPUserIdOffset = 0;
      mqcsp.CSPUserIdLength = jscsp.UserId.length;
    }
    if (jscsp.Password != null) {
      mqcsp.CSPPasswordPtr  = ref.allocCString(jscsp.Password);
      mqcsp.CSPPasswordOffset = 0;
      mqcsp.CSPPasswordLength = jscsp.Password.length;
    }

    mqcno.SecurityParmsPtr = mqcsp.ref();
    if (mqcno.Version < 5) {
      mqcno.Version = 5;
    }
  }

  if (jscno.CCDTUrl != null) {
github ibm-messaging / mq-mqi-nodejs / lib / mqcd.js View on Github external
exports._copyCDtoC = function(jscd) {

  var mqcd = exports._newMQCDffi();

  u.setMQIString(mqcd.ChannelName, jscd.ChannelName);
  u.setMQIString(mqcd.ConnectionName, normaliseConnName(jscd.ConnectionName));
  mqcd.DiscInterval = jscd.DiscInterval;
  u.setMQIString(mqcd.SecurityExit, jscd.SecurityExit);
  u.setMQIString(mqcd.SecurityUserData, jscd.SecurityUserData);
  mqcd.MaxMsgLength = jscd.MaxMsgLength;
  mqcd.HeartbeatInterval = jscd.HeartbeatInterval;
  u.setMQIString(mqcd.SSLCipherSpec, jscd.SSLCipherSpec);
  if (jscd.SSLPeerName != null) {
          mqcd.SSLPeerNamePtr = ref.allocCString(jscd.SSLPeerName);
          mqcd.SSLPeerNameLength = jscd.SSLPeerName.length;
  }
  mqcd.SSLClientAuth = jscd.SSLClientAuth;
  mqcd.KeepAliveInterval = jscd.KeepAliveInterval;
  mqcd.SharingConversations = jscd.SharingConversations;
  mqcd.PropertyControl = jscd.PropertyControl;
  mqcd.ClientChannelWeight = jscd.ClientChannelWeight;
  mqcd.ConnectionAffinity = jscd.ConnectionAffinity;
  mqcd.DefReconnect = jscd.DefReconnect;
  u.setMQIString(mqcd.CertificateLabel, jscd.CertificateLabel);

  return mqcd;
};
github ibm-messaging / mq-mqi-nodejs / lib / mqcno.js View on Github external
mqcsp.CSPUserIdLength = jscsp.UserId.length;
    }
    if (jscsp.Password != null) {
      mqcsp.CSPPasswordPtr  = ref.allocCString(jscsp.Password);
      mqcsp.CSPPasswordOffset = 0;
      mqcsp.CSPPasswordLength = jscsp.Password.length;
    }

    mqcno.SecurityParmsPtr = mqcsp.ref();
    if (mqcno.Version < 5) {
      mqcno.Version = 5;
    }
  }

  if (jscno.CCDTUrl != null) {
    mqcno.CCDTUrlPtr    = ref.allocCString(jscno.CCDTUrl);
    mqcno.CCDTUrlOffset = 0;
    mqcno.CCDTUrlLength = jscno.CCDTUrl.length;
    if (mqcno.Version < 6) {
      mqcno.Version = 6;
    }
  }

  if (jscno.ApplName != null) {
    u.setMQIString(mqcno.ApplName, jscno.ApplName);
    if (mqcno.Version < 7) {
      mqcno.Version = 7;
    }
  }

  return mqcno;
};