stanley-king 5 gadi atpakaļ
vecāks
revīzija
5b6ff0f1f4
1 mainītis faili ar 40 papildinājumiem un 28 dzēšanām
  1. 40 28
      fcgi.c

+ 40 - 28
fcgi.c

@@ -33,7 +33,7 @@
 static int le_fcgi;
 
 const zend_function_entry fcgi_functions[] = {
-	PHP_FE(confirm_fcgi_compiled,	NULL)		/* For testing, remove later. */
+	PHP_FE(confirm_fcgi_compiled,NULL)		/* For testing, remove later. */
 	PHP_FE(fcgi_init, NULL)
 	PHP_FE(fcgi_fini, NULL)	
 	PHP_FE(fcgi_accept,	NULL)
@@ -52,7 +52,7 @@ zend_module_entry fcgi_module_entry = {
 	fcgi_functions,
 	PHP_MINIT(fcgi),
 	PHP_MSHUTDOWN(fcgi),
-	PHP_RINIT(fcgi),		/* Replace with NULL if there's nothing to do at request start */
+	PHP_RINIT(fcgi),		/* Replace with NULL if there's nthing to do at request start */
 	PHP_RSHUTDOWN(fcgi),	/* Replace with NULL if there's nothing to do at request end */
 	PHP_MINFO(fcgi),
 #if ZEND_MODULE_API_NO >= 20010901
@@ -101,16 +101,16 @@ PHP_MINFO_FUNCTION(fcgi)
 
 PHP_FUNCTION(confirm_fcgi_compiled)
 {
-	char *arg = NULL;
-	int arg_len, len;
-	char *strg;
-
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) {
-		return;
-	}
-
-	len = sprintf(&strg, 0, "Congratulations! You have successfully modified ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "fcgi", arg);
-	RETURN_STRINGL(strg, len, 0);
+	zend_string     *arg;
+	char* ret = NULL;
+	int len = 0;
+    if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &arg) == FAILURE) {
+        ret = "as this return char* data";
+        len = strlen(ret);
+        RETURN_STRING(ret,);
+    } else {
+    	RETURN_STR(arg);
+    }	
 }
 
 PHP_FUNCTION(fcgi_init)
@@ -145,18 +145,21 @@ PHP_FUNCTION(fcgi_accept)
 
 PHP_FUNCTION(fcgi_getparam)
 {
-	char *arg = NULL;	 
-	int arg_len;	 
+	zend_string *arg = NULL;	 
+	int arg_len;
+	char* type;	 
 	 
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) {	 
-		return;
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &arg) == FAILURE) {	 
+		RETURN_FALSE;
 	}
 
-	const char* ret = FCGX_GetParam(arg, stParams);
+	type = ZSTR_VAL(arg);
+
+	const char* ret = FCGX_GetParam(type, stParams);
 	ret = (ret == NULL) ? "" : ret;
 
 	char* result = estrdup(ret);
-	RETURN_STRINGL(result,strlen(result),0);
+	RETURN_STRING(result);
 }
 
 static int content_length()
@@ -269,7 +272,7 @@ PHP_FUNCTION(fcgi_getcontent)
 						char* result = estrdup(g_pcontent);
 						free(g_pcontent);
 						g_pcontent = NULL;
-						RETURN_STRINGL(result, strlen(result),0);
+						RETURN_STRING(result);
 					}					
 				}
 			}
@@ -277,27 +280,36 @@ PHP_FUNCTION(fcgi_getcontent)
 
 		// normal proccess
 		char* result = estrdup(pCon);
-		RETURN_STRINGL(result,strlen(result),0);
-	} else {
+		RETURN_STRING(result);
+	}
+	else {
 		char* result = estrdup("");
-		RETURN_STRINGL(result,strlen(result),0);
+		RETURN_STRING(result);
 	}
 }
 
 PHP_FUNCTION(fcgi_echo)
 {
-	char *arg = NULL;	 
-	int arg_len;	 
-	 
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) {	 
+	zend_string *arg = NULL;
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &arg) == FAILURE) {	 
 		return;
 	}
 
-	if(arg != NULL) {
-		FCGX_PutS(arg,stOutstream);
+	if(arg != NULL) 
+	{
+		char* data = ZSTR_VAL(arg);
+		FCGX_PutS(data,stOutstream);
 	}
 }
 
+static void print_all_header()
+{
+    for( ; *stParams != NULL; stParams++) {
+        FCGX_PutS(*stParams,stOutstream);
+        FCGX_PutS("</br>",stOutstream);
+    }
+}
+
 PHP_FUNCTION(fcgi_finish)
 {
 	FCGX_Finish();