Skip to content

Instantly share code, notes, and snippets.

@orlandov
Created October 15, 2010 23:53
Show Gist options
  • Select an option

  • Save orlandov/629168 to your computer and use it in GitHub Desktop.

Select an option

Save orlandov/629168 to your computer and use it in GitHub Desktop.
Using OS zone functions from Node with node-ffi
FFI = require('./node-ffi/node-ffi');
var Zone = new FFI.Library("libc", {
// ssize_t getzonenamebyid(zoneid_t id, char *buf, size_t buflen)
"getzonenamebyid": [ "int32", [ "int32", 'pointer', "uint32" ] ],
"getzoneid": [ "int32", [] ],
"getzoneidbyname": [ "int32", [ 'string' ] ]
});
var str = new FFI.Pointer(64);
ZONENAME_MAX = 64;
var ret = Zone.getzonenamebyid(1183, str, 64);
console.log("Zone id by name " + Zone.getzoneidbyname("orlandozone0"));
console.log("This zone id " + Zone.getzoneid());
console.log("zone name " + str.getCString());
console.log("Return value was " + ret);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment