cvs: /php4/sapi/cgi getopt.c php_getopt.h /php4 getopt.c php_getopt.h /php4 main.c /php4/sapi/cgi Makefile.in cgi_main.c /php4/sapi/servlet servlet.c

From: Date: Thu, 10 Feb 2000 16:27:58 +0000
Subject: cvs: /php4/sapi/cgi getopt.c php_getopt.h /php4 getopt.c php_getopt.h /php4 main.c /php4/sapi/cgi Makefile.in cgi_main.c /php4/sapi/servlet servlet.c
Groups: php.version4 
Request: Send a blank email to php-version4+get-10034@lists.php.net to get a copy of this message
zeev Thu Feb 10 08:27:58 2000 EDT Added files: /php4/sapi/cgi getopt.c php_getopt.h Removed files: /php4 getopt.c php_getopt.h Modified files: /php4 main.c /php4/sapi/cgi Makefile.in cgi_main.c /php4/sapi/servlet servlet.c Log: Always use getopt with CGI, never use it for anything else Index: php4/main.c diff -u php4/main.c:1.193 php4/main.c:1.194 --- php4/main.c:1.193 Thu Feb 10 07:55:09 2000 +++ php4/main.c Thu Feb 10 08:27:27 2000 @@ -19,7 +19,7 @@ */ -/* $Id: main.c,v 1.193 2000/02/10 15:55:09 zeev Exp $ */ +/* $Id: main.c,v 1.194 2000/02/10 16:27:27 zeev Exp $ */ #include <stdio.h> @@ -68,11 +68,6 @@ #include "php_content_types.h" #include "SAPI.h" - -#if MSVC5 || !defined(HAVE_GETOPT) -#include "php_getopt.h" -#endif - #ifndef ZTS php_core_globals core_globals; Index: php4/sapi/cgi/Makefile.in diff -u php4/sapi/cgi/Makefile.in:1.1 php4/sapi/cgi/Makefile.in:1.2 --- php4/sapi/cgi/Makefile.in:1.1 Wed Dec 29 18:59:38 1999 +++ php4/sapi/cgi/Makefile.in Thu Feb 10 08:27:28 2000 @@ -5,6 +5,6 @@ VPATH = @srcdir@ LTLIBRARY_NAME = libsapi.la -LTLIBRARY_SOURCES = cgi_main.c +LTLIBRARY_SOURCES = cgi_main.c getopt.c include $(topsrcdir)/build/ltlib.mk Index: php4/sapi/cgi/cgi_main.c diff -u php4/sapi/cgi/cgi_main.c:1.19 php4/sapi/cgi/cgi_main.c:1.20 --- php4/sapi/cgi/cgi_main.c:1.19 Thu Feb 10 07:55:09 2000 +++ php4/sapi/cgi/cgi_main.c Thu Feb 10 08:27:28 2000 @@ -70,9 +70,7 @@ #include "zend_indent.h" -#if MSVC5 || !defined(HAVE_GETOPT) #include "php_getopt.h" -#endif PHPAPI extern char *php_ini_path; @@ -80,8 +78,8 @@ #define PHP_MODE_HIGHLIGHT 2 #define PHP_MODE_INDENT 3 -PHPAPI extern char *optarg; -PHPAPI extern int optind; +PHPAPI extern char *ap_php_optarg; +PHPAPI extern int ap_php_optind; static int sapi_cgibin_ub_write(const char *str, uint str_length) @@ -266,8 +264,8 @@ int behavior=PHP_MODE_STANDARD; int no_headers=0; int free_path_translated=0; - int orig_optind=optind; - char *orig_optarg=optarg; + int orig_optind=ap_php_optind; + char *orig_optarg=ap_php_optarg; #if SUPPORT_INTERACTIVE int interactive=0; #endif @@ -335,15 +333,15 @@ } if (!cgi) { - while ((c=getopt(argc, argv, "c:d:qvisnaeh?vf:"))!=-1) { + while ((c=ap_php_getopt(argc, argv, "c:d:qvisnaeh?vf:"))!=-1) { switch (c) { case 'c': - php_ini_path = strdup(optarg); /* intentional leak */ + php_ini_path = strdup(ap_php_optarg); /* intentional leak */ break; } } - optind = orig_optind; - optarg = orig_optarg; + ap_php_optind = orig_optind; + ap_php_optarg = orig_optarg; } @@ -366,7 +364,7 @@ if (!cgi) { /* never execute the arguments if you are a CGI */ request_info.php_argv0 = NULL; - while ((c = getopt(argc, argv, "c:d:qvisnaeh?vf:")) != -1) { + while ((c = ap_php_getopt(argc, argv, "c:d:qvisnaeh?vf:")) != -1) { switch (c) { case 'f': if (!cgi_started){ @@ -379,7 +377,7 @@ SG(headers_sent) = 1; } cgi_started=1; - SG(request_info).path_translated = estrdup(optarg); + SG(request_info).path_translated = estrdup(ap_php_optarg); free_path_translated=1; /* break missing intentionally */ case 'q': @@ -437,7 +435,7 @@ exit(1); break; case 'd': - define_command_line_ini_entry(optarg); + define_command_line_ini_entry(ap_php_optarg); break; default: break; @@ -465,20 +463,20 @@ if (!cgi) { if (!SG(request_info).query_string) { - for (i = optind, len = 0; i < argc; i++) + for (i = ap_php_optind, len = 0; i < argc; i++) len += strlen(argv[i]) + 1; s = malloc(len + 1); /* leak - but only for command line version, so ok */ *s = '\0'; /* we are pretending it came from the environment */ - for (i = optind, len = 0; i < argc; i++) { + for (i = ap_php_optind, len = 0; i < argc; i++) { strcat(s, argv[i]); if (i < (argc - 1)) strcat(s, "+"); } SG(request_info).query_string = s; } - if (!SG(request_info).path_translated && argc > optind) - SG(request_info).path_translated = argv[optind]; + if (!SG(request_info).path_translated && argc > ap_php_optind) + SG(request_info).path_translated = argv[ap_php_optind]; } /* If for some reason the CGI interface is not setting the PATH_TRANSLATED correctly, SG(request_info).path_translated is NULL. Index: php4/sapi/servlet/servlet.c diff -u php4/sapi/servlet/servlet.c:1.13 php4/sapi/servlet/servlet.c:1.14 --- php4/sapi/servlet/servlet.c:1.13 Thu Feb 10 07:55:10 2000 +++ php4/sapi/servlet/servlet.c Thu Feb 10 08:27:28 2000 @@ -67,17 +67,10 @@ #include "zend_highlight.h" #include "zend_indent.h" -#if WIN32|WINNT || !defined(HAVE_GETOPT) -#include "php_getopt.h" -#endif - PHPAPI extern char *php_ini_path; JNIEXPORT void JNICALL Java_net_php_reflect_setEnv (JNIEnv *newJenv, jclass self); - -PHPAPI extern char *optarg; -PHPAPI extern int optind; typedef struct { JNIEnv *jenv;

« previous php.version4 (#10034) next »