Win32CORE.c needed windows.h
[perl.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 #include "EXTERN.h"
14 #include "perl.h"
15 #include "XSUB.h"
16
17 static void
18 forward(pTHX_ const char *function)
19 {
20     dXSARGS;
21     DWORD err = GetLastError();
22     Perl_load_module(aTHX_ PERL_LOADMOD_NOIMPORT, newSVpvn("Win32",5), newSVnv(0.27));
23     SetLastError(err);
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); }
30 FORWARD(GetCwd)
31 FORWARD(SetCwd)
32 FORWARD(GetNextAvailDrive)
33 FORWARD(GetLastError)
34 FORWARD(SetLastError)
35 FORWARD(LoginName)
36 FORWARD(NodeName)
37 FORWARD(DomainName)
38 FORWARD(FsType)
39 FORWARD(GetOSVersion)
40 FORWARD(IsWinNT)
41 FORWARD(IsWin95)
42 FORWARD(FormatMessage)
43 FORWARD(Spawn)
44 FORWARD(GetTickCount)
45 FORWARD(GetShortPathName)
46 FORWARD(GetFullPathName)
47 FORWARD(GetLongPathName)
48 FORWARD(CopyFile)
49 FORWARD(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
58 XS(boot_Win32CORE)
59 {
60     dXSARGS;
61     char *file = __FILE__;
62
63     /* these names are Activeware compatible */
64     newXS("Win32::GetCwd", w32_GetCwd, file);
65     newXS("Win32::SetCwd", w32_SetCwd, file);
66     newXS("Win32::GetNextAvailDrive", w32_GetNextAvailDrive, file);
67     newXS("Win32::GetLastError", w32_GetLastError, file);
68     newXS("Win32::SetLastError", w32_SetLastError, file);
69     newXS("Win32::LoginName", w32_LoginName, file);
70     newXS("Win32::NodeName", w32_NodeName, file);
71     newXS("Win32::DomainName", w32_DomainName, file);
72     newXS("Win32::FsType", w32_FsType, file);
73     newXS("Win32::GetOSVersion", w32_GetOSVersion, file);
74     newXS("Win32::IsWinNT", w32_IsWinNT, file);
75     newXS("Win32::IsWin95", w32_IsWin95, file);
76     newXS("Win32::FormatMessage", w32_FormatMessage, file);
77     newXS("Win32::Spawn", w32_Spawn, file);
78     newXS("Win32::GetTickCount", w32_GetTickCount, file);
79     newXS("Win32::GetShortPathName", w32_GetShortPathName, file);
80     newXS("Win32::GetFullPathName", w32_GetFullPathName, file);
81     newXS("Win32::GetLongPathName", w32_GetLongPathName, file);
82     newXS("Win32::CopyFile", w32_CopyFile, file);
83     newXS("Win32::Sleep", w32_Sleep, file);
84     /* newXS("Win32::SetChildShowWindow", w32_SetChildShowWindow, file); */
85
86     XSRETURN_YES;
87 }