hyanantha               Wed Sep 29 02:04:37 2004 EDT

  Modified files:              
    /php-src/ext/standard       proc_open.c 
  Log:
  implemented proc_open for NETWARE
  
  
http://cvs.php.net/diff.php/php-src/ext/standard/proc_open.c?r1=1.28&r2=1.29&ty=u
Index: php-src/ext/standard/proc_open.c
diff -u php-src/ext/standard/proc_open.c:1.28 php-src/ext/standard/proc_open.c:1.29
--- php-src/ext/standard/proc_open.c:1.28       Wed Jun 16 19:57:25 2004
+++ php-src/ext/standard/proc_open.c    Wed Sep 29 02:04:36 2004
@@ -15,7 +15,7 @@
    | Author: Wez Furlong <[EMAIL PROTECTED]>                           |
    +----------------------------------------------------------------------+
  */
-/* $Id: proc_open.c,v 1.28 2004/06/16 23:57:25 abies Exp $ */
+/* $Id: proc_open.c,v 1.29 2004/09/29 06:04:36 hyanantha Exp $ */
 
 #if 0 && (defined(__linux__) || defined(sun) || defined(__IRIX__))
 # define _BSD_SOURCE           /* linux wants this when XOPEN mode is on */
@@ -35,6 +35,11 @@
 #include "php_globals.h"
 #include "SAPI.h"
 
+#ifdef NETWARE
+#include <proc.h>
+#include <library.h>
+#endif
+
 #if HAVE_SYS_WAIT_H
 #include <sys/wait.h>
 #endif
@@ -478,6 +483,13 @@
        char *command_with_cmd;
        UINT old_error_mode;
 #endif
+#ifdef NETWARE
+       char** child_argv = NULL;
+       char* command_dup = NULL;
+       char* orig_cwd = NULL;
+       int command_num_args = 0;
+       wiring_t channel;
+#endif
        php_process_id_t child;
        struct php_process_handle *proc;
        int is_persistent = 0; /* TODO: ensure that persistent procs will work */
@@ -810,6 +822,46 @@
 
                goto exit_fail;
 
+       }
+#elif defined(NETWARE)
+       if (cwd) {
+               orig_cwd = getcwd(NULL, PATH_MAX);
+               chdir2(cwd);
+       }
+       channel.infd = descriptors[0].childend;
+       channel.outfd = descriptors[1].childend;
+       channel.errfd = -1;
+       /* Duplicate the command as processing downwards will modify it*/
+       command_dup = strdup(command);
+       /* get a number of args */
+       construct_argc_argv(command_dup, NULL, &command_num_args, NULL);
+       child_argv = (char**) malloc((command_num_args + 1) * sizeof(char*));
+       if(!child_argv) {
+               free(command_dup);
+               if (cwd && orig_cwd) {
+                       chdir2(orig_cwd);
+                       free(orig_cwd);
+               }
+       }
+       /* fill the child arg vector */
+       construct_argc_argv(command_dup, NULL, &command_num_args, child_argv);
+       child_argv[command_num_args] = NULL;
+       child = procve(child_argv[0], PROC_DETACHED|PROC_INHERIT_CWD, NULL, &channel, 
NULL, NULL, 0, NULL, (const char**)child_argv);
+       free(child_argv);
+       free(command_dup);
+       if (cwd && orig_cwd) {
+               chdir2(orig_cwd);
+               free(orig_cwd);
+       }
+       if (child < 0) {
+               /* failed to fork() */
+               /* clean up all the descriptors */
+               for (i = 0; i < ndesc; i++) {
+                       close(descriptors[i].childend);
+                       close(descriptors[i].parentend);
+               }
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "procve failed - %s", 
strerror(errno));
+               goto exit_fail;
        }
 #else
 # error You lose (configure should not have let you get here)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to