#include <node.h>
#include <uv.h>
-#if defined(__OpenBSD__) || defined(__MINGW32__)
+#if defined(__OpenBSD__) || defined(__MINGW32__) || defined(_MSC_VER)
# include <nameser.h>
#else
# include <arpa/nameser.h>
#endif
// Temporary hack: libuv should provide uv_inet_pton and uv_inet_ntop.
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
extern "C" {
# include <inet_net_pton.h>
# include <inet_ntop.h>
// Subclasses should implement the appropriate Send method.
virtual int Send(const char* name) {
assert(0);
+ return 0;
}
virtual int Send(const char* name, int family) {
assert(0);
+ return 0;
}
protected:
#include <locale.h>
#include <signal.h>
#include <stdio.h>
+#if defined(_MSC_VER)
+#define snprintf _snprintf
+#endif
#include <stdlib.h>
-#include <strings.h>
#include <string.h>
+#if !defined(_MSC_VER)
+#include <strings.h>
+#else
+#define strcasecmp _stricmp
+#endif
#include <limits.h> /* PATH_MAX */
#include <assert.h>
-#include <unistd.h>
+#if !defined(_MSC_VER)
+#include <unistd.h> /* setuid, getuid */
+#else
+#include <direct.h>
+#define chdir _chdir
+#define getcwd _getcwd
+#include <process.h>
+#define getpid _getpid
+#endif
#include <errno.h>
#include <sys/types.h>
-#include <unistd.h> /* setuid, getuid */
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
# include <platform_win32.h> /* winapi_perror() */
# ifdef PTW32_STATIC_LIB
extern "C" {
# include <node_stat_watcher.h>
# include <node_timer.h>
#endif
+#if !defined(_MSC_VER)
#include <node_child_process.h>
+#endif
#include <node_constants.h>
#include <node_stdio.h>
#include <node_javascript.h>
#include <node_version.h>
#include <node_string.h>
-#ifdef HAVE_OPENSSL
+#if HAVE_OPENSSL
# include <node_crypto.h>
#endif
#include <node_script.h>
# ifdef __APPLE__
# include <crt_externs.h>
# define environ (*_NSGetEnviron())
-# else
+# elif !defined(_MSC_VER)
extern char **environ;
# endif
versions->Set(String::NewSymbol("ares"), String::New(ARES_VERSION_STR));
snprintf(buf, 20, "%d.%d", UV_VERSION_MAJOR, UV_VERSION_MINOR);
versions->Set(String::NewSymbol("uv"), String::New(buf));
-#ifdef HAVE_OPENSSL
+#if HAVE_OPENSSL
// Stupid code to slice out the version string.
int c, l = strlen(OPENSSL_VERSION_TEXT);
for (i = 0; i < l; i++) {
}
size_t size = 2*PATH_MAX;
- char execPath[size];
+ char* execPath = new char[size];
if (uv_exepath(execPath, &size) != 0) {
// as a last ditch effort, fallback on argv[0] ?
process->Set(String::NewSymbol("execPath"), String::New(argv[0]));
} else {
process->Set(String::NewSymbol("execPath"), String::New(execPath, size));
}
+ delete [] execPath;
// define various internal methods
int Start(int argc, char *argv[]) {
-#if defined __MINGW32__ && defined PTW32_STATIC_LIB
+#if (defined(__MINGW32__) || defined(_MSC_VER)) && defined(PTW32_STATIC_LIB)
pthread_win32_process_attach_np();
#endif
V8::Dispose();
#endif // NDEBUG
-#if defined __MINGW32__ && defined PTW32_STATIC_LIB
+#if (defined(__MINGW32__) || defined(_MSC_VER)) && defined(PTW32_STATIC_LIB)
pthread_win32_process_detach_np();
#endif
// A dependency include (libeio\xthread.h) defines _WIN32_WINNT to another value
// This should be defined in make system.
// See issue https://github.com/joyent/node/issues/1236
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
#ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0501
#endif
+
+#define NOMINMAX
+
+#endif
+
+#if defined(_MSC_VER)
+#define PATH_MAX MAX_PATH
#endif
#include <uv.h>
#include <uv.h>
#include <errno.h>
+#if !defined(_MSC_VER)
#include <unistd.h>
+#endif
#include <fcntl.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
# include <platform_win32.h>
#endif
-#ifdef HAVE_OPENSSL
+#if HAVE_OPENSSL
# include <openssl/ssl.h>
#endif
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);
#include "node.h"
#include "node_version.h"
#include <string.h>
+#include <stdio.h>
+#if defined(_MSC_VER)
+#define snprintf _snprintf
+#endif
#undef NODE_EXT_LIST_START
#undef NODE_EXT_LIST_ITEM
#include <sys/types.h>
#include <sys/stat.h>
+#if !defined(_MSC_VER)
#include <sys/time.h>
#include <dirent.h>
+#endif
#include <fcntl.h>
#include <stdlib.h>
+#if !defined(_MSC_VER)
#include <unistd.h>
+#else
+#include <direct.h>
+#define chdir _chdir
+#define rmdir _rmdir
+#define mkdir _mkdir
+#include <io.h>
+#define ftruncate _chsize
+#endif
#include <assert.h>
#include <string.h>
#include <errno.h>
#include <limits.h>
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
# include <platform_win32.h>
#endif
/* HACK to use pread/pwrite from eio because MINGW32 doesn't have it */
/* TODO fixme */
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
# define pread eio__pread
# define pwrite eio__pwrite
#endif
} else {
#if HAVE_FDATASYNC
int ret = fdatasync(fd);
-#elif defined(__MINGW32__)
+#elif defined(__MINGW32__) || defined(_MSC_VER)
int ret = FlushFileBuffers((HANDLE)_get_osfhandle(fd)) ? 0 : -1;
#else
int ret = fsync(fd);
if (args[1]->IsFunction()) {
ASYNC_CALL(fsync, args[1], fd)
} else {
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
int ret = FlushFileBuffers((HANDLE)_get_osfhandle(fd)) ? 0 : -1;
#else
int ret = fsync(fd);
if (args[2]->IsFunction()) {
ASYNC_CALL(mkdir, args[2], *path, mode)
} else {
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
int ret = mkdir(*path);
#else
int ret = mkdir(*path, mode);
if (args[1]->IsFunction()) {
ASYNC_CALL(readdir, args[1], *path, 0 /*flags*/)
} else {
+#if defined(__POSIX__)
DIR *dir = opendir(*path);
if (!dir) return ThrowException(ErrnoException(errno, NULL, "", *path));
-
struct dirent *ent;
+#else
+ WIN32_FIND_DATAA ent = {0};
+ size_t len = strlen(*path);
+ const char* fmt = !len ? "./*"
+ : ((*path)[len - 1] == '/' || (*path)[len - 1] == '\\') ? "%s*"
+ : "%s\\*";
+ char* path2 = new char[len + 4];
+ sprintf(path2, fmt, *path);
+ HANDLE dir = FindFirstFileA(path2, &ent);
+ delete [] path2;
+ if(dir == INVALID_HANDLE_VALUE) return ThrowException(ErrnoException(GetLastError(), "FindFirstFileA", "", path2));
+#endif
Local<Array> files = Array::New();
char *name;
int i = 0;
+#if defined(__POSIX__)
while ((ent = readdir(dir))) {
name = ent->d_name;
-
+#else
+ do {
+ name = ent.cFileName;
+#endif
if (name[0] != '.' || (name[1] && (name[1] != '.' || name[2]))) {
files->Set(Integer::New(i), String::New(name));
i++;
}
}
+#if !defined(__POSIX__)
+ while(FindNextFileA(dir, &ent));
+#endif
+#if defined(__POSIX__)
closedir(dir);
+#else
+ FindClose(dir);
+#endif
return scope.Close(files);
}
#include "node_natives.h"
#include "node_string.h"
#include <string.h>
+#if !defined(_MSC_VER)
#include <strings.h>
+#endif
using namespace v8;
#include <errno.h>
#include <stdlib.h>
+#if defined(__MINGW32__)
#include <sys/param.h> // for MAXPATHLEN
#include <unistd.h> // getpagesize
+#endif
#include <platform_win32.h>
#include <windows.h>
#include <winsock2.h>
\r
+#if defined(_MSC_VER)
+#define STDIN_FILENO 0
+#define STDOUT_FILENO 1
+#define STDERR_FILENO 2
+#endif
+
namespace node {\r
\r
-#define NO_IMPL_MSG(name...) \\r
- fprintf(stderr, "Not implemented: %s\n", #name);\r
+#define NO_IMPL_MSG(...) \\r
+ fprintf(stderr, "Not implemented: %s\n", #__VA_ARGS__);\r
\r
const char *winapi_strerror(const int errorno);\r
void winapi_perror(const char* prefix);\r
#include <stream_wrap.h>
// Temporary hack: libuv should provide uv_inet_pton and uv_inet_ntop.
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
extern "C" {
# include <inet_net_pton.h>
# include <inet_ntop.h>