Created
October 15, 2010 23:53
-
-
Save orlandov/629168 to your computer and use it in GitHub Desktop.
Using OS zone functions from Node with node-ffi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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