3
3
#include <wctype.h>
4
4
#include <windows.h>
5
5
#include <shlobj.h>
6
+ #include <wchar.h>
6
7
7
8
#define PERL_NO_GET_CONTEXT
8
9
#include "EXTERN.h"
@@ -115,7 +116,7 @@ typedef void (WINAPI *PFNGetNativeSystemInfo)(LPSYSTEM_INFO lpSystemInfo);
115
116
* WORD type has been replaced by unsigned short because
116
117
* WORD is already used by Perl itself.
117
118
*/
118
- struct {
119
+ struct g_osver_t {
119
120
DWORD dwOSVersionInfoSize ;
120
121
DWORD dwMajorVersion ;
121
122
DWORD dwMinorVersion ;
@@ -127,7 +128,7 @@ struct {
127
128
unsigned short wSuiteMask ;
128
129
BYTE wProductType ;
129
130
BYTE wReserved ;
130
- } g_osver = {0 , 0 , 0 , 0 , 0 , "" , 0 , 0 , 0 , 0 , 0 };
131
+ } g_osver = {0 , 0 , 0 , 0 , 0 , "" , 0 , 0 , 0 , 0 , 0 };
131
132
BOOL g_osver_ex = TRUE;
132
133
133
134
#define ONE_K_BUFSIZE 1024
@@ -378,6 +379,7 @@ get_childenv(void)
378
379
void
379
380
free_childenv (void * d )
380
381
{
382
+ PERL_UNUSED_ARG (d );
381
383
}
382
384
383
385
# define PerlDir_mapA (dir ) (dir)
@@ -389,7 +391,7 @@ XS(w32_ExpandEnvironmentStrings)
389
391
dXSARGS ;
390
392
391
393
if (items != 1 )
392
- croak ("usage: Win32::ExpandEnvironmentStrings($String);\n " );
394
+ croak ("usage: Win32::ExpandEnvironmentStrings($String)" );
393
395
394
396
if (IsWin2000 ()) {
395
397
WCHAR value [31 * 1024 ];
@@ -537,7 +539,7 @@ XS(w32_LookupAccountName)
537
539
538
540
if (items != 5 )
539
541
croak ("usage: Win32::LookupAccountName($system, $account, $domain, "
540
- "$sid, $sidtype);\n " );
542
+ "$sid, $sidtype)" );
541
543
542
544
SIDLen = sizeof (SID );
543
545
DomLen = sizeof (Domain );
@@ -571,7 +573,7 @@ XS(w32_LookupAccountSID)
571
573
BOOL bResult ;
572
574
573
575
if (items != 5 )
574
- croak ("usage: Win32::LookupAccountSID($system, $sid, $account, $domain, $sidtype);\n " );
576
+ croak ("usage: Win32::LookupAccountSID($system, $sid, $account, $domain, $sidtype)" );
575
577
576
578
sid = SvPV_nolen (ST (1 ));
577
579
if (IsValidSid (sid )) {
@@ -602,7 +604,7 @@ XS(w32_InitiateSystemShutdown)
602
604
603
605
if (items != 5 )
604
606
croak ("usage: Win32::InitiateSystemShutdown($machineName, $message, "
605
- "$timeOut, $forceClose, $reboot);\n " );
607
+ "$timeOut, $forceClose, $reboot)" );
606
608
607
609
machineName = SvPV_nolen (ST (0 ));
608
610
@@ -643,7 +645,7 @@ XS(w32_AbortSystemShutdown)
643
645
char * machineName ;
644
646
645
647
if (items != 1 )
646
- croak ("usage: Win32::AbortSystemShutdown($machineName);\n " );
648
+ croak ("usage: Win32::AbortSystemShutdown($machineName)" );
647
649
648
650
machineName = SvPV_nolen (ST (0 ));
649
651
@@ -681,7 +683,7 @@ XS(w32_MsgBox)
681
683
I32 result ;
682
684
683
685
if (items < 1 || items > 3 )
684
- croak ("usage: Win32::MsgBox($message [, $flags [, $title]]);\n " );
686
+ croak ("usage: Win32::MsgBox($message [, $flags [, $title]])" );
685
687
686
688
if (items > 1 )
687
689
flags = (DWORD )SvIV (ST (1 ));
@@ -788,6 +790,8 @@ XS(w32_UnregisterServer)
788
790
XS (w32_GetArchName )
789
791
{
790
792
dXSARGS ;
793
+ if (items )
794
+ Perl_croak (aTHX_ "usage: Win32::GetArchName()" );
791
795
XSRETURN_PV (getenv ("PROCESSOR_ARCHITECTURE" ));
792
796
}
793
797
@@ -797,6 +801,8 @@ XS(w32_GetChipName)
797
801
SYSTEM_INFO sysinfo ;
798
802
HMODULE module ;
799
803
PFNGetNativeSystemInfo pfnGetNativeSystemInfo ;
804
+ if (items )
805
+ Perl_croak (aTHX_ "usage: Win32::GetChipName()" );
800
806
801
807
Zero (& sysinfo ,1 ,SYSTEM_INFO );
802
808
module = GetModuleHandle ("kernel32.dll" );
@@ -815,8 +821,11 @@ XS(w32_GuidGen)
815
821
dXSARGS ;
816
822
GUID guid ;
817
823
char szGUID [50 ] = {'\0' };
818
- HRESULT hr = CoCreateGuid (& guid );
824
+ HRESULT hr ;
825
+ if (items )
826
+ Perl_croak (aTHX_ "usage: Win32::GuidGen()" );
819
827
828
+ hr = CoCreateGuid (& guid );
820
829
if (SUCCEEDED (hr )) {
821
830
LPOLESTR pStr = NULL ;
822
831
#ifdef __cplusplus
@@ -998,7 +1007,7 @@ XS(w32_GetFileVersion)
998
1007
char * data ;
999
1008
1000
1009
if (items != 1 )
1001
- croak ("usage: Win32::GetFileVersion($filename)\n " );
1010
+ croak ("usage: Win32::GetFileVersion($filename)" );
1002
1011
1003
1012
filename = SvPV_nolen (ST (0 ));
1004
1013
size = GetFileVersionInfoSize (filename , & handle );
@@ -1049,16 +1058,22 @@ XS(w32_SetChildShowWindow)
1049
1058
* inside the thread_intern structure, the MSWin32 implementation
1050
1059
* lives in win32/win32.c in the core Perl distribution.
1051
1060
*/
1052
- dXSARGS ;
1061
+ dSP ;
1062
+ I32 ax = POPMARK ;
1063
+ EXTEND (SP ,1 );
1053
1064
XSRETURN_UNDEF ;
1054
1065
}
1055
1066
#endif
1056
1067
1057
1068
XS (w32_GetCwd )
1058
1069
{
1059
1070
dXSARGS ;
1071
+ char * ptr ;
1072
+ if (items )
1073
+ Perl_croak (aTHX_ "usage: Win32::GetCwd()" );
1074
+
1060
1075
/* Make the host for current directory */
1061
- char * ptr = PerlEnv_get_childdir ();
1076
+ ptr = PerlEnv_get_childdir ();
1062
1077
/*
1063
1078
* If ptr != Nullch
1064
1079
* then it worked, set PV valid,
@@ -1109,6 +1124,8 @@ XS(w32_GetNextAvailDrive)
1109
1124
char ix = 'C' ;
1110
1125
char root [] = "_:\\" ;
1111
1126
1127
+ if (items )
1128
+ Perl_croak (aTHX_ "usage: Win32::GetNextAvailDrive()" );
1112
1129
EXTEND (SP ,1 );
1113
1130
while (ix <= 'Z' ) {
1114
1131
root [0 ] = ix ++ ;
@@ -1123,6 +1140,8 @@ XS(w32_GetNextAvailDrive)
1123
1140
XS (w32_GetLastError )
1124
1141
{
1125
1142
dXSARGS ;
1143
+ if (items )
1144
+ Perl_croak (aTHX_ "usage: Win32::GetLastError()" );
1126
1145
EXTEND (SP ,1 );
1127
1146
XSRETURN_IV (GetLastError ());
1128
1147
}
@@ -1139,6 +1158,8 @@ XS(w32_SetLastError)
1139
1158
XS (w32_LoginName )
1140
1159
{
1141
1160
dXSARGS ;
1161
+ if (items )
1162
+ Perl_croak (aTHX_ "usage: Win32::LoginName()" );
1142
1163
EXTEND (SP ,1 );
1143
1164
if (IsWin2000 ()) {
1144
1165
WCHAR name [128 ];
@@ -1165,6 +1186,8 @@ XS(w32_NodeName)
1165
1186
dXSARGS ;
1166
1187
char name [MAX_COMPUTERNAME_LENGTH + 1 ];
1167
1188
DWORD size = sizeof (name );
1189
+ if (items )
1190
+ Perl_croak (aTHX_ "usage: Win32::NodeName()" );
1168
1191
EXTEND (SP ,1 );
1169
1192
if (GetComputerName (name ,& size )) {
1170
1193
/* size does NOT include NULL :-( */
@@ -1179,9 +1202,11 @@ XS(w32_DomainName)
1179
1202
{
1180
1203
dXSARGS ;
1181
1204
HMODULE module = LoadLibrary ("netapi32.dll" );
1182
- PFNNetApiBufferFree pfnNetApiBufferFree ;
1183
- PFNNetWkstaGetInfo pfnNetWkstaGetInfo ;
1205
+ PFNNetApiBufferFree pfnNetApiBufferFree = NULL ;
1206
+ PFNNetWkstaGetInfo pfnNetWkstaGetInfo = NULL ;
1184
1207
1208
+ if (items )
1209
+ Perl_croak (aTHX_ "usage: Win32::DomainName()" );
1185
1210
if (module ) {
1186
1211
GETPROC (NetApiBufferFree );
1187
1212
GETPROC (NetWkstaGetInfo );
@@ -1243,8 +1268,10 @@ XS(w32_FsType)
1243
1268
dXSARGS ;
1244
1269
char fsname [256 ];
1245
1270
DWORD flags , filecomplen ;
1271
+ if (items )
1272
+ Perl_croak (aTHX_ "usage: Win32::FsType()" );
1246
1273
if (GetVolumeInformation (NULL , NULL , 0 , NULL , & filecomplen ,
1247
- & flags , fsname , sizeof (fsname ))) {
1274
+ & flags , fsname , sizeof (fsname ))) {
1248
1275
if (GIMME_V == G_ARRAY ) {
1249
1276
XPUSHs (sv_2mortal (newSVpvn (fsname ,strlen (fsname ))));
1250
1277
XPUSHs (sv_2mortal (newSViv (flags )));
@@ -1261,6 +1288,8 @@ XS(w32_FsType)
1261
1288
XS (w32_GetOSVersion )
1262
1289
{
1263
1290
dXSARGS ;
1291
+ if (items )
1292
+ Perl_croak (aTHX_ "usage: Win32::GetOSVersion()" );
1264
1293
1265
1294
if (GIMME_V == G_SCALAR ) {
1266
1295
XSRETURN_IV (g_osver .dwPlatformId );
@@ -1283,13 +1312,17 @@ XS(w32_GetOSVersion)
1283
1312
XS (w32_IsWinNT )
1284
1313
{
1285
1314
dXSARGS ;
1315
+ if (items )
1316
+ Perl_croak (aTHX_ "usage: Win32::IsWinNT()" );
1286
1317
EXTEND (SP ,1 );
1287
1318
XSRETURN_IV (IsWinNT ());
1288
1319
}
1289
1320
1290
1321
XS (w32_IsWin95 )
1291
1322
{
1292
1323
dXSARGS ;
1324
+ if (items )
1325
+ Perl_croak (aTHX_ "usage: Win32::IsWin95()" );
1293
1326
EXTEND (SP ,1 );
1294
1327
XSRETURN_IV (IsWin95 ());
1295
1328
}
@@ -1365,6 +1398,8 @@ XS(w32_GetTickCount)
1365
1398
{
1366
1399
dXSARGS ;
1367
1400
DWORD msec = GetTickCount ();
1401
+ if (items )
1402
+ Perl_croak (aTHX_ "usage: Win32::GetTickCount()" );
1368
1403
EXTEND (SP ,1 );
1369
1404
if ((IV )msec > 0 )
1370
1405
XSRETURN_IV (msec );
@@ -1526,7 +1561,7 @@ XS(w32_GetLongPathName)
1526
1561
WCHAR wide_path [MAX_PATH + 1 ];
1527
1562
WCHAR * long_path ;
1528
1563
1529
- if (wcslen (wstr ) < countof (wide_path )) {
1564
+ if (wcslen (wstr ) < ( size_t ) countof (wide_path )) {
1530
1565
wcscpy (wide_path , wstr );
1531
1566
long_path = my_longpathW (wide_path );
1532
1567
if (long_path ) {
@@ -1620,13 +1655,17 @@ XS(w32_OutputDebugString)
1620
1655
XS (w32_GetCurrentProcessId )
1621
1656
{
1622
1657
dXSARGS ;
1658
+ if (items )
1659
+ Perl_croak (aTHX_ "usage: Win32::GetCurrentProcessId()" );
1623
1660
EXTEND (SP ,1 );
1624
1661
XSRETURN_IV (GetCurrentProcessId ());
1625
1662
}
1626
1663
1627
1664
XS (w32_GetCurrentThreadId )
1628
1665
{
1629
1666
dXSARGS ;
1667
+ if (items )
1668
+ Perl_croak (aTHX_ "usage: Win32::GetCurrentThreadId()" );
1630
1669
EXTEND (SP ,1 );
1631
1670
XSRETURN_IV (GetCurrentThreadId ());
1632
1671
}
@@ -1714,27 +1753,35 @@ XS(w32_GetProductInfo)
1714
1753
XS (w32_GetACP )
1715
1754
{
1716
1755
dXSARGS ;
1756
+ if (items )
1757
+ Perl_croak (aTHX_ "usage: Win32::GetACP()" );
1717
1758
EXTEND (SP ,1 );
1718
1759
XSRETURN_IV (GetACP ());
1719
1760
}
1720
1761
1721
1762
XS (w32_GetConsoleCP )
1722
1763
{
1723
1764
dXSARGS ;
1765
+ if (items )
1766
+ Perl_croak (aTHX_ "usage: Win32::GetConsoleCP()" );
1724
1767
EXTEND (SP ,1 );
1725
1768
XSRETURN_IV (GetConsoleCP ());
1726
1769
}
1727
1770
1728
1771
XS (w32_GetConsoleOutputCP )
1729
1772
{
1730
1773
dXSARGS ;
1774
+ if (items )
1775
+ Perl_croak (aTHX_ "usage: Win32::GetConsoleOutputCP()" );
1731
1776
EXTEND (SP ,1 );
1732
1777
XSRETURN_IV (GetConsoleOutputCP ());
1733
1778
}
1734
1779
1735
1780
XS (w32_GetOEMCP )
1736
1781
{
1737
1782
dXSARGS ;
1783
+ if (items )
1784
+ Perl_croak (aTHX_ "usage: Win32::GetOEMCP()" );
1738
1785
EXTEND (SP ,1 );
1739
1786
XSRETURN_IV (GetOEMCP ());
1740
1787
}
@@ -1765,7 +1812,7 @@ PROTOTYPES: DISABLE
1765
1812
1766
1813
BOOT :
1767
1814
{
1768
- char * file = __FILE__ ;
1815
+ const char * file = __FILE__ ;
1769
1816
1770
1817
if (g_osver .dwOSVersionInfoSize == 0 ) {
1771
1818
g_osver .dwOSVersionInfoSize = sizeof (g_osver );
0 commit comments