| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent bd270b4 commit 13d6a1f
10 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,14 +23,14 @@ | |||
| 23 | 23 | #include <node.h> | |
| 24 | 24 | #include <uv.h> | |
| 25 | 25 | ||
| 26 | - #if defined(__OpenBSD__) || defined(__MINGW32__) | ||
| 26 | + #if defined(__OpenBSD__) || defined(__MINGW32__) || defined(_MSC_VER) | ||
| 27 | 27 | # include <nameser.h> | |
| 28 | 28 | #else | |
| 29 | 29 | # include <arpa/nameser.h> | |
| 30 | 30 | #endif | |
| 31 | 31 | ||
| 32 | 32 | // Temporary hack: libuv should provide uv_inet_pton and uv_inet_ntop. | |
| 33 | - #ifdef __MINGW32__ | ||
| 33 | + #if defined(__MINGW32__) || defined(_MSC_VER) | ||
| 34 | 34 | extern "C" { | |
| 35 | 35 | # include <inet_net_pton.h> | |
| 36 | 36 | # include <inet_ntop.h> | |
@@ -170,10 +170,12 @@ class QueryWrap { | |||
| 170 | 170 | // Subclasses should implement the appropriate Send method. | |
| 171 | 171 | virtual int Send(const char* name) { | |
| 172 | 172 | assert(0); | |
| 173 | + return 0; | ||
| 173 | 174 | } | |
| 174 | 175 | ||
| 175 | 176 | virtual int Send(const char* name, int family) { | |
| 176 | 177 | assert(0); | |
| 178 | + return 0; | ||
| 177 | 179 | } | |
| 178 | 180 | ||
| 179 | 181 | protected: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,17 +29,31 @@ | |||
| 29 | 29 | #include <locale.h> | |
| 30 | 30 | #include <signal.h> | |
| 31 | 31 | #include <stdio.h> | |
| 32 | + #if defined(_MSC_VER) | ||
| 33 | + #define snprintf _snprintf | ||
| 34 | + #endif | ||
| 32 | 35 | #include <stdlib.h> | |
| 33 | - #include <strings.h> | ||
| 34 | 36 | #include <string.h> | |
| 37 | + #if !defined(_MSC_VER) | ||
| 38 | + #include <strings.h> | ||
| 39 | + #else | ||
| 40 | + #define strcasecmp _stricmp | ||
| 41 | + #endif | ||
| 35 | 42 | #include <limits.h> /* PATH_MAX */ | |
| 36 | 43 | #include <assert.h> | |
| 37 | - #include <unistd.h> | ||
| 44 | + #if !defined(_MSC_VER) | ||
| 45 | + #include <unistd.h> /* setuid, getuid */ | ||
| 46 | + #else | ||
| 47 | + #include <direct.h> | ||
| 48 | + #define chdir _chdir | ||
| 49 | + #define getcwd _getcwd | ||
| 50 | + #include <process.h> | ||
| 51 | + #define getpid _getpid | ||
| 52 | + #endif | ||
| 38 | 53 | #include <errno.h> | |
| 39 | 54 | #include <sys/types.h> | |
| 40 | - #include <unistd.h> /* setuid, getuid */ | ||
| 41 | 55 | ||
| 42 | - #ifdef __MINGW32__ | ||
| 56 | + #if defined(__MINGW32__) || defined(_MSC_VER) | ||
| 43 | 57 | # include <platform_win32.h> /* winapi_perror() */ | |
| 44 | 58 | # ifdef PTW32_STATIC_LIB | |
| 45 | 59 | extern "C" { | |
@@ -69,13 +83,15 @@ extern "C" { | |||
| 69 | 83 | # include <node_stat_watcher.h> | |
| 70 | 84 | # include <node_timer.h> | |
| 71 | 85 | #endif | |
| 86 | + #if !defined(_MSC_VER) | ||
| 72 | 87 | #include <node_child_process.h> | |
| 88 | + #endif | ||
| 73 | 89 | #include <node_constants.h> | |
| 74 | 90 | #include <node_stdio.h> | |
| 75 | 91 | #include <node_javascript.h> | |
| 76 | 92 | #include <node_version.h> | |
| 77 | 93 | #include <node_string.h> | |
| 78 | - #ifdef HAVE_OPENSSL | ||
| 94 | + #if HAVE_OPENSSL | ||
| 79 | 95 | # include <node_crypto.h> | |
| 80 | 96 | #endif | |
| 81 | 97 | #include <node_script.h> | |
@@ -87,7 +103,7 @@ using namespace v8; | |||
| 87 | 103 | # ifdef __APPLE__ | |
| 88 | 104 | # include <crt_externs.h> | |
| 89 | 105 | # define environ (*_NSGetEnviron()) | |
| 90 | - # else | ||
| 106 | + # elif !defined(_MSC_VER) | ||
| 91 | 107 | extern char **environ; | |
| 92 | 108 | # endif | |
| 93 | 109 | ||
@@ -2086,7 +2102,7 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) { | |||
| 2086 | 2102 | versions->Set(String::NewSymbol("ares"), String::New(ARES_VERSION_STR)); | |
| 2087 | 2103 | snprintf(buf, 20, "%d.%d", UV_VERSION_MAJOR, UV_VERSION_MINOR); | |
| 2088 | 2104 | versions->Set(String::NewSymbol("uv"), String::New(buf)); | |
| 2089 | - #ifdef HAVE_OPENSSL | ||
| 2105 | + #if HAVE_OPENSSL | ||
| 2090 | 2106 | // Stupid code to slice out the version string. | |
| 2091 | 2107 | int c, l = strlen(OPENSSL_VERSION_TEXT); | |
| 2092 | 2108 | for (i = 0; i < l; i++) { | |
@@ -2154,13 +2170,14 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) { | |||
| 2154 | 2170 | } | |
| 2155 | 2171 | ||
| 2156 | 2172 | size_t size = 2*PATH_MAX; | |
| 2157 | - char execPath[size]; | ||
| 2173 | + char* execPath = new char[size]; | ||
| 2158 | 2174 | if (uv_exepath(execPath, &size) != 0) { | |
| 2159 | 2175 | // as a last ditch effort, fallback on argv[0] ? | |
| 2160 | 2176 | process->Set(String::NewSymbol("execPath"), String::New(argv[0])); | |
| 2161 | 2177 | } else { | |
| 2162 | 2178 | process->Set(String::NewSymbol("execPath"), String::New(execPath, size)); | |
| 2163 | 2179 | } | |
| 2180 | + delete [] execPath; | ||
| 2164 | 2181 | ||
| 2165 | 2182 | ||
| 2166 | 2183 | // define various internal methods | |
@@ -2531,7 +2548,7 @@ void EmitExit(v8::Handle<v8::Object> process) { | |||
| 2531 | 2548 | ||
| 2532 | 2549 | int Start(int argc, char *argv[]) { | |
| 2533 | 2550 | ||
| 2534 | - #if defined __MINGW32__ && defined PTW32_STATIC_LIB | ||
| 2551 | + #if (defined(__MINGW32__) || defined(_MSC_VER)) && defined(PTW32_STATIC_LIB) | ||
| 2535 | 2552 | pthread_win32_process_attach_np(); | |
| 2536 | 2553 | #endif | |
| 2537 | 2554 | ||
@@ -2568,7 +2585,7 @@ int Start(int argc, char *argv[]) { | |||
| 2568 | 2585 | V8::Dispose(); | |
| 2569 | 2586 | #endif // NDEBUG | |
| 2570 | 2587 | ||
| 2571 | - #if defined __MINGW32__ && defined PTW32_STATIC_LIB | ||
| 2588 | + #if (defined(__MINGW32__) || defined(_MSC_VER)) && defined(PTW32_STATIC_LIB) | ||
| 2572 | 2589 | pthread_win32_process_detach_np(); | |
| 2573 | 2590 | #endif | |
| 2574 | 2591 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,10 +25,17 @@ | |||
| 25 | 25 | // A dependency include (libeio\xthread.h) defines _WIN32_WINNT to another value | |
| 26 | 26 | // This should be defined in make system. | |
| 27 | 27 | // See issue https://github.com/joyent/node/issues/1236 | |
| 28 | - #ifdef __MINGW32__ | ||
| 28 | + #if defined(__MINGW32__) || defined(_MSC_VER) | ||
| 29 | 29 | #ifndef _WIN32_WINNT | |
| 30 | 30 | # define _WIN32_WINNT 0x0501 | |
| 31 | 31 | #endif | |
| 32 | + | ||
| 33 | + #define NOMINMAX | ||
| 34 | + | ||
| 35 | + #endif | ||
| 36 | + | ||
| 37 | + #if defined(_MSC_VER) | ||
| 38 | + #define PATH_MAX MAX_PATH | ||
| 32 | 39 | #endif | |
| 33 | 40 | ||
| 34 | 41 | #include <uv.h> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,17 +24,19 @@ | |||
| 24 | 24 | #include <uv.h> | |
| 25 | 25 | ||
| 26 | 26 | #include <errno.h> | |
| 27 | + #if !defined(_MSC_VER) | ||
| 27 | 28 | #include <unistd.h> | |
| 29 | + #endif | ||
| 28 | 30 | #include <fcntl.h> | |
| 29 | 31 | #include <signal.h> | |
| 30 | 32 | #include <sys/types.h> | |
| 31 | 33 | #include <sys/stat.h> | |
| 32 | 34 | ||
| 33 | - #ifdef __MINGW32__ | ||
| 35 | + #if defined(__MINGW32__) || defined(_MSC_VER) | ||
| 34 | 36 | # include <platform_win32.h> | |
| 35 | 37 | #endif | |
| 36 | 38 | ||
| 37 | - #ifdef HAVE_OPENSSL | ||
| 39 | + #if HAVE_OPENSSL | ||
| 38 | 40 | # include <openssl/ssl.h> | |
| 39 | 41 | #endif | |
| 40 | 42 | ||
@@ -52,8 +54,13 @@ void DefineConstants(Handle<Object> target) { | |||
| 52 | 54 | NODE_DEFINE_CONSTANT(target, S_IFREG); | |
| 53 | 55 | NODE_DEFINE_CONSTANT(target, S_IFDIR); | |
| 54 | 56 | NODE_DEFINE_CONSTANT(target, S_IFCHR); | |
| 57 | + #ifdef S_IFBLK | ||
| 55 | 58 | NODE_DEFINE_CONSTANT(target, S_IFBLK); | |
| 59 | + #endif | ||
| 60 | + | ||
| 61 | + #ifdef S_IFIFO | ||
| 56 | 62 | NODE_DEFINE_CONSTANT(target, S_IFIFO); | |
| 63 | + #endif | ||
| 57 | 64 | ||
| 58 | 65 | #ifdef S_IFLNK | |
| 59 | 66 | NODE_DEFINE_CONSTANT(target, S_IFLNK); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,6 +23,10 @@ | |||
| 23 | 23 | #include "node.h" | |
| 24 | 24 | #include "node_version.h" | |
| 25 | 25 | #include <string.h> | |
| 26 | + #include <stdio.h> | ||
| 27 | + #if defined(_MSC_VER) | ||
| 28 | + #define snprintf _snprintf | ||
| 29 | + #endif | ||
| 26 | 30 | ||
| 27 | 31 | #undef NODE_EXT_LIST_START | |
| 28 | 32 | #undef NODE_EXT_LIST_ITEM | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,17 +28,28 @@ | |||
| 28 | 28 | ||
| 29 | 29 | #include <sys/types.h> | |
| 30 | 30 | #include <sys/stat.h> | |
| 31 | + #if !defined(_MSC_VER) | ||
| 31 | 32 | #include <sys/time.h> | |
| 32 | 33 | #include <dirent.h> | |
| 34 | + #endif | ||
| 33 | 35 | #include <fcntl.h> | |
| 34 | 36 | #include <stdlib.h> | |
| 37 | + #if !defined(_MSC_VER) | ||
| 35 | 38 | #include <unistd.h> | |
| 39 | + #else | ||
| 40 | + #include <direct.h> | ||
| 41 | + #define chdir _chdir | ||
| 42 | + #define rmdir _rmdir | ||
| 43 | + #define mkdir _mkdir | ||
| 44 | + #include <io.h> | ||
| 45 | + #define ftruncate _chsize | ||
| 46 | + #endif | ||
| 36 | 47 | #include <assert.h> | |
| 37 | 48 | #include <string.h> | |
| 38 | 49 | #include <errno.h> | |
| 39 | 50 | #include <limits.h> | |
| 40 | 51 | ||
| 41 | - #ifdef __MINGW32__ | ||
| 52 | + #if defined(__MINGW32__) || defined(_MSC_VER) | ||
| 42 | 53 | # include <platform_win32.h> | |
| 43 | 54 | #endif | |
| 44 | 55 | ||
@@ -49,7 +60,7 @@ | |||
| 49 | 60 | ||
| 50 | 61 | /* HACK to use pread/pwrite from eio because MINGW32 doesn't have it */ | |
| 51 | 62 | /* TODO fixme */ | |
| 52 | - #ifdef __MINGW32__ | ||
| 63 | + #if defined(__MINGW32__) || defined(_MSC_VER) | ||
| 53 | 64 | # define pread eio__pread | |
| 54 | 65 | # define pwrite eio__pwrite | |
| 55 | 66 | #endif | |
@@ -515,7 +526,7 @@ static Handle<Value> Fdatasync(const Arguments& args) { | |||
| 515 | 526 | } else { | |
| 516 | 527 | #if HAVE_FDATASYNC | |
| 517 | 528 | int ret = fdatasync(fd); | |
| 518 | - #elif defined(__MINGW32__) | ||
| 529 | + #elif defined(__MINGW32__) || defined(_MSC_VER) | ||
| 519 | 530 | int ret = FlushFileBuffers((HANDLE)_get_osfhandle(fd)) ? 0 : -1; | |
| 520 | 531 | #else | |
| 521 | 532 | int ret = fsync(fd); | |
@@ -537,7 +548,7 @@ static Handle<Value> Fsync(const Arguments& args) { | |||
| 537 | 548 | if (args[1]->IsFunction()) { | |
| 538 | 549 | ASYNC_CALL(fsync, args[1], fd) | |
| 539 | 550 | } else { | |
| 540 | - #ifdef __MINGW32__ | ||
| 551 | + #if defined(__MINGW32__) || defined(_MSC_VER) | ||
| 541 | 552 | int ret = FlushFileBuffers((HANDLE)_get_osfhandle(fd)) ? 0 : -1; | |
| 542 | 553 | #else | |
| 543 | 554 | int ret = fsync(fd); | |
@@ -596,7 +607,7 @@ static Handle<Value> MKDir(const Arguments& args) { | |||
| 596 | 607 | if (args[2]->IsFunction()) { | |
| 597 | 608 | ASYNC_CALL(mkdir, args[2], *path, mode) | |
| 598 | 609 | } else { | |
| 599 | - #ifdef __MINGW32__ | ||
| 610 | + #if defined(__MINGW32__) || defined(_MSC_VER) | ||
| 600 | 611 | int ret = mkdir(*path); | |
| 601 | 612 | #else | |
| 602 | 613 | int ret = mkdir(*path, mode); | |
@@ -644,25 +655,48 @@ static Handle<Value> ReadDir(const Arguments& args) { | |||
| 644 | 655 | if (args[1]->IsFunction()) { | |
| 645 | 656 | ASYNC_CALL(readdir, args[1], *path, 0 /*flags*/) | |
| 646 | 657 | } else { | |
| 658 | + #if defined(__POSIX__) | ||
| 647 | 659 | DIR *dir = opendir(*path); | |
| 648 | 660 | if (!dir) return ThrowException(ErrnoException(errno, NULL, "", *path)); | |
| 649 | - | ||
| 650 | 661 | struct dirent *ent; | |
| 662 | + #else | ||
| 663 | + WIN32_FIND_DATAA ent = {0}; | ||
| 664 | + size_t len = strlen(*path); | ||
| 665 | + const char* fmt = !len ? "./*" | ||
| 666 | + : ((*path)[len - 1] == '/' || (*path)[len - 1] == '\\') ? "%s*" | ||
| 667 | + : "%s\\*"; | ||
| 668 | + char* path2 = new char[len + 4]; | ||
| 669 | + sprintf(path2, fmt, *path); | ||
| 670 | + HANDLE dir = FindFirstFileA(path2, &ent); | ||
| 671 | + delete [] path2; | ||
| 672 | + if(dir == INVALID_HANDLE_VALUE) return ThrowException(ErrnoException(GetLastError(), "FindFirstFileA", "", path2)); | ||
| 673 | + #endif | ||
| 651 | 674 | ||
| 652 | 675 | Local<Array> files = Array::New(); | |
| 653 | 676 | char *name; | |
| 654 | 677 | int i = 0; | |
| 655 | 678 | ||
| 679 | + #if defined(__POSIX__) | ||
| 656 | 680 | while ((ent = readdir(dir))) { | |
| 657 | 681 | name = ent->d_name; | |
| 658 | - | ||
| 682 | + #else | ||
| 683 | + do { | ||
| 684 | + name = ent.cFileName; | ||
| 685 | + #endif | ||
| 659 | 686 | if (name[0] != '.' || (name[1] && (name[1] != '.' || name[2]))) { | |
| 660 | 687 | files->Set(Integer::New(i), String::New(name)); | |
| 661 | 688 | i++; | |
| 662 | 689 | } | |
| 663 | 690 | } | |
| 691 | + #if !defined(__POSIX__) | ||
| 692 | + while(FindNextFileA(dir, &ent)); | ||
| 693 | + #endif | ||
| 664 | 694 | ||
| 695 | + #if defined(__POSIX__) | ||
| 665 | 696 | closedir(dir); | |
| 697 | + #else | ||
| 698 | + FindClose(dir); | ||
| 699 | + #endif | ||
| 666 | 700 | ||
| 667 | 701 | return scope.Close(files); | |
| 668 | 702 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,7 +24,9 @@ | |||
| 24 | 24 | #include "node_natives.h" | |
| 25 | 25 | #include "node_string.h" | |
| 26 | 26 | #include <string.h> | |
| 27 | + #if !defined(_MSC_VER) | ||
| 27 | 28 | #include <strings.h> | |
| 29 | + #endif | ||
| 28 | 30 | ||
| 29 | 31 | using namespace v8; | |
| 30 | 32 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,8 +27,10 @@ | |||
| 27 | 27 | ||
| 28 | 28 | #include <errno.h> | |
| 29 | 29 | #include <stdlib.h> | |
| 30 | + #if defined(__MINGW32__) | ||
| 30 | 31 | #include <sys/param.h> // for MAXPATHLEN | |
| 31 | 32 | #include <unistd.h> // getpagesize | |
| 33 | + #endif | ||
| 32 | 34 | ||
| 33 | 35 | #include <platform_win32.h> | |
| 34 | 36 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,10 +59,16 @@ | |||
| 59 | 59 | #include <windows.h> | |
| 60 | 60 | #include <winsock2.h> | |
| 61 | 61 | ||
| 62 | + #if defined(_MSC_VER) | ||
| 63 | + #define STDIN_FILENO 0 | ||
| 64 | + #define STDOUT_FILENO 1 | ||
| 65 | + #define STDERR_FILENO 2 | ||
| 66 | + #endif | ||
| 67 | + | ||
| 62 | 68 | namespace node { | |
| 63 | 69 | ||
| 64 | - #define NO_IMPL_MSG(name...) \ | ||
| 65 | - fprintf(stderr, "Not implemented: %s\n", #name); | ||
| 70 | + #define NO_IMPL_MSG(...) \ | ||
| 71 | + fprintf(stderr, "Not implemented: %s\n", #__VA_ARGS__); | ||
| 66 | 72 | ||
| 67 | 73 | const char *winapi_strerror(const int errorno); | |
| 68 | 74 | void winapi_perror(const char* prefix); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,7 +5,7 @@ | |||
| 5 | 5 | #include <stream_wrap.h> | |
| 6 | 6 | ||
| 7 | 7 | // Temporary hack: libuv should provide uv_inet_pton and uv_inet_ntop. | |
| 8 | - #ifdef __MINGW32__ | ||
| 8 | + #if defined(__MINGW32__) || defined(_MSC_VER) | ||
| 9 | 9 | extern "C" { | |
| 10 | 10 | # include <inet_net_pton.h> | |
| 11 | 11 | # include <inet_ntop.h> | |
| Back | FazBrowse Home | New Git URL |
0 commit comments