cvs: /php4 NEWS /php4/sapi/cgi cgi_main.c
| From: | Zeev Suraski | Date: | Thu, 04 May 2000 13:42:21 +0000 |
| Subject: | cvs: /php4 NEWS /php4/sapi/cgi cgi_main.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-14468@lists.php.net to get a copy of this message | ||
zeev Thu May 4 06:42:21 2000 EDT
Modified files:
/php4 NEWS
/php4/sapi/cgi cgi_main.c
Log:
- Add -z and -g switches to the CGI
Index: php4/NEWS
diff -u php4/NEWS:1.230 php4/NEWS:1.231
--- php4/NEWS:1.230 Wed May 3 18:09:09 2000
+++ php4/NEWS Thu May 4 06:42:21 2000
@@ -5,7 +5,7 @@
- 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: php4/sapi/cgi/cgi_main.c
diff -u php4/sapi/cgi/cgi_main.c:1.39 php4/sapi/cgi/cgi_main.c:1.40
--- php4/sapi/cgi/cgi_main.c:1.39 Thu Apr 20 06:43:48 2000
+++ php4/sapi/cgi/cgi_main.c Thu May 4 06:42:21 2000
@@ -236,6 +236,7 @@
#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 @@
}
+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 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 @@
}
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 @@
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 @@
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 @@
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) {