This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
boot_Win32CORE needs to be XS_EXTERNAL() following commit ab1478f7146843f7.
[perl5.git] / ext / Win32CORE / Win32CORE.c
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
10 #define WIN32_LEAN_AND_MEAN
11 #include <windows.h>
12
13 #if defined(__CYGWIN__) && !defined(USEIMPORTLIB)
14   #undef WIN32
15 #endif
16 #include "EXTERN.h"
17 #if defined(__CYGWIN__) && !defined(USEIMPORTLIB)
18   #define EXTCONST extern const
19 #endif
20 #include "perl.h"
21 #include "XSUB.h"
22
23 static void
24 forward(pTHX_ const char *function)
25 {
26     dXSARGS;
27     DWORD err = GetLastError();
28     Perl_load_module(aTHX_ PERL_LOADMOD_NOIMPORT, newSVpvn("Win32",5), newSVnv(0.27));
29     SetLastError(err);
30     SPAGAIN;
31     PUSHMARK(SP-items);
32     call_pv(function, GIMME_V);
33 }
34
35 #define FORWARD(function) XS(w32_##function){ forward(aTHX_ "Win32::"#function); }
36 FORWARD(GetCwd)
37 FORWARD(SetCwd)
38 FORWARD(GetNextAvailDrive)
39 FORWARD(GetLastError)
40 FORWARD(SetLastError)
41 FORWARD(LoginName)
42 FORWARD(NodeName)
43 FORWARD(DomainName)
44 FORWARD(FsType)
45 FORWARD(GetOSVersion)
46 FORWARD(IsWinNT)
47 FORWARD(IsWin95)
48 FORWARD(FormatMessage)
49 FORWARD(Spawn)
50 FORWARD(GetTickCount)
51 FORWARD(GetShortPathName)
52 FORWARD(GetFullPathName)
53 FORWARD(GetLongPathName)
54 FORWARD(CopyFile)
55 FORWARD(Sleep)
56
57 /* Don't forward Win32::SetChildShowWindow().  It accesses the internal variable
58  * w32_showwindow in thread_intern and is therefore not implemented in Win32.xs.
59  */
60 /* FORWARD(SetChildShowWindow) */
61
62 #undef FORWARD
63
64 XS_EXTERNAL(boot_Win32CORE)
65 {
66     /* This function only exists because writemain.SH, lib/ExtUtils/Embed.pm
67      * and win32/buildext.pl will all generate references to it.  The function
68      * should never be called though, as Win32CORE.pm doesn't use DynaLoader.
69      */
70 }
71 #if defined(__CYGWIN__) && defined(USEIMPORTLIB)
72 __declspec(dllexport)
73 #endif
74 void
75 init_Win32CORE(pTHX)
76 {
77     /* This function is called from init_os_extras().  The Perl interpreter
78      * is not yet fully initialized, so don't do anything fancy in here.
79      */
80
81     char *file = __FILE__;
82
83     newXS("Win32::GetCwd", w32_GetCwd, file);
84     newXS("Win32::SetCwd", w32_SetCwd, file);
85     newXS("Win32::GetNextAvailDrive", w32_GetNextAvailDrive, file);
86     newXS("Win32::GetLastError", w32_GetLastError, file);
87     newXS("Win32::SetLastError", w32_SetLastError, file);
88     newXS("Win32::LoginName", w32_LoginName, file);
89     newXS("Win32::NodeName", w32_NodeName, file);
90     newXS("Win32::DomainName", w32_DomainName, file);
91     newXS("Win32::FsType", w32_FsType, file);
92     newXS("Win32::GetOSVersion", w32_GetOSVersion, file);
93     newXS("Win32::IsWinNT", w32_IsWinNT, file);
94     newXS("Win32::IsWin95", w32_IsWin95, file);
95     newXS("Win32::FormatMessage", w32_FormatMessage, file);
96     newXS("Win32::Spawn", w32_Spawn, file);
97     newXS("Win32::GetTickCount", w32_GetTickCount, file);
98     newXS("Win32::GetShortPathName", w32_GetShortPathName, file);
99     newXS("Win32::GetFullPathName", w32_GetFullPathName, file);
100     newXS("Win32::GetLongPathName", w32_GetLongPathName, file);
101     newXS("Win32::CopyFile", w32_CopyFile, file);
102     newXS("Win32::Sleep", w32_Sleep, file);
103     /* newXS("Win32::SetChildShowWindow", w32_SetChildShowWindow, file); */
104 }