comparison src/os/win32/ngx_init.c @ 102:7e86d028d8f0

nginx-0.0.1-2003-06-06-18:59:20 import
author Igor Sysoev <igor@sysoev.ru>
date Fri, 06 Jun 2003 14:59:20 +0000
parents 7ebc8b7fb816
children
comparison
equal deleted inserted replaced
101:2e069b6e6920 102:7e86d028d8f0
24 static GUID tf_guid = WSAID_TRANSMITFILE; 24 static GUID tf_guid = WSAID_TRANSMITFILE;
25 25
26 26
27 int ngx_os_init(ngx_log_t *log) 27 int ngx_os_init(ngx_log_t *log)
28 { 28 {
29 DWORD bytes; 29 u_int sp;
30 SOCKET s; 30 DWORD bytes;
31 WSADATA wsd; 31 SOCKET s;
32 WSADATA wsd;
33 OSVERSIONINFOEX osvi;
34
35 /* get Windows version */
36
37 ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
38 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
39
40 osviex = GetVersionEx((OSVERSIONINFO *) &osvi);
41
42 if (osviex == 0) {
43 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
44 if (GetVersionEx((OSVERSIONINFO *) &osvi) == 0)
45 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
46 "GetVersionEx() failed");
47 return NGX_ERROR;
48 }
49 }
50
51 /*
52 * Windows 95 1400
53 * Windows 98 1410
54 * Windows ME 1490
55 * Windows NT 3.51 2351
56 * Windows NT 4.0 2400
57 * Windows 2000 2500
58 * Windows XP 2501
59 * Windows 2003 2502
60 */
61
62 ngx_win32_version = osvi.dwPlatformId * 1000
63 + osvi.dwMajorVersion * 100
64 + osvi.dwMinorVersion;
65
66 if (osviex) {
67 sp = osvi.wServicePackMajor * 100 + osvi.wServicePackMinor;
68
69 ngx_log_error(NGX_LOG_INFO, log, 0,
70 "OS: %u build:%u, %s, SP:%u, suite:%x, type:%u",
71 ngx_win32_version, osvi.dwBuildNumber, osvi.szCSDVersion,
72 sp, osvi.wSuiteMask, osvi.wProductType);
73
74 } else {
75 ngx_log_error(NGX_LOG_INFO, log, 0, "OS: %u build:%u, %s",
76 ngx_win32_version, osvi.dwBuildNumber, osvi.szCSDVersion);
77 }
78
32 79
33 /* init Winsock */ 80 /* init Winsock */
34 81
35 if (WSAStartup(MAKEWORD(2,2), &wsd) != 0) { 82 if (WSAStartup(MAKEWORD(2,2), &wsd) != 0) {
36 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, 83 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
37 "WSAStartup failed"); 84 "WSAStartup() failed");
38 return NGX_ERROR; 85 return NGX_ERROR;
39 } 86 }
40
41 ngx_log_error(NGX_LOG_INFO, log, 0, "max sockets: %d", wsd.iMaxSockets);
42 87
43 /* get AcceptEx(), GetAcceptExSockAddrs() and TransmitFile() addresses */ 88 /* get AcceptEx(), GetAcceptExSockAddrs() and TransmitFile() addresses */
44 89
45 s = ngx_socket(AF_INET, SOCK_STREAM, IPPROTO_IP, 0); 90 s = ngx_socket(AF_INET, SOCK_STREAM, IPPROTO_IP, 0);
46 if (s == -1) { 91 if (s == -1) {