]> granicus.if.org Git - php/commitdiff
- Add -z and -g switches to the CGI
authorZeev Suraski <zeev@php.net>
Thu, 4 May 2000 13:42:21 +0000 (13:42 +0000)
committerZeev Suraski <zeev@php.net>
Thu, 4 May 2000 13:42:21 +0000 (13:42 +0000)
NEWS
sapi/cgi/cgi_main.c

diff --git a/NEWS b/NEWS
index 094439992f89c95aac0dcbef9150c9a678ad3203..3bed2470ab1d8457218c848b42bfc6a5e6ffd73c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,7 +5,7 @@ PHP 4.0                                                                    NEWS
 - Moved install-local to install-sapi for clarity. (Joey)
 - Improved extension build framework. Refer to README.SELF-CONTAINED-EXTENSIONS
   for an introduction. (Sascha)
-- Dynamically allocate points for ImagePolygon (Marc Pohl)
+- ImagePolygon() is no longer limited by a maximum number of polygons (Marc Pohl)
 - Added configure time checking for bcmath package (Joey, Sascha)
 - Added get_declared_classes(). (Andrei, Zend library)
 - Add initial NSAPI module from Jayakumar Muthukumarasamy. (Rasmus)
index 972b8d90001a4a0ffbe5076566c5a710296355fc..aed82525943e1dab68f907fa4aa3ae848de8cf85 100644 (file)
@@ -236,6 +236,7 @@ static void php_cgi_usage(char *argv0)
 #endif
                                "  -d foo[=bar]   Define INI entry foo with value 'bar'\n"
                                "  -e             Generate extended information for debugger/profiler\n"
+                               "  -z<file>       Load Zend extension <file>.\n"
                                "  -i             PHP information\n"
                                "  -h             This help\n", prog);
 }
@@ -313,6 +314,24 @@ static void define_command_line_ini_entry(char *arg)
 }
 
 
+void php_register_command_line_global_vars(char **arg)
+{
+       char *var, *val;
+
+       var = *arg;
+       val = strchr(var, '=');
+       if (!val) {
+               printf("No value specified for variable '%s'\n", var);
+       } else {
+               *val++ = NULL;
+               php_register_variable(var, val, NULL ELS_CC PLS_CC);
+       }
+       efree(*arg);
+}
+       
+
+
+
 int main(int argc, char *argv[])
 {
        int cgi = 0, c, i, len;
@@ -326,6 +345,7 @@ int main(int argc, char *argv[])
        int orig_optind=ap_php_optind;
        char *orig_optarg=ap_php_optarg;
        char *argv0=NULL;
+       zend_llist global_vars;
 #if SUPPORT_INTERACTIVE
        int interactive=0;
 #endif
@@ -404,11 +424,17 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
        }
 
        if (!cgi) {
-               while ((c=ap_php_getopt(argc, argv, "c:d:qvisnaeh?vf:"))!=-1) {
+               while ((c=ap_php_getopt(argc, argv, "c:d:z:g:qvisnaeh?vf:"))!=-1) {
                        switch (c) {
                                case 'c':
                                        php_ini_path = strdup(ap_php_optarg);           /* intentional leak */
                                        break;
+                               case '?':
+                                       php_output_startup();
+                                       SG(headers_sent) = 1;
+                                       php_cgi_usage(argv[0]);
+                                       exit(1);
+                                       break;
                        }
                }
                ap_php_optind = orig_optind;
@@ -435,9 +461,11 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
 
        SG(request_info).argv0 = argv0;
 
+       zend_llist_init(&global_vars, sizeof(char *), NULL, 0);
+
        if (!cgi) {                                     /* never execute the arguments if you are a CGI */
                SG(request_info).argv0 = NULL;
-               while ((c = ap_php_getopt(argc, argv, "c:d:qvisnaeh?vf:")) != -1) {
+               while ((c = ap_php_getopt(argc, argv, "c:d:z:g:qvisnaeh?vf:")) != -1) {
                        switch (c) {
                                case 'f':
                                        if (!cgi_started){ 
@@ -510,6 +538,15 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
                                case 'd':
                                        define_command_line_ini_entry(ap_php_optarg);
                                        break;
+                               case 'g': {
+                                               char *arg = estrdup(ap_php_optarg);
+
+                                               zend_llist_add_element(&global_vars, &arg);
+                                       }
+                                       break;
+                               case 'z':
+                                       zend_load_extension(ap_php_optarg);
+                                       break;
                                default:
                                        break;
                        }
@@ -533,6 +570,9 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
        file_handle.type = ZEND_HANDLE_FP;
        file_handle.handle.fp = stdin;
 
+       /* This actually destructs the elements of the list - ugly hack */
+       zend_llist_apply(&global_vars, php_register_command_line_global_vars);
+       zend_llist_destroy(&global_vars);
 
        if (!cgi) {
                if (!SG(request_info).query_string) {