diff -Nru clearsilver-0.7.1/Makefile clearsilver-0.7.2/Makefile --- clearsilver-0.7.1/Makefile Wed Jul 31 17:01:40 2002 +++ clearsilver-0.7.2/Makefile Thu Oct 17 14:08:42 2002 @@ -39,7 +39,7 @@ killdepend: @echo "*******************************************" @echo "** Removing Old dependencies..." - @find . -name "Makefile.depends" -print | xargs -i% rm % + @find . -name "Makefile.depends" -print | $(XARGS) rm % .PHONY: man man: @@ -76,9 +76,9 @@ mkdir -p $$mdir; \ done -CS_DISTDIR = clearsilver-0.7.0 -CS_LABEL = CLEARSILVER-0_7_0 -CS_FILES = LICENSE CS_LICENSE rules.mk Makefile util cs cgi python scripts mod_ecs imd +CS_DISTDIR = clearsilver-0.7.2 +CS_LABEL = CLEARSILVER-0_7_2 +CS_FILES = LICENSE CS_LICENSE rules.mk Makefile util cs cgi python scripts mod_ecs imd java-jni perl cs_dist: rm -rf $(CS_DISTDIR) cvs -q tag -F $(CS_LABEL) $(CS_FILES) diff -Nru clearsilver-0.7.1/cgi/.cvsignore clearsilver-0.7.2/cgi/.cvsignore --- clearsilver-0.7.1/cgi/.cvsignore Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/cgi/.cvsignore Tue Oct 1 15:30:02 2002 @@ -0,0 +1,2 @@ +static.cgi +static.cso diff -Nru clearsilver-0.7.1/cgi/Makefile clearsilver-0.7.2/cgi/Makefile --- clearsilver-0.7.1/cgi/Makefile Wed Jul 31 17:01:41 2002 +++ clearsilver-0.7.2/cgi/Makefile Thu Oct 17 13:54:22 2002 @@ -46,4 +46,4 @@ $(RM) *.o distclean: - $(RM) $(TARGETS) *.o + $(RM) Makefile.depends $(TARGETS) *.o diff -Nru clearsilver-0.7.1/cgi/date.c clearsilver-0.7.2/cgi/date.c --- clearsilver-0.7.1/cgi/date.c Tue May 14 12:18:31 2002 +++ clearsilver-0.7.2/cgi/date.c Thu Sep 26 14:27:09 2002 @@ -30,6 +30,7 @@ * prefix.year - full year (ie, 4 digits) * prefix.2yr - year (2 digits) * prefix.wday - day of the week + * prefix.tzoffset - hhmm from UTC * */ @@ -39,6 +40,8 @@ HDF *obj; int hour, am = 1; char buf[256]; + int tzoffset = 0; + char tzsign = '-'; obj = hdf_get_obj (data, prefix); if (obj == NULL) @@ -54,7 +57,8 @@ snprintf (buf, sizeof(buf), "%02d", ttm->tm_min); err = hdf_set_value (obj, "min", buf); if (err) return nerr_pass(err); - err = hdf_set_int_value (obj, "24hour", ttm->tm_hour); + snprintf (buf, sizeof(buf), "%02d", ttm->tm_hour); + err = hdf_set_value (obj, "24hour", buf); if (err) return nerr_pass(err); hour = ttm->tm_hour; if (hour == 0) @@ -84,6 +88,15 @@ err = hdf_set_value (obj, "2yr", buf); if (err) return nerr_pass(err); err = hdf_set_int_value (obj, "wday", ttm->tm_wday); + if (err) return nerr_pass(err); + tzoffset = timezone / 60; + if (tzoffset < 0) + { + tzoffset *= -1; + tzsign = '+'; + } + snprintf(buf, sizeof(buf), "%c%02d%02d", tzsign, tzoffset / 60, tzoffset % 60); + err = hdf_set_value (obj, "tzoffset", buf); if (err) return nerr_pass(err); return STATUS_OK; diff -Nru clearsilver-0.7.1/cs/.cvsignore clearsilver-0.7.2/cs/.cvsignore --- clearsilver-0.7.1/cs/.cvsignore Thu Jul 5 01:23:13 2001 +++ clearsilver-0.7.2/cs/.cvsignore Tue Oct 1 15:30:03 2002 @@ -1,3 +1,4 @@ +cstest Makefile.depends test *.out diff -Nru clearsilver-0.7.1/cs/Makefile clearsilver-0.7.2/cs/Makefile --- clearsilver-0.7.1/cs/Makefile Mon Jun 10 18:46:23 2002 +++ clearsilver-0.7.2/cs/Makefile Thu Oct 17 13:54:23 2002 @@ -64,4 +64,4 @@ $(RM) core *.o distclean: - $(RM) $(TARGETS) core *.o + $(RM) Makefile.depends $(TARGETS) core *.o diff -Nru clearsilver-0.7.1/imd/Makefile clearsilver-0.7.2/imd/Makefile --- clearsilver-0.7.1/imd/Makefile Sat Dec 30 01:57:16 2000 +++ clearsilver-0.7.2/imd/Makefile Thu Oct 17 13:54:24 2002 @@ -25,4 +25,4 @@ $(RM) *.o distclean: - $(RM) $(TARGETS) *.o + $(RM) Makefile.depends $(TARGETS) *.o diff -Nru clearsilver-0.7.1/java-jni/.cvsignore clearsilver-0.7.2/java-jni/.cvsignore --- clearsilver-0.7.1/java-jni/.cvsignore Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/java-jni/.cvsignore Tue Oct 1 15:30:05 2002 @@ -0,0 +1,4 @@ +*.class +*.jar +org_clearsilver_CS.h +org_clearsilver_HDF.h diff -Nru clearsilver-0.7.1/java-jni/CGI.java clearsilver-0.7.2/java-jni/CGI.java --- clearsilver-0.7.1/java-jni/CGI.java Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/java-jni/CGI.java Thu Sep 19 23:12:45 2002 @@ -0,0 +1,23 @@ + +import java.io.*; +import java.util.*; + +class CGI { + public int _cgiptr; + + static { + try { + System.loadLibrary("clearsilver-jni"); + } catch ( UnsatisfiedLinkError e ) { + System.out.println("Could not load neo_cgi.so"); + System.exit(1); + } + } + + public CGI() { + _cgiptr = _init(); + } + + private static native int _init(); + private static native void parse(); +}; diff -Nru clearsilver-0.7.1/java-jni/CS.java clearsilver-0.7.2/java-jni/CS.java --- clearsilver-0.7.1/java-jni/CS.java Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/java-jni/CS.java Fri Sep 20 15:13:08 2002 @@ -0,0 +1,42 @@ +package org.clearsilver; + +import java.io.*; +import java.util.*; + +public class CS { + public int csptr; + + static { + try { + System.loadLibrary("clearsilver-jni"); + } catch ( UnsatisfiedLinkError e ) { + System.out.println("Could not load library 'clearsilver-jni'"); + System.exit(1); + } + } + + public CS(HDF ho) { + csptr = _init(ho.hdfptr); + } + public void finalize() { + _dealloc(csptr); + } + + public void parseFile(String filename) { + _parseFile(csptr,filename); + } + + public void parseStr(String content) { + _parseStr(csptr,content); + } + + public String render() { + return _render(csptr); + } + + private native int _init(int ptr); + private native void _dealloc(int ptr); + private native void _parseFile(int ptr,String filename); + private native void _parseStr(int ptr, String content); + private native String _render(int ptr); +}; diff -Nru clearsilver-0.7.1/java-jni/CSTest.java clearsilver-0.7.2/java-jni/CSTest.java --- clearsilver-0.7.1/java-jni/CSTest.java Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/java-jni/CSTest.java Thu Sep 19 22:55:30 2002 @@ -0,0 +1,29 @@ + +import java.io.*; +import java.util.*; + +class CSTest { + + public static void main( String [] args ) throws IOException { + org.clearsilver.HDF hdf = new org.clearsilver.HDF(); + System.out.print("hdfptr: "); + + System.out.println( hdf.hdfptr ); + + hdf.setValue("Foo.Bar","10"); + hdf.setValue("Foo.Baz","20"); + System.out.println( hdf.dump() ); + + System.out.println( "----" ); + + org.clearsilver.CS cs = new org.clearsilver.CS(hdf); + + String tmplstr = "Foo.Bar:\nFoo.Baz:\n"; + System.out.println(tmplstr); + System.out.println("----"); + + cs.parseStr(tmplstr); + System.out.println(cs.render()); + + } +}; diff -Nru clearsilver-0.7.1/java-jni/HDF.java clearsilver-0.7.2/java-jni/HDF.java --- clearsilver-0.7.1/java-jni/HDF.java Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/java-jni/HDF.java Fri Sep 20 15:13:08 2002 @@ -0,0 +1,46 @@ +package org.clearsilver; + +import java.io.*; +import java.util.*; + +public class HDF { + public int hdfptr; + + static { + try { + System.loadLibrary("clearsilver-jni"); + } catch ( UnsatisfiedLinkError e ) { + System.out.println("Could not load 'clearsilver-jni'"); + System.exit(1); + } + } + + public HDF() { + hdfptr = _init(); + } + public void finalize() { + _dealloc(hdfptr); + } + + public int getIntValue(String hdfname, int default_value) { + return _getIntValue(hdfptr,hdfname,default_value); + } + + public String getValue(String hdfname, String default_value) { + return _getValue(hdfptr,hdfname,default_value); + } + + public void setValue(String hdfname, String value) { + _setValue(hdfptr,hdfname,value); + } + public String dump() { + return _dump(hdfptr); + } + + private native int _init(); + private native void _dealloc(int ptr); + private native int _getIntValue(int ptr, String hdfname,int default_value); + private native String _getValue(int ptr, String hdfname, String default_value); + private native void _setValue(int ptr, String hdfname, String hdf_value); + private native String _dump(int ptr); +}; diff -Nru clearsilver-0.7.1/java-jni/Makefile clearsilver-0.7.2/java-jni/Makefile --- clearsilver-0.7.1/java-jni/Makefile Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/java-jni/Makefile Thu Oct 17 13:54:25 2002 @@ -0,0 +1,67 @@ + +.SUFFIXES: .java .class + +ifeq ($(NEOTONIC_ROOT),) +NEOTONIC_ROOT = ../ +endif + +include $(NEOTONIC_ROOT)rules.mk + +NEO_UTIL_SO = libclearsilver-jni.so +NEO_UTIL_JAVA_SRC = HDF.java CS.java # CGI.java +NEO_UTIL_JAVA_CLASS = $(NEO_UTIL_JAVA_SRC:%.java=%) +NEO_UTIL_JAVA_CLASSFILES = $(NEO_UTIL_JAVA_SRC:%.java=%.class) +NEO_UTIL_JAVA_JAR = clearsilver.jar +NEO_UTIL_SRC = j_neo_util.c j_neo_cs.c +NEO_UTIL_OBJ = $(NEO_UTIL_SRC:%.c=%.o) + + +CWD = /home/jeske/neotonic/java-jni + +ifeq ($(JAVA_INC),) +JAVA_INC = -I/usr/java/j2sdk1.4.1/include/ -I/usr/java/j2sdk1.4.1/include/linux +endif + +CFLAGS += -I$(NEOTONIC_ROOT) $(JAVA_INC) +DLIBS += -lneo_cgi -lneo_cs -lneo_utl +LIBS += -L$(LIB_DIR) $(DLIBS) + +TARGETS = $(NEO_UTIL_SO) + +all: $(TARGETS) test + +$(NEO_UTIL_JAVA_JAR): $(NEO_UTIL_JAVA_SRC) + $(JAVAC) $(NEO_UTIL_JAVA_SRC) + $(MKDIR) org/clearsilver + cp $(NEO_UTIL_JAVA_CLASSFILES) org/clearsilver + $(JAR) cf $(NEO_UTIL_JAVA_JAR) org + $(RM) -r org + +org_clearsilver_HDF.h: $(NEO_UTIL_JAVA_JAR) + $(JAVAH) -classpath $(NEO_UTIL_JAVA_JAR) -jni org.clearsilver.HDF + +org_clearsilver_CS.h: $(NEO_UTIL_JAVA_JAR) + $(JAVAH) -classpath $(NEO_UTIL_JAVA_JAR) -jni org.clearsilver.CS + +CSTest.class: CSTest.java + $(JAVAC) -classpath $(NEO_UTIL_JAVA_JAR) CSTest.java + +test: CSTest.class + /bin/sh -c "LD_LIBRARY_PATH=$(NEOTONIC_ROOT)/java-jni; export LD_LIBRARY_PATH; CLASSPATH=$(NEO_UTIL_JAVA_JAR):.; export CLASSPATH; java CSTest" + +CGI.h: CGI.class + $(JAVAH) -jni CGI + +$(NEO_UTIL_SO): $(NEO_UTIL_JAVA_JAR) $(NEO_UTIL_OBJ) $(DEP_LIBS) + $(LDSHARED) -o $@ $(LDFLAGS) $(NEO_UTIL_OBJ) $(LIBS) + +clean: + $(RM) *.o *.so + $(RM) -r org + $(RM) org_clearsilver_*.h + $(RM) *.class + $(RM) org_clearsilver_HDF.h org_clearsilver_CS.h + $(RM) Makefile.depends + +distclean: clean + $(RM) -f Makefile.depends $(TARGETS) diff -Nru clearsilver-0.7.1/java-jni/README.txt clearsilver-0.7.2/java-jni/README.txt --- clearsilver-0.7.1/java-jni/README.txt Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/java-jni/README.txt Fri Sep 20 15:13:08 2002 @@ -0,0 +1,40 @@ +---------------------------------- +Clearsilver JavaJNI wrapper +by David Jeske +Distributed under the Neotonic ClearSilver License +---------------------------------- + +This is a Java Native Interface (JNI) wrapper for the ClearSilver +templating library. The files in this directory build into both +a clearsilver.jar file with Java classes, and a native library +libclearsilver-jni.so. + +BUILDING + +After building clearsilver, just type "make" twice. The first +time you build it builds the depend, and throw some random error, +I don't know why. + +INSTALLING + +You must put the native library into a standard library location +(i.e. like /lib), or make sure that Java can find it by using +the java command line directive: + + -Djava.library.path=/somewhere/else + +Then you must put the clearsilver.jar file into your java +CLASSPATH. + +USING + +See the example CSTest.java for an example of how to import +and use the clearsilver objects. + +USING in a servlet + +Since the most common usage of Clearsilver is in a servlet, +we've provided some examples of how to use it in the servlet/ +directory. + + diff -Nru clearsilver-0.7.1/java-jni/j_neo_cgi.c clearsilver-0.7.2/java-jni/j_neo_cgi.c --- clearsilver-0.7.1/java-jni/j_neo_cgi.c Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/java-jni/j_neo_cgi.c Thu Sep 19 22:55:30 2002 @@ -0,0 +1,39 @@ +#include +#include "CGI.h" + +#include "util/neo_err.h" +#include "util/neo_misc.h" +#include "util/neo_str.h" +#include "util/neo_hdf.h" +#include "cgi/cgi.h" +#include "cgi/cgiwrap.h" +#include "cgi/date.h" +#include "cgi/html.h" + + +jfieldID _cgiobjFldID = NULL; + +JNIEXPORT jint JNICALL Java_CGI__1init + (JNIEnv *env, jobject obj) { + CGI *cgi = NULL; + NEOERR *err; + + if (!_cgiobjFldID) { + jclass objClass = (*env)->GetObjectClass(env,obj); + _cgiobjFldID = (*env)->GetFieldID(env,objClass,"_cgiobj","I"); + } + + err = cgi_init(&cgi,NULL); + if (err) { } // throw error + return (jint) cgi; + } + +JNIEXPORT void JNICALL Java_CGI_parse + (JNIEnv *env, jobject obj) { + CGI *cgi = (CGI *)((*env)->GetIntField(env,obj,_cgiobjFldID)); + + cgi_parse(cgi); + + +} + diff -Nru clearsilver-0.7.1/java-jni/j_neo_cs.c clearsilver-0.7.2/java-jni/j_neo_cs.c --- clearsilver-0.7.1/java-jni/j_neo_cs.c Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/java-jni/j_neo_cs.c Tue Sep 24 17:38:34 2002 @@ -0,0 +1,110 @@ +#include + +#include +#include "org_clearsilver_CS.h" + +#include "util/neo_err.h" +#include "util/neo_misc.h" +#include "util/neo_str.h" +#include "util/neo_hdf.h" +#include "cgi/cgi.h" +#include "cgi/cgiwrap.h" +#include "cgi/date.h" +#include "cgi/html.h" +#include "cs/cs.h" + + +jfieldID _csobjFldID = NULL; + +JNIEXPORT jint JNICALL Java_org_clearsilver_CS__1init + (JNIEnv *env, jobject obj, jint hdf_obj_ptr) { + HDF *hdf = (HDF *)hdf_obj_ptr; + CSPARSE *cs = NULL; + NEOERR *err; + + // if (!_hdfobjFldID) { + // jclass objClass = (*env)->GetObjectClass(env,obj); + // _hdfobjFldID = (*env)->GetFieldID(env,objClass,"hdfptr","i"); + // } + + err = cs_init(&cs,hdf); + if (err) { } // throw error + return (jint) cs; +} + +JNIEXPORT void JNICALL Java_org_clearsilver_CS__1dealloc +(JNIEnv *env, jclass objClass, jint cs_obj_ptr) { + CSPARSE *cs = (CSPARSE *)cs_obj_ptr; + cs_destroy(&cs); +} + + +JNIEXPORT void JNICALL Java_org_clearsilver_CS__1parseFile + (JNIEnv *env, jclass objClass, jint cs_obj_ptr, + jstring j_filename) { + + CSPARSE *cs = (CSPARSE *)cs_obj_ptr; + NEOERR *err; + const char *filename; + + if (!j_filename) { return; } // throw + + filename = (*env)->GetStringUTFChars(env,j_filename,0); + + err = cs_parse_file(cs,(char *)filename); + if (err) {} // throw error + + (*env)->ReleaseStringUTFChars(env,j_filename,filename); + +} + +JNIEXPORT void JNICALL Java_org_clearsilver_CS__1parseStr +(JNIEnv *env, jclass objClass, jint cs_obj_ptr, + jstring j_contentstring) { + + CSPARSE *cs = (CSPARSE *)cs_obj_ptr; + NEOERR *err; + char *ms; + int len; + const char *contentstring; + + if (!j_contentstring) { return; } // throw + + contentstring = (*env)->GetStringUTFChars(env,j_contentstring,0); + + ms = strdup(contentstring); + if (ms == NULL) {} // throw error no memory + len = strlen(ms); + + err = cs_parse_string(cs,ms,len); + if (err) {} // throw error + + (*env)->ReleaseStringUTFChars(env,j_contentstring,contentstring); + +} + +static NEOERR *render_cb (void *ctx, char *buf) +{ + STRING *str= (STRING *)ctx; + + return nerr_pass(string_append(str, buf)); +} + + +JNIEXPORT jstring JNICALL Java_org_clearsilver_CS__1render +(JNIEnv *env, jclass objClass, jint cs_obj_ptr) { + CSPARSE *cs = (CSPARSE *)cs_obj_ptr; + STRING str; + NEOERR *err; + jstring retval; + + string_init(&str); + err = cs_render(cs,&str,render_cb); + if (err) {} // throw error + + retval = (*env)->NewStringUTF(env,str.buf); + string_clear(&str); + + return retval; + +} diff -Nru clearsilver-0.7.1/java-jni/j_neo_util.c clearsilver-0.7.2/java-jni/j_neo_util.c --- clearsilver-0.7.1/java-jni/j_neo_util.c Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/java-jni/j_neo_util.c Tue Sep 24 17:38:34 2002 @@ -0,0 +1,113 @@ +#include +#include "org_clearsilver_HDF.h" + +#include "util/neo_err.h" +#include "util/neo_misc.h" +#include "util/neo_str.h" +#include "util/neo_hdf.h" +#include "cgi/cgi.h" +#include "cgi/cgiwrap.h" +#include "cgi/date.h" +#include "cgi/html.h" + + +jfieldID _hdfobjFldID = NULL; + +JNIEXPORT jint JNICALL Java_org_clearsilver_HDF__1init + (JNIEnv *env, jobject obj) { + HDF *hdf = NULL; + NEOERR *err; + + // if (!_hdfobjFldID) { + // jclass objClass = (*env)->GetObjectClass(env,obj); + // _hdfobjFldID = (*env)->GetFieldID(env,objClass,"hdfptr","i"); + // } + + err = hdf_init(&hdf); + if (err) { } // throw error + return (jint) hdf; +} + +JNIEXPORT void JNICALL Java_org_clearsilver_HDF__1dealloc +(JNIEnv *env, jclass objClass, jint hdf_obj_ptr) { + HDF *hdf = (HDF *)hdf_obj_ptr; + hdf_destroy(&hdf); +} + +JNIEXPORT jint JNICALL Java_org_clearsilver_HDF__1getIntValue + (JNIEnv *env, jclass objClass, + jint hdf_obj_ptr, jstring j_hdfname, jint default_value) { + + HDF *hdf = (HDF *)hdf_obj_ptr; + int r; + const char *hdfname; + + if (!j_hdfname) { return 0; } // throw + + hdfname = (*env)->GetStringUTFChars(env,j_hdfname,0); + + r = hdf_get_int_value(hdf,(char *) hdfname,default_value); + + (*env)->ReleaseStringUTFChars(env,j_hdfname,hdfname); + return r; + +} + +JNIEXPORT jstring JNICALL Java_org_clearsilver_HDF__1getValue + (JNIEnv *env, jclass objClass, + jint hdf_obj_ptr, jstring j_hdfname, jstring j_default_value) { + + HDF *hdf = (HDF *)hdf_obj_ptr; + const char *r; + const char *hdfname; + const char *default_value; + + if (!j_hdfname || !j_default_value) { return 0; } // throw + + hdfname = (*env)->GetStringUTFChars(env,j_hdfname,0); + default_value = (*env)->GetStringUTFChars(env,j_default_value,0); + + r = hdf_get_value(hdf,(char *)hdfname,(char *)default_value); + + (*env)->ReleaseStringUTFChars(env,j_hdfname,hdfname); + return (r ? 0 : (*env)->NewStringUTF(env,r)); +} + + + +JNIEXPORT void JNICALL Java_org_clearsilver_HDF__1setValue + (JNIEnv *env, jclass objClass, + jint hdf_obj_ptr, jstring j_hdfname, jstring j_value) { + HDF *hdf = (HDF *)hdf_obj_ptr; + NEOERR *err; + const char *hdfname; + const char *value; + + if (!j_hdfname || !j_value) { return; } + + hdfname = (*env)->GetStringUTFChars(env,j_hdfname,0); + value = (*env)->GetStringUTFChars(env,j_value,0); + + err = hdf_set_value(hdf, (char *)hdfname,(char *)value); + + (*env)->ReleaseStringUTFChars(env, j_hdfname, hdfname); + (*env)->ReleaseStringUTFChars(env, j_value, value); + +} + +JNIEXPORT jstring JNICALL Java_org_clearsilver_HDF__1dump + (JNIEnv *env, jclass objClass, + jint hdf_obj_ptr) { + HDF *hdf = (HDF *)hdf_obj_ptr; + NEOERR *err; + STRING str; + jstring retval; + + string_init(&str); + err = hdf_dump_str(hdf, NULL, 0, &str); + if (err) {} // throw exception + retval = (*env)->NewStringUTF(env,str.buf); + string_clear(&str); + + return retval; +} diff -Nru clearsilver-0.7.1/java-jni/servlet/CSPage.java clearsilver-0.7.2/java-jni/servlet/CSPage.java --- clearsilver-0.7.1/java-jni/servlet/CSPage.java Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/java-jni/servlet/CSPage.java Fri Sep 20 16:14:10 2002 @@ -0,0 +1,123 @@ +/* $Id: CSPage.java,v 1.1 2002/09/20 23:14:10 jeske Exp $ + * + */ + +import java.io.*; +import java.text.*; +import java.util.*; +import javax.servlet.*; +import javax.servlet.http.*; + +import java.lang.String.*; + +import org.clearsilver.*; + +/** + * The simplest possible servlet. + * + */ + +public class CSPage extends HttpServlet { + public HDF hdf; + public CS cs; + public boolean page_debug = true; + + public void doGet(HttpServletRequest request, + HttpServletResponse response) + throws IOException, ServletException + { + + + PrintWriter out = response.getWriter(); + hdf = new HDF(); + cs = new CS(hdf); + + // HTTP headers + Enumeration e = request.getHeaderNames(); + while (e.hasMoreElements()) { + String headerName = (String)e.nextElement(); + String headerValue = request.getHeader(headerName); + hdf.setValue("HTTP." + headerName,headerValue); + } + + + hdf.setValue("HTTP.PATH_INFO",request.getPathInfo()); + hdf.setValue("CGI.QueryString",request.getQueryString()); + hdf.setValue("CGI.RequestMethod",request.getMethod()); + + // Querystring paramaters + e = request.getParameterNames(); + while (e.hasMoreElements()) { + String paramName = (String)e.nextElement(); + String paramValue = request.getParameter(paramName); + hdf.setValue("Query." + paramName,paramValue); + } + + + // Cookies + + Cookie[] cookies = request.getCookies(); + if (cookies.length > 0) { + for (int i = 0; i < cookies.length; i++) { + Cookie cookie = cookies[i]; + hdf.setValue("Cookie." + cookie.getName(),cookie.getValue()); + } + } + + // CGI example + // check for Actions + + + // then call display method + this.display(); + + // run required page template through CS + // cs.parseFile(a_template_file); + + // Page Output + + + /* first do cookies + + String cookieName = request.getParameter("cookiename"); + String cookieValue = request.getParameter("cookievalue"); + if (cookieName != null && cookieValue != null) { + Cookie cookie = new Cookie(cookieName, cookieValue); + response.addCookie(cookie); + out.println("

"); + out.println(rb.getString("cookies.set") + "
"); + out.print(rb.getString("cookies.name") + " " + cookieName + + "
"); + out.print(rb.getString("cookies.value") + " " + cookieValue); + } + + */ + + response.setContentType("text/html"); + out.print(cs.render()); + + + // debug + if (page_debug) { + out.print("


");
+	  out.print(hdf.dump());
+	  out.print("
"); + } + + } + + public void doPost(HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + doGet(request, response); + } + + public void display() { + hdf.setValue("Foo.Bar","1"); + cs.parseStr("Hello Clearsilver

Foo.Bar
"); + } + + +} + + + diff -Nru clearsilver-0.7.1/java-jni/servlet/HelloCSServlet.java clearsilver-0.7.2/java-jni/servlet/HelloCSServlet.java --- clearsilver-0.7.1/java-jni/servlet/HelloCSServlet.java Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/java-jni/servlet/HelloCSServlet.java Fri Sep 20 15:13:08 2002 @@ -0,0 +1,42 @@ +/* $Id: HelloCSServlet.java,v 1.1 2002/09/20 22:13:08 jeske Exp $ + * + */ + +import java.io.*; +import java.text.*; +import java.util.*; +import javax.servlet.*; +import javax.servlet.http.*; + +import org.clearsilver.*; + +/** + * The simplest possible Clearsilver servlet. + * + */ + +public class HelloCSServlet extends HttpServlet { + + public void doGet(HttpServletRequest request, + HttpServletResponse response) + throws IOException, ServletException + { + + + PrintWriter out = response.getWriter(); + HDF hdf = new HDF(); + + hdf.setValue("Foo.Bar","1"); + + CS cs = new CS(hdf); + cs.parseStr("Hello Clearsilver

Foo.Bar: "); + + + + response.setContentType("text/html"); + out.print(cs.render()); + } +} + + + diff -Nru clearsilver-0.7.1/perl/Changes clearsilver-0.7.2/perl/Changes --- clearsilver-0.7.1/perl/Changes Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/perl/Changes Thu Oct 17 13:53:21 2002 @@ -0,0 +1,10 @@ +Revision history for Perl extension ClearSilver. + +0.02 Mon Sep 2 + - Added sortObj() method to HDF class. + - Filled in README. + +0.01 Wed Aug 14 17:10:52 2002 + - original version; created by h2xs 1.21 with options + -A -n ClearSilver + diff -Nru clearsilver-0.7.1/perl/ClearSilver.pm clearsilver-0.7.2/perl/ClearSilver.pm --- clearsilver-0.7.1/perl/ClearSilver.pm Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/perl/ClearSilver.pm Thu Oct 17 13:53:21 2002 @@ -0,0 +1,68 @@ +package ClearSilver; + +use 5.006; +use strict; +use warnings; + +require Exporter; +require DynaLoader; + +our @ISA = qw(Exporter DynaLoader); + +# Items to export into callers namespace by default. Note: do not export +# names by default without a very good reason. Use EXPORT_OK instead. +# Do not simply export all your public functions/methods/constants. + +# This allows declaration use ClearSilver ':all'; +# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK +# will save memory. +our %EXPORT_TAGS = ( 'all' => [ qw( + +) ] ); + +our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); + +our @EXPORT = qw( + +); +our $VERSION = '0.01'; + +bootstrap ClearSilver $VERSION; + +# Preloaded methods go here. + +1; +__END__ +# Below is stub documentation for your module. You better edit it! + +=head1 NAME + +ClearSilver - Perl extension for blah blah blah + +=head1 SYNOPSIS + + use ClearSilver; + blah blah blah + +=head1 DESCRIPTION + +Stub documentation for ClearSilver, created by h2xs. It looks like the +author of the extension was negligent enough to leave the stub +unedited. + +Blah blah blah. + +=head2 EXPORT + +None by default. + + +=head1 AUTHOR + +A. U. Thor, Ea.u.thor@a.galaxy.far.far.awayE + +=head1 SEE ALSO + +L. + +=cut diff -Nru clearsilver-0.7.1/perl/ClearSilver.xs clearsilver-0.7.2/perl/ClearSilver.xs --- clearsilver-0.7.1/perl/ClearSilver.xs Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/perl/ClearSilver.xs Thu Oct 17 13:53:21 2002 @@ -0,0 +1,402 @@ +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +#include +#include + +/* #define DEBUG_MODE 1 + */ + +typedef struct { + HDF* hdf; + NEOERR* err; +} perlHDF; + +typedef struct { + CSPARSE* cs; + NEOERR* err; +} perlCS; + +typedef perlHDF* ClearSilver__HDF; +typedef perlCS* ClearSilver__CS; + +static char* g_sort_func_name; + +static void debug(char* fmt, ...) +{ +#ifdef DEBUG_MODE + va_list argp; + va_start(argp, fmt); + vprintf(fmt, argp); + va_end(argp); +#endif +} + +static NEOERR *output (void *ctx, char *s) +{ + NEOERR* err; + STRING* str_p = (STRING*)ctx; + err = string_append(str_p, s); + return err; +} + +static int sortFunction(const void* in_a, const void* in_b) +{ + HDF** hdf_a; + HDF** hdf_b; + perlHDF a, b; + SV* sv_a; + SV* sv_b; + int count; + int ret; + + dSP; + + hdf_a = (HDF**)in_a; + hdf_b = (HDF**)in_b; + + /* convert to a type Perl can access */ + a.hdf = *hdf_a; + a.err = STATUS_OK; + b.hdf = *hdf_b; + b.err = STATUS_OK; + + ENTER; + SAVETMPS; + + PUSHMARK(SP); + sv_a = sv_newmortal(); + sv_setref_pv(sv_a, "ClearSilver::HDF", (void*)&a); + + sv_b = sv_newmortal(); + sv_setref_pv(sv_b, "ClearSilver::HDF", (void*)&b); + + XPUSHs(sv_a); + XPUSHs(sv_b); + + PUTBACK; + + count = call_pv(g_sort_func_name, G_SCALAR); + + SPAGAIN; + + if (count != 1) + croak("Big trouble\n"); + + PUTBACK; + + ret = POPi; + + FREETMPS; + LEAVE; + + return ret; +} + + + + + +MODULE = ClearSilver PACKAGE = ClearSilver::HDF PREFIX = perlhdf_ + +ClearSilver::HDF +perlhdf_new(self) + char* self + PREINIT: + ClearSilver__HDF hdf; + CODE: + debug("%s\n", self); + hdf = (ClearSilver__HDF)malloc(sizeof(perlHDF)); + if (!hdf) { + RETVAL = NULL; + } else { + hdf->err = hdf_init(&(hdf->hdf)); + RETVAL = hdf; + } + OUTPUT: + RETVAL + +void +perlhdf_DESTROY(hdf) + ClearSilver::HDF hdf; + CODE: + debug("hdf_DESTROY:%x\n", hdf); + hdf_destroy(&(hdf->hdf)); + + +int +perlhdf_setValue(hdf, key, value) + ClearSilver::HDF hdf + char* key + char* value + CODE: + hdf->err = hdf_set_value(hdf->hdf, key, value); + if (hdf->err == STATUS_OK) { + RETVAL = 0; + } else { + RETVAL = 1; + } + OUTPUT: + RETVAL + + +char* +perlhdf_getValue(hdf, key, default_value) + ClearSilver::HDF hdf + char* key + char* default_value + CODE: + RETVAL = hdf_get_value(hdf->hdf, key, default_value); + OUTPUT: + RETVAL + +int +perlhdf_readFile(hdf, filename) + ClearSilver::HDF hdf + char* filename + CODE: + hdf->err = hdf_read_file(hdf->hdf, filename); + if (hdf->err == STATUS_OK) { + RETVAL = 1; + } else { + RETVAL = 0; + } + OUTPUT: + RETVAL + +ClearSilver::HDF +perlhdf_getObj(hdf, name) + ClearSilver::HDF hdf; + char* name + PREINIT: + HDF* tmp_hdf; + perlHDF* perlhdf; + CODE: + do { + tmp_hdf = hdf_get_obj(hdf->hdf, name); + if (!tmp_hdf) { + RETVAL = NULL; + break; + } + perlhdf = (perlHDF*)malloc(sizeof(perlHDF)); + if (!perlhdf) { + RETVAL = NULL; + break; + } + perlhdf->hdf = tmp_hdf; + perlhdf->err = STATUS_OK; + RETVAL = perlhdf; + } while (0); + OUTPUT: + RETVAL + +ClearSilver::HDF +perlhdf_objChild(hdf) + ClearSilver::HDF hdf; + PREINIT: + HDF* tmp_hdf; + perlHDF* child; + CODE: + do { + tmp_hdf = hdf_obj_child(hdf->hdf); + if (!tmp_hdf) { + RETVAL = NULL; + break; + } + child = (perlHDF*)malloc(sizeof(perlHDF)); + if (!child) { + RETVAL = NULL; + break; + } + child->hdf = tmp_hdf; + child->err = STATUS_OK; + RETVAL = child; + } while (0); + OUTPUT: + RETVAL + + +ClearSilver::HDF +perlhdf_getChild(hdf, name) + ClearSilver::HDF hdf; + char* name; + PREINIT: + HDF* tmp_hdf; + perlHDF* child; + CODE: + do { + tmp_hdf = hdf_get_child(hdf->hdf, name); + if (!tmp_hdf) { + RETVAL = NULL; + break; + } + child = (perlHDF*)malloc(sizeof(perlHDF)); + if (!child) { + RETVAL = NULL; + break; + } + child->hdf = tmp_hdf; + child->err = STATUS_OK; + RETVAL = child; + } while (0); + OUTPUT: + RETVAL + +char* +perlhdf_objValue(hdf) + ClearSilver::HDF hdf; + CODE: + RETVAL = hdf_obj_value(hdf->hdf); + OUTPUT: + RETVAL + +char* +perlhdf_objName(hdf) + ClearSilver::HDF hdf; + CODE: + RETVAL = hdf_obj_name(hdf->hdf); + OUTPUT: + RETVAL + +ClearSilver::HDF +perlhdf_objNext(hdf) + ClearSilver::HDF hdf; + PREINIT: + HDF* tmp_hdf; + perlHDF* next; + CODE: + do { + tmp_hdf = hdf_obj_next(hdf->hdf); + if (!tmp_hdf) { + RETVAL = NULL; + break; + } + next = (perlHDF*)malloc(sizeof(perlHDF)); + if (!next) { + RETVAL = NULL; + break; + } + next->hdf = tmp_hdf; + next->err = STATUS_OK; + RETVAL = next; + } while (0); + OUTPUT: + RETVAL + +int +perlhdf_sortObj(hdf, func_name) + ClearSilver::HDF hdf; + char* func_name; + PREINIT: + NEOERR* err; + CODE: + g_sort_func_name = func_name; + err = hdf_sort_obj(hdf->hdf, sortFunction); + RETVAL = 0; + OUTPUT: + RETVAL + + + + +MODULE = ClearSilver PACKAGE = ClearSilver::CS PREFIX = perlcs_ + +ClearSilver::CS +perlcs_new(self, hdf) + char* self + ClearSilver::HDF hdf; + PREINIT: + perlCS* cs; + CODE: + cs = (perlCS*)malloc(sizeof(perlCS)); + if (!cs) { + RETVAL = NULL; + } else { + cs->err = cs_init(&(cs->cs), hdf->hdf); + RETVAL = cs; + } + OUTPUT: + RETVAL + +void +perlcs_DESTROY(cs) + ClearSilver::CS cs; + CODE: + debug("perlcs_DESTROY() is called\n"); + cs_destroy(&(cs->cs)); + +void +perlcs_displayError(cs) + ClearSilver::CS cs; + CODE: + nerr_log_error(cs->err); + +char * +perlcs_render(cs) + ClearSilver::CS cs + PREINIT: + STRING str; + CODE: + string_init(&str); + + cs->err = cs_render(cs->cs, &str, output); + do { + if (cs->err != STATUS_OK) { + RETVAL = NULL; + break; + } + RETVAL = (char*)malloc(str.len + 1); + if (! RETVAL) { + break; + } + strncpy(RETVAL, str.buf, str.len); + *(RETVAL + str.len) = '\0'; + string_clear (&str); + } while (0); + OUTPUT: + RETVAL + +int +perlcs_parseFile(cs, cs_file) + ClearSilver::CS cs + char* cs_file + CODE: + do { + cs->err = cs_parse_file(cs->cs, cs_file); + if (cs->err != STATUS_OK) { + cs->err = nerr_pass(cs->err); + RETVAL = 0; + break; + } + RETVAL = 1; + } while (0); + OUTPUT: + RETVAL + +int +perlcs_parseString(cs, in_str) + ClearSilver::CS cs + char* in_str + PREINIT: + char* cs_str; + int len; + CODE: + do { + len = strlen(in_str); + cs_str = (char *)malloc(len); + if (!cs_str) { + RETVAL = 0; + break; + } + strcpy(cs_str, in_str); + cs->err = cs_parse_string(cs->cs, cs_str, len); + if (cs->err != STATUS_OK) + RETVAL = 0; + RETVAL = 1; + } while (0); + OUTPUT: + RETVAL + + + diff -Nru clearsilver-0.7.1/perl/MANIFEST clearsilver-0.7.2/perl/MANIFEST --- clearsilver-0.7.1/perl/MANIFEST Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/perl/MANIFEST Thu Oct 17 13:53:21 2002 @@ -0,0 +1,11 @@ +Changes +ClearSilver.pm +ClearSilver.xs +typemap +Makefile.PL +MANIFEST +README +test.pl +test.hdf +test.gold + diff -Nru clearsilver-0.7.1/perl/Makefile.PL clearsilver-0.7.2/perl/Makefile.PL --- clearsilver-0.7.1/perl/Makefile.PL Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/perl/Makefile.PL Thu Oct 17 13:53:21 2002 @@ -0,0 +1,17 @@ +use ExtUtils::MakeMaker; +# See lib/ExtUtils/MakeMaker.pm for details of how to influence +# the contents of the Makefile that is written. +WriteMakefile( + 'NAME' => 'ClearSilver', + 'VERSION_FROM' => 'ClearSilver.pm', # finds $VERSION + 'PREREQ_PM' => {}, # e.g., Module::Name => 1.1 + ($] >= 5.005 ? ## Add these new keywords supported since 5.005 + (ABSTRACT_FROM => 'ClearSilver.pm', # retrieve abstract from module + AUTHOR => 'A. U. Thor ') : ()), + 'LIBS' => ['-L../libs -lneo_cs -lneo_utl'], + 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING' + # Insert -I. if you add *.h files later: + 'INC' => '-I../', + # Un-comment this if you add C files to link with later: + # 'OBJECT' => '$(O_FILES)', # link all the C files too +); diff -Nru clearsilver-0.7.1/perl/Makefile.old clearsilver-0.7.2/perl/Makefile.old --- clearsilver-0.7.1/perl/Makefile.old Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/perl/Makefile.old Thu Oct 17 13:53:21 2002 @@ -0,0 +1,814 @@ +# This Makefile is for the ClearSilver extension to perl. +# +# It was generated automatically by MakeMaker version +# 5.45 (Revision: 1.222) from the contents of +# Makefile.PL. Don't edit this file, edit Makefile.PL instead. +# +# ANY CHANGES MADE HERE WILL BE LOST! +# +# MakeMaker ARGV: () +# +# MakeMaker Parameters: + +# ABSTRACT_FROM => q[ClearSilver.pm] +# AUTHOR => q[A. U. Thor ] +# DEFINE => q[] +# INC => q[-I../] +# LIBS => [q[-L../libs -lneo_cs -lneo_utl]] +# NAME => q[ClearSilver] +# PREREQ_PM => { } +# VERSION_FROM => q[ClearSilver.pm] + +# --- MakeMaker post_initialize section: + + +# --- MakeMaker const_config section: + +# These definitions are from config.sh (via /usr/lib/perl5/5.6.0/i386-linux/Config.pm) + +# They may have been overridden via Makefile.PL or on the command line +AR = ar +CC = gcc +CCCDLFLAGS = -fPIC +CCDLFLAGS = -rdynamic +DLEXT = so +DLSRC = dl_dlopen.xs +LD = gcc +LDDLFLAGS = -shared -L/usr/local/lib +LDFLAGS = -L/usr/local/lib +LIBC = /lib/libc-2.2.2.so +LIB_EXT = .a +OBJ_EXT = .o +OSNAME = linux +OSVERS = 2.2.17-8smp +RANLIB = : +SO = so +EXE_EXT = +FULL_AR = /usr/bin/ar + + +# --- MakeMaker constants section: +AR_STATIC_ARGS = cr +NAME = ClearSilver +DISTNAME = ClearSilver +NAME_SYM = ClearSilver +VERSION = 0.01 +VERSION_SYM = 0_01 +XS_VERSION = 0.01 +INST_BIN = blib/bin +INST_EXE = blib/script +INST_LIB = blib/lib +INST_ARCHLIB = blib/arch +INST_SCRIPT = blib/script +PREFIX = /usr +INSTALLDIRS = site +INSTALLPRIVLIB = $(PREFIX)/lib/perl5/5.6.0 +INSTALLARCHLIB = $(PREFIX)/lib/perl5/5.6.0/i386-linux +INSTALLSITELIB = $(PREFIX)/lib/perl5/site_perl/5.6.0 +INSTALLSITEARCH = $(PREFIX)/lib/perl5/site_perl/5.6.0/i386-linux +INSTALLBIN = $(PREFIX)/bin +INSTALLSCRIPT = $(PREFIX)/bin +PERL_LIB = /usr/lib/perl5/5.6.0 +PERL_ARCHLIB = /usr/lib/perl5/5.6.0/i386-linux +SITELIBEXP = /usr/lib/perl5/site_perl/5.6.0 +SITEARCHEXP = /usr/lib/perl5/site_perl/5.6.0/i386-linux +LIBPERL_A = libperl.a +FIRST_MAKEFILE = Makefile +MAKE_APERL_FILE = Makefile.aperl +PERLMAINCC = $(CC) +PERL_INC = /usr/lib/perl5/5.6.0/i386-linux/CORE +PERL = /usr/bin/perl +FULLPERL = /usr/bin/perl +FULL_AR = /usr/bin/ar + +VERSION_MACRO = VERSION +DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\" +XS_VERSION_MACRO = XS_VERSION +XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\" +PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc + +MAKEMAKER = /usr/lib/perl5/5.6.0/ExtUtils/MakeMaker.pm +MM_VERSION = 5.45 + +# FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle). +# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle) +# ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD) !!! Deprecated from MM 5.32 !!! +# PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar) +# DLBASE = Basename part of dynamic library. May be just equal BASEEXT. +FULLEXT = ClearSilver +BASEEXT = ClearSilver +DLBASE = $(BASEEXT) +VERSION_FROM = ClearSilver.pm +INC = -I../ +DEFINE = +OBJECT = $(BASEEXT)$(OBJ_EXT) +LDFROM = $(OBJECT) +LINKTYPE = dynamic + +# Handy lists of source code files: +XS_FILES= ClearSilver.xs +C_FILES = ClearSilver.c +O_FILES = ClearSilver.o +H_FILES = +HTMLLIBPODS = +HTMLSCRIPTPODS = +MAN1PODS = +MAN3PODS = ClearSilver.pm +HTMLEXT = html +INST_MAN1DIR = blib/man1 +INSTALLMAN1DIR = $(PREFIX)/share/man/man1 +MAN1EXT = 1 +INST_MAN3DIR = blib/man3 +INSTALLMAN3DIR = $(PREFIX)/share/man/man3 +MAN3EXT = 3pm +PERM_RW = 644 +PERM_RWX = 755 + +# work around a famous dec-osf make(1) feature(?): +makemakerdflt: all + +.SUFFIXES: .xs .c .C .cpp .cxx .cc $(OBJ_EXT) + +# Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to recall, that +# some make implementations will delete the Makefile when we rebuild it. Because +# we call false(1) when we rebuild it. So make(1) is not completely wrong when it +# does so. Our milage may vary. +# .PRECIOUS: Makefile # seems to be not necessary anymore + +.PHONY: all config static dynamic test linkext manifest + +# Where is the Config information that we are using/depend on +CONFIGDEP = $(PERL_ARCHLIB)/Config.pm $(PERL_INC)/config.h + +# Where to put things: +INST_LIBDIR = $(INST_LIB) +INST_ARCHLIBDIR = $(INST_ARCHLIB) + +INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT) +INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT) + +INST_STATIC = $(INST_ARCHAUTODIR)/$(BASEEXT)$(LIB_EXT) +INST_DYNAMIC = $(INST_ARCHAUTODIR)/$(DLBASE).$(DLEXT) +INST_BOOT = $(INST_ARCHAUTODIR)/$(BASEEXT).bs + +EXPORT_LIST = + +PERL_ARCHIVE = + +TO_INST_PM = ClearSilver.pm + +PM_TO_BLIB = ClearSilver.pm \ + $(INST_LIBDIR)/ClearSilver.pm + + +# --- MakeMaker tool_autosplit section: + +# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto +AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e 'use AutoSplit;autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1) ;' + + +# --- MakeMaker tool_xsubpp section: + +XSUBPPDIR = /usr/lib/perl5/5.6.0/ExtUtils +XSUBPP = $(XSUBPPDIR)/xsubpp +XSPROTOARG = +XSUBPPDEPS = $(XSUBPPDIR)/typemap typemap $(XSUBPP) +XSUBPPARGS = -typemap $(XSUBPPDIR)/typemap -typemap typemap + + +# --- MakeMaker tools_other section: + +SHELL = /bin/sh +CHMOD = chmod +CP = cp +LD = gcc +MV = mv +NOOP = $(SHELL) -c true +RM_F = rm -f +RM_RF = rm -rf +TEST_F = test -f +TOUCH = touch +UMASK_NULL = umask 0 +DEV_NULL = > /dev/null 2>&1 + +# The following is a portable way to say mkdir -p +# To see which directories are created, change the if 0 to if 1 +MKPATH = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e mkpath + +# This helps us to minimize the effect of the .exists files A yet +# better solution would be to have a stable file in the perl +# distribution with a timestamp of zero. But this solution doesn't +# need any changes to the core distribution and works with older perls +EQUALIZE_TIMESTAMP = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e eqtime + +# Here we warn users that an old packlist file was found somewhere, +# and that they should call some uninstall routine +WARN_IF_OLD_PACKLIST = $(PERL) -we 'exit unless -f $$ARGV[0];' \ +-e 'print "WARNING: I have found an old package in\n";' \ +-e 'print "\t$$ARGV[0].\n";' \ +-e 'print "Please make sure the two installations are not conflicting\n";' + +UNINST=0 +VERBINST=1 + +MOD_INSTALL = $(PERL) -I$(INST_LIB) -I$(PERL_LIB) -MExtUtils::Install \ +-e "install({@ARGV},'$(VERBINST)',0,'$(UNINST)');" + +DOC_INSTALL = $(PERL) -e '$$\="\n\n";' \ +-e 'print "=head2 ", scalar(localtime), ": C<", shift, ">", " L<", shift, ">";' \ +-e 'print "=over 4";' \ +-e 'while (defined($$key = shift) and defined($$val = shift)){print "=item *";print "C<$$key: $$val>";}' \ +-e 'print "=back";' + +UNINSTALL = $(PERL) -MExtUtils::Install \ +-e 'uninstall($$ARGV[0],1,1); print "\nUninstall is deprecated. Please check the";' \ +-e 'print " packlist above carefully.\n There may be errors. Remove the";' \ +-e 'print " appropriate files manually.\n Sorry for the inconveniences.\n"' + + +# --- MakeMaker dist section: + +DISTVNAME = $(DISTNAME)-$(VERSION) +TAR = tar +TARFLAGS = cvf +ZIP = zip +ZIPFLAGS = -r +COMPRESS = gzip --best +SUFFIX = .gz +SHAR = shar +PREOP = @$(NOOP) +POSTOP = @$(NOOP) +TO_UNIX = @$(NOOP) +CI = ci -u +RCS_LABEL = rcs -Nv$(VERSION_SYM): -q +DIST_CP = best +DIST_DEFAULT = tardist + + +# --- MakeMaker macro section: + + +# --- MakeMaker depend section: + + +# --- MakeMaker cflags section: + +CCFLAGS = -fno-strict-aliasing +OPTIMIZE = -O2 -march=i386 -mcpu=i686 +PERLTYPE = +LARGE = +SPLIT = +MPOLLUTE = + + +# --- MakeMaker const_loadlibs section: + +# ClearSilver might depend on some other libraries: +# See ExtUtils::Liblist for details +# +EXTRALIBS = -L/home/gaku/src/clearsilver-0.7.0/perl/../libs -lneo_cs -lneo_utl +LDLOADLIBS = -L/home/gaku/src/clearsilver-0.7.0/perl/../libs -lneo_cs -lneo_utl +BSLOADLIBS = +LD_RUN_PATH = /home/gaku/src/clearsilver-0.7.0/perl/../libs + + +# --- MakeMaker const_cccmd section: +CCCMD = $(CC) -c $(INC) $(CCFLAGS) $(OPTIMIZE) \ + $(PERLTYPE) $(LARGE) $(SPLIT) $(MPOLLUTE) $(DEFINE_VERSION) \ + $(XS_DEFINE_VERSION) + +# --- MakeMaker post_constants section: + + +# --- MakeMaker pasthru section: + +PASTHRU = LIB="$(LIB)"\ + LIBPERL_A="$(LIBPERL_A)"\ + LINKTYPE="$(LINKTYPE)"\ + PREFIX="$(PREFIX)"\ + OPTIMIZE="$(OPTIMIZE)" + + +# --- MakeMaker c_o section: + +.c$(OBJ_EXT): + $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c + +.C$(OBJ_EXT): + $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.C + +.cpp$(OBJ_EXT): + $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.cpp + +.cxx$(OBJ_EXT): + $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.cxx + +.cc$(OBJ_EXT): + $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.cc + + +# --- MakeMaker xs_c section: + +.xs.c: + $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c + + +# --- MakeMaker xs_o section: + +.xs$(OBJ_EXT): + $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c + $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c + + +# --- MakeMaker top_targets section: + +#all :: config $(INST_PM) subdirs linkext manifypods + +all :: pure_all htmlifypods manifypods + @$(NOOP) + +pure_all :: config pm_to_blib subdirs linkext + @$(NOOP) + +subdirs :: $(MYEXTLIB) + @$(NOOP) + +config :: Makefile $(INST_LIBDIR)/.exists + @$(NOOP) + +config :: $(INST_ARCHAUTODIR)/.exists + @$(NOOP) + +config :: $(INST_AUTODIR)/.exists + @$(NOOP) + +$(INST_AUTODIR)/.exists :: /usr/lib/perl5/5.6.0/i386-linux/CORE/perl.h + @$(MKPATH) $(INST_AUTODIR) + @$(EQUALIZE_TIMESTAMP) /usr/lib/perl5/5.6.0/i386-linux/CORE/perl.h $(INST_AUTODIR)/.exists + + -@$(CHMOD) $(PERM_RWX) $(INST_AUTODIR) + +$(INST_LIBDIR)/.exists :: /usr/lib/perl5/5.6.0/i386-linux/CORE/perl.h + @$(MKPATH) $(INST_LIBDIR) + @$(EQUALIZE_TIMESTAMP) /usr/lib/perl5/5.6.0/i386-linux/CORE/perl.h $(INST_LIBDIR)/.exists + + -@$(CHMOD) $(PERM_RWX) $(INST_LIBDIR) + +$(INST_ARCHAUTODIR)/.exists :: /usr/lib/perl5/5.6.0/i386-linux/CORE/perl.h + @$(MKPATH) $(INST_ARCHAUTODIR) + @$(EQUALIZE_TIMESTAMP) /usr/lib/perl5/5.6.0/i386-linux/CORE/perl.h $(INST_ARCHAUTODIR)/.exists + + -@$(CHMOD) $(PERM_RWX) $(INST_ARCHAUTODIR) + +config :: $(INST_MAN3DIR)/.exists + @$(NOOP) + + +$(INST_MAN3DIR)/.exists :: /usr/lib/perl5/5.6.0/i386-linux/CORE/perl.h + @$(MKPATH) $(INST_MAN3DIR) + @$(EQUALIZE_TIMESTAMP) /usr/lib/perl5/5.6.0/i386-linux/CORE/perl.h $(INST_MAN3DIR)/.exists + + -@$(CHMOD) $(PERM_RWX) $(INST_MAN3DIR) + +help: + perldoc ExtUtils::MakeMaker + +Version_check: + @$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \ + -MExtUtils::MakeMaker=Version_check \ + -e "Version_check('$(MM_VERSION)')" + + +# --- MakeMaker linkext section: + +linkext :: $(LINKTYPE) + @$(NOOP) + + +# --- MakeMaker dlsyms section: + + +# --- MakeMaker dynamic section: + +## $(INST_PM) has been moved to the all: target. +## It remains here for awhile to allow for old usage: "make dynamic" +#dynamic :: Makefile $(INST_DYNAMIC) $(INST_BOOT) $(INST_PM) +dynamic :: Makefile $(INST_DYNAMIC) $(INST_BOOT) + @$(NOOP) + + +# --- MakeMaker dynamic_bs section: + +BOOTSTRAP = ClearSilver.bs + +# As Mkbootstrap might not write a file (if none is required) +# we use touch to prevent make continually trying to remake it. +# The DynaLoader only reads a non-empty file. +$(BOOTSTRAP): Makefile $(INST_ARCHAUTODIR)/.exists + @echo "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))" + @$(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" \ + -MExtUtils::Mkbootstrap \ + -e "Mkbootstrap('$(BASEEXT)','$(BSLOADLIBS)');" + @$(TOUCH) $(BOOTSTRAP) + $(CHMOD) $(PERM_RW) $@ + +$(INST_BOOT): $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists + @rm -rf $(INST_BOOT) + -cp $(BOOTSTRAP) $(INST_BOOT) + $(CHMOD) $(PERM_RW) $@ + + +# --- MakeMaker dynamic_lib section: + +# This section creates the dynamically loadable $(INST_DYNAMIC) +# from $(OBJECT) and possibly $(MYEXTLIB). +ARMAYBE = : +OTHERLDFLAGS = +INST_DYNAMIC_DEP = + +$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP) + LD_RUN_PATH="$(LD_RUN_PATH)" $(LD) -o $@ $(LDDLFLAGS) $(LDFROM) $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) $(EXPORT_LIST) + $(CHMOD) $(PERM_RWX) $@ + + +# --- MakeMaker static section: + +## $(INST_PM) has been moved to the all: target. +## It remains here for awhile to allow for old usage: "make static" +#static :: Makefile $(INST_STATIC) $(INST_PM) +static :: Makefile $(INST_STATIC) + @$(NOOP) + + +# --- MakeMaker static_lib section: + +$(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)/.exists + $(RM_RF) $@ + $(FULL_AR) $(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@ + $(CHMOD) $(PERM_RWX) $@ + @echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld + + + +# --- MakeMaker htmlifypods section: + +htmlifypods : pure_all + @$(NOOP) + + +# --- MakeMaker manifypods section: +POD2MAN_EXE = /usr/bin/pod2man +POD2MAN = $(PERL) -we '%m=@ARGV;for (keys %m){' \ +-e 'next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M "Makefile";' \ +-e 'print "Manifying $$m{$$_}\n";' \ +-e 'system(qq[$$^X ].q["-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" $(POD2MAN_EXE) ].qq[$$_>$$m{$$_}])==0 or warn "Couldn\047t install $$m{$$_}\n";' \ +-e 'chmod(oct($(PERM_RW))), $$m{$$_} or warn "chmod $(PERM_RW) $$m{$$_}: $$!\n";}' + +manifypods : pure_all ClearSilver.pm + @$(POD2MAN) \ + ClearSilver.pm \ + $(INST_MAN3DIR)/ClearSilver.$(MAN3EXT) + +# --- MakeMaker processPL section: + + +# --- MakeMaker installbin section: + + +# --- MakeMaker subdirs section: + +# none + +# --- MakeMaker clean section: + +# Delete temporary files but do not touch installed files. We don't delete +# the Makefile here so a later make realclean still has a makefile to use. + +clean :: + -rm -rf ClearSilver.c ./blib $(MAKE_APERL_FILE) $(INST_ARCHAUTODIR)/extralibs.all perlmain.c mon.out core core.*perl.*.? *perl.core so_locations pm_to_blib *~ */*~ */*/*~ *$(OBJ_EXT) *$(LIB_EXT) perl.exe $(BOOTSTRAP) $(BASEEXT).bso $(BASEEXT).def $(BASEEXT).exp + -mv Makefile Makefile.old $(DEV_NULL) + + +# --- MakeMaker realclean section: + +# Delete temporary files (via clean) and also delete installed files +realclean purge :: clean + rm -rf $(INST_AUTODIR) $(INST_ARCHAUTODIR) + rm -f $(INST_DYNAMIC) $(INST_BOOT) + rm -f $(INST_STATIC) + rm -f $(INST_LIBDIR)/ClearSilver.pm + rm -rf Makefile Makefile.old + + +# --- MakeMaker dist_basics section: + +distclean :: realclean distcheck + +distcheck : + $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=fullcheck \ + -e fullcheck + +skipcheck : + $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=skipcheck \ + -e skipcheck + +manifest : + $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=mkmanifest \ + -e mkmanifest + + +# --- MakeMaker dist_core section: + +dist : $(DIST_DEFAULT) + @$(PERL) -le 'print "Warning: Makefile possibly out of date with $$vf" if ' \ + -e '-e ($$vf="$(VERSION_FROM)") and -M $$vf < -M "Makefile";' + +tardist : $(DISTVNAME).tar$(SUFFIX) + +zipdist : $(DISTVNAME).zip + +$(DISTVNAME).tar$(SUFFIX) : distdir + $(PREOP) + $(TO_UNIX) + $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME) + $(RM_RF) $(DISTVNAME) + $(COMPRESS) $(DISTVNAME).tar + $(POSTOP) + +$(DISTVNAME).zip : distdir + $(PREOP) + $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME) + $(RM_RF) $(DISTVNAME) + $(POSTOP) + +uutardist : $(DISTVNAME).tar$(SUFFIX) + uuencode $(DISTVNAME).tar$(SUFFIX) \ + $(DISTVNAME).tar$(SUFFIX) > \ + $(DISTVNAME).tar$(SUFFIX)_uu + +shdist : distdir + $(PREOP) + $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar + $(RM_RF) $(DISTVNAME) + $(POSTOP) + + +# --- MakeMaker dist_dir section: + +distdir : + $(RM_RF) $(DISTVNAME) + $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=manicopy,maniread \ + -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');" + + +# --- MakeMaker dist_test section: + +disttest : distdir + cd $(DISTVNAME) && $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) Makefile.PL + cd $(DISTVNAME) && $(MAKE) + cd $(DISTVNAME) && $(MAKE) test + + +# --- MakeMaker dist_ci section: + +ci : + $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=maniread \ + -e "@all = keys %{ maniread() };" \ + -e 'print("Executing $(CI) @all\n"); system("$(CI) @all");' \ + -e 'print("Executing $(RCS_LABEL) ...\n"); system("$(RCS_LABEL) @all");' + + +# --- MakeMaker install section: + +install :: all pure_install doc_install + +install_perl :: all pure_perl_install doc_perl_install + +install_site :: all pure_site_install doc_site_install + +install_ :: install_site + @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site + +pure_install :: pure_$(INSTALLDIRS)_install + +doc_install :: doc_$(INSTALLDIRS)_install + @echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod + +pure__install : pure_site_install + @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site + +doc__install : doc_site_install + @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site + +pure_perl_install :: + @$(MOD_INSTALL) \ + read $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist \ + write $(INSTALLARCHLIB)/auto/$(FULLEXT)/.packlist \ + $(INST_LIB) $(INSTALLPRIVLIB) \ + $(INST_ARCHLIB) $(INSTALLARCHLIB) \ + $(INST_BIN) $(INSTALLBIN) \ + $(INST_SCRIPT) $(INSTALLSCRIPT) \ + $(INST_HTMLLIBDIR) $(INSTALLHTMLPRIVLIBDIR) \ + $(INST_HTMLSCRIPTDIR) $(INSTALLHTMLSCRIPTDIR) \ + $(INST_MAN1DIR) $(INSTALLMAN1DIR) \ + $(INST_MAN3DIR) $(INSTALLMAN3DIR) + @$(WARN_IF_OLD_PACKLIST) \ + $(SITEARCHEXP)/auto/$(FULLEXT) + + +pure_site_install :: + @$(MOD_INSTALL) \ + read $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist \ + write $(INSTALLSITEARCH)/auto/$(FULLEXT)/.packlist \ + $(INST_LIB) $(INSTALLSITELIB) \ + $(INST_ARCHLIB) $(INSTALLSITEARCH) \ + $(INST_BIN) $(INSTALLBIN) \ + $(INST_SCRIPT) $(INSTALLSCRIPT) \ + $(INST_HTMLLIBDIR) $(INSTALLHTMLSITELIBDIR) \ + $(INST_HTMLSCRIPTDIR) $(INSTALLHTMLSCRIPTDIR) \ + $(INST_MAN1DIR) $(INSTALLMAN1DIR) \ + $(INST_MAN3DIR) $(INSTALLMAN3DIR) + @$(WARN_IF_OLD_PACKLIST) \ + $(PERL_ARCHLIB)/auto/$(FULLEXT) + +doc_perl_install :: + -@$(MKPATH) $(INSTALLARCHLIB) + -@$(DOC_INSTALL) \ + "Module" "$(NAME)" \ + "installed into" "$(INSTALLPRIVLIB)" \ + LINKTYPE "$(LINKTYPE)" \ + VERSION "$(VERSION)" \ + EXE_FILES "$(EXE_FILES)" \ + >> $(INSTALLARCHLIB)/perllocal.pod + +doc_site_install :: + -@$(MKPATH) $(INSTALLARCHLIB) + -@$(DOC_INSTALL) \ + "Module" "$(NAME)" \ + "installed into" "$(INSTALLSITELIB)" \ + LINKTYPE "$(LINKTYPE)" \ + VERSION "$(VERSION)" \ + EXE_FILES "$(EXE_FILES)" \ + >> $(INSTALLARCHLIB)/perllocal.pod + + +uninstall :: uninstall_from_$(INSTALLDIRS)dirs + +uninstall_from_perldirs :: + @$(UNINSTALL) $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist + +uninstall_from_sitedirs :: + @$(UNINSTALL) $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist + + +# --- MakeMaker force section: +# Phony target to force checking subdirectories. +FORCE: + @$(NOOP) + + +# --- MakeMaker perldepend section: + +PERL_HDRS = \ + $(PERL_INC)/EXTERN.h \ + $(PERL_INC)/INTERN.h \ + $(PERL_INC)/XSUB.h \ + $(PERL_INC)/av.h \ + $(PERL_INC)/cc_runtime.h \ + $(PERL_INC)/config.h \ + $(PERL_INC)/cop.h \ + $(PERL_INC)/cv.h \ + $(PERL_INC)/dosish.h \ + $(PERL_INC)/embed.h \ + $(PERL_INC)/embedvar.h \ + $(PERL_INC)/fakethr.h \ + $(PERL_INC)/form.h \ + $(PERL_INC)/gv.h \ + $(PERL_INC)/handy.h \ + $(PERL_INC)/hv.h \ + $(PERL_INC)/intrpvar.h \ + $(PERL_INC)/iperlsys.h \ + $(PERL_INC)/keywords.h \ + $(PERL_INC)/mg.h \ + $(PERL_INC)/nostdio.h \ + $(PERL_INC)/objXSUB.h \ + $(PERL_INC)/op.h \ + $(PERL_INC)/opcode.h \ + $(PERL_INC)/opnames.h \ + $(PERL_INC)/patchlevel.h \ + $(PERL_INC)/perl.h \ + $(PERL_INC)/perlapi.h \ + $(PERL_INC)/perlio.h \ + $(PERL_INC)/perlsdio.h \ + $(PERL_INC)/perlsfio.h \ + $(PERL_INC)/perlvars.h \ + $(PERL_INC)/perly.h \ + $(PERL_INC)/pp.h \ + $(PERL_INC)/pp_proto.h \ + $(PERL_INC)/proto.h \ + $(PERL_INC)/regcomp.h \ + $(PERL_INC)/regexp.h \ + $(PERL_INC)/regnodes.h \ + $(PERL_INC)/scope.h \ + $(PERL_INC)/sv.h \ + $(PERL_INC)/thrdvar.h \ + $(PERL_INC)/thread.h \ + $(PERL_INC)/unixish.h \ + $(PERL_INC)/utf8.h \ + $(PERL_INC)/util.h \ + $(PERL_INC)/warnings.h + +$(OBJECT) : $(PERL_HDRS) + +ClearSilver.c : $(XSUBPPDEPS) + + +# --- MakeMaker makefile section: + +$(OBJECT) : $(FIRST_MAKEFILE) + +# We take a very conservative approach here, but it\'s worth it. +# We move Makefile to Makefile.old here to avoid gnu make looping. +Makefile : Makefile.PL $(CONFIGDEP) + @echo "Makefile out-of-date with respect to $?" + @echo "Cleaning current config before rebuilding Makefile..." + -@$(RM_F) Makefile.old + -@$(MV) Makefile Makefile.old + -$(MAKE) -f Makefile.old clean $(DEV_NULL) || $(NOOP) + $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" Makefile.PL + @echo "==> Your Makefile has been rebuilt. <==" + @echo "==> Please rerun the make command. <==" + false + +# To change behavior to :: would be nice, but would break Tk b9.02 +# so you find such a warning below the dist target. +#Makefile :: $(VERSION_FROM) +# @echo "Warning: Makefile possibly out of date with $(VERSION_FROM)" + + +# --- MakeMaker staticmake section: + +# --- MakeMaker makeaperl section --- +MAP_TARGET = perl +FULLPERL = /usr/bin/perl + +$(MAP_TARGET) :: static $(MAKE_APERL_FILE) + $(MAKE) -f $(MAKE_APERL_FILE) $@ + +$(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) + @echo Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET) + @$(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \ + Makefile.PL DIR= \ + MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \ + MAKEAPERL=1 NORECURS=1 CCCDLFLAGS= + + +# --- MakeMaker test section: + +TEST_VERBOSE=0 +TEST_TYPE=test_$(LINKTYPE) +TEST_FILE = test.pl +TEST_FILES = +TESTDB_SW = -d + +testdb :: testdb_$(LINKTYPE) + +test :: $(TEST_TYPE) + +test_dynamic :: pure_all + PERL_DL_NONLAZY=1 $(FULLPERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(TEST_FILE) + +testdb_dynamic :: pure_all + PERL_DL_NONLAZY=1 $(FULLPERL) $(TESTDB_SW) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(TEST_FILE) + +test_ : test_dynamic + +test_static :: pure_all $(MAP_TARGET) + PERL_DL_NONLAZY=1 ./$(MAP_TARGET) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(TEST_FILE) + +testdb_static :: pure_all $(MAP_TARGET) + PERL_DL_NONLAZY=1 ./$(MAP_TARGET) $(TESTDB_SW) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(TEST_FILE) + + + +# --- MakeMaker ppd section: +# Creates a PPD (Perl Package Description) for a binary distribution. +ppd: + @$(PERL) -e "print qq{\n}. qq{\tClearSilver\n}. qq{\tPerl extension for blah blah blah\n}. qq{\tA. U. Thor <a.u.thor\@a.galaxy.far.far.away>\n}. qq{\t\n}. qq{\t\t\n}. qq{\t\t\n}. qq{\t\t\n}. qq{\t\n}. qq{\n}" > ClearSilver.ppd + +# --- MakeMaker pm_to_blib section: + +pm_to_blib: $(TO_INST_PM) + @$(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" \ + "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Install \ + -e "pm_to_blib({qw{$(PM_TO_BLIB)}},'$(INST_LIB)/auto')" + @$(TOUCH) $@ + + +# --- MakeMaker selfdocument section: + + +# --- MakeMaker postamble section: + + +# End. diff -Nru clearsilver-0.7.1/perl/README clearsilver-0.7.2/perl/README --- clearsilver-0.7.1/perl/README Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/perl/README Thu Oct 17 14:06:21 2002 @@ -0,0 +1,43 @@ +ClearSilver version 0.02 +======================== + +The README is used to introduce the module and provide instructions on +how to install the module, any machine dependencies it may have (for +example C compilers and installed libraries) and any other information +that should be provided before the module is installed. + +A README file is required for CPAN modules since CPAN extracts the +README file from a module distribution so that people browsing the +archive can use it get an idea of the modules uses. It is usually a +good idea to provide version information here so that people can +decide whether fixes for the module are worth downloading. + +INSTALLATION + +This Perl module is supposed to be put under ClearSilver's +top directory as perl/. + +To install this module type the following: + + cd perl/ + perl Makefile.PL + make + make test + sudo make install + +DEPENDENCIES + +This module requires these other modules and libraries: + + libneo_cgi.a libneo_cs.a libneo_utl.a + +COPYRIGHT AND LICENCE + + This Perl module can be distributed under GPL version 2, or + under the Neotonic ClearSilver License + +Copyright (C) 2002 Gaku Ueda + +More up-to-date information available from: + +http://www.gaku.net/cs/en/ diff -Nru clearsilver-0.7.1/perl/test.cs clearsilver-0.7.2/perl/test.cs --- clearsilver-0.7.1/perl/test.cs Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/perl/test.cs Thu Oct 17 13:53:21 2002 @@ -0,0 +1,7 @@ + + + + + + + diff -Nru clearsilver-0.7.1/perl/test.gold clearsilver-0.7.2/perl/test.gold --- clearsilver-0.7.1/perl/test.gold Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/perl/test.gold Thu Oct 17 13:53:21 2002 @@ -0,0 +1,11 @@ +value3 +value1 + + +value1 + +value2 + +value3 + + diff -Nru clearsilver-0.7.1/perl/test.hdf clearsilver-0.7.2/perl/test.hdf --- clearsilver-0.7.1/perl/test.hdf Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/perl/test.hdf Thu Oct 17 13:53:21 2002 @@ -0,0 +1,14 @@ + +TopNode.2nd1.Entry1 = value1 + +TopNode.2nd1 { + Entry2 = value2 + Entry3 = value3 +} + +Sort.Data { + entry1 = 200 + entry2 = 144 + entry3 = 3 +} + diff -Nru clearsilver-0.7.1/perl/test.out clearsilver-0.7.2/perl/test.out --- clearsilver-0.7.1/perl/test.out Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/perl/test.out Thu Oct 17 13:53:21 2002 @@ -0,0 +1,11 @@ +value3 +value1 + + +value1 + +value2 + +value3 + + diff -Nru clearsilver-0.7.1/perl/test.pl clearsilver-0.7.2/perl/test.pl --- clearsilver-0.7.1/perl/test.pl Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/perl/test.pl Thu Oct 17 13:53:21 2002 @@ -0,0 +1,145 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### + +# change 'tests => 1' to 'tests => last_test_to_print'; + +sub result { + my($i, $state) = @_; + if ($state) { + print "ok $i\n"; + } else { + print "ng $i\n"; + exit $i; + } +} + +sub sortFunc { + my($a, $b) = @_; + my($va, $vb); + + $va = $a->objValue(); + $vb = $b->objValue(); + return $va <=> $vb; +} + +use Test; +BEGIN { plan tests => 13 }; +use ClearSilver; +ok(1); # If we made it this far, we're ok. + +$testnum = 2; +# +# test new() +# +$hdf = ClearSilver::HDF->new(); +$hdf ? result($testnum, 1) : result($testnum, 0); +$testnum++; + +# +# test reading file +# +$ret = $hdf->readFile("test.hdf"); +$ret ? result($testnum, 1) : result($testnum, 0); +$testnum++; + +# +# test getObj() +# +$lev2_node = $hdf->getObj("TopNode.2nd1"); +$lev2_node ? result($testnum, 1) : result($testnum, 0); +$testnum++; + +# +# test objName() +# +$lev2_name = $lev2_node->objName(); +($lev2_name eq "2nd1") ? result($testnum, 1) : result($testnum, 0); +$testnum++; + +# +# test objChild() & objValue() +# +$lev3_node = $lev2_node->objChild(); +if (!$lev3_node) { + result($testnum, 0); +} +$val = $lev3_node->objValue(); +($val eq "value1") ? result($testnum, 1) : result($testnum, 0); +$testnum++; + +# +# test objNext() +# +$next_node = $lev3_node->objNext(); +if (!$lev3_node) { + result($testnum, 0); +} +$nam = $next_node->objName(); +($nam eq "Entry2") ? result($testnum, 1) : result($testnum, 0); +$testnum++; + +# +# test getChild() +# +$lev2_node = $hdf->getChild("TopNode.2nd1"); +$lev2_node ? result($testnum, 1) : result($testnum, 0); +$testnum++; + +# +# test setValue() & getValue() +# +$hdf->setValue("Data.1", "Value1"); +$str = $hdf->getValue("Data.1", "default"); +($str eq "Value1") ? result($testnum, 1) : result($testnum, 0); +$testnum++; + +$str = $hdf->getValue("Data.2", "default"); # doesn't exist +($str eq "default") ? result($testnum, 1) : result($testnum, 0); +$testnum++; + +# +# test sortObj() +# +$sort_top = $hdf->getObj("Sort.Data"); +$sort_top->sortObj("sortFunc"); +$child = $sort_top->objChild(); +$name = $child->objName(); +($name eq "entry3") ? result($testnum, 1) : result($testnum, 0); +$testnum++; + + +# +# test CS +# +$cs = ClearSilver::CS->new($hdf); +$cs ? result($testnum, 1) : result($testnum, 0); +$testnum++; + +# +# parseString() and render() +# +$ret = $cs->parseString(""); +if (!$ret) { + result($testnum, 0); +} +$ret = $cs->render(); +($ret eq "value3") ? result($testnum, 1) : result($testnum, 0); +$testnum++; + +# +# parseFile() +# +$ret = $cs->parseFile("test.cs"); +if (!$ret) { + result($testnum, 0); +} +$ret = $cs->render(); +open(FH, "> test.out"); +print FH $ret; +close(FH); +$ret = system("diff test.gold test.out > /dev/null"); +$ret ? result($testnum, 0) : result($testnum, 1); + + diff -Nru clearsilver-0.7.1/perl/typemap clearsilver-0.7.2/perl/typemap --- clearsilver-0.7.1/perl/typemap Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/perl/typemap Thu Oct 17 13:53:21 2002 @@ -0,0 +1,3 @@ +TYPEMAP +ClearSilver::HDF T_PTROBJ +ClearSilver::CS T_PTROBJ diff -Nru clearsilver-0.7.1/python/Makefile clearsilver-0.7.2/python/Makefile --- clearsilver-0.7.1/python/Makefile Fri Mar 22 11:26:41 2002 +++ clearsilver-0.7.2/python/Makefile Thu Oct 17 13:54:27 2002 @@ -7,9 +7,12 @@ include $(NEOTONIC_ROOT)rules.mk NEO_UTIL_SO = neo_cgi.so +NEO_UTIL_PYD = neo_cgi.pyd NEO_UTIL_SRC = neo_cgi.c neo_util.c neo_cs.c NEO_UTIL_OBJ = $(NEO_UTIL_SRC:%.c=%.o) + + ifeq ($(PYTHON_INC),) PYTHON_INC = -I/usr/include/python1.5 endif @@ -17,17 +20,29 @@ CFLAGS += -I$(NEOTONIC_ROOT) $(PYTHON_INC) DLIBS += -lneo_cgi -lneo_cs -lneo_utl -LIBS += -L$(LIB_DIR) $(DLIBS) -lz $(DB2_LIB) +LIBS += -L$(LIB_DIR) $(DLIBS) $(DB2_LIB) +ifeq ($(OSNAME),WindowsNT 0) +TARGETS = $(NEO_UTIL_PYD) +PYTHONLIBS=-LC:/python22/Libs -lpython22 +else TARGETS = $(NEO_UTIL_SO) +endif all: $(TARGETS) $(NEO_UTIL_SO): $(NEO_UTIL_OBJ) $(DEP_LIBS) $(LDSHARED) -o $@ $(LDFLAGS) $(NEO_UTIL_OBJ) $(LIBS) +$(NEO_UTIL_PYD): $(NEO_UTIL_OBJ) $(DEP_LIBS) + dllwrap --dllname neo_cgi.pyd --driver-name gcc \ + --def neo_cgi.def -o neo_cgi.pyd \ + $(NEO_UTIL_OBJ) -s --entry _DllMain@12 \ + --target=i386-mingw32 \ + $(PYTHONLIBS) $(LIBS) + clean: $(RM) *.o distclean: - $(RM) $(TARGETS) *.o + $(RM) Makefile.depends $(TARGETS) *.o diff -Nru clearsilver-0.7.1/python/README.txt clearsilver-0.7.2/python/README.txt --- clearsilver-0.7.1/python/README.txt Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/python/README.txt Fri Sep 20 19:47:46 2002 @@ -0,0 +1,65 @@ +------------------------ +Python Clearsilver Module +By Brandon Long + +Windows port by David Jeske +------------------------ + +This is the python clearsilver module. You can see the online +documentation for the Python API here: + + http://www.clearsilver.net/docs/python/ + +COMPILING on UNIX + +Compiling from source on Linux (UNIX) should be pretty +straightforward. Simply make sure that the Makefile and top level +rules.mk point to your Python installation of choice. Comments or +questions to blong@fiction.net + +WINDOWS BINARY + +If you are using Python2.2, we highly recommend you download the +pre-built binary. You can download a windows binary of the module from +the clearsilver download page here: + + http://www.clearsilver.net/downloads/ + +COMPILING on Windows + +If you must compile on windows, here is the set of steps you need to +follow for Python22. Comments or questions to jeske@chat.net. + +1) Download and Install Python2.2 from: + + http://www.python.org/ftp/python/2.2.1/Python-2.2.1.exe + +2) Download and Install Mingw32-2.0 and binutils from: + + http://prdownloads.sourceforge.net/mingw/MinGW-2.0.0-3.exe?download + http://prdownloads.sourceforge.net/mingw/binutils-2.13-20020903-1.tar.gz?download + +3) Add the mingw32 binary directory to your path + +4) Build the libpython22.a import library using these steps: + + a) Download the Py-mingw32 tools: + + http://starship.python.net/crew/kernr/mingw32/Py-mingw32-tools.zip + + b) extract them to C:\Python22\libs + + c) edit lib2def.py and replace python15->python22, Python15->Python22 + + d) execute these commands: + + C:\Python22\libs> lib2def.py python22.lib > python22.def + C:\Python22\libs> dlltool --dllname python22.dll --def python22.def --output-lib libpython22.a + + Reference: + + http://starship.python.net/pipermail/mmtk/2002/000398.html + +5) Check the library and include paths in the neotonic/Python/Makefile + +6) Then type "make" in the neotonic\python directory... diff -Nru clearsilver-0.7.1/python/neo_cgi.c clearsilver-0.7.2/python/neo_cgi.c --- clearsilver-0.7.1/python/neo_cgi.c Sat Apr 13 17:49:50 2002 +++ clearsilver-0.7.2/python/neo_cgi.c Thu Oct 17 14:06:11 2002 @@ -39,9 +39,8 @@ static PyObject *p_cgi_value_get_attr (CGIObject *self, char *name); static void p_cgi_dealloc (CGIObject *ho); -static PyTypeObject CGIObjectType = -{ - PyObject_HEAD_INIT(&PyType_Type) +PyTypeObject CGIObjectType = { + PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "CGIObjectType", /*tp_name*/ sizeof(CGIObject), /*tp_size*/ @@ -381,6 +380,23 @@ return rv; } +static PyObject * p_html_strip (PyObject *self, PyObject *args) +{ + char *s, *esc; + NEOERR *err; + PyObject *rv; + int len; + + if (!PyArg_ParseTuple(args, "s#:htmlStrip(str)", &s, &len)) + return NULL; + + err = html_strip_alloc (s, len, &esc); + if (err) return p_neo_error (err); + rv = Py_BuildValue ("s", esc); + free (esc); + return rv; +} + static PyObject * p_text_html (PyObject *self, PyObject *args) { char *s, *esc; @@ -569,36 +585,64 @@ return len; } +/* We can't really have an error return from this (and the other + * cgiwrap) function, because the API doesn't have an error return, + * and if we get back to python, the error will occur at the next random + * place that python actually checks for errors independent of an error + * return. Not the best way to do things, but its what we've got. Some + * of these we can check for in cgiWrap() */ static char *p_getenv (void *data, char *s) { WRAPPER_DATA *wrap = (WRAPPER_DATA *)data; PyObject *get; - PyObject *args; + PyObject *args = NULL; PyObject *result; char *ret = NULL; get = PyObject_GetAttrString(wrap->p_env, "__getitem__"); - if (get == NULL) + if (get != NULL) { - PyErr_Clear(); - return NULL; + args = Py_BuildValue("(s)", s); + if (args == NULL) { + Py_DECREF(get); + PyErr_Clear(); + return NULL; + } } - args = Py_BuildValue("(s)", s); - if (args == NULL) { - Py_DECREF(get); + else + { + /* Python 1.5.2 and earlier don't have __getitem__ on the standard + * dict object, so we'll just use get for them */ + + get = PyObject_GetAttrString(wrap->p_env, "get"); + if (get != NULL) + { + args = Py_BuildValue("(s,O)", s, Py_None); + if (args == NULL) + { + Py_DECREF(get); + PyErr_Clear(); + return NULL; + } + } + } + if (get == NULL) + { + ne_warn("Unable to get __getitem__ from env"); PyErr_Clear(); return NULL; } result = PyEval_CallObject(get, args); Py_DECREF(get); Py_DECREF(args); - if (result != NULL && !PyString_Check(result)) { + if (result != NULL && !PyString_Check(result) && (result != Py_None)) + { Py_DECREF(result); result = NULL; PyErr_SetString(PyExc_TypeError, "env.get() returned non-string"); } - if (result != NULL) + if (result != NULL && result != Py_None) { ret = strdup (PyString_AsString(result)); Py_DECREF (result); @@ -826,6 +870,7 @@ {"urlEscape", p_cgi_url_escape, METH_VARARGS, NULL}, {"urlUnescape", p_cgi_url_unescape, METH_VARARGS, NULL}, {"htmlEscape", p_html_escape, METH_VARARGS, NULL}, + {"htmlStrip", p_html_strip, METH_VARARGS, NULL}, {"text2html", p_text_html, METH_VARARGS, NULL}, {"cgiWrap", cgiwrap, METH_VARARGS, cgiwrap_doc}, {"IgnoreEmptyFormVars", p_ignore, METH_VARARGS, NULL}, @@ -834,11 +879,15 @@ {NULL, NULL} }; -void initneo_cgi(void) +DL_EXPORT(void) initneo_cgi(void) { PyObject *m, *d; static void *NEO_PYTHON_API[P_NEO_CGI_POINTERS]; PyObject *c_api_object; + + CGIObjectType.ob_type = &PyType_Type; + + initneo_util(); _PyImport_FixupExtension("neo_util", "neo_util"); diff -Nru clearsilver-0.7.1/python/neo_cgi.def clearsilver-0.7.2/python/neo_cgi.def --- clearsilver-0.7.1/python/neo_cgi.def Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/python/neo_cgi.def Fri Sep 20 19:47:46 2002 @@ -0,0 +1,5 @@ + +EXPORTS + initneo_cgi + initneo_util + initneo_cs \ No newline at end of file diff -Nru clearsilver-0.7.1/python/neo_cs.c clearsilver-0.7.2/python/neo_cs.c --- clearsilver-0.7.1/python/neo_cs.c Sat Apr 13 17:49:50 2002 +++ clearsilver-0.7.2/python/neo_cs.c Fri Sep 20 18:28:58 2002 @@ -32,7 +32,7 @@ static PyTypeObject CSObjectType = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "CSObjectType", /*tp_name*/ sizeof(CSObject), /*tp_size*/ @@ -177,9 +177,11 @@ return Py_FindMethod(CSMethods, (PyObject *)ho, name); } -void initneo_cs(void) +DL_EXPORT(void) initneo_cs(void) { PyObject *m, *d; + + CSObjectType.ob_type = &PyType_Type; m = Py_InitModule("neo_cs", ModuleMethods); d = PyModule_GetDict(m); diff -Nru clearsilver-0.7.1/python/neo_util.c clearsilver-0.7.2/python/neo_util.c --- clearsilver-0.7.1/python/neo_util.c Mon Aug 12 19:01:08 2002 +++ clearsilver-0.7.2/python/neo_util.c Thu Oct 3 15:39:28 2002 @@ -13,6 +13,7 @@ #include "util/neo_misc.h" #include "util/neo_str.h" #include "util/neo_hdf.h" +#include "util/neo_date.h" #define NEO_CGI_MODULE #include "p_neo_util.h" @@ -51,9 +52,8 @@ static PyObject *p_hdf_value_get_attr (HDFObject *self, char *name); static void p_hdf_dealloc (HDFObject *ho); -static PyTypeObject HDFObjectType = -{ - PyObject_HEAD_INIT(&PyType_Type) +static PyTypeObject HDFObjectType = { + PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "HDFObjectType", /*tp_name*/ sizeof(HDFObject), /*tp_size*/ @@ -71,6 +71,7 @@ 0, /* tp_as_hash */ }; + static void p_hdf_dealloc (HDFObject *ho) { /* ne_warn("deallocating hdf: %X", ho); */ @@ -343,9 +344,10 @@ PyObject *rv; char *name, *value; NEOERR *err; + int nlen = 0; int vlen = 0; - if (!PyArg_ParseTuple(args, "ss#:setValue(name, value)", &name, &value, &vlen)) + if (!PyArg_ParseTuple(args, "s#s#:setValue(name, value)", &name, &nlen, &value, &vlen)) return NULL; err = hdf_set_value (ho->data, name, value); @@ -422,6 +424,24 @@ return rv; } +static PyObject * p_hdf_write_file_atomic (PyObject *self, PyObject *args) +{ + HDFObject *ho = (HDFObject *)self; + PyObject *rv; + char *path; + NEOERR *err; + + if (!PyArg_ParseTuple(args, "s:writeFile(path)", &path)) + return NULL; + + err = hdf_write_file_atomic (ho->data, path); + if (err) return p_neo_error(err); + + rv = Py_None; + Py_INCREF(rv); + return rv; +} + static PyObject * p_hdf_remove_tree (PyObject *self, PyObject *args) { HDFObject *ho = (HDFObject *)self; @@ -548,6 +568,7 @@ {"setAttr", p_hdf_set_attr, METH_VARARGS, NULL}, {"readFile", p_hdf_read_file, METH_VARARGS, NULL}, {"writeFile", p_hdf_write_file, METH_VARARGS, NULL}, + {"writeFileAtomic", p_hdf_write_file_atomic, METH_VARARGS, NULL}, {"readString", p_hdf_read_string, METH_VARARGS, NULL}, {"writeString", p_hdf_write_string, METH_VARARGS, NULL}, {"removeTree", p_hdf_remove_tree, METH_VARARGS, NULL}, @@ -598,11 +619,53 @@ return rv; } +/* This returns the expanded version in the standard python time tuple + * */ +static PyObject * p_time_expand (PyObject *self, PyObject *args) +{ + PyObject *rv; + int tt; + struct tm ttm; + char *tz; + + if (!PyArg_ParseTuple(args, "is:time_expand(time_t, timezone string)", &tt, &tz)) + return NULL; + + neo_time_expand(tt, tz, &ttm); + + rv = Py_BuildValue("(i,i,i,i,i,i,i,i,i)", ttm.tm_year + 1900, ttm.tm_mon + 1, + ttm.tm_mday, ttm.tm_hour, ttm.tm_min, ttm.tm_sec, ttm.tm_wday, 0, ttm.tm_isdst); + return rv; +} + +static PyObject * p_time_compact (PyObject *self, PyObject *args) +{ + PyObject *rv; + int tt; + struct tm ttm; + int junk; + char *tz; + + if (!PyArg_ParseTuple(args, "(i,i,i,i,i,i,i,i,i)s:time_compact(time tuple, timezone string)", &ttm.tm_year, &ttm.tm_mon, &ttm.tm_mday, &ttm.tm_hour, &ttm.tm_min, &ttm.tm_sec, &ttm.tm_wday, &junk, &ttm.tm_isdst, &tz)) + return NULL; + + /* fix up difference between ttm and python tup */ + ttm.tm_year -= 1900; + ttm.tm_mon -= 1; + + tt = neo_time_compact (&ttm, tz); + + rv = Py_BuildValue("i", tt); + return rv; +} + static PyMethodDef UtilMethods[] = { {"HDF", p_hdf_init, METH_VARARGS, NULL}, {"escape", p_escape, METH_VARARGS, NULL}, {"unescape", p_unescape, METH_VARARGS, NULL}, + {"time_expand", p_time_expand, METH_VARARGS, NULL}, + {"time_compact", p_time_compact, METH_VARARGS, NULL}, {NULL, NULL} }; @@ -611,9 +674,11 @@ return Py_FindMethod(HDFMethods, (PyObject *)ho, name); } -void initneo_util(void) +DL_EXPORT(void) initneo_util(void) { PyObject *m, *d; + + HDFObjectType.ob_type = &PyType_Type; m = Py_InitModule("neo_util", UtilMethods); d = PyModule_GetDict(m); diff -Nru clearsilver-0.7.1/rules.mk clearsilver-0.7.2/rules.mk --- clearsilver-0.7.1/rules.mk Wed Jul 31 17:01:40 2002 +++ clearsilver-0.7.2/rules.mk Thu Oct 17 13:54:22 2002 @@ -17,13 +17,19 @@ USE_ZLIB = 1 +## -------------- base (Linux/Neotonic) options + PYTHON_INC = -I/neo/opt/include/python2.2 +JAVA_PATH = /usr/java/j2sdk1.4.1 ## Programs MKDIR = mkdir -p RM = rm -f CC = gcc CPP = g++ +JAVAC = $(JAVA_PATH)/bin/javac +JAVAH = $(JAVA_PATH)/bin/javah +JAR = $(JAVA_PATH)/bin/jar CFLAGS = -g -O2 -Wall -c -I$(NEOTONIC_ROOT) -I/neo/opt/include OUTPUT_OPTION = -o $@ @@ -34,12 +40,28 @@ AR = ar -cr DEP_LIBS = $(DLIBS:-l%=$(LIB_DIR)lib%.a) LIBS = +LS = /bin/ls +XARGS = xargs -i% +## --------------win32 options -ifdef ($(OSTYPE),WindowsNT) -CFLAGS += -D__WINDOWS_GCC__=1 +ifeq ($(OSNAME),WindowsNT 0) +CFLAGS += -D__WINDOWS_GCC__ USE_DB2 = 0 USE_ZLIB = 0 +SHELL=cmd.exe +LS = ls +PYTHON_INC = -Ic:/Python22/include +LDSHARED= NEED_TO_USE_DLLWRAP +endif + +## -------------- + +ifeq ($(OSTYPE),FreeBSD) +XARGS = xargs -J% +# This should work on freebsd... but I wouldn't worry too much about it +USE_DB2 = 0 +PYTHON_INC = -I/usr/local/include/python2.2 endif ifeq ($(USE_ZLIB),1) @@ -65,9 +87,10 @@ @echo "** Building Dependencies " @rm -f Makefile.depends @touch Makefile.depends - @for II in `/bin/ls -1 *.c`; do \ + @for II in `$(LS) -1 *.c`; do \ gcc -M -MG ${CFLAGS} $$II >> Makefile.depends; \ done; + @echo "** (done) " DEPEND_FILE := $(shell find . -name Makefile.depends -print) ifneq ($(DEPEND_FILE),) diff -Nru clearsilver-0.7.1/util/Makefile clearsilver-0.7.2/util/Makefile --- clearsilver-0.7.1/util/Makefile Tue Sep 3 17:58:38 2002 +++ clearsilver-0.7.2/util/Makefile Thu Oct 17 13:54:29 2002 @@ -37,4 +37,4 @@ $(RM) *.o distclean: - $(RM) Makefile.depend $(TARGETS) *.o + $(RM) Makefile.depends $(TARGETS) *.o diff -Nru clearsilver-0.7.1/util/neo_date.h clearsilver-0.7.2/util/neo_date.h --- clearsilver-0.7.1/util/neo_date.h Wed Jul 31 16:49:42 2002 +++ clearsilver-0.7.2/util/neo_date.h Sat Oct 5 12:29:04 2002 @@ -12,6 +12,7 @@ #define _NEO_DATE_H_ 1 #include "osdep.h" +#include __BEGIN_DECLS diff -Nru clearsilver-0.7.1/util/neo_files.c clearsilver-0.7.2/util/neo_files.c --- clearsilver-0.7.1/util/neo_files.c Wed Jul 31 16:49:42 2002 +++ clearsilver-0.7.2/util/neo_files.c Fri Sep 20 18:04:17 2002 @@ -64,6 +64,7 @@ struct stat s; int fd; int len; + int bytes_read; *str = NULL; @@ -88,13 +89,14 @@ return nerr_raise (NERR_NOMEM, "Unable to allocate memory (%d) to load file %s", s.st_size, path); } - if (read (fd, *str, len) == -1) + if ((bytes_read = read (fd, *str, len)) == -1) { close(fd); free(*str); return nerr_raise_errno (NERR_SYSTEM, "Unable to read file %s", path); } - (*str)[len] = '\0'; + + (*str)[bytes_read] = '\0'; close(fd); return STATUS_OK; diff -Nru clearsilver-0.7.1/util/neo_hdf.c clearsilver-0.7.2/util/neo_hdf.c --- clearsilver-0.7.1/util/neo_hdf.c Wed Jul 31 16:49:42 2002 +++ clearsilver-0.7.2/util/neo_hdf.c Mon Oct 14 15:59:53 2002 @@ -511,6 +511,18 @@ while (1) { + /* examine cache to see if we have a match */ + hp = hn->last_hp; + hs = hn->last_hs; + + if ((hs == NULL && hp == hn->child) || (hs && hs->next == hp)) + { + if (hp && hp->name && (x == hp->name_len) && !strncmp (hp->name, n, x)) + { + goto skip_search; + } + } + hp = hn->child; hs = NULL; @@ -523,6 +535,15 @@ hs = hp; hp = hp->next; } + + /* save in cache any value we found */ + if (hp) { + hn->last_hp = hp; + hn->last_hs = hs; + } + +skip_search: + if (hp == NULL) { if (s != NULL) @@ -1117,7 +1138,7 @@ int x = 0; char *st = *s; - while (*st && x < buf_len) + while (*st && x < buf_len-1) { buf[x++] = *st; if (*st++ == '\n') break; @@ -1128,6 +1149,35 @@ return x; } +static int _copy_line_alloc (char **s, char **buf) +{ + NEOERR *err; + int x = 0; + char *st = *s; + STRING str; + char *nl; + + string_init(&str); + + nl = strchr(st, '\n'); + if (nl == NULL) + { + x = strlen(st); + err = string_append(&str, st); + *s = st + x; + } + else + { + x = nl - st; + err = string_appendn(&str, st, x); + *s = nl + 1; + } + + *buf = str.buf; + + return x; +} + /* attributes are of the form [key1, key2, key3=value, key4="repr"] */ static NEOERR* parse_attr(char **str, HDF_ATTR **attr) { @@ -1266,12 +1316,12 @@ { NEOERR *err; HDF *lower; - char buf[4096]; + char *buf = NULL; char *s; char *name, *value; HDF_ATTR *attr = NULL; - while (_copy_line(str, buf, sizeof(buf)) != 0) + while (_copy_line_alloc(str, &buf) != 0) { attr = NULL; (*line)++; @@ -1417,7 +1467,9 @@ *line, buf); } } + if (buf != NULL) free(buf); } + if (buf != NULL) free(buf); return STATUS_OK; } diff -Nru clearsilver-0.7.1/util/neo_hdf.h clearsilver-0.7.2/util/neo_hdf.h --- clearsilver-0.7.1/util/neo_hdf.h Thu Jul 25 16:39:40 2002 +++ clearsilver-0.7.2/util/neo_hdf.h Mon Oct 14 15:59:53 2002 @@ -35,6 +35,10 @@ struct _hdf *top; struct _hdf *next; struct _hdf *child; + + /* the following fields are used to implement a cache */ + struct _hdf *last_hp; + struct _hdf *last_hs; } HDF; NEOERR* hdf_init (HDF **hdf); diff -Nru clearsilver-0.7.1/util/snprintf.c clearsilver-0.7.2/util/snprintf.c --- clearsilver-0.7.1/util/snprintf.c Wed Dec 31 16:00:00 1969 +++ clearsilver-0.7.2/util/snprintf.c Fri Sep 20 19:47:46 2002 @@ -0,0 +1,832 @@ +/* + * Copyright Patrick Powell 1995 + * This code is based on code written by Patrick Powell (papowell@astart.com) + * It may be used for any purpose as long as this notice remains intact + * on all source code distributions + */ + +/************************************************************** + * Original: + * Patrick Powell Tue Apr 11 09:48:21 PDT 1995 + * A bombproof version of doprnt (dopr) included. + * Sigh. This sort of thing is always nasty do deal with. Note that + * the version here does not include floating point... + * + * snprintf() is used instead of sprintf() as it does limit checks + * for string length. This covers a nasty loophole. + * + * The other functions are there to prevent NULL pointers from + * causing nast effects. + * + * More Recently: + * Brandon Long 9/15/96 for mutt 0.43 + * This was ugly. It is still ugly. I opted out of floating point + * numbers, but the formatter understands just about everything + * from the normal C string format, at least as far as I can tell from + * the Solaris 2.5 printf(3S) man page. + * + * Brandon Long 10/22/97 for mutt 0.87.1 + * Ok, added some minimal floating point support, which means this + * probably requires libm on most operating systems. Don't yet + * support the exponent (e,E) and sigfig (g,G). Also, fmtint() + * was pretty badly broken, it just wasn't being exercised in ways + * which showed it, so that's been fixed. Also, formated the code + * to mutt conventions, and removed dead code left over from the + * original. Also, there is now a builtin-test, just compile with: + * gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm + * and run snprintf for results. + * + * Thomas Roessler 01/27/98 for mutt 0.89i + * The PGP code was using unsigned hexadecimal formats. + * Unfortunately, unsigned formats simply didn't work. + * + * Michael Elkins 03/05/98 for mutt 0.90.8 + * The original code assumed that both snprintf() and vsnprintf() were + * missing. Some systems only have snprintf() but not vsnprintf(), so + * the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF. + * + * Andrew Tridgell (tridge@samba.org) Oct 1998 + * fixed handling of %.0f + * added test for HAVE_LONG_DOUBLE + * + * Russ Allbery 2000-08-26 + * fixed return value to comply with C99 + * fixed handling of snprintf(NULL, ...) + * + **************************************************************/ + +#include "osdep.h" + +#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) + +#include +#include +#include + +/* Define this as a fall through, HAVE_STDARG_H is probably already set */ + +#define HAVE_VARARGS_H + + +/* varargs declarations: */ + +#if defined(HAVE_STDARG_H) +# include +# define HAVE_STDARGS /* let's hope that works everywhere (mj) */ +# define VA_LOCAL_DECL va_list ap +# define VA_START(f) va_start(ap, f) +# define VA_SHIFT(v,t) ; /* no-op for ANSI */ +# define VA_END va_end(ap) +#else +# if defined(HAVE_VARARGS_H) +# include +# undef HAVE_STDARGS +# define VA_LOCAL_DECL va_list ap +# define VA_START(f) va_start(ap) /* f is ignored! */ +# define VA_SHIFT(v,t) v = va_arg(ap,t) +# define VA_END va_end(ap) +# else +/*XX ** NO VARARGS ** XX*/ +# endif +#endif + +#ifdef HAVE_LONG_DOUBLE +#define LDOUBLE long double +#else +#define LDOUBLE double +#endif + +int snprintf (char *str, size_t count, const char *fmt, ...); +int vsnprintf (char *str, size_t count, const char *fmt, va_list arg); + +static int dopr (char *buffer, size_t maxlen, const char *format, + va_list args); +static int fmtstr (char *buffer, size_t *currlen, size_t maxlen, + char *value, int flags, int min, int max); +static int fmtint (char *buffer, size_t *currlen, size_t maxlen, + long value, int base, int min, int max, int flags); +static int fmtfp (char *buffer, size_t *currlen, size_t maxlen, + LDOUBLE fvalue, int min, int max, int flags); +static int dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c ); + +/* + * dopr(): poor man's version of doprintf + */ + +/* format read states */ +#define DP_S_DEFAULT 0 +#define DP_S_FLAGS 1 +#define DP_S_MIN 2 +#define DP_S_DOT 3 +#define DP_S_MAX 4 +#define DP_S_MOD 5 +#define DP_S_CONV 6 +#define DP_S_DONE 7 + +/* format flags - Bits */ +#define DP_F_MINUS (1 << 0) +#define DP_F_PLUS (1 << 1) +#define DP_F_SPACE (1 << 2) +#define DP_F_NUM (1 << 3) +#define DP_F_ZERO (1 << 4) +#define DP_F_UP (1 << 5) +#define DP_F_UNSIGNED (1 << 6) + +/* Conversion Flags */ +#define DP_C_SHORT 1 +#define DP_C_LONG 2 +#define DP_C_LDOUBLE 3 + +#define char_to_int(p) (p - '0') +#define MAX(p,q) ((p >= q) ? p : q) +#define MIN(p,q) ((p <= q) ? p : q) + +static int dopr (char *buffer, size_t maxlen, const char *format, va_list args) +{ + char ch; + long value; + LDOUBLE fvalue; + char *strvalue; + int min; + int max; + int state; + int flags; + int cflags; + int total; + size_t currlen; + + state = DP_S_DEFAULT; + currlen = flags = cflags = min = 0; + max = -1; + ch = *format++; + total = 0; + + while (state != DP_S_DONE) + { + if (ch == '\0') + state = DP_S_DONE; + + switch(state) + { + case DP_S_DEFAULT: + if (ch == '%') + state = DP_S_FLAGS; + else + total += dopr_outch (buffer, &currlen, maxlen, ch); + ch = *format++; + break; + case DP_S_FLAGS: + switch (ch) + { + case '-': + flags |= DP_F_MINUS; + ch = *format++; + break; + case '+': + flags |= DP_F_PLUS; + ch = *format++; + break; + case ' ': + flags |= DP_F_SPACE; + ch = *format++; + break; + case '#': + flags |= DP_F_NUM; + ch = *format++; + break; + case '0': + flags |= DP_F_ZERO; + ch = *format++; + break; + default: + state = DP_S_MIN; + break; + } + break; + case DP_S_MIN: + if (isdigit(ch)) + { + min = 10*min + char_to_int (ch); + ch = *format++; + } + else if (ch == '*') + { + min = va_arg (args, int); + ch = *format++; + state = DP_S_DOT; + } + else + state = DP_S_DOT; + break; + case DP_S_DOT: + if (ch == '.') + { + state = DP_S_MAX; + ch = *format++; + } + else + state = DP_S_MOD; + break; + case DP_S_MAX: + if (isdigit(ch)) + { + if (max < 0) + max = 0; + max = 10*max + char_to_int (ch); + ch = *format++; + } + else if (ch == '*') + { + max = va_arg (args, int); + ch = *format++; + state = DP_S_MOD; + } + else + state = DP_S_MOD; + break; + case DP_S_MOD: + /* Currently, we don't support Long Long, bummer */ + switch (ch) + { + case 'h': + cflags = DP_C_SHORT; + ch = *format++; + break; + case 'l': + cflags = DP_C_LONG; + ch = *format++; + break; + case 'L': + cflags = DP_C_LDOUBLE; + ch = *format++; + break; + default: + break; + } + state = DP_S_CONV; + break; + case DP_S_CONV: + switch (ch) + { + case 'd': + case 'i': + if (cflags == DP_C_SHORT) + value = va_arg (args, short int); + else if (cflags == DP_C_LONG) + value = va_arg (args, long int); + else + value = va_arg (args, int); + total += fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); + break; + case 'o': + flags |= DP_F_UNSIGNED; + if (cflags == DP_C_SHORT) + value = va_arg (args, unsigned short int); + else if (cflags == DP_C_LONG) + value = va_arg (args, unsigned long int); + else + value = va_arg (args, unsigned int); + total += fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags); + break; + case 'u': + flags |= DP_F_UNSIGNED; + if (cflags == DP_C_SHORT) + value = va_arg (args, unsigned short int); + else if (cflags == DP_C_LONG) + value = va_arg (args, unsigned long int); + else + value = va_arg (args, unsigned int); + total += fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); + break; + case 'X': + flags |= DP_F_UP; + case 'x': + flags |= DP_F_UNSIGNED; + if (cflags == DP_C_SHORT) + value = va_arg (args, unsigned short int); + else if (cflags == DP_C_LONG) + value = va_arg (args, unsigned long int); + else + value = va_arg (args, unsigned int); + total += fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags); + break; + case 'f': + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg (args, LDOUBLE); + else + fvalue = va_arg (args, double); + /* um, floating point? */ + total += fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags); + break; + case 'E': + flags |= DP_F_UP; + case 'e': + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg (args, LDOUBLE); + else + fvalue = va_arg (args, double); + break; + case 'G': + flags |= DP_F_UP; + case 'g': + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg (args, LDOUBLE); + else + fvalue = va_arg (args, double); + break; + case 'c': + total += dopr_outch (buffer, &currlen, maxlen, va_arg (args, int)); + break; + case 's': + strvalue = va_arg (args, char *); + total += fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max); + break; + case 'p': + strvalue = va_arg (args, void *); + total += fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, + max, flags); + break; + case 'n': + if (cflags == DP_C_SHORT) + { + short int *num; + num = va_arg (args, short int *); + *num = currlen; + } + else if (cflags == DP_C_LONG) + { + long int *num; + num = va_arg (args, long int *); + *num = currlen; + } + else + { + int *num; + num = va_arg (args, int *); + *num = currlen; + } + break; + case '%': + total += dopr_outch (buffer, &currlen, maxlen, ch); + break; + case 'w': + /* not supported yet, treat as next char */ + ch = *format++; + break; + default: + /* Unknown, skip */ + break; + } + ch = *format++; + state = DP_S_DEFAULT; + flags = cflags = min = 0; + max = -1; + break; + case DP_S_DONE: + break; + default: + /* hmm? */ + break; /* some picky compilers need this */ + } + } + if (buffer != NULL) + { + if (currlen < maxlen - 1) + buffer[currlen] = '\0'; + else + buffer[maxlen - 1] = '\0'; + } + return total; +} + +static int fmtstr (char *buffer, size_t *currlen, size_t maxlen, + char *value, int flags, int min, int max) +{ + int padlen, strln; /* amount to pad */ + int cnt = 0; + int total = 0; + + if (value == 0) + { + value = ""; + } + + for (strln = 0; value[strln]; ++strln); /* strlen */ + if (max >= 0 && max < strln) + strln = max; + padlen = min - strln; + if (padlen < 0) + padlen = 0; + if (flags & DP_F_MINUS) + padlen = -padlen; /* Left Justify */ + + while (padlen > 0) + { + total += dopr_outch (buffer, currlen, maxlen, ' '); + --padlen; + } + while (*value && ((max < 0) || (cnt < max))) + { + total += dopr_outch (buffer, currlen, maxlen, *value++); + ++cnt; + } + while (padlen < 0) + { + total += dopr_outch (buffer, currlen, maxlen, ' '); + ++padlen; + } + return total; +} + +/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */ + +static int fmtint (char *buffer, size_t *currlen, size_t maxlen, + long value, int base, int min, int max, int flags) +{ + int signvalue = 0; + unsigned long uvalue; + char convert[20]; + int place = 0; + int spadlen = 0; /* amount to space pad */ + int zpadlen = 0; /* amount to zero pad */ + int caps = 0; + int total = 0; + + if (max < 0) + max = 0; + + uvalue = value; + + if(!(flags & DP_F_UNSIGNED)) + { + if( value < 0 ) { + signvalue = '-'; + uvalue = -value; + } + else + if (flags & DP_F_PLUS) /* Do a sign (+/i) */ + signvalue = '+'; + else + if (flags & DP_F_SPACE) + signvalue = ' '; + } + + if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ + + do { + convert[place++] = + (caps? "0123456789ABCDEF":"0123456789abcdef") + [uvalue % (unsigned)base ]; + uvalue = (uvalue / (unsigned)base ); + } while(uvalue && (place < 20)); + if (place == 20) place--; + convert[place] = 0; + + zpadlen = max - place; + spadlen = min - MAX (max, place) - (signvalue ? 1 : 0); + if (zpadlen < 0) zpadlen = 0; + if (spadlen < 0) spadlen = 0; + if (flags & DP_F_ZERO) + { + zpadlen = MAX(zpadlen, spadlen); + spadlen = 0; + } + if (flags & DP_F_MINUS) + spadlen = -spadlen; /* Left Justifty */ + +#ifdef DEBUG_SNPRINTF + dprint (1, (debugfile, "zpad: %d, spad: %d, min: %d, max: %d, place: %d\n", + zpadlen, spadlen, min, max, place)); +#endif + + /* Spaces */ + while (spadlen > 0) + { + total += dopr_outch (buffer, currlen, maxlen, ' '); + --spadlen; + } + + /* Sign */ + if (signvalue) + total += dopr_outch (buffer, currlen, maxlen, signvalue); + + /* Zeros */ + if (zpadlen > 0) + { + while (zpadlen > 0) + { + total += dopr_outch (buffer, currlen, maxlen, '0'); + --zpadlen; + } + } + + /* Digits */ + while (place > 0) + total += dopr_outch (buffer, currlen, maxlen, convert[--place]); + + /* Left Justified spaces */ + while (spadlen < 0) { + total += dopr_outch (buffer, currlen, maxlen, ' '); + ++spadlen; + } + + return total; +} + +static LDOUBLE abs_val (LDOUBLE value) +{ + LDOUBLE result = value; + + if (value < 0) + result = -value; + + return result; +} + +static LDOUBLE pow10 (int exp) +{ + LDOUBLE result = 1; + + while (exp) + { + result *= 10; + exp--; + } + + return result; +} + +static long round (LDOUBLE value) +{ + long intpart; + + intpart = value; + value = value - intpart; + if (value >= 0.5) + intpart++; + + return intpart; +} + +static int fmtfp (char *buffer, size_t *currlen, size_t maxlen, + LDOUBLE fvalue, int min, int max, int flags) +{ + int signvalue = 0; + LDOUBLE ufvalue; + char iconvert[20]; + char fconvert[20]; + int iplace = 0; + int fplace = 0; + int padlen = 0; /* amount to pad */ + int zpadlen = 0; + int caps = 0; + int total = 0; + long intpart; + long fracpart; + + /* + * AIX manpage says the default is 0, but Solaris says the default + * is 6, and sprintf on AIX defaults to 6 + */ + if (max < 0) + max = 6; + + ufvalue = abs_val (fvalue); + + if (fvalue < 0) + signvalue = '-'; + else + if (flags & DP_F_PLUS) /* Do a sign (+/i) */ + signvalue = '+'; + else + if (flags & DP_F_SPACE) + signvalue = ' '; + +#if 0 + if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ +#endif + + intpart = ufvalue; + + /* + * Sorry, we only support 9 digits past the decimal because of our + * conversion method + */ + if (max > 9) + max = 9; + + /* We "cheat" by converting the fractional part to integer by + * multiplying by a factor of 10 + */ + fracpart = round ((pow10 (max)) * (ufvalue - intpart)); + + if (fracpart >= pow10 (max)) + { + intpart++; + fracpart -= pow10 (max); + } + +#ifdef DEBUG_SNPRINTF + dprint (1, (debugfile, "fmtfp: %f =? %d.%d\n", fvalue, intpart, fracpart)); +#endif + + /* Convert integer part */ + do { + iconvert[iplace++] = + (caps? "0123456789ABCDEF":"0123456789abcdef")[intpart % 10]; + intpart = (intpart / 10); + } while(intpart && (iplace < 20)); + if (iplace == 20) iplace--; + iconvert[iplace] = 0; + + /* Convert fractional part */ + do { + fconvert[fplace++] = + (caps? "0123456789ABCDEF":"0123456789abcdef")[fracpart % 10]; + fracpart = (fracpart / 10); + } while(fracpart && (fplace < 20)); + if (fplace == 20) fplace--; + fconvert[fplace] = 0; + + /* -1 for decimal point, another -1 if we are printing a sign */ + padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0); + zpadlen = max - fplace; + if (zpadlen < 0) + zpadlen = 0; + if (padlen < 0) + padlen = 0; + if (flags & DP_F_MINUS) + padlen = -padlen; /* Left Justifty */ + + if ((flags & DP_F_ZERO) && (padlen > 0)) + { + if (signvalue) + { + total += dopr_outch (buffer, currlen, maxlen, signvalue); + --padlen; + signvalue = 0; + } + while (padlen > 0) + { + total += dopr_outch (buffer, currlen, maxlen, '0'); + --padlen; + } + } + while (padlen > 0) + { + total += dopr_outch (buffer, currlen, maxlen, ' '); + --padlen; + } + if (signvalue) + total += dopr_outch (buffer, currlen, maxlen, signvalue); + + while (iplace > 0) + total += dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]); + + /* + * Decimal point. This should probably use locale to find the correct + * char to print out. + */ + if (max > 0) + { + total += dopr_outch (buffer, currlen, maxlen, '.'); + + while (fplace > 0) + total += dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]); + } + + while (zpadlen > 0) + { + total += dopr_outch (buffer, currlen, maxlen, '0'); + --zpadlen; + } + + while (padlen < 0) + { + total += dopr_outch (buffer, currlen, maxlen, ' '); + ++padlen; + } + + return total; +} + +static int dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c) +{ + if (*currlen + 1 < maxlen) + buffer[(*currlen)++] = c; + return 1; +} + +#ifndef HAVE_VSNPRINTF +int vsnprintf (char *str, size_t count, const char *fmt, va_list args) +{ + if (str != NULL) + str[0] = 0; + return dopr(str, count, fmt, args); +} +#endif /* !HAVE_VSNPRINTF */ + +#ifndef HAVE_SNPRINTF +/* VARARGS3 */ +#ifdef HAVE_STDARGS +int snprintf (char *str,size_t count,const char *fmt,...) +#else +int snprintf (va_alist) va_dcl +#endif +{ +#ifndef HAVE_STDARGS + char *str; + size_t count; + char *fmt; +#endif + VA_LOCAL_DECL; + int total; + + VA_START (fmt); + VA_SHIFT (str, char *); + VA_SHIFT (count, size_t ); + VA_SHIFT (fmt, char *); + total = vsnprintf(str, count, fmt, ap); + VA_END; + return total; +} +#endif /* !HAVE_SNPRINTF */ + +#ifdef TEST_SNPRINTF +#ifndef LONG_STRING +#define LONG_STRING 1024 +#endif +int main (void) +{ + char buf1[LONG_STRING]; + char buf2[LONG_STRING]; + char *fp_fmt[] = { + "%-1.5f", + "%1.5f", + "%123.9f", + "%10.5f", + "% 10.5f", + "%+22.9f", + "%+4.9f", + "%01.3f", + "%4f", + "%3.1f", + "%3.2f", + "%.0f", + "%.1f", + NULL + }; + double fp_nums[] = { -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996, + 0.9996, 1.996, 4.136, 0}; + char *int_fmt[] = { + "%-1.5d", + "%1.5d", + "%123.9d", + "%5.5d", + "%10.5d", + "% 10.5d", + "%+22.33d", + "%01.3d", + "%4d", + NULL + }; + long int_nums[] = { -1, 134, 91340, 341, 0203, 0}; + int x, y; + int fail = 0; + int num = 0; + + printf ("Testing snprintf format codes against system sprintf...\n"); + + for (x = 0; fp_fmt[x] != NULL ; x++) + for (y = 0; fp_nums[y] != 0 ; y++) + { + snprintf (buf1, sizeof (buf1), fp_fmt[x], fp_nums[y]); + sprintf (buf2, fp_fmt[x], fp_nums[y]); + if (strcmp (buf1, buf2)) + { + printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n", + fp_fmt[x], buf1, buf2); + fail++; + } + num++; + } + + for (x = 0; int_fmt[x] != NULL ; x++) + for (y = 0; int_nums[y] != 0 ; y++) + { + snprintf (buf1, sizeof (buf1), int_fmt[x], int_nums[y]); + sprintf (buf2, int_fmt[x], int_nums[y]); + if (strcmp (buf1, buf2)) + { + printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n", + int_fmt[x], buf1, buf2); + fail++; + } + num++; + } + printf ("%d tests failed out of %d.\n", fail, num); +} +#endif /* SNPRINTF_TEST */ + +#endif /* !HAVE_SNPRINTF */ + diff -Nru clearsilver-0.7.1/util/test/Makefile clearsilver-0.7.2/util/test/Makefile --- clearsilver-0.7.1/util/test/Makefile Sun Sep 1 19:00:47 2002 +++ clearsilver-0.7.2/util/test/Makefile Mon Oct 14 15:59:55 2002 @@ -38,7 +38,7 @@ $(LD) $@ $(HDFTEST_OBJ) $(LIBS) $(HDFLOADTEST_EXE): $(HDFLOADTEST_OBJ) $(NTR_LIB) - $(LD) $@ $(HDFLOADTEST_OBJ) $(LIBS) + $(LD) $@ $(HDFLOADTEST_OBJ) $(LIBS) # -lefence $(LISTDIRTEST_EXE): $(LISTDIRTEST_OBJ) $(NTR_LIB) $(LD) $@ $(LISTDIRTEST_OBJ) $(LIBS) diff -Nru clearsilver-0.7.1/util/test/hdfloadtest.c clearsilver-0.7.2/util/test/hdfloadtest.c --- clearsilver-0.7.1/util/test/hdfloadtest.c Tue Jun 4 18:26:50 2002 +++ clearsilver-0.7.2/util/test/hdfloadtest.c Wed Sep 25 13:57:45 2002 @@ -11,6 +11,7 @@ double tstart = 0; char *file; int reps = 1000; + char *s = NULL; if (argc > 1) file = argv[1]; @@ -31,12 +32,19 @@ for (x = 0; x < reps; x++) { - err = hdf_read_file (hdf, file); + err = ne_load_file(file, &s); if (err != STATUS_OK) { nerr_log_error(err); return -1; } + err = hdf_read_string(hdf, s); + if (err != STATUS_OK) + { + nerr_log_error(err); + return -1; + } + free(s); } ne_warn("Load test finished in %5.3fs", ne_timef() - tstart); /* hdf_dump(hdf, NULL); */