summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorPerl 5 Porters <perl5-porters@africa.nicoh.com>1997-05-08 00:00:00 +1200
committerChip Salzenberg <chip@atlantic.net>1997-05-08 00:00:00 +1200
commit7bac28a0157dcaf170649e8928f053f76dda4253 (patch)
tree88eadd917e84141a07d7cf3db90686edb67fe5a6 /win32
parenteb447b8692d1c89cd24ab421497dcff667570be4 (diff)
downloadperl-7bac28a0157dcaf170649e8928f053f76dda4253.tar.gz
[inseparable changes from match from perl-5.003_99 to perl-5.003_99a]
BUILD PROCESS Subject: AFS patches From: Chip Salzenberg <chip@perl.com> Files: Configure installperl CORE LANGUAGE CHANGES Subject: SECURITY: Forbid glob() when tainting (-T or setuid) From: Chip Salzenberg <chip@perl.com> Files: pod/perlrun.pod pod/perlsec.pod pp_sys.c Subject: SECURITY: Forbid exec() if $ENV{TERM} or $ENV{ENV} is tainted From: Chip Salzenberg <chip@perl.com> Files: pod/perlrun.pod pod/perlsec.pod t/op/taint.t taint.c CORE PORTABILITY Subject: (NeXT|Open)Step update Date: Wed, 7 May 97 17:47:02 -0500 From: Gerd Knops <gerti@BITart.com> Files: Configure MANIFEST config_h.SH hints/next_3.sh hints/next_4.sh private-msgid: 9705072247.AA18882@BITart.com Subject: Win32 update (consolidated patch plus three followups) From: Gurusamy Sarathy <gsar@engin.umich.edu> Files: EXTERN.h README.win32 lib/Sys/Hostname.pm pod/perldelta.pod win32/config.H win32/config.w32 win32/config_sh.PL win32/perllib.c win32/win32.c win32/win32.h win32/include/sys/socket.h DOCUMENTATION Subject: Updates to perldelta From: Chip Salzenberg <chip@perl.com> Files: pod/perldelta.pod Subject: Document 'Possible attempt to separate words with commas' Date: 06 May 1997 23:27:55 +0200 From: Gisle Aas <gisle@aas.no> Files: pod/perlop.pod Msg-ID: hyb9snvdw.fsf@bergen.sn.no (applied based on p5p patch as commit 18270fd3b8aafde2f9ea21ea13adde95ef24b149) Subject: Document that C<m?x?> is just like C<?x?> From: Chip Salzenberg <chip@perl.com> Files: pod/perlop.pod OTHER CORE CHANGES Subject: Fix for redefined sort subs nastiness Date: Thu, 08 May 1997 20:04:18 -0400 From: Gurusamy Sarathy <gsar@engin.umich.edu> Files: op.c pod/perldelta.pod pod/perldiag.pod sv.c t/op/sort.t Msg-ID: 199705090004.UAA15032@aatma.engin.umich.edu (applied based on p5p patch as commit e9e069932a0db06904b29e2b09a435afd40ed35c)
Diffstat (limited to 'win32')
-rw-r--r--win32/config.H29
-rw-r--r--win32/config.w326
-rw-r--r--win32/config_sh.PL2
-rw-r--r--win32/include/sys/socket.h6
-rw-r--r--win32/perllib.c244
-rw-r--r--win32/win32.c54
-rw-r--r--win32/win32.h7
7 files changed, 319 insertions, 29 deletions
diff --git a/win32/config.H b/win32/config.H
index 37b50a5efd..e375c5692d 100644
--- a/win32/config.H
+++ b/win32/config.H
@@ -40,8 +40,8 @@
* This symbol is the filename expanded version of the BIN symbol, for
* programs that do not want to deal with that at run-time.
*/
-#define BIN "C:\\perl\\bin" /**/
-#define BIN_EXP "C:\\perl\\bin" /**/
+#define BIN "c:\\perl\\bin" /**/
+#define BIN_EXP "c:\\perl\\bin" /**/
/* CAT2:
* This macro catenates 2 tokens together.
@@ -92,7 +92,7 @@
* This symbol, if defined, indicates that the alarm routine is
* available.
*/
-#define HAS_ALARM /**/
+/*#define HAS_ALARM /**/
/* HASATTRIBUTE:
* This symbol indicates the C compiler can check for function attributes,
@@ -250,7 +250,7 @@
* This symbol, if defined, indicates that the flock routine is
* available to do file locking.
*/
-/*#define HAS_FLOCK /**/
+#define HAS_FLOCK /**/
/* HAS_FORK:
* This symbol, if defined, indicates that the fork routine is
@@ -1068,7 +1068,7 @@
* This symbol, if defined, indicates that <ndbm.h> exists and should
* be included.
*/
-#define I_NDBM /**/
+/*#define I_NDBM /**/
/* I_NET_ERRNO:
* This symbol, if defined, indicates that <net/errno.h> exists and
@@ -1413,8 +1413,8 @@
* This symbol contains the ~name expanded version of ARCHLIB, to be used
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
-#define ARCHLIB "C:\\perl\\lib" /**/
-#define ARCHLIB_EXP "C:\\perl\\lib" /**/
+#define ARCHLIB "c:\\perl\\lib" /**/
+#define ARCHLIB_EXP "c:\\perl\\lib" /**/
/* BINCOMPAT3:
* This symbol, if defined, indicates that Perl 5.004 should be
@@ -1660,8 +1660,8 @@
* This symbol contains the ~name expanded version of PRIVLIB, to be used
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
-#define PRIVLIB "C:\\perl\\lib" /**/
-#define PRIVLIB_EXP "C:\\perl\\lib" /**/
+#define PRIVLIB "c:\\perl\\lib" /**/
+#define PRIVLIB_EXP "c:\\perl\\lib" /**/
/* SH_PATH:
* This symbol contains the full pathname to the shell used on this
@@ -1670,7 +1670,7 @@
* /bin/pdksh, /bin/ash, /bin/bash, or even something such as
* D:/bin/sh.exe.
*/
-#define SH_PATH "cmd /c" /**/
+#define SH_PATH "cmd /x /c" /**/
/* SIG_NAME:
* This symbol contains a list of signal names in order of
@@ -1716,8 +1716,8 @@
* This symbol contains the ~name expanded version of SITEARCH, to be used
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
-#define SITEARCH "C:\\perl\\lib\\site" /**/
-#define SITEARCH_EXP "C:\\perl\\lib\\site" /**/
+#define SITEARCH "c:\\perl\\lib\\site" /**/
+#define SITEARCH_EXP "c:\\perl\\lib\\site" /**/
/* SITELIB:
* This symbol contains the name of the private library for this package.
@@ -1732,8 +1732,8 @@
* This symbol contains the ~name expanded version of SITELIB, to be used
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
-#define SITELIB "C:\\perl\\lib\\site" /**/
-#define SITELIB_EXP "C:\\perl\\lib\\site" /**/
+#define SITELIB "c:\\perl\\lib\\site" /**/
+#define SITELIB_EXP "c:\\perl\\lib\\site" /**/
/* STARTPERL:
* This variable contains the string to put in front of a perl
@@ -1778,4 +1778,3 @@
#include <win32.h>
#define ARCHLIBEXP (win32PerlLibPath())
#define DEBUGGING
-#define MULTIPLCITY
diff --git a/win32/config.w32 b/win32/config.w32
index c8f3fc4eca..e977b17e07 100644
--- a/win32/config.w32
+++ b/win32/config.w32
@@ -35,11 +35,11 @@ Id='$Id'
Locker=''
Log='$Log'
Mcc='Mcc'
-PATCHLEVEL='3'
+PATCHLEVEL='~PATCHLEVEL~'
POSIX_cflags='ccflags="$ccflags -DSTRUCT_TM_HASZONE"'
RCSfile='$RCSfile'
Revision='$Revision'
-SUBVERSION='0'
+SUBVERSION='~SUBVERSION~'
Source=''
State=''
afs='false'
@@ -123,7 +123,7 @@ d_fd_set='define'
d_fds_bits='define'
d_fgetpos='define'
d_flexfnam='define'
-d_flock='undef'
+d_flock='define'
d_fork='undef'
d_fpathconf='undef'
d_fsetpos='define'
diff --git a/win32/config_sh.PL b/win32/config_sh.PL
index d397a1b53b..e62e47f4f7 100644
--- a/win32/config_sh.PL
+++ b/win32/config_sh.PL
@@ -4,6 +4,8 @@ while (@ARGV && $ARGV[0] =~ /^([\w_]+)=(.*)$/)
$opt{$1}=$2;
shift(@ARGV);
}
+
+@opt{'PATCHLEVEL','SUBVERSION'} = ($] =~ /\.0*([1-9]+)(\d\d)$/);
while (<>)
{
s/~([\w_]+)~/$opt{$1}/g;
diff --git a/win32/include/sys/socket.h b/win32/include/sys/socket.h
index 7485195590..701022a7fc 100644
--- a/win32/include/sys/socket.h
+++ b/win32/include/sys/socket.h
@@ -3,12 +3,12 @@
// djl
// Provide UNIX compatibility
-#ifdef __cplusplus
-extern "C" {
-#endif
#ifndef _INC_SYS_SOCKET
#define _INC_SYS_SOCKET
+#ifdef __cplusplus
+extern "C" {
+#endif
#ifndef _WINDOWS_
#define _WINDOWS_
diff --git a/win32/perllib.c b/win32/perllib.c
index f40013b577..0f63938f5c 100644
--- a/win32/perllib.c
+++ b/win32/perllib.c
@@ -104,7 +104,7 @@ char *staticlinkmodules[] = {
EXTERN_C void boot_DynaLoader _((CV* cv));
static
-XS(w32_GetCurrentDirectory)
+XS(w32_GetCwd)
{
dXSARGS;
SV *sv = sv_newmortal();
@@ -126,22 +126,223 @@ XS(w32_GetCurrentDirectory)
}
static
+XS(w32_SetCwd)
+{
+ dXSARGS;
+ if (items != 1)
+ croak("usage: Win32::SetCurrentDirectory($cwd)");
+ if (SetCurrentDirectory(SvPV(ST(0),na)))
+ XSRETURN_YES;
+
+ XSRETURN_NO;
+}
+
+static
+XS(w32_GetNextAvailDrive)
+{
+ dXSARGS;
+ char ix = 'C';
+ char root[] = "_:\\";
+ while (ix <= 'Z') {
+ root[0] = ix++;
+ if (GetDriveType(root) == 1) {
+ root[2] = '\0';
+ XSRETURN_PV(root);
+ }
+ }
+ XSRETURN_UNDEF;
+}
+
+static
XS(w32_GetLastError)
{
- dXSARGS;
- XSRETURN_IV(GetLastError());
+ dXSARGS;
+ XSRETURN_IV(GetLastError());
}
+static
+XS(w32_LoginName)
+{
+ dXSARGS;
+ char name[256];
+ DWORD size = sizeof(name);
+ if (GetUserName(name,&size)) {
+ /* size includes NULL */
+ ST(0) = sv_2mortal(newSVpv(name,size-1));
+ XSRETURN(1);
+ }
+ XSRETURN_UNDEF;
+}
+
+static
+XS(w32_NodeName)
+{
+ dXSARGS;
+ char name[MAX_COMPUTERNAME_LENGTH+1];
+ DWORD size = sizeof(name);
+ if (GetComputerName(name,&size)) {
+ /* size does NOT include NULL :-( */
+ ST(0) = sv_2mortal(newSVpv(name,size));
+ XSRETURN(1);
+ }
+ XSRETURN_UNDEF;
+}
+
+
+static
+XS(w32_DomainName)
+{
+ dXSARGS;
+ char name[256];
+ DWORD size = sizeof(name);
+ if (GetUserName(name,&size)) {
+ char sid[1024];
+ DWORD sidlen = sizeof(sid);
+ char dname[256];
+ DWORD dnamelen = sizeof(dname);
+ SID_NAME_USE snu;
+ if (LookupAccountName(NULL, name, &sid, &sidlen,
+ dname, &dnamelen, &snu)) {
+ XSRETURN_PV(dname); /* all that for this */
+ }
+ }
+ XSRETURN_UNDEF;
+}
+
+static
+XS(w32_FsType)
+{
+ dXSARGS;
+ char fsname[256];
+ DWORD flags, filecomplen;
+ if (GetVolumeInformation(NULL, NULL, 0, NULL, &filecomplen,
+ &flags, fsname, sizeof(fsname))) {
+ if (GIMME == G_ARRAY) {
+ XPUSHs(sv_2mortal(newSVpv(fsname,0)));
+ XPUSHs(sv_2mortal(newSViv(flags)));
+ XPUSHs(sv_2mortal(newSViv(filecomplen)));
+ PUTBACK;
+ return;
+ }
+ XSRETURN_PV(fsname);
+ }
+ XSRETURN_UNDEF;
+}
+
+static
+XS(w32_GetOSVersion)
+{
+ dXSARGS;
+ OSVERSIONINFO osver;
+
+ osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ if (GetVersionEx(&osver)) {
+ XPUSHs(newSVpv(osver.szCSDVersion, 0));
+ XPUSHs(newSViv(osver.dwMajorVersion));
+ XPUSHs(newSViv(osver.dwMinorVersion));
+ XPUSHs(newSViv(osver.dwBuildNumber));
+ XPUSHs(newSViv(osver.dwPlatformId));
+ PUTBACK;
+ return;
+ }
+ XSRETURN_UNDEF;
+}
+
+static
XS(w32_IsWinNT)
{
- dXSARGS;
- XSRETURN_IV(IsWinNT());
+ dXSARGS;
+ XSRETURN_IV(IsWinNT());
}
+static
XS(w32_IsWin95)
{
- dXSARGS;
- XSRETURN_IV(IsWin95());
+ dXSARGS;
+ XSRETURN_IV(IsWin95());
+}
+
+static
+XS(w32_FormatMessage)
+{
+ dXSARGS;
+ DWORD source = 0;
+ char msgbuf[1024];
+
+ if (items != 1)
+ croak("usage: Win32::FormatMessage($errno)");
+
+ if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
+ &source, SvIV(ST(0)), 0,
+ msgbuf, sizeof(msgbuf)-1, NULL))
+ XSRETURN_PV(msgbuf);
+
+ XSRETURN_UNDEF;
+}
+
+static
+XS(w32_Spawn)
+{
+ dXSARGS;
+ char *cmd, *args;
+ PROCESS_INFORMATION stProcInfo;
+ STARTUPINFO stStartInfo;
+ BOOL bSuccess = FALSE;
+
+ if(items != 3)
+ croak("usage: Win32::Spawn($cmdName, $args, $PID)");
+
+ cmd = SvPV(ST(0),na);
+ args = SvPV(ST(1), na);
+
+ memset(&stStartInfo, 0, sizeof(stStartInfo)); /* Clear the block */
+ stStartInfo.cb = sizeof(stStartInfo); /* Set the structure size */
+ stStartInfo.dwFlags = STARTF_USESHOWWINDOW; /* Enable wShowWindow control */
+ stStartInfo.wShowWindow = SW_SHOWMINNOACTIVE; /* Start min (normal) */
+
+ if(CreateProcess(
+ cmd, /* Image path */
+ args, /* Arguments for command line */
+ NULL, /* Default process security */
+ NULL, /* Default thread security */
+ FALSE, /* Must be TRUE to use std handles */
+ NORMAL_PRIORITY_CLASS, /* No special scheduling */
+ NULL, /* Inherit our environment block */
+ NULL, /* Inherit our currrent directory */
+ &stStartInfo, /* -> Startup info */
+ &stProcInfo)) /* <- Process info (if OK) */
+ {
+ CloseHandle(stProcInfo.hThread);/* library source code does this. */
+ sv_setiv(ST(2), stProcInfo.dwProcessId);
+ bSuccess = TRUE;
+ }
+ XSRETURN_IV(bSuccess);
+}
+
+static
+XS(w32_GetTickCount)
+{
+ dXSARGS;
+ XSRETURN_IV(GetTickCount());
+}
+
+static
+XS(w32_GetShortPathName)
+{
+ dXSARGS;
+ SV *shortpath;
+
+ if(items != 1)
+ croak("usage: Win32::GetShortPathName($longPathName)");
+
+ shortpath = sv_mortalcopy(ST(0));
+ SvUPGRADE(shortpath, SVt_PV);
+ /* src == target is allowed */
+ if (GetShortPathName(SvPVX(shortpath), SvPVX(shortpath), SvCUR(shortpath)))
+ ST(0) = shortpath;
+ else
+ ST(0) = &sv_undef;
+ XSRETURN(1);
}
static void
@@ -150,9 +351,36 @@ xs_init()
char *file = __FILE__;
dXSUB_SYS;
newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
- newXS("Win32::GetCurrentDirectory", w32_GetCurrentDirectory, file);
+
+ /* XXX should be removed after checking with Nick */
+ newXS("Win32::GetCurrentDirectory", w32_GetCwd, file);
+
+ /* these names are Activeware compatible */
+ newXS("Win32::GetCwd", w32_GetCwd, file);
+ newXS("Win32::SetCwd", w32_SetCwd, file);
+ newXS("Win32::GetNextAvailDrive", w32_GetNextAvailDrive, file);
newXS("Win32::GetLastError", w32_GetLastError, file);
+ newXS("Win32::LoginName", w32_LoginName, file);
+ newXS("Win32::NodeName", w32_NodeName, file);
+ newXS("Win32::DomainName", w32_DomainName, file);
+ newXS("Win32::FsType", w32_FsType, file);
+ newXS("Win32::GetOSVersion", w32_GetOSVersion, file);
newXS("Win32::IsWinNT", w32_IsWinNT, file);
newXS("Win32::IsWin95", w32_IsWin95, file);
+ newXS("Win32::FormatMessage", w32_FormatMessage, file);
+ newXS("Win32::Spawn", w32_Spawn, file);
+ newXS("Win32::GetTickCount", w32_GetTickCount, file);
+ newXS("Win32::GetShortPathName", w32_GetShortPathName, file);
+
+ /* XXX Bloat Alert! The following Activeware preloads really
+ * ought to be part of Win32::Sys::*, so they're not included
+ * here.
+ */
+ /* LookupAccountName
+ * LookupAccountSID
+ * InitiateSystemShutdown
+ * AbortSystemShutdown
+ * ExpandEnvrironmentStrings
+ */
}
diff --git a/win32/win32.c b/win32/win32.c
index e6dfb6b024..9a0f910b42 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -1120,3 +1120,57 @@ stolen_get_osfhandle(int fd)
{
return pIOSubSystem->pfn_get_osfhandle(fd);
}
+
+
+/*
+ * Extras.
+ */
+
+/* simulate flock by locking a range on the file */
+
+#define LK_ERR(f,i) ((f) ? (i = 0) : (errno = GetLastError()))
+#define LK_LEN 0xffff0000
+
+DllExport int
+win32_flock(int fd, int oper)
+{
+ OVERLAPPED o;
+ int i = -1;
+ HANDLE fh;
+
+ if (!IsWinNT()) {
+ croak("flock() unimplemented on this platform");
+ return -1;
+ }
+
+ fh = (HANDLE)stolen_get_osfhandle(fd);
+ memset(&o, 0, sizeof(o));
+
+ switch(oper) {
+ case LOCK_SH: /* shared lock */
+ LK_ERR(LockFileEx(fh, 0, 0, LK_LEN, 0, &o),i);
+ break;
+ case LOCK_EX: /* exclusive lock */
+ LK_ERR(LockFileEx(fh, LOCKFILE_EXCLUSIVE_LOCK, 0, LK_LEN, 0, &o),i);
+ break;
+ case LOCK_SH|LOCK_NB: /* non-blocking shared lock */
+ LK_ERR(LockFileEx(fh, LOCKFILE_FAIL_IMMEDIATELY, 0, LK_LEN, 0, &o),i);
+ break;
+ case LOCK_EX|LOCK_NB: /* non-blocking exclusive lock */
+ LK_ERR(LockFileEx(fh,
+ LOCKFILE_EXCLUSIVE_LOCK|LOCKFILE_FAIL_IMMEDIATELY,
+ 0, LK_LEN, 0, &o),i);
+ break;
+ case LOCK_UN: /* unlock lock */
+ LK_ERR(UnlockFileEx(fh, 0, LK_LEN, 0, &o),i);
+ break;
+ default: /* unknown */
+ errno = EINVAL;
+ break;
+ }
+ return i;
+}
+
+#undef LK_ERR
+#undef LK_LEN
+
diff --git a/win32/win32.h b/win32/win32.h
index 31dfde05f2..711403315c 100644
--- a/win32/win32.h
+++ b/win32/win32.h
@@ -65,6 +65,13 @@ extern FILE *myfdopen(int, char *);
#undef alarm
#define alarm myalarm
+#undef flock
+#define flock(fd,o) win32_flock(fd,o)
+#define LOCK_SH 1
+#define LOCK_EX 2
+#define LOCK_NB 4
+#define LOCK_UN 8
+
struct tms {
long tms_utime;
long tms_stime;