You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2022/06/22 15:00:21 UTC
[tomcat-native] 03/03: Remove unnecessary / unused code
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat-native.git
commit ae1b334538a3575370ac527cfb5679bd0c95730c
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Jun 22 12:51:44 2022 +0100
Remove unnecessary / unused code
---
native/os/win32/libtcnative.rc | 1 -
native/os/win32/logmessages.bin | Bin 224 -> 0 bytes
native/os/win32/logmessages.mc | 41 -------
native/os/win32/system.c | 255 ----------------------------------------
4 files changed, 297 deletions(-)
diff --git a/native/os/win32/libtcnative.rc b/native/os/win32/libtcnative.rc
index 841d8ea3e..f9ea95975 100644
--- a/native/os/win32/libtcnative.rc
+++ b/native/os/win32/libtcnative.rc
@@ -1,7 +1,6 @@
#include <windows.h>
LANGUAGE 0x9,0x1
-1 11 logmessages.bin
#define TCN_COPYRIGHT "Licensed to the Apache Software Foundation (ASF) under " \
"one or more contributor license agreements. See the " \
diff --git a/native/os/win32/logmessages.bin b/native/os/win32/logmessages.bin
deleted file mode 100644
index 44ce98505..000000000
Binary files a/native/os/win32/logmessages.bin and /dev/null differ
diff --git a/native/os/win32/logmessages.mc b/native/os/win32/logmessages.mc
deleted file mode 100644
index 68f86f644..000000000
--- a/native/os/win32/logmessages.mc
+++ /dev/null
@@ -1,41 +0,0 @@
-MessageId=0x1
-Severity=Error
-SymbolicName=LOG_MSG_EMERG
-Language=English
-Emerg: %1
-.
-
-MessageId=0x2
-Severity=Error
-SymbolicName=LOG_MSG_ERROR
-Language=English
-Error: %1
-.
-
-MessageId=0x3
-Severity=Warning
-SymbolicName=LOG_MSG_NOTICE
-Language=English
-Notice: %1
-.
-
-MessageId=0x4
-Severity=Warning
-SymbolicName=LOG_MSG_WARN
-Language=English
-Warn: %1
-.
-
-MessageId=0x5
-Severity=Informational
-SymbolicName=LOG_MSG_INFO
-Language=English
-Info: %1
-.
-
-MessageId=0x6
-Severity=Success
-SymbolicName=LOG_MSG_DEBUG
-Language=English
-Debug: %1
-.
diff --git a/native/os/win32/system.c b/native/os/win32/system.c
index 42adf611f..ad9c58ae4 100644
--- a/native/os/win32/system.c
+++ b/native/os/win32/system.c
@@ -14,9 +14,6 @@
* limitations under the License.
*/
-#ifndef _WIN32_WINNT
-#define _WIN32_WINNT 0x0500
-#endif
#include <winsock2.h>
#include <mswsock.h>
#include <ws2tcpip.h>
@@ -34,9 +31,6 @@
#pragma warning(push)
#pragma warning(disable : 4201)
-#if (_WIN32_WINNT < 0x0501)
-#include <winternl.h>
-#endif
#include <psapi.h>
#pragma warning(pop)
@@ -50,10 +44,6 @@ static char dll_file_name[MAX_PATH];
typedef BOOL (WINAPI *pfnGetSystemTimes)(LPFILETIME, LPFILETIME, LPFILETIME);
static pfnGetSystemTimes fnGetSystemTimes = NULL;
-#if (_WIN32_WINNT < 0x0501)
-typedef NTSTATUS (WINAPI *pfnNtQuerySystemInformation)(SYSTEM_INFORMATION_CLASS, PVOID, ULONG, PULONG);
-static pfnNtQuerySystemInformation fnNtQuerySystemInformation = NULL;
-#endif
BOOL
WINAPI
@@ -122,251 +112,6 @@ DllMain(
}
-TCN_IMPLEMENT_CALL(jstring, OS, syserror)(TCN_STDARGS, jint err)
-{
- jstring str;
- void *buf;
-
- UNREFERENCED(o);
- if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- err,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR)&buf,
- 0,
- NULL)) {
- str = AJP_TO_JSTRING("Unknown Error");
- }
- else {
- str = AJP_TO_JSTRING((const char *)buf);
- LocalFree(buf);
- }
- return str;
-}
-
-TCN_IMPLEMENT_CALL(jstring, OS, expand)(TCN_STDARGS, jstring val)
-{
- jstring str;
- jchar buf[TCN_BUFFER_SZ] = L"";
- DWORD len;
- TCN_ALLOC_WSTRING(val);
-
- UNREFERENCED(o);
- TCN_INIT_WSTRING(val);
-
- len = ExpandEnvironmentStringsW(J2W(val), buf, TCN_BUFFER_SZ - 1);
- if (len > (TCN_BUFFER_SZ - 1)) {
- jchar *dbuf = malloc((len + 1) * 2);
- ExpandEnvironmentStringsW(J2W(val), dbuf, len);
- str = (*e)->NewString(e, dbuf, lstrlenW(dbuf));
- free(dbuf);
- }
- else
- str = (*e)->NewString(e, buf, lstrlenW(buf));
-
- TCN_FREE_WSTRING(val);
- return str;
-}
-
-#define LOG_MSG_EMERG 0xC0000001L
-#define LOG_MSG_ERROR 0xC0000002L
-#define LOG_MSG_NOTICE 0x80000003L
-#define LOG_MSG_WARN 0x80000004L
-#define LOG_MSG_INFO 0x40000005L
-#define LOG_MSG_DEBUG 0x00000006L
-#define LOG_MSG_DOMAIN "Native"
-
-static char log_domain[MAX_PATH] = "Native";
-
-static void init_log_source(const char *domain)
-{
- HKEY key;
- DWORD ts;
- char event_key[MAX_PATH];
-
- strcpy(event_key, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\");
- strcat(event_key, domain);
- if (!RegCreateKey(HKEY_LOCAL_MACHINE, event_key, &key)) {
- RegSetValueEx(key, "EventMessageFile", 0, REG_SZ, (LPBYTE)&dll_file_name[0],
- lstrlenA(dll_file_name) + 1);
- ts = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE;
-
- RegSetValueEx(key, "TypesSupported", 0, REG_DWORD, (LPBYTE) &ts, sizeof(DWORD));
- RegCloseKey(key);
- }
- strcpy(log_domain, domain);
-}
-
-TCN_IMPLEMENT_CALL(void, OS, sysloginit)(TCN_STDARGS, jstring domain)
-{
- const char *d;
- TCN_ALLOC_CSTRING(domain);
-
- UNREFERENCED(o);
-
- if ((d = J2S(domain)) == NULL)
- d = LOG_MSG_DOMAIN;
- init_log_source(d);
-
- TCN_FREE_CSTRING(domain);
-}
-
-TCN_IMPLEMENT_CALL(void, OS, syslog)(TCN_STDARGS, jint level,
- jstring msg)
-{
- TCN_ALLOC_CSTRING(msg);
- DWORD id = LOG_MSG_DEBUG;
- WORD il = EVENTLOG_SUCCESS;
- HANDLE source;
- const char *messages[1];
- UNREFERENCED(o);
-
- switch (level) {
- case TCN_LOG_EMERG:
- id = LOG_MSG_EMERG;
- il = EVENTLOG_ERROR_TYPE;
- break;
- case TCN_LOG_ERROR:
- id = LOG_MSG_ERROR;
- il = EVENTLOG_ERROR_TYPE;
- break;
- case TCN_LOG_NOTICE:
- id = LOG_MSG_NOTICE;
- il = EVENTLOG_WARNING_TYPE;
- break;
- case TCN_LOG_WARN:
- id = LOG_MSG_WARN;
- il = EVENTLOG_WARNING_TYPE;
- break;
- case TCN_LOG_INFO:
- id = LOG_MSG_INFO;
- il = EVENTLOG_INFORMATION_TYPE;
- break;
- }
-
- messages[0] = J2S(msg);
- source = RegisterEventSource(NULL, log_domain);
-
- if (source != NULL) {
- ReportEvent(source, il,
- 0,
- id,
- NULL,
- 1, 0,
- messages, NULL);
- DeregisterEventSource(source);
- }
-
- TCN_FREE_CSTRING(msg);
-}
-
-TCN_IMPLEMENT_CALL(jboolean, OS, is)(TCN_STDARGS, jint type)
-{
- UNREFERENCED_STDARGS;
-#ifdef _WIN64
- if (type == 4)
- return JNI_TRUE;
- else
-#endif
- if (type == 3)
- return JNI_TRUE;
- else
- return JNI_FALSE;
-}
-
-TCN_IMPLEMENT_CALL(jint, OS, info)(TCN_STDARGS,
- jlongArray inf)
-{
- MEMORYSTATUSEX ms;
- ULONGLONG st[4];
- FILETIME ft[4];
- PROCESS_MEMORY_COUNTERS pmc;
- jint rv;
- int i;
- jsize ilen = (*e)->GetArrayLength(e, inf);
- jlong *pvals = (*e)->GetLongArrayElements(e, inf, NULL);
-
- if (ilen < 16) {
- return APR_EINVAL;
- }
- for (i = 0; i < 16; i++)
- pvals[i] = 0;
-
- ms.dwLength = sizeof(MEMORYSTATUSEX);
-
- UNREFERENCED(o);
- if (GlobalMemoryStatusEx(&ms)) {
- pvals[0] = (jlong)ms.ullTotalPhys;
- pvals[1] = (jlong)ms.ullAvailPhys;
- pvals[2] = (jlong)ms.ullTotalPageFile;
- pvals[3] = (jlong)ms.ullAvailPageFile;
- /* Slots 4 and 5 are for shared memory */
- pvals[6] = (jlong)ms.dwMemoryLoad;
- }
- else
- goto cleanup;
-
- memset(st, 0, sizeof(st));
-
- if (fnGetSystemTimes) {
- if ((*fnGetSystemTimes)(&ft[0], &ft[1], &ft[2])) {
- st[0] = (((ULONGLONG)ft[0].dwHighDateTime << 32) | ft[0].dwLowDateTime) / 10;
- st[1] = (((ULONGLONG)ft[1].dwHighDateTime << 32) | ft[1].dwLowDateTime) / 10;
- st[2] = (((ULONGLONG)ft[2].dwHighDateTime << 32) | ft[2].dwLowDateTime) / 10;
- }
- else
- goto cleanup;
- }
-#if (_WIN32_WINNT < 0x0501)
- else if (fnNtQuerySystemInformation) {
- BYTE buf[2048]; /* This should ne enough for 32 processors */
- NTSTATUS rs = (*fnNtQuerySystemInformation)(SystemProcessorPerformanceInformation,
- (LPVOID)buf, 2048, NULL);
- if (rs == 0) {
- PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION pspi = (PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION)&buf[0];
- DWORD i;
- /* Calculate all processors */
- for (i = 0; i < dll_system_info.dwNumberOfProcessors; i++) {
- st[0] += pspi[i].IdleTime.QuadPart / 10;
- st[1] += pspi[i].KernelTime.QuadPart / 10;
- st[2] += pspi[i].UserTime.QuadPart / 10;
- }
- }
- else
- goto cleanup;
- }
-#endif
- pvals[7] = st[0];
- pvals[8] = st[1];
- pvals[9] = st[2];
-
- memset(st, 0, sizeof(st));
- if (GetProcessTimes(GetCurrentProcess(), &ft[0], &ft[1], &ft[2], &ft[3])) {
- FileTimeToAprTime((apr_time_t *)&st[0], &ft[0]);
- st[1] = (((ULONGLONG)ft[2].dwHighDateTime << 32) | ft[2].dwLowDateTime) / 10;
- st[2] = (((ULONGLONG)ft[3].dwHighDateTime << 32) | ft[3].dwLowDateTime) / 10;
- }
- pvals[10] = st[0];
- pvals[11] = st[1];
- pvals[12] = st[2];
-
- if (GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc))) {
- pvals[13] = pmc.WorkingSetSize;
- pvals[14] = pmc.PeakWorkingSetSize;
- pvals[15] = pmc.PageFaultCount;
- }
-
- (*e)->ReleaseLongArrayElements(e, inf, pvals, 0);
- return APR_SUCCESS;
-cleanup:
- rv = apr_get_os_error();
- (*e)->ReleaseLongArrayElements(e, inf, pvals, 0);
- return rv;
-}
-
-
static DWORD WINAPI password_thread(void *data)
{
tcn_pass_cb_t *cb = (tcn_pass_cb_t *)data;
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org