This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
RE: Problem in Win32CORE when building PAR-Packer-0.975 with bleadperl on Win32
[perl5.git] / ext / Win32CORE / Win32CORE.c
CommitLineData
78ff2d7b
YST
1/* Win32CORE.c
2 *
3 * Copyright (C) 2007 by Larry Wall and others
4 *
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
7 *
8 */
9
ef3b47fb
JH
10#define WIN32_LEAN_AND_MEAN
11#include <windows.h>
12
78ff2d7b
YST
13#include "EXTERN.h"
14#include "perl.h"
15#include "XSUB.h"
16
17static void
18forward(pTHX_ const char *function)
19{
20 dXSARGS;
dcd628c7 21 DWORD err = GetLastError();
78ff2d7b 22 Perl_load_module(aTHX_ PERL_LOADMOD_NOIMPORT, newSVpvn("Win32",5), newSVnv(0.27));
dcd628c7 23 SetLastError(err);
78ff2d7b
YST
24 SPAGAIN;
25 PUSHMARK(SP-items);
26 call_pv(function, GIMME_V);
27}
28
29#define FORWARD(function) XS(w32_##function){ forward(aTHX_ "Win32::"#function); }
30FORWARD(GetCwd)
31FORWARD(SetCwd)
32FORWARD(GetNextAvailDrive)
33FORWARD(GetLastError)
34FORWARD(SetLastError)
35FORWARD(LoginName)
36FORWARD(NodeName)
37FORWARD(DomainName)
38FORWARD(FsType)
39FORWARD(GetOSVersion)
40FORWARD(IsWinNT)
41FORWARD(IsWin95)
42FORWARD(FormatMessage)
43FORWARD(Spawn)
44FORWARD(GetTickCount)
45FORWARD(GetShortPathName)
46FORWARD(GetFullPathName)
47FORWARD(GetLongPathName)
48FORWARD(CopyFile)
49FORWARD(Sleep)
50
51/* Don't forward Win32::SetChildShowWindow(). It accesses the internal variable
52 * w32_showwindow in thread_intern and is therefore not implemented in Win32.xs.
53 */
54/* FORWARD(SetChildShowWindow) */
55
56#undef FORWARD
57
58XS(boot_Win32CORE)
59{
9fb265f7
JD
60 /* This function only exists because writemain.SH, lib/ExtUtils/Embed.pm
61 * and win32/buildext.pl will all generate references to it. The function
62 * should never be called though, as Win32CORE.pm doesn't use DynaLoader.
63 */
64}
65#ifdef __CYGWIN__
66__declspec(dllexport)
67#endif
68void
69init_Win32CORE(pTHX)
70{
71 /* This function is called from init_os_extras(). The Perl interpreter
72 * is not yet fully initialized, so don't do anything fancy in here.
73 */
74
78ff2d7b
YST
75 char *file = __FILE__;
76
78ff2d7b
YST
77 newXS("Win32::GetCwd", w32_GetCwd, file);
78 newXS("Win32::SetCwd", w32_SetCwd, file);
79 newXS("Win32::GetNextAvailDrive", w32_GetNextAvailDrive, file);
80 newXS("Win32::GetLastError", w32_GetLastError, file);
81 newXS("Win32::SetLastError", w32_SetLastError, file);
82 newXS("Win32::LoginName", w32_LoginName, file);
83 newXS("Win32::NodeName", w32_NodeName, file);
84 newXS("Win32::DomainName", w32_DomainName, file);
85 newXS("Win32::FsType", w32_FsType, file);
86 newXS("Win32::GetOSVersion", w32_GetOSVersion, file);
87 newXS("Win32::IsWinNT", w32_IsWinNT, file);
88 newXS("Win32::IsWin95", w32_IsWin95, file);
89 newXS("Win32::FormatMessage", w32_FormatMessage, file);
90 newXS("Win32::Spawn", w32_Spawn, file);
91 newXS("Win32::GetTickCount", w32_GetTickCount, file);
92 newXS("Win32::GetShortPathName", w32_GetShortPathName, file);
93 newXS("Win32::GetFullPathName", w32_GetFullPathName, file);
94 newXS("Win32::GetLongPathName", w32_GetLongPathName, file);
95 newXS("Win32::CopyFile", w32_CopyFile, file);
96 newXS("Win32::Sleep", w32_Sleep, file);
97 /* newXS("Win32::SetChildShowWindow", w32_SetChildShowWindow, file); */
78ff2d7b 98}