CPAN in source form, along with many added bugfixes, and with MakeMaker
support. This bundle is available at:
- http://www.perl.com/CPAN/authors/id/GSAR/libwin32-0.06.tar.gz
+ http://www.perl.com/CPAN/authors/id/GSAR/libwin32-0.07.tar.gz
See the README in that distribution for building and installation
instructions. Look for later versions that may be available at the
=item *
-The following functions are currently unavailable: C<fork()>, C<exec()>,
+The following functions are currently unavailable: C<fork()>,
C<dump()>, C<chown()>, C<link()>, C<symlink()>, C<chroot()>,
C<setpgrp()>, C<getpgrp()>, C<setpriority()>, C<getpriority()>,
C<syscall()>, C<fcntl()>. This list is possibly very incomplete.
=item *
+crypt() is not available due to silly export restrictions. It may
+become available when the laws change. Meanwhile, look in CPAN for
+extensions that provide it.
+
+=item *
+
Various C<socket()> related calls are supported, but they may not
behave as on Unix platforms.
Borland support was added in 5.004_01 (Gurusamy Sarathy).
-Last updated: 11 June 1997
+Last updated: 15 June 1997
=cut
}
}
-#ifndef OS2
+#if !defined(OS2) && !defined(WIN32)
bool
do_exec(cmd)
return FALSE;
}
-#endif /* OS2 */
+#endif /* OS2 || WIN32 */
I32
apply(type,mark,sp)
* /bin/pdksh, /bin/ash, /bin/bash, or even something such as
* D:/bin/sh.exe.
*/
-#define SH_PATH "cmd /x /c" /**/
+#define SH_PATH "cmd.exe" /**/
/* SIG_NAME:
* This symbol contains a list of signal names in order of
* /bin/pdksh, /bin/ash, /bin/bash, or even something such as
* D:/bin/sh.exe.
*/
-#define SH_PATH "cmd /x /c" /**/
+#define SH_PATH "cmd.exe" /**/
/* SIG_NAME:
* This symbol contains a list of signal names in order of
win32_rmdir
win32_chdir
win32_flock
+win32_execvp
win32_htons
win32_ntohs
win32_htonl
#define CROAK croak
#define WARN warn
+#define EXECF_EXEC 1
+#define EXECF_SPAWN 2
+#define EXECF_SPAWN_NOWAIT 3
+
static DWORD IdOS(void);
extern WIN32_IOSUBSYSTEM win32stdio;
char szPerlLibRoot[MAX_PATH+1];
HANDLE PerlDllHandle = INVALID_HANDLE_VALUE;
+static int do_spawn2(char *cmd, int exectype);
+
int
IsWin95(void) {
return (IdOS() == VER_PLATFORM_WIN32_WINDOWS);
}
int
-do_spawn(char *cmd)
+do_spawn2(char *cmd, int exectype)
{
char **a;
char *s;
}
*a = Nullch;
if(argv[0]) {
- status = win32_spawnvp(P_WAIT, argv[0], (const char* const*)argv);
+ switch (exectype) {
+ case EXECF_SPAWN:
+ status = win32_spawnvp(P_WAIT, argv[0],
+ (const char* const*)argv);
+ break;
+ case EXECF_SPAWN_NOWAIT:
+ status = win32_spawnvp(P_NOWAIT, argv[0],
+ (const char* const*)argv);
+ break;
+ case EXECF_EXEC:
+ status = win32_execvp(argv[0], (const char* const*)argv);
+ break;
+ }
if(status != -1 || errno == 0)
needToTry = FALSE;
}
char *argv[5];
argv[0] = shell; argv[1] = "/x"; argv[2] = "/c";
argv[3] = cmd; argv[4] = Nullch;
- status = win32_spawnvp(P_WAIT, argv[0], (const char* const*)argv);
+ switch (exectype) {
+ case EXECF_SPAWN:
+ status = win32_spawnvp(P_WAIT, argv[0],
+ (const char* const*)argv);
+ break;
+ case EXECF_SPAWN_NOWAIT:
+ status = win32_spawnvp(P_NOWAIT, argv[0],
+ (const char* const*)argv);
+ break;
+ case EXECF_EXEC:
+ status = win32_execvp(argv[0], (const char* const*)argv);
+ break;
+ }
}
if (status < 0) {
if (dowarn)
- warn("Can't spawn \"%s\": %s", needToTry ? shell : argv[0],
+ warn("Can't %s \"%s\": %s",
+ (exectype == EXECF_EXEC ? "exec" : "spawn"),
+ needToTry ? shell : argv[0],
strerror(errno));
status = 255 << 8;
}
return (status);
}
+int
+do_spawn(char *cmd)
+{
+ return do_spawn2(cmd, EXECF_SPAWN);
+}
+
+bool
+do_exec(char *cmd)
+{
+ do_spawn2(cmd, EXECF_EXEC);
+ return FALSE;
+}
+
#define PATHLEN 1024
return pIOSubSystem->pfnspawnvp(mode, cmdname, argv);
}
+DllExport int
+win32_execvp(const char *cmdname, const char *const *argv)
+{
+ return pIOSubSystem->pfnexecvp(cmdname, argv);
+}
+
int
stolen_open_osfhandle(long handle, int flags)
{
unsigned int myalarm(unsigned int sec);
int do_aspawn(void* really, void** mark, void** arglast);
int do_spawn(char *cmd);
+char do_exec(char *cmd);
typedef char * caddr_t; /* In malloc.c (core address). */
_rmdir,
_chdir,
my_flock, /* (*pfunc_flock)(int fd, int oper) */
+ execvp,
87654321L, /* end of structure */
};
int (*pfnrmdir)(const char *path);
int (*pfnchdir)(const char *path);
int (*pfnflock)(int fd, int oper);
-int signature_end;
+int (*pfnexecvp)(const char *cmdname, const char *const *argv);
+int signature_end;
} WIN32_IOSUBSYSTEM;
typedef WIN32_IOSUBSYSTEM *PWIN32_IOSUBSYSTEM;
EXT int win32_rmdir(const char *dir);
EXT int win32_chdir(const char *dir);
EXT int win32_flock(int fd, int oper);
+EXT int win32_execvp(const char *cmdname, const char *const *argv);
/*
* these two are win32 specific but still io related
#define rmdir win32_rmdir
#define chdir win32_chdir
#define flock(fd,o) win32_flock(fd,o)
+#define execvp win32_execvp
#endif /* WIN32IO_IS_STDIO */
#endif /* WIN32IOP_H */