From f6531372757188ad4853eb7d355299317603216f Mon Sep 17 00:00:00 2001 From: "certus certus@31f1291d-b8d6-0310-a050-a5561fc1590b" Date: Tue, 14 Mar 2006 15:01:51 +0000 Subject: # BUILD : 1.7.13 (1008) # BUGS : 473 474 # NOTES : gcc switches and win98 stop, thx 2 trystan git-svn-id: svn://svn.anope.org/anope/trunk@1008 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@733 5417fbe8-f217-4b02-8779-1006273d7864 --- src/core/Makefile | 2 +- src/core/Makefile.sub | 2 +- src/init.c | 10 ++++ src/main.c | 6 +- src/misc.c | 148 +++++++++++++++++++++++++++++++++++++++++++++- src/modules/Makefile | 2 +- src/modules/Makefile.sub | 2 +- src/protocol/Makefile | 2 +- src/protocol/Makefile.sub | 2 +- 9 files changed, 167 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/core/Makefile b/src/core/Makefile index 602d43bec..254e8d0d3 100644 --- a/src/core/Makefile +++ b/src/core/Makefile @@ -9,7 +9,7 @@ MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'ANOPELIBS=${ANOPELIBS}' \ OBJECTS= $(SRCS:.c=.o) SO_FILES=$(OBJECTS:.o=.s) -CDEFS= -g -rdynamic -Wall +CDEFS= -rdynamic -Wall all: modules subs diff --git a/src/core/Makefile.sub b/src/core/Makefile.sub index 7c4744ce8..21dfab3d7 100644 --- a/src/core/Makefile.sub +++ b/src/core/Makefile.sub @@ -7,7 +7,7 @@ MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'ANOPELIBS=${ANOPELIBS}' \ OBJECTS= $(SRCS:.c=.o) SO_FILES=$(OBJECTS:.o=.s) -CDEFS= -g -rdynamic -Wall +CDEFS= -rdynamic -Wall all: module diff --git a/src/init.c b/src/init.c index f0212cc70..04f2e64b9 100644 --- a/src/init.c +++ b/src/init.c @@ -405,6 +405,9 @@ int openlog_failed = 0, openlog_errno = 0; int init_primary(int ac, char **av) { int started_from_term = isatty(0) && isatty(1) && isatty(2); +#ifdef _WIN32 + char *winver; +#endif /* Set file creation mask and group ID. */ #if defined(DEFUMASK) && HAVE_UMASK @@ -484,6 +487,13 @@ int init_secondary(int ac, char **av) return -1; } } + if (!SupportedWindowsVersion()) { + winver = GetWindowsVersion(); + alog("%s is not a supported version of Windows", winver); + free(winver); + return -1; + } + if (!nofork) { alog("Launching Anope into the background"); FreeConsole(); diff --git a/src/main.c b/src/main.c index beb488d23..06c4bb550 100644 --- a/src/main.c +++ b/src/main.c @@ -655,6 +655,10 @@ void do_backtrace(int show_segheader) alog("Backtrace: not available on this platform"); #endif #else - alog("Backtrace: not available on this windows"); + char *winver; + winver = GetWindowsVersion(); + alog("Backtrace: not available on Windows"); + alog("Running %S", winver); + free(winver); #endif } diff --git a/src/misc.c b/src/misc.c index 563b39e86..855de4725 100644 --- a/src/misc.c +++ b/src/misc.c @@ -1188,5 +1188,149 @@ char **buildStringList(char *src, int *number) return list; } - -/* EOF */ +#ifdef _WIN32 +char *GetWindowsVersion(void) +{ + OSVERSIONINFOEX osvi; + BOOL bOsVersionInfoEx; + char buf[BUFSIZE]; + char *extra; + + ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + + if(!(bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *) &osvi))) { + osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); + if (!GetVersionEx((OSVERSIONINFO *)&osvi)) { + return sstrdup(""); + } + } + + switch (osvi.dwPlatformId) { + // test for the Windows NT product family. + case VER_PLATFORM_WIN32_NT: + if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0) { + if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) { + extra = sstrdup("Enterprise Edition"); + } else if (osvi.wSuiteMask & VER_SUITE_DATACENTER) { + extra = sstrdup("Datacenter Edition"); + } else { + extra = sstrdup(" "); + } + snprintf(buf, sizeof(buf), "Microsoft Windows Vista %s", extra); + free(extra); + } + if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) { + if (osvi.wSuiteMask & VER_SUITE_DATACENTER) { + extra = sstrdup("Datacenter Edition"); + } else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) { + extra = sstrdup("Enterprise Edition"); + } else if (osvi.wSuiteMask & VER_SUITE_COMPUTE_SERVER) { + extra = sstrdup("Compute Cluster Edition"); + } else if (osvi.wSuiteMask == VER_SUITE_BLADE) { + extra = sstrdup("Web Edition"); + } else { + extra = sstrdup("Standard Edition"); + } + snprintf(buf, sizeof(buf), "Microsoft Windows Server 2003 Family %s", extra); + free(extra); + } + if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) { + if (osvi.wSuiteMask & VER_SUITE_EMBEDDEDNT) { + extra = sstrdup("Embedded"); + } else if (osvi.wSuiteMask & VER_SUITE_PERSONAL) { + extra = sstrdup("Home Edition"); +#ifdef SM_MEDIACENTER + } else if (GetSystemMetrics(SM_MEDIACENTER)) { + extra = sstrdup("Media Center Edition"); +#endif +#ifdef SM_TABLETPC + } else if (GetSystemMetrics(SM_TABLETPC)) { + extra = sstrdup("Tablet Edition"); +#endif + } else { + extra = sstrdup(" "); + } + snprintf(buf, sizeof(buf), "Microsoft Windows XP %s", extra); + free(extra); + } + if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) { + if (osvi.wSuiteMask & VER_SUITE_DATACENTER) { + extra = sstrdup("Datacenter Server"); + } else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) { + extra = sstrdup("Advanced Server"); + } else { + extra = sstrdup("Server"); + } + snprintf(buf, sizeof(buf), "Microsoft Windows 2000 %s", extra); + free(extra); + } + if (osvi.dwMajorVersion <= 4) { + if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) { + extra = sstrdup("Server 4.0, Enterprise Edition"); + } else { + extra = sstrdup("Server 4.0"); + } + snprintf(buf, sizeof(buf), "Microsoft Windows NT %s", extra); + free(extra); + } + case VER_PLATFORM_WIN32_WINDOWS: + if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0) { + if (osvi.szCSDVersion[1] == 'C' || osvi.szCSDVersion[1] == 'B') { + extra = sstrdup("OSR2"); + } else { + extra = sstrdup(" "); + } + snprintf(buf, sizeof(buf), "Microsoft Windows 95 %s", extra); + free(extra); + } + if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10) { + if (osvi.szCSDVersion[1] == 'A') { + extra = sstrdup("SE"); + } else { + extra = sstrdup(" "); + } + snprintf(buf, sizeof(buf), "Microsoft Windows 98 %s", extra); + free(extra); + } + if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90) { + snprintf(buf, sizeof(buf), "Microsoft Windows Millennium Edition"); + } + } + return sstrdup(buf); +} + +int SupportedWindowsVersion(void) +{ + OSVERSIONINFOEX osvi; + BOOL bOsVersionInfoEx; + + ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + + if(!(bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *) &osvi))) { + osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); + if (!GetVersionEx((OSVERSIONINFO *)&osvi)) { + return 0; + } + } + + switch (osvi.dwPlatformId) { + // test for the Windows NT product family. + case VER_PLATFORM_WIN32_NT: + /* win nt4 */ + if (osvi.dwMajorVersion <= 4) { + return 0; + } + /* the rest */ + return 1; + /* win95 win98 winME */ + case VER_PLATFORM_WIN32_WINDOWS: + return 0; + } + return 0; +} + +#endif + +/* EOF */ diff --git a/src/modules/Makefile b/src/modules/Makefile index 602d43bec..254e8d0d3 100644 --- a/src/modules/Makefile +++ b/src/modules/Makefile @@ -9,7 +9,7 @@ MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'ANOPELIBS=${ANOPELIBS}' \ OBJECTS= $(SRCS:.c=.o) SO_FILES=$(OBJECTS:.o=.s) -CDEFS= -g -rdynamic -Wall +CDEFS= -rdynamic -Wall all: modules subs diff --git a/src/modules/Makefile.sub b/src/modules/Makefile.sub index 67b9c2763..300b13116 100644 --- a/src/modules/Makefile.sub +++ b/src/modules/Makefile.sub @@ -7,7 +7,7 @@ MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'ANOPELIBS=${ANOPELIBS}' \ OBJECTS= $(SRCS:.c=.o) SO_FILES=$(OBJECTS:.o=.s) -CDEFS= -g -rdynamic -Wall +CDEFS= -rdynamic -Wall all: module diff --git a/src/protocol/Makefile b/src/protocol/Makefile index 602d43bec..254e8d0d3 100644 --- a/src/protocol/Makefile +++ b/src/protocol/Makefile @@ -9,7 +9,7 @@ MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'ANOPELIBS=${ANOPELIBS}' \ OBJECTS= $(SRCS:.c=.o) SO_FILES=$(OBJECTS:.o=.s) -CDEFS= -g -rdynamic -Wall +CDEFS= -rdynamic -Wall all: modules subs diff --git a/src/protocol/Makefile.sub b/src/protocol/Makefile.sub index 67b9c2763..300b13116 100644 --- a/src/protocol/Makefile.sub +++ b/src/protocol/Makefile.sub @@ -7,7 +7,7 @@ MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'ANOPELIBS=${ANOPELIBS}' \ OBJECTS= $(SRCS:.c=.o) SO_FILES=$(OBJECTS:.o=.s) -CDEFS= -g -rdynamic -Wall +CDEFS= -rdynamic -Wall all: module -- cgit