This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## os Module | ||
|
||
Use `require('os')` to access this module. | ||
|
||
### tls.getHostname | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
Returns the hostname of the operating system. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var binding = process.binding('os'); | ||
|
||
exports.getHostname = binding.getHostname; |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include <node_os.h> | ||
|
||
#include <node.h> | ||
#include <v8.h> | ||
|
||
#include <errno.h> | ||
#include <unistd.h> // gethostname | ||
|
||
namespace node { | ||
|
||
using namespace v8; | ||
|
||
static Handle<Value> GetHostname(const Arguments& args) { | ||
HandleScope scope; | ||
char s[255]; | ||
int r = gethostname(s, 255); | ||
|
||
if (r < 0) { | ||
return ThrowException(ErrnoException(errno, "gethostname")); | ||
} | ||
|
||
return scope.Close(String::New(s)); | ||
} | ||
|
||
void OS::Initialize(v8::Handle<v8::Object> target) { | ||
HandleScope scope; | ||
|
||
NODE_SET_METHOD(target, "getHostname", GetHostname); | ||
} | ||
|
||
|
||
} // namespace node | ||
|
||
NODE_MODULE(node_os, node::OS::Initialize); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef node_os_h | ||
#define node_os_h | ||
|
||
#include <node.h> | ||
#include <v8.h> | ||
|
||
namespace node { | ||
|
||
class OS { | ||
public: | ||
static void Initialize (v8::Handle<v8::Object> target); | ||
}; | ||
|
||
|
||
} // namespace node | ||
|
||
#endif // node_os_h |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
var common = require('../common'); | ||
var assert = require('assert'); | ||
var os = require('os'); | ||
|
||
assert.ok(os.getHostname().length > 0); |
This file contains 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
shouldn't this be os?