return (exitstatus);
}
-/* Register any extra external extensions */
-
-char *staticlinkmodules[] = {
- "DynaLoader",
- NULL,
-};
-
-EXTERN_C void boot_DynaLoader _((CV* cv));
-
-static
-XS(w32_GetCurrentDirectory)
-{
- dXSARGS;
- SV *sv = sv_newmortal();
- /* Make one call with zero size - return value is required size */
- DWORD len = GetCurrentDirectory((DWORD)0,NULL);
- SvUPGRADE(sv,SVt_PV);
- SvGROW(sv,len);
- SvCUR(sv) = GetCurrentDirectory((DWORD) SvLEN(sv), SvPVX(sv));
- /*
- * If result != 0
- * then it worked, set PV valid,
- * else leave it 'undef'
- */
- if (SvCUR(sv))
- SvPOK_on(sv);
- EXTEND(sp,1);
- ST(0) = sv;
- XSRETURN(1);
-}
-
-static void
-xs_init()
-{
- char *file = __FILE__;
- dXSUB_SYS;
- newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
- newXS("Win32::GetCurrentDirectory", w32_GetCurrentDirectory, file);
-}
-
extern HANDLE PerlDllHandle;
BOOL APIENTRY
}
return TRUE;
}
+
+/* Register any extra external extensions */
+
+char *staticlinkmodules[] = {
+ "DynaLoader",
+ NULL,
+};
+
+EXTERN_C void boot_DynaLoader _((CV* cv));
+
+static
+XS(w32_GetCurrentDirectory)
+{
+ dXSARGS;
+ SV *sv = sv_newmortal();
+ /* Make one call with zero size - return value is required size */
+ DWORD len = GetCurrentDirectory((DWORD)0,NULL);
+ SvUPGRADE(sv,SVt_PV);
+ SvGROW(sv,len);
+ SvCUR(sv) = GetCurrentDirectory((DWORD) SvLEN(sv), SvPVX(sv));
+ /*
+ * If result != 0
+ * then it worked, set PV valid,
+ * else leave it 'undef'
+ */
+ if (SvCUR(sv))
+ SvPOK_on(sv);
+ EXTEND(sp,1);
+ ST(0) = sv;
+ XSRETURN(1);
+}
+
+static
+XS(w32_GetLastError)
+{
+ dXSARGS;
+ XSRETURN_IV(GetLastError());
+}
+
+XS(w32_IsWinNT)
+{
+ dXSARGS;
+ XSRETURN_IV(IsWinNT());
+}
+
+XS(w32_IsWin95)
+{
+ dXSARGS;
+ XSRETURN_IV(IsWin95());
+}
+
+static void
+xs_init()
+{
+ char *file = __FILE__;
+ dXSUB_SYS;
+ newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
+ newXS("Win32::GetCurrentDirectory", w32_GetCurrentDirectory, file);
+ newXS("Win32::GetLastError", w32_GetLastError, file);
+ newXS("Win32::IsWinNT", w32_IsWinNT, file);
+ newXS("Win32::IsWin95", w32_IsWin95, file);
+}
+
#define CROAK croak
#define WARN warn
+static DWORD IdOS(void);
+
extern WIN32_IOSUBSYSTEM win32stdio;
__declspec(thread) PWIN32_IOSUBSYSTEM pIOSubSystem = &win32stdio;
/*__declspec(thread) PWIN32_IOSUBSYSTEM pIOSubSystem = NULL;*/
BOOL ProbeEnv = FALSE;
-DWORD Win32System;
+DWORD Win32System = (DWORD)-1;
char szShellPath[MAX_PATH+1];
char szPerlLibRoot[MAX_PATH+1];
HANDLE PerlDllHandle = INVALID_HANDLE_VALUE;
int
IsWin95(void) {
- return (Win32System == VER_PLATFORM_WIN32_WINDOWS);
+ return (IdOS() == VER_PLATFORM_WIN32_WINDOWS);
}
int
IsWinNT(void) {
- return (Win32System == VER_PLATFORM_WIN32_NT);
+ return (IdOS() == VER_PLATFORM_WIN32_NT);
}
void *
return win32_pclose(fp);
}
-static void
+static DWORD
IdOS(void)
{
- OSVERSIONINFO osver;
+ static OSVERSIONINFO osver;
- memset(&osver, 0, sizeof(OSVERSIONINFO));
- osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&osver);
- Win32System = osver.dwPlatformId;
- return;
+ if (osver.dwPlatformId != Win32System) {
+ memset(&osver, 0, sizeof(OSVERSIONINFO));
+ osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&osver);
+ Win32System = osver.dwPlatformId;
+ }
+ return (Win32System);
}
static char *
static char* szWinNTDefaultShell = "cmd.exe";
if (!ProbeEnv) {
- IdOS(), ProbeEnv = TRUE;
+ ProbeEnv = TRUE;
if (IsWin95()) {
strcpy(szShellPath, szWin95DefaultShell);
}