diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 2000-01-10 05:27:03 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 2000-01-10 05:27:03 +0000 |
commit | 3a2f06e93704a4187f4ca10ac210246cacbd9b05 (patch) | |
tree | e2098523c3499c3b9f0441e69fa72fd71a73907a /epoc/epoc.c | |
parent | 5a3e78123e3b27b54e7f651bd5fa051044f04189 (diff) | |
download | perl-3a2f06e93704a4187f4ca10ac210246cacbd9b05.tar.gz |
EPOC port update (from Olaf Flebbe <O.Flebbe@science-computing.de>)
p4raw-id: //depot/perl@4782
Diffstat (limited to 'epoc/epoc.c')
-rw-r--r-- | epoc/epoc.c | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/epoc/epoc.c b/epoc/epoc.c index d0fae23f7e..498036dbc0 100644 --- a/epoc/epoc.c +++ b/epoc/epoc.c @@ -11,7 +11,6 @@ #include <stdio.h> #include <sys/unistd.h> -char *environ = NULL; void Perl_epoc_init(int *argcp, char ***argvp) { int i; @@ -87,4 +86,62 @@ __fixunsdfsi (a) return (SItype) a; } +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +int +do_aspawn( pTHX_ SV *really,SV **mark,SV **sp) { + return do_spawn( really, mark, sp); +} + +int +do_spawn (pTHX_ SV *really,SV **mark,SV **sp) +{ + dTHR; + int rc; + char **a,*cmd,**ptr, *cmdline, **argv, *p2; + STRLEN n_a; + size_t len = 0; + + if (sp<=mark) + return -1; + + a=argv=ptr=(char**) malloc ((sp-mark+3)*sizeof (char*)); + + while (++mark <= sp) { + if (*mark) + *a = SvPVx(*mark, n_a); + else + *a = ""; + len += strlen( *a) + 1; + a++; + } + *a = Nullch; + + if (!(really && *(cmd = SvPV(really, n_a)))) { + cmd = argv[0]; + argv++; + } + + cmdline = (char * ) malloc( len + 1); + cmdline[ 0] = '\0'; + while (*argv != NULL) { + strcat( cmdline, *argv++); + strcat( cmdline, " "); + } + + for (p2=cmd; *p2 != '\0'; p2++) { + /* Change / to \ */ + if ( *p2 == '/') + *p2 = '\\'; + } + rc = epoc_spawn( cmd, cmdline); + free( ptr); + free( cmdline); + + return rc; +} + + #endif |