Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_load_ngshared_lib(path) {
// judge platform and search for lib
try {
return ffi.Library(path, struct.methods_structure);
} catch (e) {
throw Error(`cannot open ${path} for ngspice shared library, due to error: ${e}`);
}
}
// _load_ngshared_lib() ends
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
var ffi = require('ffi');
// Create the interface to the wiringPi interface
var pi = ffi.Library('libwiringPi', {
wiringPiI2CSetup: [ 'int', [ 'int' ] ],
wiringPiI2CRead: [ 'int', [ 'int' ] ],
wiringPiI2CWrite: [ 'int', [ 'int', 'int' ] ],
wiringPiI2CWriteReg8: [ 'int', [ 'int', 'int', 'int' ] ],
wiringPiI2CWriteReg16: [ 'int', [ 'int', 'int', 'int' ] ],
wiringPiI2CReadReg8: [ 'int', [ 'int', 'int' ] ],
wiringPiI2CReadReg16: [ 'int', [ 'int', 'int' ] ]
});
module.exports = I2C;
function I2C(address) {
if (typeof address != 'number') {
throw new Error('Invalid I2C address "' + address + '". Addresses must be a number');
}
var fd = pi.wiringPiI2CSetup(address);
var FFI = require('ffi')
var ArrayType = require('ref-array')
var Struct = require('ref-struct')
var Union = require('ref-union');
var ref = require('ref')
var voit = exports.voit = ref.types.void
var int32 = exports.int32 = ref.types.int32
FFI.Library(process.platform == 'win32' ? 'SDL2' : 'libSDL2', {
SDLTest_ResetAssertSummary: [ voit, [ ] ],
SDLTest_LogAssertSummary: [ voit, [ ] ],
SDLTest_AssertSummaryToTestResult: [ int32, [ ] ],
}, exports)
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
var ffi = require('ffi');
var pi;
try {
pi = ffi.Library('libwiringPi', {
wiringPiSetup: [ 'int', [] ],
piBoardRev: [ 'int', [] ]
});
pi.wiringPiSetup();
} catch(e) {
console.error('Wiring PI is not installed. Please install it from http://wiringpi.com/');
process.exit(1);
}
module.exports = {
GPIO: require('./gpio'),
I2C: require('./i2c'),
PWM: require('./pwm'),
SPI: require('./spi'),
UART: require('./uart'),
getBoardRev: function getBoardRev() {
var ffi = require('ffi');
var process = require('process')
var isWin = /^win/.test(process.platform);
module.exports = ffi.Library('rust/target/release/'+(!isWin?'lib':'')+'embed', {
fibonacci: ['int', ['int']]
});
var FFI = require('ffi')
var ArrayType = require('ref-array')
var Struct = require('ref-struct')
var Union = require('ref-union');
var ref = require('ref')
var voit = exports.voit = ref.types.void
FFI.Library(process.platform == 'win32' ? 'SDL2' : 'libSDL2', {
}, exports)
var FFI = require('ffi')
var ArrayType = require('ref-array')
var Struct = require('ref-struct')
var Union = require('ref-union');
var ref = require('ref')
var voit = exports.voit = ref.types.void
FFI.Library(process.platform == 'win32' ? 'SDL2' : 'libSDL2', {
}, exports)
var FFI = require('ffi')
var ArrayType = require('ref-array')
var Struct = require('ref-struct')
var Union = require('ref-union');
var ref = require('ref')
var voit = exports.voit = ref.types.void
FFI.Library(process.platform == 'win32' ? 'SDL2' : 'libSDL2', {
}, exports)
var FFI = require('ffi')
var ArrayType = require('ref-array')
var Struct = require('ref-struct')
var Union = require('ref-union');
var ref = require('ref')
var voit = exports.voit = ref.types.void
FFI.Library(process.platform == 'win32' ? 'SDL2' : 'libSDL2', {
}, exports)
this.load = function(libPath) {
api = ffi.Library(path.resolve(libPath, process.platform === 'win32' ? 'safe_ffi' : 'libsafe_ffi'), {
'create_sub_directory': ['int', ['string', 'bool']],
'create_file': ['int', ['string', IntArray, 'int']],
'register_dns': ['int', ['string', 'string', 'string']]
});
};