2 * Copyright (c) 1999 Olaf Flebbe o.flebbe@gmx.de
4 * You may distribute under the terms of either the GNU General Public
5 * License or the Artistic License, as specified in the README file.
12 #include <sys/unistd.h>
15 Perl_epoc_init(int *argcp, char ***argvp) {
18 char **lastcp = (*argvp);
22 epoc_spawn_posix_server();
24 for (i=0; i< *argcp; i++) {
26 if (*((*argvp)[i]) == '<') {
27 if (strlen((*argvp)[i]) > 1) {
33 freopen( ptr, "r", stdin);
34 } else if (*((*argvp)[i]) == '>') {
35 if (strlen((*argvp)[i]) > 1) {
41 freopen( ptr, "w", stdout);
42 } else if ((*((*argvp)[i]) == '2') && (*(((*argvp)[i])+1) == '>')) {
43 if (strcmp( (*argvp)[i], "2>&1") == 0) {
44 dup2( fileno( stdout), fileno( stderr));
46 if (strlen((*argvp)[i]) > 2) {
52 freopen( ptr, "w", stderr);
55 *lastcp++ = (*argvp)[i];
67 /* Symbian forgot to include __fixunsdfi into the MARM euser.lib */
68 /* This is from libgcc2.c , gcc-2.7.2.3 */
70 typedef unsigned int UQItype __attribute__ ((mode (QI)));
71 typedef int SItype __attribute__ ((mode (SI)));
72 typedef unsigned int USItype __attribute__ ((mode (SI)));
73 typedef int DItype __attribute__ ((mode (DI)));
74 typedef unsigned int UDItype __attribute__ ((mode (DI)));
76 typedef float SFtype __attribute__ ((mode (SF)));
77 typedef float DFtype __attribute__ ((mode (DF)));
81 extern DItype __fixunssfdi (SFtype a);
82 extern DItype __fixunsdfdi (DFtype a);
89 if (a >= - (DFtype) (- 2147483647L -1) )
90 return (SItype) (a + (- 2147483647L -1) ) - (- 2147483647L -1) ;
101 do_spawn( char *cmd) {
107 argv0 = ptr = malloc( strlen(cmd) + 1);
109 while (*cmdptr && !isSPACE( *cmdptr)) {
116 while (*cmdptr && isSPACE( *cmdptr)) {
120 ret = epoc_spawn( argv0, cmdptr);
126 do_aspawn ( void *vreally, void **vmark, void **vsp) {
130 SV *really = (SV*)vreally;
131 SV **mark = (SV**)vmark;
147 ptr = argv =(char**) malloc ((sp-mark+3)*sizeof (char*));
149 while (++mark <= sp) {
150 if (*mark && (str = SvPV_nolen(*mark)))
155 len += strlen(argv[ index++]) + 1;
159 cmd = strdup((const char*)(really ? SvPV_nolen(really) : argv[0]));
161 for (p2=cmd; *p2 != '\0'; p2++) {
167 cmdline = (char * ) malloc( len + 1);
169 while (*argv != NULL) {
170 strcat( cmdline, *ptr++);
171 strcat( cmdline, " ");
176 rc = epoc_spawn( cmd, cmdline);
184 XS(epoc_getcwd) /* more or less stolen from win32.c */
187 /* Make the host for current directory */
192 buffer = (char *) malloc( buflen);
193 if (buffer == NULL) {
196 while ((NULL == ( ptr = getcwd( buffer, buflen))) && (errno == ERANGE)) {
198 if (NULL == realloc( buffer, buflen)) {
206 * then it worked, set PV valid,
207 * else return 'undef'
211 SV *sv = sv_newmortal();
214 for (tptr = ptr; *tptr != '\0'; tptr++) {
233 Perl_init_os_extras(void)
236 char *file = __FILE__;
237 newXS("EPOC::getcwd", epoc_getcwd, file);
241 Perl_my_setenv(pTHX_ char *nam,char *val) {
242 setenv( nam, val, 1);