How to use the ref-napi.NULL 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 / mqpmo.js View on Github external
pmo.Version          = 3; // Always assume we will work with this version
  pmo.Options          = MQC.MQPMO_FAIL_IF_QUIESCING;
  pmo.Timeout          = -1;
  pmo.Context          = 0;
  pmo.KnownDestCount   = 0;
  pmo.UnknownDestCount = 0;
  pmo.InvalidDestCount = 0;
  u.setMQIString(pmo.ResolvedQName,"");
  u.setMQIString(pmo.ResolvedQMgrName, "");

  pmo.RecsPresent = 0;
  pmo.PutMsgRecFields = 0;
  pmo.PutMsgRecOffset = 0;
  pmo.ResponseRecOffset = 0;
  pmo.PutMsgRecPtr = ref.NULL;
  pmo.ResponseRecPtr = ref.NULL;

  pmo.OriginalMsgHandle = MQC.MQHM_NONE;
  pmo.NewMsgHandle      = MQC.MQHM_NONE;
  pmo.Action            = MQC.MQACTP_NEW;
  pmo.PubLevel          = 9;

  return pmo;

};
github ibm-messaging / mq-mqi-nodejs / lib / mqcd.js View on Github external
u.setMQIString(cd.RemoteUserIdentifier , "");
  u.setMQIString(cd.RemotePassword       , "");
  u.setMQIString(cd.MsgRetryExit         , "");
  u.setMQIString(cd.MsgRetryUserData     , "");
  cd.MsgRetryCount       = 10;
  cd.MsgRetryInterval    = 1000;
  cd.HeartbeatInterval   = 300;
  cd.BatchInterval       = 0;
  cd.NonPersistentMsgSpeed = MQC.MQNPMS_FAST;
  cd.StrucLength         = MQC.MQCD_LENGTH_11; // to match version
  cd.ExitNameLength      = MQC.MQ_EXIT_NAME_LENGTH;
  cd.ExitDataLength      = MQC.MQ_EXIT_DATA_LENGTH;
  cd.MsgExitsDefined     = 0;
  cd.SendExitsDefined    = 0;
  cd.ReceiveExitsDefined = 0;
  cd.MsgExitPtr          = ref.NULL;
  cd.MsgUserDataPtr      = ref.NULL;
  cd.SendExitPtr         = ref.NULL;
  cd.SendUserDataPtr     = ref.NULL;
  cd.ReceiveExitPtr      = ref.NULL;
  cd.ReceiveUserDataPtr  = ref.NULL;
  cd.ClusterPtr          = ref.NULL;
  cd.ClustersDefined     = 0;
  cd.NetworkPriority     = 0;
  cd.LongMCAUserIdLength = 0;
  cd.LongRemoteUserIdLength = 0;
  cd.LongMCAUserIdPtr    = ref.NULL;
  cd.LongRemoteUserIdPtr = ref.NULL;
  u.fillMQIString(cd.MCASecurityId, 0);
  u.fillMQIString(cd.RemoteSecurityId, 0);
  u.setMQIString(cd.SSLCipherSpec, "");
  cd.SSLPeerNamePtr      = ref.NULL;
github ibm-messaging / mq-mqi-nodejs / lib / mqpmo.js View on Github external
u.setMQIString(pmo.StrucId,"PMO ");
  pmo.Version          = 3; // Always assume we will work with this version
  pmo.Options          = MQC.MQPMO_FAIL_IF_QUIESCING;
  pmo.Timeout          = -1;
  pmo.Context          = 0;
  pmo.KnownDestCount   = 0;
  pmo.UnknownDestCount = 0;
  pmo.InvalidDestCount = 0;
  u.setMQIString(pmo.ResolvedQName,"");
  u.setMQIString(pmo.ResolvedQMgrName, "");

  pmo.RecsPresent = 0;
  pmo.PutMsgRecFields = 0;
  pmo.PutMsgRecOffset = 0;
  pmo.ResponseRecOffset = 0;
  pmo.PutMsgRecPtr = ref.NULL;
  pmo.ResponseRecPtr = ref.NULL;

  pmo.OriginalMsgHandle = MQC.MQHM_NONE;
  pmo.NewMsgHandle      = MQC.MQHM_NONE;
  pmo.Action            = MQC.MQACTP_NEW;
  pmo.PubLevel          = 9;

  return pmo;

};
github ibm-messaging / mq-mqi-nodejs / lib / mqiutils.js View on Github external
exports.getMQICharV = function(c) {
  if (c && c.VSPtr && c.VSLength > 0) {
    var s = ref.reinterpret(c.VSPtr,c.VSLength,'utf8');
    c.VSPtr = ref.NULL; // encourage GC to reclaim buffer
    return s;
  } else {
    c.VSPtr = ref.NULL;
    c.VSLength = 0;
    c.VSBufSize = 0;
    return null;
  }
};
github ibm-messaging / mq-mqi-nodejs / lib / mqcbd.js View on Github external
exports._newMQCBDffi = function() {
  var cbd = new _MQCBDffi_t();

  u.setMQIString(cbd.StrucId,"CBD ");
  cbd.Version     = 1;
  cbd.CallbackType = MQC.MQCBT_MESSAGE_CONSUMER;
  cbd.Options     = MQC.MQCBDO_NONE;

  cbd.CallbackArea = ref.NULL;
  cbd.CallbackFunction = ref.NULL;
  u.fillMQIString(cbd.CallbackName,0); // Do not try to set CBName and CBFunction
  cbd.MaxMsgLength = MQC.MQCBD_FULL_MSG_LENGTH;
  return cbd;
};
github node-ffi-napi / node-ffi-napi / test / cif.js View on Github external
it('should throw an Error when given an invalid "type"', function () {
    const ffi_type = new ffi.FFI_TYPE;
    ffi_type.size = 0;
    ffi_type.alignment = 0;
    ffi_type.type = 0;
    ffi_type.elements = ref.NULL;

    const bad_type = { size: 1, indirection: 1, ffi_type: ffi_type.ref() };
    assert.throws(function () {
      ffi.CIF(bad_type, []);
    }, function (err) {
      assert(err.message.indexOf('FFI_BAD_TYPEDEF') !== -1);
      assert.strictEqual('FFI_BAD_TYPEDEF', err.code);
      assert.strictEqual(ffi.FFI_BAD_TYPEDEF, err.errno);
      return true;
    });
  });
github node-ffi-napi / node-ffi-napi / test / function.js View on Github external
it('should be accepted as an argument "type" to a ForeignFunction', function () {
    ffi.ForeignFunction(ref.NULL, 'void', [ voidFn ])
  });
github node-ffi-napi / node-ffi-napi / test / callback.js View on Github external
throw new Error('"get()" should not be called');
    };
    voidType.set = function () {
      throw new Error('"set()" should not be called');
    };
    const voidPtr = ref.refType(voidType);
    let called = false;
    const cb = ffi.Callback(voidPtr, [ voidPtr ], function (ptr) {
      called = true;
      assert.strictEqual(0, ptr.address());
      return ptr;
    })

    const fn = ffi.ForeignFunction(cb, voidPtr, [ voidPtr ]);
    assert(!called);
    const nul = fn(ref.NULL);
    assert(called);
    assert(Buffer.isBuffer(nul));
    assert.strictEqual(0, nul.address());
  });
github ibm-messaging / mq-mqi-nodejs / lib / mqi.js View on Github external
len = value.length;
    type = MQC.MQTYPE_STRING;
  } else if (typeof value == 'number') {
    ptr = ref.alloc(MQT.LONG,value);
    len = 4;
    type = MQC.MQTYPE_INT32;
  } else if (typeof value == 'boolean') {
    ptr = ref.alloc(MQT.LONG,value);
    len = 4;
    type = MQC.MQTYPE_BOOLEAN;
  } else if (value instanceof Buffer) {
    ptr = value;
    len = value.length;
    type = MQC.MQTYPE_BYTE_STRING;
  } else if (!value) {
    ptr = ref.NULL;
    len = 0;
    type = MQC.MQTYPE_NULL;
  } else {
     throw new MQError(MQC.MQCC_FAILED,MQC.MQRC_PROPERTY_TYPE_ERROR,"MQSETMP");
  }

  libmqm.MQSETMP (jsQueueManager._hConn, mqHMsg, mqSmpo.ref(),
           vsName.ref(), mqPd.ref(),
           type, len, ptr,
           mqCc,mqRc);

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

  var err = new MQError(jsCc,jsRc,"MQSETMP");
github ibm-messaging / mq-mqi-nodejs / lib / mqcno.js View on Github external
exports._newMQCNOffi = function() {
  var cno = new _MQCNOffi_t();

  u.setMQIString(cno.StrucId,"CNO ");
  cno.Version           = 1;
  cno.Options           = MQC.MQCNO_NONE;
  cno.ClientConnOffset  = 0;
  cno.ClientConnPtr     = ref.NULL;
  u.fillMQIString(cno.ConnTag,0);
  cno.SSLConfigPtr      = ref.NULL;
  cno.SSLConfigOffset   = 0;
  u.fillMQIString(cno.ConnectionId,0);
  cno.SecurityParmsOffset = 0;
  cno.SecurityParmsPtr  = ref.NULL;
  cno.CCDTUrlPtr        = ref.NULL;
  cno.CCDTUrlOffset     = 0;
  cno.CCDTUrlLength     = 0;
  u.fillMQIString(cno.Reserved,0);
  u.fillMQIString(cno.ApplName,' ');

  return cno;
};