GCC Code Coverage Report
Directory: ../src/ Exec Total Coverage
File: /home/node-core-coverage/node-core-coverage/workdir/node/src/node_main.cc Lines: 4 4 100.0 %
Date: 2016-07-26 Branches: 0 0 0.0 %

Line Exec Source
1
#include "node.h"
2
3
#ifdef _WIN32
4
#include <VersionHelpers.h>
5
6
int wmain(int argc, wchar_t *wargv[]) {
7
  if (!IsWindows7OrGreater()) {
8
    fprintf(stderr, "This application is only supported on Windows 7, "
9
                    "Windows Server 2008 R2, or higher.");
10
    exit(1);
11
  }
12
13
  // Convert argv to to UTF8
14
  char** argv = new char*[argc + 1];
15
  for (int i = 0; i < argc; i++) {
16
    // Compute the size of the required buffer
17
    DWORD size = WideCharToMultiByte(CP_UTF8,
18
                                     0,
19
                                     wargv[i],
20
                                     -1,
21
                                     nullptr,
22
                                     0,
23
                                     nullptr,
24
                                     nullptr);
25
    if (size == 0) {
26
      // This should never happen.
27
      fprintf(stderr, "Could not convert arguments to utf8.");
28
      exit(1);
29
    }
30
    // Do the actual conversion
31
    argv[i] = new char[size];
32
    DWORD result = WideCharToMultiByte(CP_UTF8,
33
                                       0,
34
                                       wargv[i],
35
                                       -1,
36
                                       argv[i],
37
                                       size,
38
                                       nullptr,
39
                                       nullptr);
40
    if (result == 0) {
41
      // This should never happen.
42
      fprintf(stderr, "Could not convert arguments to utf8.");
43
      exit(1);
44
    }
45
  }
46
  argv[argc] = nullptr;
47
  // Now that conversion is done, we can finally start.
48
  return node::Start(argc, argv);
49
}
50
#else
51
// UNIX
52
1566
int main(int argc, char *argv[]) {
53
  // Disable stdio buffering, it interacts poorly with printf()
54
  // calls elsewhere in the program (e.g., any logging from V8.)
55
1566
  setvbuf(stdout, nullptr, _IONBF, 0);
56
1566
  setvbuf(stderr, nullptr, _IONBF, 0);
57
1566
  return node::Start(argc, argv);
58
}
59
#endif