cvs: /php4/sapi/servlet formatter.java servlet.dsw /php4/sapi/servlet Makefile.in servlet.c servlet.dsp servlet.java web.xml

From: Date: Sun, 05 Mar 2000 21:35:53 +0000
Subject: cvs: /php4/sapi/servlet formatter.java servlet.dsw /php4/sapi/servlet Makefile.in servlet.c servlet.dsp servlet.java web.xml
Groups: php.version4 
Request: Send a blank email to php-version4+get-11541@lists.php.net to get a copy of this message
rubys Sun Mar 5 13:35:53 2000 EDT Added files: /php4/sapi/servlet formatter.java servlet.dsw Modified files: /php4/sapi/servlet Makefile.in servlet.c servlet.dsp servlet.java web.xml Log: Add support for PHP syntax highlighting Remove debug output Fix trap when string to be output is not null terminated Add a MS workspace for project level dependencies Match case of contentType header Index: php4/sapi/servlet/Makefile.in diff -u php4/sapi/servlet/Makefile.in:1.7 php4/sapi/servlet/Makefile.in:1.8 --- php4/sapi/servlet/Makefile.in:1.7 Sun Jan 30 12:48:32 2000 +++ php4/sapi/servlet/Makefile.in Sun Mar 5 13:35:23 2000 @@ -26,8 +26,9 @@ javac net/php/reflect.java @test ! -f reflect.class || mv reflect.class net/php # bug in KJC javac javac -classpath .:$(SERVLET_CLASSPATH):$(JAVA_CLASSPATH) net/php/servlet.java + javac net/php/formatter.java @test ! -f servlet.class || mv servlet.class net/php # bug in KJC javac $(JAVA_JAR) phpsrvlt.jar net/php/*.class net/php/*.properties - @rm net/php/servlet.* net/php/reflect.* + @rm net/php/servlet.* net/php/reflect.* net/php/formatter.* @rmdir net/php @rmdir net Index: php4/sapi/servlet/servlet.c diff -u php4/sapi/servlet/servlet.c:1.21 php4/sapi/servlet/servlet.c:1.22 --- php4/sapi/servlet/servlet.c:1.21 Sun Feb 20 05:43:50 2000 +++ php4/sapi/servlet/servlet.c Sun Mar 5 13:35:23 2000 @@ -108,13 +108,11 @@ void ThrowIOException (JNIEnv *jenv, char *msg) { jclass iox = (*jenv)->FindClass (jenv, "java/io/IOException"); (*jenv)->ThrowNew (jenv, iox, (msg?msg:"null") ); - printf("IOException: %s\n", msg); } void ThrowServletException (JNIEnv *jenv, char *msg) { jclass sx = (*jenv)->FindClass (jenv, "javax/servlet/ServletException"); (*jenv)->ThrowNew (jenv, sx, msg); - printf("ServletException: %s\n", msg); } /***************************************************************************/ @@ -138,7 +136,12 @@ jclass servletClass = (*jenv)->GetObjectClass(jenv, servlet); jmethodID write = (*jenv)->GetMethodID(jenv, servletClass, "write", "(Ljava/lang/String;)V"); - jstring arg=(*jenv)->NewStringUTF(jenv, str); + char *copy = malloc(str_length+1); + jstring arg; + memcpy(copy, str, str_length); + copy[str_length] = 0; + arg=(*jenv)->NewStringUTF(jenv, copy); + free(copy); (*jenv)->CallVoidMethod(jenv, servlet, write, arg); (*jenv)->DeleteLocalRef(jenv, arg); return str_length; @@ -315,7 +318,8 @@ (JNIEnv *jenv, jobject self, jstring requestMethod, jstring queryString, jstring pathInfo, jstring pathTranslated, - jstring contentType, jint contentLength, jstring authUser) + jstring contentType, jint contentLength, + jstring authUser, jboolean display_source_mode) { zend_file_handle file_handle; @@ -376,12 +380,23 @@ * Execute the request */ Java_net_php_reflect_setEnv(jenv, 0); - php_execute_script(&file_handle CLS_CC ELS_CC PLS_CC); + if (display_source_mode) { + zend_syntax_highlighter_ini syntax_highlighter_ini; + + if (open_file_for_scanning(&file_handle CLS_CC)==SUCCESS) { + php_get_highlight_struct(&syntax_highlighter_ini); + sapi_send_headers(); + zend_highlight(&syntax_highlighter_ini); + } + } else { + php_execute_script(&file_handle CLS_CC ELS_CC PLS_CC); + php_header(); /* Make sure headers have been sent */ + } + /* * Clean up */ - php_header(); /* Make sure headers have been sent */ FREESTRING(SG(request_info).request_method); FREESTRING(SG(request_info).query_string); @@ -392,6 +407,6 @@ efree(SG(server_context)); SG(server_context)=0; - php_request_shutdown((void *) 0); + if (!display_source_mode) php_request_shutdown((void *) 0); } Index: php4/sapi/servlet/servlet.dsp diff -u php4/sapi/servlet/servlet.dsp:1.5 php4/sapi/servlet/servlet.dsp:1.6 --- php4/sapi/servlet/servlet.dsp:1.5 Tue Feb 22 06:37:44 2000 +++ php4/sapi/servlet/servlet.dsp Sun Mar 5 13:35:23 2000 @@ -181,8 +181,10 @@ echo library=phpsrvlt>net/php/reflect.properties echo library=phpsrvlt>net/php/servlet.properties $(JAVA_HOME)\bin\javac net\php\servlet.java + $(JAVA_HOME)\bin\javac net\php\formatter.java $(JAVA_HOME)\bin\jar c0f $(OutDir)\phpsrvlt.jar net\php\*.class net\php\*.properties erase net\php\servlet.* + erase net\php\formatter.* erase net\php\reflect.* rmdir net\php rmdir net @@ -204,8 +206,10 @@ echo library=phpsrvlt>net/php/reflect.properties echo library=phpsrvlt>net/php/servlet.properties $(JAVA_HOME)\bin\javac -g net\php\servlet.java + $(JAVA_HOME)\bin\javac -g net\php\formatter.java $(JAVA_HOME)\bin\jar c0f $(OutDir)\phpsrvlt.jar net\php\*.class net\php\*.properties erase net\php\servlet.* + erase net\php\formatter.* erase net\php\reflect.* rmdir net\php rmdir net @@ -227,8 +231,10 @@ echo library=phpsrvlt>net/php/reflect.properties echo library=phpsrvlt>net/php/servlet.properties $(JAVA_HOME)\bin\javac -g net\php\servlet.java + $(JAVA_HOME)\bin\javac -g net\php\formatter.java $(JAVA_HOME)\bin\jar c0f $(OutDir)\phpsrvlt.jar net\php\*.class net\php\*.properties erase net\php\servlet.* + erase net\php\formatter.* erase net\php\reflect.* rmdir net\php rmdir net @@ -250,8 +256,10 @@ echo library=phpsrvlt>net/php/reflect.properties echo library=phpsrvlt>net/php/servlet.properties $(JAVA_HOME)\bin\javac net\php\servlet.java + $(JAVA_HOME)\bin\javac net\php\formatter.java $(JAVA_HOME)\bin\jar c0f $(OutDir)\phpsrvlt.jar net\php\*.class net\php\*.properties erase net\php\servlet.* + erase net\php\formatter.* erase net\php\reflect.* rmdir net\php rmdir net Index: php4/sapi/servlet/servlet.java diff -u php4/sapi/servlet/servlet.java:1.3 php4/sapi/servlet/servlet.java:1.4 --- php4/sapi/servlet/servlet.java:1.3 Sun Jan 30 12:48:32 2000 +++ php4/sapi/servlet/servlet.java Sun Mar 5 13:35:23 2000 @@ -29,6 +29,10 @@ HttpServletResponse response; ServletInputStream stream; + static int startup_count = 0; + + protected boolean display_source_mode = false; + /******************************************************************/ /* native methods */ /******************************************************************/ @@ -38,7 +42,8 @@ native long define(String name); native void send(String requestMethod, String queryString, String pathInfo, String pathTranslated, - String contentType, int contentLength, String authUser); + String contentType, int contentLength, String authUser, + boolean display_source_mode); native void shutdown(); /******************************************************************/ @@ -65,7 +70,7 @@ void header(String data) { try { - if (data.startsWith("Content-Type: ")) { + if (data.startsWith("Content-type: ")) { response.setContentType(data.substring(data.indexOf(" ")+1)); } else if (data.startsWith("Location: ")) { response.sendRedirect(data.substring(data.indexOf(" ")+1)); @@ -96,8 +101,8 @@ /******************************************************************/ public void init(ServletConfig config) throws ServletException { - super.init(config); - startup(); + super.init(config); + if (0 == startup_count++) startup(); } public void service(HttpServletRequest request, @@ -113,7 +118,7 @@ send(request.getMethod(), request.getQueryString(), request.getPathInfo(), contextPath, request.getContentType(), request.getContentLength(), - request.getRemoteUser()); + request.getRemoteUser(), display_source_mode); try { if (stream != null) stream.close(); @@ -123,7 +128,7 @@ } public void destroy() { - shutdown(); + if (0 == --startup_count) shutdown(); super.destroy(); } Index: php4/sapi/servlet/web.xml diff -u php4/sapi/servlet/web.xml:1.1 php4/sapi/servlet/web.xml:1.2 --- php4/sapi/servlet/web.xml:1.1 Mon Nov 29 07:36:25 1999 +++ php4/sapi/servlet/web.xml Sun Mar 5 13:35:23 2000 @@ -21,4 +21,21 @@ *.php </url-pattern> </servlet-mapping> + + <servlet> + <servlet-name> + php-formatter + </servlet-name> + <servlet-class> + net.php.formatter + </servlet-class> + </servlet> + <servlet-mapping> + <servlet-name> + php-formatter + </servlet-name> + <url-pattern> + *.phps + </url-pattern> + </servlet-mapping> </web-app>

« previous php.version4 (#11541) next »