Skip to content
Browse files

src: lint c++ code

  • Loading branch information...
1 parent 3c6b5d5 commit 8e29ce9f13f7e4b6c0296325287c05f78ff22ce0 @indutny indutny committed
Showing with 964 additions and 875 deletions.
  1. +22 −19 src/cares_wrap.cc
  2. +7 −11 src/fs_event_wrap.cc
  3. +8 −8 src/handle_wrap.h
  4. +52 −63 src/node.cc
  5. +2 −2 src/node.h
  6. +0 −2 src/node_buffer.cc
  7. +3 −5 src/node_buffer.h
  8. +171 −161 src/node_constants.cc
  9. +3 −3 src/node_constants.h
  10. +3 −2 src/node_counters.cc
  11. +4 −4 src/node_counters.h
  12. +139 −132 src/node_crypto.cc
  13. +12 −13 src/node_crypto.h
  14. +44 −44 src/node_crypto_bio.cc
  15. +6 −1 src/node_crypto_bio.h
  16. +25 −0 src/node_crypto_groups.h
  17. +1 −1 src/node_dtrace.cc
  18. +19 −20 src/node_dtrace.h
  19. +5 −5 src/node_extensions.cc
  20. +34 −23 src/node_extensions.h
  21. +10 −10 src/node_file.cc
  22. +4 −3 src/node_file.h
  23. +9 −10 src/node_http_parser.cc
  24. +4 −4 src/node_http_parser.h
  25. +24 −18 src/node_internals.h
  26. +8 −4 src/node_javascript.cc
  27. +5 −0 src/node_javascript.h
  28. +7 −7 src/node_object_wrap.h
  29. +16 −12 src/node_os.cc
  30. +5 −6 src/node_os.h
  31. +2 −3 src/node_script.cc
  32. +5 −5 src/node_script.h
  33. +3 −5 src/node_stat_watcher.cc
  34. +3 −3 src/node_stat_watcher.h
  35. +5 −4 src/node_version.h
  36. +1 −4 src/node_watchdog.cc
  37. +1 −1 src/node_watchdog.h
  38. +17 −11 src/node_win32_etw_provider-inl.h
  39. +1 −3 src/node_win32_etw_provider.cc
  40. +7 −8 src/node_win32_etw_provider.h
  41. +12 −24 src/node_win32_perfctr_provider.cc
  42. +4 −5 src/node_win32_perfctr_provider.h
  43. +4 −4 src/node_wrap.h
  44. +15 −20 src/node_zlib.cc
  45. +10 −8 src/pipe_wrap.cc
  46. +3 −3 src/pipe_wrap.h
  47. +4 −4 src/process_wrap.cc
  48. +3 −3 src/queue.h
  49. +5 −5 src/req_wrap.h
  50. +1 −1 src/signal_wrap.cc
  51. +3 −4 src/smalloc.h
  52. +6 −6 src/stream_wrap.cc
  53. +5 −5 src/stream_wrap.h
  54. +2 −2 src/string_bytes.cc
  55. +10 −6 src/tcp_wrap.cc
  56. +4 −4 src/tcp_wrap.h
  57. +1 −1 src/timer_wrap.cc
  58. +114 −114 src/tls_wrap.cc
  59. +3 −1 src/tty_wrap.cc
  60. +4 −4 src/tty_wrap.h
  61. +3 −3 src/udp_wrap.cc
  62. +26 −5 src/udp_wrap.h
  63. +25 −3 src/v8abbr.h
View
41 src/cares_wrap.cc
@@ -42,7 +42,6 @@
namespace node {
-
namespace cares_wrap {
using v8::Array;
@@ -230,7 +229,7 @@ static Local<Array> HostentToNames(struct hostent* host) {
class QueryWrap {
public:
- QueryWrap(Local<Object> req_wrap_obj) {
+ explicit QueryWrap(Local<Object> req_wrap_obj) {
HandleScope scope(node_isolate);
persistent().Reset(node_isolate, req_wrap_obj);
}
@@ -333,7 +332,7 @@ class QueryWrap {
class QueryAWrap: public QueryWrap {
public:
- QueryAWrap(Local<Object> req_wrap_obj) : QueryWrap(req_wrap_obj) {
+ explicit QueryAWrap(Local<Object> req_wrap_obj) : QueryWrap(req_wrap_obj) {
}
int Send(const char* name) {
@@ -363,7 +362,7 @@ class QueryAWrap: public QueryWrap {
class QueryAaaaWrap: public QueryWrap {
public:
- QueryAaaaWrap(Local<Object> req_wrap_obj) : QueryWrap(req_wrap_obj) {
+ explicit QueryAaaaWrap(Local<Object> req_wrap_obj) : QueryWrap(req_wrap_obj) {
}
int Send(const char* name) {
@@ -398,7 +397,8 @@ class QueryAaaaWrap: public QueryWrap {
class QueryCnameWrap: public QueryWrap {
public:
- QueryCnameWrap(Local<Object> req_wrap_obj) : QueryWrap(req_wrap_obj) {
+ explicit QueryCnameWrap(Local<Object> req_wrap_obj)
+ : QueryWrap(req_wrap_obj) {
}
int Send(const char* name) {
@@ -436,7 +436,7 @@ class QueryCnameWrap: public QueryWrap {
class QueryMxWrap: public QueryWrap {
public:
- QueryMxWrap(Local<Object> req_wrap_obj) : QueryWrap(req_wrap_obj) {
+ explicit QueryMxWrap(Local<Object> req_wrap_obj) : QueryWrap(req_wrap_obj) {
}
int Send(const char* name) {
@@ -478,7 +478,7 @@ class QueryMxWrap: public QueryWrap {
class QueryNsWrap: public QueryWrap {
public:
- QueryNsWrap(Local<Object> req_wrap_obj) : QueryWrap(req_wrap_obj) {
+ explicit QueryNsWrap(Local<Object> req_wrap_obj) : QueryWrap(req_wrap_obj) {
}
int Send(const char* name) {
@@ -506,7 +506,7 @@ class QueryNsWrap: public QueryWrap {
class QueryTxtWrap: public QueryWrap {
public:
- QueryTxtWrap(Local<Object> req_wrap_obj) : QueryWrap(req_wrap_obj) {
+ explicit QueryTxtWrap(Local<Object> req_wrap_obj) : QueryWrap(req_wrap_obj) {
}
int Send(const char* name) {
@@ -541,7 +541,7 @@ class QueryTxtWrap: public QueryWrap {
class QuerySrvWrap: public QueryWrap {
public:
- QuerySrvWrap(Local<Object> req_wrap_obj) : QueryWrap(req_wrap_obj) {
+ explicit QuerySrvWrap(Local<Object> req_wrap_obj) : QueryWrap(req_wrap_obj) {
}
int Send(const char* name) {
@@ -593,7 +593,8 @@ class QuerySrvWrap: public QueryWrap {
class QueryNaptrWrap: public QueryWrap {
public:
- QueryNaptrWrap(Local<Object> req_wrap_obj) : QueryWrap(req_wrap_obj) {
+ explicit QueryNaptrWrap(Local<Object> req_wrap_obj)
+ : QueryWrap(req_wrap_obj) {
}
int Send(const char* name) {
@@ -630,7 +631,6 @@ class QueryNaptrWrap: public QueryWrap {
for (ares_naptr_reply* naptr_current = naptr_start;
naptr_current;
naptr_current = naptr_current->next) {
-
Local<Object> naptr_record = Object::New();
naptr_record->Set(flags_symbol,
@@ -658,7 +658,8 @@ class QueryNaptrWrap: public QueryWrap {
class GetHostByAddrWrap: public QueryWrap {
public:
- GetHostByAddrWrap(Local<Object> req_wrap_obj) : QueryWrap(req_wrap_obj) {
+ explicit GetHostByAddrWrap(Local<Object> req_wrap_obj)
+ : QueryWrap(req_wrap_obj) {
}
int Send(const char* name) {
@@ -695,7 +696,8 @@ class GetHostByAddrWrap: public QueryWrap {
class GetHostByNameWrap: public QueryWrap {
public:
- GetHostByNameWrap(Local<Object> req_wrap_obj) : QueryWrap(req_wrap_obj) {
+ explicit GetHostByNameWrap(Local<Object> req_wrap_obj)
+ : QueryWrap(req_wrap_obj) {
}
int Send(const char* name, int family) {
@@ -768,7 +770,8 @@ static void QueryWithFamily(const FunctionCallbackInfo<Value>& args) {
void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
HandleScope scope(node_isolate);
- GetAddrInfoReqWrap* req_wrap = (GetAddrInfoReqWrap*) req->data;
+ GetAddrInfoReqWrap* req_wrap =
+ reinterpret_cast<GetAddrInfoReqWrap*>(req->data);
Local<Value> argv[] = {
Integer::New(status, node_isolate),
@@ -802,7 +805,8 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
// Ignore random ai_family types.
if (address->ai_family == AF_INET) {
// Juggle pointers
- addr = (char*) &((struct sockaddr_in*) address->ai_addr)->sin_addr;
+ addr = reinterpret_cast<char*>(&(reinterpret_cast<struct sockaddr_in*>(
+ address->ai_addr)->sin_addr));
int err = uv_inet_ntop(address->ai_family,
addr,
ip,
@@ -828,7 +832,8 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
// Ignore random ai_family types.
if (address->ai_family == AF_INET6) {
// Juggle pointers
- addr = (char*) &((struct sockaddr_in6*) address->ai_addr)->sin6_addr;
+ addr = reinterpret_cast<char*>(&(reinterpret_cast<struct sockaddr_in6*>(
+ address->ai_addr)->sin6_addr));
int err = uv_inet_ntop(address->ai_family,
addr,
ip,
@@ -1075,9 +1080,7 @@ static void Initialize(Handle<Object> target) {
oncomplete_sym = String::New("oncomplete");
}
-
-} // namespace cares_wrap
-
+} // namespace cares_wrap
} // namespace node
NODE_MODULE(node_cares_wrap, node::cares_wrap::Initialize)
View
18 src/fs_event_wrap.cc
@@ -41,14 +41,14 @@ static Cached<String> onchange_sym;
static Cached<String> rename_sym;
class FSEventWrap: public HandleWrap {
-public:
+ public:
static void Initialize(Handle<Object> target);
static void New(const FunctionCallbackInfo<Value>& args);
static void Start(const FunctionCallbackInfo<Value>& args);
static void Close(const FunctionCallbackInfo<Value>& args);
-private:
- FSEventWrap(Handle<Object> object);
+ private:
+ explicit FSEventWrap(Handle<Object> object);
virtual ~FSEventWrap();
static void OnEvent(uv_fs_event_t* handle, const char* filename, int events,
@@ -147,14 +147,11 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename,
// unreasonable, right? Still, we should revisit this before v1.0.
if (status) {
eventStr = String::Empty(node_isolate);
- }
- else if (events & UV_RENAME) {
+ } else if (events & UV_RENAME) {
eventStr = rename_sym;
- }
- else if (events & UV_CHANGE) {
+ } else if (events & UV_CHANGE) {
eventStr = change_sym;
- }
- else {
+ } else {
assert(0 && "bad fs events flag");
abort();
}
@@ -190,7 +187,6 @@ void FSEventWrap::Close(const FunctionCallbackInfo<Value>& args) {
HandleWrap::Close(args);
}
-
-} // namespace node
+} // namespace node
NODE_MODULE(node_fs_event_wrap, node::FSEventWrap::Initialize)
View
16 src/handle_wrap.h
@@ -19,8 +19,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
-#ifndef HANDLE_WRAP_H_
-#define HANDLE_WRAP_H_
+#ifndef SRC_HANDLE_WRAP_H_
+#define SRC_HANDLE_WRAP_H_
#include "queue.h"
@@ -53,16 +53,16 @@ namespace node {
args.This()->GetAlignedPointerFromInternalField(0));
class HandleWrap {
-public:
+ public:
static void Initialize(v8::Handle<v8::Object> target);
static void Close(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Ref(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Unref(const v8::FunctionCallbackInfo<v8::Value>& args);
- inline uv_handle_t* GetHandle() { return handle__; };
+ inline uv_handle_t* GetHandle() { return handle__; }
-protected:
- HandleWrap(v8::Handle<v8::Object> object, uv_handle_t* handle);
+ protected:
+ explicit HandleWrap(v8::Handle<v8::Object> object, uv_handle_t* handle);
virtual ~HandleWrap();
inline v8::Local<v8::Object> object() {
@@ -73,7 +73,7 @@ class HandleWrap {
return object_;
}
-private:
+ private:
friend void GetActiveHandles(const v8::FunctionCallbackInfo<v8::Value>&);
static void OnClose(uv_handle_t* handle);
v8::Persistent<v8::Object> object_;
@@ -91,4 +91,4 @@ class HandleWrap {
} // namespace node
-#endif // HANDLE_WRAP_H_
+#endif // SRC_HANDLE_WRAP_H_
View
115 src/node.cc
@@ -80,12 +80,12 @@ typedef int mode_t;
#endif
#include "node_script.h"
-# ifdef __APPLE__
+#ifdef __APPLE__
# include <crt_externs.h>
# define environ (*_NSGetEnviron())
-# elif !defined(_MSC_VER)
+#elif !defined(_MSC_VER)
extern char **environ;
-# endif
+#endif
namespace node {
@@ -164,7 +164,7 @@ static char *eval_string = NULL;
static int option_end_index = 0;
static bool use_debug_agent = false;
static bool debug_wait_connect = false;
-static int debug_port=5858;
+static int debug_port = 5858;
static int max_stack_size = 0;
bool using_domains = false;
@@ -208,7 +208,7 @@ Isolate* node_isolate = NULL;
class ArrayBufferAllocator : public ArrayBuffer::Allocator {
-public:
+ public:
// Impose an upper limit to avoid out of memory errors that bring down
// the process.
static const size_t kMaxLength = 0x3fffffff;
@@ -216,7 +216,7 @@ class ArrayBufferAllocator : public ArrayBuffer::Allocator {
virtual ~ArrayBufferAllocator() {}
virtual void* Allocate(size_t length);
virtual void Free(void* data);
-private:
+ private:
ArrayBufferAllocator() {}
ArrayBufferAllocator(const ArrayBufferAllocator&);
void operator=(const ArrayBufferAllocator&);
@@ -260,7 +260,6 @@ static void IdleImmediateDummy(uv_idle_t* handle, int status) {
static inline const char *errno_string(int errorno) {
#define ERRNO_CASE(e) case e: return #e;
switch (errorno) {
-
#ifdef EACCES
ERRNO_CASE(EACCES);
#endif
@@ -585,7 +584,6 @@ static inline const char *errno_string(int errorno) {
const char *signo_string(int signo) {
#define SIGNO_CASE(e) case e: return #e;
switch (signo) {
-
#ifdef SIGHUP
SIGNO_CASE(SIGHUP);
#endif
@@ -823,7 +821,7 @@ Local<Value> UVException(int errorno,
Local<Object> obj = e->ToObject();
- // TODO errno should probably go
+ // TODO(piscisaureus) errno should probably go
obj->Set(errno_symbol, Integer::New(errorno, node_isolate));
obj->Set(code_symbol, estring);
if (path) obj->Set(errpath_symbol, path_str);
@@ -921,7 +919,7 @@ MakeDomainCallback(const Handle<Object> object,
const Handle<Function> callback,
int argc,
Handle<Value> argv[]) {
- // TODO Hook for long stack traces to be made here.
+ // TODO(trevnorris) Hook for long stack traces to be made here.
// lazy load domain specific symbols
if (enter_symbol.IsEmpty()) {
@@ -1003,7 +1001,7 @@ MakeCallback(const Handle<Object> object,
const Handle<Function> callback,
int argc,
Handle<Value> argv[]) {
- // TODO Hook for long stack traces to be made here.
+ // TODO(trevnorris) Hook for long stack traces to be made here.
Local<Object> process = PersistentToLocal(process_p);
if (using_domains)
@@ -1204,8 +1202,6 @@ void DisplayExceptionLine(Handle<Message> message) {
int start = message->GetStartColumn();
int end = message->GetEndColumn();
- // fprintf(stderr, "---\nsourceline:%s\noffset:%d\nstart:%d\nend:%d\n---\n", sourceline_string, start, end);
-
fprintf(stderr, "%s\n", sourceline_string);
// Print wavy underline (GetUnderline is deprecated).
for (int i = 0; i < start; i++) {
@@ -1252,7 +1248,7 @@ static void ReportException(Handle<Value> er, Handle<Message> message) {
}
-static void ReportException(TryCatch& try_catch) {
+static void ReportException(const TryCatch& try_catch) {
ReportException(try_catch.Exception(), try_catch.Message());
}
@@ -1371,13 +1367,11 @@ static void Umask(const FunctionCallbackInfo<Value>& args) {
if (args.Length() < 1 || args[0]->IsUndefined()) {
old = umask(0);
umask(static_cast<mode_t>(old));
-
- } else if(!args[0]->IsInt32() && !args[0]->IsString()) {
+ } else if (!args[0]->IsInt32() && !args[0]->IsString()) {
return ThrowTypeError("argument must be an integer or octal string.");
-
} else {
int oct;
- if(args[0]->IsInt32()) {
+ if (args[0]->IsInt32()) {
oct = args[0]->Uint32Value();
} else {
oct = 0;
@@ -1664,7 +1658,7 @@ static void InitGroups(const FunctionCallbackInfo<Value>& args) {
}
}
-#endif // __POSIX__ && !defined(__ANDROID__)
+#endif // __POSIX__ && !defined(__ANDROID__)
void Exit(const FunctionCallbackInfo<Value>& args) {
@@ -1773,8 +1767,8 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
return ThrowError("process.dlopen takes exactly 2 arguments.");
}
- Local<Object> module = args[0]->ToObject(); // Cast
- String::Utf8Value filename(args[1]); // Cast
+ Local<Object> module = args[0]->ToObject(); // Cast
+ String::Utf8Value filename(args[1]); // Cast
if (exports_symbol.IsEmpty()) {
exports_symbol = String::New("exports");
@@ -1786,7 +1780,7 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
#ifdef _WIN32
// Windows needs to add the filename into the error message
errmsg = String::Concat(errmsg, args[1]->ToString());
-#endif
+#endif // _WIN32
ThrowException(Exception::Error(errmsg));
return;
}
@@ -1800,7 +1794,7 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
if (pos != NULL) {
base = pos + 1;
}
-#else // Windows
+#else // Windows
for (;;) {
pos = strpbrk(base, "\\/:");
if (pos == NULL) {
@@ -1808,7 +1802,7 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
}
base = pos + 1;
}
-#endif
+#endif // __POSIX__
/* Strip the .node extension. */
pos = strrchr(base, '.');
@@ -1913,9 +1907,9 @@ void FatalException(Handle<Value> error, Handle<Message> message) {
}
-void FatalException(TryCatch& try_catch) {
+void FatalException(const TryCatch& try_catch) {
HandleScope scope(node_isolate);
- // TODO do not call FatalException if try_catch is verbose
+ // TODO(bajtos) do not call FatalException if try_catch is verbose
// (requires V8 API to expose getter for try_catch.is_verbose_)
FatalException(try_catch.Exception(), try_catch.Message());
}
@@ -1946,7 +1940,7 @@ static void Binding(const FunctionCallbackInfo<Value>& args) {
// Append a string to process.moduleLoadList
char buf[1024];
- snprintf(buf, 1024, "Binding %s", *module_v);
+ snprintf(buf, sizeof(buf), "Binding %s", *module_v);
Local<Array> modules = PersistentToLocal(module_load_list);
uint32_t l = modules->Length();
@@ -1958,19 +1952,15 @@ static void Binding(const FunctionCallbackInfo<Value>& args) {
// only exports.
modp->register_func(exports, Undefined(node_isolate));
cache->Set(module, exports);
-
} else if (!strcmp(*module_v, "constants")) {
exports = Object::New();
DefineConstants(exports);
cache->Set(module, exports);
-
} else if (!strcmp(*module_v, "natives")) {
exports = Object::New();
DefineJavaScript(exports);
cache->Set(module, exports);
-
} else {
-
return ThrowError("No such module");
}
@@ -1992,7 +1982,7 @@ static void ProcessTitleSetter(Local<String> property,
const PropertyCallbackInfo<void>& info) {
HandleScope scope(node_isolate);
String::Utf8Value title(value);
- // TODO: protect with a lock
+ // TODO(piscisaureus): protect with a lock
uv_set_process_title(*title);
}
@@ -2008,7 +1998,7 @@ static void EnvGetter(Local<String> property,
}
#else // _WIN32
String::Value key(property);
- WCHAR buffer[32767]; // The maximum size allowed for environment variables.
+ WCHAR buffer[32767]; // The maximum size allowed for environment variables.
DWORD result = GetEnvironmentVariableW(reinterpret_cast<WCHAR*>(*key),
buffer,
ARRAY_SIZE(buffer));
@@ -2142,16 +2132,17 @@ static Handle<Object> GetFeatures() {
HandleScope scope(node_isolate);
Local<Object> obj = Object::New();
- obj->Set(String::NewSymbol("debug"),
#if defined(DEBUG) && DEBUG
- True(node_isolate)
+ Local<Value> debug = True(node_isolate);
#else
- False(node_isolate)
-#endif
- );
+ Local<Value> debug = False(node_isolate);
+#endif // defined(DEBUG) && DEBUG
+
+ obj->Set(String::NewSymbol("debug"), debug);
obj->Set(String::NewSymbol("uv"), True(node_isolate));
- obj->Set(String::NewSymbol("ipv6"), True(node_isolate)); // TODO ping libuv
+ // TODO(bnoordhuis) ping libuv
+ obj->Set(String::NewSymbol("ipv6"), True(node_isolate));
obj->Set(String::NewSymbol("tls_npn"), Boolean::New(use_npn));
obj->Set(String::NewSymbol("tls_sni"), Boolean::New(use_sni));
obj->Set(String::NewSymbol("tls"),
@@ -2375,7 +2366,7 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
NODE_SET_METHOD(process, "getgroups", GetGroups);
NODE_SET_METHOD(process, "setgroups", SetGroups);
NODE_SET_METHOD(process, "initgroups", InitGroups);
-#endif // __POSIX__ && !defined(__ANDROID__)
+#endif // __POSIX__ && !defined(__ANDROID__)
NODE_SET_METHOD(process, "_kill", Kill);
@@ -2488,7 +2479,7 @@ static void ParseDebugOpt(const char* arg) {
debug_port = atoi(p);
} else {
use_debug_agent = true;
- if (!strcmp (arg, "--debug-brk")) {
+ if (!strcmp(arg, "--debug-brk")) {
debug_wait_connect = true;
return;
} else if (!strcmp(arg, "--debug")) {
@@ -2546,7 +2537,7 @@ static void PrintHelp() {
static void ParseArgs(int argc, char **argv) {
int i;
- // TODO use parse opts
+ // TODO(bnoordhuis) use parse opts
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
if (strstr(arg, "--debug") == arg) {
@@ -2687,7 +2678,7 @@ static void EnableDebugSignalHandler(uv_signal_t* handle, int) {
}
-static void RegisterSignalHandler(int signal, void (*handler)(int)) {
+static void RegisterSignalHandler(int signal, void (*handler)(int signal)) {
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
@@ -2713,7 +2704,7 @@ void DebugProcess(const FunctionCallbackInfo<Value>& args) {
return ThrowErrnoException(errno, "kill");
}
}
-#endif // __POSIX__
+#endif // __POSIX__
#ifdef _WIN32
@@ -2776,7 +2767,7 @@ static int RegisterDebugSignalHandler() {
*handler = EnableDebugThreadProc;
- UnmapViewOfFile((void*) handler);
+ UnmapViewOfFile(static_cast<void*>(handler));
return 0;
}
@@ -2851,20 +2842,16 @@ static void DebugProcess(const FunctionCallbackInfo<Value>& args) {
}
out:
- if (process != NULL) {
- CloseHandle(process);
- }
- if (thread != NULL) {
+ if (process != NULL)
+ CloseHandle(process);
+ if (thread != NULL)
CloseHandle(thread);
- }
- if (handler != NULL) {
+ if (handler != NULL)
UnmapViewOfFile(handler);
- }
- if (mapping != NULL) {
+ if (mapping != NULL)
CloseHandle(mapping);
- }
}
-#endif // _WIN32
+#endif // _WIN32
static void DebugPause(const FunctionCallbackInfo<Value>& args) {
@@ -2928,7 +2915,7 @@ char** Init(int argc, char *argv[]) {
uint32_t *stack_limit = &stack_var - (max_stack_size / sizeof(uint32_t));
constraints.set_stack_limit(stack_limit);
- SetResourceConstraints(&constraints); // Must be done before V8::Initialize
+ SetResourceConstraints(&constraints); // Must be done before V8::Initialize
}
V8::SetFlagsFromCommandLine(&v8argc, v8argv, false);
@@ -2945,7 +2932,7 @@ char** Init(int argc, char *argv[]) {
RegisterSignalHandler(SIGPIPE, SIG_IGN);
RegisterSignalHandler(SIGINT, SignalExit);
RegisterSignalHandler(SIGTERM, SignalExit);
-#endif // __POSIX__
+#endif // __POSIX__
uv_check_init(uv_default_loop(), &check_immediate_watcher);
uv_unref(reinterpret_cast<uv_handle_t*>(&check_immediate_watcher));
@@ -2960,12 +2947,12 @@ char** Init(int argc, char *argv[]) {
} else {
#ifdef _WIN32
RegisterDebugSignalHandler();
-#else // Posix
+#else // Posix
static uv_signal_t signal_watcher;
uv_signal_init(uv_default_loop(), &signal_watcher);
uv_signal_start(&signal_watcher, EnableDebugSignalHandler, SIGUSR1);
uv_unref(reinterpret_cast<uv_handle_t*>(&signal_watcher));
-#endif // __POSIX__
+#endif // __POSIX__
}
return argv;
@@ -3018,18 +3005,20 @@ static char **copy_argv(int argc, char **argv) {
int i;
strlen_sum = 0;
- for(i = 0; i < argc; i++) {
+ for (i = 0; i < argc; i++) {
strlen_sum += strlen(argv[i]) + 1;
}
- argv_copy = (char **) malloc(sizeof(char *) * (argc + 1) + strlen_sum);
+ argv_copy = static_cast<char**>(
+ malloc(sizeof(*argv_copy) * (argc + 1) + strlen_sum));
if (!argv_copy) {
return NULL;
}
- argv_data = (char *) argv_copy + sizeof(char *) * (argc + 1);
+ argv_data = reinterpret_cast<char*>(argv_copy) +
+ sizeof(*argv_copy) * (argc + 1);
- for(i = 0; i < argc; i++) {
+ for (i = 0; i < argc; i++) {
argv_copy[i] = argv_data;
len = strlen(argv[i]) + 1;
memcpy(argv_data, argv[i], len);
View
4 src/node.h
@@ -139,7 +139,7 @@ void EmitExit(v8::Handle<v8::Object> process);
// Used to be a macro, hence the uppercase name.
template <typename TypeName>
-inline void NODE_SET_METHOD(TypeName& recv,
+inline void NODE_SET_METHOD(const TypeName& recv,
const char* name,
v8::FunctionCallback callback) {
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(callback);
@@ -163,7 +163,7 @@ inline void NODE_SET_PROTOTYPE_METHOD(v8::Handle<v8::FunctionTemplate> recv,
enum encoding {ASCII, UTF8, BASE64, UCS2, BINARY, HEX, BUFFER};
enum encoding ParseEncoding(v8::Handle<v8::Value> encoding_v,
enum encoding _default = BINARY);
-NODE_EXTERN void FatalException(v8::TryCatch &try_catch);
+NODE_EXTERN void FatalException(const v8::TryCatch& try_catch);
void DisplayExceptionLine(v8::Handle<v8::Message> message);
NODE_EXTERN v8::Local<v8::Value> Encode(const void *buf, size_t len,
View
2 src/node_buffer.cc
@@ -53,7 +53,6 @@
size_t length = end - start;
namespace node {
-
namespace Buffer {
using v8::Function;
@@ -610,7 +609,6 @@ void Initialize(Handle<Object> target) {
} // namespace Buffer
-
} // namespace node
NODE_MODULE(node_buffer, node::Buffer::Initialize)
View
8 src/node_buffer.h
@@ -23,11 +23,10 @@
#include "smalloc.h"
#include "v8.h"
-#ifndef NODE_BUFFER_H_
-#define NODE_BUFFER_H_
+#ifndef SRC_NODE_BUFFER_H_
+#define SRC_NODE_BUFFER_H_
namespace node {
-
namespace Buffer {
static const unsigned int kMaxLength = smalloc::kMaxLength;
@@ -58,7 +57,6 @@ NODE_EXTERN v8::Local<v8::Object> New(char* data,
NODE_EXTERN v8::Local<v8::Object> Use(char* data, uint32_t len);
} // namespace Buffer
-
} // namespace node
-#endif // NODE_BUFFER_H_
+#endif // SRC_NODE_BUFFER_H_
View
332 src/node_constants.cc
@@ -38,131 +38,10 @@
namespace node {
-using namespace v8;
-
-void DefineConstants(Handle<Object> target) {
- // file access modes
- NODE_DEFINE_CONSTANT(target, O_RDONLY);
- NODE_DEFINE_CONSTANT(target, O_WRONLY);
- NODE_DEFINE_CONSTANT(target, O_RDWR);
-
- NODE_DEFINE_CONSTANT(target, S_IFMT);
- NODE_DEFINE_CONSTANT(target, S_IFREG);
- NODE_DEFINE_CONSTANT(target, S_IFDIR);
- NODE_DEFINE_CONSTANT(target, S_IFCHR);
-#ifdef S_IFBLK
- NODE_DEFINE_CONSTANT(target, S_IFBLK);
-#endif
-
-#ifdef S_IFIFO
- NODE_DEFINE_CONSTANT(target, S_IFIFO);
-#endif
-
-#ifdef S_IFLNK
- NODE_DEFINE_CONSTANT(target, S_IFLNK);
-#endif
-
-#ifdef S_IFSOCK
- NODE_DEFINE_CONSTANT(target, S_IFSOCK);
-#endif
-
-#ifdef O_CREAT
- NODE_DEFINE_CONSTANT(target, O_CREAT);
-#endif
-
-#ifdef O_EXCL
- NODE_DEFINE_CONSTANT(target, O_EXCL);
-#endif
-
-#ifdef O_NOCTTY
- NODE_DEFINE_CONSTANT(target, O_NOCTTY);
-#endif
-
-#ifdef O_TRUNC
- NODE_DEFINE_CONSTANT(target, O_TRUNC);
-#endif
-
-#ifdef O_APPEND
- NODE_DEFINE_CONSTANT(target, O_APPEND);
-#endif
-
-#ifdef O_DIRECTORY
- NODE_DEFINE_CONSTANT(target, O_DIRECTORY);
-#endif
-
-#ifdef O_EXCL
- NODE_DEFINE_CONSTANT(target, O_EXCL);
-#endif
-
-#ifdef O_NOFOLLOW
- NODE_DEFINE_CONSTANT(target, O_NOFOLLOW);
-#endif
-
-#ifdef O_SYNC
- NODE_DEFINE_CONSTANT(target, O_SYNC);
-#endif
-
-#ifdef O_SYMLINK
- NODE_DEFINE_CONSTANT(target, O_SYMLINK);
-#endif
-
-#ifdef O_DIRECT
- NODE_DEFINE_CONSTANT(target, O_DIRECT);
-#endif
-
-#ifdef S_IRWXU
- NODE_DEFINE_CONSTANT(target, S_IRWXU);
-#endif
-
-
-#ifdef S_IRUSR
- NODE_DEFINE_CONSTANT(target, S_IRUSR);
-#endif
-
-#ifdef S_IWUSR
- NODE_DEFINE_CONSTANT(target, S_IWUSR);
-#endif
-
-#ifdef S_IXUSR
- NODE_DEFINE_CONSTANT(target, S_IXUSR);
-#endif
-
-
-#ifdef S_IRWXG
- NODE_DEFINE_CONSTANT(target, S_IRWXG);
-#endif
-
-
-#ifdef S_IRGRP
- NODE_DEFINE_CONSTANT(target, S_IRGRP);
-#endif
-
-#ifdef S_IWGRP
- NODE_DEFINE_CONSTANT(target, S_IWGRP);
-#endif
-
-#ifdef S_IXGRP
- NODE_DEFINE_CONSTANT(target, S_IXGRP);
-#endif
-
-
-#ifdef S_IRWXO
- NODE_DEFINE_CONSTANT(target, S_IRWXO);
-#endif
-
-
-#ifdef S_IROTH
- NODE_DEFINE_CONSTANT(target, S_IROTH);
-#endif
-
-#ifdef S_IWOTH
- NODE_DEFINE_CONSTANT(target, S_IWOTH);
-#endif
-
-#ifdef S_IXOTH
- NODE_DEFINE_CONSTANT(target, S_IXOTH);
-#endif
+using v8::Handle;
+using v8::Object;
+void DefineErrnoConstants(Handle<Object> target) {
#ifdef E2BIG
NODE_DEFINE_CONSTANT(target, E2BIG);
#endif
@@ -478,7 +357,9 @@ void DefineConstants(Handle<Object> target) {
#ifdef EXDEV
NODE_DEFINE_CONSTANT(target, EXDEV);
#endif
+}
+void DefineWindowsErrorConstants(Handle<Object> target) {
#ifdef WSAEINTR
NODE_DEFINE_CONSTANT(target, WSAEINTR);
#endif
@@ -710,7 +591,9 @@ void DefineConstants(Handle<Object> target) {
#ifdef WSAEREFUSED
NODE_DEFINE_CONSTANT(target, WSAEREFUSED);
#endif
+}
+void DefineSignalConstants(Handle<Object> target) {
#ifdef SIGHUP
NODE_DEFINE_CONSTANT(target, SIGHUP);
#endif
@@ -853,149 +736,276 @@ void DefineConstants(Handle<Object> target) {
#ifdef SIGUNUSED
NODE_DEFINE_CONSTANT(target, SIGUNUSED);
#endif
+}
-// OpenSSL SSL context options
-
+void DefineOpenSSLConstants(Handle<Object> target) {
#ifdef SSL_OP_ALL
- NODE_DEFINE_CONSTANT(target, SSL_OP_ALL);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_ALL);
#endif
#ifdef SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION
- NODE_DEFINE_CONSTANT(target, SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION);
#endif
#ifdef SSL_OP_CIPHER_SERVER_PREFERENCE
- NODE_DEFINE_CONSTANT(target, SSL_OP_CIPHER_SERVER_PREFERENCE);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_CIPHER_SERVER_PREFERENCE);
#endif
#ifdef SSL_OP_CISCO_ANYCONNECT
- NODE_DEFINE_CONSTANT(target, SSL_OP_CISCO_ANYCONNECT);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_CISCO_ANYCONNECT);
#endif
#ifdef SSL_OP_COOKIE_EXCHANGE
- NODE_DEFINE_CONSTANT(target, SSL_OP_COOKIE_EXCHANGE);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_COOKIE_EXCHANGE);
#endif
#ifdef SSL_OP_CRYPTOPRO_TLSEXT_BUG
- NODE_DEFINE_CONSTANT(target, SSL_OP_CRYPTOPRO_TLSEXT_BUG);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_CRYPTOPRO_TLSEXT_BUG);
#endif
#ifdef SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS
- NODE_DEFINE_CONSTANT(target, SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS);
#endif
#ifdef SSL_OP_EPHEMERAL_RSA
- NODE_DEFINE_CONSTANT(target, SSL_OP_EPHEMERAL_RSA);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_EPHEMERAL_RSA);
#endif
#ifdef SSL_OP_LEGACY_SERVER_CONNECT
- NODE_DEFINE_CONSTANT(target, SSL_OP_LEGACY_SERVER_CONNECT);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_LEGACY_SERVER_CONNECT);
#endif
#ifdef SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER
- NODE_DEFINE_CONSTANT(target, SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER);
#endif
#ifdef SSL_OP_MICROSOFT_SESS_ID_BUG
- NODE_DEFINE_CONSTANT(target, SSL_OP_MICROSOFT_SESS_ID_BUG);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_MICROSOFT_SESS_ID_BUG);
#endif
#ifdef SSL_OP_MSIE_SSLV2_RSA_PADDING
- NODE_DEFINE_CONSTANT(target, SSL_OP_MSIE_SSLV2_RSA_PADDING);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_MSIE_SSLV2_RSA_PADDING);
#endif
#ifdef SSL_OP_NETSCAPE_CA_DN_BUG
- NODE_DEFINE_CONSTANT(target, SSL_OP_NETSCAPE_CA_DN_BUG);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_NETSCAPE_CA_DN_BUG);
#endif
#ifdef SSL_OP_NETSCAPE_CHALLENGE_BUG
- NODE_DEFINE_CONSTANT(target, SSL_OP_NETSCAPE_CHALLENGE_BUG);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_NETSCAPE_CHALLENGE_BUG);
#endif
#ifdef SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG
- NODE_DEFINE_CONSTANT(target, SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG);
#endif
#ifdef SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG
- NODE_DEFINE_CONSTANT(target, SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG);
#endif
#ifdef SSL_OP_NO_COMPRESSION
- NODE_DEFINE_CONSTANT(target, SSL_OP_NO_COMPRESSION);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_NO_COMPRESSION);
#endif
#ifdef SSL_OP_NO_QUERY_MTU
- NODE_DEFINE_CONSTANT(target, SSL_OP_NO_QUERY_MTU);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_NO_QUERY_MTU);
#endif
#ifdef SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION
- NODE_DEFINE_CONSTANT(target, SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION);
#endif
#ifdef SSL_OP_NO_SSLv2
- NODE_DEFINE_CONSTANT(target, SSL_OP_NO_SSLv2);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_NO_SSLv2);
#endif
#ifdef SSL_OP_NO_SSLv3
- NODE_DEFINE_CONSTANT(target, SSL_OP_NO_SSLv3);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_NO_SSLv3);
#endif
#ifdef SSL_OP_NO_TICKET
- NODE_DEFINE_CONSTANT(target, SSL_OP_NO_TICKET);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_NO_TICKET);
#endif
#ifdef SSL_OP_NO_TLSv1
- NODE_DEFINE_CONSTANT(target, SSL_OP_NO_TLSv1);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_NO_TLSv1);
#endif
#ifdef SSL_OP_NO_TLSv1_1
- NODE_DEFINE_CONSTANT(target, SSL_OP_NO_TLSv1_1);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_NO_TLSv1_1);
#endif
#ifdef SSL_OP_NO_TLSv1_2
- NODE_DEFINE_CONSTANT(target, SSL_OP_NO_TLSv1_2);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_NO_TLSv1_2);
#endif
#ifdef SSL_OP_PKCS1_CHECK_1
- NODE_DEFINE_CONSTANT(target, SSL_OP_PKCS1_CHECK_1);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_PKCS1_CHECK_1);
#endif
#ifdef SSL_OP_PKCS1_CHECK_2
- NODE_DEFINE_CONSTANT(target, SSL_OP_PKCS1_CHECK_2);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_PKCS1_CHECK_2);
#endif
#ifdef SSL_OP_SINGLE_DH_USE
- NODE_DEFINE_CONSTANT(target, SSL_OP_SINGLE_DH_USE);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_SINGLE_DH_USE);
#endif
#ifdef SSL_OP_SINGLE_ECDH_USE
- NODE_DEFINE_CONSTANT(target, SSL_OP_SINGLE_ECDH_USE);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_SINGLE_ECDH_USE);
#endif
#ifdef SSL_OP_SSLEAY_080_CLIENT_DH_BUG
- NODE_DEFINE_CONSTANT(target, SSL_OP_SSLEAY_080_CLIENT_DH_BUG);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_SSLEAY_080_CLIENT_DH_BUG);
#endif
#ifdef SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG
- NODE_DEFINE_CONSTANT(target, SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG);
#endif
#ifdef SSL_OP_TLS_BLOCK_PADDING_BUG
- NODE_DEFINE_CONSTANT(target, SSL_OP_TLS_BLOCK_PADDING_BUG);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_TLS_BLOCK_PADDING_BUG);
#endif
#ifdef SSL_OP_TLS_D5_BUG
- NODE_DEFINE_CONSTANT(target, SSL_OP_TLS_D5_BUG);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_TLS_D5_BUG);
#endif
#ifdef SSL_OP_TLS_ROLLBACK_BUG
- NODE_DEFINE_CONSTANT(target, SSL_OP_TLS_ROLLBACK_BUG);
+ NODE_DEFINE_CONSTANT(target, SSL_OP_TLS_ROLLBACK_BUG);
#endif
#ifdef OPENSSL_NPN_NEGOTIATED
#define NPN_ENABLED 1
- NODE_DEFINE_CONSTANT(target, NPN_ENABLED);
+ NODE_DEFINE_CONSTANT(target, NPN_ENABLED);
+#endif
+}
+
+void DefineSystemConstants(Handle<Object> target) {
+ // file access modes
+ NODE_DEFINE_CONSTANT(target, O_RDONLY);
+ NODE_DEFINE_CONSTANT(target, O_WRONLY);
+ NODE_DEFINE_CONSTANT(target, O_RDWR);
+
+ NODE_DEFINE_CONSTANT(target, S_IFMT);
+ NODE_DEFINE_CONSTANT(target, S_IFREG);
+ NODE_DEFINE_CONSTANT(target, S_IFDIR);
+ NODE_DEFINE_CONSTANT(target, S_IFCHR);
+#ifdef S_IFBLK
+ NODE_DEFINE_CONSTANT(target, S_IFBLK);
+#endif
+
+#ifdef S_IFIFO
+ NODE_DEFINE_CONSTANT(target, S_IFIFO);
+#endif
+
+#ifdef S_IFLNK
+ NODE_DEFINE_CONSTANT(target, S_IFLNK);
+#endif
+
+#ifdef S_IFSOCK
+ NODE_DEFINE_CONSTANT(target, S_IFSOCK);
+#endif
+
+#ifdef O_CREAT
+ NODE_DEFINE_CONSTANT(target, O_CREAT);
+#endif
+
+#ifdef O_EXCL
+ NODE_DEFINE_CONSTANT(target, O_EXCL);
+#endif
+
+#ifdef O_NOCTTY
+ NODE_DEFINE_CONSTANT(target, O_NOCTTY);
+#endif
+
+#ifdef O_TRUNC
+ NODE_DEFINE_CONSTANT(target, O_TRUNC);
+#endif
+
+#ifdef O_APPEND
+ NODE_DEFINE_CONSTANT(target, O_APPEND);
+#endif
+
+#ifdef O_DIRECTORY
+ NODE_DEFINE_CONSTANT(target, O_DIRECTORY);
+#endif
+
+#ifdef O_EXCL
+ NODE_DEFINE_CONSTANT(target, O_EXCL);
+#endif
+
+#ifdef O_NOFOLLOW
+ NODE_DEFINE_CONSTANT(target, O_NOFOLLOW);
+#endif
+
+#ifdef O_SYNC
+ NODE_DEFINE_CONSTANT(target, O_SYNC);
+#endif
+
+#ifdef O_SYMLINK
+ NODE_DEFINE_CONSTANT(target, O_SYMLINK);
+#endif
+
+#ifdef O_DIRECT
+ NODE_DEFINE_CONSTANT(target, O_DIRECT);
+#endif
+
+#ifdef S_IRWXU
+ NODE_DEFINE_CONSTANT(target, S_IRWXU);
+#endif
+
+#ifdef S_IRUSR
+ NODE_DEFINE_CONSTANT(target, S_IRUSR);
+#endif
+
+#ifdef S_IWUSR
+ NODE_DEFINE_CONSTANT(target, S_IWUSR);
+#endif
+
+#ifdef S_IXUSR
+ NODE_DEFINE_CONSTANT(target, S_IXUSR);
+#endif
+
+#ifdef S_IRWXG
+ NODE_DEFINE_CONSTANT(target, S_IRWXG);
#endif
+
+#ifdef S_IRGRP
+ NODE_DEFINE_CONSTANT(target, S_IRGRP);
+#endif
+
+#ifdef S_IWGRP
+ NODE_DEFINE_CONSTANT(target, S_IWGRP);
+#endif
+
+#ifdef S_IXGRP
+ NODE_DEFINE_CONSTANT(target, S_IXGRP);
+#endif
+
+#ifdef S_IRWXO
+ NODE_DEFINE_CONSTANT(target, S_IRWXO);
+#endif
+
+#ifdef S_IROTH
+ NODE_DEFINE_CONSTANT(target, S_IROTH);
+#endif
+
+#ifdef S_IWOTH
+ NODE_DEFINE_CONSTANT(target, S_IWOTH);
+#endif
+
+#ifdef S_IXOTH
+ NODE_DEFINE_CONSTANT(target, S_IXOTH);
+#endif
+}
+
+void DefineConstants(Handle<Object> target) {
+ DefineErrnoConstants(target);
+ DefineWindowsErrorConstants(target);
+ DefineSignalConstants(target);
+ DefineOpenSSLConstants(target);
+ DefineSystemConstants(target);
}
} // namespace node
View
6 src/node_constants.h
@@ -19,8 +19,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
-#ifndef SRC_CONSTANTS_H_
-#define SRC_CONSTANTS_H_
+#ifndef SRC_NODE_CONSTANTS_H_
+#define SRC_NODE_CONSTANTS_H_
#include "node.h"
#include "v8.h"
@@ -29,4 +29,4 @@ namespace node {
void DefineConstants(v8::Handle<v8::Object> target);
} // namespace node
-#endif // SRC_CONSTANTS_H_
+#endif // SRC_NODE_CONSTANTS_H_
View
5 src/node_counters.cc
@@ -86,7 +86,8 @@ static void counter_gc_done(GCType type, GCCallbackFlags flags) {
uint64_t gcperiod = endgc - counter_gc_start_time;
if (totalperiod > 0) {
- unsigned int percent = static_cast<unsigned int>((gcperiod * 100) / totalperiod);
+ unsigned int percent = static_cast<unsigned int>(
+ (gcperiod * 100) / totalperiod);
NODE_COUNT_GC_PERCENTTIME(percent);
counter_gc_end_time = endgc;
@@ -137,4 +138,4 @@ void TermPerfCounters(Handle<Object> target) {
TermPerfCountersWin32();
}
-}
+} // namespace node
View
8 src/node_counters.h
@@ -19,8 +19,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
-#ifndef NODE_COUNTERS_H_
-#define NODE_COUNTERS_H_
+#ifndef SRC_NODE_COUNTERS_H_
+#define SRC_NODE_COUNTERS_H_
#include "node.h"
#include "v8.h"
@@ -30,7 +30,7 @@ namespace node {
void InitPerfCounters(v8::Handle<v8::Object> target);
void TermPerfCounters(v8::Handle<v8::Object> target);
-}
+} // namespace node
#ifdef HAVE_PERFCTR
#include "node_win32_perfctr_provider.h"
@@ -50,4 +50,4 @@ void TermPerfCounters(v8::Handle<v8::Object> target);
#define NODE_COUNT_PIPE_BYTES_RECV(bytes)
#endif
-#endif
+#endif // SRC_NODE_COUNTERS_H_
View
271 src/node_crypto.cc
@@ -326,7 +326,7 @@ int SecureContext::NewSessionCallback(SSL* s, SSL_SESSION* sess) {
// Takes a string or buffer and loads it into a BIO.
// Caller responsible for BIO_free_all-ing the returned object.
-static BIO* LoadBIO (Handle<Value> v) {
+static BIO* LoadBIO(Handle<Value> v) {
BIO *bio = BIO_new(NodeBIO::GetMethod());
if (!bio) return NULL;
@@ -354,8 +354,8 @@ static BIO* LoadBIO (Handle<Value> v) {
// Takes a string or buffer and loads it into an X509
// Caller responsible for X509_free-ing the returned object.
-static X509* LoadX509 (Handle<Value> v) {
- HandleScope scope(node_isolate); // necessary?
+static X509* LoadX509(Handle<Value> v) {
+ HandleScope scope(node_isolate);
BIO *bio = LoadBIO(v);
if (!bio) return NULL;
@@ -467,7 +467,7 @@ int SSL_CTX_use_certificate_chain(SSL_CTX *ctx, BIO *in) {
}
}
-end:
+ end:
if (x != NULL) X509_free(x);
return ret;
}
@@ -648,8 +648,7 @@ void SecureContext::SetSessionIdContext(
bio = BIO_new(BIO_s_mem());
if (bio == NULL) {
message = String::New("SSL_CTX_set_session_id_context error");
- }
- else {
+ } else {
ERR_print_errors(bio);
BIO_get_mem_ptr(bio, &mem);
message = String::New(mem->data, mem->length);
@@ -681,7 +680,7 @@ void SecureContext::Close(const FunctionCallbackInfo<Value>& args) {
}
-//Takes .pfx or .p12 and password in string or buffer format
+// Takes .pfx or .p12 and password in string or buffer format
void SecureContext::LoadPKCS12(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
@@ -722,8 +721,7 @@ void SecureContext::LoadPKCS12(const FunctionCallbackInfo<Value>& args) {
if (d2i_PKCS12_bio(in, &p12) &&
PKCS12_parse(p12, pass, &pkey, &cert, &extraCerts) &&
SSL_CTX_use_certificate(sc->ctx_, cert) &&
- SSL_CTX_use_PrivateKey(sc->ctx_, pkey))
- {
+ SSL_CTX_use_PrivateKey(sc->ctx_, pkey)) {
// set extra certs
while (X509* x509 = sk_X509_pop(extraCerts)) {
if (!sc->ca_store_) {
@@ -817,115 +815,114 @@ size_t ClientHelloParser::Write(const uint8_t* data, size_t len) {
Handle<Value> argv[1];
switch (state_) {
- case kWaiting:
- // >= 5 bytes for header parsing
- if (offset_ < 5) break;
-
- if (data_[0] == kChangeCipherSpec || data_[0] == kAlert ||
- data_[0] == kHandshake || data_[0] == kApplicationData) {
- frame_len_ = (data_[3] << 8) + data_[4];
- state_ = kTLSHeader;
- body_offset_ = 5;
- } else {
- frame_len_ = (data_[0] << 8) + data_[1];
- state_ = kSSLHeader;
- if (*data_ & 0x40) {
- // header with padding
- body_offset_ = 3;
+ case kWaiting:
+ // >= 5 bytes for header parsing
+ if (offset_ < 5)
+ break;
+
+ if (data_[0] == kChangeCipherSpec ||
+ data_[0] == kAlert ||
+ data_[0] == kHandshake ||
+ data_[0] == kApplicationData) {
+ frame_len_ = (data_[3] << 8) + data_[4];
+ state_ = kTLSHeader;
+ body_offset_ = 5;
} else {
- // without padding
- body_offset_ = 2;
+ frame_len_ = (data_[0] << 8) + data_[1];
+ state_ = kSSLHeader;
+ if (*data_ & 0x40) {
+ // header with padding
+ body_offset_ = 3;
+ } else {
+ // without padding
+ body_offset_ = 2;
+ }
}
- }
- // Sanity check (too big frame, or too small)
- if (frame_len_ >= sizeof(data_)) {
- // Let OpenSSL handle it
- Finish();
- return copied;
- }
- case kTLSHeader:
- case kSSLHeader:
- // >= 5 + frame size bytes for frame parsing
- if (offset_ < body_offset_ + frame_len_) break;
-
- // Skip unsupported frames and gather some data from frame
-
- // TODO: Check protocol version
- if (data_[body_offset_] == kClientHello) {
- is_clienthello = true;
- uint8_t* body;
- size_t session_offset;
-
- if (state_ == kTLSHeader) {
- // Skip frame header, hello header, protocol version and random data
- session_offset = body_offset_ + 4 + 2 + 32;
-
- if (session_offset + 1 < offset_) {
- body = data_ + session_offset;
- session_size = *body;
- session_id = body + 1;
- }
- } else if (state_ == kSSLHeader) {
- // Skip header, version
- session_offset = body_offset_ + 3;
+ // Sanity check (too big frame, or too small)
+ if (frame_len_ >= sizeof(data_)) {
+ // Let OpenSSL handle it
+ Finish();
+ return copied;
+ }
+ case kTLSHeader:
+ case kSSLHeader:
+ // >= 5 + frame size bytes for frame parsing
+ if (offset_ < body_offset_ + frame_len_)
+ break;
+
+ // Skip unsupported frames and gather some data from frame
+
+ if (data_[body_offset_] == kClientHello) {
+ is_clienthello = true;
+ uint8_t* body;
+ size_t session_offset;
+
+ if (state_ == kTLSHeader) {
+ // Skip frame header, hello header, protocol version and random data
+ session_offset = body_offset_ + 4 + 2 + 32;
+
+ if (session_offset + 1 < offset_) {
+ body = data_ + session_offset;
+ session_size = *body;
+ session_id = body + 1;
+ }
+ } else if (state_ == kSSLHeader) {
+ // Skip header, version
+ session_offset = body_offset_ + 3;
- if (session_offset + 4 < offset_) {
- body = data_ + session_offset;
+ if (session_offset + 4 < offset_) {
+ body = data_ + session_offset;
- int ciphers_size = (body[0] << 8) + body[1];
+ int ciphers_size = (body[0] << 8) + body[1];
- if (body + 4 + ciphers_size < data_ + offset_) {
- session_size = (body[2] << 8) + body[3];
- session_id = body + 4 + ciphers_size;
+ if (body + 4 + ciphers_size < data_ + offset_) {
+ session_size = (body[2] << 8) + body[3];
+ session_id = body + 4 + ciphers_size;
+ }
}
+ } else {
+ // Whoa? How did we get here?
+ abort();
+ }
+
+ // Check if we overflowed (do not reply with any private data)
+ if (session_id == NULL ||
+ session_size > 32 ||
+ session_id + session_size > data_ + offset_) {
+ Finish();
+ return copied;
}
- } else {
- // Whoa? How did we get here?
- abort();
}
- // Check if we overflowed (do not reply with any private data)
- if (session_id == NULL ||
- session_size > 32 ||
- session_id + session_size > data_ + offset_) {
+ // Not client hello - let OpenSSL handle it
+ if (!is_clienthello) {
Finish();
return copied;
}
- // TODO: Parse other things?
- }
-
- // Not client hello - let OpenSSL handle it
- if (!is_clienthello) {
- Finish();
- return copied;
- }
-
- // Parse frame, call javascript handler and
- // move parser into the paused state
- if (onclienthello_sym.IsEmpty()) {
- onclienthello_sym = String::New("onclienthello");
- }
- if (sessionid_sym.IsEmpty()) {
- sessionid_sym = String::New("sessionId");
- }
-
- state_ = kPaused;
- hello = Object::New();
- hello->Set(sessionid_sym,
- Buffer::New(reinterpret_cast<char*>(session_id),
- session_size));
-
- argv[0] = hello;
- MakeCallback(conn_->handle(node_isolate),
- onclienthello_sym,
- ARRAY_SIZE(argv),
- argv);
- break;
- case kEnded:
- default:
- break;
+ // Parse frame, call javascript handler and
+ // move parser into the paused state
+ if (onclienthello_sym.IsEmpty())
+ onclienthello_sym = String::New("onclienthello");
+ if (sessionid_sym.IsEmpty())
+ sessionid_sym = String::New("sessionId");
+
+ state_ = kPaused;
+ hello = Object::New();
+ hello->Set(sessionid_sym,
+ Buffer::New(reinterpret_cast<char*>(session_id),
+ session_size));
+
+ argv[0] = hello;
+ MakeCallback(conn_->handle(node_isolate),
+ onclienthello_sym,
+ ARRAY_SIZE(argv),
+ argv);
+ break;
+ case kEnded:
+ default:
+ break;
}
return copied;
@@ -954,10 +951,13 @@ int Connection::HandleBIOError(BIO *bio, const char* func, int rv) {
if (rv >= 0) return rv;
int retry = BIO_should_retry(bio);
- (void) retry; // unused if !defined(SSL_PRINT_DEBUG)
+ (void) retry; // unused if !defined(SSL_PRINT_DEBUG)
if (BIO_should_write(bio)) {
- DEBUG_PRINT("[%p] BIO: %s want write. should retry %d\n", ssl_, func, retry);
+ DEBUG_PRINT("[%p] BIO: %s want write. should retry %d\n",
+ ssl_,
+ func,
+ retry);
return 0;
} else if (BIO_should_read(bio)) {
@@ -972,7 +972,11 @@ int Connection::HandleBIOError(BIO *bio, const char* func, int rv) {
Local<Value> e = Exception::Error(String::New(ssl_error_buf));
handle(node_isolate)->Set(String::New("error"), e);
- DEBUG_PRINT("[%p] BIO: %s failed: (%d) %s\n", ssl_, func, rv, ssl_error_buf);
+ DEBUG_PRINT("[%p] BIO: %s failed: (%d) %s\n",
+ ssl_,
+ func,
+ rv,
+ ssl_error_buf);
return rv;
}
@@ -1046,7 +1050,7 @@ void Connection::ClearError() {
// We should clear the error in JS-land
assert(
handle(node_isolate)->Get(String::New("error"))->BooleanValue() == false);
-#endif // NDEBUG
+#endif // NDEBUG
}
@@ -1079,22 +1083,32 @@ void Connection::Initialize(Handle<Object> target) {
NODE_SET_PROTOTYPE_METHOD(t, "encOut", Connection::EncOut);
NODE_SET_PROTOTYPE_METHOD(t, "clearPending", Connection::ClearPending);
NODE_SET_PROTOTYPE_METHOD(t, "encPending", Connection::EncPending);
- NODE_SET_PROTOTYPE_METHOD(t, "getPeerCertificate", Connection::GetPeerCertificate);
+ NODE_SET_PROTOTYPE_METHOD(t,
+ "getPeerCertificate",
+ Connection::GetPeerCertificate);
NODE_SET_PROTOTYPE_METHOD(t, "getSession", Connection::GetSession);
NODE_SET_PROTOTYPE_METHOD(t, "setSession", Connection::SetSession);
NODE_SET_PROTOTYPE_METHOD(t, "loadSession", Connection::LoadSession);
NODE_SET_PROTOTYPE_METHOD(t, "isSessionReused", Connection::IsSessionReused);
NODE_SET_PROTOTYPE_METHOD(t, "isInitFinished", Connection::IsInitFinished);
NODE_SET_PROTOTYPE_METHOD(t, "verifyError", Connection::VerifyError);
- NODE_SET_PROTOTYPE_METHOD(t, "getCurrentCipher", Connection::GetCurrentCipher);
+ NODE_SET_PROTOTYPE_METHOD(t,
+ "getCurrentCipher",
+ Connection::GetCurrentCipher);
NODE_SET_PROTOTYPE_METHOD(t, "start", Connection::Start);
NODE_SET_PROTOTYPE_METHOD(t, "shutdown", Connection::Shutdown);
- NODE_SET_PROTOTYPE_METHOD(t, "receivedShutdown", Connection::ReceivedShutdown);
+ NODE_SET_PROTOTYPE_METHOD(t,
+ "receivedShutdown",
+ Connection::ReceivedShutdown);
NODE_SET_PROTOTYPE_METHOD(t, "close", Connection::Close);
#ifdef OPENSSL_NPN_NEGOTIATED
- NODE_SET_PROTOTYPE_METHOD(t, "getNegotiatedProtocol", Connection::GetNegotiatedProto);
- NODE_SET_PROTOTYPE_METHOD(t, "setNPNProtocols", Connection::SetNPNProtocols);
+ NODE_SET_PROTOTYPE_METHOD(t,
+ "getNegotiatedProtocol",
+ Connection::GetNegotiatedProto);
+ NODE_SET_PROTOTYPE_METHOD(t,
+ "setNPNProtocols",
+ Connection::SetNPNProtocols);
#endif
@@ -1158,7 +1172,6 @@ int Connection::AdvertiseNextProtoCallback_(SSL *s,
const unsigned char** data,
unsigned int *len,
void *arg) {
-
Connection *p = static_cast<Connection*>(SSL_get_app_data(s));
if (p->npnProtos_.IsEmpty()) {
@@ -1599,8 +1612,8 @@ void Connection::GetPeerCertificate(const FunctionCallbackInfo<Value>& args) {
EVP_PKEY *pkey = NULL;
RSA *rsa = NULL;
- if( NULL != (pkey = X509_get_pubkey(peer_cert))
- && NULL != (rsa = EVP_PKEY_get1_RSA(pkey)) ) {
+ if (NULL != (pkey = X509_get_pubkey(peer_cert)) &&
+ NULL != (rsa = EVP_PKEY_get1_RSA(pkey))) {
BN_print(bio, rsa->n);
BIO_get_mem_ptr(bio, &mem);
info->Set(modulus_symbol, String::New(mem->data, mem->length) );
@@ -1637,7 +1650,7 @@ void Connection::GetPeerCertificate(const FunctionCallbackInfo<Value>& args) {
const char hex[] = "0123456789ABCDEF";
char fingerprint[EVP_MAX_MD_SIZE * 3];
- for (i = 0; i<md_size; i++) {
+ for (i = 0; i < md_size; i++) {
fingerprint[3*i] = hex[(md[i] & 0xf0) >> 4];
fingerprint[(3*i)+1] = hex[(md[i] & 0x0f)];
fingerprint[(3*i)+2] = ':';
@@ -1645,8 +1658,7 @@ void Connection::GetPeerCertificate(const FunctionCallbackInfo<Value>& args) {
if (md_size > 0) {
fingerprint[(3*(md_size-1))+2] = '\0';
- }
- else {
+ } else {
fingerprint[0] = '\0';
}
@@ -1840,7 +1852,6 @@ void Connection::VerifyError(const FunctionCallbackInfo<Value>& args) {
}
X509_free(peer_cert);
-
long x509_verify_error = SSL_get_verify_result(ss->ssl_);
Local<String> s;
@@ -2678,7 +2689,7 @@ void Sign::SignFinal(const FunctionCallbackInfo<Value>& args) {
ssize_t len = Buffer::Length(args[0]);
char* buf = Buffer::Data(args[0]);
- md_len = 8192; // Maximum key size is 8192 bits
+ md_len = 8192; // Maximum key size is 8192 bits
md_value = new unsigned char[md_len];
bool r = sign->SignFinal(&md_value, &md_len, buf, len);
@@ -2841,7 +2852,7 @@ bool Verify::VerifyFinal(const char* key_pem,
siglen,
pkey);
-exit:
+ exit:
if (pkey != NULL)
EVP_PKEY_free(pkey);
if (bp != NULL)
@@ -3404,7 +3415,7 @@ void PBKDF2(const FunctionCallbackInfo<Value>& args) {
}
return;
-err:
+ err:
delete[] salt;
delete[] pass;
return ThrowTypeError(type_error);
@@ -3414,7 +3425,7 @@ void PBKDF2(const FunctionCallbackInfo<Value>& args) {
struct RandomBytesRequest {
~RandomBytesRequest();
Persistent<Object> obj_;
- unsigned long error_; // openssl error code or zero
+ unsigned long error_; // openssl error code or zero
uv_work_t work_req_;
size_t size_;
char* data_;
@@ -3460,8 +3471,7 @@ void RandomBytesCheck(RandomBytesRequest* req, Local<Value> argv[2]) {
argv[0] = Exception::Error(String::New(errmsg));
argv[1] = Null(node_isolate);
- }
- else {
+ } else {
argv[0] = Null(node_isolate);
argv[1] = Buffer::Use(req->data_, req->size_);
}
@@ -3511,8 +3521,7 @@ void RandomBytes(const FunctionCallbackInfo<Value>& args) {
RandomBytesWork<pseudoRandom>,
RandomBytesAfter);
args.GetReturnValue().Set(obj);
- }
- else {
+ } else {
Local<Value> argv[2];
RandomBytesWork<pseudoRandom>(&req->work_req_);
RandomBytesCheck(req, argv);
@@ -3596,13 +3605,11 @@ void InitCrypto(Handle<Object> target) {
// Turn off compression. Saves memory - do it in userland.
#if !defined(OPENSSL_NO_COMP)
- STACK_OF(SSL_COMP)* comp_methods =
#if OPENSSL_VERSION_NUMBER < 0x00908000L
- SSL_COMP_get_compression_method()
+ STACK_OF(SSL_COMP)* comp_methods = SSL_COMP_get_compression_method();
#else
- SSL_COMP_get_compression_methods()
+ STACK_OF(SSL_COMP)* comp_methods = SSL_COMP_get_compression_methods();
#endif
- ;
sk_SSL_COMP_zero(comp_methods);
assert(sk_SSL_COMP_num(comp_methods) == 0);
#endif
View
25 src/node_crypto.h
@@ -57,7 +57,7 @@ class SecureContext : ObjectWrap {
static void Initialize(v8::Handle<v8::Object> target);
SSL_CTX *ctx_;
- // TODO: ca_store_ should probably be removed, it's not used anywhere.
+ // TODO(indutny): ca_store_ should probably be removed, it's not used anywhere
X509_STORE *ca_store_;
static const int kMaxSessionSize = 10 * 1024;
@@ -139,10 +139,10 @@ class ClientHelloParser {
kEnded
};
- ClientHelloParser(Connection* c) : conn_(c),
- state_(kWaiting),
- offset_(0),
- body_offset_(0) {
+ explicit ClientHelloParser(Connection* c) : conn_(c),
+ state_(kWaiting),
+ offset_(0),
+ body_offset_(0) {
}
size_t Write(const uint8_t* data, size_t len);
@@ -316,9 +316,9 @@ class CipherBase : public ObjectWrap {
static void Final(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetAutoPadding(const v8::FunctionCallbackInfo<v8::Value>& args);
- CipherBase(CipherKind kind) : cipher_(NULL),
- initialised_(false),
- kind_(kind) {
+ explicit CipherBase(CipherKind kind) : cipher_(NULL),
+ initialised_(false),
+ kind_(kind) {
}
~CipherBase() {
@@ -335,7 +335,7 @@ class CipherBase : public ObjectWrap {
class Hmac : public ObjectWrap {
public:
- static void Initialize (v8::Handle<v8::Object> target);
+ static void Initialize(v8::Handle<v8::Object> target);
protected:
void HmacInit(const char* hash_type, const char* key, int key_len);
@@ -363,7 +363,7 @@ class Hmac : public ObjectWrap {
class Hash : public ObjectWrap {
public:
- static void Initialize (v8::Handle<v8::Object> target);
+ static void Initialize(v8::Handle<v8::Object> target);
bool HashInit(const char* hash_type);
bool HashUpdate(const char* data, int len);
@@ -420,7 +420,7 @@ class Sign : public ObjectWrap {
class Verify : public ObjectWrap {
public:
- static void Initialize (v8::Handle<v8::Object> target);
+ static void Initialize(v8::Handle<v8::Object> target);
void VerifyInit(const char* verify_type);
bool VerifyUpdate(const char* data, int len);
@@ -430,7 +430,7 @@ class Verify : public ObjectWrap {
int siglen);
protected:
- static void New (const v8::FunctionCallbackInfo<v8::Value>& args);
+ static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
static void VerifyInit(const v8::FunctionCallbackInfo<v8::Value>& args);
static void VerifyUpdate(const v8::FunctionCallbackInfo<v8::Value>& args);
static void VerifyFinal(const v8::FunctionCallbackInfo<v8::Value>& args);
@@ -447,7 +447,6 @@ class Verify : public ObjectWrap {
EVP_MD_CTX mdctx_; /* coverity[member_decl] */
const EVP_MD* md_; /* coverity[member_decl] */
bool initialised_;
-
};
class DiffieHellman : public ObjectWrap {
View
88 src/node_crypto_bio.cc
@@ -133,49 +133,49 @@ long NodeBIO::Ctrl(BIO* bio, int cmd, long num, void* ptr) {
ret = 1;
switch (cmd) {
- case BIO_CTRL_RESET:
- nbio->Reset();
- break;
- case BIO_CTRL_EOF:
- ret = nbio->Length() == 0;
- break;
- case BIO_C_SET_BUF_MEM_EOF_RETURN:
- bio->num = num;
- break;
- case BIO_CTRL_INFO:
- ret = nbio->Length();
- if (ptr != NULL)
- *reinterpret_cast<void**>(ptr) = NULL;
- break;
- case BIO_C_SET_BUF_MEM:
- assert(0 && "Can't use SET_BUF_MEM_PTR with NodeBIO");
- abort();
- break;
- case BIO_C_GET_BUF_MEM_PTR:
- assert(0 && "Can't use GET_BUF_MEM_PTR with NodeBIO");
- ret = 0;
- break;
- case BIO_CTRL_GET_CLOSE:
- ret = bio->shutdown;
- break;
- case BIO_CTRL_SET_CLOSE:
- bio->shutdown = num;
- break;
- case BIO_CTRL_WPENDING:
- ret = 0;
- break;
- case BIO_CTRL_PENDING:
- ret = nbio->Length();
- break;
- case BIO_CTRL_DUP:
- case BIO_CTRL_FLUSH:
- ret = 1;
- break;
- case BIO_CTRL_PUSH:
- case BIO_CTRL_POP:
- default:
- ret = 0;
- break;
+ case BIO_CTRL_RESET:
+ nbio->Reset();
+ break;
+ case BIO_CTRL_EOF:
+ ret = nbio->Length() == 0;
+ break;
+ case BIO_C_SET_BUF_MEM_EOF_RETURN:
+ bio->num = num;
+ break;
+ case BIO_CTRL_INFO:
+ ret = nbio->Length();
+ if (ptr != NULL)
+ *reinterpret_cast<void**>(ptr) = NULL;
+ break;
+ case BIO_C_SET_BUF_MEM:
+ assert(0 && "Can't use SET_BUF_MEM_PTR with NodeBIO");
+ abort();
+ break;
+ case BIO_C_GET_BUF_MEM_PTR:
+ assert(0 && "Can't use GET_BUF_MEM_PTR with NodeBIO");
+ ret = 0;
+ break;
+ case BIO_CTRL_GET_CLOSE:
+ ret = bio->shutdown;
+ break;
+ case BIO_CTRL_SET_CLOSE:
+ bio->shutdown = num;
+ break;
+ case BIO_CTRL_WPENDING:
+ ret = 0;
+ break;
+ case BIO_CTRL_PENDING:
+ ret = nbio->Length();
+ break;
+ case BIO_CTRL_DUP:
+ case BIO_CTRL_FLUSH:
+ ret = 1;
+ break;
+ case BIO_CTRL_PUSH:
+ case BIO_CTRL_POP:
+ default:
+ ret = 0;
+ break;
}
return ret;
}
@@ -387,4 +387,4 @@ NodeBIO::~NodeBIO() {
write_head_ = NULL;
}
-} // namespace node
+} // namespace node
View
7 src/node_crypto_bio.h
@@ -19,6 +19,9 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
+#ifndef SRC_NODE_CRYPTO_BIO_H_
+#define SRC_NODE_CRYPTO_BIO_H_
+
#include "openssl/bio.h"
#include <assert.h>
@@ -110,4 +113,6 @@ class NodeBIO {
static BIO_METHOD method_;
};
-} // namespace node
+} // namespace node
+
+#endif // SRC_NODE_CRYPTO_BIO_H_
View
25 src/node_crypto_groups.h
@@ -1,3 +1,26 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be 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.
+
+#ifndef SRC_NODE_CRYPTO_GROUPS_H_
+#define SRC_NODE_CRYPTO_GROUPS_H_
/*
These modular groups were literally taken from:
@@ -385,3 +408,5 @@ static const modp_group modp_groups[] = {
{ "modp18", V(group_modp18), sizeof(group_modp18), V(two_generator), 1 }
#undef V
};
+
+#endif // SRC_NODE_CRYPTO_GROUPS_H_
View
2 src/node_dtrace.cc
@@ -347,4 +347,4 @@ void InitDTrace(Handle<Object> target) {
#endif
}
-}
+} // namespace node
View
39 src/node_dtrace.h
@@ -19,14 +19,13 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
-#ifndef NODE_DTRACE_H_
-#define NODE_DTRACE_H_
+#ifndef SRC_NODE_DTRACE_H_
+#define SRC_NODE_DTRACE_H_
#include "node.h"
#include "v8.h"
extern "C" {
-
/*
* The following structures are passed directly to DTrace when probes are fired.
* Translators in node.d translate these structures into the corresponding D
@@ -36,15 +35,15 @@ extern "C" {
*/
typedef struct {
- int32_t fd;
- int32_t port;