Compare commits

..

1 Commits

Author SHA1 Message Date
(no author)
973a54719f This commit was manufactured by cvs2svn to create tag 'Last140MergeSource'.
git-svn-id: svn://10.0.0.236/tags/Last140MergeSource@10343 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-18 02:28:51 +00:00
169 changed files with 11682 additions and 193744 deletions

View File

@@ -0,0 +1,5 @@
# This is a list of local files which get copied to the mozilla:dist directory
#
jsjava.h
nsILiveconnect.h

View File

@@ -0,0 +1,89 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../..
include $(DEPTH)/config/config.mk
ifdef NSJVM
DIRS = classes
endif
MODULE = java
LIBRARY_NAME = jsj
REQUIRES = java js applet nspr img util layer xpcom
CSRCS = jsj.c \
jsj_JSObject.c \
jsj_JavaArray.c \
jsj_JavaClass.c \
jsj_JavaMember.c \
jsj_JavaObject.c \
jsj_JavaPackage.c \
jsj_array.c \
jsj_class.c \
jsj_convert.c \
jsj_field.c \
jsj_hash.c \
jsj_method.c \
jsj_utils.c \
nsCLiveconnect.c \
nsCLiveconnectFactory.c
LLIBS=$(LIBNSPR) $(DIST)/lib/js$(MOZ_BITS)$(VERSION_NUMBER).lib \
$(DIST)/lib/xpcom32.lib
ifdef NSJVM
JNI_GEN = netscape.javascript.JSObject netscape.javascript.JSException
endif
EXPORTS = jsjava.h \
$(JNI_GEN_DIR)/netscape_javascript_JSObject.h \
$(JNI_GEN_DIR)/netscape_javascript_JSException.h \
nsILiveconnect.h \
$(NULL)
include $(DEPTH)/config/rules.mk
######################################################################
# Generate jsj_nodl.c (so that you can check it in)
# These make rules only works on IRIX...sigh
ifeq ($(OS_ARCH),IRIX)
jsj_nodl.c: $(OBJDIR)/stubs.o Makefile $(DEPTH)/config/nodl.pl
rm -f $@
$(PERL) $(DEPTH)/config/nodl.pl "jsj_nodl_tab" \
`nm -Bn $(OBJDIR)/stubs.o | egrep Java_.*_stub | awk '{print $$3;}'` > $@
endif
ifdef JAVA_OR_OJI
$(OBJDIR)/stubs.o: \
$(JNI_GEN_DIR)/netscape_javascript_JSObject.c \
$(JNI_GEN_DIR)/netscape_javascript_JSException.c \
$(NULL)
else
$(OBJDIR)/stubs.o:
endif

View File

@@ -0,0 +1,90 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/config.mk
ifdef NSJVM
DIRS = classes
endif
MODULE = java
LIBRARY_NAME = jsj
REQUIRES = java js applet nspr img util layer xpcom caps oji plugin
CSRCS = jsj.c \
jsj_JSObject.c \
jsj_JavaArray.c \
jsj_JavaClass.c \
jsj_JavaMember.c \
jsj_JavaObject.c \
jsj_JavaPackage.c \
jsj_array.c \
jsj_class.c \
jsj_convert.c \
jsj_field.c \
jsj_hash.c \
jsj_method.c \
jsj_utils.c
nsCLiveconnect.c \
nsCLiveconnectFactory.c
ifdef NSJVM
JNI_GEN = netscape.javascript.JSObject netscape.javascript.JSException
endif
EXPORTS = $(srcdir)/jsjava.h \
$(srcdir)/$(JNI_GEN_DIR)/netscape_javascript_JSObject.h \
$(srcdir)/$(JNI_GEN_DIR)/netscape_javascript_JSException.h \
$(NULL)
include $(topsrcdir)/config/rules.mk
######################################################################
# Generate jsj_nodl.c (so that you can check it in)
# These make rules only works on IRIX...sigh
ifeq ($(OS_ARCH),IRIX)
jsj_nodl.c: $(OBJDIR)/stubs.o Makefile $(topsrcdir)/config/nodl.pl
rm -f $@
$(PERL) $(topsrcdir)/config/nodl.pl "jsj_nodl_tab" \
`nm -Bn $(OBJDIR)/stubs.o | egrep Java_.*_stub | awk '{print $$3;}'` > $@
endif
ifdef JAVA_OR_OJI
$(OBJDIR)/stubs.o: \
$(JRI_GEN_DIR)/netscape_javascript_JSObject.c \
$(JRI_GEN_DIR)/netscape_javascript_JSException.c \
$(NULL)
else
$(OBJDIR)/stubs.o:
endif

View File

@@ -0,0 +1,14 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include "jni.h"
/* Header for class netscape_javascript_JSException */
#ifndef _Included_netscape_javascript_JSException
#define _Included_netscape_javascript_JSException
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,102 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include "jni.h"
/* Header for class netscape_javascript_JSObject */
#ifndef _Included_netscape_javascript_JSObject
#define _Included_netscape_javascript_JSObject
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: netscape_javascript_JSObject
* Method: initClass
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_netscape_javascript_JSObject_initClass
(JNIEnv *, jclass);
/*
* Class: netscape_javascript_JSObject
* Method: getMember
* Signature: (Ljava/lang/String;)Ljava/lang/Object;
*/
JNIEXPORT jobject JNICALL Java_netscape_javascript_JSObject_getMember
(JNIEnv *, jobject, jstring);
/*
* Class: netscape_javascript_JSObject
* Method: getSlot
* Signature: (I)Ljava/lang/Object;
*/
JNIEXPORT jobject JNICALL Java_netscape_javascript_JSObject_getSlot
(JNIEnv *, jobject, jint);
/*
* Class: netscape_javascript_JSObject
* Method: setMember
* Signature: (Ljava/lang/String;Ljava/lang/Object;)V
*/
JNIEXPORT void JNICALL Java_netscape_javascript_JSObject_setMember
(JNIEnv *, jobject, jstring, jobject);
/*
* Class: netscape_javascript_JSObject
* Method: setSlot
* Signature: (ILjava/lang/Object;)V
*/
JNIEXPORT void JNICALL Java_netscape_javascript_JSObject_setSlot
(JNIEnv *, jobject, jint, jobject);
/*
* Class: netscape_javascript_JSObject
* Method: removeMember
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_netscape_javascript_JSObject_removeMember
(JNIEnv *, jobject, jstring);
/*
* Class: netscape_javascript_JSObject
* Method: call
* Signature: (Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;
*/
JNIEXPORT jobject JNICALL Java_netscape_javascript_JSObject_call
(JNIEnv *, jobject, jstring, jobjectArray);
/*
* Class: netscape_javascript_JSObject
* Method: eval
* Signature: (Ljava/lang/String;)Ljava/lang/Object;
*/
JNIEXPORT jobject JNICALL Java_netscape_javascript_JSObject_eval
(JNIEnv *, jobject, jstring);
/*
* Class: netscape_javascript_JSObject
* Method: toString
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_netscape_javascript_JSObject_toString
(JNIEnv *, jobject);
/*
* Class: netscape_javascript_JSObject
* Method: getWindow
* Signature: (Ljava/applet/Applet;)Lnetscape/javascript/JSObject;
*/
JNIEXPORT jobject JNICALL Java_netscape_javascript_JSObject_getWindow
(JNIEnv *, jclass, jobject);
/*
* Class: netscape_javascript_JSObject
* Method: finalize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_netscape_javascript_JSObject_finalize
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,65 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../../..
MODULE = java
#
# the idea is that the install phase for those modules will
# make their own signed jar files
# there are some exceptions here that we deal with
# stuff in modules and in ns/js/jsj
#
JMODS = netscape/javascript netscape/javascript/adapters
#
# JDIRS is dependant on JAVA_DESTPATH in config/rules.m[a]k.
# Be sure to touch that directory if you add a new directory to
# JDIRS, or else it will not build. FIXME
#
JDIRS = $(JMODS)
JAR_JSJ = jsj10.jar
JAR_JSJ_CLASSES = $(JMODS)
#
# jars to build at install time
#
JARS = $(JAR_JSJ)
include $(DEPTH)/config/rules.mk
JAVA_SOURCEPATH = $(DEPTH)/js/src/liveconnect/classes
doc::
$(JAVADOC) -d $(DIST)/doc netscape.javascript
natives_list:: FORCE
rm -rf $@
find . -name "*.class" -print | sed 's@\./\(.*\)\.class$$@\1@' | \
sed 's@/@.@g' | xargs $(JVH) -natives | sort > $@
check_natives:: natives_list
rm -f found_natives
nm -B ../$(OBJDIR)/*.o \
| egrep "Java.*_stub" | awk '{ print $$3; }' | sort > found_natives
diff found_natives natives_list
FORCE:

View File

@@ -0,0 +1,70 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = java
#
# the idea is that the install phase for those modules will
# make their own signed jar files
# there are some exceptions here that we deal with
# stuff in modules and in ns/js/jsj
#
JMODS = netscape/javascript netscape/javascript/adapters
#
# JDIRS is dependant on JAVA_DESTPATH in config/rules.m[a]k.
# Be sure to touch that directory if you add a new directory to
# JDIRS, or else it will not build. FIXME
#
JDIRS = $(JMODS)
JAR_JSJ = jsj10.jar
JAR_JSJ_CLASSES = $(JMODS)
#
# jars to build at install time
#
JARS = $(JAR_JSJ)
include $(topsrcdir)/config/rules.mk
JAVA_SOURCEPATH = $(topsrcdir)/js/src/liveconnect/classes
doc::
$(JAVADOC) -d $(DIST)/doc netscape.javascript
natives_list:: FORCE
rm -rf $@
find . -name "*.class" -print | sed 's@\./\(.*\)\.class$$@\1@' | \
sed 's@/@.@g' | xargs $(JVH) -natives | sort > $@
check_natives:: natives_list
rm -f found_natives
nm -B ../$(OBJDIR)/*.o \
| egrep "Java.*_stub" | awk '{ print $$3; }' | sort > found_natives
diff found_natives natives_list
FORCE:

View File

@@ -0,0 +1,78 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
IGNORE_MANIFEST=1
#
#//------------------------------------------------------------------------
#//
#// Makefile to build the JavaScript-Java tree
#//
#//------------------------------------------------------------------------
DEPTH = ..\..\..\..
JAVA_SOURCEPATH=$(DEPTH)\js\src\liveconnect\classes
#//------------------------------------------------------------------------
#//
#// Define the files necessary to build the target (ie. OBJS)
#//
#//------------------------------------------------------------------------
include <$(DEPTH)\config\config.mak>
JMOZ = \
netscape/javascript \
$(NULL)
all::
MODULE=java
JMODS=netscape/javascript
!ifdef JAVA_OR_NSJVM
JDIRS=$(JMODS)
JAR_JSJ_CLASSES=$(JMODS)
JAR_NAME = jsj10.jar
!endif
include <$(DEPTH)\config\rules.mak>
!ifdef JAVA_OR_NSJVM
install::
cd $(JAVA_DESTPATH)
@echo +++ building/updating $(JAR_NAME)
-for %i in ($(JAR_JSJ_CLASSES:/=\)) do @$(ZIP_PROG) $(ZIP_FLAGS) $(JAR_NAME) %i\*.class
cd $(MAKEDIR)
!ifdef REGENERATE
install::
cd $(JAVA_DESTPATH)
@echo +++ updating $(DEPTH)\nav-java\stubs\classes\$(JAR_NAME) for checkin
-for %i in ($(JAR_JSJ_CLASSES:/=\)) do @$(ZIP_PROG) $(ZIP_FLAGS) ..\..\nav-java\stubs\classes\$(JAR_NAME) %i\*.class
cd $(MAKEDIR)
!endif
!endif
javadoc:
-mkdir $(XPDIST)\javadoc 2> NUL
echo $(JAVADOC) -sourcepath . -d $(XPDIST)\javadoc $(JDIRS:/=.)
$(JAVADOC) -sourcepath . -d $(XPDIST)\javadoc $(JDIRS:/=.)

View File

@@ -0,0 +1,56 @@
/* Insert copyright and license here 19** */
package netscape.javascript;
/**
* JSException is an exception which is thrown when JavaScript code
* returns an error.
*/
public
class JSException extends Exception {
String filename;
int lineno;
String source;
int tokenIndex;
/**
* Constructs a JSException without a detail message.
* A detail message is a String that describes this particular exception.
*/
public JSException() {
super();
filename = "unknown";
lineno = 0;
source = "";
tokenIndex = 0;
}
/**
* Constructs a JSException with a detail message.
* A detail message is a String that describes this particular exception.
* @param s the detail message
*/
public JSException(String s) {
super(s);
filename = "unknown";
lineno = 0;
source = "";
tokenIndex = 0;
}
/**
* Constructs a JSException with a detail message and all the
* other info that usually comes with a JavaScript error.
* @param s the detail message
*/
public JSException(String s, String filename, int lineno,
String source, int tokenIndex) {
super(s);
this.filename = filename;
this.lineno = lineno;
this.source = source;
this.tokenIndex = tokenIndex;
}
}

View File

@@ -0,0 +1,150 @@
/* -*- Mode: C; tab-width: 4; -*- */
/* Insert copyright and license here 19** */
/* more doc todo:
* threads
* gc
*
*
*/
package netscape.javascript;
import java.applet.Applet;
/**
* JSObject allows Java to manipulate objects that are
* defined in JavaScript.
* Values passed from Java to JavaScript are converted as
* follows:<ul>
* <li>JSObject is converted to the original JavaScript object
* <li>Any other Java object is converted to a JavaScript wrapper,
* which can be used to access methods and fields of the java object.
* Converting this wrapper to a string will call the toString method
* on the original object, converting to a number will call the
* floatValue method if possible and fail otherwise. Converting
* to a boolean will try to call the booleanValue method in the
* same way.
* <li>Java arrays are wrapped with a JavaScript object that understands
* array.length and array[index]
* <li>A Java boolean is converted to a JavaScript boolean
* <li>Java byte, char, short, int, long, float, and double are converted
* to JavaScript numbers
* </ul>
* Values passed from JavaScript to Java are converted as follows:<ul>
* <li>objects which are wrappers around java objects are unwrapped
* <li>other objects are wrapped with a JSObject
* <li>strings, numbers and booleans are converted to String, Float,
* and Boolean objects respectively
* </ul>
* This means that all JavaScript values show up as some kind
* of java.lang.Object in Java. In order to make much use of them,
* you will have to cast them to the appropriate subclass of Object,
* e.g. <code>(String) window.getMember("name");</code> or
* <code>(JSObject) window.getMember("document");</code>.
*/
public final class JSObject {
/* the internal object data */
private int internal;
/**
* initialize
*/
private static native void initClass();
static {
// On MRJ, this property won't exist, because the library is preloaded.
String liveConnectLibrary = System.getProperty("netscape.jsj.dll", null);
if (liveConnectLibrary != null) {
System.loadLibrary(liveConnectLibrary);
initClass();
}
}
/**
* it is illegal to construct a JSObject manually
*/
private JSObject(int jsobj_addr) {
internal = jsobj_addr;
}
/**
* Retrieves a named member of a JavaScript object.
* Equivalent to "this.<i>name</i>" in JavaScript.
*/
public native Object getMember(String name);
/**
* Retrieves an indexed member of a JavaScript object.
* Equivalent to "this[<i>index</i>]" in JavaScript.
*/
// public Object getMember(int index) { return getSlot(index); }
public native Object getSlot(int index);
/**
* Sets a named member of a JavaScript object.
* Equivalent to "this.<i>name</i> = <i>value</i>" in JavaScript.
*/
public native void setMember(String name, Object value);
/**
* Sets an indexed member of a JavaScript object.
* Equivalent to "this[<i>index</i>] = <i>value</i>" in JavaScript.
*/
// public void setMember(int index, Object value) {
// setSlot(index, value);
// }
public native void setSlot(int index, Object value);
/**
* Removes a named member of a JavaScript object.
*/
public native void removeMember(String name);
/**
* Calls a JavaScript method.
* Equivalent to "this.<i>methodName</i>(<i>args</i>[0], <i>args</i>[1], ...)" in JavaScript.
*/
public native Object call(String methodName, Object args[]);
/**
* Evaluates a JavaScript expression. The expression is a string
* of JavaScript source code which will be evaluated in the context
* given by "this".
*/
public native Object eval(String s);
/**
* Converts a JSObject to a String.
*/
public native String toString();
// should use some sort of identifier rather than String
// is "property" the right word?
// native String[] listProperties();
/**
* get a JSObject for the window containing the given applet
*/
public static native JSObject getWindow(Applet applet);
/**
* Finalization decrements the reference count on the corresponding
* JavaScript object.
*/
protected native void finalize();
/**
* Override java.lang.Object.equals() because identity is not preserved
* with instances of JSObject.
*/
public boolean equals(Object obj) {
JSObject jsobj;
if (!(obj instanceof JSObject))
return false;
jsobj = (JSObject)obj;
return (internal == jsobj.internal);
}
}

View File

@@ -0,0 +1,37 @@
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* ** */
/**
* The JSProxy interface allows applets and plugins to
* share javascript contexts.
*/
package netscape.javascript;
import java.applet.Applet;
public interface JSProxy {
Object getMember(JSObject jso, String name);
Object getSlot(JSObject jso, int index);
void setMember(JSObject jso, String name, Object value);
void setSlot(JSObject jso, int index, Object value);
void removeMember(JSObject jso, String name);
Object call(JSObject jso, String methodName, Object args[]);
Object eval(JSObject jso, String s);
String toString(JSObject jso);
JSObject getWindow(Applet applet);
}

View File

@@ -0,0 +1,31 @@
package netscape.javascript;
/**
* Runs a JavaScript object with a run() method in a separate thread.
*/
public class JSRunnable implements Runnable {
private JSObject runnable;
public JSRunnable(JSObject runnable) {
this.runnable = runnable;
synchronized(this) {
new Thread(this).start();
try {
this.wait();
} catch (InterruptedException ie) {
}
}
}
public void run() {
try {
runnable.call("run", null);
synchronized(this) {
notifyAll();
}
} catch (Throwable t) {
System.err.println(t);
t.printStackTrace(System.err);
}
}
}

View File

@@ -0,0 +1,38 @@
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* ** */
package netscape.javascript;
import java.io.*;
public class JSUtil {
/* Return the stack trace of an exception or error as a String */
public static String getStackTrace(Throwable t) {
ByteArrayOutputStream captureStream;
PrintStream p;
captureStream = new ByteArrayOutputStream();
p = new PrintStream(captureStream);
t.printStackTrace(p);
p.flush();
return captureStream.toString();
}
}

View File

@@ -0,0 +1,876 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
/*
* This file is part of the Java-vendor-neutral implementation of LiveConnect
*
* It contains the top-level initialization code and the implementation of the
* public API.
*
*/
#include <stdlib.h>
#include <string.h>
#include "jsj_private.h" /* LiveConnect internals */
#include "jsjava.h" /* LiveConnect external API */
/*
* At certain times during initialization, there may be no JavaScript context
* available to direct error reports to, in which case the error messages
* are sent to this function. The caller is responsible for free'ing
* the js_error_msg argument.
*/
static void
report_java_initialization_error(JNIEnv *jEnv, const char *js_error_msg)
{
const char *error_msg, *java_error_msg;
java_error_msg = NULL;
#if 0 /* This can never work here, because jsj_GetJavaErrorMessage relies on
jlThrowable_toString which is set up by the initialization that calls
this function. */
if (jEnv) {
java_error_msg = jsj_GetJavaErrorMessage(jEnv);
(*jEnv)->ExceptionClear(jEnv);
}
#endif
if (java_error_msg) {
error_msg = PR_smprintf("initialization error: %s (%s)\n",
js_error_msg, java_error_msg);
free((void*)java_error_msg);
} else {
error_msg = PR_smprintf("initialization error: %s\n",
js_error_msg);
}
jsj_LogError(error_msg);
}
/*
* Opaque JVM handles to Java classes and methods required for Java reflection.
* These are computed and cached during initialization.
*/
jclass jlObject; /* java.lang.Object */
jclass jlrMethod; /* java.lang.reflect.Method */
jclass jlrField; /* java.lang.reflect.Field */
jclass jlVoid; /* java.lang.Void */
jclass jlrConstructor; /* java.lang.reflect.Constructor */
jclass jlThrowable; /* java.lang.Throwable */
jclass jlSystem; /* java.lang.System */
jclass jlClass; /* java.lang.Class */
jclass jlBoolean; /* java.lang.Boolean */
jclass jlDouble; /* java.lang.Double */
jclass jlString; /* java.lang.String */
jclass njJSObject; /* netscape.javascript.JSObject */
jclass njJSException; /* netscape.javascript.JSException */
jclass njJSUtil; /* netscape.javascript.JSUtil */
jmethodID jlClass_getMethods; /* java.lang.Class.getMethods() */
jmethodID jlClass_getConstructors; /* java.lang.Class.getConstructors() */
jmethodID jlClass_getFields; /* java.lang.Class.getFields() */
jmethodID jlClass_getName; /* java.lang.Class.getName() */
jmethodID jlClass_getComponentType; /* java.lang.Class.getComponentType() */
jmethodID jlClass_getModifiers; /* java.lang.Class.getModifiers() */
jmethodID jlClass_isArray; /* java.lang.Class.isArray() */
jmethodID jlrMethod_getName; /* java.lang.reflect.Method.getName() */
jmethodID jlrMethod_getParameterTypes; /* java.lang.reflect.Method.getParameterTypes() */
jmethodID jlrMethod_getReturnType; /* java.lang.reflect.Method.getReturnType() */
jmethodID jlrMethod_getModifiers; /* java.lang.reflect.Method.getModifiers() */
jmethodID jlrConstructor_getParameterTypes; /* java.lang.reflect.Constructor.getParameterTypes() */
jmethodID jlrConstructor_getModifiers; /* java.lang.reflect.Constructor.getModifiers() */
jmethodID jlrField_getName; /* java.lang.reflect.Field.getName() */
jmethodID jlrField_getType; /* java.lang.reflect.Field.getType() */
jmethodID jlrField_getModifiers; /* java.lang.reflect.Field.getModifiers() */
jmethodID jlBoolean_Boolean; /* java.lang.Boolean constructor */
jmethodID jlBoolean_booleanValue; /* java.lang.Boolean.booleanValue() */
jmethodID jlDouble_Double; /* java.lang.Double constructor */
jmethodID jlDouble_doubleValue; /* java.lang.Double.doubleValue() */
jmethodID jlThrowable_toString; /* java.lang.Throwable.toString() */
jmethodID jlThrowable_getMessage; /* java.lang.Throwable.getMessage() */
jmethodID jlSystem_identityHashCode; /* java.lang.System.identityHashCode() */
jobject jlVoid_TYPE; /* java.lang.Void.TYPE value */
jmethodID njJSException_JSException; /* netscape.javascript.JSexception constructor */
jmethodID njJSObject_JSObject; /* netscape.javascript.JSObject constructor */
jmethodID njJSUtil_getStackTrace; /* netscape.javascript.JSUtil.getStackTrace() */
jfieldID njJSObject_internal; /* netscape.javascript.JSObject.internal */
jfieldID njJSException_lineno; /* netscape.javascript.JSException.lineno */
jfieldID njJSException_tokenIndex; /* netscape.javascript.JSException.tokenIndex */
jfieldID njJSException_source; /* netscape.javascript.JSException.source */
jfieldID njJSException_filename; /* netscape.javascript.JSException.filename */
/* Obtain a reference to a Java class */
#define LOAD_CLASS(qualified_name, class) \
{ \
jclass _##class = (*jEnv)->FindClass(jEnv, #qualified_name); \
if (_##class == 0) { \
(*jEnv)->ExceptionClear(jEnv); \
report_java_initialization_error(jEnv, \
"Can't load class " #qualified_name); \
return JS_FALSE; \
} \
class = (*jEnv)->NewGlobalRef(jEnv, _##class); \
}
/* Obtain a methodID reference to a Java method or constructor */
#define _LOAD_METHOD(qualified_class, method, mvar, signature, class, is_static)\
if (is_static) { \
class##_##mvar = \
(*jEnv)->GetStaticMethodID(jEnv, class, #method, signature); \
} else { \
class##_##mvar = \
(*jEnv)->GetMethodID(jEnv, class, #method, signature); \
} \
if (class##_##mvar == 0) { \
report_java_initialization_error(jEnv, \
"Can't get mid for " #qualified_class "." #method "()"); \
return JS_FALSE; \
}
/* Obtain a methodID reference to a Java instance method */
#define LOAD_METHOD(qualified_class, method, signature, class) \
_LOAD_METHOD(qualified_class, method, method, signature, class, JS_FALSE)
/* Obtain a methodID reference to a Java static method */
#define LOAD_STATIC_METHOD(qualified_class, method, signature, class) \
_LOAD_METHOD(qualified_class, method, method, signature, class, JS_TRUE)
/* Obtain a methodID reference to a Java constructor */
#define LOAD_CONSTRUCTOR(qualified_class, method, signature, class) \
_LOAD_METHOD(qualified_class,<init>, method, signature, class, JS_FALSE)
/* Obtain a fieldID reference to a Java instance or static field */
#define _LOAD_FIELDID(qualified_class, field, signature, class, is_static) \
if (is_static) { \
class##_##field = (*jEnv)->GetStaticFieldID(jEnv, class, #field, signature);\
} else { \
class##_##field = (*jEnv)->GetFieldID(jEnv, class, #field, signature);\
} \
if (class##_##field == 0) { \
report_java_initialization_error(jEnv, \
"Can't get fid for " #qualified_class "." #field); \
return JS_FALSE; \
}
/* Obtain a fieldID reference to a Java instance field */
#define LOAD_FIELDID(qualified_class, field, signature, class) \
_LOAD_FIELDID(qualified_class, field, signature, class, JS_FALSE)
/* Obtain the value of a static field in a Java class */
#define LOAD_FIELD_VAL(qualified_class, field, signature, class, type) \
{ \
jfieldID field_id; \
field_id = (*jEnv)->GetStaticFieldID(jEnv, class, #field, signature);\
if (field_id == 0) { \
report_java_initialization_error(jEnv, \
"Can't get fid for " #qualified_class "." #field); \
return JS_FALSE; \
} \
class##_##field = \
(*jEnv)->GetStatic##type##Field(jEnv, class, field_id); \
if (class##_##field == 0) { \
report_java_initialization_error(jEnv, \
"Can't read static field " #qualified_class "." #field); \
return JS_FALSE; \
} \
}
/* Obtain the value of a static field in a Java class, which is known to
contain an object value. */
#define LOAD_FIELD_OBJ(qualified_class, field, signature, class) \
LOAD_FIELD_VAL(qualified_class, field, signature, class, Object); \
class##_##field = (*jEnv)->NewGlobalRef(jEnv, class##_##field);
/*
* Load the Java classes, and the method and field descriptors required for Java reflection.
* Returns JS_TRUE on success, JS_FALSE on failure.
*/
static JSBool
init_java_VM_reflection(JSJavaVM *jsjava_vm, JNIEnv *jEnv)
{
/* Load Java system classes and method, including java.lang.reflect classes */
LOAD_CLASS(java/lang/Object, jlObject);
LOAD_CLASS(java/lang/Class, jlClass);
LOAD_CLASS(java/lang/reflect/Method, jlrMethod);
LOAD_CLASS(java/lang/reflect/Constructor, jlrConstructor);
LOAD_CLASS(java/lang/reflect/Field, jlrField);
LOAD_CLASS(java/lang/Throwable, jlThrowable);
LOAD_CLASS(java/lang/System, jlSystem);
LOAD_CLASS(java/lang/Boolean, jlBoolean);
LOAD_CLASS(java/lang/Double, jlDouble);
LOAD_CLASS(java/lang/String, jlString);
LOAD_CLASS(java/lang/Void, jlVoid);
LOAD_METHOD(java.lang.Class, getMethods, "()[Ljava/lang/reflect/Method;",jlClass);
LOAD_METHOD(java.lang.Class, getConstructors, "()[Ljava/lang/reflect/Constructor;",jlClass);
LOAD_METHOD(java.lang.Class, getFields, "()[Ljava/lang/reflect/Field;", jlClass);
LOAD_METHOD(java.lang.Class, getName, "()Ljava/lang/String;", jlClass);
LOAD_METHOD(java.lang.Class, isArray, "()Z", jlClass);
LOAD_METHOD(java.lang.Class, getComponentType, "()Ljava/lang/Class;", jlClass);
LOAD_METHOD(java.lang.Class, getModifiers, "()I", jlClass);
LOAD_METHOD(java.lang.reflect.Method, getName, "()Ljava/lang/String;", jlrMethod);
LOAD_METHOD(java.lang.reflect.Method, getParameterTypes, "()[Ljava/lang/Class;", jlrMethod);
LOAD_METHOD(java.lang.reflect.Method, getReturnType, "()Ljava/lang/Class;", jlrMethod);
LOAD_METHOD(java.lang.reflect.Method, getModifiers, "()I", jlrMethod);
LOAD_METHOD(java.lang.reflect.Constructor, getParameterTypes, "()[Ljava/lang/Class;", jlrConstructor);
LOAD_METHOD(java.lang.reflect.Constructor, getModifiers, "()I", jlrConstructor);
LOAD_METHOD(java.lang.reflect.Field, getName, "()Ljava/lang/String;", jlrField);
LOAD_METHOD(java.lang.reflect.Field, getType, "()Ljava/lang/Class;", jlrField);
LOAD_METHOD(java.lang.reflect.Field, getModifiers, "()I", jlrField);
LOAD_METHOD(java.lang.Throwable, toString, "()Ljava/lang/String;", jlThrowable);
LOAD_METHOD(java.lang.Throwable, getMessage, "()Ljava/lang/String;", jlThrowable);
LOAD_METHOD(java.lang.Double, doubleValue, "()D", jlDouble);
LOAD_METHOD(java.lang.Boolean, booleanValue, "()Z", jlBoolean);
LOAD_STATIC_METHOD(java.lang.System, identityHashCode, "(Ljava/lang/Object;)I", jlSystem);
LOAD_CONSTRUCTOR(java.lang.Boolean, Boolean, "(Z)V", jlBoolean);
LOAD_CONSTRUCTOR(java.lang.Double, Double, "(D)V", jlDouble);
LOAD_FIELD_OBJ(java.lang.Void, TYPE, "Ljava/lang/Class;", jlVoid);
return JS_TRUE;
}
#if XP_MAC
/**
* Workaround for the fact that MRJ loads a different instance of the shared library.
*/
#include "netscape_javascript_JSObject.h"
static JSObject_RegisterNativeMethods(JNIEnv* jEnv)
{
// Manually load the required native methods.
static JNINativeMethod nativeMethods[] = {
"initClass", "()V", (void*)&Java_netscape_javascript_JSObject_initClass,
"getMember", "(Ljava/lang/String;)Ljava/lang/Object;", (void*)&Java_netscape_javascript_JSObject_getMember,
"getSlot", "(I)Ljava/lang/Object;", (void*)&Java_netscape_javascript_JSObject_getSlot,
"setMember", "(Ljava/lang/String;Ljava/lang/Object;)V", (void*)&Java_netscape_javascript_JSObject_setMember,
"setSlot", "(ILjava/lang/Object;)V", (void*)&Java_netscape_javascript_JSObject_setSlot,
"removeMember", "(Ljava/lang/String;)V", (void*)&Java_netscape_javascript_JSObject_removeMember,
"call", "(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;", (void*)&Java_netscape_javascript_JSObject_call,
"eval", "(Ljava/lang/String;)Ljava/lang/Object;", (void*)&Java_netscape_javascript_JSObject_eval,
"toString", "()Ljava/lang/String;", (void*)&Java_netscape_javascript_JSObject_toString,
"getWindow", "(Ljava/applet/Applet;)Lnetscape/javascript/JSObject;", (void*)&Java_netscape_javascript_JSObject_getWindow,
"finalize", "()V", (void*)&Java_netscape_javascript_JSObject_finalize,
/* "equals", "(Ljava/lang/Object;)Z", (void*)&Java_netscape_javascript_JSObject_equals */
};
(*jEnv)->RegisterNatives(jEnv, njJSObject, nativeMethods, sizeof(nativeMethods) / sizeof(JNINativeMethod));
if ((*jEnv)->ExceptionOccurred(jEnv)) {
report_java_initialization_error(jEnv, "Couldn't initialize JSObject native methods.");
(*jEnv)->ExceptionClear(jEnv);
}
/* call the initClass method, since we nailed the static initializer for testing. */
Java_netscape_javascript_JSObject_initClass(jEnv, njJSObject);
}
#endif
/* Load Netscape-specific Java extension classes, methods, and fields */
static JSBool
init_netscape_java_classes(JSJavaVM *jsjava_vm, JNIEnv *jEnv)
{
LOAD_CLASS(netscape/javascript/JSObject, njJSObject);
LOAD_CLASS(netscape/javascript/JSException, njJSException);
LOAD_CLASS(netscape/javascript/JSUtil, njJSUtil);
#if XP_MAC
JSObject_RegisterNativeMethods(jEnv);
#endif
LOAD_CONSTRUCTOR(netscape.javascript.JSObject,
JSObject, "(I)V", njJSObject);
LOAD_CONSTRUCTOR(netscape.javascript.JSException,
JSException, "(Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;I)V",
njJSException);
LOAD_FIELDID(netscape.javascript.JSObject,
internal, "I", njJSObject);
LOAD_FIELDID(netscape.javascript.JSException,
lineno, "I", njJSException);
LOAD_FIELDID(netscape.javascript.JSException,
tokenIndex, "I", njJSException);
LOAD_FIELDID(netscape.javascript.JSException,
source, "Ljava/lang/String;", njJSException);
LOAD_FIELDID(netscape.javascript.JSException,
filename, "Ljava/lang/String;", njJSException);
LOAD_STATIC_METHOD(netscape.javascript.JSUtil,
getStackTrace, "(Ljava/lang/Throwable;)Ljava/lang/String;",
njJSUtil);
return JS_TRUE;
}
JSJavaVM *jsjava_vm_list = NULL;
/*
* Called once per Java VM, this function initializes the classes, fields, and
* methods required for Java reflection. If java_vm is NULL, a new Java VM is
* created, using the provided classpath in addition to any default classpath.
* The classpath argument is ignored, however, if java_vm_arg is non-NULL.
*/
JSJavaVM *
JSJ_ConnectToJavaVM(SystemJavaVM *java_vm_arg, void* initargs)
{
SystemJavaVM* java_vm;
JSJavaVM *jsjava_vm;
JNIEnv *jEnv;
PR_ASSERT(JSJ_callbacks);
PR_ASSERT(JSJ_callbacks->attach_current_thread);
PR_ASSERT(JSJ_callbacks->detach_current_thread);
PR_ASSERT(JSJ_callbacks->get_java_vm);
jsjava_vm = (JSJavaVM*)malloc(sizeof(JSJavaVM));
if (!jsjava_vm)
return NULL;
memset(jsjava_vm, 0, sizeof(JSJavaVM));
java_vm = java_vm_arg;
/* If a Java VM was passed in, try to attach to it on the current thread. */
if (java_vm) {
jEnv = JSJ_callbacks->attach_current_thread(java_vm);
if (jEnv == NULL) {
jsj_LogError("Failed to attach to Java VM thread\n");
free(jsjava_vm);
return NULL;
}
}
else {
PRBool ok;
PR_ASSERT(JSJ_callbacks->create_java_vm);
PR_ASSERT(JSJ_callbacks->destroy_java_vm);
ok = JSJ_callbacks->create_java_vm(&java_vm, &jEnv, initargs);
if (!ok || java_vm == NULL) {
jsj_LogError("Failed to create Java VM\n");
free(jsjava_vm);
return NULL;
}
/* Remember that we created the VM so that we know to destroy it later */
jsjava_vm->jsj_created_java_vm = JS_TRUE;
}
jsjava_vm->java_vm = java_vm;
jsjava_vm->main_thread_env = jEnv;
/* Load the Java classes, and the method and field descriptors required for
Java reflection. */
if (!init_java_VM_reflection(jsjava_vm, jEnv)) {
JSJ_DisconnectFromJavaVM(jsjava_vm);
return NULL;
}
/*
* JVM initialization for netscape.javascript.JSObject is performed
* independently of the other classes that are initialized in
* init_java_VM_reflection, because we allow it to fail. In the case
* of failure, LiveConnect is still operative, but only when calling
* from JS to Java and not vice-versa.
*/
init_netscape_java_classes(jsjava_vm, jEnv);
/* Put this VM on the list of all created VMs */
jsjava_vm->next = jsjava_vm_list;
jsjava_vm_list = jsjava_vm;
return jsjava_vm;
}
JSJCallbacks *JSJ_callbacks = NULL;
/* Called once to set up callbacks for all instances of LiveConnect */
void
JSJ_Init(JSJCallbacks *callbacks)
{
PR_ASSERT(callbacks);
JSJ_callbacks = callbacks;
}
/*
* Initialize the provided JSContext by setting up the JS classes necessary for
* reflection and by defining JavaPackage objects for the default Java packages
* as properties of global_obj. Additional packages may be pre-defined by
* setting the predefined_packages argument. (Pre-defining a Java package at
* initialization time is not necessary, but it will make package lookup faster
* and, more importantly, will avoid unnecessary network accesses if classes
* are being loaded over the network.)
*/
JSBool
JSJ_InitJSContext(JSContext *cx, JSObject *global_obj,
JavaPackageDef *predefined_packages)
{
/* Initialize the JavaScript classes used for reflection */
if (!jsj_init_JavaObject(cx, global_obj))
return JS_FALSE;
/* if (!jsj_init_JavaMember(cx, global_obj))
return JS_FALSE; */
if (!jsj_init_JavaPackage(cx, global_obj, predefined_packages))
return JS_FALSE;
if (!jsj_init_JavaClass(cx, global_obj))
return JS_FALSE;
if (!jsj_init_JavaArray(cx, global_obj))
return JS_FALSE;
if (!jsj_init_JavaMember(cx, global_obj))
return JS_FALSE;
return JS_TRUE;
}
/* Eliminate a reference to a Java class */
#define UNLOAD_CLASS(qualified_name, class) \
if (class) { \
(*jEnv)->DeleteGlobalRef(jEnv, class); \
class = NULL; \
}
/*
* This routine severs the connection to a Java VM, freeing all related resources.
* It shouldn't be called until the global scope has been cleared in all related
* JSContexts (so that all LiveConnect objects are finalized) and a JavaScript
* GC is performed. Otherwise, accessed to free'ed memory could result.
*/
void
JSJ_DisconnectFromJavaVM(JSJavaVM *jsjava_vm)
{
JNIEnv *jEnv;
SystemJavaVM *java_vm;
JSJavaVM *j, **jp;
java_vm = jsjava_vm->java_vm;
jEnv = jsjava_vm->main_thread_env;
/* Drop all references to Java objects and classes */
jsj_DiscardJavaObjReflections(jEnv);
jsj_DiscardJavaClassReflections(jEnv);
if (jsjava_vm->jsj_created_java_vm) {
(void)JSJ_callbacks->destroy_java_vm(java_vm, jEnv);
} else {
UNLOAD_CLASS(java/lang/Object, jlObject);
UNLOAD_CLASS(java/lang/Class, jlClass);
UNLOAD_CLASS(java/lang/reflect/Method, jlrMethod);
UNLOAD_CLASS(java/lang/reflect/Constructor, jlrConstructor);
UNLOAD_CLASS(java/lang/reflect/Field, jlrField);
UNLOAD_CLASS(java/lang/Throwable, jlThrowable);
UNLOAD_CLASS(java/lang/System, jlSystem);
UNLOAD_CLASS(java/lang/Boolean, jlBoolean);
UNLOAD_CLASS(java/lang/Double, jlDouble);
UNLOAD_CLASS(java/lang/String, jlString);
UNLOAD_CLASS(java/lang/Void, jlVoid);
UNLOAD_CLASS(netscape/javascript/JSObject, njJSObject);
UNLOAD_CLASS(netscape/javascript/JSException, njJSException);
UNLOAD_CLASS(netscape/javascript/JSUtil, njJSUtil);
}
/* Remove this VM from the list of all JSJavaVM objects. */
for (jp = &jsjava_vm_list; (j = *jp) != NULL; jp = &j->next) {
if (j == jsjava_vm) {
*jp = jsjava_vm->next;
break;
}
}
PR_ASSERT(j);
free(jsjava_vm);
}
static JSJavaThreadState *thread_list = NULL;
static JSJavaThreadState *
new_jsjava_thread_state(JSJavaVM *jsjava_vm, const char *thread_name, JNIEnv *jEnv)
{
JSJavaThreadState *jsj_env;
jsj_env = (JSJavaThreadState *)malloc(sizeof(JSJavaThreadState));
if (!jsj_env)
return NULL;
memset(jsj_env, 0, sizeof(JSJavaThreadState));
jsj_env->jEnv = jEnv;
jsj_env->jsjava_vm = jsjava_vm;
if (thread_name)
jsj_env->name = strdup(thread_name);
/* THREADSAFETY - need to protect against races */
jsj_env->next = thread_list;
thread_list = jsj_env;
return jsj_env;
}
static JSJavaThreadState *
find_jsjava_thread(JNIEnv *jEnv)
{
JSJavaThreadState *e, **p, *jsj_env;
jsj_env = NULL;
/* THREADSAFETY - need to protect against races in manipulating the thread list */
/* Search for the thread state among the list of all created
LiveConnect threads */
for (p = &thread_list; (e = *p) != NULL; p = &(e->next)) {
if (e->jEnv == jEnv) {
jsj_env = e;
*p = jsj_env->next;
break;
}
}
/* Move a found thread to head of list for faster search next time. */
if (jsj_env)
thread_list = jsj_env;
return jsj_env;
}
PR_IMPLEMENT(JSJavaThreadState *)
JSJ_AttachCurrentThreadToJava(JSJavaVM *jsjava_vm, const char *name, JNIEnv **java_envp)
{
JNIEnv *jEnv;
SystemJavaVM *java_vm;
JSJavaThreadState *jsj_env;
/* Try to attach a Java thread to the current native thread */
java_vm = jsjava_vm->java_vm;
jEnv = JSJ_callbacks->attach_current_thread(java_vm);
if (jEnv == NULL)
return NULL;
/* If we found an existing thread state, just return it. */
jsj_env = find_jsjava_thread(jEnv);
if (jsj_env)
return jsj_env;
/* Create a new wrapper around the thread/VM state */
jsj_env = new_jsjava_thread_state(jsjava_vm, name, jEnv);
if (java_envp)
*java_envp = jEnv;
return jsj_env;
}
static JSJavaVM *
map_java_vm_to_jsjava_vm(SystemJavaVM *java_vm)
{
JSJavaVM *v;
for (v = jsjava_vm_list; v; v = v->next) {
if (v->java_vm == java_vm)
return v;
}
return NULL;
}
/*
* Unfortunately, there's no standard means to associate any private data with
* a JNI thread environment, so we need to use the Java environment pointer as
* the key in a lookup table that maps it to a JSJavaThreadState structure,
* where we store all our per-thread private data. If no existing thread state
* is found, a new one is created.
*
* If an error occurs, returns NULL and sets the errp argument to an error
* message, which the caller is responsible for free'ing.
*/
JSJavaThreadState *
jsj_MapJavaThreadToJSJavaThreadState(JNIEnv *jEnv, char **errp)
{
JSJavaThreadState *jsj_env;
SystemJavaVM *java_vm;
JSJavaVM *jsjava_vm;
/* If we found an existing thread state, just return it. */
jsj_env = find_jsjava_thread(jEnv);
if (jsj_env)
return jsj_env;
/* No one set up a LiveConnect thread state for a given Java thread.
Invoke the callback to create one on-the-fly. */
/* First, figure out which Java VM is calling us */
java_vm = JSJ_callbacks->get_java_vm(jEnv);
if (jsjava_vm == NULL)
return NULL;
/* Get our private JavaVM data */
jsjava_vm = map_java_vm_to_jsjava_vm(java_vm);
if (!jsjava_vm) {
*errp = PR_smprintf("Total weirdness: No JSJavaVM wrapper ever created "
"for JavaVM 0x%08x", java_vm);
return NULL;
}
jsj_env = new_jsjava_thread_state(jsjava_vm, NULL, jEnv);
if (!jsj_env)
return NULL;
return jsj_env;
}
/*
* This function is used to specify a particular JSContext as *the* JavaScript
* execution environment to be used when LiveConnect is accessed from the given
* Java thread, i.e. by using one of the methods of netscape.javascript.JSObject.
* (There can only be one such JS context for a given Java thread. To
* multiplex JSContexts among a single thread, this function must be called
* before Java is invoked on that thread.) The return value is the previous
* context associated with the given Java thread.
*/
PR_IMPLEMENT(JSContext *)
JSJ_SetDefaultJSContextForJavaThread(JSContext *cx, JSJavaThreadState *jsj_env)
{
JSContext *old_context;
old_context = jsj_env->cx;
jsj_env->cx = cx;
return old_context;
}
PR_IMPLEMENT(JSBool)
JSJ_DetachCurrentThreadFromJava(JSJavaThreadState *jsj_env)
{
SystemJavaVM *java_vm;
JNIEnv* jEnv;
JSJavaThreadState *e, **p;
/* Disassociate the current native thread from its corresponding Java thread */
java_vm = jsj_env->jsjava_vm->java_vm;
jEnv = jsj_env->jEnv;
if (!JSJ_callbacks->detach_current_thread(java_vm, jEnv))
return JS_FALSE;
/* Destroy the LiveConnect execution environment passed in */
jsj_ClearPendingJSErrors(jsj_env);
/* THREADSAFETY - need to protect against races */
for (p = &thread_list; (e = *p) != NULL; p = &(e->next)) {
if (e == jsj_env) {
*p = jsj_env->next;
break;
}
}
free(jsj_env);
return JS_TRUE;
}
JSBool
JSJ_ConvertJavaObjectToJSValue(JSContext *cx, jobject java_obj, jsval *vp)
{
JNIEnv *jEnv;
/* Get the Java per-thread environment pointer for this JSContext */
jsj_MapJSContextToJSJThread(cx, &jEnv);
if (!jEnv)
return JS_FALSE;
return jsj_ConvertJavaObjectToJSValue(cx, jEnv, java_obj, vp);
}
/*===========================================================================*/
#ifndef MOZILLA_CLIENT
/* The convenience functions below present a complete, but simplified
LiveConnect API which is designed to handle the special case of a single
Java-VM, single-threaded operation, and use of only one JSContext. */
/* We can get away with global variables in our single-threaded,
single-JSContext case. */
static JSJavaVM * the_jsj_vm = NULL;
static JSContext * the_cx = NULL;
static JSJavaThreadState * the_jsj_thread = NULL;
static JSObject * the_global_js_obj = NULL;
/* Trivial implementation of callback function */
static JSJavaThreadState *
default_map_js_context_to_jsj_thread(JSContext *cx, char **errp)
{
return the_jsj_thread;
}
/* Trivial implementation of callback function */
static JSContext *
default_map_jsj_thread_to_js_context(JSJavaThreadState *jsj_env, JNIEnv *jEnv, char **errp)
{
return the_cx;
}
/* Trivial implementation of callback function */
static JSObject *
default_map_java_object_to_js_object(JNIEnv *jEnv, jobject hint, char **errp)
{
return the_global_js_obj;
}
static PRBool PR_CALLBACK
default_create_java_vm(SystemJavaVM* *jvm, JNIEnv* *initialEnv, void* initargs)
{
jint err;
const char* user_classpath = (const char*)initargs;
/* No Java VM supplied, so create our own */
JDK1_1InitArgs vm_args;
/* Magic constant indicates JRE version 1.1 */
vm_args.version = 0x00010001;
JNI_GetDefaultJavaVMInitArgs(&vm_args);
/* Prepend the classpath argument to the default JVM classpath */
if (user_classpath) {
#ifdef XP_UNIX
const char *full_classpath = PR_smprintf("%s:%s", user_classpath, vm_args.classpath);
#else
const char *full_classpath = PR_smprintf("%s;%s", user_classpath, vm_args.classpath);
#endif
if (!full_classpath) {
return PR_FALSE;
}
vm_args.classpath = (char*)full_classpath;
}
err = JNI_CreateJavaVM((JavaVM**)jvm, initialEnv, &vm_args);
return err == 0;
}
static PRBool PR_CALLBACK
default_destroy_java_vm(SystemJavaVM* jvm, JNIEnv* initialEnv)
{
JavaVM* java_vm = (JavaVM*)jvm;
jint err = (*java_vm)->DestroyJavaVM(java_vm);
return err == 0;
}
static JNIEnv* PR_CALLBACK
default_attach_current_thread(SystemJavaVM* jvm)
{
JavaVM* java_vm = (JavaVM*)jvm;
JNIEnv* env = NULL;
jint err = (*java_vm)->AttachCurrentThread(java_vm, &env, NULL);
return env;
}
static PRBool PR_CALLBACK
default_detach_current_thread(SystemJavaVM* jvm, JNIEnv* env)
{
JavaVM* java_vm = (JavaVM*)jvm;
/* assert that env is the JNIEnv of the current thread */
jint err = (*java_vm)->DetachCurrentThread(java_vm);
return err == 0;
}
static SystemJavaVM* PR_CALLBACK
default_get_java_vm(JNIEnv* env)
{
JavaVM* java_vm = NULL;
jint err = (*env)->GetJavaVM(env, &java_vm);
return (SystemJavaVM*)java_vm;
}
/* Trivial implementations of callback functions */
JSJCallbacks jsj_default_callbacks = {
default_map_jsj_thread_to_js_context,
default_map_js_context_to_jsj_thread,
default_map_java_object_to_js_object,
NULL,
NULL,
NULL,
NULL,
default_create_java_vm,
default_destroy_java_vm,
default_attach_current_thread,
default_detach_current_thread,
default_get_java_vm
};
/*
* Initialize the provided JSContext by setting up the JS classes necessary for
* reflection and by defining JavaPackage objects for the default Java packages
* as properties of global_obj. If java_vm is NULL, a new Java VM is
* created, using the provided classpath in addition to any default classpath.
* The classpath argument is ignored, however, if java_vm is non-NULL.
*/
JSBool
JSJ_SimpleInit(JSContext *cx, JSObject *global_obj, SystemJavaVM *java_vm, const char *classpath)
{
JNIEnv *jEnv;
PR_ASSERT(!the_jsj_vm);
the_jsj_vm = JSJ_ConnectToJavaVM(java_vm, (void*)classpath);
if (!the_jsj_vm)
return JS_FALSE;
JSJ_Init(&jsj_default_callbacks);
if (!JSJ_InitJSContext(cx, global_obj, NULL))
goto error;
the_cx = cx;
the_global_js_obj = global_obj;
the_jsj_thread = JSJ_AttachCurrentThreadToJava(the_jsj_vm, "main thread", &jEnv);
if (!the_jsj_thread)
goto error;
JSJ_SetDefaultJSContextForJavaThread(cx, the_jsj_thread);
return JS_TRUE;
error:
JSJ_SimpleShutdown();
return JS_FALSE;
}
/*
* Free up all LiveConnect resources. Destroy the Java VM if it was
* created by LiveConnect.
*/
PR_IMPLEMENT(void)
JSJ_SimpleShutdown()
{
PR_ASSERT(the_jsj_vm);
JSJ_DisconnectFromJavaVM(the_jsj_vm);
the_jsj_vm = NULL;
the_cx = NULL;
the_global_js_obj = NULL;
the_jsj_thread = NULL;
}
#endif /* MOZILLA_CLIENT */

View File

@@ -0,0 +1,76 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
// Version stamp for this .DLL
#include <windows.h>
#include <ver.h>
VS_VERSION_INFO VERSIONINFO
FILEVERSION 4 // major, minor, release (alpha 1), build #
PRODUCTVERSION 4
FILEFLAGSMASK 0
FILEFLAGS 0 // final version
FILEOS VOS_DOS_WINDOWS16
FILETYPE VFT_DLL
FILESUBTYPE 0 // not used
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4" // Lang=US English, CharSet=Windows Multilingual
BEGIN
VALUE "CompanyName", "Netscape Communications Corporation\0"
VALUE "FileDescription", "Netscape 16-bit JavaScript-Java Module\0"
VALUE "FileVersion", "4.0\0"
VALUE "InternalName", "JSJ1640\0"
VALUE "LegalCopyright", "Copyright Netscape Communications. 1994-96\0"
VALUE "LegalTrademarks", "Netscape, Mozilla\0"
VALUE "OriginalFilename","JSJ1640.DLL\0"
VALUE "ProductName", "NETSCAPE\0"
VALUE "ProductVersion", "4.0\0"
END
END
END

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,403 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
/*
* This file is part of the Java-vendor-neutral implementation of LiveConnect
*
* It contains the definition of the JavaScript JavaArray class.
* Instances of JavaArray are used to reflect Java arrays.
*/
#include <stdlib.h>
#include <string.h>
#include "jsj_private.h" /* LiveConnect internals */
/* Shorthands for ASCII (7-bit) decimal and hex conversion. */
#define JS7_ISDEC(c) (((c) >= '0') && ((c) <= '9'))
#define JS7_UNDEC(c) ((c) - '0')
/*
* Convert any jsval v to an integer jsval if ToString(v)
* contains a base-10 integer that fits into 31 bits.
* Otherwise return v.
*/
static jsval
try_convert_to_jsint(JSContext *cx, jsval idval)
{
const jschar *cp;
JSString *jsstr;
jsstr = JS_ValueToString(cx, idval);
if (!jsstr)
return idval;
cp = JS_GetStringChars(jsstr);
if (JS7_ISDEC(*cp)) {
jsuint index = JS7_UNDEC(*cp++);
jsuint oldIndex = 0;
jsuint c = 0;
if (index != 0) {
while (JS7_ISDEC(*cp)) {
oldIndex = index;
c = JS7_UNDEC(*cp);
index = 10*index + c;
cp++;
}
}
if (*cp == 0 &&
(oldIndex < (JSVAL_INT_MAX / 10) ||
(oldIndex == (JSVAL_INT_MAX / 10) && c < (JSVAL_INT_MAX % 10)))) {
return INT_TO_JSVAL(index);
}
}
return idval;
}
static JSBool
access_java_array_element(JSContext *cx,
JNIEnv *jEnv,
JSObject *obj,
jsid id,
jsval *vp,
JSBool do_assignment)
{
jsval idval;
jarray java_array;
JavaClassDescriptor *class_descriptor;
JavaObjectWrapper *java_wrapper;
jsize array_length, index;
JavaSignature *array_component_signature;
/* printf("In JavaArray_getProperty\n"); */
java_wrapper = JS_GetPrivate(cx, obj);
if (!java_wrapper) {
const char *property_name;
if (JS_IdToValue(cx, id, &idval) && JSVAL_IS_STRING(idval) &&
(property_name = JS_GetStringBytes(JSVAL_TO_STRING(idval))) != NULL) {
if (!strcmp(property_name, "constructor")) {
*vp = JSVAL_VOID;
return JS_TRUE;
}
}
JS_ReportError(cx, "illegal operation on JavaArray prototype object");
return JS_FALSE;
}
class_descriptor = java_wrapper->class_descriptor;
java_array = java_wrapper->java_obj;
PR_ASSERT(class_descriptor->type == JAVA_SIGNATURE_ARRAY);
JS_IdToValue(cx, id, &idval);
if (!JSVAL_IS_INT(idval))
idval = try_convert_to_jsint(cx, idval);
if (!JSVAL_IS_INT(idval)) {
/*
* Usually, properties of JavaArray objects are indexed by integers, but
* Java arrays also inherit all the methods of java.lang.Object, so a
* string-valued property is also possible.
*/
if (JSVAL_IS_STRING(idval)) {
const char *member_name;
member_name = JS_GetStringBytes(JSVAL_TO_STRING(idval));
if (do_assignment) {
JSVersion version = JS_GetVersion(cx);
if (!JSVERSION_IS_ECMA(version)) {
JS_ReportError(cx, "Attempt to write to invalid Java array "
"element \"%s\"", member_name);
return JS_FALSE;
} else {
*vp = JSVAL_VOID;
return JS_TRUE;
}
} else {
if (!strcmp(member_name, "length")) {
array_length = jsj_GetJavaArrayLength(cx, jEnv, java_array);
if (array_length < 0)
return JS_FALSE;
if (vp)
*vp = INT_TO_JSVAL(array_length);
return JS_TRUE;
}
/* Check to see if we're reflecting a Java array method */
return JavaObject_getPropertyById(cx, obj, id, vp);
}
}
JS_ReportError(cx, "invalid Java array index expression");
return JS_FALSE;
}
index = JSVAL_TO_INT(idval);
#if 0
array_length = jsj_GetJavaArrayLength(cx, jEnv, java_array);
if (array_length < 0)
return JS_FALSE;
/* Just let Java throw an exception instead of checking array bounds here */
if (index < 0 || index >= array_length) {
JS_ReportError(cx, "Java array index %d out of range", index);
return JS_FALSE;
}
#endif
array_component_signature = class_descriptor->array_component_signature;
if (!vp)
return JS_TRUE;
if (do_assignment) {
return jsj_SetJavaArrayElement(cx, jEnv, java_array, index,
array_component_signature, *vp);
} else {
return jsj_GetJavaArrayElement(cx, jEnv, java_array, index,
array_component_signature, vp);
}
}
PR_STATIC_CALLBACK(JSBool)
JavaArray_getPropertyById(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
JNIEnv *jEnv;
jsj_MapJSContextToJSJThread(cx, &jEnv);
if (!jEnv)
return JS_FALSE;
return access_java_array_element(cx, jEnv, obj, id, vp, JS_FALSE);
}
PR_STATIC_CALLBACK(JSBool)
JavaArray_setPropertyById(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
JNIEnv *jEnv;
jsj_MapJSContextToJSJThread(cx, &jEnv);
if (!jEnv)
return JS_FALSE;
return access_java_array_element(cx, jEnv, obj, id, vp, JS_TRUE);
}
static JSBool
JavaArray_lookupProperty(JSContext *cx, JSObject *obj, jsid id,
JSObject **objp, JSProperty **propp
#if defined JS_THREADSAFE && defined DEBUG
, const char *file, uintN line
#endif
)
{
JNIEnv *jEnv;
jsj_MapJSContextToJSJThread(cx, &jEnv);
if (!jEnv)
return JS_FALSE;
return access_java_array_element(cx, jEnv, obj, id, NULL, JS_FALSE);
}
static JSBool
JavaArray_defineProperty(JSContext *cx, JSObject *obj, jsid id, jsval value,
JSPropertyOp getter, JSPropertyOp setter,
uintN attrs, JSProperty **propp)
{
JS_ReportError(cx, "Cannot define a new property in a JavaArray");
return JS_FALSE;
}
static JSBool
JavaArray_getAttributes(JSContext *cx, JSObject *obj, jsid id,
JSProperty *prop, uintN *attrsp)
{
/* We don't maintain JS property attributes for Java class members */
*attrsp = JSPROP_PERMANENT|JSPROP_ENUMERATE;
return JS_FALSE;
}
static JSBool
JavaArray_setAttributes(JSContext *cx, JSObject *obj, jsid id,
JSProperty *prop, uintN *attrsp)
{
/* We don't maintain JS property attributes for Java class members */
if (*attrsp != (JSPROP_PERMANENT|JSPROP_ENUMERATE)) {
PR_ASSERT(0);
return JS_FALSE;
}
/* Silently ignore all setAttribute attempts */
return JS_TRUE;
}
static JSBool
JavaArray_deleteProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
{
JSVersion version = JS_GetVersion(cx);
*vp = JSVAL_FALSE;
if (!JSVERSION_IS_ECMA(version)) {
JS_ReportError(cx, "Properties of JavaArray objects may not be deleted");
return JS_FALSE;
} else {
/* Attempts to delete permanent properties are silently ignored
by ECMAScript. */
return JS_TRUE;
}
}
static JSBool
JavaArray_defaultValue(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
{
/* printf("In JavaArray_defaultValue()\n"); */
return JavaObject_convert(cx, obj, JSTYPE_STRING, vp);
}
static JSBool
JavaArray_newEnumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
jsval *statep, jsid *idp)
{
JavaObjectWrapper *java_wrapper;
JNIEnv *jEnv;
jsize array_length, index;
java_wrapper = JS_GetPrivate(cx, obj);
/* Check for prototype object */
if (!java_wrapper) {
*statep = JSVAL_NULL;
if (idp)
*idp = INT_TO_JSVAL(0);
return JS_TRUE;
}
/* Get the Java per-thread environment pointer for this JSContext */
jsj_MapJSContextToJSJThread(cx, &jEnv);
if (!jEnv)
return JS_FALSE;
array_length = jsj_GetJavaArrayLength(cx, jEnv, java_wrapper->java_obj);
if (array_length < 0)
return JS_FALSE;
switch(enum_op) {
case JSENUMERATE_INIT:
*statep = INT_TO_JSVAL(0);
if (idp)
*idp = INT_TO_JSVAL(array_length);
return JS_TRUE;
case JSENUMERATE_NEXT:
index = JSVAL_TO_INT(*statep);
if (index < array_length) {
JS_ValueToId(cx, INT_TO_JSVAL(index), idp);
index++;
*statep = INT_TO_JSVAL(index);
return JS_TRUE;
}
/* Fall through ... */
case JSENUMERATE_DESTROY:
*statep = JSVAL_NULL;
return JS_TRUE;
default:
PR_ASSERT(0);
return JS_FALSE;
}
}
static JSBool
JavaArray_checkAccess(JSContext *cx, JSObject *obj, jsid id,
JSAccessMode mode, jsval *vp, uintN *attrsp)
{
switch (mode) {
case JSACC_WATCH:
JS_ReportError(cx, "Cannot place watchpoints on JavaArray object properties");
return JS_FALSE;
case JSACC_IMPORT:
JS_ReportError(cx, "Cannot export a JavaArray object's properties");
return JS_FALSE;
default:
return JS_TRUE;
}
}
JSObjectOps JavaArray_ops = {
/* Mandatory non-null function pointer members. */
NULL, /* newObjectMap */
NULL, /* destroyObjectMap */
JavaArray_lookupProperty,
JavaArray_defineProperty,
JavaArray_getPropertyById, /* getProperty */
JavaArray_setPropertyById, /* setProperty */
JavaArray_getAttributes,
JavaArray_setAttributes,
JavaArray_deleteProperty,
JavaArray_defaultValue,
JavaArray_newEnumerate,
JavaArray_checkAccess,
/* Optionally non-null members start here. */
NULL, /* thisObject */
NULL, /* dropProperty */
NULL, /* call */
NULL, /* construct */
NULL, /* xdrObject */
NULL /* hasInstance */
};
static JSObjectOps *
JavaArray_getObjectOps(JSContext *cx, JSClass *clazz)
{
return &JavaArray_ops;
}
JSClass JavaArray_class = {
"JavaArray", JSCLASS_HAS_PRIVATE,
NULL, NULL, NULL, NULL,
NULL, NULL, JavaObject_convert, JavaObject_finalize,
JavaArray_getObjectOps,
};
extern PR_IMPORT_DATA(JSObjectOps) js_ObjectOps;
/* Initialize the JS JavaArray class */
JSBool
jsj_init_JavaArray(JSContext *cx, JSObject *global_obj)
{
JavaArray_ops.newObjectMap = js_ObjectOps.newObjectMap;
JavaArray_ops.destroyObjectMap = js_ObjectOps.destroyObjectMap;
if (!JS_InitClass(cx, global_obj,
0, &JavaArray_class, 0, 0,
0, 0, 0, 0))
return JS_FALSE;
return JS_TRUE;
}

View File

@@ -0,0 +1,586 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
/* This file is part of the Java-vendor-neutral implementation of LiveConnect
*
* It contains the native code implementation of JS's JavaClass class.
*
* A JavaClass is JavaScript's representation of a Java class.
* Its parent JS object is always a JavaPackage object. A JavaClass is not an
* exact reflection of Java's corresponding java.lang.Class object. Rather,
* the properties of a JavaClass are the static methods and properties of the
* corresponding Java class.
*
* Note that there is no runtime equivalent to the JavaClass class in Java.
* (Although there are instances of java.lang.String and there are static
* methods of java.lang.String that can be invoked, there's no such thing as
* a first-class object that can be referenced simply as "java.lang.String".)
*/
#include <stdlib.h>
#include <string.h>
#include "jsj_private.h" /* LiveConnect internals */
static JSBool
JavaClass_convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
{
char *name;
JSString *str;
JavaClassDescriptor *class_descriptor;
class_descriptor = JS_GetPrivate(cx, obj);
if (!class_descriptor)
return JS_FALSE;
switch(type) {
case JSTYPE_STRING:
/* Convert '/' to '.' so that it looks like Java language syntax. */
if (!class_descriptor->name)
break;
name = PR_smprintf("[JavaClass %s]", class_descriptor->name);
if (!name) {
JS_ReportOutOfMemory(cx);
return JS_FALSE;
}
str = JS_NewString(cx, name, strlen(name));
if (!str) {
free(name);
/* It's not necessary to call JS_ReportOutOfMemory(), as
JS_NewString() will do so on failure. */
return JS_FALSE;
}
*vp = STRING_TO_JSVAL(str);
return JS_TRUE;
default:
break;
}
return JS_TRUE;
}
static JSBool
lookup_static_member_by_id(JSContext *cx, JNIEnv *jEnv, JSObject *obj,
JavaClassDescriptor **class_descriptorp,
jsid id, JavaMemberDescriptor **memberp)
{
jsval idval;
JavaMemberDescriptor *member_descriptor;
const char *member_name;
JavaClassDescriptor *class_descriptor;
class_descriptor = JS_GetPrivate(cx, obj);
if (!class_descriptor) {
*class_descriptorp = NULL;
*memberp = NULL;
return JS_TRUE;
}
if (class_descriptorp)
*class_descriptorp = class_descriptor;
member_descriptor = jsj_LookupJavaStaticMemberDescriptorById(cx, jEnv, class_descriptor, id);
if (!member_descriptor) {
JS_IdToValue(cx, id, &idval);
if (!JSVAL_IS_STRING(idval)) {
JS_ReportError(cx, "invalid JavaClass property expression. "
"(methods and fields of a JavaClass object can only be identified by their name)");
return JS_FALSE;
}
member_name = JS_GetStringBytes(JSVAL_TO_STRING(idval));
/* Why do we have to do this ? */
if (!strcmp(member_name, "prototype")) {
*memberp = NULL;
return JS_TRUE;
}
JS_ReportError(cx, "Java class %s has no public static field or method named \"%s\"",
class_descriptor->name, member_name);
return JS_FALSE;
}
if (memberp)
*memberp = member_descriptor;
return JS_TRUE;
}
PR_STATIC_CALLBACK(JSBool)
JavaClass_getPropertyById(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
{
jsval idval;
jclass java_class;
const char *member_name;
JavaClassDescriptor *class_descriptor;
JavaMemberDescriptor *member_descriptor;
JNIEnv *jEnv;
/* printf("In JavaClass_getProperty\n"); */
/* Get the Java per-thread environment pointer for this JSContext */
jsj_MapJSContextToJSJThread(cx, &jEnv);
if (!jEnv)
return JS_FALSE;
if (!lookup_static_member_by_id(cx, jEnv, obj, &class_descriptor, id, &member_descriptor))
return JS_FALSE;
if (!member_descriptor) {
*vp = JSVAL_VOID;
return JS_TRUE;
}
java_class = class_descriptor->java_class;
if (member_descriptor->field) {
if (!member_descriptor->methods) {
return jsj_GetJavaFieldValue(cx, jEnv, member_descriptor->field, java_class, vp);
} else {
PR_ASSERT(0);
}
} else {
JSFunction *function;
/* TODO - eliminate JSFUN_BOUND_METHOD */
JS_IdToValue(cx, id, &idval);
member_name = JS_GetStringBytes(JSVAL_TO_STRING(idval));
function = JS_NewFunction(cx, jsj_JavaStaticMethodWrapper, 0,
JSFUN_BOUND_METHOD, obj, member_name);
if (!function)
return JS_FALSE;
*vp = OBJECT_TO_JSVAL(JS_GetFunctionObject(function));
}
return JS_TRUE;
}
PR_STATIC_CALLBACK(JSBool)
JavaClass_setPropertyById(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
{
jclass java_class;
const char *member_name;
JavaClassDescriptor *class_descriptor;
JavaMemberDescriptor *member_descriptor;
jsval idval;
JNIEnv *jEnv;
/* printf("In JavaClass_setProperty\n"); */
/* Get the Java per-thread environment pointer for this JSContext */
jsj_MapJSContextToJSJThread(cx, &jEnv);
if (!jEnv)
return JS_FALSE;
if (!lookup_static_member_by_id(cx, jEnv, obj, &class_descriptor, id, &member_descriptor))
return JS_FALSE;
/* Check for the case where there is a method with the given name, but no field
with that name */
if (!member_descriptor->field)
goto no_such_field;
/* Silently fail if field value is final (immutable), as required by ECMA spec */
if (member_descriptor->field->modifiers & ACC_FINAL)
return JS_TRUE;
java_class = class_descriptor->java_class;
return jsj_SetJavaFieldValue(cx, jEnv, member_descriptor->field, java_class, *vp);
no_such_field:
JS_IdToValue(cx, id, &idval);
member_name = JS_GetStringBytes(JSVAL_TO_STRING(idval));
JS_ReportError(cx, "No static field named \"%s\" in Java class %s",
member_name, class_descriptor->name);
return JS_FALSE;
}
/*
* Free the private native data associated with the JavaPackage object.
*/
PR_STATIC_CALLBACK(void)
JavaClass_finalize(JSContext *cx, JSObject *obj)
{
JNIEnv *jEnv;
JavaClassDescriptor *class_descriptor = JS_GetPrivate(cx, obj);
if (!class_descriptor)
return;
/* Get the Java per-thread environment pointer for this JSContext */
jsj_MapJSContextToJSJThread(cx, &jEnv);
if (!jEnv)
return;
/* printf("Finalizing %s\n", class_descriptor->name); */
jsj_ReleaseJavaClassDescriptor(cx, jEnv, class_descriptor);
}
static JSBool
JavaClass_lookupProperty(JSContext *cx, JSObject *obj, jsid id,
JSObject **objp, JSProperty **propp
#if defined JS_THREADSAFE && defined DEBUG
, const char *file, uintN line
#endif
)
{
JNIEnv *jEnv;
JSErrorReporter old_reporter;
/* printf("In JavaClass_lookupProperty()\n"); */
/* Get the Java per-thread environment pointer for this JSContext */
jsj_MapJSContextToJSJThread(cx, &jEnv);
if (!jEnv)
return JS_FALSE;
old_reporter = JS_SetErrorReporter(cx, NULL);
if (lookup_static_member_by_id(cx, jEnv, obj, NULL, id, NULL)) {
*objp = obj;
*propp = (JSProperty*)1;
} else {
*objp = NULL;
*propp = NULL;
}
JS_SetErrorReporter(cx, old_reporter);
return JS_TRUE;
}
static JSBool
JavaClass_defineProperty(JSContext *cx, JSObject *obj, jsid id, jsval value,
JSPropertyOp getter, JSPropertyOp setter,
uintN attrs, JSProperty **propp)
{
JS_ReportError(cx, "Cannot define a new property in a JavaClass");
return JS_FALSE;
}
static JSBool
JavaClass_getAttributes(JSContext *cx, JSObject *obj, jsid id,
JSProperty *prop, uintN *attrsp)
{
/* We don't maintain JS property attributes for Java class members */
*attrsp = JSPROP_PERMANENT|JSPROP_ENUMERATE;
return JS_FALSE;
}
static JSBool
JavaClass_setAttributes(JSContext *cx, JSObject *obj, jsid id,
JSProperty *prop, uintN *attrsp)
{
/* We don't maintain JS property attributes for Java class members */
if (*attrsp != (JSPROP_PERMANENT|JSPROP_ENUMERATE)) {
PR_ASSERT(0);
return JS_FALSE;
}
/* Silently ignore all setAttribute attempts */
return JS_TRUE;
}
static JSBool
JavaClass_deleteProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
{
JSVersion version = JS_GetVersion(cx);
*vp = JSVAL_FALSE;
if (!JSVERSION_IS_ECMA(version)) {
JS_ReportError(cx, "Properties of JavaClass objects may not be deleted");
return JS_FALSE;
} else {
/* Attempts to delete permanent properties are silently ignored
by ECMAScript. */
return JS_TRUE;
}
}
static JSBool
JavaClass_defaultValue(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
{
/* printf("In JavaClass_defaultValue()\n"); */
return JavaClass_convert(cx, obj, JSTYPE_STRING, vp);
}
static JSBool
JavaClass_newEnumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
jsval *statep, jsid *idp)
{
JavaMemberDescriptor *member_descriptor;
JavaClassDescriptor *class_descriptor;
JNIEnv *jEnv;
class_descriptor = JS_GetPrivate(cx, obj);
/* Check for prototype JavaClass object */
if (!class_descriptor) {
*statep = JSVAL_NULL;
if (idp)
*idp = INT_TO_JSVAL(0);
return JS_TRUE;
}
switch(enum_op) {
case JSENUMERATE_INIT:
/* Get the Java per-thread environment pointer for this JSContext */
jsj_MapJSContextToJSJThread(cx, &jEnv);
if (!jEnv)
return JS_FALSE;
member_descriptor = jsj_GetClassStaticMembers(cx, jEnv, class_descriptor);
*statep = PRIVATE_TO_JSVAL(member_descriptor);
if (idp)
*idp = INT_TO_JSVAL(class_descriptor->num_instance_members);
return JS_TRUE;
case JSENUMERATE_NEXT:
member_descriptor = JSVAL_TO_PRIVATE(*statep);
if (member_descriptor) {
*idp = member_descriptor->id;
*statep = PRIVATE_TO_JSVAL(member_descriptor->next);
return JS_TRUE;
}
/* Fall through ... */
case JSENUMERATE_DESTROY:
*statep = JSVAL_NULL;
return JS_TRUE;
default:
PR_ASSERT(0);
return JS_FALSE;
}
}
static JSBool
JavaClass_checkAccess(JSContext *cx, JSObject *obj, jsid id,
JSAccessMode mode, jsval *vp, uintN *attrsp)
{
switch (mode) {
case JSACC_WATCH:
JS_ReportError(cx, "Cannot place watchpoints on JavaClass object properties");
return JS_FALSE;
case JSACC_IMPORT:
JS_ReportError(cx, "Cannot export a JavaClass object's properties");
return JS_FALSE;
default:
return JS_TRUE;
}
}
/*
* Implement the JavaScript instanceof operator for JavaClass objects by using
* the equivalent Java instanceof operation.
*/
static JSBool
JavaClass_hasInstance(JSContext *cx, JSObject *obj, jsval candidate_jsval,
JSBool *has_instancep)
{
JavaClassDescriptor *class_descriptor;
JavaObjectWrapper *java_wrapper;
JSClass *js_class;
JSBool has_instance;
JSObject *candidate_obj;
jclass java_class;
jobject java_obj;
JNIEnv *jEnv;
has_instance = JS_FALSE;
class_descriptor = JS_GetPrivate(cx, obj);
if (!class_descriptor) {
JS_ReportError(cx, "illegal operation on JavaClass prototype object");
return JS_FALSE;
}
/*
* Make sure that the thing to the left of the instanceof operator is a
* Java object.
*/
if (!JSVAL_IS_OBJECT(candidate_jsval))
goto done;
candidate_obj = JSVAL_TO_OBJECT(candidate_jsval);
js_class = JS_GetClass(candidate_obj);
if ((js_class != &JavaObject_class) && (js_class != &JavaArray_class))
goto done;
java_class = class_descriptor->java_class;
java_wrapper = JS_GetPrivate(cx, candidate_obj);
if (!java_wrapper) {
JS_ReportError(cx, "illegal operation on prototype object");
return JS_FALSE;
}
java_obj = java_wrapper->java_obj;
/* Get JNI pointer */
jsj_MapJSContextToJSJThread(cx, &jEnv);
has_instance = (*jEnv)->IsInstanceOf(jEnv, java_obj, java_class);
done:
*has_instancep = has_instance;
return JS_TRUE;
}
JSObjectOps JavaClass_ops = {
/* Mandatory non-null function pointer members. */
NULL, /* newObjectMap */
NULL, /* destroyObjectMap */
JavaClass_lookupProperty,
JavaClass_defineProperty,
JavaClass_getPropertyById, /* getProperty */
JavaClass_setPropertyById, /* setProperty */
JavaClass_getAttributes,
JavaClass_setAttributes,
JavaClass_deleteProperty,
JavaClass_defaultValue,
JavaClass_newEnumerate,
JavaClass_checkAccess,
/* Optionally non-null members start here. */
NULL, /* thisObject */
NULL, /* dropProperty */
jsj_JavaConstructorWrapper, /* call */
jsj_JavaConstructorWrapper, /* construct */
NULL, /* xdrObject */
JavaClass_hasInstance, /* hasInstance */
};
static JSObjectOps *
JavaClass_getObjectOps(JSContext *cx, JSClass *clazz)
{
return &JavaClass_ops;
}
JSClass JavaClass_class = {
"JavaClass", JSCLASS_HAS_PRIVATE,
NULL, NULL, NULL, NULL,
NULL, NULL, JavaClass_convert, JavaClass_finalize,
JavaClass_getObjectOps,
};
static JSObject *
jsj_new_JavaClass(JSContext *cx, JNIEnv *jEnv, JSObject* parent_obj,
JavaClassDescriptor *class_descriptor)
{
JSObject *JavaClass_obj;
JavaClass_obj = JS_NewObject(cx, &JavaClass_class, 0, parent_obj);
if (!JavaClass_obj)
return NULL;
JS_SetPrivate(cx, JavaClass_obj, (void *)class_descriptor);
#ifdef DEBUG
/* printf("JavaClass \'%s\' created\n", class_descriptor->name); */
#endif
return JavaClass_obj;
}
JSObject *
jsj_define_JavaClass(JSContext *cx, JNIEnv *jEnv, JSObject* parent_obj,
const char *simple_class_name,
jclass java_class)
{
JavaClassDescriptor *class_descriptor;
JSObject *JavaClass_obj;
class_descriptor = jsj_GetJavaClassDescriptor(cx, jEnv, java_class);
if (!class_descriptor)
return NULL;
JavaClass_obj = jsj_new_JavaClass(cx, jEnv, parent_obj, class_descriptor);
if (!JavaClass_obj)
return NULL;
if (!JS_DefineProperty(cx, parent_obj, simple_class_name,
OBJECT_TO_JSVAL(JavaClass_obj), 0, 0,
JSPROP_PERMANENT|JSPROP_READONLY|JSPROP_ENUMERATE))
return NULL;
return JavaClass_obj;
}
/*
* The getClass() native JS method is defined as a property of the global
* object. Given a JavaObject it returns the corresponding JavaClass. This
* is useful for accessing static methods and fields.
*
* js> getClass(new java.lang.String("foo"))
* [JavaClass java.lang.String]
*/
static JSBool
getClass(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
JSObject *obj_arg, *JavaClass_obj;
JavaObjectWrapper *java_wrapper;
JavaClassDescriptor *class_descriptor;
JNIEnv *jEnv;
jsj_MapJSContextToJSJThread(cx, &jEnv);
if (!jEnv)
return JS_FALSE;
if (argc != 1 ||
!JSVAL_IS_OBJECT(argv[0]) ||
!(obj_arg = JSVAL_TO_OBJECT(argv[0])) ||
(!JS_InstanceOf(cx, obj_arg, &JavaObject_class, 0) &&
!JS_InstanceOf(cx, obj_arg, &JavaArray_class, 0))) {
JS_ReportError(cx, "getClass expects a Java object argument");
return JS_FALSE;
}
java_wrapper = JS_GetPrivate(cx, obj_arg);
if (!java_wrapper) {
JS_ReportError(cx, "getClass called on prototype object");
return JS_FALSE;
}
class_descriptor = java_wrapper->class_descriptor;
JavaClass_obj = jsj_new_JavaClass(cx, jEnv, NULL, class_descriptor);
if (!JavaClass_obj)
return JS_FALSE;
*rval = OBJECT_TO_JSVAL(JavaClass_obj);
return JS_TRUE;
}
extern PR_IMPORT_DATA(JSObjectOps) js_ObjectOps;
JSBool
jsj_init_JavaClass(JSContext *cx, JSObject *global_obj)
{
JavaClass_ops.newObjectMap = js_ObjectOps.newObjectMap;
JavaClass_ops.destroyObjectMap = js_ObjectOps.destroyObjectMap;
/* Define JavaClass class */
if (!JS_InitClass(cx, global_obj, 0, &JavaClass_class, 0, 0, 0, 0, 0, 0))
return JS_FALSE;
if (!JS_DefineFunction(cx, global_obj, "getClass", getClass, 0,
JSPROP_READONLY))
return JS_FALSE;
return jsj_InitJavaClassReflectionsTable();
}

View File

@@ -0,0 +1,134 @@
/* -*- Mode: C; tab-width: 8 -*-
* Copyright (C) 1998 Netscape Communications Corporation, All Rights Reserved.
*/
/*
* This file is part of the Java-vendor-neutral implementation of LiveConnect
*
* It contains the native code implementation of JS's JavaMember class.
* JavaMember's are a strange beast required only to handle the special case
* of a public field and a public method that appear in the same class and
* have the same name. When such a field/method is used in Java, the compiler
* can statically determine from context whether the field or the method is
* being referenced, but that is not possible with JavaScript. For example:
*
* ambiguousVal = javaObj.fieldOrMethod; // ambiguousVal is a JavaMember object
* a = ambiguousVal(); // ambiguousVal used as a method value
* b = ambiguousVal + 4; // ambiguousVal used as a field value
*
* A JavaMember instance carries both the captured value of the Java field and
* the method value until the context that the value is to be used in is known,
* at which point conversion forces the use of one or the other.
*/
#include <stdlib.h>
#include <string.h>
#include "jsj_private.h" /* LiveConnect internals */
/* Private, native portion of a JavaMember */
typedef struct JavaMethodOrFieldValue {
jsval method_val;
jsval field_val;
} JavaMethodOrFieldValue;
JSObject *
jsj_CreateJavaMember(JSContext *cx, jsval method_val, jsval field_val)
{
JavaMethodOrFieldValue *member_val;
JSObject *JavaMember_obj;
member_val = (JavaMethodOrFieldValue *)JS_malloc(cx, sizeof(*member_val));
if (!member_val)
return NULL;
JavaMember_obj = JS_NewObject(cx, &JavaMember_class, 0, 0);
if (!JavaMember_obj) {
JS_free(cx, member_val);
return NULL;
}
JS_SetPrivate(cx, JavaMember_obj, (void *)member_val);
member_val->method_val = method_val;
JS_AddRoot(cx, &member_val->method_val);
member_val->field_val = field_val;
if (JSVAL_IS_GCTHING(field_val))
JS_AddRoot(cx, &member_val->field_val);
return JavaMember_obj;
}
static void
JavaMember_finalize(JSContext *cx, JSObject *obj)
{
JavaMethodOrFieldValue *member_val;
JNIEnv *jEnv;
jsj_MapJSContextToJSJThread(cx, &jEnv);
if (!jEnv)
return;
member_val = JS_GetPrivate(cx, obj);
if (!member_val)
return;
JS_RemoveRoot(cx, &member_val->method_val);
if (JSVAL_IS_GCTHING(member_val->method_val))
JS_RemoveRoot(cx, &member_val->method_val);
JS_free(cx, member_val);
}
static JSBool
JavaMember_convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
{
JavaMethodOrFieldValue *member_val;
member_val = JS_GetPrivate(cx, obj);
if (!member_val) {
if (type == JSTYPE_OBJECT) {
*vp = OBJECT_TO_JSVAL(obj);
return JS_TRUE;
}
JS_ReportError(cx, "illegal operation on JavaObject prototype object");
return JS_FALSE;
}
switch (type) {
case JSTYPE_VOID:
case JSTYPE_STRING:
case JSTYPE_NUMBER:
case JSTYPE_BOOLEAN:
case JSTYPE_OBJECT:
*vp = member_val->field_val;
return JS_TRUE;
case JSTYPE_FUNCTION:
*vp = member_val->method_val;
return JS_TRUE;
default:
PR_ASSERT(0);
return JS_FALSE;
}
}
JSClass JavaMember_class = {
"JavaMember", JSCLASS_HAS_PRIVATE,
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
JS_EnumerateStub, JS_ResolveStub,
JavaMember_convert, JavaMember_finalize
};
extern PR_IMPORT_DATA(JSObjectOps) js_ObjectOps;
JSBool
jsj_init_JavaMember(JSContext *cx, JSObject *global_obj)
{
if (!JS_InitClass(cx, global_obj,
0, &JavaMember_class, 0, 0,
0, 0,
0, 0))
return JS_FALSE;
return JS_TRUE;
}

View File

@@ -0,0 +1,686 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
/*
* This file is part of the Java-vendor-neutral implementation of LiveConnect
*
* It contains the native code implementation of JS's JavaObject class.
*
* An instance of JavaObject is the JavaScript reflection of a Java object.
*
*/
#include <stdlib.h>
#include <string.h>
#include "jsj_private.h" /* LiveConnect internals */
#include "jsj_hash.h" /* Hash table with Java object as key */
/*
* This is a hash table that maps from Java objects to JS objects.
* It is used to ensure that the same JS object is obtained when a Java
* object is reflected more than once, so that JS object equality tests
* work in the expected manner, i.e. the "==" and "===" operators.
*
* The table entry keys are Java objects (of type jobject) and the entry values
* are JSObject pointers. Because the jobject type is an opaque handle and
* not necessarily a pointer, the hashing and key comparison functions must
* invoke the appropriate JVM functions.
*
* When the corresponding JS object instance is finalized, the entry is
* removed from the table, and a Java GC root for the Java object is removed.
*/
static JSJHashTable *java_obj_reflections = NULL;
#ifdef JS_THREADSAFE
static PRMonitor *java_obj_reflections_monitor = NULL;
#endif
static JSBool
init_java_obj_reflections_table()
{
java_obj_reflections =
JSJ_NewHashTable(512, jsj_HashJavaObject, jsj_JavaObjectComparator,
NULL, NULL, NULL);
if (!java_obj_reflections)
return JS_FALSE;
#ifdef JS_THREADSAFE
java_obj_reflections_monitor = PR_NewNamedMonitor("java_obj_reflections");
if (!java_obj_reflections_monitor) {
PR_HashTableDestroy(java_obj_reflections);
return JS_FALSE;
}
#endif
return JS_TRUE;
}
JSObject *
jsj_WrapJavaObject(JSContext *cx,
JNIEnv *jEnv,
jobject java_obj,
jclass java_class)
{
JSJHashNumber hash_code;
JSClass *js_class;
JSObject *js_wrapper_obj;
JavaObjectWrapper *java_wrapper;
JavaClassDescriptor *class_descriptor;
JSJHashEntry *he, **hep;
js_wrapper_obj = NULL;
hash_code = jsj_HashJavaObject((void*)java_obj, (void*)jEnv);
#ifdef JS_THREADSAFE
PR_EnterMonitor(java_obj_reflections_monitor);
#endif
hep = JSJ_HashTableRawLookup(java_obj_reflections,
hash_code, java_obj, (void*)jEnv);
he = *hep;
if (he) {
js_wrapper_obj = (JSObject *)he->value;
if (js_wrapper_obj)
goto done;
}
/* No existing reflection found. Construct a new one */
class_descriptor = jsj_GetJavaClassDescriptor(cx, jEnv, java_class);
if (!class_descriptor)
goto done;
if (class_descriptor->type == JAVA_SIGNATURE_ARRAY) {
js_class = &JavaArray_class;
} else {
PR_ASSERT(class_descriptor->type == JAVA_SIGNATURE_CLASS);
js_class = &JavaObject_class;
}
/* Create new JS object to reflect Java object */
js_wrapper_obj = JS_NewObject(cx, js_class, NULL, NULL);
if (!js_wrapper_obj)
goto done;
/* Create private, native portion of JavaObject */
java_wrapper =
(JavaObjectWrapper *)JS_malloc(cx, sizeof(JavaObjectWrapper));
if (!java_wrapper) {
jsj_ReleaseJavaClassDescriptor(cx, jEnv, class_descriptor);
goto done;
}
JS_SetPrivate(cx, js_wrapper_obj, java_wrapper);
java_wrapper->class_descriptor = class_descriptor;
java_obj = (*jEnv)->NewGlobalRef(jEnv, java_obj);
java_wrapper->java_obj = java_obj;
if (!java_obj)
goto out_of_memory;
/* Add the JavaObject to the hash table */
he = JSJ_HashTableRawAdd(java_obj_reflections, hep, hash_code,
java_obj, js_wrapper_obj, (void*)jEnv);
if (!he) {
(*jEnv)->DeleteGlobalRef(jEnv, java_obj);
goto out_of_memory;
}
done:
#ifdef JS_THREADSAFE
PR_ExitMonitor(java_obj_reflections_monitor);
#endif
return js_wrapper_obj;
out_of_memory:
/* No need to free js_wrapper_obj, as it will be finalized by GC. */
JS_ReportOutOfMemory(cx);
js_wrapper_obj = NULL;
goto done;
}
static void
remove_java_obj_reflection_from_hashtable(jobject java_obj, JNIEnv *jEnv)
{
JSJHashNumber hash_code;
JSJHashEntry *he, **hep;
hash_code = jsj_HashJavaObject((void*)java_obj, (void*)jEnv);
#ifdef JS_THREADSAFE
PR_EnterMonitor(java_obj_reflections_monitor);
#endif
hep = JSJ_HashTableRawLookup(java_obj_reflections, hash_code,
java_obj, (void*)jEnv);
he = *hep;
PR_ASSERT(he);
if (he)
JSJ_HashTableRawRemove(java_obj_reflections, hep, he, (void*)jEnv);
#ifdef JS_THREADSAFE
PR_ExitMonitor(java_obj_reflections_monitor);
#endif
}
void
JavaObject_finalize(JSContext *cx, JSObject *obj)
{
JavaObjectWrapper *java_wrapper;
jobject java_obj;
JNIEnv *jEnv;
jsj_MapJSContextToJSJThread(cx, &jEnv);
if (!jEnv)
return;
java_wrapper = JS_GetPrivate(cx, obj);
if (!java_wrapper)
return;
java_obj = java_wrapper->java_obj;
if (java_obj) {
remove_java_obj_reflection_from_hashtable(java_obj, jEnv);
(*jEnv)->DeleteGlobalRef(jEnv, java_obj);
}
jsj_ReleaseJavaClassDescriptor(cx, jEnv, java_wrapper->class_descriptor);
JS_free(cx, java_wrapper);
}
/* Trivial helper for jsj_DiscardJavaObjReflections(), below */
static PRIntn
enumerate_remove_java_obj(JSJHashEntry *he, PRIntn i, void *arg)
{
JNIEnv *jEnv = (JNIEnv*)arg;
jobject java_obj;
JavaObjectWrapper *java_wrapper;
JSObject *java_wrapper_obj;
java_wrapper_obj = (JSObject *)he->value;
java_wrapper = JS_GetPrivate(NULL, java_wrapper_obj);
java_obj = java_wrapper->java_obj;
(*jEnv)->DeleteGlobalRef(jEnv, java_obj);
java_wrapper->java_obj = NULL;
return HT_ENUMERATE_REMOVE;
}
/* This shutdown routine discards all JNI references to Java objects
that have been reflected into JS, even if there are still references
to them from JS. */
void
jsj_DiscardJavaObjReflections(JNIEnv *jEnv)
{
if (java_obj_reflections) {
JSJ_HashTableEnumerateEntries(java_obj_reflections,
enumerate_remove_java_obj,
(void*)jEnv);
JSJ_HashTableDestroy(java_obj_reflections);
java_obj_reflections = NULL;
}
}
PR_CALLBACK JSBool
JavaObject_convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
{
JavaObjectWrapper *java_wrapper;
JavaClassDescriptor *class_descriptor;
jobject java_obj;
JNIEnv *jEnv;
/* Get the Java per-thread environment pointer for this JSContext */
jsj_MapJSContextToJSJThread(cx, &jEnv);
if (!jEnv)
return JS_FALSE;
java_wrapper = JS_GetPrivate(cx, obj);
if (!java_wrapper) {
if (type == JSTYPE_OBJECT) {
*vp = OBJECT_TO_JSVAL(obj);
return JS_TRUE;
}
JS_ReportError(cx, "illegal operation on JavaObject prototype object");
return JS_FALSE;
}
java_obj = java_wrapper->java_obj;
class_descriptor = java_wrapper->class_descriptor;
switch (type) {
case JSTYPE_OBJECT:
*vp = OBJECT_TO_JSVAL(obj);
return JS_TRUE;
case JSTYPE_FUNCTION:
JS_ReportError(cx, "can't convert Java object to function");
return JS_FALSE;
case JSTYPE_VOID:
case JSTYPE_STRING:
/* Either extract a C-string from the java.lang.String object
or call the Java toString() method */
return jsj_ConvertJavaObjectToJSString(cx, jEnv, class_descriptor, java_obj, vp);
case JSTYPE_NUMBER:
/* Call Java doubleValue() method, if applicable */
return jsj_ConvertJavaObjectToJSNumber(cx, jEnv, class_descriptor, java_obj, vp);
case JSTYPE_BOOLEAN:
/* Call booleanValue() method, if applicable */
return jsj_ConvertJavaObjectToJSBoolean(cx, jEnv, class_descriptor, java_obj, vp);
default:
PR_ASSERT(0);
return JS_FALSE;
}
}
static JSBool
lookup_member_by_id(JSContext *cx, JNIEnv *jEnv, JSObject *obj,
JavaObjectWrapper **java_wrapperp,
jsid id,
JavaMemberDescriptor **member_descriptorp)
{
jsval idval;
JavaObjectWrapper *java_wrapper;
JavaMemberDescriptor *member_descriptor;
const char *member_name, *property_name;
JavaClassDescriptor *class_descriptor;
java_wrapper = JS_GetPrivate(cx, obj);
if (!java_wrapper) {
if (JS_IdToValue(cx, id, &idval) && JSVAL_IS_STRING(idval) &&
(property_name = JS_GetStringBytes(JSVAL_TO_STRING(idval))) != NULL) {
if (!strcmp(property_name, "constructor")) {
*java_wrapperp = NULL;
*member_descriptorp = NULL;
return JS_TRUE;
}
}
JS_ReportError(cx, "illegal operation on JavaObject prototype object");
return JS_FALSE;
}
class_descriptor = java_wrapper->class_descriptor;
PR_ASSERT(class_descriptor->type == JAVA_SIGNATURE_CLASS ||
class_descriptor->type == JAVA_SIGNATURE_ARRAY);
member_descriptor = jsj_LookupJavaMemberDescriptorById(cx, jEnv, class_descriptor, id);
if (!member_descriptor) {
JS_IdToValue(cx, id, &idval);
if (!JSVAL_IS_STRING(idval)) {
JS_ReportError(cx, "invalid JavaObject property expression. "
"(methods and field properties of a JavaObject object can only be strings)");
return JS_FALSE;
}
member_name = JS_GetStringBytes(JSVAL_TO_STRING(idval));
JS_ReportError(cx, "Java class %s has no public instance field or "
"method named \"%s\"",
class_descriptor->name, member_name);
return JS_FALSE;
}
/* Success. Handle the multiple return values */
if (java_wrapperp)
*java_wrapperp = java_wrapper;
if (member_descriptorp)
*member_descriptorp = member_descriptor;
return JS_TRUE;
}
PR_CALLBACK JSBool
JavaObject_getPropertyById(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
{
jobject java_obj;
JavaMemberDescriptor *member_descriptor;
JavaObjectWrapper *java_wrapper;
JNIEnv *jEnv;
JSObject *funobj;
jsval field_val, method_val;
JSBool success;
/* printf("In JavaObject_getProperty\n"); */
/* Get the Java per-thread environment pointer for this JSContext */
jsj_MapJSContextToJSJThread(cx, &jEnv);
if (!jEnv)
return JS_FALSE;
if (!lookup_member_by_id(cx, jEnv, obj, &java_wrapper, id, &member_descriptor))
return JS_FALSE;
/* Handle access to "constructor" property of prototype object with
silent failure. */
if (!member_descriptor) {
*vp = JSVAL_VOID;
return JS_TRUE;
}
java_obj = java_wrapper->java_obj;
field_val = method_val = JSVAL_VOID;
/* If a field member, get the value of the field */
if (member_descriptor->field) {
success = jsj_GetJavaFieldValue(cx, jEnv, member_descriptor->field, java_obj, &field_val);
if (!success)
return JS_FALSE;
}
/* If a method member, build a wrapper around the Java method */
if (member_descriptor->methods) {
/* Create a function object with this JavaObject as its parent, so that
JSFUN_BOUND_METHOD binds it as the default 'this' for the function. */
funobj = JS_CloneFunctionObject(cx, member_descriptor->invoke_func_obj, obj);
if (!funobj)
return JS_FALSE;
method_val = OBJECT_TO_JSVAL(funobj);
}
#if TEST_JAVAMEMBER
/* Always create a JavaMember object, even though it's inefficient */
obj = jsj_CreateJavaMember(cx, method_val, field_val);
if (!obj)
return JS_FALSE;
*vp = OBJECT_TO_JSVAL(obj);
#else /* !TEST_JAVAMEMBER */
if (member_descriptor->field) {
if (!member_descriptor->methods) {
/* Return value of Java field */
*vp = field_val;
} else {
/* Handle special case of access to a property that could refer
to either a Java field or a method that share the same name.
In Java, such ambiguity is not possible because the compiler
can statically determine which is being accessed. */
obj = jsj_CreateJavaMember(cx, method_val, field_val);
if (!obj)
return JS_FALSE;
*vp = OBJECT_TO_JSVAL(obj);
}
} else {
/* Return wrapper around Java method */
*vp = method_val;
}
#endif /* !TEST_JAVAMEMBER */
return JS_TRUE;
}
PR_STATIC_CALLBACK(JSBool)
JavaObject_setPropertyById(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
{
jobject java_obj;
const char *member_name;
JavaObjectWrapper *java_wrapper;
JavaClassDescriptor *class_descriptor;
JavaMemberDescriptor *member_descriptor;
jsval idval;
JNIEnv *jEnv;
/* printf("In JavaObject_setProperty\n"); */
/* Get the Java per-thread environment pointer for this JSContext */
jsj_MapJSContextToJSJThread(cx, &jEnv);
if (!jEnv)
return JS_FALSE;
if (!lookup_member_by_id(cx, jEnv, obj, &java_wrapper, id, &member_descriptor))
return JS_FALSE;
/* Check for the case where there is a method with the give name, but no field
with that name */
if (!member_descriptor->field)
goto no_such_field;
/* Silently fail if field value is final (immutable), as required by ECMA spec */
if (member_descriptor->field->modifiers & ACC_FINAL)
return JS_TRUE;
java_obj = java_wrapper->java_obj;
return jsj_SetJavaFieldValue(cx, jEnv, member_descriptor->field, java_obj, *vp);
no_such_field:
JS_IdToValue(cx, id, &idval);
member_name = JS_GetStringBytes(JSVAL_TO_STRING(idval));
class_descriptor = java_wrapper->class_descriptor;
JS_ReportError(cx, "No instance field named \"%s\" in Java class %s",
member_name, class_descriptor->name);
return JS_FALSE;
}
static JSBool
JavaObject_lookupProperty(JSContext *cx, JSObject *obj, jsid id,
JSObject **objp, JSProperty **propp
#if defined JS_THREADSAFE && defined DEBUG
, const char *file, uintN line
#endif
)
{
JNIEnv *jEnv;
JSErrorReporter old_reporter;
/* printf("In JavaObject_lookupProperty()\n"); */
/* Get the Java per-thread environment pointer for this JSContext */
jsj_MapJSContextToJSJThread(cx, &jEnv);
if (!jEnv)
return JS_FALSE;
old_reporter = JS_SetErrorReporter(cx, NULL);
if (lookup_member_by_id(cx, jEnv, obj, NULL, id, NULL)) {
*objp = obj;
*propp = (JSProperty*)1;
} else {
*objp = NULL;
*propp = NULL;
}
JS_SetErrorReporter(cx, old_reporter);
return JS_TRUE;
}
static JSBool
JavaObject_defineProperty(JSContext *cx, JSObject *obj, jsid id, jsval value,
JSPropertyOp getter, JSPropertyOp setter,
uintN attrs, JSProperty **propp)
{
JS_ReportError(cx, "Cannot define a new property in a JavaObject");
return JS_FALSE;
}
static JSBool
JavaObject_getAttributes(JSContext *cx, JSObject *obj, jsid id,
JSProperty *prop, uintN *attrsp)
{
/* We don't maintain JS property attributes for Java class members */
*attrsp = JSPROP_PERMANENT|JSPROP_ENUMERATE;
return JS_FALSE;
}
static JSBool
JavaObject_setAttributes(JSContext *cx, JSObject *obj, jsid id,
JSProperty *prop, uintN *attrsp)
{
/* We don't maintain JS property attributes for Java class members */
if (*attrsp != (JSPROP_PERMANENT|JSPROP_ENUMERATE)) {
PR_ASSERT(0);
return JS_FALSE;
}
/* Silently ignore all setAttribute attempts */
return JS_TRUE;
}
static JSBool
JavaObject_deleteProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
{
JSVersion version = JS_GetVersion(cx);
*vp = JSVAL_FALSE;
if (!JSVERSION_IS_ECMA(version)) {
JS_ReportError(cx, "Properties of JavaObject objects may not be deleted");
return JS_FALSE;
} else {
/* Attempts to delete permanent properties are silently ignored
by ECMAScript. */
return JS_TRUE;
}
}
static JSBool
JavaObject_defaultValue(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
{
/* printf("In JavaObject_defaultValue()\n"); */
return JavaObject_convert(cx, obj, type, vp);
}
static JSBool
JavaObject_newEnumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
jsval *statep, jsid *idp)
{
JavaObjectWrapper *java_wrapper;
JavaMemberDescriptor *member_descriptor;
JavaClassDescriptor *class_descriptor;
JNIEnv *jEnv;
java_wrapper = JS_GetPrivate(cx, obj);
/* Check for prototype object */
if (!java_wrapper) {
*statep = JSVAL_NULL;
if (idp)
*idp = INT_TO_JSVAL(0);
return JS_TRUE;
}
class_descriptor = java_wrapper->class_descriptor;
switch(enum_op) {
case JSENUMERATE_INIT:
/* Get the Java per-thread environment pointer for this JSContext */
jsj_MapJSContextToJSJThread(cx, &jEnv);
if (!jEnv)
return JS_FALSE;
member_descriptor = jsj_GetClassInstanceMembers(cx, jEnv, class_descriptor);
*statep = PRIVATE_TO_JSVAL(member_descriptor);
if (idp)
*idp = INT_TO_JSVAL(class_descriptor->num_instance_members);
return JS_TRUE;
case JSENUMERATE_NEXT:
member_descriptor = JSVAL_TO_PRIVATE(*statep);
if (member_descriptor) {
*idp = member_descriptor->id;
*statep = PRIVATE_TO_JSVAL(member_descriptor->next);
return JS_TRUE;
}
/* Fall through ... */
case JSENUMERATE_DESTROY:
*statep = JSVAL_NULL;
return JS_TRUE;
default:
PR_ASSERT(0);
return JS_FALSE;
}
}
static JSBool
JavaObject_checkAccess(JSContext *cx, JSObject *obj, jsid id,
JSAccessMode mode, jsval *vp, uintN *attrsp)
{
switch (mode) {
case JSACC_WATCH:
JS_ReportError(cx, "Cannot place watchpoints on JavaObject object properties");
return JS_FALSE;
case JSACC_IMPORT:
JS_ReportError(cx, "Cannot export a JavaObject object's properties");
return JS_FALSE;
default:
return JS_TRUE;
}
}
JSObjectOps JavaObject_ops = {
/* Mandatory non-null function pointer members. */
NULL, /* newObjectMap */
NULL, /* destroyObjectMap */
JavaObject_lookupProperty,
JavaObject_defineProperty,
JavaObject_getPropertyById, /* getProperty */
JavaObject_setPropertyById, /* setProperty */
JavaObject_getAttributes,
JavaObject_setAttributes,
JavaObject_deleteProperty,
JavaObject_defaultValue,
JavaObject_newEnumerate,
JavaObject_checkAccess,
/* Optionally non-null members start here. */
NULL, /* thisObject */
NULL, /* dropProperty */
NULL, /* call */
NULL, /* construct */
NULL, /* xdrObject */
NULL, /* hasInstance */
};
static JSObjectOps *
JavaObject_getObjectOps(JSContext *cx, JSClass *clazz)
{
return &JavaObject_ops;
}
JSClass JavaObject_class = {
"JavaObject", JSCLASS_HAS_PRIVATE,
NULL, NULL, NULL, NULL,
NULL, NULL, JavaObject_convert, JavaObject_finalize,
JavaObject_getObjectOps,
};
extern PR_IMPORT_DATA(JSObjectOps) js_ObjectOps;
JSBool
jsj_init_JavaObject(JSContext *cx, JSObject *global_obj)
{
JavaObject_ops.newObjectMap = js_ObjectOps.newObjectMap;
JavaObject_ops.destroyObjectMap = js_ObjectOps.destroyObjectMap;
if (!JS_InitClass(cx, global_obj,
0, &JavaObject_class, 0, 0,
0, 0,
0, 0))
return JS_FALSE;
return init_java_obj_reflections_table();
}

View File

@@ -0,0 +1,500 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
/* This file is part of the Java-vendor-neutral implementation of LiveConnect
*
* It contains the native code implementation of the JavaPackage class.
*
* A JavaPackage is JavaScript's representation of a Java package. The
* JavaPackage object contains only a string, which is the path to the package,
* e.g. "java/lang". The JS properties of a JavaPackage are either nested packages
* or a JavaClass object, which represents the path to a Java class.
*
* Note that there is no equivalent to a JavaPackage object in Java. Example:
* Although there are instances of java.lang.String and there are static methods
* of java.lang.String that can be invoked, there's no such thing as a java.lang
* object in Java that exists at run time.
*
*/
#include <stdlib.h>
#include <string.h>
#include "jsj_private.h" /* LiveConnect internals */
#include "jsjava.h"
JSClass JavaPackage_class; /* Forward declaration */
/*
* The native part of a JavaPackage object. It gets stored in the object's
* private slot.
*/
typedef struct {
const char * path; /* e.g. "java/lang" or NULL if top level package */
int flags; /* e.g. PKG_SYSTEM, PKG_CLASS */
} JavaPackage_Private;
static JSObject *
define_JavaPackage(JSContext *cx, JSObject *parent_obj,
const char *obj_name, const char *path, int flags)
{
JSObject *package_obj;
JavaPackage_Private *package;
package_obj = JS_DefineObject(cx, parent_obj, obj_name, &JavaPackage_class, 0,
JSPROP_PERMANENT | JSPROP_READONLY);
if (!package_obj)
return NULL;
/* Attach private, native data to the JS object */
package = (JavaPackage_Private *)JS_malloc(cx, sizeof(JavaPackage_Private));
JS_SetPrivate(cx, package_obj, (void *)package);
if (path)
package->path = JS_strdup(cx, path);
else
package->path = "";
package->flags = flags;
/* Check for OOM */
if (!package->path) {
JS_DeleteProperty(cx, parent_obj, obj_name);
JS_free(cx, package);
return NULL;
}
return package_obj;
}
/* JavaPackage uses standard JS getProperty */
/*
* Don't allow user-defined properties to be set on Java package objects, e.g.
* it is illegal to write "java.lang.myProperty = 4". We probably could relax
* this restriction, but it's potentially confusing and not clearly useful.
*/
static JSBool
JavaPackage_setProperty(JSContext *cx, JSObject *obj, jsval slot, jsval *vp)
{
JavaPackage_Private *package = JS_GetPrivate(cx, obj);
if (!package) {
JS_ReportError(cx, "illegal attempt to add property to "
"JavaPackage prototype object");
return JS_FALSE;
}
JS_ReportError(cx, "You may not add properties to a JavaPackage object");
return JS_FALSE;
}
static JSBool quiet_resolve_failure;
/*
* Resolve a component name to be either the name of a class or a package.
*/
static JSBool
JavaPackage_resolve(JSContext *cx, JSObject *obj, jsval id)
{
JavaPackage_Private *package;
JSBool ok = JS_TRUE;
jclass jclazz;
char *subPath, *newPath;
const char *path;
JNIEnv *jEnv;
package = (JavaPackage_Private *)JS_GetPrivate(cx, obj);
if (!package)
return JS_TRUE;
if (!JSVAL_IS_STRING(id))
return JS_TRUE;
subPath = JS_GetStringBytes(JSVAL_TO_STRING(id));
/*
* There will be an attempt to invoke the toString() method when producing
* the string representation of a JavaPackage. When this occurs, avoid
* creating a bogus toString package. (This means that no one can ever
* create a package with the simple name "toString", but we'll live with
* that limitation.)
*/
if (!strcmp(subPath, "toString"))
return JS_FALSE;
path = package->path;
newPath = PR_smprintf("%s%s%s", path, (path[0] ? "/" : ""), subPath);
if (!newPath) {
JS_ReportOutOfMemory(cx);
return JS_FALSE;
}
jsj_MapJSContextToJSJThread(cx, &jEnv);
if (!jEnv)
return JS_FALSE;
/*
Unfortunately, Java provides no way to find out whether a particular
name is a package or not. The only way to tell is to try to load the
name as a class file and, if that fails, assume it's a package. This
makes things work as expected for the most part, but it has three
noticeable problems that keep coming up:
- You can refer to a package like java.lang.i.buried.paul without
generating a complaint. Of course, you'll never be able to refer to
any classes through it.
- An annoying consequence of the above is that misspelling a class name
results in a cryptic error about packages.
- In a browser context, i.e. where applets are involved, figuring out
whether something is a class may require looking for it over the net
using the current classloader. This means that the first time you
refer to java.lang.System in a js context, there will be an attempt
to search for [[DOCBASE]]/java.class on the server.
A solution is to explicitly tell jsjava the names of all the (local)
packages on the CLASSPATH. (Not implemented yet.)
*/
jclazz = (*jEnv)->FindClass(jEnv, newPath);
if (jclazz) {
JSObject *newClass;
newClass = jsj_define_JavaClass(cx, jEnv, obj, subPath, jclazz);
if (!newClass) {
ok = JS_FALSE;
goto out;
}
} else {
/* We assume that any failed attempt to load a class is because it
doesn't exist. If we wanted to do a better job, we would check
the exception type and make sure that it's NoClassDefFoundError */
(*jEnv)->ExceptionClear(jEnv);
/* beard: this has to be done here, so built-in classes will be defined. */
/* Painful hack for pre_define_java_packages() */
if (quiet_resolve_failure) {
ok = JS_FALSE;
goto out;
}
/*
* If there's no class of the given name, then we must be referring to
* a package. However, don't allow bogus sub-packages of pre-defined
* system packages to be created.
*/
if (JS_InstanceOf(cx, obj, &JavaPackage_class, NULL)) {
JavaPackage_Private *package;
package = JS_GetPrivate(cx, obj);
if (package->flags & PKG_SYSTEM) {
char *msg, *cp;
msg = PR_smprintf("No Java system package with name \"%s\" was identified "
"and no Java class with that name exists either",
newPath);
/* Check for OOM */
if (msg) {
/* Convert package of form "java/lang" to "java.lang" */
for (cp = msg; *cp != '\0'; cp++)
if (*cp == '/')
*cp = '.';
JS_ReportError(cx, msg);
free((char*)msg);
}
ok = JS_FALSE;
goto out;
}
}
if (!define_JavaPackage(cx, obj, subPath, newPath, 0)) {
ok = JS_FALSE;
goto out;
}
#ifdef DEBUG
/* printf("JavaPackage \'%s\' created\n", newPath); */
#endif
}
out:
free(newPath);
return ok;
}
static JSBool
JavaPackage_convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
{
JSString *str;
char *name, *cp;
JavaPackage_Private *package = JS_GetPrivate(cx, obj);
if (!package) {
fprintf(stderr, "JavaPackage_resolve: no private data!\n");
return JS_FALSE;
}
switch (type) {
/* Pretty-printing of JavaPackage */
case JSTYPE_VOID: /* Default value */
case JSTYPE_NUMBER:
case JSTYPE_STRING:
/* Convert '/' to '.' so that it looks like Java language syntax. */
if (!package->path)
break;
name = PR_smprintf("[JavaPackage %s]", package->path);
if (!name) {
JS_ReportOutOfMemory(cx);
return JS_FALSE;
}
for (cp = name; *cp != '\0'; cp++)
if (*cp == '/')
*cp = '.';
str = JS_NewString(cx, name, strlen(name));
if (!str) {
free(name);
/* It's not necessary to call JS_ReportOutOfMemory(), as
JS_NewString() will do so on failure. */
return JS_FALSE;
}
*vp = STRING_TO_JSVAL(str);
break;
case JSTYPE_OBJECT:
*vp = OBJECT_TO_JSVAL(obj);
break;
default:
break;
}
return JS_TRUE;
}
/*
* Free the private native data associated with the JavaPackage object.
*/
static void
JavaPackage_finalize(JSContext *cx, JSObject *obj)
{
JavaPackage_Private *package = JS_GetPrivate(cx, obj);
if (!package)
return;
if (package->path)
JS_free(cx, (char *)package->path);
JS_free(cx, package);
}
/*
* The definition of the JavaPackage class
*/
JSClass JavaPackage_class = {
"JavaPackage", JSCLASS_HAS_PRIVATE,
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JavaPackage_setProperty,
JS_EnumerateStub, JavaPackage_resolve,
JavaPackage_convert, JavaPackage_finalize
};
JavaPackageDef
standard_java_packages[] = {
{"java", NULL, PKG_USER},
{"java.applet", NULL, PKG_USER},
{"java.awt", NULL, PKG_USER},
{"java.awt.datatransfer",
NULL, PKG_SYSTEM},
{"java.awt.event", NULL, PKG_SYSTEM},
{"java.awt.image", NULL, PKG_SYSTEM},
{"java.awt.peer", NULL, PKG_SYSTEM},
{"java.beans", NULL, PKG_USER},
{"java.io", NULL, PKG_SYSTEM},
{"java.lang", NULL, PKG_USER},
{"java.lang.reflect", NULL, PKG_SYSTEM},
{"java.math", NULL, PKG_SYSTEM},
{"java.net", NULL, PKG_USER},
{"java.rmi", NULL, PKG_USER},
{"java.rmi.dgc", NULL, PKG_USER},
{"java.rmi.user", NULL, PKG_USER},
{"java.rmi.registry", NULL, PKG_USER},
{"java.rmi.server", NULL, PKG_USER},
{"java.security", NULL, PKG_USER},
{"java.security.acl", NULL, PKG_SYSTEM},
{"java.security.interfaces",
NULL, PKG_SYSTEM},
{"java.sql", NULL, PKG_USER},
{"java.text", NULL, PKG_USER},
{"java.text.resources", NULL, PKG_SYSTEM},
{"java.util", NULL, PKG_USER},
{"java.util.zip", NULL, PKG_SYSTEM},
{"netscape", NULL, PKG_USER},
{"netscape.applet", NULL, PKG_SYSTEM},
{"netscape.application",NULL, PKG_SYSTEM},
{"netscape.debug", NULL, PKG_SYSTEM},
{"netscape.javascript", NULL, PKG_SYSTEM},
{"netscape.ldap", NULL, PKG_SYSTEM},
{"netscape.misc", NULL, PKG_SYSTEM},
{"netscape.net", NULL, PKG_SYSTEM},
{"netscape.plugin", NULL, PKG_SYSTEM},
{"netscape.util", NULL, PKG_SYSTEM},
{"netscape.secfile", NULL, PKG_SYSTEM},
{"netscape.security", NULL, PKG_SYSTEM},
{"netscape.WAI", NULL, PKG_SYSTEM},
{"sun", NULL, PKG_USER},
{"Packages", "", PKG_USER},
{NULL, NULL, 0}
};
/*
* Pre-define a hierarchy of JavaPackage objects.
* Pre-defining a Java package at initialization time is not necessary, but
* it will make package lookup faster and, more importantly, will avoid
* unnecessary network accesses if classes are being loaded over the network.
*/
static JSBool
pre_define_java_packages(JSContext *cx, JSObject *global_obj,
JavaPackageDef *predefined_packages)
{
JSBool package_exists;
JSObject *parent_obj;
JavaPackageDef *package_def;
char *simple_name, *cp, *package_name, *path;
int flags;
if (!predefined_packages)
return JS_TRUE;
/* Iterate over all pre-defined Java packages */
for (package_def = predefined_packages; package_def->name; package_def++) {
package_name = path = NULL;
parent_obj = global_obj;
package_name = strdup(package_def->name);
if (!package_name)
goto out_of_memory;
/* Walk the chain of JavaPackage objects to get to the parent of the
rightmost sub-package in the fully-qualified package name. */
for (simple_name = strtok(package_name, "."); 1; simple_name = strtok(NULL, ".")) {
jsval v;
if (!simple_name) {
JS_ReportError(cx, "Package %s defined twice ?", package_name);
goto error;
}
/* Check to see if the sub-package already exists */
quiet_resolve_failure = JS_TRUE;
package_exists = JS_LookupProperty(cx, parent_obj, simple_name, &v) && JSVAL_IS_OBJECT(v);
quiet_resolve_failure = JS_FALSE;
if (package_exists) {
parent_obj = JSVAL_TO_OBJECT(v);
continue;
} else {
/* New package objects should only be created at the terminal
sub-package in a fully-qualified package-name */
if (strtok(NULL, ".")) {
JS_ReportError(cx, "Illegal predefined package definition for %s",
package_def->name);
goto error;
}
if (package_def->path) {
path = strdup(package_def->path);
if (!path)
goto out_of_memory;
} else {
/*
* The default path is specified, so create it from the
* fully-qualified package name.
*/
path = strdup(package_def->name);
if (!path)
goto out_of_memory;
/* Transform package name, e.g. "java.lang" ==> "java/lang" */
for (cp = path; *cp != '\0'; cp++) {
if (*cp == '.')
*cp = '/';
}
}
flags = package_def->flags;
parent_obj = define_JavaPackage(cx, parent_obj, simple_name, path, flags);
if (!parent_obj)
goto error;
free(path);
break;
}
}
free(package_name);
}
return JS_TRUE;
out_of_memory:
JS_ReportOutOfMemory(cx);
error:
JS_FREE_IF(cx, package_name);
JS_FREE_IF(cx, path);
return JS_FALSE;
}
static JSBool
JavaPackage_toString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
jsval *rval)
{
if (!JS_InstanceOf(cx, obj, &JavaPackage_class, argv))
return JS_FALSE;
return JavaPackage_convert(cx, obj, JSTYPE_STRING, rval);
}
static JSFunctionSpec JavaPackage_methods[] = {
{"toString", JavaPackage_toString, 0},
{0}
};
/*
* One-time initialization for the JavaPackage class. (This is not
* run once per thread, rather it's run once for a given JSContext.)
*/
JSBool
jsj_init_JavaPackage(JSContext *cx, JSObject *global_obj,
JavaPackageDef *additional_predefined_packages) {
/* Define JavaPackage class */
if (!JS_InitClass(cx, global_obj, 0, &JavaPackage_class,
0, 0, 0, JavaPackage_methods, 0, 0))
return JS_FALSE;
/* Add top-level packages, e.g. : java, netscape, sun */
if (!pre_define_java_packages(cx, global_obj, standard_java_packages))
return JS_FALSE;
if (!pre_define_java_packages(cx, global_obj, additional_predefined_packages))
return JS_FALSE;
return JS_TRUE;
}

View File

@@ -0,0 +1,180 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
/*
* This file is part of the Java-vendor-neutral implementation of LiveConnect
*
* It contains the code for reading and writing elements of a Java array.
*/
#include "jsj_private.h" /* LiveConnect internals */
/*
* Read the Java value at a given index into a Java array and convert it
* to a JS value. The array_component_signature describes the type of
* the resulting Java value, which can be a primitive type or an object type.
* More specifically it can be an array type in the case of multidimensional
* arrays.
*/
JSBool
jsj_GetJavaArrayElement(JSContext *cx, JNIEnv *jEnv, jarray java_array, jsize index,
JavaSignature *array_component_signature,
jsval *vp)
{
jvalue java_value;
JavaSignatureChar component_type;
#define GET_ELEMENT_FROM_PRIMITIVE_JAVA_ARRAY(Type,member) \
(*jEnv)->Get##Type##ArrayRegion(jEnv, java_array, index, 1, \
&java_value.member); \
if ((*jEnv)->ExceptionOccurred(jEnv)) { \
jsj_ReportJavaError(cx, jEnv, "Error reading element of " \
"Java primitive array"); \
return JS_FALSE; \
}
component_type = array_component_signature->type;
switch(component_type) {
case JAVA_SIGNATURE_BYTE:
GET_ELEMENT_FROM_PRIMITIVE_JAVA_ARRAY(Byte,b);
break;
case JAVA_SIGNATURE_CHAR:
GET_ELEMENT_FROM_PRIMITIVE_JAVA_ARRAY(Char,c);
break;
case JAVA_SIGNATURE_SHORT:
GET_ELEMENT_FROM_PRIMITIVE_JAVA_ARRAY(Short,s);
break;
case JAVA_SIGNATURE_INT:
GET_ELEMENT_FROM_PRIMITIVE_JAVA_ARRAY(Int,i);
break;
case JAVA_SIGNATURE_BOOLEAN:
GET_ELEMENT_FROM_PRIMITIVE_JAVA_ARRAY(Boolean,z);
break;
case JAVA_SIGNATURE_LONG:
GET_ELEMENT_FROM_PRIMITIVE_JAVA_ARRAY(Long,j);
break;
case JAVA_SIGNATURE_FLOAT:
GET_ELEMENT_FROM_PRIMITIVE_JAVA_ARRAY(Float,f);
break;
case JAVA_SIGNATURE_DOUBLE:
GET_ELEMENT_FROM_PRIMITIVE_JAVA_ARRAY(Double,d);
break;
case JAVA_SIGNATURE_CLASS:
case JAVA_SIGNATURE_ARRAY:
java_value.l = (*jEnv)->GetObjectArrayElement(jEnv, java_array, index);
if ((*jEnv)->ExceptionOccurred(jEnv)) {
jsj_ReportJavaError(cx, jEnv, "Error reading Java object array");
return JS_FALSE;
}
break;
#undef GET_ELEMENT_FROM_PRIMITIVE_JAVA_ARRAY
default:
PR_ASSERT(0); /* Unknown java type signature */
return JS_FALSE;
}
return jsj_ConvertJavaValueToJSValue(cx, jEnv, array_component_signature, &java_value, vp);
}
JSBool
jsj_SetJavaArrayElement(JSContext *cx, JNIEnv *jEnv, jarray java_array, jsize index,
JavaSignature *array_component_signature,
jsval js_val)
{
int dummy_cost;
jvalue java_value;
JavaSignatureChar component_type;
JSBool is_local_ref;
if (!jsj_ConvertJSValueToJavaValue(cx, jEnv, js_val, array_component_signature,
&dummy_cost, &java_value, &is_local_ref))
return JS_FALSE;
#define SET_ELEMENT_FROM_PRIMITIVE_JAVA_ARRAY(Type,member) \
(*jEnv)->Set##Type##ArrayRegion(jEnv, java_array, index, 1, \
&java_value.member); \
if ((*jEnv)->ExceptionOccurred(jEnv)) { \
jsj_ReportJavaError(cx, jEnv, "Error assigning to element of " \
"Java primitive array"); \
return JS_FALSE; \
}
component_type = array_component_signature->type;
switch(component_type) {
case JAVA_SIGNATURE_BYTE:
SET_ELEMENT_FROM_PRIMITIVE_JAVA_ARRAY(Byte,b);
break;
case JAVA_SIGNATURE_CHAR:
SET_ELEMENT_FROM_PRIMITIVE_JAVA_ARRAY(Char,c);
break;
case JAVA_SIGNATURE_SHORT:
SET_ELEMENT_FROM_PRIMITIVE_JAVA_ARRAY(Short,s);
break;
case JAVA_SIGNATURE_INT:
SET_ELEMENT_FROM_PRIMITIVE_JAVA_ARRAY(Int,i);
break;
case JAVA_SIGNATURE_BOOLEAN:
SET_ELEMENT_FROM_PRIMITIVE_JAVA_ARRAY(Boolean,z);
break;
case JAVA_SIGNATURE_LONG:
SET_ELEMENT_FROM_PRIMITIVE_JAVA_ARRAY(Long,j);
break;
case JAVA_SIGNATURE_FLOAT:
SET_ELEMENT_FROM_PRIMITIVE_JAVA_ARRAY(Float,f);
break;
case JAVA_SIGNATURE_DOUBLE:
SET_ELEMENT_FROM_PRIMITIVE_JAVA_ARRAY(Double,d);
break;
case JAVA_SIGNATURE_CLASS:
case JAVA_SIGNATURE_ARRAY:
(*jEnv)->SetObjectArrayElement(jEnv, java_array, index, java_value.l);
if (is_local_ref) \
(*jEnv)->DeleteLocalRef(jEnv, java_value.l);
if ((*jEnv)->ExceptionOccurred(jEnv)) {
jsj_ReportJavaError(cx, jEnv, "Error assigning to Java object array");
return JS_FALSE;
}
break;
#undef SET_ELEMENT_FROM_PRIMITIVE_JAVA_ARRAY
default:
PR_ASSERT(0); /* Unknown java type signature */
return JS_FALSE;
}
return JS_TRUE;
}

View File

@@ -0,0 +1,605 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
/*
* This file is part of the Java-vendor-neutral implementation of LiveConnect
*
* It contains the code that constructs and manipulates JavaClassDescriptor
* structs, which are the native wrappers for Java classes.
* JavaClassDescriptors are used to describe the signatures of methods and
* fields. There is a JavaClassDescriptor associated with the reflection of
* each Java Object.
*/
#include <stdlib.h>
#include <string.h>
#include "jsj_private.h" /* LiveConnect internals */
#include "jsj_hash.h" /* Hash tables */
/* A one-to-one mapping between all referenced java.lang.Class objects and
their corresponding JavaClassDescriptor objects */
static JSJHashTable *java_class_reflections;
/*
* Given a JVM handle to a java.lang.Class object, malloc a C-string
* containing the UTF8 encoding of the fully qualified name of the class.
* It's the caller's responsibility to free the returned string.
*
* If an error occurs, NULL is returned and the error reporter called.
*/
const char *
jsj_GetJavaClassName(JSContext *cx, JNIEnv *jEnv, jclass java_class)
{
jstring java_class_name_jstr;
const char *java_class_name;
/* Get java.lang.String object containing class name */
java_class_name_jstr =
(*jEnv)->CallObjectMethod(jEnv, java_class, jlClass_getName);
if (!java_class_name_jstr)
goto error;
/* Convert to UTF8 encoding and copy */
java_class_name = jsj_DupJavaStringUTF(cx, jEnv, java_class_name_jstr);
if (!java_class_name)
return NULL;
return java_class_name;
error:
jsj_UnexpectedJavaError(cx, jEnv, "Can't get Java class name using"
"java.lang.Class.getName()");
return NULL;
}
/*
* Convert in-place a string of the form "java.lang.String" into "java/lang/String".
* Though the former style is conventionally used by Java programmers, the latter is
* what the JNI functions require.
*/
void
jsj_MakeJNIClassname(char * class_name)
{
char * c;
for (c = class_name; *c; c++)
if (*c == '.')
*c = '/';
}
/*
* Classify an instance of java.lang.Class as either one of the primitive
* types, e.g. int, char, etc., as an array type or as a non-array object type
* (subclass of java.lang.Object) by returning the appropriate enum member.
*
*/
static JavaSignatureChar
get_signature_type(JSContext *cx, JavaClassDescriptor *class_descriptor)
{
JavaSignatureChar type;
const char *java_class_name;
/* Get UTF8 encoding of class name */
java_class_name = class_descriptor->name;
PR_ASSERT(java_class_name);
if (!java_class_name)
return JAVA_SIGNATURE_UNKNOWN;
if (!strcmp(java_class_name, "byte"))
type = JAVA_SIGNATURE_BYTE;
else if (!strcmp(java_class_name, "char"))
type = JAVA_SIGNATURE_CHAR;
else if (!strcmp(java_class_name, "float"))
type = JAVA_SIGNATURE_FLOAT;
else if (!strcmp(java_class_name, "double"))
type = JAVA_SIGNATURE_DOUBLE;
else if (!strcmp(java_class_name, "int"))
type = JAVA_SIGNATURE_INT;
else if (!strcmp(java_class_name, "long"))
type = JAVA_SIGNATURE_LONG;
else if (!strcmp(java_class_name, "short"))
type = JAVA_SIGNATURE_SHORT;
else if (!strcmp(java_class_name, "boolean"))
type = JAVA_SIGNATURE_BOOLEAN;
else if (!strcmp(java_class_name, "void"))
type = JAVA_SIGNATURE_VOID;
else
/* Well, I guess it's a Java class, then. */
type = JAVA_SIGNATURE_CLASS;
return type;
}
static JSBool
is_java_array_class(JNIEnv *jEnv, jclass java_class)
{
return (*jEnv)->CallBooleanMethod(jEnv, java_class, jlClass_isArray);
}
/*
* Return the class of a Java array's component type. This is not the same
* as the array's element type. For example, the component type of an array
* of type SomeType[][][] is SomeType[][], but its element type is SomeType.
*
* If an error occurs, NULL is returned and an error reported.
*/
static jclass
get_java_array_component_class(JSContext *cx, JNIEnv *jEnv, jclass java_class)
{
jclass result;
result = (*jEnv)->CallObjectMethod(jEnv, java_class, jlClass_getComponentType);
if (!result) {
jsj_UnexpectedJavaError(cx, jEnv,
"Can't get Java array component class using "
"java.lang.Class.getComponentType()");
return NULL;
}
return result;
}
/*
* Given a Java class, fill in the signature structure that describes the class.
* If an error occurs, JS_FALSE is returned and the error reporter called.
*/
static JSBool
compute_java_class_signature(JSContext *cx, JNIEnv *jEnv, JavaSignature *signature)
{
jclass java_class = signature->java_class;
if (is_java_array_class(jEnv, java_class)) {
jclass component_class;
signature->type = JAVA_SIGNATURE_ARRAY;
component_class = get_java_array_component_class(cx, jEnv, java_class);
if (!component_class)
return JS_FALSE;
signature->array_component_signature =
jsj_GetJavaClassDescriptor(cx, jEnv, component_class);
if (!signature->array_component_signature)
return JS_FALSE;
} else {
signature->type = get_signature_type(cx, signature);
}
return JS_TRUE;
}
/*
* Convert a JavaSignature object into a string format as used by
* the JNI functions, e.g. java.lang.Object ==> "Ljava/lang/Object;"
* The caller is responsible for freeing the resulting string.
*
* If an error is encountered, NULL is returned and an error reported.
*/
const char *
jsj_ConvertJavaSignatureToString(JSContext *cx, JavaSignature *signature)
{
char *sig;
if (signature->type == JAVA_SIGNATURE_CLASS) {
/* A non-array object class */
sig = PR_smprintf("L%s;", signature->name);
if (sig)
jsj_MakeJNIClassname(sig);
} else if (signature->type == JAVA_SIGNATURE_ARRAY) {
/* An array class */
const char *component_signature_string;
component_signature_string =
jsj_ConvertJavaSignatureToString(cx, signature->array_component_signature);
if (!component_signature_string)
return NULL;
sig = PR_smprintf("[%s", component_signature_string);
JS_free(cx, (char*)component_signature_string);
} else {
/* A primitive class */
sig = PR_smprintf("%c", (char)signature->type);
}
if (!sig) {
JS_ReportOutOfMemory(cx);
return NULL;
}
return sig;
}
/*
* Convert a JavaSignature object into a human-readable string format as seen
* in Java source files, e.g. "byte", or "int[][]" or "java.lang.String".
* The caller is responsible for freeing the resulting string.
*
* If an error is encountered, NULL is returned and an error reported.
*/
const char *
jsj_ConvertJavaSignatureToHRString(JSContext *cx,
JavaSignature *signature)
{
char *sig;
JavaSignature *acs;
if (signature->type == JAVA_SIGNATURE_ARRAY) {
/* An array class */
const char *component_signature_string;
acs = signature->array_component_signature;
component_signature_string =
jsj_ConvertJavaSignatureToHRString(cx, acs);
if (!component_signature_string)
return NULL;
sig = PR_smprintf("%s[]", component_signature_string);
JS_free(cx, (char*)component_signature_string);
} else {
/* A primitive class or a non-array object class */
sig = JS_strdup(cx, signature->name);
}
if (!sig) {
JS_ReportOutOfMemory(cx);
return NULL;
}
return sig;
}
static void
destroy_java_member_descriptor(JSContext *cx, JNIEnv *jEnv, JavaMemberDescriptor *member_descriptor)
{
JavaMethodSpec *method, *next_method;
if (member_descriptor->field)
jsj_DestroyFieldSpec(cx, jEnv, member_descriptor->field);
method = member_descriptor->methods;
while (method) {
next_method = method->next;
jsj_DestroyMethodSpec(cx, jEnv, method);
method = next_method;
}
if (member_descriptor->invoke_func_obj)
JS_RemoveRoot(cx, &member_descriptor->invoke_func_obj);
}
static void
destroy_class_member_descriptors(JSContext *cx, JNIEnv *jEnv, JavaMemberDescriptor *member_descriptor)
{
JavaMemberDescriptor *next_member;
while (member_descriptor) {
next_member = member_descriptor->next;
destroy_java_member_descriptor(cx, jEnv, member_descriptor);
member_descriptor = next_member;
}
}
static void
destroy_class_descriptor(JSContext *cx, JNIEnv *jEnv, JavaClassDescriptor *class_descriptor)
{
JS_FREE_IF(cx, (char *)class_descriptor->name);
if (class_descriptor->java_class) {
JSJ_HashTableRemove(java_class_reflections,
class_descriptor->java_class, (void*)jEnv);
(*jEnv)->DeleteGlobalRef(jEnv, class_descriptor->java_class);
}
if (class_descriptor->array_component_signature)
jsj_ReleaseJavaClassDescriptor(cx, jEnv, class_descriptor->array_component_signature);
destroy_class_member_descriptors(cx, jEnv, class_descriptor->instance_members);
destroy_class_member_descriptors(cx, jEnv, class_descriptor->static_members);
destroy_class_member_descriptors(cx, jEnv, class_descriptor->constructors);
JS_free(cx, class_descriptor);
}
static JavaClassDescriptor *
new_class_descriptor(JSContext *cx, JNIEnv *jEnv, jclass java_class)
{
JavaClassDescriptor *class_descriptor;
class_descriptor = (JavaClassDescriptor *)JS_malloc(cx, sizeof(JavaClassDescriptor));
if (!class_descriptor)
return NULL;
memset(class_descriptor, 0, sizeof(JavaClassDescriptor));
class_descriptor->name = jsj_GetJavaClassName(cx, jEnv, java_class);
if (!class_descriptor->name)
goto error;
java_class = (*jEnv)->NewGlobalRef(jEnv, java_class);
if (!java_class) {
jsj_UnexpectedJavaError(cx, jEnv, "Unable to reference Java class");
goto error;
}
class_descriptor->java_class = java_class;
if (!compute_java_class_signature(cx, jEnv, class_descriptor))
goto error;
class_descriptor->modifiers =
(*jEnv)->CallIntMethod(jEnv, java_class, jlClass_getModifiers);
class_descriptor->ref_count = 1;
if (!JSJ_HashTableAdd(java_class_reflections, java_class, class_descriptor,
(void*)jEnv))
goto error;
return class_descriptor;
error:
destroy_class_descriptor(cx, jEnv, class_descriptor);
return NULL;
}
/* Trivial helper for jsj_DiscardJavaClassReflections(), below */
static PRIntn
enumerate_remove_java_class(JSJHashEntry *he, PRIntn i, void *arg)
{
JNIEnv *jEnv = (JNIEnv*)arg;
jclass java_class;
JavaClassDescriptor *class_descriptor;
class_descriptor = (JavaClassDescriptor*)he->value;
java_class = class_descriptor->java_class;
(*jEnv)->DeleteGlobalRef(jEnv, java_class);
class_descriptor->java_class = NULL;
return HT_ENUMERATE_REMOVE;
}
/* This shutdown routine discards all JNI references to Java objects
that have been reflected into JS, even if there are still references
to them from JS. */
void
jsj_DiscardJavaClassReflections(JNIEnv *jEnv)
{
if (java_class_reflections) {
JSJ_HashTableEnumerateEntries(java_class_reflections,
enumerate_remove_java_class,
(void*)jEnv);
JSJ_HashTableDestroy(java_class_reflections);
java_class_reflections = NULL;
}
}
extern JavaClassDescriptor *
jsj_GetJavaClassDescriptor(JSContext *cx, JNIEnv *jEnv, jclass java_class)
{
JavaClassDescriptor *class_descriptor;
class_descriptor = JSJ_HashTableLookup(java_class_reflections,
(const void *)java_class,
(void*)jEnv);
if (!class_descriptor)
return new_class_descriptor(cx, jEnv, java_class);
PR_ASSERT(class_descriptor->ref_count > 0);
class_descriptor->ref_count++;
return class_descriptor;
}
void
jsj_ReleaseJavaClassDescriptor(JSContext *cx, JNIEnv *jEnv, JavaClassDescriptor *class_descriptor)
{
if (!--class_descriptor->ref_count)
destroy_class_descriptor(cx, jEnv, class_descriptor);
}
static JSBool
reflect_java_methods_and_fields(JSContext *cx,
JNIEnv *jEnv,
JavaClassDescriptor *class_descriptor,
JSBool reflect_statics_only)
{
JavaMemberDescriptor *member_descriptor;
if (reflect_statics_only)
class_descriptor->static_members_reflected = JS_TRUE;
else
class_descriptor->instance_members_reflected = JS_TRUE;
if (!jsj_ReflectJavaMethods(cx, jEnv, class_descriptor, reflect_statics_only))
return JS_FALSE;
if (!jsj_ReflectJavaFields(cx, jEnv, class_descriptor, reflect_statics_only))
return JS_FALSE;
if (reflect_statics_only) {
member_descriptor = class_descriptor->static_members;
while (member_descriptor) {
class_descriptor->num_static_members++;
member_descriptor = member_descriptor->next;
}
} else {
member_descriptor = class_descriptor->instance_members;
while (member_descriptor) {
class_descriptor->num_instance_members++;
member_descriptor = member_descriptor->next;
}
}
return JS_TRUE;
}
JavaMemberDescriptor *
jsj_GetClassStaticMembers(JSContext *cx,
JNIEnv *jEnv,
JavaClassDescriptor *class_descriptor)
{
if (!class_descriptor->static_members_reflected)
reflect_java_methods_and_fields(cx, jEnv, class_descriptor, JS_TRUE);
return class_descriptor->static_members;
}
JavaMemberDescriptor *
jsj_GetClassInstanceMembers(JSContext *cx,
JNIEnv *jEnv,
JavaClassDescriptor *class_descriptor)
{
if (!class_descriptor->instance_members_reflected)
reflect_java_methods_and_fields(cx, jEnv, class_descriptor, JS_FALSE);
return class_descriptor->instance_members;
}
JavaMemberDescriptor *
jsj_LookupJavaStaticMemberDescriptorById(JSContext *cx,
JNIEnv *jEnv,
JavaClassDescriptor *class_descriptor,
jsid id)
{
JavaMemberDescriptor *member_descriptor;
member_descriptor = jsj_GetClassStaticMembers(cx, jEnv, class_descriptor);
while (member_descriptor) {
if (id == member_descriptor->id)
return member_descriptor;
member_descriptor = member_descriptor->next;
}
return NULL;
}
JavaMemberDescriptor *
jsj_GetJavaStaticMemberDescriptor(JSContext *cx,
JNIEnv *jEnv,
JavaClassDescriptor *class_descriptor,
jstring member_name_jstr)
{
JavaMemberDescriptor *member_descriptor;
jsid id;
if (!JavaStringToId(cx, jEnv, member_name_jstr, &id))
return NULL;
member_descriptor = jsj_LookupJavaStaticMemberDescriptorById(cx, jEnv, class_descriptor, id);
if (member_descriptor)
return member_descriptor;
member_descriptor = JS_malloc(cx, sizeof(JavaMemberDescriptor));
if (!member_descriptor)
return NULL;
memset(member_descriptor, 0, sizeof(JavaMemberDescriptor));
member_descriptor->name = jsj_DupJavaStringUTF(cx, jEnv, member_name_jstr);
if (!member_descriptor->name) {
JS_free(cx, member_descriptor);
return NULL;
}
member_descriptor->id = id;
member_descriptor->next = class_descriptor->static_members;
class_descriptor->static_members = member_descriptor;
return member_descriptor;
}
JavaMemberDescriptor *
jsj_GetJavaClassConstructors(JSContext *cx,
JavaClassDescriptor *class_descriptor)
{
JavaMemberDescriptor *member_descriptor;
if (class_descriptor->constructors)
return class_descriptor->constructors;
member_descriptor = JS_malloc(cx, sizeof(JavaMemberDescriptor));
if (!member_descriptor)
return NULL;
memset(member_descriptor, 0, sizeof(JavaMemberDescriptor));
member_descriptor->name = JS_strdup(cx, "<init>");
if (!member_descriptor->name) {
JS_free(cx, member_descriptor);
return NULL;
}
class_descriptor->constructors = member_descriptor;
return member_descriptor;
}
JavaMemberDescriptor *
jsj_LookupJavaClassConstructors(JSContext *cx, JNIEnv *jEnv,
JavaClassDescriptor *class_descriptor)
{
if (!class_descriptor->static_members_reflected)
reflect_java_methods_and_fields(cx, jEnv, class_descriptor, JS_TRUE);
return class_descriptor->constructors;
}
JavaMemberDescriptor *
jsj_LookupJavaMemberDescriptorById(JSContext *cx, JNIEnv *jEnv,
JavaClassDescriptor *class_descriptor,
jsid id)
{
JavaMemberDescriptor *member_descriptor;
member_descriptor = jsj_GetClassInstanceMembers(cx, jEnv, class_descriptor);
while (member_descriptor) {
if (id == member_descriptor->id)
return member_descriptor;
member_descriptor = member_descriptor->next;
}
return NULL;
}
JavaMemberDescriptor *
jsj_GetJavaMemberDescriptor(JSContext *cx,
JNIEnv *jEnv,
JavaClassDescriptor *class_descriptor,
jstring member_name_jstr)
{
JavaMemberDescriptor *member_descriptor;
jsid id;
if (!JavaStringToId(cx, jEnv, member_name_jstr, &id))
return NULL;
member_descriptor = jsj_LookupJavaMemberDescriptorById(cx, jEnv, class_descriptor, id);
if (member_descriptor)
return member_descriptor;
member_descriptor = JS_malloc(cx, sizeof(JavaMemberDescriptor));
if (!member_descriptor)
return NULL;
memset(member_descriptor, 0, sizeof(JavaMemberDescriptor));
member_descriptor->name = jsj_DupJavaStringUTF(cx, jEnv, member_name_jstr);
if (!member_descriptor->name) {
JS_free(cx, member_descriptor);
return NULL;
}
member_descriptor->id = id;
member_descriptor->next = class_descriptor->instance_members;
class_descriptor->instance_members = member_descriptor;
return member_descriptor;
}
JSBool
jsj_InitJavaClassReflectionsTable()
{
java_class_reflections =
JSJ_NewHashTable(64, jsj_HashJavaObject, jsj_JavaObjectComparator,
NULL, NULL, NULL);
if (!java_class_reflections)
return JS_FALSE;
return JS_TRUE;
}

View File

@@ -0,0 +1,806 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
/* This file is part of the Java-vendor-neutral implementation of LiveConnect
*
* Below is the code that converts between Java and JavaScript values of all
* types.
*/
#include <stdlib.h>
#include <string.h>
#include "jsj_private.h" /* LiveConnect internals */
/* Floating-point double utilities, stolen from jsnum.h */
#ifdef IS_LITTLE_ENDIAN
#define JSDOUBLE_HI32(x) (((uint32 *)&(x))[1])
#define JSDOUBLE_LO32(x) (((uint32 *)&(x))[0])
#else
#define JSDOUBLE_HI32(x) (((uint32 *)&(x))[0])
#define JSDOUBLE_LO32(x) (((uint32 *)&(x))[1])
#endif
#define JSDOUBLE_HI32_SIGNBIT 0x80000000
#define JSDOUBLE_HI32_EXPMASK 0x7ff00000
#define JSDOUBLE_HI32_MANTMASK 0x000fffff
#define JSDOUBLE_IS_NaN(x) \
((JSDOUBLE_HI32(x) & JSDOUBLE_HI32_EXPMASK) == JSDOUBLE_HI32_EXPMASK && \
(JSDOUBLE_LO32(x) || (JSDOUBLE_HI32(x) & JSDOUBLE_HI32_MANTMASK)))
#define JSDOUBLE_IS_INFINITE(x) \
((JSDOUBLE_HI32(x) & ~JSDOUBLE_HI32_SIGNBIT) == JSDOUBLE_HI32_EXPMASK && \
!JSDOUBLE_LO32(x))
static JSBool
convert_js_obj_to_JSObject_wrapper(JSContext *cx, JNIEnv *jEnv, JSObject *js_obj,
JavaSignature *signature,
int *cost, jobject *java_value)
{
if (!njJSObject) {
if (java_value)
JS_ReportError(cx, "Couldn't convert JavaScript object to an "
"instance of netscape.javascript.JSObject "
"because that class could not be loaded.");
return JS_FALSE;
}
if (!(*jEnv)->IsAssignableFrom(jEnv, njJSObject, signature->java_class))
return JS_FALSE;
if (!java_value)
return JS_TRUE;
*java_value = jsj_WrapJSObject(cx, jEnv, js_obj);
return (*java_value != NULL);
}
jstring
jsj_ConvertJSStringToJavaString(JSContext *cx, JNIEnv *jEnv, JSString *js_str)
{
jstring result;
result = (*jEnv)->NewString(jEnv, JS_GetStringChars(js_str),
JS_GetStringLength(js_str));
if (!result) {
jsj_UnexpectedJavaError(cx, jEnv, "Couldn't construct instance "
"of java.lang.String");
}
return result;
}
/*
* Convert a JS value to an instance of java.lang.Object or one of its subclasses,
* performing any necessary type coercion. If non-trivial coercion is required,
* the cost value is incremented. If the java_value pass-by-reference argument
* is non-NULL, the resulting Java value is stored there.
*
* Returns JS_TRUE if the conversion is possible, JS_FALSE otherwise
*/
JSBool
jsj_ConvertJSValueToJavaObject(JSContext *cx, JNIEnv *jEnv, jsval v, JavaSignature *signature,
int *cost, jobject *java_value, JSBool *is_local_refp)
{
JSString *jsstr;
jclass target_java_class;
PR_ASSERT(signature->type == JAVA_SIGNATURE_CLASS ||
signature->type == JAVA_SIGNATURE_ARRAY);
/* Initialize to default case, in which no new Java object is
synthesized to perform the conversion and, therefore, no JNI local
references are being held. */
*is_local_refp = JS_FALSE;
/* Get the Java type of the target value */
target_java_class = signature->java_class;
if (JSVAL_IS_OBJECT(v)) {
JSObject *js_obj = JSVAL_TO_OBJECT(v);
/* JS null is always assignable to a Java object */
if (!js_obj) {
if (java_value)
*java_value = NULL;
return JS_TRUE;
}
if (JS_InstanceOf(cx, js_obj, &JavaObject_class, 0) ||
JS_InstanceOf(cx, js_obj, &JavaArray_class, 0)) {
/* The source value is a Java object wrapped inside a JavaScript
object. Unwrap the JS object and return the original Java
object if it's class makes it assignment-compatible with the
target class using Java's assignability rules. */
JavaObjectWrapper *java_wrapper = JS_GetPrivate(cx, js_obj);
jobject java_obj = java_wrapper->java_obj;
if ((*jEnv)->IsInstanceOf(jEnv, java_obj, target_java_class)) {
if (java_value)
*java_value = java_obj;
return JS_TRUE;
}
#ifdef LIVECONNECT_IMPROVEMENTS
/* Don't allow wrapped Java objects to be converted to strings */
goto conversion_error;
#else
/* Fall through, to attempt conversion to a Java string */
#endif
} else if (JS_InstanceOf(cx, js_obj, &JavaClass_class, 0)) {
/* We're dealing with the reflection of a Java class */
JavaClassDescriptor *java_class_descriptor = JS_GetPrivate(cx, js_obj);
/* Check if target type is java.lang.Class class */
if ((*jEnv)->IsAssignableFrom(jEnv, jlClass, target_java_class)) {
if (java_value)
*java_value = java_class_descriptor->java_class;
return JS_TRUE;
}
/* Check if target type is netscape.javascript.JSObject wrapper class */
if (convert_js_obj_to_JSObject_wrapper(cx, jEnv, js_obj, signature, cost, java_value)) {
if (*java_value)
*is_local_refp = JS_TRUE;
return JS_TRUE;
}
/* Fall through, to attempt conversion to a Java string */
} else if (JS_InstanceOf(cx, js_obj, &JavaMember_class, 0)) {
if (!JS_ConvertValue(cx, v, JSTYPE_OBJECT, &v))
return JS_FALSE;
return jsj_ConvertJSValueToJavaObject(cx, jEnv, v, signature, cost,
java_value, is_local_refp);
} else {
/* Otherwise, see if the target type is the netscape.javascript.JSObject
wrapper class or one of its subclasses, in which case a
reference is passed to the original JS object by wrapping it
inside an instance of netscape.javascript.JSObject */
if (convert_js_obj_to_JSObject_wrapper(cx, jEnv, js_obj, signature, cost, java_value)) {
return JS_TRUE;
}
/* Fall through, to attempt conversion to a Java string */
}
} else if (JSVAL_IS_NUMBER(v)) {
/* JS numbers, integral or not, can be converted to instances of java.lang.Double */
if ((*jEnv)->IsAssignableFrom(jEnv, jlDouble, target_java_class)) {
if (java_value) {
jsdouble d;
if (!JS_ValueToNumber(cx, v, &d))
goto conversion_error;
*java_value = (*jEnv)->NewObject(jEnv, jlDouble, jlDouble_Double, d);
if (*java_value) {
*is_local_refp = JS_TRUE;
} else {
jsj_UnexpectedJavaError(cx, jEnv,
"Couldn't construct instance of java.lang.Double");
return JS_FALSE;
}
}
#ifdef LIVECONNECT_IMPROVEMENTS
(*cost)++;
#endif
return JS_TRUE;
}
/* Fall through, to attempt conversion to a java.lang.String ... */
} else if (JSVAL_IS_BOOLEAN(v)) {
/* JS boolean values can be converted to instances of java.lang.Boolean */
if ((*jEnv)->IsAssignableFrom(jEnv, jlBoolean, target_java_class)) {
if (java_value) {
JSBool b;
if (!JS_ValueToBoolean(cx, v, &b))
goto conversion_error;
*java_value =
(*jEnv)->NewObject(jEnv, jlBoolean, jlBoolean_Boolean, b);
if (*java_value) {
*is_local_refp = JS_TRUE;
} else {
jsj_UnexpectedJavaError(cx, jEnv, "Couldn't construct instance "
"of java.lang.Boolean");
return JS_FALSE;
}
}
#ifdef LIVECONNECT_IMPROVEMENTS
(*cost)++;
#endif
return JS_TRUE;
}
/* Fall through, to attempt conversion to a java.lang.String ... */
}
/* If no other conversion is possible, see if the target type is java.lang.String */
if ((*jEnv)->IsAssignableFrom(jEnv, jlString, target_java_class)) {
#ifdef LIVECONNECT_IMPROVEMENTS
JSBool is_string = JSVAL_IS_STRING(v);
#endif
/* Convert to JS string, if necessary, and then to a Java Unicode string */
jsstr = JS_ValueToString(cx, v);
if (jsstr) {
if (java_value) {
*java_value = jsj_ConvertJSStringToJavaString(cx, jEnv, jsstr);
if (*java_value) {
*is_local_refp = JS_TRUE;
} else {
return JS_FALSE;
}
}
#ifdef LIVECONNECT_IMPROVEMENTS
if (!is_string)
(*cost)++;
#endif
return JS_TRUE;
}
}
conversion_error:
return JS_FALSE;
}
/* Valid ranges for Java numeric types */
#define jbyte_MAX_VALUE 127.0
#define jbyte_MIN_VALUE -128.0
#define jchar_MAX_VALUE 65535.0
#define jchar_MIN_VALUE 0.0
#define jshort_MAX_VALUE 32767.0
#define jshort_MIN_VALUE -32768.0
#define jint_MAX_VALUE 2147483647.0
#define jint_MIN_VALUE -2147483648.0
#define jlong_MAX_VALUE 9223372036854775807.0
#define jlong_MIN_VALUE -9223372036854775808.0
/* Utility macro for jsj_ConvertJSValueToJavaValue(), below */
#define JSVAL_TO_INTEGRAL_JVALUE(type_name, member_name, member_type, jsval, java_value) \
if (!JSVAL_IS_NUMBER(v)) { \
if (!JS_ConvertValue(cx, v, JSTYPE_NUMBER, &v)) \
goto conversion_error; \
(*cost)++; \
} \
{ \
member_type member_name; \
\
if (JSVAL_IS_INT(v)) { \
jsint ival = JSVAL_TO_INT(v); \
member_name = (member_type) ival; \
\
/* Check to see if the jsval's magnitude is too large to be \
representable in the target java type */ \
if (member_name != ival) \
goto numeric_conversion_error; \
} else { \
jdouble dval = *JSVAL_TO_DOUBLE(v); \
\
/* NaN becomes zero when converted to integral value */ \
if (JSDOUBLE_IS_NaN(dval)) \
member_name = 0; \
\
/* Unrepresentably large numbers, including infinities, */ \
/* cause an error. */ \
else if ((dval > member_type ## _MAX_VALUE) || \
(dval < member_type ## _MIN_VALUE)) { \
goto numeric_conversion_error; \
} else \
member_name = (member_type) dval; \
\
/* Don't allow a non-integral number to be converted \
to an integral type */ \
/* Actually, we have to allow this for LC1 compatibility */ \
/* if ((jdouble)member_name != dval) \
(*cost)++; */ \
} \
if (java_value) \
java_value->member_name = member_name; \
}
#if XP_MAC
/* on MRJ jlong is typedef'd to wide, which is a struct. */
#include <Math64.h>
static jsint jlong_to_jsint(jlong lvalue)
{
SInt64 val = WideToSInt64(lvalue);
return S32Set(val);
}
static jlong jsint_to_jlong(jsint ivalue)
{
SInt64 val = S64Set(ivalue);
wide wval =SInt64ToWide(val);
return *(jlong*)&wval;
}
static jdouble jlong_to_jdouble(jlong lvalue)
{
SInt64 val = WideToSInt64(lvalue);
return SInt64ToLongDouble(val);
}
static jlong jdouble_to_jlong(jdouble dvalue)
{
SInt64 val = LongDoubleToSInt64(dvalue);
wide wval = SInt64ToWide(val);
return *(jlong*)&wval;
}
/* Mac utility macro for jsj_ConvertJSValueToJavaValue(), below */
#define JSVAL_TO_JLONG_JVALUE(member_name, member_type, jsvalue, java_value) \
if (!JSVAL_IS_NUMBER(jsvalue)) { \
if (!JS_ConvertValue(cx, jsvalue, JSTYPE_NUMBER, &jsvalue)) \
goto conversion_error; \
(*cost)++; \
} \
{ \
member_type member_name; \
\
if (JSVAL_IS_INT(jsvalue)) { \
jsint ival = JSVAL_TO_INT(jsvalue); \
member_name = jsint_to_jlong(ival); \
\
} else { \
jdouble dval = *JSVAL_TO_DOUBLE(jsvalue); \
\
/* NaN becomes zero when converted to integral value */ \
if (JSDOUBLE_IS_NaN(dval)) \
member_name = jsint_to_jlong(0); \
\
/* Unrepresentably large numbers, including infinities, */ \
/* cause an error. */ \
else if ((dval > member_type ## _MAX_VALUE) || \
(dval < member_type ## _MIN_VALUE)) { \
goto numeric_conversion_error; \
} else \
member_name = jdouble_to_jlong(dval); \
\
/* Don't allow a non-integral number to be converted \
to an integral type */ \
/* Actually, we have to allow this for LC1 compatibility */ \
/*if (jlong_to_jdouble(member_name) != dval) \
(*cost)++;*/ \
} \
if (java_value) \
java_value->member_name = member_name; \
}
#else
#define jlong_to_jdouble(lvalue) ((jdouble) lvalue)
#endif
/*
* Convert a JS value to a Java value of the given type signature. The cost
* variable is incremented if coercion is required, e.g. the source value is
* a string, but the target type is a boolean.
*
* Returns JS_FALSE if no conversion is possible, either because the jsval has
* a type that is wholly incompatible with the Java value, or because a scalar
* jsval can't be represented in a variable of the target type without loss of
* precision, e.g. the source value is "4.2" but the destination type is byte.
* If conversion is not possible and java_value is non-NULL, the JS error
* reporter is called with an appropriate message.
*/
JSBool
jsj_ConvertJSValueToJavaValue(JSContext *cx, JNIEnv *jEnv, jsval v,
JavaSignature *signature,
int *cost, jvalue *java_value, JSBool *is_local_refp)
{
JavaSignatureChar type;
JSBool success = JS_FALSE;
/* Initialize to default case, in which no new Java object is
synthesized to perform the conversion and, therefore, no JNI local
references are being held. */
*is_local_refp = JS_FALSE;
type = signature->type;
switch (type) {
case JAVA_SIGNATURE_BOOLEAN:
if (!JSVAL_IS_BOOLEAN(v)) {
if (!JS_ConvertValue(cx, v, JSTYPE_BOOLEAN, &v))
goto conversion_error;
(*cost)++;
}
if (java_value)
java_value->z = (jboolean)(JSVAL_TO_BOOLEAN(v) == JS_TRUE);
break;
case JAVA_SIGNATURE_SHORT:
JSVAL_TO_INTEGRAL_JVALUE(short, s, jshort, v, java_value);
break;
case JAVA_SIGNATURE_BYTE:
JSVAL_TO_INTEGRAL_JVALUE(byte, b, jbyte, v, java_value);
break;
case JAVA_SIGNATURE_CHAR:
/* A one-character string can be converted into a character */
if (JSVAL_IS_STRING(v) && (JS_GetStringLength(JSVAL_TO_STRING(v)) == 1)) {
v = INT_TO_JSVAL(*JS_GetStringChars(JSVAL_TO_STRING(v)));
}
JSVAL_TO_INTEGRAL_JVALUE(char, c, jchar, v, java_value);
break;
case JAVA_SIGNATURE_INT:
JSVAL_TO_INTEGRAL_JVALUE(int, i, jint, v, java_value);
break;
case JAVA_SIGNATURE_LONG:
#if XP_MAC
JSVAL_TO_JLONG_JVALUE(j, jlong, v, java_value);
#else
JSVAL_TO_INTEGRAL_JVALUE(long, j, jlong, v, java_value);
#endif
break;
case JAVA_SIGNATURE_FLOAT:
if (!JSVAL_IS_NUMBER(v)) {
if (!JS_ConvertValue(cx, v, JSTYPE_NUMBER, &v))
goto conversion_error;
(*cost)++;
}
if (java_value) {
if (JSVAL_IS_INT(v))
java_value->f = (jfloat) JSVAL_TO_INT(v);
else
java_value->f = (jfloat) *JSVAL_TO_DOUBLE(v);
}
break;
case JAVA_SIGNATURE_DOUBLE:
if (!JSVAL_IS_NUMBER(v)) {
if (!JS_ConvertValue(cx, v, JSTYPE_NUMBER, &v))
goto conversion_error;
(*cost)++;
}
if (java_value) {
if (JSVAL_IS_INT(v))
java_value->d = (jdouble) JSVAL_TO_INT(v);
else
java_value->d = (jdouble) *JSVAL_TO_DOUBLE(v);
}
break;
case JAVA_SIGNATURE_CLASS:
case JAVA_SIGNATURE_ARRAY:
if (!jsj_ConvertJSValueToJavaObject(cx, jEnv, v, signature, cost,
&java_value->l, is_local_refp))
goto conversion_error;
break;
default:
PR_ASSERT(0);
return JS_FALSE;
}
/* Success */
return JS_TRUE;
numeric_conversion_error:
success = JS_TRUE;
/* Fall through ... */
conversion_error:
if (java_value) {
const char *jsval_string;
JSString *jsstr;
jsval_string = NULL;
jsstr = JS_ValueToString(cx, v);
if (jsstr)
jsval_string = JS_GetStringBytes(jsstr);
if (!jsval_string)
jsval_string = "";
JS_ReportError(cx, "Unable to convert JavaScript value %s to "
"Java value of type %s",
jsval_string, signature->name);
return JS_FALSE;
}
return success;
}
/*
* A utility routine to create a JavaScript Unicode string from a
* java.lang.String (Unicode) string.
*/
JSString *
jsj_ConvertJavaStringToJSString(JSContext *cx, JNIEnv *jEnv, jstring java_str)
{
JSString *js_str;
jboolean is_copy;
const jchar *ucs2_str;
jchar *copy_ucs2_str;
jsize ucs2_str_len, num_bytes;
ucs2_str_len = (*jEnv)->GetStringLength(jEnv, java_str);
ucs2_str = (*jEnv)->GetStringChars(jEnv, java_str, &is_copy);
if (!ucs2_str) {
jsj_UnexpectedJavaError(cx, jEnv,
"Unable to extract native Unicode from Java string");
return NULL;
}
js_str = NULL;
/* The string data passed into JS_NewUCString() is
not copied, so make a copy of the Unicode character vector. */
num_bytes = ucs2_str_len * sizeof(jchar);
copy_ucs2_str = (jchar*)JS_malloc(cx, num_bytes);
if (!copy_ucs2_str)
goto done;
memcpy(copy_ucs2_str, ucs2_str, num_bytes);
js_str = JS_NewUCString(cx, (jschar*)copy_ucs2_str, ucs2_str_len);
done:
(*jEnv)->ReleaseStringChars(jEnv, java_str, ucs2_str);
return js_str;
}
/*
* Attempt to obtain a JS string representation of a Java object.
* The java_obj argument must be of type java.lang.Object or a subclass.
* If java_obj is a Java string, it's value is simply extracted and
* copied into a JS string. Otherwise, the toString() method is called
* on java_obj.
*/
JSBool
jsj_ConvertJavaObjectToJSString(JSContext *cx,
JNIEnv *jEnv,
JavaClassDescriptor *class_descriptor,
jobject java_obj, jsval *vp)
{
JSString *js_str;
jstring java_str;
jmethodID toString;
/* Create a Java string, unless java_obj is already a java.lang.String */
if ((*jEnv)->IsInstanceOf(jEnv, java_obj, jlString)) {
java_str = java_obj;
} else {
jclass java_class;
java_class = class_descriptor->java_class;
toString = (*jEnv)->GetMethodID(jEnv, java_class, "toString",
"()Ljava/lang/String;");
if (!toString) {
/* All Java objects have a toString method */
jsj_UnexpectedJavaError(cx, jEnv, "No toString() method for class %s!",
class_descriptor->name);
return JS_FALSE;
}
java_str = (*jEnv)->CallObjectMethod(jEnv, java_obj, toString);
if (!java_str) {
jsj_ReportJavaError(cx, jEnv, "toString() method failed");
return JS_FALSE;
}
}
/* Extract Unicode from java.lang.String instance and convert to JS string */
js_str = jsj_ConvertJavaStringToJSString(cx, jEnv, java_str);
if (!js_str)
return JS_FALSE;
*vp = STRING_TO_JSVAL(js_str);
return JS_TRUE;
}
/*
* Convert a Java object to a number by attempting to call the
* doubleValue() method on a Java object to get a double result.
* This usually only works on instances of java.lang.Double, but the code
* is generalized to work with any Java object that supports this method.
*
* Returns JS_TRUE if the call was successful.
* Returns JS_FALSE if conversion is not possible or an error occurs.
*/
JSBool
jsj_ConvertJavaObjectToJSNumber(JSContext *cx, JNIEnv *jEnv,
JavaClassDescriptor *class_descriptor,
jobject java_obj, jsval *vp)
{
jdouble d;
jmethodID doubleValue;
jclass java_class;
java_class = class_descriptor->java_class;
doubleValue = (*jEnv)->GetMethodID(jEnv, java_class, "doubleValue", "()D");
if (!doubleValue) {
/* There is no doubleValue() method for the object. Try toString()
instead and the JS engine will attempt to convert the result to
a number. */
(*jEnv)->ExceptionClear(jEnv);
return jsj_ConvertJavaObjectToJSString(cx, jEnv, class_descriptor,
java_obj, vp);
}
d = (*jEnv)->CallDoubleMethod(jEnv, java_obj, doubleValue);
if ((*jEnv)->ExceptionOccurred(jEnv)) {
jsj_UnexpectedJavaError(cx, jEnv, "doubleValue() method failed");
return JS_FALSE;
}
return JS_NewDoubleValue(cx, d, vp);
}
/*
* Convert a Java object to a boolean by attempting to call the
* booleanValue() method on a Java object to get a boolean result.
* This usually only works on instances of java.lang.Boolean, but the code
* is generalized to work with any Java object that supports this method.
*
* Returns JS_TRUE if the call was successful.
* Returns JS_FALSE if conversion is not possible or an error occurs.
*/
extern JSBool
jsj_ConvertJavaObjectToJSBoolean(JSContext *cx, JNIEnv *jEnv,
JavaClassDescriptor *class_descriptor,
jobject java_obj, jsval *vp)
{
jboolean b;
jmethodID booleanValue;
jclass java_class;
/* Null converts to false. */
if (!java_obj) {
*vp = JSVAL_FALSE;
return JS_TRUE;
}
java_class = class_descriptor->java_class;
booleanValue = (*jEnv)->GetMethodID(jEnv, java_obj, "booleanValue", "()Z");
/* Non-null Java object does not have a booleanValue() method, so
it converts to true. */
if (!booleanValue) {
(*jEnv)->ExceptionClear(jEnv);
*vp = JSVAL_TRUE;
return JS_TRUE;
}
b = (*jEnv)->CallBooleanMethod(jEnv, java_obj, booleanValue);
if ((*jEnv)->ExceptionOccurred(jEnv)) {
jsj_UnexpectedJavaError(cx, jEnv, "booleanValue() method failed");
return JS_FALSE;
}
*vp = BOOLEAN_TO_JSVAL(b);
return JS_TRUE;
}
/*
* Reflect a Java object into a JS value. The source object, java_obj, must
* be of type java.lang.Object or a subclass and may, therefore, be an array.
*/
JSBool
jsj_ConvertJavaObjectToJSValue(JSContext *cx, JNIEnv *jEnv,
jobject java_obj, jsval *vp)
{
jclass java_class;
JSObject *js_obj;
/* A null in Java-land is also null in JS */
if (!java_obj) {
*vp = JSVAL_NULL;
return JS_TRUE;
}
java_class = (*jEnv)->GetObjectClass(jEnv, java_obj);
/*
* If it's an instance of netscape.javascript.JSObject, i.e. a wrapper
* around a JS object that has been passed into the Java world, unwrap
* it to obtain the original JS object.
*/
if (njJSObject && (*jEnv)->IsInstanceOf(jEnv, java_obj, njJSObject)) {
#ifdef PRESERVE_JSOBJECT_IDENTITY
js_obj = (JSObject *)((*jEnv)->GetIntField(jEnv, java_obj, njJSObject_internal));
#else
js_obj = jsj_UnwrapJSObjectWrapper(jEnv, java_obj);
#endif
PR_ASSERT(js_obj);
if (!js_obj)
return JS_FALSE;
*vp = OBJECT_TO_JSVAL(js_obj);
return JS_TRUE;
}
/*
* Instances of java.lang.String are wrapped so we can call methods on
* them, but they convert to a JS string if used in a string context.
*/
/* TODO - let's get rid of this annoying "feature" */
/* otherwise, wrap it inside a JavaObject */
js_obj = jsj_WrapJavaObject(cx, jEnv, java_obj, java_class);
if (!js_obj)
return JS_FALSE;
*vp = OBJECT_TO_JSVAL(js_obj);
return JS_TRUE;
}
/*
* Convert a Java value (primitive or object) to a JS value.
*
* This is usually an infallible operation, but JS_FALSE is returned
* on an out-of-memory condition and the error reporter is called.
*/
JSBool
jsj_ConvertJavaValueToJSValue(JSContext *cx, JNIEnv *jEnv,
JavaSignature *signature,
jvalue *java_value,
jsval *vp)
{
int32 ival32;
switch (signature->type) {
case JAVA_SIGNATURE_VOID:
*vp = JSVAL_VOID;
return JS_TRUE;
case JAVA_SIGNATURE_BYTE:
*vp = INT_TO_JSVAL((jsint)java_value->b);
return JS_TRUE;
case JAVA_SIGNATURE_CHAR:
*vp = INT_TO_JSVAL((jsint)java_value->c);
return JS_TRUE;
case JAVA_SIGNATURE_SHORT:
*vp = INT_TO_JSVAL((jsint)java_value->s);
return JS_TRUE;
case JAVA_SIGNATURE_INT:
ival32 = java_value->i;
if (INT_FITS_IN_JSVAL(ival32)) {
*vp = INT_TO_JSVAL((jsint) ival32);
return JS_TRUE;
} else {
return JS_NewDoubleValue(cx, ival32, vp);
}
case JAVA_SIGNATURE_BOOLEAN:
*vp = BOOLEAN_TO_JSVAL((JSBool) java_value->z);
return JS_TRUE;
case JAVA_SIGNATURE_LONG:
return JS_NewDoubleValue(cx, jlong_to_jdouble(java_value->j), vp);
case JAVA_SIGNATURE_FLOAT:
return JS_NewDoubleValue(cx, java_value->f, vp);
case JAVA_SIGNATURE_DOUBLE:
return JS_NewDoubleValue(cx, java_value->d, vp);
case JAVA_SIGNATURE_CLASS:
case JAVA_SIGNATURE_ARRAY:
return jsj_ConvertJavaObjectToJSValue(cx, jEnv, java_value->l, vp);
default:
PR_ASSERT(0);
return JS_FALSE;
}
}

View File

@@ -0,0 +1,383 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
/*
* This file is part of the Java-vendor-neutral implementation of LiveConnect
*
* It contains the code used to reflect Java fields as properties of
* JavaObject objects and the code to access those fields.
*
*/
#include <stdlib.h>
#include "jsj_private.h" /* LiveConnect internals */
/*
* Add a single field, described by java_field, to the JavaMemberDescriptor
* named by field_name within the given JavaClassDescriptor.
*
* Returns JS_TRUE on success. Otherwise, returns JS_FALSE and reports an error.
*/
static JSBool
add_java_field_to_class_descriptor(JSContext *cx,
JNIEnv *jEnv,
JavaClassDescriptor *class_descriptor,
jstring field_name_jstr,
jobject java_field, /* a java.lang.reflect.Field */
jint modifiers)
{
jclass fieldType;
jfieldID fieldID;
jclass java_class;
JSBool is_static_field;
JavaMemberDescriptor *member_descriptor = NULL;
const char *sig_cstr = NULL;
const char *field_name = NULL;
JavaSignature *signature = NULL;
JavaFieldSpec *field_spec = NULL;
is_static_field = modifiers & ACC_STATIC;
if (is_static_field) {
member_descriptor = jsj_GetJavaStaticMemberDescriptor(cx, jEnv, class_descriptor, field_name_jstr);
} else {
member_descriptor = jsj_GetJavaMemberDescriptor(cx, jEnv, class_descriptor, field_name_jstr);
}
if (!member_descriptor)
goto error;
field_spec = (JavaFieldSpec*)JS_malloc(cx, sizeof(JavaFieldSpec));
if (!field_spec)
goto error;
field_spec->modifiers = modifiers;
/* Get the Java class corresponding to the type of the field */
fieldType = (*jEnv)->CallObjectMethod(jEnv, java_field, jlrField_getType);
if (!fieldType) {
jsj_UnexpectedJavaError(cx, jEnv,
"Unable to determine type of field using"
" java.lang.reflect.Field.getType()");
goto error;
}
signature = jsj_GetJavaClassDescriptor(cx, jEnv, fieldType);
if (!signature)
goto error;
field_spec->signature = signature;
field_name = jsj_DupJavaStringUTF(cx, jEnv, field_name_jstr);
if (!field_name)
goto error;
field_spec->name = field_name;
/* Compute the JNI-style (string-based) signature of the field type */
sig_cstr = jsj_ConvertJavaSignatureToString(cx, signature);
if (!sig_cstr)
goto error;
/* Compute the JNI fieldID and cache it for quick field access */
java_class = class_descriptor->java_class;
if (is_static_field)
fieldID = (*jEnv)->GetStaticFieldID(jEnv, java_class, field_name, sig_cstr);
else
fieldID = (*jEnv)->GetFieldID(jEnv, java_class, field_name, sig_cstr);
if (!fieldID) {
jsj_UnexpectedJavaError(cx, jEnv,
"Can't get Java field ID for class %s, field %s (sig=%s)",
class_descriptor->name, field_name, sig_cstr);
goto error;
}
field_spec->fieldID = fieldID;
JS_free(cx, (char*)sig_cstr);
member_descriptor->field = field_spec;
/* Success */
return JS_TRUE;
error:
if (field_spec) {
JS_FREE_IF(cx, (char*)field_spec->name);
JS_free(cx, field_spec);
}
JS_FREE_IF(cx, (char*)sig_cstr);
if (signature)
jsj_ReleaseJavaClassDescriptor(cx, jEnv, signature);
return JS_FALSE;
}
/*
* Free up a JavaFieldSpec and all its resources.
*/
void
jsj_DestroyFieldSpec(JSContext *cx, JNIEnv *jEnv, JavaFieldSpec *field)
{
JS_FREE_IF(cx, (char*)field->name);
jsj_ReleaseJavaClassDescriptor(cx, jEnv, field->signature);
JS_free(cx, field);
}
/*
* Add a JavaMemberDescriptor to the collection of members in class_descriptor
* for every public field of the identified Java class. (A separate collection
* is kept in class_descriptor for static and instance members.)
* If reflect_only_static_fields is set, instance fields are not reflected. If
* it isn't set, only instance fields are reflected and static fields are not
* reflected.
*
* Returns JS_TRUE on success. Otherwise, returns JS_FALSE and reports an error.
*/
JSBool
jsj_ReflectJavaFields(JSContext *cx, JNIEnv *jEnv, JavaClassDescriptor *class_descriptor,
JSBool reflect_only_static_fields)
{
int i;
JSBool ok;
jint modifiers;
jobject java_field;
jstring field_name_jstr;
jarray joFieldArray;
jsize num_fields;
jclass java_class;
/* Get a java array of java.lang.reflect.Field objects, by calling
java.lang.Class.getFields(). */
java_class = class_descriptor->java_class;
joFieldArray = (*jEnv)->CallObjectMethod(jEnv, java_class, jlClass_getFields);
if (!joFieldArray) {
jsj_UnexpectedJavaError(cx, jEnv,
"Can't determine Java object's fields "
"using java.lang.Class.getFields()");
return JS_FALSE;
}
/* Iterate over the class fields */
num_fields = (*jEnv)->GetArrayLength(jEnv, joFieldArray);
for (i = 0; i < num_fields; i++) {
/* Get the i'th reflected field */
java_field = (*jEnv)->GetObjectArrayElement(jEnv, joFieldArray, i);
if (!java_field) {
jsj_UnexpectedJavaError(cx, jEnv, "Can't access a Field[] array");
return JS_FALSE;
}
/* Get the field modifiers, e.g. static, public, private, etc. */
modifiers = (*jEnv)->CallIntMethod(jEnv, java_field, jlrField_getModifiers);
if ((*jEnv)->ExceptionOccurred(jEnv)) {
jsj_UnexpectedJavaError(cx, jEnv,
"Can't access a Field's modifiers using"
"java.lang.reflect.Field.getModifiers()");
return JS_FALSE;
}
/* Don't allow access to private or protected Java fields. */
if (!(modifiers & ACC_PUBLIC))
continue;
/* Reflect all instance fields or all static fields, but not both */
if (reflect_only_static_fields != ((modifiers & ACC_STATIC) != 0))
continue;
/* Determine the unqualified name of the field */
field_name_jstr = (*jEnv)->CallObjectMethod(jEnv, java_field, jlrField_getName);
if (!field_name_jstr) {
jsj_UnexpectedJavaError(cx, jEnv,
"Can't obtain a Field's name"
"java.lang.reflect.Field.getName()");
return JS_FALSE;
}
/* Add a JavaFieldSpec object to the JavaClassDescriptor */
ok = add_java_field_to_class_descriptor(cx, jEnv, class_descriptor, field_name_jstr,
java_field, modifiers);
if (!ok)
return JS_FALSE;
}
/* Success */
return JS_TRUE;
}
/*
* Read the value of a Java field and return it as a JavaScript value.
* If the field is static, then java_obj is a Java class, otherwise
* it's a Java instance object.
*
* Returns JS_TRUE on success. Otherwise, returns JS_FALSE and reports an error.
*/
JSBool
jsj_GetJavaFieldValue(JSContext *cx, JNIEnv *jEnv, JavaFieldSpec *field_spec,
jobject java_obj, jsval *vp)
{
JSBool is_static_field;
jvalue java_value;
JavaSignature *signature;
JavaSignatureChar field_type;
jfieldID fieldID = field_spec->fieldID;
is_static_field = field_spec->modifiers & ACC_STATIC;
#define GET_JAVA_FIELD(Type,member) \
PR_BEGIN_MACRO \
if (is_static_field) \
java_value.member = \
(*jEnv)->GetStatic##Type##Field(jEnv, java_obj, fieldID); \
else \
java_value.member = \
(*jEnv)->Get##Type##Field(jEnv, java_obj, fieldID); \
if ((*jEnv)->ExceptionOccurred(jEnv)) { \
jsj_UnexpectedJavaError(cx, jEnv, "Error reading Java field"); \
return JS_FALSE; \
} \
PR_END_MACRO
signature = field_spec->signature;
field_type = signature->type;
switch(field_type) {
case JAVA_SIGNATURE_BYTE:
GET_JAVA_FIELD(Byte,b);
break;
case JAVA_SIGNATURE_CHAR:
GET_JAVA_FIELD(Char,c);
break;
case JAVA_SIGNATURE_SHORT:
GET_JAVA_FIELD(Short,s);
break;
case JAVA_SIGNATURE_INT:
GET_JAVA_FIELD(Int,i);
break;
case JAVA_SIGNATURE_BOOLEAN:
GET_JAVA_FIELD(Boolean,z);
break;
case JAVA_SIGNATURE_LONG:
GET_JAVA_FIELD(Long,j);
break;
case JAVA_SIGNATURE_FLOAT:
GET_JAVA_FIELD(Float,f);
break;
case JAVA_SIGNATURE_DOUBLE:
GET_JAVA_FIELD(Double,d);
break;
case JAVA_SIGNATURE_CLASS:
case JAVA_SIGNATURE_ARRAY:
GET_JAVA_FIELD(Object,l);
break;
#undef GET_JAVA_FIELD
default:
PR_ASSERT(0); /* Unknown java type signature */
return JS_FALSE;
}
return jsj_ConvertJavaValueToJSValue(cx, jEnv, signature, &java_value, vp);
}
JSBool
jsj_SetJavaFieldValue(JSContext *cx, JNIEnv *jEnv, JavaFieldSpec *field_spec,
jclass java_obj, jsval js_val)
{
JSBool is_static_field, is_local_ref;
int dummy_cost;
jvalue java_value;
JavaSignature *signature;
JavaSignatureChar field_type;
jfieldID fieldID = field_spec->fieldID;
is_static_field = field_spec->modifiers & ACC_STATIC;
#define SET_JAVA_FIELD(Type,member) \
PR_BEGIN_MACRO \
if (is_static_field) { \
(*jEnv)->SetStatic##Type##Field(jEnv, java_obj, fieldID, \
java_value.member); \
} else { \
(*jEnv)->Set##Type##Field(jEnv, java_obj, fieldID,java_value.member);\
} \
if ((*jEnv)->ExceptionOccurred(jEnv)) { \
jsj_UnexpectedJavaError(cx, jEnv, "Error assigning to Java field"); \
return JS_FALSE; \
} \
PR_END_MACRO
signature = field_spec->signature;
if (!jsj_ConvertJSValueToJavaValue(cx, jEnv, js_val, signature, &dummy_cost,
&java_value, &is_local_ref))
return JS_FALSE;
field_type = signature->type;
switch(field_type) {
case JAVA_SIGNATURE_BYTE:
SET_JAVA_FIELD(Byte,b);
break;
case JAVA_SIGNATURE_CHAR:
SET_JAVA_FIELD(Char,c);
break;
case JAVA_SIGNATURE_SHORT:
SET_JAVA_FIELD(Short,s);
break;
case JAVA_SIGNATURE_INT:
SET_JAVA_FIELD(Int,i);
break;
case JAVA_SIGNATURE_BOOLEAN:
SET_JAVA_FIELD(Boolean,z);
break;
case JAVA_SIGNATURE_LONG:
SET_JAVA_FIELD(Long,j);
break;
case JAVA_SIGNATURE_FLOAT:
SET_JAVA_FIELD(Float,f);
break;
case JAVA_SIGNATURE_DOUBLE:
SET_JAVA_FIELD(Double,d);
break;
case JAVA_SIGNATURE_CLASS:
case JAVA_SIGNATURE_ARRAY:
SET_JAVA_FIELD(Object,l);
if (is_local_ref)
(*jEnv)->DeleteLocalRef(jEnv, java_value.l);
break;
#undef SET_JAVA_FIELD
default:
PR_ASSERT(0); /* Unknown java type signature */
return JS_FALSE;
}
return JS_TRUE;
}

View File

@@ -0,0 +1,487 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
/*
* This is a copy of the NSPR hash-table library, but it has been slightly
* modified to allow an additional argument to be passed into the hash
* key-comparision function. This is used to maintain thread-safety by
* passing in a JNIEnv pointer to the key-comparison function rather
* than storing it in a global. All types,function names, etc. have
* been renamed from their original NSPR names to protect the innocent.
*/
#include <stdlib.h>
#include <string.h>
#include "jsj_hash.h"
#include "prtypes.h"
#ifdef NSPR20
# include "prlog.h"
# include "prbit.h"
#else
# include "prassert.h"
#endif
/* Compute the number of buckets in ht */
#define NBUCKETS(ht) (1 << (JSJ_HASH_BITS - (ht)->shift))
/* The smallest table has 16 buckets */
#define MINBUCKETSLOG2 4
#define MINBUCKETS (1 << MINBUCKETSLOG2)
/* Compute the maximum entries given n buckets that we will tolerate, ~90% */
#define OVERLOADED(n) ((n) - ((n) >> 3))
/* Compute the number of entries below which we shrink the table by half */
#define UNDERLOADED(n) (((n) > MINBUCKETS) ? ((n) >> 2) : 0)
/*
** Stubs for default hash allocator ops.
*/
static void *
DefaultAllocTable(void *pool, size_t size)
{
#if defined(XP_MAC)
#pragma unused (pool)
#endif
return malloc(size);
}
static void
DefaultFreeTable(void *pool, void *item)
{
#if defined(XP_MAC)
#pragma unused (pool)
#endif
free(item);
}
static JSJHashEntry *
DefaultAllocEntry(void *pool, const void *key)
{
#if defined(XP_MAC)
#pragma unused (pool,key)
#endif
return malloc(sizeof(JSJHashEntry));
}
static void
DefaultFreeEntry(void *pool, JSJHashEntry *he, PRUintn flag)
{
#if defined(XP_MAC)
#pragma unused (pool)
#endif
if (flag == HT_FREE_ENTRY)
free(he);
}
static JSJHashAllocOps defaultHashAllocOps = {
DefaultAllocTable, DefaultFreeTable,
DefaultAllocEntry, DefaultFreeEntry
};
PR_IMPLEMENT(JSJHashTable *)
JSJ_NewHashTable(PRUint32 n, JSJHashFunction keyHash,
JSJHashComparator keyCompare, JSJHashComparator valueCompare,
JSJHashAllocOps *allocOps, void *allocPriv)
{
JSJHashTable *ht;
PRUint32 nb;
if (n <= MINBUCKETS) {
n = MINBUCKETSLOG2;
} else {
n = PR_CeilingLog2(n);
if ((PRInt32)n < 0)
return 0;
}
if (!allocOps) allocOps = &defaultHashAllocOps;
ht = (*allocOps->allocTable)(allocPriv, sizeof *ht);
if (!ht)
return 0;
memset(ht, 0, sizeof *ht);
ht->shift = JSJ_HASH_BITS - n;
n = 1 << n;
#if defined(XP_PC) && !defined(_WIN32)
if (n > 16000) {
(*allocOps->freeTable)(allocPriv, ht);
return 0;
}
#endif /* WIN16 */
nb = n * sizeof(JSJHashEntry *);
ht->buckets = (*allocOps->allocTable)(allocPriv, nb);
if (!ht->buckets) {
(*allocOps->freeTable)(allocPriv, ht);
return 0;
}
memset(ht->buckets, 0, nb);
ht->keyHash = keyHash;
ht->keyCompare = keyCompare;
ht->valueCompare = valueCompare;
ht->allocOps = allocOps;
ht->allocPriv = allocPriv;
return ht;
}
PR_IMPLEMENT(void)
JSJ_HashTableDestroy(JSJHashTable *ht)
{
PRUint32 i, n;
JSJHashEntry *he, *next;
JSJHashAllocOps *allocOps = ht->allocOps;
void *allocPriv = ht->allocPriv;
n = NBUCKETS(ht);
for (i = 0; i < n; i++) {
for (he = ht->buckets[i]; he; he = next) {
next = he->next;
(*allocOps->freeEntry)(allocPriv, he, HT_FREE_ENTRY);
}
}
#ifdef DEBUG
memset(ht->buckets, 0xDB, n * sizeof ht->buckets[0]);
#endif
(*allocOps->freeTable)(allocPriv, ht->buckets);
#ifdef DEBUG
memset(ht, 0xDB, sizeof *ht);
#endif
(*allocOps->freeTable)(allocPriv, ht);
}
/*
** Multiplicative hash, from Knuth 6.4.
*/
#define GOLDEN_RATIO 0x9E3779B9U
PR_IMPLEMENT(JSJHashEntry **)
JSJ_HashTableRawLookup(JSJHashTable *ht, JSJHashNumber keyHash, const void *key, void *arg)
{
JSJHashEntry *he, **hep, **hep0;
JSJHashNumber h;
#ifdef HASHMETER
ht->nlookups++;
#endif
h = keyHash * GOLDEN_RATIO;
h >>= ht->shift;
hep = hep0 = &ht->buckets[h];
while ((he = *hep) != 0) {
if (he->keyHash == keyHash && (*ht->keyCompare)(key, he->key, arg)) {
/* Move to front of chain if not already there */
if (hep != hep0) {
*hep = he->next;
he->next = *hep0;
*hep0 = he;
}
return hep0;
}
hep = &he->next;
#ifdef HASHMETER
ht->nsteps++;
#endif
}
return hep;
}
PR_IMPLEMENT(JSJHashEntry *)
JSJ_HashTableRawAdd(JSJHashTable *ht, JSJHashEntry **hep,
JSJHashNumber keyHash, const void *key, void *value,
void *arg)
{
PRUint32 i, n;
JSJHashEntry *he, *next, **oldbuckets;
PRUint32 nb;
/* Grow the table if it is overloaded */
n = NBUCKETS(ht);
if (ht->nentries >= OVERLOADED(n)) {
#ifdef HASHMETER
ht->ngrows++;
#endif
ht->shift--;
oldbuckets = ht->buckets;
#if defined(XP_PC) && !defined(_WIN32)
if (2 * n > 16000)
return 0;
#endif /* WIN16 */
nb = 2 * n * sizeof(JSJHashEntry *);
ht->buckets = (*ht->allocOps->allocTable)(ht->allocPriv, nb);
if (!ht->buckets) {
ht->buckets = oldbuckets;
return 0;
}
memset(ht->buckets, 0, nb);
for (i = 0; i < n; i++) {
for (he = oldbuckets[i]; he; he = next) {
next = he->next;
hep = JSJ_HashTableRawLookup(ht, he->keyHash, he->key, arg);
PR_ASSERT(*hep == 0);
he->next = 0;
*hep = he;
}
}
#ifdef DEBUG
memset(oldbuckets, 0xDB, n * sizeof oldbuckets[0]);
#endif
(*ht->allocOps->freeTable)(ht->allocPriv, oldbuckets);
hep = JSJ_HashTableRawLookup(ht, keyHash, key, arg);
}
/* Make a new key value entry */
he = (*ht->allocOps->allocEntry)(ht->allocPriv, key);
if (!he)
return 0;
he->keyHash = keyHash;
he->key = key;
he->value = value;
he->next = *hep;
*hep = he;
ht->nentries++;
return he;
}
PR_IMPLEMENT(JSJHashEntry *)
JSJ_HashTableAdd(JSJHashTable *ht, const void *key, void *value, void *arg)
{
JSJHashNumber keyHash;
JSJHashEntry *he, **hep;
keyHash = (*ht->keyHash)(key, arg);
hep = JSJ_HashTableRawLookup(ht, keyHash, key, arg);
if ((he = *hep) != 0) {
/* Hit; see if values match */
if ((*ht->valueCompare)(he->value, value, arg)) {
/* key,value pair is already present in table */
return he;
}
if (he->value)
(*ht->allocOps->freeEntry)(ht->allocPriv, he, HT_FREE_VALUE);
he->value = value;
return he;
}
return JSJ_HashTableRawAdd(ht, hep, keyHash, key, value, arg);
}
PR_IMPLEMENT(void)
JSJ_HashTableRawRemove(JSJHashTable *ht, JSJHashEntry **hep, JSJHashEntry *he, void *arg)
{
PRUint32 i, n;
JSJHashEntry *next, **oldbuckets;
PRUint32 nb;
*hep = he->next;
(*ht->allocOps->freeEntry)(ht->allocPriv, he, HT_FREE_ENTRY);
/* Shrink table if it's underloaded */
n = NBUCKETS(ht);
if (--ht->nentries < UNDERLOADED(n)) {
#ifdef HASHMETER
ht->nshrinks++;
#endif
ht->shift++;
oldbuckets = ht->buckets;
nb = n * sizeof(JSJHashEntry*) / 2;
ht->buckets = (*ht->allocOps->allocTable)(ht->allocPriv, nb);
if (!ht->buckets) {
ht->buckets = oldbuckets;
return;
}
memset(ht->buckets, 0, nb);
for (i = 0; i < n; i++) {
for (he = oldbuckets[i]; he; he = next) {
next = he->next;
hep = JSJ_HashTableRawLookup(ht, he->keyHash, he->key, arg);
PR_ASSERT(*hep == 0);
he->next = 0;
*hep = he;
}
}
#ifdef DEBUG
memset(oldbuckets, 0xDB, n * sizeof oldbuckets[0]);
#endif
(*ht->allocOps->freeTable)(ht->allocPriv, oldbuckets);
}
}
PR_IMPLEMENT(PRBool)
JSJ_HashTableRemove(JSJHashTable *ht, const void *key, void *arg)
{
JSJHashNumber keyHash;
JSJHashEntry *he, **hep;
keyHash = (*ht->keyHash)(key, arg);
hep = JSJ_HashTableRawLookup(ht, keyHash, key, arg);
if ((he = *hep) == 0)
return PR_FALSE;
/* Hit; remove element */
JSJ_HashTableRawRemove(ht, hep, he, arg);
return PR_TRUE;
}
PR_IMPLEMENT(void *)
JSJ_HashTableLookup(JSJHashTable *ht, const void *key, void *arg)
{
JSJHashNumber keyHash;
JSJHashEntry *he, **hep;
keyHash = (*ht->keyHash)(key, arg);
hep = JSJ_HashTableRawLookup(ht, keyHash, key, arg);
if ((he = *hep) != 0) {
return he->value;
}
return 0;
}
/*
** Iterate over the entries in the hash table calling func for each
** entry found. Stop if "f" says to (return value & PR_ENUMERATE_STOP).
** Return a count of the number of elements scanned.
*/
PR_IMPLEMENT(int)
JSJ_HashTableEnumerateEntries(JSJHashTable *ht, JSJHashEnumerator f, void *arg)
{
JSJHashEntry *he, **hep;
PRUint32 i, nbuckets;
int rv, n = 0;
JSJHashEntry *todo = 0;
nbuckets = NBUCKETS(ht);
for (i = 0; i < nbuckets; i++) {
hep = &ht->buckets[i];
while ((he = *hep) != 0) {
rv = (*f)(he, n, arg);
n++;
if (rv & (HT_ENUMERATE_REMOVE | HT_ENUMERATE_UNHASH)) {
*hep = he->next;
if (rv & HT_ENUMERATE_REMOVE) {
he->next = todo;
todo = he;
}
} else {
hep = &he->next;
}
if (rv & HT_ENUMERATE_STOP) {
goto out;
}
}
}
out:
hep = &todo;
while ((he = *hep) != 0) {
JSJ_HashTableRawRemove(ht, hep, he, arg);
}
return n;
}
#ifdef HASHMETER
#include <math.h>
#include <stdio.h>
PR_IMPLEMENT(void)
JSJ_HashTableDumpMeter(JSJHashTable *ht, JSJHashEnumerator dump, FILE *fp)
{
double mean, variance;
PRUint32 nchains, nbuckets;
PRUint32 i, n, maxChain, maxChainLen;
JSJHashEntry *he;
variance = 0;
nchains = 0;
maxChainLen = 0;
nbuckets = NBUCKETS(ht);
for (i = 0; i < nbuckets; i++) {
he = ht->buckets[i];
if (!he)
continue;
nchains++;
for (n = 0; he; he = he->next)
n++;
variance += n * n;
if (n > maxChainLen) {
maxChainLen = n;
maxChain = i;
}
}
mean = (double)ht->nentries / nchains;
variance = fabs(variance / nchains - mean * mean);
fprintf(fp, "\nHash table statistics:\n");
fprintf(fp, " number of lookups: %u\n", ht->nlookups);
fprintf(fp, " number of entries: %u\n", ht->nentries);
fprintf(fp, " number of grows: %u\n", ht->ngrows);
fprintf(fp, " number of shrinks: %u\n", ht->nshrinks);
fprintf(fp, " mean steps per hash: %g\n", (double)ht->nsteps
/ ht->nlookups);
fprintf(fp, "mean hash chain length: %g\n", mean);
fprintf(fp, " standard deviation: %g\n", sqrt(variance));
fprintf(fp, " max hash chain length: %u\n", maxChainLen);
fprintf(fp, " max hash chain: [%u]\n", maxChain);
for (he = ht->buckets[maxChain], i = 0; he; he = he->next, i++)
if ((*dump)(he, i, fp) != HT_ENUMERATE_NEXT)
break;
}
#endif /* HASHMETER */
PR_IMPLEMENT(int)
JSJ_HashTableDump(JSJHashTable *ht, JSJHashEnumerator dump, FILE *fp)
{
int count;
count = JSJ_HashTableEnumerateEntries(ht, dump, fp);
#ifdef HASHMETER
JSJ_HashTableDumpMeter(ht, dump, fp);
#endif
return count;
}
PR_IMPLEMENT(JSJHashNumber)
JSJ_HashString(const void *key)
{
JSJHashNumber h;
const unsigned char *s;
h = 0;
for (s = key; *s; s++)
h = (h >> 28) ^ (h << 4) ^ *s;
return h;
}
PR_IMPLEMENT(int)
JSJ_CompareStrings(const void *v1, const void *v2)
{
return strcmp(v1, v2) == 0;
}
PR_IMPLEMENT(int)
JSJ_CompareValues(const void *v1, const void *v2)
{
return v1 == v2;
}

View File

@@ -0,0 +1,141 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
/*
* This is a copy of the NSPR hash-table library, but it has been slightly
* modified to allow an additional argument to be passed into the hash
* key-comparision function. This is used to maintain thread-safety by
* passing in a JNIEnv pointer to the key-comparison function rather
* than storing it in a global. All types,function names, etc. have
* been renamed from their original NSPR names to protect the innocent.
*/
#ifndef jsj_hash_h___
#define jsj_hash_h___
/*
* API to portable hash table code.
*/
#include <stddef.h>
#include <stdio.h>
#include "prtypes.h"
PR_BEGIN_EXTERN_C
typedef struct JSJHashEntry JSJHashEntry;
typedef struct JSJHashTable JSJHashTable;
typedef PRUint32 JSJHashNumber;
#define JSJ_HASH_BITS 32
typedef JSJHashNumber (*JSJHashFunction)(const void *key, void *arg);
typedef PRIntn (*JSJHashComparator)(const void *v1, const void *v2, void *arg);
typedef PRIntn (*JSJHashEnumerator)(JSJHashEntry *he, PRIntn i, void *arg);
/* Flag bits in JSJHashEnumerator's return value */
#define HT_ENUMERATE_NEXT 0 /* continue enumerating entries */
#define HT_ENUMERATE_STOP 1 /* stop enumerating entries */
#define HT_ENUMERATE_REMOVE 2 /* remove and free the current entry */
#define HT_ENUMERATE_UNHASH 4 /* just unhash the current entry */
typedef struct JSJHashAllocOps {
void * (*allocTable)(void *pool, size_t size);
void (*freeTable)(void *pool, void *item);
JSJHashEntry * (*allocEntry)(void *pool, const void *key);
void (*freeEntry)(void *pool, JSJHashEntry *he, PRUintn flag);
} JSJHashAllocOps;
#define HT_FREE_VALUE 0 /* just free the entry's value */
#define HT_FREE_ENTRY 1 /* free value and entire entry */
struct JSJHashEntry {
JSJHashEntry *next; /* hash chain linkage */
JSJHashNumber keyHash; /* key hash function result */
const void *key; /* ptr to opaque key */
void *value; /* ptr to opaque value */
};
struct JSJHashTable {
JSJHashEntry **buckets; /* vector of hash buckets */
PRUint32 nentries; /* number of entries in table */
PRUint32 shift; /* multiplicative hash shift */
JSJHashFunction keyHash; /* key hash function */
JSJHashComparator keyCompare; /* key comparison function */
JSJHashComparator valueCompare; /* value comparison function */
JSJHashAllocOps *allocOps; /* allocation operations */
void *allocPriv; /* allocation private data */
#ifdef HASHMETER
PRUint32 nlookups; /* total number of lookups */
PRUint32 nsteps; /* number of hash chains traversed */
PRUint32 ngrows; /* number of table expansions */
PRUint32 nshrinks; /* number of table contractions */
#endif
};
/*
* Create a new hash table.
* If allocOps is null, use default allocator ops built on top of malloc().
*/
PR_EXTERN(JSJHashTable *)
JSJ_NewHashTable(PRUint32 n, JSJHashFunction keyHash,
JSJHashComparator keyCompare, JSJHashComparator valueCompare,
JSJHashAllocOps *allocOps, void *allocPriv);
PR_EXTERN(void)
JSJ_HashTableDestroy(JSJHashTable *ht);
/* Low level access methods */
PR_EXTERN(JSJHashEntry **)
JSJ_HashTableRawLookup(JSJHashTable *ht, JSJHashNumber keyHash, const void *key, void *arg);
PR_EXTERN(JSJHashEntry *)
JSJ_HashTableRawAdd(JSJHashTable *ht, JSJHashEntry **hep, JSJHashNumber keyHash,
const void *key, void *value, void *arg);
PR_EXTERN(void)
JSJ_HashTableRawRemove(JSJHashTable *ht, JSJHashEntry **hep, JSJHashEntry *he, void *arg);
/* Higher level access methods */
PR_EXTERN(JSJHashEntry *)
JSJ_HashTableAdd(JSJHashTable *ht, const void *key, void *value, void *arg);
PR_EXTERN(PRBool)
JSJ_HashTableRemove(JSJHashTable *ht, const void *key, void *arg);
PR_EXTERN(PRIntn)
JSJ_HashTableEnumerateEntries(JSJHashTable *ht, JSJHashEnumerator f, void *arg);
PR_EXTERN(void *)
JSJ_HashTableLookup(JSJHashTable *ht, const void *key, void *arg);
PR_EXTERN(PRIntn)
JSJ_HashTableDump(JSJHashTable *ht, JSJHashEnumerator dump, FILE *fp);
/* General-purpose C string hash function. */
PR_EXTERN(JSJHashNumber)
JSJ_HashString(const void *key);
/* Compare strings using strcmp(), return true if equal. */
PR_EXTERN(int)
JSJ_CompareStrings(const void *v1, const void *v2);
/* Stub function just returns v1 == v2 */
PR_EXTERN(PRIntn)
JSJ_CompareValues(const void *v1, const void *v2);
PR_END_EXTERN_C
#endif /* jsj_hash_h___ */

File diff suppressed because it is too large Load Diff

View File

View File

@@ -0,0 +1,552 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
/*
* This file is part of the Java-vendor-neutral implementation of LiveConnect
*
* Declarations of private (internal) functions/data/types for
* JavaScript <==> Java communication.
*
*/
#ifndef _JSJAVA_PVT_H
#define _JSJAVA_PVT_H
#include "prtypes.h"
/* NSPR1 compatibility definitions */
#ifdef NSPR20
# include "prprf.h"
# include "prlog.h"
# include "plhash.h" /* NSPR hash-tables */
#else
# include "prprintf.h"
# include "prassert.h"
# include "prhash.h" /* NSPR hash-tables */
# define PRHashNumber prhashcode
#endif
#ifdef XP_MAC
# include "prosdep.h"
#endif
#include "jsj_hash.h" /* Hash tables */
#include "jni.h" /* Java Native Interface */
#include "jsapi.h" /* JavaScript engine API */
#include "jsjava.h" /* LiveConnect public API */
/*************************** Type Declarations ******************************/
/* Forward type declarations */
typedef struct JavaMemberDescriptor JavaMemberDescriptor;
typedef struct JavaMethodSpec JavaMethodSpec;
typedef struct JavaClassDescriptor JavaClassDescriptor;
typedef struct JavaClassDescriptor JavaSignature;
typedef struct CapturedJSError CapturedJSError;
typedef struct JavaMemberVal JavaMemberVal;
/*
* This enum uses the same character encoding used by the JDK to encode
* Java type signatures, but the enum is easier to debug/compile with.
*/
typedef enum {
JAVA_SIGNATURE_ARRAY = '[',
JAVA_SIGNATURE_BYTE = 'B',
JAVA_SIGNATURE_CHAR = 'C',
JAVA_SIGNATURE_CLASS = 'L',
JAVA_SIGNATURE_FLOAT = 'F',
JAVA_SIGNATURE_DOUBLE = 'D',
JAVA_SIGNATURE_INT = 'I',
JAVA_SIGNATURE_LONG = 'J',
JAVA_SIGNATURE_SHORT = 'S',
JAVA_SIGNATURE_VOID = 'V',
JAVA_SIGNATURE_BOOLEAN = 'Z',
JAVA_SIGNATURE_UNKNOWN = 0
} JavaSignatureChar;
/* The signature of a Java method consists of the signatures of all its
arguments and its return type signature. */
typedef struct JavaMethodSignature {
jsize num_args; /* Length of arg_signatures array */
JavaSignature ** arg_signatures; /* Array of argument signatures */
JavaSignature * return_val_signature; /* Return type signature */
} JavaMethodSignature;
/* A descriptor for the reflection of a single Java field */
typedef struct JavaFieldSpec {
jfieldID fieldID; /* JVM opaque access handle for field */
JavaSignature * signature; /* Java type of field */
int modifiers; /* Bitfield indicating field qualifiers */
const char * name; /* UTF8; TODO - Should support Unicode field names */
} JavaFieldSpec;
/* A descriptor for the reflection of a single Java method.
Each overloaded method has a separate corresponding JavaMethodSpec. */
struct JavaMethodSpec {
jmethodID methodID; /* JVM opaque access handle for method */
JavaMethodSignature signature;
const char * name; /* UTF8; TODO - Should support Unicode method names */
JavaMethodSpec * next; /* next method in chain of overloaded methods */
};
/*
* A descriptor for the reflection of a single member of a Java object.
* This can represent one or more Java methods and/or a single field.
* (When there is more than one method attached to a single JavaMemberDescriptor
* they are overloaded methods sharing the same simple name.) This same
* descriptor type is used for both static or instance members.
*/
struct JavaMemberDescriptor {
const char * name; /* simple name of field and/or method */
jsid id; /* hashed name for quick JS property lookup */
JavaFieldSpec * field; /* field with the given name, if any */
JavaMethodSpec * methods; /* Overloaded methods which share the same name, if any */
JavaMemberDescriptor * next; /* next descriptor in same defining class */
JSObject * invoke_func_obj; /* If non-null, JSFunction obj to invoke method */
};
/* This is the native portion of a reflected Java class */
struct JavaClassDescriptor {
const char * name; /* Name of class, e.g. "java/lang/Byte" */
JavaSignatureChar type; /* class category: primitive type, object, array */
jclass java_class; /* Opaque JVM handle to corresponding java.lang.Class */
int num_instance_members;
int num_static_members;
JSBool instance_members_reflected;
JavaMemberDescriptor * instance_members;
JSBool static_members_reflected;
JavaMemberDescriptor * static_members;
JavaMemberDescriptor * constructors;
int modifiers; /* Class declaration qualifiers,
e.g. abstract, private */
int ref_count; /* # of references to this struct */
JavaSignature * array_component_signature; /* Only non-NULL for array classes */
};
/* This is the native portion of a reflected Java method or field */
struct JavaMemberVal {
jsval field_val; /* Captured value of Java field */
jsval invoke_method_func_val; /* JSFunction wrapper around Java method invoker */
JavaMemberDescriptor * descriptor;
JavaMemberVal * next;
};
/* This is the native portion of a reflected Java object */
typedef struct JavaObjectWrapper {
jobject java_obj; /* Opaque JVM ref to Java object */
JavaClassDescriptor * class_descriptor; /* Java class info */
} JavaObjectWrapper;
/* These are definitions of the Java class/method/field modifier bits.
These really shouldn't be hard-coded here. Rather,
they should be read from java.lang.reflect.Modifier */
#define ACC_PUBLIC 0x0001 /* visible to everyone */
#define ACC_STATIC 0x0008 /* instance variable is static */
#define ACC_FINAL 0x0010 /* no further subclassing,overriding */
#define ACC_INTERFACE 0x0200 /* class is an interface */
#define ACC_ABSTRACT 0x0400 /* no definition provided */
/* A JSJavaVM structure must be created for each Java VM that is accessed
via LiveConnect */
struct JSJavaVM {
/* TODO - all LiveConnect global variables should be migrated into this
structure in order to allow more than one LiveConnect-enabled
Java VM to exist within the same process. */
SystemJavaVM * java_vm;
JNIEnv * main_thread_env; /* Main-thread Java environment */
JSBool jsj_created_java_vm;
int num_attached_threads;
JSJavaVM * next; /* next VM among all created VMs */
};
/* Per-thread state that encapsulates the connection to the Java VM */
struct JSJavaThreadState {
const char * name; /* Thread name, for debugging */
JSJavaVM * jsjava_vm; /* All per-JVM state */
JNIEnv * jEnv; /* Per-thread opaque handle to Java VM */
CapturedJSError * pending_js_errors; /* JS errors to be thrown as Java exceptions */
JSContext * cx; /* current JS context for thread */
JSJavaThreadState * next; /* next thread state among all created threads */
};
struct JavaToJSSavedState {
JSErrorReporter error_reporter;
JSJavaThreadState* java_jsj_env;
};
typedef struct JavaToJSSavedState JavaToJSSavedState;
/******************************** Globals ***********************************/
extern JSJCallbacks *JSJ_callbacks;
/* JavaScript classes that reflect Java objects */
extern JSClass JavaObject_class;
extern JSClass JavaArray_class;
extern JSClass JavaClass_class;
extern JSClass JavaMember_class;
/*
* Opaque JVM handles to Java classes, methods and objects required for
* Java reflection. These are computed and cached during initialization.
* TODO: These should be moved inside the JSJavaVM struct
*/
extern jclass jlObject; /* java.lang.Object */
extern jclass jlrConstructor; /* java.lang.reflect.Constructor */
extern jclass jlThrowable; /* java.lang.Throwable */
extern jclass jlSystem; /* java.lang.System */
extern jclass jlClass; /* java.lang.Class */
extern jclass jlBoolean; /* java.lang.Boolean */
extern jclass jlDouble; /* java.lang.Double */
extern jclass jlString; /* java.lang.String */
extern jclass njJSObject; /* netscape.javascript.JSObject */
extern jclass njJSException; /* netscape.javascript.JSException */
extern jclass njJSUtil; /* netscape.javascript.JSUtil */
extern jmethodID jlClass_getMethods; /* java.lang.Class.getMethods() */
extern jmethodID jlClass_getConstructors; /* java.lang.Class.getConstructors() */
extern jmethodID jlClass_getFields; /* java.lang.Class.getFields() */
extern jmethodID jlClass_getName; /* java.lang.Class.getName() */
extern jmethodID jlClass_getComponentType; /* java.lang.Class.getComponentType() */
extern jmethodID jlClass_getModifiers; /* java.lang.Class.getModifiers() */
extern jmethodID jlClass_isArray; /* java.lang.Class.isArray() */
extern jmethodID jlrMethod_getName; /* java.lang.reflect.Method.getName() */
extern jmethodID jlrMethod_getParameterTypes; /* java.lang.reflect.Method.getParameterTypes() */
extern jmethodID jlrMethod_getReturnType; /* java.lang.reflect.Method.getReturnType() */
extern jmethodID jlrMethod_getModifiers; /* java.lang.reflect.Method.getModifiers() */
extern jmethodID jlrConstructor_getParameterTypes; /* java.lang.reflect.Constructor.getParameterTypes() */
extern jmethodID jlrConstructor_getModifiers; /* java.lang.reflect.Constructor.getModifiers() */
extern jmethodID jlrField_getName; /* java.lang.reflect.Field.getName() */
extern jmethodID jlrField_getType; /* java.lang.reflect.Field.getType() */
extern jmethodID jlrField_getModifiers; /* java.lang.reflect.Field.getModifiers() */
extern jmethodID jlThrowable_getMessage; /* java.lang.Throwable.getMessage() */
extern jmethodID jlThrowable_toString; /* java.lang.Throwable.toString() */
extern jmethodID jlBoolean_Boolean; /* java.lang.Boolean constructor */
extern jmethodID jlBoolean_booleanValue; /* java.lang.Boolean.booleanValue() */
extern jmethodID jlDouble_Double; /* java.lang.Double constructor */
extern jmethodID jlDouble_doubleValue; /* java.lang.Double.doubleValue() */
extern jmethodID jlSystem_identityHashCode; /* java.lang.System.identityHashCode() */
extern jobject jlVoid_TYPE; /* java.lang.Void.TYPE value */
extern jmethodID njJSException_JSException; /* netscape.javascipt.JSexception constructor */
extern jmethodID njJSObject_JSObject; /* netscape.javascript.JSObject constructor */
extern jmethodID njJSUtil_getStackTrace; /* netscape.javascript.JSUtil.getStackTrace() */
extern jfieldID njJSObject_internal; /* netscape.javascript.JSObject.internal */
extern jfieldID njJSException_lineno; /* netscape.javascript.JSException.lineno */
extern jfieldID njJSException_tokenIndex; /* netscape.javascript.JSException.tokenIndex */
extern jfieldID njJSException_source; /* netscape.javascript.JSException.source */
extern jfieldID njJSException_filename; /* netscape.javascript.JSException.filename */
/**************** Java <==> JS conversions and Java types *******************/
extern JSBool
jsj_ComputeJavaClassSignature(JSContext *cx,
JavaSignature *signature,
jclass java_class);
extern const char *
jsj_ConvertJavaSignatureToString(JSContext *cx, JavaSignature *signature);
extern const char *
jsj_ConvertJavaSignatureToHRString(JSContext *cx,
JavaSignature *signature);
extern JavaMethodSignature *
jsj_InitJavaMethodSignature(JSContext *cx, JNIEnv *jEnv, jobject method,
JavaMethodSignature *method_signature);
extern const char *
jsj_ConvertJavaMethodSignatureToString(JSContext *cx,
JavaMethodSignature *method_signature);
extern const char *
jsj_ConvertJavaMethodSignatureToHRString(JSContext *cx,
const char *method_name,
JavaMethodSignature *method_signature);
extern void
jsj_PurgeJavaMethodSignature(JSContext *cx, JNIEnv *jEnv, JavaMethodSignature *signature);
extern JSBool
jsj_ConvertJSValueToJavaValue(JSContext *cx, JNIEnv *jEnv, jsval v, JavaSignature *signature,
int *cost, jvalue *java_value, JSBool *is_local_refp);
extern JSBool
jsj_ConvertJSValueToJavaObject(JSContext *cx, JNIEnv *jEnv, jsval v, JavaSignature *signature,
int *cost, jobject *java_value, JSBool *is_local_refp);
extern jstring
jsj_ConvertJSStringToJavaString(JSContext *cx, JNIEnv *jEnv, JSString *js_str);
extern JSBool
jsj_ConvertJavaValueToJSValue(JSContext *cx, JNIEnv *jEnv, JavaSignature *signature,
jvalue *java_value, jsval *vp);
extern JSBool
jsj_ConvertJavaObjectToJSValue(JSContext *cx, JNIEnv *jEnv,
jobject java_obj, jsval *vp);
extern JSString *
jsj_ConvertJavaStringToJSString(JSContext *cx, JNIEnv *jEnv, jstring java_str);
extern JSBool
jsj_ConvertJavaObjectToJSString(JSContext *cx, JNIEnv *jEnv,
JavaClassDescriptor *class_descriptor,
jobject java_obj, jsval *vp);
extern JSBool
jsj_ConvertJavaObjectToJSNumber(JSContext *cx, JNIEnv *jEnv,
JavaClassDescriptor *class_descriptor,
jobject java_obj, jsval *vp);
extern JSBool
jsj_ConvertJavaObjectToJSBoolean(JSContext *cx, JNIEnv *jEnv,
JavaClassDescriptor *class_descriptor,
jobject java_obj, jsval *vp);
extern JSJavaThreadState *
jsj_enter_js(JNIEnv *jEnv, jobject java_wrapper_obj,
JSContext **cxp, JSObject **js_objp, JavaToJSSavedState* saved_state);
extern JSBool
jsj_exit_js(JSContext *cx, JSJavaThreadState *jsj_env, JavaToJSSavedState* original_state);
extern JavaClassDescriptor *
jsj_get_jlObject_descriptor(JSContext *cx, JNIEnv *jEnv);
extern JSBool
jsj_remove_js_obj_reflection_from_hashtable(JSContext *cx, JSObject *js_obj);
extern JSBool
jsj_init_js_obj_reflections_table();
/************************ Java package reflection **************************/
extern JSBool
jsj_init_JavaPackage(JSContext *, JSObject *,
JavaPackageDef *predefined_packages);
/************************* Java class reflection ***************************/
extern JSBool
jsj_init_JavaClass(JSContext *cx, JSObject *global_obj);
extern void
jsj_DiscardJavaClassReflections(JNIEnv *jEnv);
extern const char *
jsj_GetJavaClassName(JSContext *cx, JNIEnv *jEnv, jclass java_class);
extern JavaClassDescriptor *
jsj_GetJavaClassDescriptor(JSContext *cx, JNIEnv *jEnv, jclass java_class);
extern void
jsj_ReleaseJavaClassDescriptor(JSContext *cx, JNIEnv *jEnv, JavaClassDescriptor *class_descriptor);
extern JSObject *
jsj_define_JavaClass(JSContext *cx, JNIEnv *jEnv, JSObject *obj,
const char *unqualified_class_name,
jclass jclazz);
extern JavaMemberDescriptor *
jsj_GetJavaMemberDescriptor(JSContext *cx,
JNIEnv *jEnv,
JavaClassDescriptor *class_descriptor,
jstring member_name);
extern JavaMemberDescriptor *
jsj_LookupJavaMemberDescriptorById(JSContext *cx, JNIEnv *jEnv,
JavaClassDescriptor *class_descriptor,
jsid id);
extern JavaMemberDescriptor *
jsj_LookupJavaStaticMemberDescriptorById(JSContext *cx, JNIEnv *jEnv,
JavaClassDescriptor *class_descriptor,
jsid id);
extern JavaMemberDescriptor *
jsj_GetJavaStaticMemberDescriptor(JSContext *cx, JNIEnv *jEnv,
JavaClassDescriptor *class_descriptor,
jstring member_name);
extern JavaMemberDescriptor *
jsj_GetJavaClassConstructors(JSContext *cx,
JavaClassDescriptor *class_descriptor);
extern JavaMemberDescriptor *
jsj_LookupJavaClassConstructors(JSContext *cx, JNIEnv *jEnv,
JavaClassDescriptor *class_descriptor);
extern JavaMemberDescriptor *
jsj_GetClassInstanceMembers(JSContext *cx, JNIEnv *jEnv,
JavaClassDescriptor *class_descriptor);
extern JavaMemberDescriptor *
jsj_GetClassStaticMembers(JSContext *cx, JNIEnv *jEnv,
JavaClassDescriptor *class_descriptor);
extern JSBool
jsj_InitJavaClassReflectionsTable();
/************************* Java field reflection ***************************/
extern JSBool
jsj_GetJavaFieldValue(JSContext *cx, JNIEnv *jEnv, JavaFieldSpec *field_spec,
jobject java_obj, jsval *vp);
extern JSBool
jsj_SetJavaFieldValue(JSContext *cx, JNIEnv *jEnv, JavaFieldSpec *field_spec,
jobject java_obj, jsval js_val);
extern JSBool
jsj_ReflectJavaFields(JSContext *cx, JNIEnv *jEnv,
JavaClassDescriptor *class_descriptor,
JSBool reflect_only_static_fields);
extern void
jsj_DestroyFieldSpec(JSContext *cx, JNIEnv *jEnv, JavaFieldSpec *field);
/************************* Java method reflection ***************************/
extern JSBool
jsj_JavaInstanceMethodWrapper(JSContext *cx, JSObject *obj,
uintN argc, jsval *argv, jsval *vp);
extern JSBool
jsj_JavaStaticMethodWrapper(JSContext *cx, JSObject *obj,
uintN argc, jsval *argv, jsval *vp);
extern JSBool
jsj_JavaConstructorWrapper(JSContext *cx, JSObject *obj,
uintN argc, jsval *argv, jsval *vp);
extern JSBool
jsj_ReflectJavaMethods(JSContext *cx, JNIEnv *jEnv,
JavaClassDescriptor *class_descriptor,
JSBool reflect_only_static_methods);
extern void
jsj_DestroyMethodSpec(JSContext *cx, JNIEnv *jEnv, JavaMethodSpec *method_spec);
/************************* Java member reflection ***************************/
extern JSBool
jsj_init_JavaMember(JSContext *, JSObject *);
extern JSBool
jsj_ReflectJavaMethodsAndFields(JSContext *cx, JavaClassDescriptor *class_descriptor,
JSBool reflect_only_statics);
extern JSObject *
jsj_CreateJavaMember(JSContext *cx, jsval method_val, jsval field_val);
/************************* Java object reflection **************************/
extern JSBool
jsj_init_JavaObject(JSContext *, JSObject *);
extern JSObject *
jsj_WrapJavaObject(JSContext *cx, JNIEnv *jEnv, jobject java_obj, jclass java_class);
extern void
jsj_DiscardJavaObjReflections(JNIEnv *jEnv);
extern JSBool
JavaObject_convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp);
extern void
JavaObject_finalize(JSContext *cx, JSObject *obj);
extern JSBool
JavaObject_resolve(JSContext *cx, JSObject *obj, jsval id);
extern JSBool
JavaObject_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
extern JSBool
JavaObject_getPropertyById(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
/************************* Java array reflection ***************************/
extern JSBool
jsj_init_JavaArray(JSContext *cx, JSObject *global_obj);
extern JSBool
jsj_GetJavaArrayElement(JSContext *cx, JNIEnv *jEnv, jarray java_array,
jsize index, JavaSignature *array_component_signature,
jsval *vp);
extern JSBool
jsj_SetJavaArrayElement(JSContext *cx, JNIEnv *jEnv, jarray java_array,
jsize index, JavaSignature *array_component_signature,
jsval js_val);
/********************* JavaScript object reflection ************************/
extern jobject
jsj_WrapJSObject(JSContext *cx, JNIEnv *jEnv, JSObject *js_obj);
extern JSObject *
jsj_UnwrapJSObjectWrapper(JNIEnv *jEnv, jobject java_wrapper_obj);
extern void
jsj_ClearPendingJSErrors(JSJavaThreadState *jsj_env);
extern JSBool
jsj_ReportUncaughtJSException(JSContext *cx, JNIEnv *jEnv, jthrowable java_exception);
/**************************** Utilities ************************************/
extern void
jsj_ReportJavaError(JSContext *cx, JNIEnv *env, const char *format, ...);
extern void
jsj_UnexpectedJavaError(JSContext *cx, JNIEnv *env, const char *format, ...);
extern const char *
jsj_GetJavaErrorMessage(JNIEnv *env);
extern void
jsj_LogError(const char *error_msg);
PR_CALLBACK JSJHashNumber
jsj_HashJavaObject(const void *key, void* env);
PR_CALLBACK intN
jsj_JavaObjectComparator(const void *v1, const void *v2, void *arg);
extern JSJavaThreadState *
jsj_MapJavaThreadToJSJavaThreadState(JNIEnv *jEnv, char **errp);
extern void
jsj_MakeJNIClassname(char *jClassName);
extern const char *
jsj_ClassNameOfJavaObject(JSContext *cx, JNIEnv *jEnv, jobject java_object);
extern jsize
jsj_GetJavaArrayLength(JSContext *cx, JNIEnv *jEnv, jarray java_array);
extern JSBool
JavaStringToId(JSContext *cx, JNIEnv *jEnv, jstring jstr, jsid *idp);
extern const char *
jsj_DupJavaStringUTF(JSContext *cx, JNIEnv *jEnv, jstring jstr);
JSJavaThreadState *
jsj_MapJSContextToJSJThread(JSContext *cx, JNIEnv **envp);
JSJavaThreadState *
jsj_SetJavaJSJEnv(JSJavaThreadState* java_jsj_env);
#ifdef DEBUG
#define DEBUG_LOG(args) printf args
#endif
#define JS_FREE_IF(cx, x) \
PR_BEGIN_MACRO \
if (x) \
JS_free(cx, x); \
PR_END_MACRO
#endif /* _JSJAVA_PVT_H */

View File

@@ -0,0 +1,361 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
/*
* This file is part of the Java-vendor-neutral implementation of LiveConnect
*
* It contains low-level utility code.
*
*/
#include <stdlib.h>
#include <string.h>
#include "jsj_private.h" /* LiveConnect internals */
#include "jsjava.h" /* External LiveConnect API */
/*
* This is a hash-table utility routine that computes the hash code of a Java
* object by calling java.lang.System.identityHashCode()
*/
PR_CALLBACK JSJHashNumber
jsj_HashJavaObject(const void *key, void* env)
{
PRHashNumber hash_code;
jobject java_obj;
JNIEnv *jEnv;
java_obj = (jobject)key;
jEnv = (JNIEnv*) env;
hash_code = (*jEnv)->CallStaticIntMethod(jEnv, jlSystem,
jlSystem_identityHashCode, java_obj);
PR_ASSERT(!(*jEnv)->ExceptionOccurred(jEnv));
return hash_code;
}
/*
* This is a hash-table utility routine for comparing two Java objects.
* It's not possible to use the == operator to directly compare two jobject's,
* since they're opaque references and aren't guaranteed to be simple pointers
* or handles (though they may be in some JVM implementations). Instead,
* use the JNI routine for comparing the two objects.
*/
PR_CALLBACK intN
jsj_JavaObjectComparator(const void *v1, const void *v2, void *arg)
{
jobject java_obj1, java_obj2;
JNIEnv *jEnv;
jEnv = (JNIEnv*)arg;
java_obj1 = (jobject)v1;
java_obj2 = (jobject)v2;
if (java_obj1 == java_obj2)
return 1;
return (*jEnv)->IsSameObject(jEnv, java_obj1, java_obj2);
}
/*
* Return a UTF8, null-terminated encoding of a Java string. The string must
* be free'ed by the caller.
*
* If an error occurs, returns NULL and calls the JS error reporter.
*/
const char *
jsj_DupJavaStringUTF(JSContext *cx, JNIEnv *jEnv, jstring jstr)
{
const char *str, *retval;
str = (*jEnv)->GetStringUTFChars(jEnv, jstr, 0);
if (!str) {
jsj_UnexpectedJavaError(cx, jEnv, "Can't get UTF8 characters from "
"Java string");
return NULL;
}
retval = JS_strdup(cx, str);
(*jEnv)->ReleaseStringUTFChars(jEnv, jstr, str);
return retval;
}
JSBool
JavaStringToId(JSContext *cx, JNIEnv *jEnv, jstring jstr, jsid *idp)
{
const jschar *ucs2;
JSString *jsstr;
jsize ucs2_len;
jsval val;
ucs2 = (*jEnv)->GetStringChars(jEnv, jstr, 0);
if (!ucs2) {
jsj_UnexpectedJavaError(cx, jEnv, "Couldn't obtain Unicode characters"
"from Java string");
return JS_FALSE;
}
ucs2_len = (*jEnv)->GetStringLength(jEnv, jstr);
jsstr = JS_InternUCStringN(cx, ucs2, ucs2_len);
(*jEnv)->ReleaseStringChars(jEnv, jstr, ucs2);
if (!jsstr)
return JS_FALSE;
val = STRING_TO_JSVAL(jsstr);
JS_ValueToId(cx, STRING_TO_JSVAL(jsstr), idp);
return JS_TRUE;
}
/* Not used ?
const char *
jsj_ClassNameOfJavaObject(JSContext *cx, JNIEnv *jEnv, jobject java_object)
{
jobject java_class;
java_class = (*jEnv)->GetObjectClass(jEnv, java_object);
if (!java_class) {
PR_ASSERT(0);
return NULL;
}
return jsj_GetJavaClassName(cx, jEnv, java_class);
}
*/
/*
* Return, as a C string, the error message associated with a Java exception
* that occurred as a result of a JNI call, preceded by the class name of
* the exception. As a special case, if the class of the exception is
* netscape.javascript.JSException, the exception class name is omitted.
*
* NULL is returned if no Java exception is pending. The caller is
* responsible for free'ing the returned string. On exit, the Java exception
* is *not* cleared.
*/
const char *
jsj_GetJavaErrorMessage(JNIEnv *jEnv)
{
const char *java_error_msg;
char *error_msg = NULL;
jthrowable exception;
jstring java_exception_jstring;
exception = (*jEnv)->ExceptionOccurred(jEnv);
if (exception && jlThrowable_toString) {
java_exception_jstring =
(*jEnv)->CallObjectMethod(jEnv, exception, jlThrowable_toString);
java_error_msg = (*jEnv)->GetStringUTFChars(jEnv, java_exception_jstring, NULL);
error_msg = strdup((char*)java_error_msg);
(*jEnv)->ReleaseStringUTFChars(jEnv, java_exception_jstring, java_error_msg);
#ifdef DEBUG
/* (*jEnv)->ExceptionDescribe(jEnv); */
#endif
}
return error_msg;
}
/*
* Return, as a C string, the JVM stack trace associated with a Java
* exception, as would be printed by java.lang.Throwable.printStackTrace().
* The caller is responsible for free'ing the returned string.
*
* Returns NULL if an error occurs.
*/
static const char *
get_java_stack_trace(JSContext *cx, JNIEnv *jEnv, jthrowable java_exception)
{
const char *backtrace;
jstring backtrace_jstr;
backtrace = NULL;
if (java_exception && njJSUtil_getStackTrace) {
backtrace_jstr = (*jEnv)->CallStaticObjectMethod(jEnv, njJSUtil,
njJSUtil_getStackTrace,
java_exception);
if (!backtrace_jstr) {
jsj_UnexpectedJavaError(cx, jEnv, "Unable to get exception stack trace");
return NULL;
}
backtrace = jsj_DupJavaStringUTF(cx, jEnv, backtrace_jstr);
}
return backtrace;
}
/* Full Java backtrace when Java exceptions reported to JavaScript */
#define REPORT_JAVA_EXCEPTION_STACK_TRACE
/*
* This is a wrapper around JS_ReportError(), useful when an error condition
* is the result of a JVM failure or exception condition. It appends the
* message associated with the pending Java exception to the passed in
* printf-style format string and arguments.
*/
static void
vreport_java_error(JSContext *cx, JNIEnv *jEnv, const char *format, va_list ap)
{
char *error_msg, *js_error_msg;
const char *java_stack_trace;
const char *java_error_msg;
jthrowable java_exception;
java_error_msg = NULL;
java_exception = (*jEnv)->ExceptionOccurred(jEnv);
if (java_exception && njJSException &&
(*jEnv)->IsInstanceOf(jEnv, java_exception, njJSException)) {
(*jEnv)->ExceptionClear(jEnv);
jsj_ReportUncaughtJSException(cx, jEnv, java_exception);
return;
}
js_error_msg = PR_vsmprintf(format, ap);
if (!js_error_msg) {
PR_ASSERT(0); /* Out-of-memory */
return;
}
#ifdef REPORT_JAVA_EXCEPTION_STACK_TRACE
java_stack_trace = get_java_stack_trace(cx, jEnv, java_exception);
if (java_stack_trace) {
error_msg = PR_smprintf("%s\n%s", js_error_msg, java_stack_trace);
free((char*)java_stack_trace);
if (!error_msg) {
PR_ASSERT(0); /* Out-of-memory */
return;
}
} else
#endif
{
java_error_msg = jsj_GetJavaErrorMessage(jEnv);
if (java_error_msg) {
error_msg = PR_smprintf("%s (%s)\n", js_error_msg, java_error_msg);
free((char*)java_error_msg);
free(js_error_msg);
} else {
error_msg = js_error_msg;
}
}
JS_ReportError(cx, error_msg);
/* Important: the Java exception must not be cleared until the reporter
has been called, because the capture_js_error_reports_for_java(),
called from JS_ReportError(), needs to read the exception from the JVM */
(*jEnv)->ExceptionClear(jEnv);
free(error_msg);
}
void
jsj_ReportJavaError(JSContext *cx, JNIEnv *env, const char *format, ...)
{
va_list ap;
va_start(ap, format);
vreport_java_error(cx, env, format, ap);
va_end(ap);
}
/*
* Same as jsj_ReportJavaError, except "internal error: " is prepended
* to message.
*/
void
jsj_UnexpectedJavaError(JSContext *cx, JNIEnv *env, const char *format, ...)
{
va_list ap;
const char *format2;
va_start(ap, format);
format2 = PR_smprintf("internal error: %s", format);
if (format2) {
vreport_java_error(cx, env, format2, ap);
free((void*)format2);
}
va_end(ap);
}
/*
* Most LiveConnect errors are signaled by calling JS_ReportError(),
* but in some circumstances, the target JSContext for such errors
* is not determinable, e.g. during initialization. In such cases
* any error messages are routed to this function.
*/
void
jsj_LogError(const char *error_msg)
{
if (JSJ_callbacks && JSJ_callbacks->error_print)
JSJ_callbacks->error_print(error_msg);
else
fputs(error_msg, stderr);
}
jsize
jsj_GetJavaArrayLength(JSContext *cx, JNIEnv *jEnv, jarray java_array)
{
jsize array_length = (*jEnv)->GetArrayLength(jEnv, java_array);
if ((*jEnv)->ExceptionOccurred(jEnv)) {
jsj_UnexpectedJavaError(cx, jEnv, "Couldn't obtain array length");
return -1;
}
return array_length;
}
static JSJavaThreadState *the_java_jsj_env = NULL;
JSJavaThreadState *
jsj_MapJSContextToJSJThread(JSContext *cx, JNIEnv **envp)
{
JSJavaThreadState *jsj_env;
char *err_msg;
*envp = NULL;
err_msg = NULL;
jsj_env = the_java_jsj_env;
if (jsj_env == NULL)
jsj_env = JSJ_callbacks->map_js_context_to_jsj_thread(cx, &err_msg);
if (!jsj_env) {
if (err_msg) {
JS_ReportError(cx, err_msg);
free(err_msg);
}
return NULL;
}
if (envp)
*envp = jsj_env->jEnv;
return jsj_env;
}
/**
* Since only one Java thread is allowed to enter JavaScript, this function is
* used to enforce the use of that thread's state. The static global the_java_jsj_env
* overrides using JSJ_callbacks->map_js_context_to_jsj_thread, which maps
* native threads to JSJavaThreadStates. This isn't appropriate when Java calls
* JavaScript, as there can be a many to one mapping from Java threads to native
* threads.
*/
JSJavaThreadState *
jsj_SetJavaJSJEnv(JSJavaThreadState* java_jsj_env)
{
JSJavaThreadState *old_jsj_env = the_java_jsj_env;
the_java_jsj_env = java_jsj_env;
return old_jsj_env;
}

View File

@@ -0,0 +1,264 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
/*
* This file is part of the Java-vendor-neutral implementation of LiveConnect
*
* Publicly exported functions for JavaScript <==> Java communication.
*
*/
#ifndef _JSJAVA_H
#define _JSJAVA_H
#ifndef prtypes_h___
#include "prtypes.h"
#endif
PR_BEGIN_EXTERN_C
#include "jni.h" /* Java Native Interface */
#include "jsapi.h" /* JavaScript engine API */
/*
* A JSJavaVM structure is a wrapper around a JavaVM which incorporates
* additional LiveConnect state.
*/
typedef struct JSJavaVM JSJavaVM;
/* LiveConnect and Java state, one per thread */
typedef struct JSJavaThreadState JSJavaThreadState;
/*
* An opaque type that represents the connection to the Java VM. In stand-alone
* Java environments, this may be a JNI JavaVM object; in the browser environment
* it is a reference to a JVM plugin. A set of callbacks in the JSJCallbacks
* struct allow it to be manipulated.
*/
typedef struct SystemJavaVM SystemJavaVM;
/*
* This callback table provides hooks to external functions that implement
* functionality specific to the embedding. For example, these callbacks are
* necessary in multi-threaded environments or to implement a security
* policy.
*/
typedef struct JSJCallbacks {
/* This callback is invoked when there is no JavaScript execution
environment (JSContext) associated with the current Java thread and
a call is made from Java into JavaScript. (A JSContext is associated
with a Java thread by calling the JSJ_SetJSContextForJavaThread()
function.) This callback is only invoked when Java spontaneously calls
into JavaScript, i.e. it is not called when JS calls into Java which
calls back into JS.
This callback can be used to create a JSContext lazily, or obtain
one from a pool of available JSContexts. The implementation of this
callback can call JSJ_SetJSContextForJavaThread() to avoid any further
callbacks of this type for this Java thread. */
JSContext * (*map_jsj_thread_to_js_context)(JSJavaThreadState *jsj_env,
JNIEnv *jEnv,
char **errp);
/* This callback is invoked whenever a call is made into Java from
JavaScript. It's responsible for mapping from a JavaScript execution
environment (JSContext) to a Java thread. (A JavaContext can only
be associated with one Java thread at a time.) */
JSJavaThreadState * (*map_js_context_to_jsj_thread)(JSContext *cx,
char **errp);
/* This callback implements netscape.javascript.JSObject.getWindow(),
a method named for its behavior in the browser environment, where it
returns the JS "Window" object corresponding to the HTML window that an
applet is embedded within. More generally, it's a way for Java to get
hold of a JS object that has not been explicitly passed to it. */
JSObject * (*map_java_object_to_js_object)(JNIEnv *jEnv, void *pJavaObject,
char **errp);
/* An interim callback function until the LiveConnect security story is
straightened out. This function pointer can be set to NULL. */
JSPrincipals * (*get_JSPrincipals_from_java_caller)(JNIEnv *jEnv, JSContext *pJSContext);
/* The following two callbacks sandwich any JS evaluation performed
from Java. They may be used to implement concurrency constraints, e.g.
by suspending the current thread until some condition is met. In the
browser embedding, these are used to maintain the run-to-completion
semantics of JavaScript. It is acceptable for either function pointer
to be NULL. */
JSBool (*enter_js_from_java)(JNIEnv *jEnv, char **errp);
void (*exit_js)(JNIEnv *jEnv);
/* Most LiveConnect errors are signaled by calling JS_ReportError(), but in
some circumstances, the target JSContext for such errors is not
determinable, e.g. during initialization. In such cases any error
messages are routed to this function. If the function pointer is set to
NULL, error messages are sent to stderr. */
void (*error_print)(const char *error_msg);
/* This enables liveconnect to ask the VM for a java wrapper so that VM gets a chance to
store a mapping between a jsobject and java wrapper. So the unwrapping can be done on the
VM side before calling nsILiveconnect apis. This saves on a round trip request. */
jobject (*get_java_wrapper)(JNIEnv *jEnv, jint jsobject);
/* The following set of methods abstract over the JavaVM object. */
PRBool (*create_java_vm)(SystemJavaVM* *jvm, JNIEnv* *initialEnv, void* initargs);
PRBool (*destroy_java_vm)(SystemJavaVM* jvm, JNIEnv* initialEnv);
JNIEnv* (*attach_current_thread)(SystemJavaVM* jvm);
PRBool (*detach_current_thread)(SystemJavaVM* jvm, JNIEnv* env);
SystemJavaVM* (*get_java_vm)(JNIEnv* env);
/* Reserved for future use */
void * reserved[10];
} JSJCallbacks;
/*===========================================================================*/
/* A flag that denotes that a Java package has no sub-packages other than those
explicitly pre-defined at the time of initialization. An access
to a simple name within such a package, therefore, must either correspond to
one of these explicitly pre-defined sub-packages or to a class within this
package. It is reasonable for LiveConnect to signal an error if a simple
name does not comply with these criteria. */
#define PKG_SYSTEM 1
/* A flag that denotes that a Java package which might contain sub-packages
that are not pre-defined at initialization time, because the sub-packages
may not be the same in all installations. Therefore, an access to a simple
name within such a a package which does not correspond to either a
pre-defined sub-package or to a class, must be assummed to refer to an
unknown sub-package. This behavior may cause bogus JavaPackage objects to be
created if a package name is misspelled, e.g. sun.oi.net. */
#define PKG_USER 2
/* A Java package defined at initialization time. */
typedef struct JavaPackageDef {
const char * name; /* e.g. "java.lang" */
const char * path; /* e.g. "java/lang", or NULL for default */
int flags; /* PKG_USER, PKG_SYSTEM, etc. */
} JavaPackageDef;
/*===========================================================================*/
/* The following two convenience functions present a complete, but simplified
LiveConnect API which is designed to handle the special case of a single
Java-VM, with single-threaded operation, and the use of only one JSContext.
The full API is in the section below. */
/* Initialize the provided JSContext by setting up the JS classes necessary for
reflection and by defining JavaPackage objects for the default Java packages
as properties of global_obj. If java_vm is NULL, a new Java VM is
created, using the provided classpath in addition to any default classpath.
The classpath argument is ignored, however, if java_vm is non-NULL. */
PR_IMPLEMENT(JSBool)
JSJ_SimpleInit(JSContext *cx, JSObject *global_obj,
SystemJavaVM *java_vm, const char *classpath);
/* Free up all resources. Destroy the Java VM if it was created by LiveConnect */
PR_IMPLEMENT(void)
JSJ_SimpleShutdown();
/*===========================================================================*/
/* The "full" LiveConnect API, required when more than one thread, Java VM, or
JSContext is involved. Initialization pseudocode might go roughly like
this:
JSJ_Init() // Setup callbacks
for each JavaVM {
JSJ_ConnectToJavaVM(...)
}
for each JSContext {
JSJ_InitJSContext(...)
}
for each JS evaluation {
run JavaScript code in the JSContext;
}
*/
/* Called once for all instances of LiveConnect to set up callbacks */
PR_IMPLEMENT(void)
JSJ_Init(JSJCallbacks *callbacks);
/* Called once per Java VM, this function initializes the classes, fields, and
methods required for Java reflection. If java_vm is NULL, a new Java VM is
created according to the create_java_vm callback in the JSJCallbacks,
using the provided classpath in addition to any default initargs.
The initargs argument is ignored, however, if java_vm is non-NULL. */
PR_IMPLEMENT(JSJavaVM *)
JSJ_ConnectToJavaVM(SystemJavaVM *java_vm, void* initargs);
/* Initialize the provided JSContext by setting up the JS classes necessary for
reflection and by defining JavaPackage objects for the default Java packages
as properties of global_obj. Additional packages may be pre-defined by
setting the predefined_packages argument. (Pre-defining a Java package at
initialization time is not necessary, but it will make package lookup faster
and, more importantly, will avoid unnecessary network accesses if classes
are being loaded over the network.) */
PR_IMPLEMENT(JSBool)
JSJ_InitJSContext(JSContext *cx, JSObject *global_obj,
JavaPackageDef *predefined_packages);
/* This function returns a structure that encapsulates the Java and JavaScript
execution environment for the current native thread. It is intended to
be called from the embedder's implementation of JSJCallback's
map_js_context_to_jsj_thread() function. The thread_name argument is only
used for debugging purposes and can be set to NULL. The Java JNI
environment associated with this thread is returned through the java_envp
argument if java_envp is non-NULL. */
PR_IMPLEMENT(JSJavaThreadState *)
JSJ_AttachCurrentThreadToJava(JSJavaVM *jsjava_vm, const char *thread_name,
JNIEnv **java_envp);
/* Destructor routine for per-thread JSJavaThreadState structure */
PR_IMPLEMENT(JSBool)
JSJ_DetachCurrentThreadFromJava(JSJavaThreadState *jsj_env);
/* This function is used to specify a particular JSContext as *the* JavaScript
execution environment to be used when LiveConnect is accessed from the given
Java thread, i.e. when one of the methods of netscape.javascript.JSObject
has been called. There can only be one such JS context for any given Java
thread at a time. (To multiplex JSContexts among a single thread, this
function could be called before Java is invoked on that thread.) The return
value is the previous JSContext associated with the given Java thread.
If this function has not been called for a thread and a crossing is made
into JavaScript from Java, the map_jsj_thread_to_js_context() callback will
be invoked to determine the JSContext for the thread. The purpose of the
function is to improve performance by avoiding the expense of the callback.
*/
PR_IMPLEMENT(JSContext *)
JSJ_SetDefaultJSContextForJavaThread(JSContext *cx, JSJavaThreadState *jsj_env);
/* This routine severs the connection to a Java VM, freeing all related resources.
It shouldn't be called until the global scope has been cleared in all related
JSContexts (so that all LiveConnect objects are finalized) and a JavaScript
GC is performed. Otherwise, accessed to free'ed memory could result. */
PR_IMPLEMENT(void)
JSJ_DisconnectFromJavaVM(JSJavaVM *);
/*
* Reflect a Java object into a JS value. The source object, java_obj, must
* be of type java.lang.Object or a subclass and may, therefore, be an array.
*/
PR_IMPLEMENT(JSBool)
JSJ_ConvertJavaObjectToJSValue(JSContext *cx, jobject java_obj, jsval *vp);
PR_END_EXTERN_C
#endif /* _JSJAVA_H */

View File

@@ -0,0 +1,182 @@
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
IGNORE_MANIFEST=1
#//------------------------------------------------------------------------
#//
#// Makefile to build the Java reflections of JavaScript objects
#//
#//------------------------------------------------------------------------
#//------------------------------------------------------------------------
#//
#// Specify the depth of the current directory relative to the
#// root of NS
#//
#//------------------------------------------------------------------------
DEPTH= ..\..\..
include <$(DEPTH)/config/config.mak>
!ifdef NSJVM
DIRS = classes
!endif
#//------------------------------------------------------------------------
#//
#// Define any Public Make Variables here: (ie. PDFFILE, MAPFILE, ...)
#//
#//------------------------------------------------------------------------
DLLNAME=jsj$(MOZ_BITS)$(VERSION_NUMBER)
PDBFILE=$(DLLNAME).pdb
MAPFILE = $(DLLNAME).map
RESFILE = jsj1640.res
DLL=.\$(OBJDIR)\$(DLLNAME).dll
MAKE_OBJ_TYPE = DLL
!if "$(MOZ_BITS)" == "16"
DEFFILE = $(DLLNAME).def
!endif
LLIBS=$(LIBNSPR) $(DIST)\lib\js$(MOZ_BITS)$(VERSION_NUMBER).lib \
$(DIST)\lib\xpcom32.lib
!if "$(MOZ_BITS)"=="32" && defined(MOZ_DEBUG) && defined(GLOWCODE)
LLIBS=$(LLIBS) $(GLOWDIR)\glowcode.lib
!endif
#//------------------------------------------------------------------------
#//
#// Define the files necessary to build the target (ie. OBJS)
#//
#//------------------------------------------------------------------------
OBJS= \
.\$(OBJDIR)\jsj.obj \
.\$(OBJDIR)\jsj_JSObject.obj \
.\$(OBJDIR)\jsj_JavaArray.obj \
.\$(OBJDIR)\jsj_JavaClass.obj \
.\$(OBJDIR)\jsj_JavaMember.obj \
.\$(OBJDIR)\jsj_JavaObject.obj \
.\$(OBJDIR)\jsj_JavaPackage.obj \
.\$(OBJDIR)\jsj_array.obj \
.\$(OBJDIR)\jsj_class.obj \
.\$(OBJDIR)\jsj_convert.obj \
.\$(OBJDIR)\jsj_field.obj \
.\$(OBJDIR)\jsj_hash.obj \
.\$(OBJDIR)\jsj_method.obj \
.\$(OBJDIR)\jsj_utils.obj \
.\$(OBJDIR)\nsCLiveconnect.obj \
.\$(OBJDIR)\nsCLiveconnectFactory.obj \
!if "$(MOZ_BITS)" == "16"
.\$(OBJDIR)\jsj_nodl.obj \
!endif
$(NULL)
#//------------------------------------------------------------------------
#//
#// install headers
#//
#//------------------------------------------------------------------------
INSTALL_DIR=$(PUBLIC)\js
INSTALL_FILE_LIST= \
jsjava.h nsILiveconnect.h
#//------------------------------------------------------------------------
#//
#// Define any Public Targets here (ie. PROGRAM, LIBRARY, DLL, ...)
#// (these must be defined before the common makefiles are included)
#//
#//------------------------------------------------------------------------
!ifdef NSJVM
JNI_GEN= \
netscape.javascript.JSObject \
netscape.javascript.JSException \
$(NULL)
!endif
MODULE = java
EXPORTS = \
$(JNI_GEN_DIR)\netscape_javascript_JSObject.h \
$(JNI_GEN_DIR)\netscape_javascript_JSException.h \
$(NULL)
#//------------------------------------------------------------------------
#//
#// Define any local options for the make tools
#// (ie. LCFLAGS, LLFLAGS, LLIBS, LINCS)
#//
#//------------------------------------------------------------------------
LINCS=$(LINCS) -I$(JNI_GEN_DIR) \
-I$(PUBLIC)\js \
-I$(PUBLIC)\java \
-I$(PUBLIC)\xpcom \
$(NULL)
#!ifdef SERVER_BUILD
#LLIBS=$(DIST)/lib/httpdlw.lib $(DIST)/lib/libsjboot.lib
#!endif
#//------------------------------------------------------------------------
#//
#// Include the common makefile rules
#//
#//------------------------------------------------------------------------
include <$(DEPTH)/config/rules.mak>
export:: INSTALL_FILES
libs:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
####
# this bit of extreme scariness came from the js/src makefile
# reproduced here since that's where jsjava.c lives now...
!if ("$(MOZ_BITS)" == "16")
#//
#// Win16 Hoovers SO BAD!!!
#//
!if !defined(MOZ_DEBUG)
#//
#// We must turn off codeview debug info so jni.c can build.
#// Otherwise the linker gives errors about data in the $SYMBOLS
#// segment being beyond a segment boundary.
#//
$(OBJDIR)\jsjava.obj: jsjava.c
@$(CC) @<<$(CFGFILE)
-c
-Od
$(CFLAGS)
$(LCFLAGS)
$(LINCS)
$(LINCS_1)
$(INCS)
-Fd$(PDBFILE)
-Fo.\$(OBJDIR)\
$(*B).c
<<KEEP
!endif
!endif

View File

@@ -0,0 +1,111 @@
/* -*- Mode: C; tab-width: 8 -*-
* Copyright (C) 1998 Netscape Communications Corporation, All Rights Reserved.
*/
#include <jni.h>
/* Header for class netscape_javascript_JSObject */
#ifndef _Included_netscape_javascript_JSObject
#define _Included_netscape_javascript_JSObject
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: netscape_javascript_JSObject
* Method: initClass
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_netscape_javascript_JSObject_initClass
(JNIEnv *, jclass);
/*
* Class: netscape_javascript_JSObject
* Method: getMember
* Signature: (Ljava/lang/String;)Ljava/lang/Object;
*/
JNIEXPORT jobject JNICALL Java_netscape_javascript_JSObject_getMember
(JNIEnv *, jobject, jstring);
/*
* Class: netscape_javascript_JSObject
* Method: getSlot
* Signature: (I)Ljava/lang/Object;
*/
JNIEXPORT jobject JNICALL Java_netscape_javascript_JSObject_getSlot
(JNIEnv *, jobject, jint);
/*
* Class: netscape_javascript_JSObject
* Method: setMember
* Signature: (Ljava/lang/String;Ljava/lang/Object;)V
*/
JNIEXPORT void JNICALL Java_netscape_javascript_JSObject_setMember
(JNIEnv *, jobject, jstring, jobject);
/*
* Class: netscape_javascript_JSObject
* Method: setSlot
* Signature: (ILjava/lang/Object;)V
*/
JNIEXPORT void JNICALL Java_netscape_javascript_JSObject_setSlot
(JNIEnv *, jobject, jint, jobject);
/*
* Class: netscape_javascript_JSObject
* Method: removeMember
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_netscape_javascript_JSObject_removeMember
(JNIEnv *, jobject, jstring);
/*
* Class: netscape_javascript_JSObject
* Method: call
* Signature: (Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;
*/
JNIEXPORT jobject JNICALL Java_netscape_javascript_JSObject_call
(JNIEnv *, jobject, jstring, jobjectArray);
/*
* Class: netscape_javascript_JSObject
* Method: eval
* Signature: (Ljava/lang/String;)Ljava/lang/Object;
*/
JNIEXPORT jobject JNICALL Java_netscape_javascript_JSObject_eval
(JNIEnv *, jobject, jstring);
/*
* Class: netscape_javascript_JSObject
* Method: toString
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_netscape_javascript_JSObject_toString
(JNIEnv *, jobject);
/*
* Class: netscape_javascript_JSObject
* Method: getWindow
* Signature: (Ljava/applet/Applet;)Lnetscape/javascript/JSObject;
*/
JNIEXPORT jobject JNICALL Java_netscape_javascript_JSObject_getWindow
(JNIEnv *, jclass, jobject);
/*
* Class: netscape_javascript_JSObject
* Method: finalize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_netscape_javascript_JSObject_finalize
(JNIEnv *, jobject);
/*
* Class: netscape_javascript_JSObject
* Method: equals
* Signature: (Ljava/lang/Object;)Z
*/
JNIEXPORT jboolean JNICALL Java_netscape_javascript_JSObject_equals
(JNIEnv *, jobject, jobject);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,567 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* This file is part of the Java-vendor-neutral implementation of LiveConnect
*
* It contains the implementation providing nsIFactory XP-COM interface.
*
*/
#include <stdlib.h>
#include <string.h>
#include "prtypes.h"
#include "prprf.h"
#include "prlog.h"
PR_BEGIN_EXTERN_C
#ifdef XP_MAC
#include "prosdep.h"
#endif
#include "jsj_private.h"
#include "jsjava.h"
#include "jscntxt.h" /* For js_ReportErrorAgain().
TODO - get rid of private header */
#include "netscape_javascript_JSObject.h" /* javah-generated headers */
/* A captured JavaScript error, created when JS_ReportError() is called while
running JavaScript code that is itself called from Java. */
struct CapturedJSError {
char * message;
JSErrorReport report; /* Line # of error, etc. */
jthrowable java_exception; /* Java exception, error, or null */
CapturedJSError * next; /* Next oldest captured JS error */
};
PR_END_EXTERN_C
#include "nsCLiveconnect.h"
static NS_DEFINE_IID(kILiveconnectIID, NS_ILIVECONNECT_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
////////////////////////////////////////////////////////////////////////////
// from nsISupports and AggregatedQueryInterface:
// Thes macro expands to the aggregated query interface scheme.
NS_IMPL_AGGREGATED(nsCLiveconnect);
NS_METHOD
nsCLiveconnect::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr)
{
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = GetInner();
AddRef();
return NS_OK;
}
if (aIID.Equals(kILiveconnectIID)) {
*aInstancePtr = this;
AddRef();
return NS_OK;
}
return NS_NOINTERFACE;
}
////////////////////////////////////////////////////////////////////////////
// from nsILiveconnect:
/**
* get member of a Native JSObject for a given name.
*
* @param jEnv - JNIEnv on which the call is being made.
* @param obj - A Native JS Object.
* @param name - Name of a member.
* @param pjobj - return parameter as a java object representing
* the member. If it is a basic data type it is converted to
* a corresponding java type. If it is a NJSObject, then it is
* wrapped up as java wrapper netscape.javascript.JSObject.
*/
NS_METHOD
nsCLiveconnect::GetMember(JNIEnv *jEnv, jsobject obj, const char *name, jobject *pjobj)
{
JSContext *cx = NULL;
JSJavaThreadState *jsj_env = NULL;
JSObject *js_obj = (JSObject *)obj;
nsresult err = NS_OK;
jobject member = NULL;
jsval js_val = NULL;
int dummy_cost = 0;
JSBool dummy_bool = PR_FALSE;
JavaToJSSavedState saved_state = {NULL,NULL};
if(jEnv == NULL)
{
return NS_ERROR_FAILURE;
}
jsj_env = jsj_enter_js(jEnv, NULL, &cx, NULL, &saved_state);
if (!jsj_env)
return NS_ERROR_FAILURE;
if (!name) {
JS_ReportError(cx, "illegal null member name");
member = NULL;
goto done;
}
if (!JS_GetProperty(cx, js_obj, name, &js_val))
goto done;
jsj_ConvertJSValueToJavaObject(cx, jEnv, js_val, jsj_get_jlObject_descriptor(cx, jEnv),
&dummy_cost, &member, &dummy_bool);
done:
if (!jsj_exit_js(cx, jsj_env, &saved_state))
return NS_ERROR_FAILURE;
*pjobj = member;
return NS_OK;
}
/**
* get member of a Native JSObject for a given index.
*
* @param jEnv - JNIEnv on which the call is being made.
* @param obj - A Native JS Object.
* @param index - Index of a member.
* @param pjobj - return parameter as a java object representing
* the member.
*/
NS_METHOD
nsCLiveconnect::GetSlot(JNIEnv *jEnv, jsobject obj, int slot, jobject *pjobj)
{
JSContext *cx = NULL;
JSJavaThreadState *jsj_env = NULL;
JSObject *js_obj = (JSObject *)obj;
nsresult err = NS_OK;
jobject member = NULL;
jsval js_val = NULL;
int dummy_cost = 0;
JSBool dummy_bool = PR_FALSE;
JavaToJSSavedState saved_state = {NULL,NULL};
if(jEnv == NULL)
{
return NS_ERROR_FAILURE;
}
jsj_env = jsj_enter_js(jEnv, NULL, &cx, NULL, &saved_state);
if (!jsj_env)
return NS_ERROR_FAILURE;
// =-= sudu: check to see if slot can be passed in as is.
// Should it be converted to a jsint?
if (!JS_GetElement(cx, js_obj, slot, &js_val))
goto done;
if (!jsj_ConvertJSValueToJavaObject(cx, jEnv, js_val, jsj_get_jlObject_descriptor(cx, jEnv),
&dummy_cost, &member, &dummy_bool))
goto done;
done:
if (!jsj_exit_js(cx, jsj_env, &saved_state))
return NS_ERROR_FAILURE;
*pjobj = member;
return NS_OK;
}
/**
* set member of a Native JSObject for a given name.
*
* @param jEnv - JNIEnv on which the call is being made.
* @param obj - A Native JS Object.
* @param name - Name of a member.
* @param jobj - Value to set. If this is a basic data type, it is converted
* using standard JNI calls but if it is a wrapper to a JSObject
* then a internal mapping is consulted to convert to a NJSObject.
*/
NS_METHOD
nsCLiveconnect::SetMember(JNIEnv *jEnv, jsobject obj, const char *name, jobject java_obj)
{
JSContext *cx = NULL;
JSJavaThreadState *jsj_env = NULL;
JSObject *js_obj = (JSObject *)obj;
nsresult err = NS_OK;
jobject member = NULL;
jsval js_val = NULL;
JavaToJSSavedState saved_state = {NULL,NULL};
if(jEnv == NULL)
{
return NS_ERROR_FAILURE;
}
jsj_env = jsj_enter_js(jEnv, NULL, &cx, NULL, &saved_state);
if (!jsj_env)
return NS_ERROR_FAILURE;
if (!name) {
JS_ReportError(cx, "illegal null member name");
goto done;
}
if (!jsj_ConvertJavaObjectToJSValue(cx, jEnv, java_obj, &js_val))
goto done;
JS_SetProperty(cx, js_obj, name, &js_val);
done:
jsj_exit_js(cx, jsj_env, &saved_state);
return NS_OK;
}
/**
* set member of a Native JSObject for a given index.
*
* @param jEnv - JNIEnv on which the call is being made.
* @param obj - A Native JS Object.
* @param index - Index of a member.
* @param jobj - Value to set. If this is a basic data type, it is converted
* using standard JNI calls but if it is a wrapper to a JSObject
* then a internal mapping is consulted to convert to a NJSObject.
*/
NS_METHOD
nsCLiveconnect::SetSlot(JNIEnv *jEnv, jsobject obj, int slot, jobject java_obj)
{
JSContext *cx = NULL;
JSJavaThreadState *jsj_env = NULL;
JSObject *js_obj = (JSObject *)obj;
nsresult err = NS_OK;
jsval js_val = NULL;
JavaToJSSavedState saved_state = {NULL,NULL};
if(jEnv == NULL)
{
return NS_ERROR_FAILURE;
}
jsj_env = jsj_enter_js(jEnv, NULL, &cx, NULL, &saved_state);
if (!jsj_env)
return NS_ERROR_FAILURE;
if (!jsj_ConvertJavaObjectToJSValue(cx, jEnv, java_obj, &js_val))
goto done;
JS_SetElement(cx, js_obj, slot, &js_val);
done:
jsj_exit_js(cx, jsj_env, &saved_state);
return NS_OK;
}
/**
* remove member of a Native JSObject for a given name.
*
* @param jEnv - JNIEnv on which the call is being made.
* @param obj - A Native JS Object.
* @param name - Name of a member.
*/
NS_METHOD
nsCLiveconnect::RemoveMember(JNIEnv *jEnv, jsobject obj, const char *name)
{
JSContext *cx = NULL;
JSJavaThreadState *jsj_env = NULL;
JSObject *js_obj = (JSObject *)obj;
nsresult err = NS_OK;
jsval js_val = NULL;
JavaToJSSavedState saved_state = {NULL,NULL};
if(jEnv == NULL)
{
return NS_ERROR_FAILURE;
}
jsj_env = jsj_enter_js(jEnv, NULL, &cx, NULL, &saved_state);
if (!jsj_env)
return NS_ERROR_FAILURE;
if (!name) {
JS_ReportError(cx, "illegal null member name");
goto done;
}
JS_DeleteProperty2(cx, js_obj, name, &js_val);
done:
jsj_exit_js(cx, jsj_env, &saved_state);
return NS_OK;
}
/**
* call a method of Native JSObject.
*
* @param jEnv - JNIEnv on which the call is being made.
* @param obj - A Native JS Object.
* @param name - Name of a method.
* @param jobjArr - Array of jobjects representing parameters of method being caled.
* @param pjobj - return value.
*/
NS_METHOD
nsCLiveconnect::Call(JNIEnv *jEnv, jsobject obj, const char *name, jobjectArray java_args, jobject *pjobj)
{
int i = 0;
int argc = 0;
int arg_num = 0;
jsval *argv = 0;
JSContext *cx = NULL;
JSJavaThreadState *jsj_env = NULL;
JSObject *js_obj = (JSObject *)obj;
nsresult err = NS_OK;
jobject member = NULL;
jsval js_val = NULL;
jsval function_val = NULL;
int dummy_cost = 0;
JSBool dummy_bool = PR_FALSE;
JavaToJSSavedState saved_state = {NULL,NULL};
jobject result = NULL;
if(jEnv == NULL)
{
return NS_ERROR_FAILURE;
}
jsj_env = jsj_enter_js(jEnv, NULL, &cx, NULL, &saved_state);
if (!jsj_env)
return NS_ERROR_FAILURE;
result = NULL;
if (!name) {
JS_ReportError(cx, "illegal null JavaScript function name");
goto done;
}
/* FIXME: What about security stuff ? Don't principals need to be set here ? */
/* Allocate space for JS arguments */
if (java_args) {
argc = jEnv->GetArrayLength(java_args);
argv = (jsval*)JS_malloc(cx, argc * sizeof(jsval));
} else {
argc = 0;
argv = 0;
}
/* Convert arguments from Java to JS values */
for (arg_num = 0; arg_num < argc; arg_num++) {
jobject arg = jEnv->GetObjectArrayElement(java_args, arg_num);
if (!jsj_ConvertJavaObjectToJSValue(cx, jEnv, arg, &argv[arg_num]))
goto cleanup_argv;
JS_AddRoot(cx, &argv[arg_num]);
}
if (!JS_GetProperty(cx, js_obj, name, &function_val))
goto cleanup_argv;
if (!JS_CallFunctionValue(cx, js_obj, function_val, argc, argv, &js_val))
goto cleanup_argv;
jsj_ConvertJSValueToJavaObject(cx, jEnv, js_val, jsj_get_jlObject_descriptor(cx, jEnv),
&dummy_cost, &result, &dummy_bool);
cleanup_argv:
if (argv) {
for (i = 0; i < arg_num; i++)
JS_RemoveRoot(cx, &argv[i]);
JS_free(cx, argv);
}
done:
if (!jsj_exit_js(cx, jsj_env, &saved_state))
return NS_ERROR_FAILURE;
*pjobj = result;
return NS_OK;
}
/**
* Evaluate a script with a Native JS Object representing scope.
*
* @param jEnv - JNIEnv on which the call is being made.
* @param obj - A Native JS Object.
* @param pNSIPrincipaArray - Array of principals to be used to compare privileges.
* @param numPrincipals - Number of principals being passed.
* @param script - Script to be executed.
* @param pjobj - return value.
*/
NS_METHOD
nsCLiveconnect::Eval(JNIEnv *jEnv, jsobject obj, const char *script, jobject *pjobj)
{
JSContext *cx = NULL;
JSJavaThreadState *jsj_env = NULL;
JSObject *js_obj = (JSObject *)obj;
nsresult err = NS_OK;
jobject member = NULL;
jsval js_val = NULL;
jsval function_val = NULL;
int dummy_cost = 0;
JSBool dummy_bool = PR_FALSE;
JavaToJSSavedState saved_state = {NULL,NULL};
jobject result = NULL;
const char *codebase = NULL;
JSPrincipals *principals = NULL;
JSBool eval_succeeded = PR_FALSE;
if(jEnv == NULL)
{
return NS_ERROR_FAILURE;
}
jsj_env = jsj_enter_js(jEnv, NULL, &cx, NULL, &saved_state);
if (!jsj_env)
return NULL;
result = NULL;
if (!script) {
JS_ReportError(cx, "illegal null string eval argument");
goto done;
}
/* Set up security stuff */
principals = NULL;
if (JSJ_callbacks->get_JSPrincipals_from_java_caller)
principals = JSJ_callbacks->get_JSPrincipals_from_java_caller(jEnv, cx);
codebase = principals ? principals->codebase : NULL;
/* Have the JS engine evaluate the unicode string */
eval_succeeded = JS_EvaluateScriptForPrincipals(cx, js_obj, principals,
script, strlen(script),
codebase, 0, &js_val);
if (!eval_succeeded)
goto done;
/* Convert result to a subclass of java.lang.Object */
jsj_ConvertJSValueToJavaObject(cx, jEnv, js_val, jsj_get_jlObject_descriptor(cx, jEnv),
&dummy_cost, &result, &dummy_bool);
done:
if (!jsj_exit_js(cx, jsj_env, &saved_state))
return NULL;
*pjobj = result;
return NS_OK;
}
/**
* Get the window object for a plugin instance.
*
* @param jEnv - JNIEnv on which the call is being made.
* @param pJavaObject - Either a jobject or a pointer to a plugin instance
* representing the java object.
* @param pjobj - return value. This is a native js object
* representing the window object of a frame
* in which a applet/bean resides.
*/
NS_METHOD
nsCLiveconnect::GetWindow(JNIEnv *jEnv, void *pJavaObject, jsobject *pobj)
{
char *err_msg = NULL;
JSContext *cx = NULL;
JSObject *js_obj = NULL;
jsval js_val = NULL;
int dummy_cost = 0;
JSBool dummy_bool = PR_FALSE;
JavaToJSSavedState saved_state = {NULL,NULL};
jobject java_obj = NULL;
JSJavaThreadState *jsj_env = NULL;
if(jEnv == NULL)
{
return NS_ERROR_FAILURE;
}
jsj_env = jsj_enter_js(jEnv, NULL, &cx, NULL, &saved_state);
if (!jsj_env)
return NULL;
err_msg = NULL;
java_obj = NULL;
js_obj = JSJ_callbacks->map_java_object_to_js_object(jEnv, pJavaObject, &err_msg);
if (!js_obj) {
if (err_msg) {
JS_ReportError(cx, err_msg);
free(err_msg);
}
goto done;
}
#if 0
js_val = OBJECT_TO_JSVAL(js_obj);
jsj_ConvertJSValueToJavaObject(cx, jEnv, js_val, jsj_get_jlObject_descriptor(cx, jEnv),
&dummy_cost, &java_obj, &dummy_bool);
#endif
done:
if (!jsj_exit_js(cx, jsj_env, &saved_state))
return NULL;
//*pjobj = java_obj;
*pobj = (jint)js_obj;
return NS_OK;
}
/**
* Get the window object for a plugin instance.
*
* @param jEnv - JNIEnv on which the call is being made.
* @param obj - A Native JS Object.
*/
NS_METHOD
nsCLiveconnect::FinalizeJSObject(JNIEnv *jEnv, jsobject obj)
{
JSContext *cx = NULL;
JavaToJSSavedState saved_state = {NULL,NULL};
JSJavaThreadState *jsj_env = NULL;
JSObject *js_obj = (JSObject *)obj;
if(jEnv == NULL)
{
return NS_ERROR_FAILURE;
}
jsj_env = jsj_enter_js(jEnv, NULL, &cx, NULL, &saved_state);
if (!jsj_env) /* Note: memory leak if we exit here */
return NS_ERROR_FAILURE;
#ifdef PRESERVE_JSOBJECT_IDENTITY
jsj_remove_js_obj_reflection_from_hashtable(cx, js_obj);
#endif /* PRESERVE_JSOBJECT_IDENTITY */
jsj_exit_js(cx, jsj_env, &saved_state);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////
// from nsCLiveconnect:
nsCLiveconnect::nsCLiveconnect(nsISupports *aOuter)
{
NS_INIT_AGGREGATED(aOuter);
jsj_init_js_obj_reflections_table();
}
nsCLiveconnect::~nsCLiveconnect()
{
}

View File

@@ -0,0 +1,166 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* This file is part of the Java-vendor-neutral implementation of LiveConnect
*
* It contains class definition implementing the public interface.
*
*/
/*
* This file is part of the Java-vendor-neutral implementation of LiveConnect
*
* It contains the class definition to implement nsILiveconnect XP-COM interface.
*
*/
#ifndef nsCLiveconnect_h___
#define nsCLiveconnect_h___
#include "nsILiveconnect.h"
#include "nsAgg.h"
/**
* nsCLiveconnect implements nsILiveconnect interface for navigator.
* This is used by a JVM to implement netscape.javascript.JSObject functionality.
*/
class nsCLiveconnect :public nsILiveconnect {
public:
////////////////////////////////////////////////////////////////////////////
// from nsISupports and AggregatedQueryInterface:
NS_DECL_AGGREGATED
////////////////////////////////////////////////////////////////////////////
// from nsILiveconnect:
/**
* get member of a Native JSObject for a given name.
*
* @param obj - A Native JS Object.
* @param name - Name of a member.
* @param pjobj - return parameter as a java object representing
* the member. If it is a basic data type it is converted to
* a corresponding java type. If it is a NJSObject, then it is
* wrapped up as java wrapper netscape.javascript.JSObject.
*/
NS_IMETHOD
GetMember(JNIEnv *jEnv, jsobject obj, const char *name, jobject *pjobj);
/**
* get member of a Native JSObject for a given index.
*
* @param obj - A Native JS Object.
* @param index - Index of a member.
* @param pjobj - return parameter as a java object representing
* the member.
*/
NS_IMETHOD
GetSlot(JNIEnv *jEnv, jsobject obj, int index, jobject *pjobj);
/**
* set member of a Native JSObject for a given name.
*
* @param obj - A Native JS Object.
* @param name - Name of a member.
* @param jobj - Value to set. If this is a basic data type, it is converted
* using standard JNI calls but if it is a wrapper to a JSObject
* then a internal mapping is consulted to convert to a NJSObject.
*/
NS_IMETHOD
SetMember(JNIEnv *jEnv, jsobject obj, const char *name, jobject jobj);
/**
* set member of a Native JSObject for a given index.
*
* @param obj - A Native JS Object.
* @param index - Index of a member.
* @param jobj - Value to set. If this is a basic data type, it is converted
* using standard JNI calls but if it is a wrapper to a JSObject
* then a internal mapping is consulted to convert to a NJSObject.
*/
NS_IMETHOD
SetSlot(JNIEnv *jEnv, jsobject obj, int slot, jobject jobj);
/**
* remove member of a Native JSObject for a given name.
*
* @param obj - A Native JS Object.
* @param name - Name of a member.
*/
NS_IMETHOD
RemoveMember(JNIEnv *jEnv, jsobject obj, const char *name);
/**
* call a method of Native JSObject.
*
* @param obj - A Native JS Object.
* @param name - Name of a method.
* @param jobjArr - Array of jobjects representing parameters of method being caled.
* @param pjobj - return value.
*/
NS_IMETHOD
Call(JNIEnv *jEnv, jsobject obj, const char *name, jobjectArray jobjArr, jobject *pjobj);
/**
* Evaluate a script with a Native JS Object representing scope.
*
* @param obj - A Native JS Object.
* @param pNSIPrincipaArray - Array of principals to be used to compare privileges.
* @param numPrincipals - Number of principals being passed.
* @param script - Script to be executed.
* @param pjobj - return value.
*/
NS_IMETHOD
//Eval(JNIEnv *jEnv, jsobject obj, nsIPrincipal **pNSIPrincipaArray, PRInt32 numPrincipals, const char *script, jobject *pjobj);
Eval(JNIEnv *jEnv, jsobject obj, const char *script, jobject *pjobj);
/**
* Get the window object for a plugin instance.
*
* @param pJavaObject - Either a jobject or a pointer to a plugin instance
* representing the java object.
* @param pjobj - return value. This is a native js object
* representing the window object of a frame
* in which a applet/bean resides.
*/
NS_IMETHOD
GetWindow(JNIEnv *jEnv, void *pJavaObject, jsobject *pobj);
/**
* Get the window object for a plugin instance.
*
* @param jEnv - JNIEnv on which the call is being made.
* @param obj - A Native JS Object.
*/
NS_IMETHOD
FinalizeJSObject(JNIEnv *jEnv, jsobject obj);
////////////////////////////////////////////////////////////////////////////
// from nsCLiveconnect:
nsCLiveconnect(nsISupports *aOuter);
virtual ~nsCLiveconnect(void);
protected:
};
#endif // nsCLiveconnect_h___

View File

@@ -0,0 +1,168 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* This file is part of the Java-vendor-neutral implementation of LiveConnect
*
* It contains the implementation providing nsILiveconnect XP-COM interface.
*
*/
#include "prtypes.h"
#include "nspr.h"
#include "prmem.h"
#include "prmon.h"
#include "prlog.h"
#include "nsCLiveconnect.h"
#include "nsCLiveconnectFactory.h"
#include "nsRepository.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
static NS_DEFINE_CID(kCLiveconnectCID, NS_CLIVECONNECT_CID);
static NS_DEFINE_IID(kILiveconnectIID, NS_ILIVECONNECT_IID);
nsIFactory *nsCLiveconnectFactory::m_pNSIFactory = NULL;
nsCLiveconnect *nsCLiveconnectFactory::m_pNSCLiveconnect = NULL;
/*+++++++++++++++++++++++++++++++++++++++++++++++++
* NSGetFactory:
* Provides entry point to liveconnect dll.
+++++++++++++++++++++++++++++++++++++++++++++++++*/
extern "C" NS_EXPORT nsresult
NSGetFactory(const nsCID &aClass, nsIFactory **aFactory)
{
if (!aClass.Equals(kCLiveconnectCID)) {
return NS_ERROR_FACTORY_NOT_LOADED; // XXX right error?
}
nsCLiveconnectFactory* pCLiveConnectFactory = new nsCLiveconnectFactory();
if (pCLiveConnectFactory == NULL)
return NS_ERROR_OUT_OF_MEMORY;
pCLiveConnectFactory->AddRef();
*aFactory = pCLiveConnectFactory;
return NS_OK;
}
extern "C" NS_EXPORT PRBool
NSCanUnload(void)
{
return PR_FALSE;
}
////////////////////////////////////////////////////////////////////////////
// from nsISupports
NS_METHOD
nsCLiveconnectFactory::QueryInterface(const nsIID& aIID, void** aInstancePtr)
{
PR_ASSERT(NULL != aInstancePtr);
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
if (aIID.Equals(kIFactoryIID) ||
aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*) this;
AddRef();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMPL_ADDREF(nsCLiveconnectFactory)
NS_IMPL_RELEASE(nsCLiveconnectFactory)
////////////////////////////////////////////////////////////////////////////
// from nsIFactory:
NS_METHOD
nsCLiveconnectFactory::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
nsCLiveconnect *pNSCLiveconnect = NULL;
*aResult = NULL;
if (aOuter && !aIID.Equals(kISupportsIID))
return NS_NOINTERFACE; // XXX right error?
if (m_pNSCLiveconnect == NULL)
{
m_pNSCLiveconnect = new nsCLiveconnect(aOuter);
}
if (m_pNSCLiveconnect == NULL)
{
return NS_ERROR_FAILURE;
}
if (m_pNSCLiveconnect->QueryInterface(aIID,
(void**)aResult) != NS_OK) {
// then we're trying get a interface other than nsISupports and
// nsICapsManager
return NS_ERROR_FAILURE;
}
return NS_OK;
}
NS_METHOD
nsCLiveconnectFactory::LockFactory(PRBool aLock)
{
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////
// from nsCLiveconnectFactory:
nsCLiveconnectFactory::nsCLiveconnectFactory(void)
{
if( m_pNSIFactory != NULL)
{
return;
}
NS_INIT_REFCNT();
nsresult err = NS_OK;
NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
err = this->QueryInterface(kIFactoryIID, (void**)&m_pNSIFactory);
if ( (err == NS_OK) && (m_pNSIFactory != NULL) )
{
NS_DEFINE_CID(kCLiveconnectCID, NS_CLIVECONNECT_CID);
nsRepository::RegisterFactory(kCLiveconnectCID, m_pNSIFactory,
PR_FALSE);
}
}
nsCLiveconnectFactory::~nsCLiveconnectFactory()
{
if(mRefCnt == 0)
{
NS_DEFINE_CID(kCLiveconnectCID, NS_CLIVECONNECT_CID);
nsRepository::UnregisterFactory(kCLiveconnectCID, (nsIFactory *)m_pNSIFactory);
}
}

View File

@@ -0,0 +1,59 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* This file is part of the Java-vendor-neutral implementation of LiveConnect
*
* It contains the class definition to implement nsIFactory XP-COM interface.
*
*/
#ifndef nsCLiveconnectFactory_h___
#define nsCLiveconnectFactory_h___
#include "nsISupports.h"
#include "nsIFactory.h"
class nsCLiveconnectFactory : public nsIFactory {
public:
////////////////////////////////////////////////////////////////////////////
// from nsISupports and AggregatedQueryInterface:
NS_DECL_ISUPPORTS
////////////////////////////////////////////////////////////////////////////
// from nsIFactory:
NS_IMETHOD
CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult);
NS_IMETHOD
LockFactory(PRBool aLock);
////////////////////////////////////////////////////////////////////////////
// from nsCLiveconnectFactory:
nsCLiveconnectFactory(void);
virtual ~nsCLiveconnectFactory(void);
protected:
static nsIFactory *m_pNSIFactory;
static nsCLiveconnect *m_pNSCLiveconnect;
};
#endif // nsCLiveconnectFactory_h___

View File

@@ -0,0 +1,157 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* This file is part of the Java-vendor-neutral implementation of LiveConnect
*
* It contains the public XP-COM based interface for java to javascript communication.
*
*/
#ifndef nsILiveconnect_h___
#define nsILiveconnect_h___
#include "nsISupports.h"
#include "nsIFactory.h"
#include "jni.h"
typedef jint jsobject;
class nsILiveconnect : public nsISupports {
public:
/**
* get member of a Native JSObject for a given name.
*
* @param obj - A Native JS Object.
* @param name - Name of a member.
* @param pjobj - return parameter as a java object representing
* the member. If it is a basic data type it is converted to
* a corresponding java type. If it is a NJSObject, then it is
* wrapped up as java wrapper netscape.javascript.JSObject.
*/
NS_IMETHOD
GetMember(JNIEnv *jEnv, jsobject obj, const char *name, jobject *pjobj) = 0;
/**
* get member of a Native JSObject for a given index.
*
* @param obj - A Native JS Object.
* @param index - Index of a member.
* @param pjobj - return parameter as a java object representing
* the member.
*/
NS_IMETHOD
GetSlot(JNIEnv *jEnv, jsobject obj, int index, jobject *pjobj) = 0;
/**
* set member of a Native JSObject for a given name.
*
* @param obj - A Native JS Object.
* @param name - Name of a member.
* @param jobj - Value to set. If this is a basic data type, it is converted
* using standard JNI calls but if it is a wrapper to a JSObject
* then a internal mapping is consulted to convert to a NJSObject.
*/
NS_IMETHOD
SetMember(JNIEnv *jEnv, jsobject obj, const char *name, jobject jobj) = 0;
/**
* set member of a Native JSObject for a given index.
*
* @param obj - A Native JS Object.
* @param index - Index of a member.
* @param jobj - Value to set. If this is a basic data type, it is converted
* using standard JNI calls but if it is a wrapper to a JSObject
* then a internal mapping is consulted to convert to a NJSObject.
*/
NS_IMETHOD
SetSlot(JNIEnv *jEnv, jsobject obj, int slot, jobject jobj) = 0;
/**
* remove member of a Native JSObject for a given name.
*
* @param obj - A Native JS Object.
* @param name - Name of a member.
*/
NS_IMETHOD
RemoveMember(JNIEnv *jEnv, jsobject obj, const char *name) = 0;
/**
* call a method of Native JSObject.
*
* @param obj - A Native JS Object.
* @param name - Name of a method.
* @param jobjArr - Array of jobjects representing parameters of method being caled.
* @param pjobj - return value.
*/
NS_IMETHOD
Call(JNIEnv *jEnv, jsobject obj, const char *name, jobjectArray jobjArr, jobject *pjobj) = 0;
/**
* Evaluate a script with a Native JS Object representing scope.
*
* @param obj - A Native JS Object.
* @param pNSIPrincipaArray - Array of principals to be used to compare privileges.
* @param numPrincipals - Number of principals being passed.
* @param script - Script to be executed.
* @param pjobj - return value.
*/
NS_IMETHOD
//Eval(jsobject obj, nsIPrincipal **pNSIPrincipaArray, PRInt32 numPrincipals, const char *script, jobject *pjobj) = 0;
Eval(JNIEnv *jEnv, jsobject obj, const char *script, jobject *pjobj) = 0;
/**
* Get the window object for a plugin instance.
*
* @param pJavaObject - Either a jobject or a pointer to a plugin instance
* representing the java object.
* @param pjobj - return value. This is a native js object
* representing the window object of a frame
* in which a applet/bean resides.
*/
NS_IMETHOD
GetWindow(JNIEnv *jEnv, void *pJavaObject, jsobject *pobj) = 0;
/**
* Get the window object for a plugin instance.
*
* @param jEnv - JNIEnv on which the call is being made.
* @param obj - A Native JS Object.
*/
NS_IMETHOD
FinalizeJSObject(JNIEnv *jEnv, jsobject obj) = 0;
};
#define NS_ILIVECONNECT_IID \
{ /* 68190910-3318-11d2-97f0-00805f8a28d0 */ \
0x68190910, \
0x3318, \
0x11d2, \
{0x97, 0xf0, 0x00, 0x80, 0x5f, 0x8a, 0x28, 0xd0} \
};
#define NS_CLIVECONNECT_CID \
{ /* b8f0cef0-3931-11d2-97f0-00805f8a28d0 */ \
0xb8f0cef0, \
0x3931, \
0x11d2, \
{0x97, 0xf0, 0x00, 0x80, 0x5f, 0x8a, 0x28, 0xd0} \
};
#endif // nsILiveconnect_h___

View File

@@ -1,46 +0,0 @@
Mstone building instructions
For Unix, just "gmake" one of these
release The usual optimized build
debug Debug build includes some asserts
rpackage Build the release and package it
dpackage Build the debug version and package it
all_OPT Build a multi-platform package
all_DBG Build a multi-platform debug package
For NT, run autobuild.bat. This will build and package both the debug
and optimized versions. Perl must already be built and installed in
\. The NT build may be behind the Unix stuff. Pull the build/package/*
subdirectories into the main build/package before doing a 'make all_???'.
You can build multiple OSes in the same tree. Debug and optimized
builds are kept separately. The all_??? targets will combine whatever
OSes are present into a multi-architecture package (including NT).
Note that you have ot build and package each OS before doing the all_
step.
Helper components
Linux usually comes with workable versions of gnuplot and perl. Most
other OSes don't. Mstone can build and package perl, gnuplot, and gd
with the right settings. These will be automatically built and
packaged if they are present.
Unpack gd1.3 or later in the mstone directory. You can probably find
gd from here: http://www.boutell.com/gd/. The directory should look
like gd?.*. Right now we need the (obsolete) version 1.3 to generate
GIF files (without patented run-length coding). The scripts need to
be updated to be able to handle PNG or GIF files.
Unpack gnuplot 3.7 or later in the mstone directory. You can probably
find gnuplot from http://www.cs.dartmouth.edu/gnuplot_info.html. The
directory should look like gnuplot-?.* (the exact version should not
matter). Gnuplot requres gd to generate GIFs (which is what we need).
Unpack perl 5.005 or later in the mstone directory. You can probably
find perl from http://www.perl.com/pub/language/info/software.html.
The directory should look like perl5.* (the exact version should
not matter).

View File

@@ -1,73 +0,0 @@
2005-02-19 Dan Christian <robodan@idiom.com>
* Merge big Sendmail patch see ChangeLog-Sendmail for details
* src/bench.h (VERSION): Start working toward version 5.0 (now 4.9)
2004-09-07 Dan Christian <robodan@idiom.com>
* data/*.msg: Updated with more realistic messages
* bin/args.pl: Really fix doc link to be relative
* src/smtp.c (sendSMTPLoop): Handle file lists (random selection)
(sendFile): New, send file with option offset and head/tail
(SmtpFilePrep): Split a glob pattern to a list
(SmtpFileInit): New, split out initial file scan
* src/bench.c (rangeNext): Get to last value in a random range
2004-06-14 Dan Christian <robodan@idiom.com>
* Makefile (VERSION): Bump version to 4.3
* Make build work on recent versions of Linux and Solaris
* Make ssh the default way to get a remote shell
* Support SVG graph output (not supported by all browsers)
* Use rfc822 style from addresses
* Fix documentation link on index page to be local
2000-04-28 Dan Christian <dac@x.cx>
* http and wmap now use common routines from http-util
* http is now separated from the pish command structure.
2000-04-27 Dan Christian <dac@x.cx>
* bin/genplot.pl: Support gnuplot generating images other than gif
* src/smtp.c (sendSMTPStart): Send domain name with HELO
2000-04-05 Dan Christian <robodan@netscape.com>
* Fix bug in WMAP where the login field was reporting banner data.
* Add a reconnect concept to WMAP. This separates out the
reconnect activity from the initial connections. There is still a
bug/feature that the reconnect increments an error which can
eventually hit the maxErrors limit. You have to record the error
or else you could not get the "connections" graph right.
2000-03-31 Dan Christian <robodan@netscape.com>
* Merged setup and mstone into one script to reduce command
namespace polution. "mstone setup" is the the same as "setup".
* Made setup try to be more tolerant of OSes that were not
include in the distribution. SunOS 5.7 will fall back to 5.6.
* Now package conf/general.wld.in and only copy to general.wld if
there isn't one already in place. This means that you can unpack
new bits over old bits without blowing away your configuration.
* Added <includeOnce file> command to workloads. This allows
tests to be used either as a stand alone or as part of another
test (e.g. smtp).
* Converted ChangeLog to more common formating
* Spilt off old ChangeLog entries to ChangeLog.1 and ChangeLog.2

View File

@@ -1,86 +0,0 @@
2005-02-03 Thom O'Connor <thom@sendmail.com>
* Merge Mozilla mstone HEAD with Sendmail,Inc. modifications. In
particular, this included some hand-waving around the bitwise
operators "leaveMailOnServer" in the Mozilla branch and the
dinst_t struct pish->leaveMailOnServerDist.
2005-01-25 Thom O'Connor <thom@sendmail.com>
* Fix comments, properly attribute Sean O'Rourke's contributions.
2004-09-21 Thom O'Connor <thom@sendmail.com>
* Modified config/config.mk to build SSL version of mailclient.
2004-06-07 Thom O'Connor <thom@sendmail.com>
* Remove _thread_sys_poll defininition for poll in FreeBSD builds
(bench.h).
2001-04-27 Sean O'Rourke <sean@sendmail.com>
* distributions can now be truncated. This is used to prevent
0-recipient messages, and could be used to prevent enormous
messages.
* throttling: Preload workloads use some additional mstone magic
to throttle delivery rate based on server responsiveness. This is
still in the experimental phase, and may change.
* fix for parsing bug exposed by distribution truncation notation.
2001-03-10 Sean O'Rourke <sean@sendmail.com>
* clients: Fixed up code for specifying client counts on a
per-host or per-group basis. This eliminates the need to force
the mozilla distribution code to do one's bidding.
* smtpsink.pl: Very basic threaded perl SMTP sink. This may go
away to be replaced by the sink from smtpslam. Needs much better
statistics.
2001-02-24 Sean O'Rourke <sean@sendmail.com>
* checksums added. See {checksum,md5}.{c,h}. Auto-generated
messages can currently have checksums computed over the body, and
pop and multipop retrieval will verify the sum.
2001-02-21 Sean O'Rourke <sean@sendmail.com>
* MIME generation changed to generate deep messages rather than
several parts. This should be a better test of MIME parsers,
forcing them to save more state.
2001-02-18 Sean O'Rourke <sean@sendmail.com>
* mstone_changes.html: update SSL documentation.
* wld, defaults.pm: divide the ever-expanding "config" section
into more descriptive subparts: clients, server, sink, mstone.
* report: now in bin directory, where it should be.
2001-02-17 Sean O'Rourke <sean@sendmail.com>
* client.c, main.c, parse.c: removed old throttling code, as it
wasn't being used.
* ALL: General code cleanup.
* sysdep.c: simplified rlimit-bumping code, added increase for
RLIM_NPROC, as threads are procs on some systems.
* imap4.c: removed silliness of malloc()ing a buffer the size of
the entire message every time we retrieve a message.
* xalloc.c, xalloc.h: consolidated memory allocation so everyone
handles OOM the same way (for now, dump core).
* constants.h: various assumptions and limits, were in bench.h.
* events: added event-queue model to reduce thread requirements.
Eventually, it would be nice for a consultant to be able to run
this off a laptop to test a small- to medium-sized box. For
now, at least, configuration remains the same. This doesn't
work on NT. Oh, well.

View File

@@ -1,129 +0,0 @@
MailStone 4.1: Changes to since version 4.0
* threads are used on all platforms reduces memory requirements by
10x for large numbers of clients must run as root for maximum
connections per process
* massive internal code and script cleanup / rewrite performance
improvements for socket handling (blocking) and caching files and
name lookups
* filename and path conventions restructuring '/mailstone'
hardwired path no longer required mailstone/results/index.html
(index of test runs) mailstone/results/<datestamp>/stderr (look
here for errors) mailstone/results/<datestamp>/results.html
mailstone/results/<datestamp>/results.txt
mailstone/results/<datestamp>/work.wld (workload config used)
mailstone/results/<datestamp>/testbed.tbd (testbed used)
mailstone/results/<datestamp>/summary.csv (per client summary)
mailstone/results/<datestamp>/*.gif (graphs)
mailstone/tmp/<datestamp>/*.out (raw results from each client)
mailstone/conf/*.wld (workload file) mailstone/conf/*.html
(machine descriptions for reports) mailstone/data/*.msg (sample
test messages)
* periodic statistics reporting allows for trend analysis of many
variables per protocol. sampling rate is automatically determined
by mailmaster Can now generate on-the-fly reports for above by
running "process"
* The accountFormat directive is now obsolete. Use loginFormat
and addressFormat instead.
* The numAccounts and beginAccounts directives are now obsolete.
Use numLogins, firstLogin, numAddresses, and firstAddress instead.
* The sequentialLogins directive disables random account number
selection. This insures a predictable account sequence.
* The checkMailInterval directive for IMAP is now obsolete. Use
loopDelay instead.
* The directives idleTime, loopDelay, and numLoops now apply to
all protocols. See the manual for how loopDelay and numLoops are
used by each protocol.
* a command directive such as <SMTP> without HOSTS=xxx will now
apply to all clients in the testbed
* <include> directive for workload and testbed files (e.g. for
user profile)
* workloads are now passed to 'mailclient' through stdin no test
specific files need to be copied to client machines more
synchonized test startup
* 'setup' script will copy mailclient and test messages
(data/*.msg) to each testbed machine in /var/tmp
* 'cleanup' form of setup will remove mailclient and test messages
from each testbed machine in /var/tmp
* 'checktime' form of setup will (nearly) simultaneously retrieve
time from each client. This lets you easily check for clock
problems.
* 'timesync' form of setup will (nearly) simultaneously set time
on each client. This only works on OSs that support setting
seconds through the "date" command. rdate or ntpdate should be
used if available. You must be the root user and be able to rsh
as root for timesync to work.
* Improved reports in text and html (formatting and content)
* The text version of the report is now only displayed
automatically if "-v" is given.
* Graphs with more than one protocol will also display a "Total"
graph
* The graphs can now be customized for each test (see sample.wld
for the default)
* You can now add graphs (in addition to the default or configured
ones) by using "process timestamp -a conf/moregraph.wld".
* An informative index of test runs is now generated in
results/index.html
* The index is updated while the run is in progress to make
checking for errors easier.
* The error log now displays times relative to test start.
* Memory use while processing results has been greatly reduced.
* A summary of the data from each process is now saved in a
Comma-separated-value (CSV) file. results/timestamp/clients.csv
* A summary of the data over time is now saved in a
Comma-separated-value (CSV) file.
results/timestamp/protocol-time.csv
* new gnuplot binary included, can output directly to gif format
* read and write performance numbers now reported separately
* new runtime banners and copyrights (ooh boy)
* idleTime option for IMAP fixed, plus now applies to all commands
* blockTime now sets a delay between command blocks
* Process model is as follows
User runs the top-level 'mstone' script
This calls 'conf/testname.pl' with command line arguments
This calls 'mailmaster.pl' with config and command line arguments
mailmaster uses 'rsh' or equivalent to launch mailclients
mailclient runs on each testbed and forks numprocs
each proc spawns numthreads (one per client)
<run tests> (note: results are being sent continuously)
threads send results back through sockets to top mailclient
mailclient forwards results back over stdout via rsh pipe
(for future work - do some data reduction/combining here)
mailmaster directs output to each client-<hostname> file
mailmaster launches report generator
* sample LDIF fragment for a postmaster entry included

View File

@@ -1,77 +0,0 @@
MailStone 4.15: Changes to Mailstone since version 4.1
* Setup now checks license acceptance and configures a basic
setup. By default, it will also create a user LDIF file with a
'allusers' account.
* All parameters and and testbed information may now be specified
in the workload files (*.wld). New sections: CONFIG, CLIENT,
MONITOR, PRETEST, and POSTTEST. Command line parameters still
override the files. A complete copy of the configuration is saved
in results/<TIMESTAMP>/all.wld.
* The '*.pl', '*.tbd', and 'config*' files in ./conf/ are
depreciated. These should still work, but the new sections are
simpler and more flexible.
* Any CONFIG parameter can now be specified on the command line
using the form: 'PARAMETER=value'. Note that PARAMETER is case
insensitive. No whitespace is allowed before or after the '='.
* The new switch '-l' or CONFIG parameter 'ClientCount' can now
specify the total number of clients. The 'MaxClients' and
'MaxThreads' parameters in each CLIENT section control load
balancing. If the 'processes' and 'threads' parameters are set,
then the load for that CLIENT section will not be adjusted, but
will be taken into account when calculating other CLIENT sections.
If just 'processes' is set, then only the thread count will be
adjusted. All hosts in a CLIENT section will run the same number
of processes and threads.
* bin/makeusers.pl now creates users, broadcast account, etc.
Numbered passwords are now suppored. The new user/password format
now replaces '%ld' with the user number to match the rest of
mailstone. The ldif/ directory is obsolete. Run "perl/bin/perl
bin/makeusers.pl -h" for usage.
* NT client machines may now be used from a Unix test master. See
conf/sample.wld for configuration details.
* Commands can now be run for a specified block count, error
count, or time (whichever comes first). Set 'maxBlocks' and/or
'maxErrors'.
* Telemetry logging to /var/tmp/mstone-log.pn.tn is now performed
when "telemetry 1" is specified.
* The name used in the "CLIENT" section is now used to match
"HOSTS=..." qualifier. Compatibility with "hostname" is no longer
needed.
* Config values can now use quoted characters such as \n, \r, \t
* Config values can be continued using \ (backslash)
* System configuration information (SYSCONFIG) can now be
specified entirely within a workload file by quoting the newlines.
* Config values get enclosing double-quotes stripped
* Preliminary support for HTTP and WMAP (WebMail) testing.
* New table formats are easier to interpret and allow more protocols.
* The new text format report is easier to machine processes.
* The following command line switches are now obsolete: -f, -g,
-e, -p, and -l. The same functionality can be obtained by
FREQUENCY=<interval>, GNUPLOT=<path>, RSH=<path>, RCP=<path>, and
TEMPDIR=<directory> respectively.
* File backups are now created. When ./process is run multiple
times, the old files are moved to the ./tmp/<TIMESTAMP>/
directory.
* perl has been updated to include full perl5.005_03 install
package. Perl support for each architecture is now under the
perl/ directory.

View File

@@ -1,222 +0,0 @@
Mstone 4.15 Quick Installation
This version of Mstone runs on many current UNIX platforms and NT.
Only a web browser and text editor are needed to view the results and
configure tests.
QUICK INSTALL
-------------
IMPORTANT: If you have an existing mstone, save a copy of the
mstone/conf directory to preserve any configuration files you may want
to keep.
Unpack distribution:
tar xzf /tmp/mstone_OPT.tar.gz
or
gunzip -c /tmp/mstone_OPT.tar.gz | tar xf -
or
unzip /tmp/mstone_OPT.zip
cd mstone
Both the tar.gz file and the zip file are identical. Use whichever is
more convenient for you.
This will create a sub-directory named "mstone" with files and
directories under that.
cd mstone
NOTE: all scripts must be run from the mstone directory.
Do initial configuration:
Run "mstone config". It will ask you about your system configuration.
Fill in the appropriate values and create the optional user accounts
and broadcast account. When it asks about client machines, enter them
seperated by commas, with no spaces (e.g. host1,host2,host3). If you
need to re-configure, run "mstone config".
The machine starting the test may also be a client. For accurate
results, clients should not be run on the test mailserver machine (or
its directory server). If all the client machines are not running
the same operating system version, see "Configuring Client Machines"
below to configure for different OSes.
When the test master is on NT, only the local machine may be a client
and only one process is allowed. You will not be asked about client
machines.
Setup only configures the most important parameters. If you have more
advanced needs, edit conf/general.wld appropriately.
Run "mstone setup". It will now push the necessary files to each
client machine. If there are problems (i.e. with rsh permissions),
fix them and re-run "mstone setup" until everything works.
Install test accounts:
Setup will create a file called conf/MAILHOST.ldif (where MAILHOST is the
name of your mail server). If you are not using Netscape Messaging
and Directory Servers, then you may have to edit the ldif file or use
alternate means to create the user accounts.
To import these users into Netscape Messaging Server, use "add
entries" from the directory console or use the ldapmodify command line
utility.
Note: imports will go faster if access logging is disabled. For large
user counts (more than 10,000 users), it may be much faster to export
the current database, merge the files together manually, and then
import the new database.
Here is how the ldapmodify supplied with Netscape Messaging Server
would be used.
setenv LD_LIBRARY_PATH /usr/netscape/messaging/lib
cd /usr/netscape/messaging
shared/bin/ldapmodify -h mailhost -a -D 'cn=directory manager' -w d_m_password < conf/MAILHOST.ldif
Check time consistency:
IMPORTANT: The system time on each client machine must be synchronized
within one second of each other for accurate results graphs.
Run "checktime" to see the time on each client. There should not be
more than two seconds difference among the displayed time.
The best way to synchronize clients is use NTP (Network Time Protocol)
or similar protocols (like rdate or timeslave) that have sub second
accuracy.
A simple utility called "timesync" is provide to push the local
system time to all clients. You must be root and have root rsh
permissions to use timesync. Timesync only works on OSs that support
setting seconds using "date MMDDhhmmCCYY.ss". Timesync is only
accurate to a second (at best) and should only be used if better
protocols aren't available.
When running the test master on NT, "checktime" and "timesync" are
never needed (because there is only one client machine). Timesync
will be ignored for NT clients, another method must be used
(e.g. timeserv or Dimension4).
Run tests:
Try it out. Use small process and thread counts until everything is
working.
mstone pop -t 30s
The script will tell you how many processes and threads it is running
on each system and where errors are logged. At the end of the test,
it will print out a URL for the test results and an indication of the
size of the errorlog file (stderr).
The results of the mstone run will display statistics for each
protocol that was tested. The results are presented in both a HTML
web page and a text file. The text file is simple and uniform, while
the web page is more user readable. The web page has links to the
test configuration files, error log, and the text version.
For long tests run (e.g. 8 hours), the results can be updated while
the test is running by using the "process" utility. Don't run
"process" near the very end of the test.
If a test has to be aborted, then use "process" to generate a report
using the available data.
Customize tests:
Copy and edit the scripts (e.g. "conf/pop.wld") to define new tests.
The CONFIG section specifies all the attributes used in the test.
Other sections specify the protocols to be tested and the parameters
for them.
All switches can be overridden on the command line to facilitate
easier testing. The exact configuration (include command line
overrides) is stored with the results from each test.
Maintenance:
You can run "mstone setup" at any time (except during a test :-) to
update the files on the client machines.
Use "mstone cleanup" to remove the files created by "mstone setup".
After the test is finished, the directories under "tmp/" can be
compressed or deleted to save space. All the information about a test
run is stored in the "results/" directories.
Configuring client machines:
Edit conf/general.wld to include CLIENT sections for each machines to
use.
You can also specify the OS type for each client machine. Set the
"Arch" parameter in each CLIENT section as appropriate (e.g. SunOS5.6,
Linux2.2_x86, AIX4.2, HP-UXB.11.00, IRIX6.5, OSF1V4.0, WINNT4.0). The
directories under "bin" specify the available OS types.
For NT4.0 clients with a UNIX test master, you will need to configure
"command" and "tempDir" for proper operation. See the "HOSTS=winnt01"
example in conf/sample.wld.
The total number of processes and threads that can be supported on a
client is dependent on the number of commands in the test, the OS, and
available memory. Check the stderr log for messages about not being
able to create processes or threads. Check on the client machines
during the test and make sure they aren't running out of CPU. The
UNIX programs "top" and "vmstat" are good for this. If the client CPU
is more than 75% busy, use more machines.
Also watch out for network saturation. You may have to use machines
with separate networks to the server to reach full server load.
Know problems:
There can be extraneous errors or connections after the specified end
of the test. These are most likely do to stopping the test and should
be ignored.
At the end of the test, all current connections will logout without
any delays. This can cause very high peak loads.
If one process exits early (due to misconfiguration or resource
exhaustion) and the monitoring command did not specify a count (%c),
then the monitoring tasks will be terminated early as well.
Monitoring commands that specify a count (%c), may take longer than
predicted and delay the processing of test results. This is because
vmstat actually delays the requested time plus the time needed to
generate the statistics summary.
If you are doing tests with large thread counts, you may have to run
as root to allow mailclient to raise its resource limits.
The telemetry logging for SMTP, POP3, and IMAP4 is incomplete. Most
commands are captured, but banners and message contents may be missing.
The MaxBlocks parameter gets divided by the total number of processes
before starting each client. This doesn't account for clients that
don't have commands to run.
The HTTP protocol used by WMAP allows connections to be dropped and
re-connected as needed. WMAP logs this as an error and an additional
connect. The error log must be consulted to distinguish another types
of connection errors (timeout or connection refused) from an automatic
re-connect.
The HTTP protocol test is experimental and subject to change.

View File

@@ -1,19 +0,0 @@
The contents of this software package are subject to the Netscape
Public License Version 1.1 (the "License"); you may not use this
software except in compliance with the License. You may obtain a copy
of the License at http://www.mozilla.org/NPL/
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
the License for the specific language governing rights and limitations
under the License.
Alternatively, the this software package may be used under the terms
of the GNU Public License (the "GPL"), in which case the provisions of
the GPL are applicable instead of those above. If you wish to allow
use of your version of this file only under the terms of the GPL and
not to allow others to use your version of this file under the NPL,
indicate your decision by deleting the provisions above and replace
them with the notice and other provisions required by the GPL. If you
do not delete the provisions above, a recipient may use your version
of this file under either the NPL or the GPL.

View File

@@ -1,535 +0,0 @@
MOZILLA PUBLIC LICENSE
Version 1.1
---------------
1. Definitions.
1.0.1. "Commercial Use" means distribution or otherwise making the
Covered Code available to a third party.
1.1. "Contributor" means each entity that creates or contributes to
the creation of Modifications.
1.2. "Contributor Version" means the combination of the Original
Code, prior Modifications used by a Contributor, and the Modifications
made by that particular Contributor.
1.3. "Covered Code" means the Original Code or Modifications or the
combination of the Original Code and Modifications, in each case
including portions thereof.
1.4. "Electronic Distribution Mechanism" means a mechanism generally
accepted in the software development community for the electronic
transfer of data.
1.5. "Executable" means Covered Code in any form other than Source
Code.
1.6. "Initial Developer" means the individual or entity identified
as the Initial Developer in the Source Code notice required by Exhibit
A.
1.7. "Larger Work" means a work which combines Covered Code or
portions thereof with code not governed by the terms of this License.
1.8. "License" means this document.
1.8.1. "Licensable" means having the right to grant, to the maximum
extent possible, whether at the time of the initial grant or
subsequently acquired, any and all of the rights conveyed herein.
1.9. "Modifications" means any addition to or deletion from the
substance or structure of either the Original Code or any previous
Modifications. When Covered Code is released as a series of files, a
Modification is:
A. Any addition to or deletion from the contents of a file
containing Original Code or previous Modifications.
B. Any new file that contains any part of the Original Code or
previous Modifications.
1.10. "Original Code" means Source Code of computer software code
which is described in the Source Code notice required by Exhibit A as
Original Code, and which, at the time of its release under this
License is not already Covered Code governed by this License.
1.10.1. "Patent Claims" means any patent claim(s), now owned or
hereafter acquired, including without limitation, method, process,
and apparatus claims, in any patent Licensable by grantor.
1.11. "Source Code" means the preferred form of the Covered Code for
making modifications to it, including all modules it contains, plus
any associated interface definition files, scripts used to control
compilation and installation of an Executable, or source code
differential comparisons against either the Original Code or another
well known, available Covered Code of the Contributor's choice. The
Source Code can be in a compressed or archival form, provided the
appropriate decompression or de-archiving software is widely available
for no charge.
1.12. "You" (or "Your") means an individual or a legal entity
exercising rights under, and complying with all of the terms of, this
License or a future version of this License issued under Section 6.1.
For legal entities, "You" includes any entity which controls, is
controlled by, or is under common control with You. For purposes of
this definition, "control" means (a) the power, direct or indirect,
to cause the direction or management of such entity, whether by
contract or otherwise, or (b) ownership of more than fifty percent
(50%) of the outstanding shares or beneficial ownership of such
entity.
2. Source Code License.
2.1. The Initial Developer Grant.
The Initial Developer hereby grants You a world-wide, royalty-free,
non-exclusive license, subject to third party intellectual property
claims:
(a) under intellectual property rights (other than patent or
trademark) Licensable by Initial Developer to use, reproduce,
modify, display, perform, sublicense and distribute the Original
Code (or portions thereof) with or without Modifications, and/or
as part of a Larger Work; and
(b) under Patents Claims infringed by the making, using or
selling of Original Code, to make, have made, use, practice,
sell, and offer for sale, and/or otherwise dispose of the
Original Code (or portions thereof).
(c) the licenses granted in this Section 2.1(a) and (b) are
effective on the date Initial Developer first distributes
Original Code under the terms of this License.
(d) Notwithstanding Section 2.1(b) above, no patent license is
granted: 1) for code that You delete from the Original Code; 2)
separate from the Original Code; or 3) for infringements caused
by: i) the modification of the Original Code or ii) the
combination of the Original Code with other software or devices.
2.2. Contributor Grant.
Subject to third party intellectual property claims, each Contributor
hereby grants You a world-wide, royalty-free, non-exclusive license
(a) under intellectual property rights (other than patent or
trademark) Licensable by Contributor, to use, reproduce, modify,
display, perform, sublicense and distribute the Modifications
created by such Contributor (or portions thereof) either on an
unmodified basis, with other Modifications, as Covered Code
and/or as part of a Larger Work; and
(b) under Patent Claims infringed by the making, using, or
selling of Modifications made by that Contributor either alone
and/or in combination with its Contributor Version (or portions
of such combination), to make, use, sell, offer for sale, have
made, and/or otherwise dispose of: 1) Modifications made by that
Contributor (or portions thereof); and 2) the combination of
Modifications made by that Contributor with its Contributor
Version (or portions of such combination).
(c) the licenses granted in Sections 2.2(a) and 2.2(b) are
effective on the date Contributor first makes Commercial Use of
the Covered Code.
(d) Notwithstanding Section 2.2(b) above, no patent license is
granted: 1) for any code that Contributor has deleted from the
Contributor Version; 2) separate from the Contributor Version;
3) for infringements caused by: i) third party modifications of
Contributor Version or ii) the combination of Modifications made
by that Contributor with other software (except as part of the
Contributor Version) or other devices; or 4) under Patent Claims
infringed by Covered Code in the absence of Modifications made by
that Contributor.
3. Distribution Obligations.
3.1. Application of License.
The Modifications which You create or to which You contribute are
governed by the terms of this License, including without limitation
Section 2.2. The Source Code version of Covered Code may be
distributed only under the terms of this License or a future version
of this License released under Section 6.1, and You must include a
copy of this License with every copy of the Source Code You
distribute. You may not offer or impose any terms on any Source Code
version that alters or restricts the applicable version of this
License or the recipients' rights hereunder. However, You may include
an additional document offering the additional rights described in
Section 3.5.
3.2. Availability of Source Code.
Any Modification which You create or to which You contribute must be
made available in Source Code form under the terms of this License
either on the same media as an Executable version or via an accepted
Electronic Distribution Mechanism to anyone to whom you made an
Executable version available; and if made available via Electronic
Distribution Mechanism, must remain available for at least twelve (12)
months after the date it initially became available, or at least six
(6) months after a subsequent version of that particular Modification
has been made available to such recipients. You are responsible for
ensuring that the Source Code version remains available even if the
Electronic Distribution Mechanism is maintained by a third party.
3.3. Description of Modifications.
You must cause all Covered Code to which You contribute to contain a
file documenting the changes You made to create that Covered Code and
the date of any change. You must include a prominent statement that
the Modification is derived, directly or indirectly, from Original
Code provided by the Initial Developer and including the name of the
Initial Developer in (a) the Source Code, and (b) in any notice in an
Executable version or related documentation in which You describe the
origin or ownership of the Covered Code.
3.4. Intellectual Property Matters
(a) Third Party Claims.
If Contributor has knowledge that a license under a third party's
intellectual property rights is required to exercise the rights
granted by such Contributor under Sections 2.1 or 2.2,
Contributor must include a text file with the Source Code
distribution titled "LEGAL" which describes the claim and the
party making the claim in sufficient detail that a recipient will
know whom to contact. If Contributor obtains such knowledge after
the Modification is made available as described in Section 3.2,
Contributor shall promptly modify the LEGAL file in all copies
Contributor makes available thereafter and shall take other steps
(such as notifying appropriate mailing lists or newsgroups)
reasonably calculated to inform those who received the Covered
Code that new knowledge has been obtained.
(b) Contributor APIs.
If Contributor's Modifications include an application programming
interface and Contributor has knowledge of patent licenses which
are reasonably necessary to implement that API, Contributor must
also include this information in the LEGAL file.
(c) Representations.
Contributor represents that, except as disclosed pursuant to
Section 3.4(a) above, Contributor believes that Contributor's
Modifications are Contributor's original creation(s) and/or
Contributor has sufficient rights to grant the rights conveyed by
this License.
3.5. Required Notices.
You must duplicate the notice in Exhibit A in each file of the Source
Code. If it is not possible to put such notice in a particular Source
Code file due to its structure, then You must include such notice in a
location (such as a relevant directory) where a user would be likely
to look for such a notice. If You created one or more Modification(s)
You may add your name as a Contributor to the notice described in
Exhibit A. You must also duplicate this License in any documentation
for the Source Code where You describe recipients' rights or ownership
rights relating to Covered Code. You may choose to offer, and to
charge a fee for, warranty, support, indemnity or liability
obligations to one or more recipients of Covered Code. However, You
may do so only on Your own behalf, and not on behalf of the Initial
Developer or any Contributor. You must make it absolutely clear than
any such warranty, support, indemnity or liability obligation is
offered by You alone, and You hereby agree to indemnify the Initial
Developer and every Contributor for any liability incurred by the
Initial Developer or such Contributor as a result of warranty,
support, indemnity or liability terms You offer.
3.6. Distribution of Executable Versions.
You may distribute Covered Code in Executable form only if the
requirements of Section 3.1-3.5 have been met for that Covered Code,
and if You include a notice stating that the Source Code version of
the Covered Code is available under the terms of this License,
including a description of how and where You have fulfilled the
obligations of Section 3.2. The notice must be conspicuously included
in any notice in an Executable version, related documentation or
collateral in which You describe recipients' rights relating to the
Covered Code. You may distribute the Executable version of Covered
Code or ownership rights under a license of Your choice, which may
contain terms different from this License, provided that You are in
compliance with the terms of this License and that the license for the
Executable version does not attempt to limit or alter the recipient's
rights in the Source Code version from the rights set forth in this
License. If You distribute the Executable version under a different
license You must make it absolutely clear that any terms which differ
from this License are offered by You alone, not by the Initial
Developer or any Contributor. You hereby agree to indemnify the
Initial Developer and every Contributor for any liability incurred by
the Initial Developer or such Contributor as a result of any such
terms You offer.
3.7. Larger Works.
You may create a Larger Work by combining Covered Code with other code
not governed by the terms of this License and distribute the Larger
Work as a single product. In such a case, You must make sure the
requirements of this License are fulfilled for the Covered Code.
4. Inability to Comply Due to Statute or Regulation.
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Code due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description
must be included in the LEGAL file described in Section 3.4 and must
be included with all distributions of the Source Code. Except to the
extent prohibited by statute or regulation, such description must be
sufficiently detailed for a recipient of ordinary skill to be able to
understand it.
5. Application of this License.
This License applies to code to which the Initial Developer has
attached the notice in Exhibit A and to related Covered Code.
6. Versions of the License.
6.1. New Versions.
Netscape Communications Corporation ("Netscape") may publish revised
and/or new versions of the License from time to time. Each version
will be given a distinguishing version number.
6.2. Effect of New Versions.
Once Covered Code has been published under a particular version of the
License, You may always continue to use it under the terms of that
version. You may also choose to use such Covered Code under the terms
of any subsequent version of the License published by Netscape. No one
other than Netscape has the right to modify the terms applicable to
Covered Code created under this License.
6.3. Derivative Works.
If You create or use a modified version of this License (which you may
only do in order to apply it to code which is not already Covered Code
governed by this License), You must (a) rename Your license so that
the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",
"MPL", "NPL" or any confusingly similar phrase do not appear in your
license (except to note that your license differs from this License)
and (b) otherwise make it clear that Your version of the license
contains terms which differ from the Mozilla Public License and
Netscape Public License. (Filling in the name of the Initial
Developer, Original Code or Contributor in the notice described in
Exhibit A shall not of themselves be deemed to be modifications of
this License.)
7. DISCLAIMER OF WARRANTY.
COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
8. TERMINATION.
8.1. This License and the rights granted hereunder will terminate
automatically if You fail to comply with terms herein and fail to cure
such breach within 30 days of becoming aware of the breach. All
sublicenses to the Covered Code which are properly granted shall
survive any termination of this License. Provisions which, by their
nature, must remain in effect beyond the termination of this License
shall survive.
8.2. If You initiate litigation by asserting a patent infringement
claim (excluding declatory judgment actions) against Initial Developer
or a Contributor (the Initial Developer or Contributor against whom
You file such action is referred to as "Participant") alleging that:
(a) such Participant's Contributor Version directly or indirectly
infringes any patent, then any and all rights granted by such
Participant to You under Sections 2.1 and/or 2.2 of this License
shall, upon 60 days notice from Participant terminate prospectively,
unless if within 60 days after receipt of notice You either: (i)
agree in writing to pay Participant a mutually agreeable reasonable
royalty for Your past and future use of Modifications made by such
Participant, or (ii) withdraw Your litigation claim with respect to
the Contributor Version against such Participant. If within 60 days
of notice, a reasonable royalty and payment arrangement are not
mutually agreed upon in writing by the parties or the litigation claim
is not withdrawn, the rights granted by Participant to You under
Sections 2.1 and/or 2.2 automatically terminate at the expiration of
the 60 day notice period specified above.
(b) any software, hardware, or device, other than such Participant's
Contributor Version, directly or indirectly infringes any patent, then
any rights granted to You by such Participant under Sections 2.1(b)
and 2.2(b) are revoked effective as of the date You first made, used,
sold, distributed, or had made, Modifications made by that
Participant.
8.3. If You assert a patent infringement claim against Participant
alleging that such Participant's Contributor Version directly or
indirectly infringes any patent where such claim is resolved (such as
by license or settlement) prior to the initiation of patent
infringement litigation, then the reasonable value of the licenses
granted by such Participant under Sections 2.1 or 2.2 shall be taken
into account in determining the amount or value of any payment or
license.
8.4. In the event of termination under Sections 8.1 or 8.2 above,
all end user license agreements (excluding distributors and resellers)
which have been validly granted by You or any distributor hereunder
prior to termination shall survive termination.
9. LIMITATION OF LIABILITY.
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR
ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO
THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
10. U.S. GOVERNMENT END USERS.
The Covered Code is a "commercial item," as that term is defined in
48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer
software" and "commercial computer software documentation," as such
terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
all U.S. Government End Users acquire Covered Code with only those
rights set forth herein.
11. MISCELLANEOUS.
This License represents the complete agreement concerning subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. This License shall be governed by
California law provisions (except to the extent applicable law, if
any, provides otherwise), excluding its conflict-of-law provisions.
With respect to disputes in which at least one party is a citizen of,
or an entity chartered or registered to do business in the United
States of America, any litigation relating to this License shall be
subject to the jurisdiction of the Federal Courts of the Northern
District of California, with venue lying in Santa Clara County,
California, with the losing party responsible for costs, including
without limitation, court costs and reasonable attorneys' fees and
expenses. The application of the United Nations Convention on
Contracts for the International Sale of Goods is expressly excluded.
Any law or regulation which provides that the language of a contract
shall be construed against the drafter shall not apply to this
License.
12. RESPONSIBILITY FOR CLAIMS.
As between Initial Developer and the Contributors, each party is
responsible for claims and damages arising, directly or indirectly,
out of its utilization of rights under this License and You agree to
work with Initial Developer and Contributors to distribute such
responsibility on an equitable basis. Nothing herein is intended or
shall be deemed to constitute any admission of liability.
13. MULTIPLE-LICENSED CODE.
Initial Developer may designate portions of the Covered Code as
"Multiple-Licensed". "Multiple-Licensed" means that the Initial
Developer permits you to utilize portions of the Covered Code under
Your choice of the NPL or the alternative licenses, if any, specified
by the Initial Developer in the file described in Exhibit A.
EXHIBIT A-Netscape Public License.
"The contents of this file are subject to the Netscape Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/NPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is the Netscape Mailstone code, released
March 17, 2000.
The Initial Developer of the Original Code is Netscape
Communications Corporation. Portions created by Netscape are
Copyright (C) 1999-2000 Netscape Communications Corporation. All
Rights Reserved.
Contributor(s): Dan Christian <robodan@netscape.com>
Marcel DePaolis <marcel@netscape.com>
Jim Salter <jsalter@netscape.com>
Mike Blakely, David Shak, Brain Williams
Alternatively, the contents of this file may be used under the
terms of the GNU General Public license Version 2 or later
(the "GPL"), in which case the provisions of GPL are
applicable instead of those above. If you wish to allow use
of your version of this file only under the terms of the GPL
and not to allow others to use your version of this file
under the NPL, indicate your decision by deleting the
provisions above and replace them with the notice and other
provisions required by the GPL. If you do not delete the
provisions above, a recipient may use your version of this
file under either the NPL or the GPL License."
----------------------------------------------------------------------
AMENDMENTS
The Netscape Public License Version 1.1 ("NPL") consists of the
Mozilla Public License Version 1.1 with the following Amendments,
including Exhibit A-Netscape Public License. Files identified with
"Exhibit A-Netscape Public License" are governed by the Netscape
Public License Version 1.1.
Additional Terms applicable to the Netscape Public License.
I. Effect.
These additional terms described in this Netscape Public
License -- Amendments shall apply to the Mozilla Communicator
client code and to all Covered Code under this License.
II. "Netscape's Branded Code" means Covered Code that Netscape
distributes and/or permits others to distribute under one or more
trademark(s) which are controlled by Netscape but which are not
licensed for use under this License.
III. Netscape and logo.
This License does not grant any rights to use the trademarks
"Netscape", the "Netscape N and horizon" logo or the "Netscape
lighthouse" logo, "Netcenter", "Gecko", "Java" or "JavaScript",
"Smart Browsing" even if such marks are included in the Original
Code or Modifications.
IV. Inability to Comply Due to Contractual Obligation.
Prior to licensing the Original Code under this License, Netscape
has licensed third party code for use in Netscape's Branded Code.
To the extent that Netscape is limited contractually from making
such third party code available under this License, Netscape may
choose to reintegrate such code into Covered Code without being
required to distribute such code in Source Code form, even if
such code would otherwise be considered "Modifications" under
this License.
V. Use of Modifications and Covered Code by Initial Developer.
V.1. In General.
The obligations of Section 3 apply to Netscape, except to
the extent specified in this Amendment, Section V.2 and V.3.
V.2. Other Products.
Netscape may include Covered Code in products other than the
Netscape's Branded Code which are released by Netscape
during the two (2) years following the release date of the
Original Code, without such additional products becoming
subject to the terms of this License, and may license such
additional products on different terms from those contained
in this License.
V.3. Alternative Licensing.
Netscape may license the Source Code of Netscape's Branded
Code, including Modifications incorporated therein, without
such Netscape Branded Code becoming subject to the terms of
this License, and may license such Netscape Branded Code on
different terms from those contained in this License.
VI. Litigation.
Notwithstanding the limitations of Section 11 above, the
provisions regarding litigation in Section 11(a), (b) and (c) of
the License shall apply to all disputes relating to this License.

View File

@@ -1,246 +0,0 @@
# Makefile for mstone
# use gmake
# Builds each of the components and then packages everything
topsrcdir = .
CP := cp -p
ifndef INCLUDED_CONFIG_MK
include $(topsrcdir)/config/config.mk
endif
# dynamically find the optional directories names
LIBGD_DIR = $(wildcard gd?.*)
GNUPLOT_DIR = $(wildcard gnuplot-?.*)
PERL_DIR = $(wildcard perl5.*)
# file that we package
GDFILES = gd.txt gd.html libgd.* gd.h demoin.gif gddemo giftogd webgif
GNUPLOTFILES = gnuplot Copyright gnuplot_x11 gnuplot.1 gnuplot.gih
VERSION = 4.3
TARBALL = mstone-$(VERSION)-$(NSARCH)$(OBJDIR_TAG).tar.gz
ZIPFILE = mstone-$(VERSION)-$(NSARCH)$(OBJDIR_TAG).zip
TARBALL_ALL = mstone-$(VERSION)-all$(OBJDIR_TAG).tar.gz
ZIPFILE_ALL = mstone-$(VERSION)-all$(OBJDIR_TAG).zip
NTFILES = mstone.bat process.bat setup.bat
all:: usage
usage::
@$(ECHO) "gmake [ release | rpackage | debug | dpackage ]"
@$(ECHO) " [ DIST=/m/dist/mailstone/1999xxxx dist ]"
@$(ECHO) " [ all_DBG | all_OPT ]"
@$(ECHO) "perl is" $(PERL_DIR) ". gd is" $(LIBGD_DIR) ". gnuplot is" $(GNUPLOT_DIR) "."
targets:: $(OBJDIR) mailclient
ifneq (,$(LIBGD_DIR))
targets:: libgd
endif
ifneq (,$(GNUPLOT_DIR))
targets:: gnuplot
endif
ifneq (,$(PERL_DIR))
targets:: perl
endif
$(OBJDIR):
-mkdir -p $(OBJDIR)
mailclient::
@$(ECHO) "\n===== [`date`] making OS_CONFIG=$(NSARCH) BUILD_VARIANT=$(BUILD_VARIANT)\n"
cd src; $(MAKE) BUILD_VARIANT=$(BUILD_VARIANT) OBJDIR=../$(OBJDIR) PKGDIR=../$(PKGDIR) all
# Use our top level makefiles to drive the component builds
libgd $(OBJDIR)/gd/libgd.a::
$(MAKE) -f gd.mk LIBGD_DIR=$(LIBGD_DIR) libgd
gnuplot $(OBJDIR)/gnuplot/gnuplot::
$(MAKE) -f gnuplot.mk LIBGD_DIR=$(LIBGD_DIR) GNUPLOT_DIR=$(GNUPLOT_DIR) gnuplot
perl $(OBJDIR)/perl/perl::
$(MAKE) -f perl.mk PERL_DIR=$(PERL_DIR) perl
# Create packaging binary directories
# Note: dont make gd or gnuplot here. For multi-OS, they are links
mkpkgdirs:: $(PKGDIR)/bin $(PKGDIR)/conf $(PKGDIR)/data $(PKGDIR)/doc
$(PKGDIR)/bin:
mkdir -p $(PKGDIR)/bin
$(PKGDIR)/conf:
mkdir -p $(PKGDIR)/conf
$(PKGDIR)/data:
mkdir -p $(PKGDIR)/data
$(PKGDIR)/doc:
mkdir -p $(PKGDIR)/doc
$(PKGDIR)/gd:
mkdir -p $(PKGDIR)/gd
$(PKGDIR)/gnuplot:
mkdir -p $(PKGDIR)/gnuplot
$(PKGDIR)/perl:
mkdir -p $(PKGDIR)/perl
# operating system independent share-files (at least for Unix)
pkg-share-files:: mkpkgdirs
@$(ECHO) "\n===== [`date`] making package share-files...\n"
$(CP) mstone process $(PKGDIR)
(cd $(PKGDIR); [ ! -f setup ] || rm -f setup; ln -s mstone setup)
(cd $(PKGDIR); [ ! -f cleanup ] || rm -f cleanup; ln -s mstone cleanup)
(cd $(PKGDIR); [ ! -f checktime ] || rm -f checktime; ln -s mstone checktime)
(cd $(PKGDIR); [ ! -f timesync ] || rm -f timesync; ln -s mstone timesync)
-$(CP) nsarch bin/*.pl $(PKGDIR)/bin
-$(CP) conf/*.wld conf/*.wld.in conf/*.html $(PKGDIR)/conf
-$(CP) data/*.msg $(PKGDIR)/data
-$(CP) doc/*.html doc/*.gif $(PKGDIR)/doc
-$(CP) INSTALL $(PKGDIR)
-$(CP) README $(PKGDIR)
-$(CP) ChangeLog $(PKGDIR)
-$(CP) LICENSE $(PKGDIR)
# split out OS specific file so that combined packaging possible (set PKGDIR)
pkg-arch-files-gd:: $(PKGDIR)/gd $(OBJDIR)/gd/libgd.a
$(CP) $(addprefix $(OBJDIR)/gd/, $(GDFILES)) $(PKGDIR)/gd
-$(STRIP) $(PKGDIR)/gd/webgif $(PKGDIR)/gd/giftogd $(PKGDIR)/gd/gddemo
pkg-arch-files-gnuplot:: $(PKGDIR)/gnuplot $(OBJDIR)/gnuplot/gnuplot
$(CP) $(addprefix $(OBJDIR)/gnuplot/, $(GNUPLOTFILES)) $(PKGDIR)/gnuplot
-$(STRIP) $(PKGDIR)/gnuplot/gnuplot $(PKGDIR)/gnuplot/gnuplot_x11
ifneq (,$(LIBGD_DIR))
pkg-arch-files:: pkg-arch-files-gd
endif
ifneq (,$(GNUPLOT_DIR))
pkg-arch-files:: pkg-arch-files-gnuplot
endif
pkg-arch-files:: $(PKGDIR)/bin $(OBJDIR)/mailclient
@$(ECHO) "\n===== [`date`] making package arch-files...\n"
$(CP) $(OBJDIR)/mailclient $(PKGDIR)/bin
-$(STRIP) $(PKGDIR)/bin/mailclient
pkg-perl-files:: $(PKGDIR)/bin $(OBJDIR)/perl/perl
@$(ECHO) "\n===== [`date`] making package perl-files...\n"
$(MAKE) -f perl.mk PERL_DIR=$(PERL_DIR) \
BUILD_VARIANT=$(BUILD_VARIANT) \
OBJDIR=$(OBJDIR) PKGDIR=$(PKGDIR) package-perl
find $(PKGDIR)/perl/lib -name .packlist -exec rm {} \; -print
-$(STRIP) $(PKGDIR)/perl/bin/perl
-$(STRIP) $(PKGDIR)/perl/bin/a2p
# for combined packaging, this should not be part of pkg-arch-files
# perl is handled seperately do to its size
ifneq (,$(PERL_DIR))
pkg:: pkg-perl-files
endif
pkg:: targets pkg-share-files pkg-arch-files
tarball: build/$(TARBALL)
build/$(TARBALL):
@$(ECHO) "\n===== [`date`] making os tar file...\n"
-rm -f build/$(TARBALL)
cd $(dir $(PKGDIR)) && tar cf - . | gzip > ../../$(TARBALL)
zipfile: build/$(ZIPFILE)
build/$(ZIPFILE):
@$(ECHO) "\n===== [`date`] making os zip file...\n"
-rm -f build/$(ZIPFILE)
cd $(dir $(PKGDIR)) && zip -r -q ../../$(ZIPFILE) .
########################################################################
# Generate a combined build for every Unix OS that is already packaged
# NT has to be done seperately because it has different file names
# We have to nuke some old parts, because permissions wont allow overwrites
# Finally, dont ship perl development headers and libraries
all_DBG all_OPT::
@$(ECHO) "===== [`date`] unified packaging for $@..."
$(MAKE) NSARCH=$@ OBJDIR_TAG='' \
PKGDIR=$(topsrcdir)/build/package/$@.OBJ/mstone pkg-share-files
./ospkg.sh $@.OBJ \
$(notdir $(shell ls -d build/package/[A-Z]*$(subst all,,$@.OBJ)))
[ -d $(topsrcdir)/build/package/$@.OBJ/mstone/bin/WINNT4.0 ] \
&& cp -p $(NTFILES) $(topsrcdir)/build/package/$@.OBJ/mstone; :
-rm -f ./build/mstone-$(VERSION)-$@.tar.gz
cd ./build/package/$@.OBJ \
&& tar cf - . | gzip > ../../mstone-$(VERSION)-$@.tar.gz
-rm -f ./build/mstone-$(VERSION)-$@.zip
cd ./build/package/$@.OBJ \
&& zip -r -q ../../mstone-$(VERSION)-$@.zip .
########################################################################
# Copy all the packaged trees to the distribution site
# Copy in the unified tarball and zip file
# Link mstone to mailstone for Netscape back compatibility
# Re-map short Linux name to standard Netscape convention
dist::
@[ "$(DIST)" != "" ] || ($(MAKE) usage && /bin/false)
@[ ! -d "$(DIST)" ] || ($(ECHO) "Error: $(DIST) already exists" && \
$(MAKE) usage && /bin/false)
mkdir -p $(DIST)
cp -p build/mstone-$(VERSION)-all_*.*[a-z] $(DIST)/
(cd build/package; tar cf - *.OBJ) | (cd $(DIST); tar xf - )
for l in $(DIST)/*_???.OBJ ; do \
(cd $$l; ln -s mstone mailstone); done
cd $(DIST); for l in Linux*_???.OBJ ; do \
nn=`echo $$l | sed -e 's/_OPT/_glibc_PTH_OPT/' | sed -e 's/_DBG/_glibc_PTH_DBG/'`; \
ln -s $$l $$nn; done
# since the default is release mode, this can just work off a dependency
release:: targets
#release::
# @$(ECHO) "\n===== [`date`] making release build..."
# $(MAKE) BUILD_VARIANT=release OBJDIR_TAG=_OPT targets
@$(ECHO) "\n===== [`date`] making release build done."
rpackage:: release pkg #tarball zipfile
#rpackage:: release
# @$(ECHO) "\n===== [`date`] making release package..."
# $(MAKE) BUILD_VARIANT=release OBJDIR_TAG=_OPT pkg tarball zipfile
@$(ECHO) "\n===== [`date`] making release package done."
# since the default is release mode, start a make with the right mode
debug::
@$(ECHO) "\n===== [`date`] making debug build..."
$(MAKE) BUILD_VARIANT=debug OBJDIR_TAG=_DBG targets
@$(ECHO) "\n===== [`date`] making debug build done."
# We dont usually bother to tar up a debug build
dpackage:: debug
@$(ECHO) "\n===== [`date`] making debug package..."
$(MAKE) BUILD_VARIANT=debug OBJDIR_TAG=_DBG pkg
@$(ECHO) "\n===== [`date`] making debug package done."
# These are old and may be broken
cleanvariant::
(cd src; $(MAKE) OBJDIR=../$(OBJDIR) clean)
rm -rf $(PKGDIR)
clean::
$(MAKE) BUILD_VARIANT=release OBJDIR_TAG=_OPT cleanvariant
$(MAKE) BUILD_VARIANT=debug OBJDIR_TAG=_DBG cleanvariant
distcleanvariant::
(cd src; $(MAKE) OBJDIR=../$(OBJDIR) distclean)
rm -rf $(OBJDIR) $(PKGDIR)
distclean:: clean
$(MAKE) BUILD_VARIANT=release OBJDIR_TAG=_OPT distcleanvariant
$(MAKE) BUILD_VARIANT=debug OBJDIR_TAG=_DBG distcleanvariant

View File

@@ -1,75 +0,0 @@
MSTONE 4.2
Mstone is a mail server performance testing tool designed to simulate
the different types and volume of mail traffic a mail server would
experience during a peak activity period. Mstone was formerly known
as Mailstone.
A quick installation guide is available in INSTALL.
The full Mailstone 4.15 user manual is available at
http://lxr.mozilla.org/mozilla/source/mstone/doc/MailStone.html
Testing strategy
----------------
Mstone is capable of opening SMTP, POP3, IMAP4, and other protocol
connections to mail servers. The number and type of connections made
to the mail server is based on a weighted command list which provides
the ability to test mail server implementation requirements.
A series of perl script allow you to setup client machines, run tests,
and then cleanup client machine files. Each client machine has a copy
of the mailclient program and SMTP message files. When the test is
run, the mailclient is started with the proper command line and work load.
After experimenting with mstone loads, you will notice that there
are a few factors that can distort server the byte and message
throughput. You will find that the server byte throughput is related
to the average SMTP message (file) size. Also, server throughput, in
bytes and messages, is affected by larger than normal POP3/IMAP4
mailboxes. So it is important to approach the mstone command
configuration with data collected from existing mail server
implementations, for example, a customer might say "during our peak
activity in the morning, we handle up to two thousand employees
sending an average of 5 messages of 20K average size and receiving 25
messages of same size". With input like this, you can begin tuning
mstone to generate relevant data.
There are two important things to consider when reviewing the results of
mstone performance analysis: Was the test run on target for
simulating the type and volume of mail traffic; and did the server, both
software and machine, handle the load within an acceptable margin?
With this information, it can be determined: whether enough SMTP
connections were made to the server during the run, and how many
messages were downloaded over how many POP3/IMAP4 connections. If the
number of SMTP connections is not in the acceptable range, then
consider adding more client processes/machines or checking the server
performance during the run. The message/connection ratio for
POP3/IMAP4 should be checked for soundness, and adjustments should be
made to the mailboxes before running the next test.
Monitoring the server performance during test runs is crucial in
understanding the results. If the number of client connections is not
being achieved and the server cpu usage and process run queue is not
settling down after the initial spike, then modifications to the server
architecture could be in order.
The analysis of mstone results is an iterative process of client
(mstone client) and server tuning. The bottom line is to determine
whether the messaging solution can handle the type of load expected in
an acceptable manner.
Server Log Tuning
-----------------
The Messaging and Directory server ship with access logging enabled by
default. This gives the most information about what is going on in
the system, but can reduce performance. You should test the way the
system will be run.
Noticeable performance increases are often obtained by disabling access
logging on the directory server and by reducing the logging level of
the messaging servers from "Notice" to "Warning".

View File

@@ -1,16 +0,0 @@
Under the terms of the Mozilla Public License, Version 1.1, granted
by Mozilla, Sendmail Inc. is contributing the following Source Code
changes to the Mozilla mstone source repository.
Sendmail, Inc. is making available these source code modifications
according to the Distribution Obligations as listed in section 3
of the Mozilla Public License, Version 1.1
The changes provided herein are described in the included files:
README.Sendmail-mstone_changes.html
ChangeLog-Sendmail
All modifications are derived, directly or indirectly, from the original
code as provided by Mozilla.

View File

@@ -1,419 +0,0 @@
<html>
<head><title>Sendmail, Inc. Mstone changes</title></head>
<body>
<h3>Mstone modifications</h3>
<ol>
<li><h4>Random Variable Parameters</h4>
In addition to taking on constant values, some parameters can now be
sampled from probability distributions. These variables are:
<ul>
<li><code>startDelay</code>
<li><code>idleTime</code>
<li><code>blockTime</code>
<li><code>loopDelay</code>
<li><code>numRecips</code>
<li><code>size</code>
<li><code>headers</code>
<li><code>mime</code>
<li><code>leaveMailOnServer</code>
<li><code>bandwidth</code>
<li><code>latency</code>
</ul>
<p>
The following distributions are currently implemented:
<ul>
<li>Uniform (~unif(a, b))
<li>Normal (~normal(a, b))
<li>Log-Normal (~lognormal(a, b))
<li>Weibull (~weib(a, b, c))
<li>Exponential (~exp(a))
<li>Constant (~const(a))
<li>Binomial (~binomial(a))
</ul>
<p>
Sampled values may also be constrained by a minimum and maximum value.
This is particularly useful for e.g. the normal and lognormal
distributions, though over-tight constraints will create a "lump" at
the end of the generated distribution, and any constraints may change
the distribution's characteristics (e.g. mean). To specify
constraints, do the following:
<h5>getdist</h5>
<p>
There is also a helper tool called "getdist" in the Sendmail mstone
distribution. Building getdist:
<pre>
file: mstone/src/idle.c
# gcc -DTEST_PROB -Dxalloc=malloc -Dxfree=free -lm idle.c
</pre>
<p>
Rename the resulting binary to "getdist"
<p>
<b>Using getdist</b>
<p>
To run it interactively:
<ol>
<li>Start up getdist</li>
<li>Enter the distribution you want to see a sample and mean (ignore warning about 'gets()')</li>
</ol>
<p>
Example:
<pre>
% getdist
warning: this program uses gets(), which is unsafe.
~lognormal(3,4.5)
Samples:
6.846493
0.109578
31.402784
0.467486
21.905714
7.113645
0.225102
29.372181
4.252427
1.444493
mean: 29.128932
</pre>
<p>
It will only OUTPUT 10 samples as examples but the mean
is calculated based on 2000 samples by default. You can specify
the mean sample size on the command line by giving it a -n option:
<pre>
% getdist -n 1000000
</pre>
<p>
This will calculate the mean based on a sample of 1000000 entries.
<p>
The above data was calculated with 2M samples.
<p>
<i>Known Problems</i><BR>
It appears (anecdotally) that the first set of samples returned by
getdist are inaccurate. After starting the getdist program interactively,
it may appear necessary to ignore the first set of output, but that entering
the distribution again will return a more accurate result.<BR>
<p>
For example:
<pre>
# getdist
~lognormal(10,2)
Samples:
670043.575395
48.842052
54.039792
0.460849
2.152179
32.534664
6.163511
42.827706
27.806642
4.966444
mean: 364.747532
var: 224352671.855287
stddev: 14978.406853
~lognormal(10,2)
Samples:
1.842800
39.760727
4.798239
10.722216
27.052030
28.923926
61.504273
20.743583
5.373420
42.195531
mean: 25.510130
var: 2674.124997
stddev: 51.711942
</pre>
<dl>
<dt><code>~dist(...) : [min,]</code>
<dd>force all sampled values to be >= <code>min</code>
<dt><code>~dist(...) : [min,max]</code>
<dd>force all sampled values X to be <code>min</code> <= X <= <code>max</code>.
<dt><code>~dist(...) : [,max]</code>
<dd>force values to be <= <code>max</code>
</dl>
<li><h4>Parsing Changes</h4>
All of the time-valued test parameters except <code>rampTime</code>
and <code>time</code> now have millisecond values. In particular,
this means that a value of "17" parses to 17
<strong>milliseconds</strong>, not 17 seconds. Use "17s" instead.
<p>
Size-valued parameters can have units of "k" or "m" to indicate
kilobytes or megabytes, respectively.
<p>
For parameters supporting random-variable values, a value starting
with "~" will be interpreted as a random variable specification of the
form "~NAME([ARGS ...])". Unit suffixes (e.g. "s", and "m") apply to
random variable parameters as well as constant values. This implies
that for unitless parameters, the suffixes corresponding to the random
variable's units will still be recognized (i.e. the values will be
multiplied by the appropriate factors). This is probably best
considered as a "bug" rather than excercised as a "feature."
<p>
<code>blockTime</code>, <code>loopDelay</code>, and
<code>idleTime</code> now refer to the total amount of time a command
block, loop, and initialization phase should take, respectively, not
the amount of time the simulation should stall after completing each
phase. For example, if a block takes 2 seconds to complete, and the
block time is 4 seconds, the client thread will sleep for 2 seconds
after finishing instead of the full 4.<p>
<code>rampTime</code> is now solely for the benefit of the client
machines, to control the rate at which threads are started. The rate
at which commands from a given protocol are started is now controlled
by the <code>startDelay</code> variable, which is
distribution-valued. Thus the actual command loop now looks like
this:
<pre>
wait for startDelay
start counting idleTime
start counting blockTime
execute start function
wait for remainder of idleTime
for (1 ... numLoops)
start counting loopDelay
execute loop function
wait for remainder of loopDelay
execute end function
wait for remainder of blockTime
</pre>
<li><h4>Automatic Message Generation</h4>
Both MIME and text/plain messages can now be generated automatically.
To enable automatic message generation, set the <code>file</code>
attribute of an SMTP block to "auto". The messages will then have at
least as many headers as the value of the <code>headers</code>
attribute, have bodies <code>size</code> bytes long, and have
<code>mime</code> MIME parts. To generate text/plain messages, set
<code>mime</code> to zero.
<table border=1 cellpadding=2>
<tr><th>Attribute</th><th>Description</th></tr>
<tr>
<td><code>headers <i>N</i></code></td>
<td>(optional; default=5) Each automatically generated message will
have <code>min(<i>N</i>, min_hdrs)</code> headers, where
<code>min_hdrs</code> is 5 for text/plain, and about 7 for MIME
messages. Additional headers are named
"X-generated-header-%d". </td>
</tr>
<tr>
<td><code>size <i>N</i></code></td>
<td>(required) Each generated message will have a body be <i>N</i>
bytes long.</td>
</tr>
<tr>
<td><code>mime <i>N</i></code></td>
<td>Each generated message will have <code>N</code> MIME parts. If
the value of <code>size</code> does not allow <code>N</code> parts,
one part is generated. If <code>N</code> is zero, the message is
text/plain.</td>
</tr>
<tr>
<td><code>checksum <i>{yes|no|save}</i></code></td>
<td>For SMTP: each generated message will have the MD5 sum of the
message body appended to the message unless the value is <i>no</i>.
For retrieval protocols, checksums will be verified. (NOT
IMPLEMENTED: if <code>checksum</code> is <i>save</i>, messages with
incorrect checksums will be saved to temporary files for later
examination.) </td>
</tr>
</table>
<li><h4>Linespeed Emulation</h4>
SMTP, POP, and IMAP all support a form of linespeed emulation,
controlled via the <code>latency</code> and <code>bandwidth</code>
parameters.
<table border=1 cellpadding=2>
<tr><th>Attribute</th><th>Description</th></tr>
<tr><td><code>latency <i>N</i></code></td>
<td>Set the network latency to <code>N</code> milliseconds.</td></tr>
<tr><td><code>bandwidth <i>N</i></code></td>
<td>Transfer at most <code>N</code> bytes per second.</td></tr>
</table>
<li><h4>TLS support</h4>
If you have openssl, mstone now supports STARTTLS for SMTP and IMAP,
and STLS for POP (both old-style and MULTIPOP), as well as SSL
tunneling. This support is <strong>not</strong> well-tested, and TLS
can be a bit tricky to set up, so use at your own risk. TLS
introduces several new attributes to the protocol blocks:
<table border=1 cellpadding=2>
<tr><th>Attribute</th><th>Description</th></tr>
<tr><td><code>sslcert <i>filename</i></code></td>
<td>Read the client's cert from <i>filename</i>, which should be in
PEM format. </td></tr>
<tr><td><code>sslkey <i>filename</i></code></td>
<td>Read the client's private key from <i>filename</i>, which should
be in PEM format.</td></tr>
<tr><td><code>usetls {0|1}</code></td>
<td>Turn STARTTLS/STLS on or off (default: off). <b>Note</b>:
<code>starttls</code> and <code>ssltunnel</code> are mutually
exlcusive.</td></tr>
<tr><td><code>ssltunnel {0|1}</code></td>
<td>Turn SSL tunneling on or off (default: off).</td></tr>
</table>
<li><h4>"Multi-POP" protocol</h4>
<b>Note</b>: multipop, always a band-aid, is hopefully obsoleted by
the new event-queue execution model. Though it has not been tested,
it should be easier, more efficient, and more accurate to use the
normal POP protocol with events to simulate a large number of users
with a reasonable number of threads. Once this has been tested,
automatically-generated workloads should revert to using POP.
<p>To simulate a large number of concurrently active POP users with
Mstone's extravagant use of threads, and to simulate a period of
activity comprised of several POP sessions one can use the MULTIPOP
protocol to multiplex active users onto a single thread. The protocol
has all the same parameters as POP, plus the following:
<table border=1 cellpadding=2>
<tr><th>Attribute</th><th>Description</th></tr>
<tr><td><code>userSpacing</code></td>
<td>Total time for each user's session.</td>
</tr>
<tr><td><code>usersPerModem</code></td>
<td>The maximum number of concurrently connected users is limited
to <code>users / usersPerModem</code></td>
</tr>
</table>
<p>
The protocol functions are substantially different. Instead of
simulating a single login-check-logout sequence, a protocol block
simulates an entire active period for a set of users. Each user
checks mail once in the initialization function, once each time the
loop body is executed, and once more in the protocol conclusion
function.
<p>
<li><h4>"Event-queue" implementation</h4>
<p>
Unless the "noevents" parameter in the "&lt;config&gt;" section is set to 1,
or mailclient is not given the "-e" flag, mstone will run in
"event-queue" mode. Instead of creating one thread per client, it
will multiplex clients over a much smaller number of threads. This is
intended to increase the tool's scalability.
<p>
Note that I/O is still synchronous with this model, so the number of
threads required will approximately equal the maximum number of
concurrent operations. Also note that this change does not reduce the
number of required file descriptors.
<p>
<li><h4>Other Minor Additions</h4>
<ul>
<li>IMAP now has a ramp-down time, enabled by defining
<code>IMAP_RAMPDOWN</code>. IMAP threads now exit uniformly between
the time the test is supposed to be over and the time Mstone starts
killing them.
<li>Mstone used to always time out connections after 60 seconds. The
timeout value can now be configured on a per-block basis via the
<code>timeout</code> parameter. The value of the timeout parameter must
be defined in milliseconds, so the following value would mean a timeout
of one (1) hour:<BR>
&nbsp;&nbsp;&nbsp;timeout 3600000
<li>Simplified client allocation. It is now possible to specify the
number of clients in each group by specifying a value for
<code>clients</code> in each <code>&lt;CLIENT&gt;</code> section and
<em>not</em> specifying a global <code>clientCount</code> in the
<code>&lt;CONFIG&gt;</code> section.
</ul>
<li><h4>Bug Fixes</h4>
<ul>
<li>SMTP now ignores debugging output appearing over the connection.
Before, Mstone would generate an error when talking to
e.g. <code>sendmail -d64.5</code>.
<li>(now it works...) The old sequence of IMAP commands used by
Mstone was incorrect. Instead of only downloading unread messages, it
would download all messages received since the start of the session
each time a new messages was received. Depending on what you were
doing, this could have a serious effect on your results.
</ul>
<li><h4>Wish List</h4>
<ul>
<li>Scriptable user behavior for POP and IMAP protocols. While we should
probably not go overboard, adding more configuration options to Mstone
is probably not the answer. There is already some support for more
complex behaviors in the IMAP code -- we may or may not want to make
use of it. More to the point, wider coverage of the IMAP
protocol is vital to QA's use of the tool.
</ul>
</ol>
</body></html>

View File

@@ -1,189 +0,0 @@
Mstone TODO List
Updated:
3-20-2000 Dan Christian
======================================================================
Minor improvements
Data reduction at each testbed client
Test message generator (plain and MIME styles)
More graphs for multiple runs
Option to drop a fraction of connections
IMAP delete without reading
Just get the message list and delete everything. This could
be the fastest way to drain out the store.
Display MIN/MAX or standard deviation on graphs
Gnuplot can do data points with error bars. You could either
use MIN/MAX or the standard deviation for the error bars. There are
issues with calculating the standard deviation numbers throughout the
graph that need to be addressed.
Statistics reset
At least the MIN and MAX statistics could be easily reset
during the test (after ramp up). This keeps the transients during
startup and shutdown from dominating these numbers. The standard
deviation statistics are much trickier to reset during the run. It
may be better to isolate sections in post processing.
Perl web server
Sometimes it would be nice to include our own web server to
provide the results (instead of using file: URLs). This would also be
a gateway to form based test configuration editing and allow results
to be interactively updated during tests. Perl with a socket library
could handle this without too much trouble.
Dynamic test loading
Finalize an API for dynamically loading tests. This would
allow tests to be added or updated separately from the core
functionality. This may be needed for some types of security testing.
Link graphs to the results tables
There are already tags by each graph. You should be able to
link the appropriate results table entry to each graph. This sort of
tricky since graphs often combine multiple entries.
Show statistics for every block
Statistics are actually kept for every block in every thread.
There should be a way to view information at this detail.
Man pages
The online docs are nice, but good 'ol man pages would be
great in a different way.
Reduce namespace polution
Scripts names like setup and cleanup are too general. They
should be part of the main 'mstone' script (e.g. mstone setup).
Examples of script series
Include example scripts to run entire series of tests in a
sane way.
Fix FORMAT clash
At the start of a test, each client process outputs the
information needed to report all its protocols. When there are
multiple processes on one client, these FORMAT lines can intermix and
cause parsing errors.
Set connection drop rate
Drop some percentage of the connections without a proper
shutdown. This tests how well a server can detect and recover from
hard disconnects.
Improve randomness
The way that we generate random numbers in a range may be not
generate the proper randomness. We are using lrand48()%range we
should use (lrand48/RAND_RANGE)*range. There are some end conditions
that need to be thought about. All of this is in the sequence code;
one change should fix (or break :) everything.
Also, we may be generating numbers that are never used. This
may be costly, and can create holes in the proper sequence.
Improve printing
The color graphs are great on screen, but tend to print
poorly. Either we need a better way to generate a printable version
(maybe through a CGI button), or the seperate protocols need to be
printed individually. Also, Communicator does a lousy job of keeping
title with tables or graphs. Hopefully, Mozilla will do better.
======================================================================
Whole new protocol tests:
ICQ
Test high volume instant messaging. Very useful for the
bridges and gateways that people are considering using.
WAP
WAP is the emerging standard for mobile phones.
WCAP
Web based calendar services
LDAP
Use the LDAP SDK to do basic LDAP testing. The SDK probably
isn't fast enough to call this a real performance test, but you can at
least test performance degredation due to load from a real application
(like a mail server).
DNS
Mail servers use DNS a lot. You should at least be able to
see if performance is degrading due to load.
Disk/filesystem
Test read, write, sync, link, un-link, and append performance under
multiple threads.
Cert servers
Test certificate authenticity checking performance
======================================================================
Possible dummy servers:
SMTP
Receive mail via SMTP and ignore it. Usefull for SMTP relay
testing.
DNS
Simulate slow DNS server lookups. Usefull for SMTP relay testing.
======================================================================
Major changes
Throttling
Monitor and control transaction rates so that specific load
levels can be easily specified. The rates should be able to vary to
simulate peek hour usage and disconnect-restore.
NSPR threading
Use NSPR for threading and sockets. This may allow other OSes
to be used as clients. This might be easy, since mstone does not need
any locking, just simple thread creation and harvesting. NSPR
argument parsing and hashes may also be useful.
SSL
Support SSL on the protocols that allow it. May require NSPR.
Line speed emulation
Simulate the variable delays and limited throughput of dial up
connections.
Scripting
Allow more detailed control of protocol tests. It looks
difficult to make this scalable and fast.
Combined tests
Deliver mail over SMTP and then see when it arrives using IMAP.

View File

@@ -1,462 +0,0 @@
#!/bin/ksh
########################################################################
# buildall - automated multi-platform build tool
#
# 10/09/97 - marcel - created
# 10/13/97 - marcel - support shared build tree
# 2/11/98 - marcel - updated for 4.0 Beta builds (need -update)
# 2/26/98 - marcel - added -r, -t and host specifiers
# 7/01/99 - robodan - added VAR=value ability
# 8/01/99 - robodan - explicitly know about building on localhost
# 10/15/99 - robodan - remove older OSes from build list
# 2000/4/7 - robodan - Created mstone version
########################################################################
#
# This script is intended to do a set of UNIX builds for a
# given CVS module. It is designed to use 'rsh' between a
# set of trusting hosts and use shared NFS storage with common
# mount points (e.g. /u/username/...)
#
# To check if you have rights to rsh to a particular host, try:
# rsh hostname "echo $PATH"
# You may have to edit your .rhosts or /etc/hosts.equiv
#
# A target directory will be created based on the current date.
#
# A set of global build logs plus a log per platform are kept
# in a log directory under the target
#
# It will checkout a copy of the source, duplicate it for
# each platform and perform a set of remote builds in parallel.
# The script will exit when all the work has been completed.
#
# Example usage:
# cd ~/src; buildall msg
# Result:
# ~/src/19980210_40.1/
# ~/src/19980210_40.1/logs/...
# ~/src/19980210_40.1/src/...
# ...
#
# Buildhosts
DEFAULT_BUILDHOSTS="kimo nugget vsync shave purgatory trex0"
usage() {
echo ""
echo "usage: buildall [ make assigns... ] < -t | target > [ -r ] [ buildhosts... ]"
echo " [ -t | --test]: just test rsh and report OS versions."
echo " [-r | --respin]: rebuild in place using existing source."
echo " [-p | --postbuild]: Execute post build command too."
echo " [make assigns]: e.g. VARIANT=release"
echo " <target>: one of: mstone42"
echo " [buildhosts...]: default [$DEFAULT_BUILDHOSTS]"
echo ""
exit 1
}
########################################################################
# Set these defaults and options for your desired build
########################################################################
# Target base destination directory
DESTBASE=`pwd`
# Can we do multiple ARCH builds in same source tree
SHARESRC=yes
DESCRIPTION=""
BUILDHOSTS=""
RESPIN="no"
POSTBUILD="no"
JUST_TEST="no"
DESTTYPE=""
CO_CMD="cvs -d $CVSROOT -q checkout"
CHECKOUT=""
CHECKOUT2=""
#MOZCVSROOT=':pserver:anonymous@cvs.mozilla.org:/cvsroot'
MOZCVSROOT=':pserver:robodan%netscape.com@cvs.mozilla.org:/cvsroot'
MAKE="gmake"
MK_ARG=""
ARGS="$@"
for ARG in "$@"; do
# If this is a make assignment (FOO=whatever), add it to make command
# Arguments with quotes in them dont go all the way through.
# Make args trick: 'FOO=nop -j 2'
# The pre-post arg stuff uses hostnames as a switch, ugly calling syntax.
if [[ -n "`echo z$ARG | egrep '^z[A-Z0-9_]+=[^ ]'`" ]] ; then
if [[ -n "$DESCRIPTION" ]] ; then
echo "Arg after target is ignored! ($ARG)"
continue
fi
if [[ -z "$BUILDHOSTS" ]] ; then # pre args
MAKE="$MAKE $ARG"
else # post args
MK_ARG="$MK_ARG $ARG"
fi
continue
fi
# should we just rebuild todays latest source...
if [[ "$ARG" = "-r" || "$ARG" = "--respin" || "$ARG" = "respin" ]]; then
RESPIN="yes"
continue
fi
# should we just run post build command...
if [[ "$ARG" = "-p" || "$ARG" = "--postbuild" || "$ARG" = "postbuild" ]]; then
POSTBUILD="yes"
continue
fi
# should we just test remote connectivity and execute permissions...
if [[ "$ARG" = "-t" || "$ARG" = "--test" ]]; then
JUST_TEST="yes"
RESPIN="yes"
continue
fi
# We will pull source using: "$CHECKOUT"
# And build on each machine: "cd $BUILDDIR && $BUILDCMD"
# expand targets (but dont confuse hosts for targets (msg7))
# These will build just mstone
# expand targets (but dont confuse hosts for targets (msg7))
if [[ "$BUILDCMD" = "" && "$ARG" = mailstone* ]]; then
case ${ARG#mstone} in
"")
"42")
DESTTYPE=_MSTONE42
MS_BRANCH=""
#BUILDCMD="$MAKE $MK_ARG debug release"
#POSTCMD="$MAKE $MK_ARG all_DBG.OBJ all_OPT.OBJ"
BUILDCMD="$MAKE $MK_ARG rpackage"
POSTCMD="$MAKE $MK_ARG all_OPT"
;;
*)
echo "Unknown mstone version in $ARG"
echo "Try mstone42"
exit 1;;
esac
DESCRIPTION="Mstone $MS_BRANCH"
BUILDDIR=./mozilla/mstone
CVSROOT=$MOZCVSROOT
CHECKOUT="$CO_CMD $MS_BRANCH mozilla/mstone"
# BUG No way to unpack perl, gd, and gnuplot before building
continue
fi
#########################
# Other...
#########################
# These will print some tools info
if [[ "$ARG" = "tools" ]]; then
CHECKOUT="$CO_CMD modules"
BUILDDIR=.
BUILDCMD="which gcc && ls -l /tools/ns/bin/gcc && which gcc-2.7.2.1 && ls -l /tools/ns/bin/gcc-2.7.2.1"
continue
fi
#########################
# Everything else is assumed to be a hostname
#########################
BUILDHOSTS="$ARG $BUILDHOSTS"
done # for ARG in $*; do
if [[ "$BUILDHOSTS" = "" ]]; then
BUILDHOSTS=$DEFAULT_BUILDHOSTS
fi
if [[ "$BUILDCMD" = "" && "$JUST_TEST" = "no" ]]; then
usage
fi
########################################################################
# You shouldn't have to modify stuff below here too much
########################################################################
# Who and Where are we
PROG=buildall
RSH=rsh
SYS=`uname -s`
echo SYS=$SYS
if [[ "$SYS" = "HP-UX" ]]; then
RSH=remsh
fi
########################################################################
# Simple log output function
########################################################################
log() {
# echo "[`date +\"%Y/%m/%d %H:%M:%S\"`] $PROG: $*"
echo "`date +\"%H:%M:%S\"` $PROG: $*"
}
########################################################################
# Error
########################################################################
quit() {
log "$* (exiting)..."
exit 1
}
# Where should the work be done
REV=1
WORKDIR=$DESTBASE/`date +"%Y%m%d"`$DESTTYPE.$REV
LASTWORKDIR=$WORKDIR
LASTREV=$REV
while [[ -d $WORKDIR ]]; do
LASTREV=$REV
let "REV= REV + 1"
LASTWORKDIR=$WORKDIR
WORKDIR=$DESTBASE/`date +"%Y%m%d"`$DESTTYPE.$REV
done
if [[ "$RESPIN" = "yes" ]]; then
WORKDIR=$LASTWORKDIR
REV=$LASTREV
fi
BUILDREV=$REV
if [[ ! -d $WORKDIR && "$RESPIN" = "yes" ]]; then
quit "missing expected respin workdir ($WORKDIR)"
fi
mkdir -p $WORKDIR
# Where to send logs
LOGDIR=$WORKDIR/logs
[[ -d $LOGDIR ]] || mkdir $LOGDIR
# What tool to use for compressed tar
if [[ -x /tools/ns/bin/tar ]] ; then # ROBDAN 9-15-98 for Linux
TAR=/tools/ns/bin/tar
else
TAR=tar
fi
SRCDIR=$WORKDIR/src
SRCTAR=$WORKDIR/src.tar.gz
########################################################################
# The function which extracts the source and prepares for copies
########################################################################
prepare_source() {
log "Preparing source code..."
mkdir $SRCDIR
(cd $SRCDIR;
log "Extracting source in $SRCDIR...";
log "$CHECKOUT > $LOGDIR/cvs-co.txt";
$CHECKOUT > $LOGDIR/cvs-co.txt;
RET=$?
if [[ $RET -ne 0 ]]; then quit "### Failed($RET): $CHECKOUT"; fi
if [[ "$CHECKOUT2" != "" ]]; then
log "$CHECKOUT2 >> $LOGDIR/cvs-co.txt";
$CHECKOUT2 >> $LOGDIR/cvs-co.txt;
RET=$?
if [[ $RET -ne 0 ]]; then quit "### Failed($RET): $CHECKOUT2"; fi
fi
log "Listing source...";
ls -Rl > $LOGDIR/src-ls-Rl.txt
log "Archiving source..."
$TAR czf $SRCTAR .
)
RET=$?
if [[ $RET -ne 0 ]]; then
quit "### Failed($RET): cannot prepare source";
else
log "Source extraction complete";
fi
}
########################################################################
# The function which does a build
########################################################################
do_rbuild() {
OSDEST=$1
if [ "$SHARESRC" = "yes" ]; then
RSRCDIR=$SRCDIR
else
RSRCDIR=$WORKDIR/$OSDEST
fi
[[ -d $RSRCDIR ]] || mkdir -p $RSRCDIR
cd $RSRCDIR;
# do any late variable expansions
RAWCMD=$BUILDCMD
BUILDCMD=$(eval echo $RAWCMD)
if [[ $RHOST = localhost ]] ; then
log "Build locally for $OSDEST ($BUILDCMD)...";
cd $BUILDDIR && pwd && $BUILDCMD && echo $PROG: Success
RET=$?
if [[ $RET -ne 0 ]]; then quit "### Failed($RET): $OSDEST build"; fi
log "Completed local build..."
return
fi
if [[ "$SHARESRC" != "yes" ]]; then
log "Extracting source for $OSDEST...";
$RSH $RHOST -n "cd $RSRCDIR && pwd && $TAR xzf $SRCTAR";
RET=$?
if [[ $RET -ne 0 ]]; then quit "### Failed($RET): $OSDEST source extraction"; fi
else
log "Using common source in $RSRCDIR";
fi
log "Building for $OSDEST ($BUILDCMD)...";
$RSH $RHOST -n "cd $RSRCDIR/$BUILDDIR && pwd && $BUILDCMD && echo $PROG: Success"
RET=$?
if [[ $RET -ne 0 ]]; then quit "### Failed($RET): $OSDEST build"; fi
log "Completed $OSDEST...";
}
buildhost() {
RHOST=$1
log "Query $RHOST configuration...";
if [[ $RHOST = localhost ]] ; then
uname -s > /tmp/$$.$RHOST 2>&1
else
$RSH $RHOST -n "uname -s" > /tmp/$$.$RHOST 2>&1
RET=$?
if [[ $RET -ne 0 ]]; then
quit "..[$RHOST] ### Failed($RET): $RSH $RHOST -n \"uname -s\"";
fi
fi
ROSTYPE=`tail -1 /tmp/$$.$RHOST`
if [[ "$ROSTYPE" = "AIX" ]]; then
$RSH $RHOST -n "uname -v" > /tmp/$$.$RHOST 2>&1
ROSTYPE=${ROSTYPE}`tail -1 /tmp/$$.$RHOST`
fi
if [[ $RHOST = localhost ]] ; then
uname -r > /tmp/$$.$RHOST 2>&1
else
$RSH $RHOST -n "uname -r" > /tmp/$$.$RHOST 2>&1
fi
ROSREV=`tail -1 /tmp/$$.$RHOST`
rm /tmp/$$.$RHOST
if [[ $RHOST = localhost ]] ; then
OSDEST=`hostname | cut -f1 -d.`-${ROSTYPE}${ROSREV}
else
OSDEST=${RHOST}-${ROSTYPE}${ROSREV}
fi
log "..Building on [$OSDEST]..."
REV=1 # find unique logfile name
OSLOG=$LOGDIR/$OSDEST.$REV
while [[ -f $OSLOG ]]; do
let "REV = REV + 1"
OSLOG=$LOGDIR/$OSDEST.$REV
done
if [[ "$JUST_TEST" = "yes" ]]; then
echo "$PROG: Success" > $OSLOG
else
( do_rbuild $OSDEST ) > $OSLOG 2>&1
fi
grep "$PROG: Success" $OSLOG > /dev/null
RET=$?
if [[ $RET -eq 0 ]]; then
RESULT="SUCCESS";
else
RESULT="FAILURE($RET)";
fi
log "..Completed [$OSDEST] <$RESULT>.";
}
########################################################################
# The function which initiates all the builds
########################################################################
do_builds() {
log "Launching builds..."
for HOST in $BUILDHOSTS; do
buildhost $HOST &
done
}
########################################################################
# main
########################################################################
main() {
if [[ "$JUST_TEST" = "yes" ]]; then
log "Automated test starting..."
else
log "Automated build of [$DESCRIPTION] starting..."
fi
log ""
log " ARGS = $ARGS"
log " BUILDHOSTS = $BUILDHOSTS"
log " WORKDIR = $WORKDIR"
log " SRCDIR = $SRCDIR"
log " LOGDIR = $LOGDIR"
log " CHECKOUT = $CHECKOUT"
log " BUILDDIR = $BUILDDIR"
log " BUILDCMD = $BUILDCMD"
log " RESPIN = $RESPIN"
log ""
[[ "$RESPIN" = "no" ]] && prepare_source
do_builds
log "Waiting for all builds to complete..."
wait
log "All builds completed."
if [[ -n "$POSTCMD" && "$POSTBUILD" = "yes" ]] ; then
log "Running post build command."
REV=1 # find unique logfile name
POSTLOG=$LOGDIR/postbuild.$REV
while [[ -f $POSTLOG ]]; do
let "REV = REV + 1"
POSTLOG=$LOGDIR/postbuild.$REV
done
echo "Dir $SRCDIR/$BUILDDIR" > $POSTLOG
echo "Cmd $POSTCMD" >> $POSTLOG
(cd $SRCDIR/$BUILDDIR && $POSTCMD && echo $PROG: Success) >> $POSTLOG 2>&1
log "Post build command completed."
elif [[ -n "$POSTCMD" ]] ; then
echo "Skipping post build command: $POSTCMD"
fi
}
REV=1
PROGLOG=$LOGDIR/$PROG.$REV
while [[ -f $PROGLOG ]]; do
REV=`expr $REV + 1`
PROGLOG=$LOGDIR/$PROG.$REV
done
main | tee $PROGLOG 2>&1
exit 0

View File

@@ -1,164 +0,0 @@
@if not "%echo%" == "on" echo off
REM ************ simple autobuild for mailstone
setlocal
set BOTH=0
if not "%1" == "" goto GetTag
set BOTH=1
set TAG=_OPT
goto SetConfig
:GetTag
if %1 == dbg set TAG=_DBG
if %1 == DBG set TAG=_DBG
if %1 == Debug set TAG=_DBG
if %1 == debug set TAG=_DBG
if %1 == Release set TAG=_OPT
if %1 == release set TAG=_OPT
if %1 == opt set TAG=_OPT
if %1 == OPT set TAG=_OPT
if %1 == optimize set TAG=_OPT
if %1 == Optimize set TAG=_OPT
if %1 == optimized set TAG=_OPT
if %1 == Optimized set TAG=_OPT
if %1 == clean goto CleanBoth
:SetConfig
if %TAG% == _DBG set Config=Debug
if %TAG% == _OPT set Config=Release
set ARCH=WINNT4.0%TAG%.OBJ
set FINAL_PATH=built\package\%ARCH%\mailstone
if not "%2" == "clean" if not exist %FINAL_PATH%\nul mkdir %FINAL_PATH%
REM ************ first, clean the binary release
nmake /f mailstone.mak CFG="mailstone - Win32 %Config%" /nologo NO_EXTERNAL_DEPS=1 CLEAN
if not "%2" == "clean" goto BuildMailstone
if exist src\%Config%\nul echo y | rd /s src\%Config% > nul
if exist src\gnuplot-3.7\%Config%\nul echo y | rd /s src\gnuplot-3.7\%Config% > nul
if exist src\gd1.3\%Config%\nul echo y | rd /s src\gd1.3\%Config% > nul
if exist built\%ARCH%\nul echo y | rd /s built\%ARCH% > nul
if exist %FINAL_PATH%\nul echo y | rd /s %FINAL_PATH% > nul
goto done
:BuildMailstone
REM **************** next, build it
nmake /f mailstone.mak CFG="mailstone - Win32 %Config%" /nologo NO_EXTERNAL_DEPS=1
if errorlevel 1 goto BadBuild
REM ************ next, copy the top-level files
copy mstone.bat %FINAL_PATH%
copy setup.bat %FINAL_PATH%
copy CHANGELOG %FINAL_PATH%
copy INSTALL %FINAL_PATH%
copy README %FINAL_PATH%
copy LICENSE %FINAL_PATH%
REM ************ now, copy the files for running mailstone into bin
if not exist %FINAL_PATH%\bin\nul mkdir %FINAL_PATH%\bin
copy built\%ARCH%\mailclient.exe %FINAL_PATH%\bin
if exist built\package\%ARCH%\mailclient.exe copy built\package\%ARCH%\mailclient.exe %FINAL_PATH%\bin
if exist built\package\%ARCH%\mailclient.exe del /f /q built\package\%ARCH%\mailclient.exe
copy bin\*.pl %FINAL_PATH%\bin
REM ************ now, copy the configuration files into conf
if not exist %FINAL_PATH%\conf\nul mkdir %FINAL_PATH%\conf
copy conf\*.* %FINAL_PATH%\conf
REM ************ now, copy the data files into data
if not exist %FINAL_PATH%\data\nul mkdir %FINAL_PATH%\data
copy data\*.msg %FINAL_PATH%\data
REM ************ now, copy the gd files into gd
if not exist %FINAL_PATH%\gd\nul mkdir %FINAL_PATH%\gd
copy src\gd1.3\index.html %FINAL_PATH%\gd\gd.html
REM ************ now, copy the gnuplot files into gnuplot
if not exist %FINAL_PATH%\gnuplot\nul mkdir %FINAL_PATH%\gnuplot
copy built\%ARCH%\gnuplot\gnuplot.exe %FINAL_PATH%\gnuplot
copy src\gnuplot-3.7\Copyright %FINAL_PATH%\gnuplot
copy src\gnuplot-3.7\docs\gnuplot.1 %FINAL_PATH%\gnuplot
REM ************ now, copy the perl files into perl
if not exist %FINAL_PATH%\perl\nul mkdir %FINAL_PATH%\perl
if not exist %FINAL_PATH%\perl\bin\nul mkdir %FINAL_PATH%\perl\bin
if not exist %FINAL_PATH%\perl\lib\nul mkdir %FINAL_PATH%\perl\lib
if not exist %FINAL_PATH%\perl\lib\5.00503\nul mkdir %FINAL_PATH%\perl\lib\5.00503
if not exist %FINAL_PATH%\perl\lib\5.00503\MSWin32-x86\nul mkdir %FINAL_PATH%\perl\lib\5.00503\MSWin32-x86
#copy built\%ARCH%\perl\perl.exe %FINAL_PATH%\perl\bin
#rcp -b sandpit:/share/builds/components/perl5/WINNT-perl5/perl.exe %FINAL_PATH%\perl\bin\perl.exe
#if errorlevel 1 goto BadRcp
#if not exist %FINAL_PATH%\perl\perl.exe goto BadRcp
#rcp -b sandpit:/share/builds/components/perl5/WINNT-perl5/perl300.dll %FINAL_PATH%\perl\bin\perl300.dll
#if errorlevel 1 goto BadRcp
#if not exist %FINAL_PATH%\perl\perl300.dll goto BadRcp
copy src\perl5.005_03\Artistic %FINAL_PATH%\perl
copy c:\perl\5.00503\bin\MSWin32-x86\perl.exe %FINAL_PATH%\perl\bin
copy c:\perl\5.00503\bin\MSWin32-x86\perl.dll %FINAL_PATH%\perl\bin
copy c:\perl\5.00503\lib\*.pm %FINAL_PATH%\perl\lib\5.00503
copy c:\perl\5.00503\lib\*.pl %FINAL_PATH%\perl\lib\5.00503
copy c:\perl\5.00503\lib\MSWin32-x86\*.pm %FINAL_PATH%\perl\lib\5.00503\MSWin32-x86
goto end
:CleanBoth
echo.
echo NOTICE: CLEANING debug build
call autobuild.bat debug clean
echo NOTICE: CLEANING optimized build
call autobuild.bat release clean
echo NOTICE: Removing generated dependency files
del /s *.dep
if exist built\nul echo y | rd /s built > nul
goto done
:BadRcp
echo.
echo ERROR: Failed to rcp perl files over to mailstone packaging
echo ERROR: Two common causes of this are .rhosts permissions or a broken rcp.exe
echo ERROR: Make sure you are not using rcp.exe from NT4.0 SP4
echo ERROR: The SP5 version is available in \\cobra\engineering\bin\rcp_sp5.exe
echo ERROR: Use this version to replace ...\system32\rcp.exe
goto done
:BadBuild
echo.
echo ERROR: Failed to build mailstone
goto done
:end
echo.
if %BOTH% == 0 goto done
if %TAG% == _DBG goto done
set TAG=_DBG
goto SetConfig
:done
endlocal

View File

@@ -1,64 +0,0 @@
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Netscape Mailstone utility,
# released March 17, 2000.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1997-2000 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Dan Christian <robodan@netscape.com>
# Marcel DePaolis <marcel@netcape.com>
#
# Alternatively, the contents of this file may be used under the
# terms of the GNU Public License (the "GPL"), in which case the
# provisions of the GPL are applicable instead of those above.
# If you wish to allow use of your version of this file only
# under the terms of the GPL and not to allow others to use your
# version of this file under the NPL, indicate your decision by
# deleting the provisions above and replace them with the notice
# and other provisions required by the GPL. If you do not delete
# the provisions above, a recipient may use your version of this
# file under either the NPL or the GPL.
#####################################################
# This file does argument processing, file IO, and other utility routines
# Where the online docs live
#$mailstoneURL =
# "http://home.netscape.com/eng/server/messaging/4.1/mailston/stone.htm";
#$mailstoneURL =
# "http://lxr.mozilla.org/mozilla/source/mstone/doc/MailStone.html";
#$mailstoneURL =
# "http://docs.iplanet.com/docs/manuals/messaging/nms415/mailstone/stone.htm"
$mailstoneURL = "doc/MailStone.html";
# Subdirs for results (each under a timestamp dir). Should just hardwire.
$tmpbase = "tmp";
$resultbase = "results";
# This holds everything about the test and system configuration
@workload = ();
# Setup the special CONFIG section
$params{"sectionTitle"} = "CONFIG";
$params{"sectionParams"} = "";
$params{"lineList"} = ();
push @workload, \%params;
# Get the lists discribing the data we process
do 'protoconf.pl' || die "$@\n";
%includedFiles = (); # array of included files
do 'util.pl' || die "$@\n";
return 1;

View File

@@ -1,310 +0,0 @@
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Netscape Mailstone utility,
# released March 17, 2000.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1997-2000 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Dan Christian <robodan@netscape.com>
# Marcel DePaolis <marcel@netcape.com>
# Sean O'Rourke <sean@sendmail.com>
#
# Alternatively, the contents of this file may be used under the
# terms of the GNU Public License (the "GPL"), in which case the
# provisions of the GPL are applicable instead of those above.
# If you wish to allow use of your version of this file only
# under the terms of the GPL and not to allow others to use your
# version of this file under the NPL, indicate your decision by
# deleting the provisions above and replace them with the notice
# and other provisions required by the GPL. If you do not delete
# the provisions above, a recipient may use your version of this
# file under either the NPL or the GPL.
#####################################################
# This file deals with the graphs data only
# Interfaces to gnuplot to generate gifs for HTML inclusion.
do 'util.pl';
sub warn_system;
sub die_system;
# Type of images to hold plots (e.g. png, gif, jpeg, svg, tiff, pbm, etc)
unless ($params{IMAGETYPE}) {
# Should probe gnuplot and see if it can generate one of:
# png, gif, jpeg, svg, tiff, or pbm.
# Not all the programs that use args.pl need this (or have gnuplot, yet)
my $outfile = "$tmpbase/termtypes.out";
my %types = (); # hash of interesting types that we spot
unless (open(NEW, "<$outfile")) { # re-use old file if present
($params{DEBUG}) &&
print "Asking gnuplot what output types it supports\n";
# SEAN: this appears to do what they want:
warn_system "echo 'set term' | $params{GNUPLOT} > $outfile";
open(NEW, "<$outfile") ||
warn ": Could not open gnuplot output for parsing ($outfile): $!";
}
# now check through the output for terminal types we can use.
# I havent verified the jpeg or tiff types. e-mail me success or failure
while (<NEW>) {
(/\spng\s/) && ++$types{"png"} && next;
(/\sgif\s/) && ++$types{"gif"} && next;
(/\sjpeg\s/) && ++$types{"jpeg"} && next;
(/\ssvg\s/) && ++$types{"svg"} && next;
(/\stiff\s/) && ++$types{"tiff"} && next;
(/\spbm\s/) && ++$types{"pbm"} && next;
}
close (NEW);
($params{DEBUG}) &&
print "Found these gnuplot types: " . (join " ", (keys %types)) . "\n";
# The ordering here determines our preferences
# This list is by likely browser compatibility and image compactness
# png is about 10x smaller than gif
# svg is smooth and scalable but usually requires a plug-in
# jpeg will probably look bad, but will be directly supported
if ($types{"png"}) { $params{IMAGETYPE}="png"; }
elsif ($types{"gif"}) { $params{IMAGETYPE}="gif"; }
elsif ($types{"jpeg"}) { $params{IMAGETYPE}="jpeg"; }
elsif ($types{"svg"}) { $params{IMAGETYPE}="svg"; }
elsif ($types{"tiff"}) { $params{IMAGETYPE}="tiff"; }
elsif ($types{"pbm"}) { $params{IMAGETYPE}="pbm"; }
else {
warn "Gnuplot doesn't support any good image types. Check $outfile.\n";
$params{IMAGETYPE} = undef;
}
# leave the output file around to speed up repeat runs
}
# sub function to write data files, fire off gnuscript, and clean up
# Uses global startTime and endTime figured above
# genPlot counterName title label \@protocols \@variables
sub genPlot {
my $name = shift;
my $title = shift;
my $label = shift;
my $protos = shift || die "genPlot: '$name' missing protocols";
my $f = shift;
my $vars = shift || die "genPlot: '$name' missing vars";
my $runlist = "";
my $totPoints = 0;
my $totProtos = 0;
my @realProtos;
my @goodProtos;
# user fewer data points than pixels to look good.
# on 640x480 gif, the graph is about 579x408
my $maxData = int (($params{CHARTWIDTH}-60) * 0.9);
my $averageCnt = int (($endTime - $startTime + ($maxData - 1))/$maxData);
if ($averageCnt < 1) { $averageCnt = 1; } # must be a positive int
($params{DEBUG}) && print "$name: averageCnt=$averageCnt vars = @$vars \n";
foreach $p (@$protos) { # First see if there is anything to graph
($p =~ /^Total$/o) && next; # derived if needed
my $pPoints = 0;
my $gp = $graphs{$p};
ALLVAR: foreach $vm (@$vars) {
my $vp = ($f) ? $gp->{$vm}->{$f} : $gp->{$vm};
unless (($vp) && (scalar %$vp)) {
#print "genplot Checking: $p $vm $f => NO\n";
next;
}
#print "genplot Checking: $p $vm $f => ";
foreach $time (keys %$vp) {
next unless ($vp->{$time} != 0);
$totPoints++;
$pPoints++;
#print "VALUES\n";
last ALLVAR;
}
#print "nothing\n"
}
if ($pPoints > 0) { # count how many protocols have non 0
$totProtos++;
push @goodProtos, $p;
}
}
($params{DEBUG}) && print "\tprotocols: @goodProtos\n";
if ($totPoints == 0) { # nothing in any protocol
print "No data for graph '$name', variables '@$vars'\n";
return 0;
}
foreach $p (@$protos) {
unlink ("$tmpdir/$name.$p"); # remove any previous runs
(($p =~ /^Total$/o) && ($totProtos <= 1))
&& next; # skip Totally if only 1 protocol plus total
($p !~ /^Total$/o) && push @realProtos, $p; # everything but Total
# if ($p =~ /^Total$/o) { # move from last to first
# $runlist = "\'$name.$p\' with lines, " . $runlist;
# next;
# }
$runlist .= ", " if ($runlist); # later ones
$runlist .= "\'$name.$p\' with lines";
}
$totPoints = 0;
foreach $p (@realProtos) { # create the plot data files
open(DATA, ">$tmpdir/$name.$p") ||
die "Can't open $tmpdir/$name.$p:$!";
my $gp = $graphs{$p};
my $n = 0;
my $s = 0.0;
my $sTime = 0.0;
my $vp = ($f) ? $gp->{$vars->[0]}->{$f} : $gp->{$vars->[0]};
# foreach $time (sort numeric keys %$vp) {
for (my $tm = $startTime; $tm <= $endTime; $tm++) {
my $v = 0.0;
foreach $vm (@$vars) {
$vp = ($f) ? $gp->{$vm}->{$f} : $gp->{$vm};
$totPoints++;
# due to optimization in updateDelta,
# 0 entries are undefined (also avoids warning)
$v += ($vp->{$tm}) ? $vp->{$tm} : 0;
# if ($vp->{$tm} < 0) {
# print $name, ": proto=", $p, " var=", $vm,
# " value=", $vp->{$tm}, "\n";
# }
}
$s += $v;
$n += 1;
if ($n == 1) { # NOTE: shifts left in sliding window
$sTime = $tm-$startTime;
}
if ($n >= $averageCnt) {
printf (DATA "%d %f\n", $sTime * $timeStep, $s/$n);
$n = 0;
$s = 0.0;
}
}
if ($n > 0) { # handle end case
printf (DATA "%d %f\n", $sTime * $timeStep, $s/$n);
}
close(DATA);
}
#($params{DEBUG}) && print "\tpoints: $totPoints\n";
# need to handle "Total" case
# read the other files and write out the sum
# FIX: total my be mis-aligned with data
if (($#$protos > $#realProtos) && ($totProtos > 1)) {
unlink ("$tmpdir/$name.Total");
open(DATA, ">$tmpdir/$name.Total") ||
die "Can't open $tmpdir/$name.Total:$!";
foreach $r (@goodProtos) { # get file handles
open($r, "$tmpdir/$name.$r")
|| die "Couldn't open $tmpdir/$name.$r: $!";
}
# ASSUMES files are identical in order
my $first = shift @goodProtos;
# print "First protocol: $first Rest: @realProtos\n";
while (<$first>) {
my ($t, $s) = split ' ', $_;
foreach $r (@goodProtos) { # get file handles
$l = <$r>;
if ($l) {
my ($tt, $v) = split ' ', $l;
$t = $tt unless ($t); # in case first proto missing time
$s += $v;
}
}
printf (DATA "%d %f\n", $t, $s);
}
foreach $r (@goodProtos) { close($r); }
close (DATA);
}
# SEAN: don't even try if we aren't generating images:
return 0 unless $params{IMAGETYPE};
# Create a script to feed to gnuplot, which creates a .gif graph.
$runTime = ($endTime - $startTime + 1) * $timeStep;
unlink("$tmpdir/$name.gpt");
open(SCRIPT, ">$tmpdir/$name.gpt")
|| die "Can't open $tmpdir/$name.gpt:$!";
$gnuplot = $params{GNUPLOT};
return 1 unless $gnuplot;
if ($gnuplot !~ /^\//) { # if not absolute, adjust for cd $tmpbase
$gnuplot = "../../$gnuplot"; # ASSUME $tmpbase is single dir
}
#print "gnuplot is $gnuplot $params{GNUPLOT}\n";
my $varstring = ""; # create display version of names
foreach $t (@$vars) {
$varstring .= ", " if ($varstring);
$varstring .= ($timerNames{$t}) ? $timerNames{$t} : $t;
}
# Setup output "terminal type"
if ($params{IMAGETYPE} eq "gif") { # gif type has different arguments
print SCRIPT "set terminal $params{IMAGETYPE} small size $params{CHARTWIDTH},$params{CHARTHEIGHT}\n";
} elsif ($params{IMAGETYPE} eq "svg") { # svg type has different args too
print SCRIPT "set terminal $params{IMAGETYPE} size $params{CHARTWIDTH} $params{CHARTHEIGHT}\n";
} else { # most types work like this
print SCRIPT "set terminal $params{IMAGETYPE} small color\n";
if (($params{CHARTWIDTH} != 640) || ($params{CHARTHEIGHT} != 480)) {
my $xscale = $params{CHARTWIDTH} / 640;
my $yscale = $params{CHARTHEIGHT} / 480;
print SCRIPT "set size $xscale,$yscale\n";
}
}
print SCRIPT<<"!GROK!THIS!";
set output "../../$resultdir/$name.$params{IMAGETYPE}" # ASSUME $tmpbase is single dir
set autoscale
set xlabel "Test time (seconds)"
set ylabel "$label"
set title "$title ($varstring) -- $params{TSTAMP}"
plot [0:$runTime] $runlist
!GROK!THIS!
close(SCRIPT);
# run script from tmpbase to clean up line labeling
# my $olddir=getcwd();
chdir $tmpdir;
warn_system (split (/\s/, $gnuplot), "$name.gpt");
chdir "../..";
# chdir $olddir;
unless ($params{DEBUG}) {
# cleanup the plot data (or leave around for debugging)
foreach $p (@$protos) {
unlink("$tmpdir/$name.$p");
}
unlink("$tmpdir/$name.gpt");
}
return 1;
}
return 1;

View File

@@ -1,629 +0,0 @@
#!/usr/bin/env perl
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Netscape Mailstone utility,
# released March 17, 2000.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1997-2000 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Dan Christian <robodan@netscape.com>
# Marcel DePaolis <marcel@netcape.com>
# Mike Blakely
#
# Alternatively, the contents of this file may be used under the
# terms of the GNU Public License (the "GPL"), in which case the
# provisions of the GPL are applicable instead of those above.
# If you wish to allow use of your version of this file only
# under the terms of the GPL and not to allow others to use your
# version of this file under the NPL, indicate your decision by
# deleting the provisions above and replace them with the notice
# and other provisions required by the GPL. If you do not delete
# the provisions above, a recipient may use your version of this
# file under either the NPL or the GPL.
#####################################################
# see setup.pl for full usage
# mailmaster [-d] [-c <config file>] ...
# This script reads in the client configuration files and will
# fork children to rsh the mailclient process on network clients,
# each child will write test results to /mailstone directory before
# dying. The parent will the read and combine the results.
#
# Make sure the user running this script has rsh privilege across
# all client machines
print "Netscape Mailstone version 4.2\n";
print "Copyright (c) Netscape Communications Corp. 1997-2000\n";
# this parses the command line and config file
do 'args.pl'|| die "$@\n";
sub die_system;
sub warn_system;
parseArgs(); # parse command line
{ # get unique date string
my ($sec, $min, $hour, $mday, $mon, $year) = localtime;
my $tstamp = sprintf ("%04d%02d%02d.%02d%02d",
1900+$year, 1+$mon, $mday, $hour, $min);
if ( -d "$resultbase/$tstamp") { # check for runs within a minute
my $tail = 'a';
while ( -d "$resultbase/$tstamp$tail" ) { $tail++; }
$tstamp .= $tail;
}
$params{TSTAMP} = $tstamp;
}
$resultdir = "$resultbase/$params{TSTAMP}";
$tmpdir = "$tmpbase/$params{TSTAMP}";
$resultstxt = "$resultdir/results.txt";
$resultshtml = "$resultdir/results.html";
mkdir ("$resultbase", 0775);
mkdir ("$tmpbase", 0775);
mkdir ("$resultdir", 0775);
mkdir ("$tmpdir", 0775);
# Make sure we have everything
die "Must specify the test time" unless $params{TIME};
die "Must specify a workload file" unless $params{WORKLOAD};
if ($params{TESTBED}) { # BACK COMPATIBILITY
readTestbedFile ($params{TESTBED}) || die "Error reading testbed: $@\n";
}
$testsecs = figureTimeSeconds ($params{TIME}, "seconds");
# figure out the processes and thread, given the desired number
# takes into account all the constraints. todo can be a float.
sub figurePT {
my $sec = shift;
my $todo = shift;
my $p = 1; # first guess
my $t = 1;
my $start = 1; # initial process guess
my $end = 250; # highest process guess
if ($todo < 1) { # mark this client as inactive
$sec->{PROCESSES} = 0;
$sec->{THREADS} = 0;
return 0;
}
if (($section->{MAXCLIENTS}) && ($todo > $section->{MAXCLIENTS})) {
$todo = $section->{MAXCLIENTS}; # trim to max client per host
}
if ($section->{PROCESSES}) { # they set this part already
$start = int ($section->{PROCESSES});
$end = $start;
$p = $start;
my $slist = $section->{sectionParams};
$slist =~ s/HOSTS=\s*//; # strip off initial bit
print "Using specified $p processes for clients $slist\n";
}
$end = int ($section->{MAXPROCESSES})
if ($section->{MAXPROCESSES}); # they set a max
if (($params{NT}) || ($section->{ARCH} eq "NT4.0")) {
$end = 1; # # NT is currently limited to 1 process
$start = 1;
$p = 1;
}
# step through some process counts
# it should first reduce errors due to MAXTHREADS,
# the it will reduce errors due to integer math.
# not optimal, just good enough
my $misses = 0;
for (my $n = $start; $n <= $end; $n++) { # try some process counts
my $tryt = int ($todo / $n);
if (($sec->{MAXTHREADS}) && ($tryt > $sec->{MAXTHREADS})) {
$tryt = $sec->{MAXTHREADS};
}
# see if this is a better match than the last one
if (abs ($todo - ($n * $tryt)) < abs ($todo - ($p * $t))) {
$p = $n;
$t = $tryt;
$misses = 0;
} else {
$misses++;
last if ($misses > 1); # getting worse
}
}
$sec->{PROCESSES} = $p;
$sec->{THREADS} = $t;
return $p * $t;
}
# Allocate CLIENTCOUNT to the client machines
# try NOT to turn this into a massive linear programming project
# works best to put bigger machines last
if ($params{CLIENTCOUNT}) {
my $todo = $params{CLIENTCOUNT};
my $softcli = 0; # how many can we play with
foreach $section (@workload) { # see which are already fixed
next unless ($section->{sectionTitle} =~ /CLIENT/i);
unless (($section->{PROCESSES}) && ($section->{THREADS})) {
$softcli++;
next;
}
my $slist = $section->{sectionParams};
$slist =~ s/HOSTS=\s*//; # strip off initial bit
my @hlist = split /[\s,]/, $slist;
my $hcnt = (1 + $#hlist);
# subtract fixed entries
my $tcount = ($section->{THREADS}) ? $section->{THREADS} : 1;
$todo -= $tcount * $section->{PROCESSES} * $hcnt;
$clientProcCount += $section->{PROCESSES} * $hcnt; # total processes
$params{DEBUG} &&
print "Fixed load group with $hcnt hosts: $section->{PROCESSES} x $tcount\n";
}
$params{DEBUG} &&
print "Allocating $todo clients over $softcli groups\n";
if ($softcli) {
foreach $section (@workload) {
next unless ($section->{sectionTitle} =~ /CLIENT/i);
next if (($section->{PROCESSES}) && ($section->{THREADS}));
my $slist = $section->{sectionParams};
$slist =~ s/HOSTS=\s*//; # strip off initial bit
my @hlist = split /[\s,]/, $slist;
my $hcnt = (1 + $#hlist);
#print "todo=$todo softcli=$softcli hcnt=$hcnt\n";
$todo -= $hcnt * figurePT ($section, $todo / ($softcli * $hcnt));
$clientProcCount += $hcnt * $section->{PROCESSES}; # total procs
$softcli--;
last if ($softcli <= 0); # should not happen
}
}
if ($todo) {
print "Warning: Could not allocate $todo of $params{CLIENTCOUNT} clients.\n";
$params{CLIENTCOUNT} -= $todo;
}
} else { # figure out the client count
my $cnt = 0;
foreach $section (@workload) { # see which are already fixed
next unless ($section->{sectionTitle} =~ /CLIENT/i);
# next unless ($section->{PROCESSES});
next unless $section->{CLIENTS};
my $clients = $section->{CLIENTS};
my $slist = $section->{sectionParams};
$slist =~ s/HOSTS=\s*//; # strip off initial bit
my @hlist = split /[\s,]/, $slist;
my $hcnt = scalar @hlist;
$clients /= $hcnt;
my $maxp = ($section->{MAXPROCESSES} || 10000);
my $maxt = ($section->{MAXTHREADS} || 10000);
if ($maxp * $maxt < $clients) {
die <<EOS;
Too many clients for hosts $section->{sectionParams}:
clients = $section->{CLIENTS}
maxThreads = $section->{MAXTHREADS}
maxProcesses = $section->{MAXPROCESSES}
EOS
}
my ($nt, $np);
if ($maxt >= $clients) {
$nt = $clients;
$np = 1;
} else {
$np = int (($clients / $maxt) + (($clients % $maxt) ? 1 : 0));
$nt = int ($clients / $np);
}
$section->{THREADS} = $nt;
$section->{PROCESSES} = $np;
# $section->{CLIENTS} = $np * $nt * $hcnt;
$cnt += $nt * $np * $hcnt;
$clientProcCount += $np * $hcnt; # total processes
}
$params{CLIENTCOUNT} = $cnt;
die "No clients configured!\n" unless ($cnt > 0);
}
# This has to be written into save workload file for later processing
unless ($params{FREQUENCY}) { # unless frequency set on command line
my $chartp = ($params{CHARTPOINTS}) ? $params{CHARTPOINTS} : 464;
# approximate data points for good graphs (up to 2 times this)
$params{FREQUENCY} = int ($testsecs / $chartp);
if ($params{FREQUENCY} < 2) { # fastest is every 2 seconds
$params{FREQUENCY} = 2;
} elsif ($params{FREQUENCY} > 60) { # slowest is every minute
$params{FREQUENCY} = 60;
}
}
{ # set a unique block id on every section
my $id = 0;
my $configSeen = 0;
my $defaultSeen = 0;
foreach $section (@workload) {
if ($section->{"sectionTitle"} =~ /^CONFIG$/) {
next if $configSeen;
$configSeen++;
}
if ($section->{"sectionTitle"} =~ /^DEFAULT$/) {
next if $defaultSeen;
$defaultSeen++;
}
$id++; # number 1, 2, ...
if ($section->{"sectionTitle"} =~ /^(CONFIG|CLIENT)$/) {
$section->{BLOCKID} = $id;
} else {
push @{$section->{"lineList"}}, "blockID\t$id\n";
}
}
}
# Write the version we pass to mailclient
writeWorkloadFile ("$resultdir/work.wld", \@workload,
\@scriptWorkloadSections);
# Write the complete inclusive version
writeWorkloadFile ("$resultdir/all.wld", \@workload);
# SEAN: copy the wld.in file to the result directory for later
# statistics gathering.
my $wld = $params{WORKLOAD};
if (-f "$wld.in") {
die_system "cp $wld.in $resultdir/wld.in";
} else {
unless ($wld !~ /\.preload_(new|old|touch)$/) {
warn "Can't find wld.in file for `$wld'\n" unless -f "$wld.in";
}
}
setConfigDefaults(); # pick up any missing defaults
unless ($#protocolsAll > 0) {
die "No protocols found. Test Failed!\n";
}
print "Starting: ", scalar(localtime), "\n";
# redirect STDERR
open SAVEERR, ">&STDERR";
open(STDERR, ">$resultdir/stderr") || warn "Can't redirect STDERR:$!\n";
$totalProcs = 0; # number of clients started
# iterate over every client in the testbed, complete the cmd and rsh
if ($params{NT}) { # single client on local host
pathprint ("Starting clients (errors logged to $resultdir/stderr)\n");
foreach $section (@workload) {
next unless ($section->{sectionTitle} =~ /CLIENT/i);
my $tcount = ($section->{THREADS}) ? $section->{THREADS} : 1;
# Build the initial Mailclient command line
my $preCmd = ($section->{COMMAND})
? $section->{COMMAND} : $params{CLIENTCOMMAND};
$preCmd .= " -s -t $params{TIME} -f $params{FREQUENCY}";
$preCmd .= " -d" if ($params{DEBUG});
$preCmd .= " -r" if ($params{TELEMETRY});
$preCmd .= " -R $params{RAMPTIME}" if ($params{RAMPTIME});
$preCmd .= " -m $params{MAXERRORS}" if ($params{MAXERRORS});
$preCmd .= " -M $params{MAXBLOCKS}" if ($params{MAXBLOCKS});
$preCmd .= " -n 1 -N $tcount";
$preCmd .= ($params{USEGROUPS} && $section->{GROUP})
? " -H $section->{GROUP}" : " -H $cli";
my $stdout = "$tmpdir/localhost.out";
$totalProcs += $tcount;
do 'makeindex.pl' || warn "$@\n"; # html index
printf "\nTest duration: %d %s. Rampup time: %d %s. Number of clients: %d\n",
figureTimeNumber ($params{TIME}),
figureTimeUnits ($params{TIME}, "seconds"),
figureTimeNumber ($params{RAMPTIME}),
figureTimeUnits ($params{RAMPTIME}, "seconds"),
$totalProcs;
print STDERR "localhost: cd $params{TEMPDIR}; $preCmd\n";
# Redirect STDIN, and STDOUT
#open SAVEIN, "<STDIN";
open STDIN, "<$resultdir/work.wld"
|| die "Coundn't open $resultdir/work.wld for input\n";
open SAVEOUT, ">&STDOUT";
open STDOUT, ">$stdout"
|| die "Couldnt open $stdout for output\n";
chdir $params{TEMPDIR} || die "Could not cd $params{TEMPDIR}: $!\n";
warn_system $preCmd;
close STDOUT;
open STDOUT, ">&SAVEOUT";
printf "Test done.\n";
chdir $cwd || die "Could not cd $cwd: $!\n";
last; # only do the first one
}
} else { # not NT (forking works)
foreach $section (@workload) { # do pre run commands
next unless ($section->{sectionTitle} =~ /PRETEST/i);
unless ($section->{COMMAND}) {
print "PreTest with no Command for $section->{sectionParams}\n";
next;
}
my $slist = $section->{sectionParams};
$slist =~ s/HOSTS=\s*//; # strip off initial bit
my $myCmd = $section->{COMMAND};
$myCmd =~ s/%f/$params{FREQUENCY}/; # fill in frequency variable
if ($myCmd =~ m/%c/o) { # dont force down if count is used
$count = $testsecs / $params{FREQUENCY};
$myCmd =~ s/%c/$count/; # fill in count variable
}
my $rsh = ($section->{RSH}) ? $section->{RSH} : $params{RSH};
foreach $cli (split /[\s,]/, $slist) {
print "Running pre test command on $cli\n";
open PRE, ">>$resultdir/$cli-pre.log";
print PRE "========\n";
print PRE "$myCmd\n";
print PRE "========\n";
close PRE;
print STDERR "$cli: $myCmd\n"; # log the actual command
forkproc ($rsh, $cli, $myCmd,
"/dev/null", "$resultdir/$cli-pre.log");
}
foreach $cli (split /[\s,]/, $slist) {
wait(); # run multiple PRETEST section sequentially
}
}
foreach $section (@workload) { # start monitors
next unless ($section->{sectionTitle} =~ /MONITOR/i);
my $slist = $section->{sectionParams};
$slist =~ s/HOSTS=\s*//; # strip off initial bit
my $myCmd = ($section->{COMMAND})
? $section->{COMMAND} : $params{MONITORCOMMAND};
my $forceDown = 0;
$myCmd =~ s/,/ /g; # turn commas into spaces BACK COMPATIBIILITY
$myCmd =~ s/%f/$params{FREQUENCY}/; # fill in frequency variable
if ($myCmd =~ m/%c/o) { # dont force down if count is used
$count = $testsecs / $params{FREQUENCY};
$myCmd =~ s/%c/$count/; # fill in count variable
} else {
$forceDown = 1;
}
my $rsh = ($section->{RSH}) ? $section->{RSH} : $params{RSH};
foreach $cli (split /[\s,]/, $slist) {
printf "Monitoring on $cli\n";
open PRE, ">>$resultdir/$cli-run.log";
print PRE "========\n";
print PRE "$myCmd\n";
print PRE "========\n";
close PRE;
print STDERR "$cli: $myCmd\n"; # log the actual command
$pid = forkproc ($rsh, $cli, $myCmd,
"/dev/null", "$resultdir/$cli-run.log");
push @forceDownPids, $pid if ($forceDown); # save PID for shutdown
}
}
print "Starting clients (errors logged to $resultdir/stderr)\n";
foreach $section (@workload) {
next unless ($section->{sectionTitle} =~ /CLIENT/i);
next unless ($section->{PROCESSES}); # unused client
my $slist = $section->{sectionParams};
$slist =~ s/HOSTS=\s*//; # strip off initial bit
my $rsh = ($section->{RSH}) ? $section->{RSH} : $params{RSH};
my $pcount = $section->{PROCESSES};
my $tcount = ($section->{THREADS}) ? $section->{THREADS} : 0;
my $tempdir;
if ($section->{TEMPDIR}) {
$tempdir = $section->{TEMPDIR};
} elsif ($params{TEMPDIR}) {
$tempdir = $params{TEMPDIR};
}
my $preCmd = "./" . (($section->{COMMAND})
? $section->{COMMAND} : $params{CLIENTCOMMAND});
$preCmd .= " -e" unless ($params{NOEVENTS});
$preCmd .= " -s -t $params{TIME} -f $params{FREQUENCY}";
$preCmd .= " -d" if ($params{DEBUG});
$preCmd .= " -r" if ($params{TELEMETRY});
$preCmd .= " -R $params{RAMPTIME}" if ($params{RAMPTIME});
if ($params{MAXERRORS}) {
# distribute error count over processes, rounding up
my $n = int (($params{MAXERRORS} + $clientProcCount - 1)
/ $clientProcCount);
$n = 1 if ($n < 1);
$preCmd .= " -m $n";
}
if ($params{MAXBLOCKS}) {
# distribute block count over processes, rounding up
my $n = int (($params{MAXBLOCKS} + $clientProcCount - 1)
/ $clientProcCount);
$n = 1 if ($n < 1);
$preCmd .= " -M $n";
}
$preCmd = "cd $tempdir; " . $preCmd if ($tempdir);
$preCmd =~ s!/!\\!g if ($section->{ARCH} eq "NT4.0");
$preCmd =~ s/;/&&/g if ($section->{ARCH} eq "NT4.0");
my $total_clients = $section->{CLIENTS};
my $residue = $total_clients - ($tcount * $pcount);
foreach $cli (split /[\s,]/, $slist) {
my $stdout = getClientFilename ($cli, $section);
my $myCmd = $preCmd;
$myCmd .= ($params{USEGROUPS} && $section->{GROUP})
? " -H $section->{GROUP}" : " -H $cli";
my $foo = ($params{USEGROUPS} && $section->{GROUP})
? $section->{GROUP} : undef;
if ($tcount) {
my $nt = $tcount;
if ($residue > 0) {
++$nt;
$residue -= $pcount;
}
$myCmd .= " -n $pcount -N $nt";
printf "Starting $pcount x $nt on $cli%s\n",
$foo?" (group = $foo)":'';
$totalProcs += $pcount * $nt;
} else {
my $np = $pcount;
if ($residue > 0) {
++$np;
--$residue;
}
$myCmd .= " -n $np";
printf "Starting $np processes on $foo\n";
$totalProcs += $np;
}
print STDERR "$cli: $myCmd\n"; # log the actual command
$pid = forkproc ($rsh, $cli, $myCmd,
"$resultdir/work.wld", $stdout);
push @localPids, $pid if ($cli =~ /^localhost$/i);
}
}
if (@localPids) {
# print "Trapping extraneous local signals\n";
# This doesnt trap quite right. We dont die, but shell returns...
$SIG{ALRM} = 'IGNORE'; # in case we get an ALRM from the mailclient
}
printf "\nTest duration: %d %s. Rampup time: %d %s. Number of clients: %d\n",
figureTimeNumber ($params{TIME}),
figureTimeUnits ($params{TIME}, "seconds"),
figureTimeNumber ($params{RAMPTIME}),
figureTimeUnits ($params{RAMPTIME}, "seconds"),
$totalProcs;
do 'makeindex.pl' || warn "$@\n"; # html index
print "Waiting for test to finish.\n";
print "Waiting: ", scalar(localtime), "\n";
# wait for children to finish
$pid = wait();
if (@forceDownPids) { # shut down after the first return.
print "Shutting down @forceDownPids\n";
kill 1 => @forceDownPids; # sigHUP
# kill 9 => @forceDownPids; # sigTERM
}
while ($pid != -1) { # wait for all children
$pid = wait();
}
foreach $section (@workload) { # do post test commands
next unless ($section->{sectionTitle} =~ /POSTTEST/i);
unless ($section->{COMMAND}) {
print "PostTest with no command for $section->{sectionParams}\n";
next;
}
my $slist = $section->{sectionParams};
$slist =~ s/HOSTS=\s*//; # strip off initial bit
my $myCmd = $section->{COMMAND};
$myCmd =~ s/%f/$params{FREQUENCY}/; # fill in frequency variable
if ($myCmd =~ m/%c/o) { # dont force down if count is used
$count = $testsecs / $params{FREQUENCY};
$myCmd =~ s/%c/$count/; # fill in count variable
}
my $rsh = ($section->{RSH}) ? $section->{RSH} : $params{RSH};
foreach $cli (split /[\s,]/, $slist) {
printf "Running post test command on $cli\n";
open PRE, ">>$resultdir/$cli-post.log";
print PRE "========\n";
print PRE "$myCmd\n";
print PRE "========\n";
close PRE;
print STDERR "$cli: $myCmd\n"; # log the actual command
forkproc ($rsh, $cli, $myCmd,
"/dev/null", "$resultdir/$cli-post.log");
}
foreach $cli (split /[\s,]/, $slist) {
wait(); # run multiple POSTTEST section sequentially
}
}
}
print STDERR "\nDone.\n";
close(STDERR);
open STDERR, ">&SAVEERR";
print "\nClients done: ", scalar(localtime), "\n";
print "Collecting results\n";
do 'reduce.pl' || die "$@\n"; # generate graphs and sums
print "Generating results pages\n";
do 'report.pl' || die "$@\n";
# Now display that data to console
if ($params{VERBOSE}) {
fileShow ($resultstxt);
print "\n";
}
print "Processing done: ", scalar (localtime), "\n";
pathprint ("\nResults (text):\t$resultstxt\n");
pathprint ( "Results (HTML):\t$resultshtml\n");
print "Index of runs: \tfile://$cwd/$resultbase/index.html\n";
# Now check for major problems in the stderr file
if (open(RESULTSTXT, "$resultdir/stderr")) {
$ERRCNT=0;
while (<RESULTSTXT>) { $ERRCNT++; }
close(RESULTSTXT);
pathprint ("Error log ($ERRCNT lines):\t$resultdir/stderr\n");
}
{ # list user requested logging
my @logfiles = <$resultdir/*-pre.log>;
if (@logfiles) {
foreach $f (@logfiles) {
print "Pre test log: \t$f\n";
}
}
@logfiles = <$resultdir/*-run.log>;
if (@logfiles) {
foreach $f (@logfiles) {
print "Monitoring log: \t$f\n";
}
}
@logfiles = <$resultdir/*-post.log>;
if (@logfiles) {
foreach $f (@logfiles) {
print "Post test log: \t$f\n";
}
}
}
print "Mailmaster done: ", scalar(localtime), "\n"; exit 0;

View File

@@ -1,115 +0,0 @@
#!/usr/bin/env perl
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Netscape Mailstone utility,
# released March 17, 2000.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1997-2000 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Dan Christian <robodan@netscape.com>
# Marcel DePaolis <marcel@netcape.com>
#
# Alternatively, the contents of this file may be used under the
# terms of the GNU Public License (the "GPL"), in which case the
# provisions of the GPL are applicable instead of those above.
# If you wish to allow use of your version of this file only
# under the terms of the GPL and not to allow others to use your
# version of this file under the NPL, indicate your decision by
# deleting the provisions above and replace them with the notice
# and other provisions required by the GPL. If you do not delete
# the provisions above, a recipient may use your version of this
# file under either the NPL or the GPL.
#####################################################
# usage: perl -Ibin makeindex.pl
# Look at all the results files and create a top level index
unless ($resultbase) { # pick up systematic defaults, if needed
do 'args.pl'|| die $@;
parseArgs(); # parse command line
}
($testname = $params{WORKLOAD}) =~ s:conf/::;
$testname =~ s:.wld::;
my $entry = "";
$entry .= "<TR><TD><BR><A HREF=\"$params{TSTAMP}/results.html\">$params{TSTAMP}</A></TD>";
$entry .= "<TD>$testname</TD>\n";
$entry .= "<TD>$params{TITLE}</TD>\n";
$entry .= "<TD>$params{TIME}</TD>\n";
$entry .= "<TD>$params{CLIENTCOUNT}</TD>\n";
$entry .= "<TD><A HREF=\"$params{TSTAMP}/all.wld\">workload</A></TD>\n";
$entry .= "<TD><A HREF=\"$params{TSTAMP}/stderr\">stderr</A></TD></TR>\n";
if (-r "$resultbase/index.html") {
fileInsertAfter ("$resultbase/index.html",
"^<!-- INSERT TAGS HERE",
$entry);
} else { # create index from scratch
system ("cd $resultbase; ln -s ../doc .");
open(INDEXNEW, ">$resultbase/index.new") ||
die "Couldn't open $resultbase/index.new: $!";
print INDEXNEW <<END;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<TITLE>
MailStone Results
</TITLE>
<HEAD>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#FF0000" ALINK="#000088">
<A HREF=$mailstoneURL>Mailstone documentation</A><BR>
<TABLE BORDER=2>
<CAPTION> Mozilla MailStone Results Index </CAPTION>
<TR>
<TH>Run</TH> <TH>Testname</TH> <TH> Title </TH>
<TH>Duration</TH> <TH>Clients</TH> <TH>Details</TH> <TH>Error log</TH>
</TR>
<!-- INSERT TAGS HERE - DO NOT DELETE THIS LINE -->
END
print INDEXNEW $entry; # put in this entry
# Add in any existing entries
# get a list of all the results files
@resall = <$resultbase/*/results.html>;
# Write out all the links
# This could be rather slow, but we only do it when index.html is missing
foreach $filefull (reverse @resall) {
my $file = $filefull;
$file =~ s:$resultbase/::;
if ($file eq $params{TSTAMP}) { next; } # written above
my $dir = $file;
$dir =~ s:/results.html::;
# dont read in old workloads, it will override the current one
print INDEXNEW "<TR><TD><BR><A HREF=\"$file\">$dir</A></TD>\n";
print INDEXNEW "<TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD>\n";
print INDEXNEW "<TD><A HREF=\"$dir/all.wld\">workload</A></TD>\n";
print INDEXNEW "<TD><A HREF=\"$dir/stderr\">stderr</A></TD></TR>\n";
}
print INDEXNEW <<END;
</TABLE>
</BODY>
</HTML>
END
close (INDEXNEW);
fileBackup ("$resultbase/index.html");
rename ("$resultbase/index.new", "$resultbase/index.html");
print "Created $resultbase/index.html\n";
}
return 1;

View File

@@ -1,414 +0,0 @@
#!/usr/bin/perl
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Netscape Mailstone utility,
# released March 17, 2000.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1997-2000 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Dan Christian <robodan@netscape.com>
# Marcel DePaolis <marcel@netcape.com>
#
# Alternatively, the contents of this file may be used under the
# terms of the GNU Public License (the "GPL"), in which case the
# provisions of the GPL are applicable instead of those above.
# If you wish to allow use of your version of this file only
# under the terms of the GPL and not to allow others to use your
# version of this file under the NPL, indicate your decision by
# deleting the provisions above and replace them with the notice
# and other provisions required by the GPL. If you do not delete
# the provisions above, a recipient may use your version of this
# file under either the NPL or the GPL.
#####################################################
# script to create test user accounts for Netscape Messaging Server 3, 4
#
# Given a set of parameters, this script will create an LDIF file
# for a number of email users of the form:
# test1, test2, test3, ...
#
# usage: perl create_accounts_ldif [users] [broadcast] [postmaster] [ options ]
# [ -a allUsersAlias ]
# [ -b basedn ]
# [ -d maildomain ]
# [ -f firstaccount ]
# [ -k ]
# [ -m mailhost ]
# [ -n numaccounts ]
# [ -o outputfile ]
# [ -p password ]
# [ -s storebase ]
# [ -u username ]
# [ -v ]
# [ -w workload ]
# [ -x maxstores ]
# [ -3 ]
#
#perl -Ibin -- bin/makeusers.pl -d mailhost.example.com -m mailhost.example.com -b 'o=example.com' -u mailhost-test -n 100 -4 -o mailhost100.ldif
# Create the ldif for the user accounts and/or broadcast, postmaster account.
#
# The ldif then must be added to
# the directory by hand (ldapadd, or through the dir admin server's
# Database Mgmt->Add entries from an ldif file).
# A faster way
# is to export the existing directory, append the results of
# this script, and re-import the combined file. This can be
# done using the following Netscape Directory Server commands:
# stop-slapd
# db2ldif outputfile
# [ merge files ]
# ldif2db inputfile # for DS4 you would typically use -noconfig
# start-sladp
#
print "Netscape Mailstone.\nCopyright (c) 1998,1999 Netscape Communications Corp.\n";
# server to be used in the internet mail address of the users
$domain = "newdomain.example.net";
# machine that will act as the user's mailhost
$mailhost = "mailhost.example.net";
# base dn for the user entries, e.g. o=Ace Industry,c=US
$basedn = "o=Benchmark Lab, c=US";
# name of broadcast account
$bcastacct = "allusers";
# name of broadcast account
$postmasteraddr = "root\@localhost";
# base name to build user names, will construct test0, test1, ...
$username = "test%ld";
# user passwds, in SHA format, the passwd below is 'netscape'
#$userpassword = "{SHA}aluWfd0LYY9ImsJb3h4afrI4AXk=";
# these can also be imported as cleartext
$userpassword = "netscape";
# 0: no numbered passwords, 1: number with userID
$maxpass = 0;
# first account to use
$firstaccount = 0;
# number of user accounts to create ($first - $first+$num-1)
$numaccounts = 1_000;
# For larger systems, spreading the users over multiple partitions
# is usually a good idea. This example assumes you have
# created partitions named p0, p1, etc.
# store partition base name
$storebase = "p%ld";
# max store number (0 - maxstores-1), skip if 0
$maxstores = 0;
#default to msg 4 schemas
$usemsg4schema = 1;
#default to writing to stdout
$outfile = STDOUT;
# Initial UID for genpasswd
$firstuid = 1000;
sub usage {
print "Usage: perl -Ibin -- makeusers [users] [broadcast] [postmaster]\n";
print "\t[ -w workload ] [ -o outputFile ]\n";
print "\t[ -d mailDomain ] [ -m mailHost ] [ -b baseDN ]\n";
print "\t[ -u username ] [ -f firstAccount ] [ -n numAccounts ]\n";
print "\t[ -p password ] [ -k ]\n";
print "\t[ -s storeBase ] [ -x numStores ]\n";
print "\t[ -a allUsersAlias ] [ -t postmasterAddress ]\n";
print "\t[ -3 ]|[ -4 ]\n";
}
sub readWorkConfig { # read the workload in, parse our params
my $workloadfile = shift || die "Workload file name expected\n";
do 'args.pl'|| die $@;
readWorkloadFile ($workloadfile, \@workload)
|| die "Error reading workload: $@\n";
# assign all the parameters from the config
$mailhost = $defaultSection->{SERVER}
if ($defaultSection->{SERVER});
if ($defaultSection->{ADDRESSFORMAT}) {
my $addr = $defaultSection->{ADDRESSFORMAT};
$addr =~ s/^.*@//;
$domain = $addr;
}
if ($defaultSection->{LOGINFORMAT}) {
my $user = $defaultSection->{LOGINFORMAT};
#$user =~ s/%ld$//;
$username = $user;
}
$numaccounts = $defaultSection->{NUMLOGINS}
if ($defaultSection->{NUMLOGINS});
$firstaccount = $defaultSection->{FIRSTLOGINS}
if ($defaultSection->{FIRSTLOGINS});
$userpassword = $defaultSection->{PASSWDFORMAT}
if ($defaultSection->{SERVER});
if ($userpassword =~ m/%ld/) { # see if numbered passwords
$maxpass++;
#$userpassword =~ s/%ld//g;
}
# what isnt set: basedn, storebase, maxstores, usemsg4schema
}
while (@ARGV) {
$arg = shift(@ARGV);
if ($arg =~ /^-a$/i) { # allusers (broadcast) user name
$bcastacct = shift(@ARGV);
next;
}
if ($arg =~ /^-b$/i) { # LDAP base DN
$basedn = shift(@ARGV);
next;
}
if ($arg =~ /^-d$/i) { # mail domain
$domain = shift(@ARGV);
next;
}
if ($arg =~ /^-f$/i) { # initial account
$firstaccount = shift(@ARGV);
next;
}
if ($arg =~ /^-k$/i) { # use numbered passwords
$maxpass++;
next;
}
if ($arg =~ /^-h$/i) { # help
usage();
exit 0;
}
if ($arg =~ /^-m$/i) { # mail server name
$mailhost = shift(@ARGV);
next;
}
if ($arg =~ /^-n$/i) { # number of accounts
$numaccounts = shift(@ARGV);
next;
}
if ($arg =~ /^-o$/i) { # name output file
my $fname = shift || die "File name expected\n";
open OUTFILE, ">$fname" || die "Error opening file $@\n";
$outfile = OUTFILE;
next; # use msg4 user admin schema
}
if ($arg =~ /^-p$/i) { # password
$userpassword = shift(@ARGV);
next;
}
if ($arg =~ /^-s$/i) { # base name for above
$storebase = shift(@ARGV);
next;
}
if ($arg =~ /^-t$/i) { # postmaster address
$postmasteraddress = shift(@ARGV);
next;
}
if ($arg =~ /^-u$/i) { # user name base
$username = shift(@ARGV);
next;
}
if ($arg =~ /^-v$/i) { # be verbose
$verbose++;
next;
}
# do this when read, so that later switches can override
if ($arg =~ /^-w$/i) { # get a workload file
readWorkConfig (shift(@ARGV));
next;
}
if ($arg =~ /^-x$/i) { # number of partitions (0 to skip)
$maxstores = shift(@ARGV);
next;
}
if ($arg =~ /^-3$/) { # no msg4 schema
$usemsg4schema = 0;
next;
}
if ($arg =~ /^-4$/) { # use msg4 user admin schema
$usemsg4schema = 1;
next;
}
if ($arg =~ /^users$/i) {
$genusers++;
next;
}
if ($arg =~ /^broadcast$/i) {
$genbroadcast++;
next;
}
if ($arg =~ /^passwd$/i) {
$genpasswd++;
next;
}
if ($arg =~ /^postmaster$/i) {
$genpostmaster++;
next;
}
print STDERR "Unknown argument $arg. Use -h for help.\n";
exit 1;
}
unless (($genusers) || ($genbroadcast) || ($genpasswd) || ($genpostmaster)) {
print STDERR "Must specify mode [users] [broadcast] [postmaster] ...\n";
usage();
exit 0;
}
# specify number fields, if needed
unless ($username =~ /%ld/) {
$username .= '%ld';
}
if (($maxpass) && !($userpassword =~ /%ld/)) {
$userpassword .= '%ld';
}
if (($maxstores) && !($storename =~ /%ld/)) {
$storename .= '%ld';
}
if ($verbose) {
print STDERR "Here is the configuration:\n";
print STDERR "baseDN='$basedn' \t";
print STDERR (($usemsg4schema) ? "-4\n" : "-3\n");
print STDERR "mailHost='$mailhost' \tdomain='$domain'\n";
print STDERR "userName='$username' \tnumAccounts=$numaccounts \tfirstAccount=$firstaccount\n";
print STDERR "userPassword='$userpassword'\n";
print STDERR "allUsersAccount='$bcastacct'\n" if ($genbroadcast);
print STDERR "postmasterAddress='$postmasterAddress'\n" if ($genpostmaster);
}
if ($genusers) { # Create the user accounts
$storenum=0;
for ($i = $firstaccount; $i < $firstaccount+$numaccounts; $i++) {
# build user account name
my $acctname = $username;
$acctname =~ s/%ld/$i/; # insert user number
my $password = $userpassword;
$password =~ s/%ld/$i/; # insert user number
# MAKE SURE THERE ARE NO TRAILING SPACES IN THE LDIF
my $extradata = "";
if ($maxstores > 0) { # assign them to a store
my $storename = $storebase;
$storename =~ s/%ld/$storenum/;
$extradata .= "mailmessagestore: $storename\n";
$storenum++;
$storenum=0 if ($storenum >= $maxstores);
}
$extradata .= "objectclass: nsMessagingServerUser\n"
if ($usemsg4schema);
print $outfile <<END;
dn: uid=$acctname, $basedn
userpassword: $password
givenname: $acctname
sn: $acctname
cn: $acctname
uid: $acctname
mail: $acctname\@$domain
mailhost: $mailhost
maildeliveryoption: mailbox
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
objectclass: mailRecipient
$extradata
END
}
}
if ($genbroadcast) { # Create the broadcast account
# MAKE SURE THERE ARE NO TRAILING SPACES IN THE LDIF
my $password = $userpassword;
$password =~ s/%ld//; # strip user number
# initial part
print $outfile <<END;
dn: uid=$bcastacct, $basedn
userpassword: $password
givenname: $bcastacct
sn: $bcastacct
cn: $bcastacct
uid: $bcastacct
mail: $bcastacct\@$domain
mailhost: $mailhost
maildeliveryoption: forward
END
# now put in each address
for ($i = $firstaccount; $i < $firstaccount+$numaccounts; $i++) {
# build user account name
my $acctname = $username;
$acctname =~ s/%ld/$i/; # insert user number
print $outfile "mailforwardingaddress: $acctname\@$domain\n";
}
# final part
print $outfile <<END;
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
objectclass: mailRecipient
END
}
if ($genpostmaster) { # Create the postmaster account
# MAKE SURE THERE ARE NO TRAILING SPACES IN THE LDIF
print $outfile <<END;
dn: cn=postmaster, $basedn
cn: postmaster
mail: postmaster\@$domain
mailalternateaddress: postmaster\@$mailhost
mgrprfc822mailmember: $postmasterAddress
objectclass: top
objectclass: mailGroup
objectclass: groupOfUniqueNames
END
}
# mixing passwd output with the ldif output above would be quite silly
if ($genpasswd) { # Create passwd entries for makeusers
for ($i = $firstaccount; $i < $firstaccount+$numaccounts; $i++) {
# build user account name
my $acctname = $username;
$acctname =~ s/%ld/$i/; # insert user number
my $password = $userpassword;
$password =~ s/%ld/$i/; # insert user number
my $uid = $firstuid + $i;
print $outfile "$acctname:$password:$uid:$uid:Mail user $acctname:/home/$acctname:/bin/sh\n";
}
}
exit 0;

View File

@@ -1,147 +0,0 @@
#!/bin/sh
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Netscape Mailstone utility,
# released March 17, 2000.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1999-2000 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Dan Christian <robodan@netscape.com>
# Marcel DePaolis <marcel@netcape.com>
#
# Alternatively, the contents of this file may be used under the
# terms of the GNU Public License (the "GPL"), in which case the
# provisions of the GPL are applicable instead of those above.
# If you wish to allow use of your version of this file only
# under the terms of the GPL and not to allow others to use your
# version of this file under the NPL, indicate your decision by
# deleting the provisions above and replace them with the notice
# and other provisions required by the GPL. If you do not delete
# the provisions above, a recipient may use your version of this
# file under either the NPL or the GPL.
#####################################################
# Figure out standard system names
UNAME_REPORTS=`uname`
UNAME_OS_ARCH=`uname -s`
UNAME_OS_RELEASE=`uname -r`
OS_ARCH=$UNAME_OS_ARCH
OS_RELEASE=$UNAME_OS_RELEASE
OS_CONFIG=${OS_ARCH}${OS_RELEASE}
if [ "$UNAME_OS_ARCH" = "SunOS" ]; then
PROCESSOR=`uname -p`
if [ "$PROCESSOR" = "i386" ]; then
BUILD_ARCH=x86
else
BUILD_ARCH=SPARC
fi
BUILD_OS=SOLARIS
if [ "$UNAME_OS_RELEASE" = "5.5" ]; then
BUILD_VER=2.5
elif [ "$UNAME_OS_RELEASE" = "5.5.1" ]; then
BUILD_VER=2.5
elif [ "$UNAME_OS_RELEASE" = "5.6" ]; then
BUILD_VER=2.6
elif [ "$UNAME_OS_RELEASE" = "5.7" ]; then
BUILD_VER=7
elif [ "$UNAME_OS_RELEASE" = "5.8" ]; then
BUILD_VER=8
fi
elif [ "$UNAME_OS_ARCH" = "HP-UX" ]; then
BUILD_ARCH=HPPA
BUILD_OS=$UNAME_OS_ARCH
BUILD_VER=$OS_RELEASE
elif [ "$UNAME_OS_ARCH" = "AIX" ]; then
BUILD_ARCH=POWER
BUILD_OS=$UNAME_OS_ARCH
BUILD_VER=`uname -v`.`uname -r`
OS_CONFIG=${BUILD_OS}${BUILD_VER}
elif [ "$UNAME_OS_ARCH" = "OSF1" ]; then
BUILD_ARCH=ALPHA
BUILD_OS=$UNAME_OS_ARCH
BUILD_VER=$OS_RELEASE
elif [ "$UNAME_OS_ARCH" = "IRIX64" -o "$UNAME_OS_ARCH" = "IRIX" ]; then
BUILD_ARCH=MIPS
BUILD_OS=IRIX
BUILD_VER=$OS_RELEASE
OS_CONFIG=${BUILD_OS}${OS_RELEASE}
elif [ "$UNAME_OS_ARCH" = "BSD/386" ]; then
BUILD_ARCH=x86
BUILD_OS=BSDI
BUILD_VER=$OS_RELEASE
elif [ "$UNAME_OS_ARCH" = "FreeBSD" ]; then
BUILD_ARCH=`uname -p`
BUILD_OS=$UNAME_OS_ARCH
BUILD_VER=$UNAME_OS_RELEASE
if [ "$BUILD_ARCH" = "i386" ]; then
BUILD_ARCH=x86
fi
OS_CONFIG=${BUILD_OS}${BUILD_VER}_${BUILD_ARCH}
elif [ "$UNAME_OS_ARCH" = "SCO_SV" ]; then
BUILD_ARCH=x86
BUILD_OS=SCO
BUILD_VER=$OS_RELEASE
elif [ "$UNAME_OS_ARCH" = "UNIX_SV" ]; then
# Check for braindamage
grep NCR /etc/bcheckrc > /dev/null 2>&1
BUILD_ARCH=x86
if [ $? = 0 ]; then
BUILD_OS=NCR
else
BUILD_OS=UNIXWARE
fi
BUILD_VER=$OS_RELEASE
elif [ "$UNAME_OS_ARCH" = "NEWS-OS" ]; then
BUILD_ARCH=`uname -p`
BUILD_OS=SONY
BUILD_VER=$OS_RELEASE
elif [ "$UNAME_OS_ARCH" = "UNIX_System_V" ]; then
BUILD_ARCH=`uname -p`
BUILD_OS=NEC
BUILD_VER=$OS_RELEASE
elif [ $UNAME_OS_ARCH = Linux ]; then
BUILD_ARCH=`uname -m`
if [ -n "`echo $BUILD_ARCH | grep -e '86$'`" ] ; then
BUILD_ARCH=x86
fi
BUILD_OS=$UNAME_OS_ARCH
BUILD_VER=`echo $OS_RELEASE | cut -f1,2 -d.`
OS_CONFIG=${BUILD_OS}${BUILD_VER}_${BUILD_ARCH}
fi
case "$UNAME_OS_ARCH" in
SINIX*|ReliantUNIX*)
BUILD_ARCH=`uname -p`
BUILD_OS="ReliantUNIX"
BUILD_VER=$OS_RELEASE
;;
esac
#PLATFORM=${BUILD_ARCH}_${BUILD_OS}_${BUILD_VER}
#echo $PLATFORM
echo $OS_CONFIG

View File

@@ -1,70 +0,0 @@
#!/bin/sh
# The conZtents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Netscape Mailstone utility,
# released March 17, 2000.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1999-2000 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Dan Christian <robodan@netscape.com>
# Marcel DePaolis <marcel@netcape.com>
#
# Alternatively, the contents of this file may be used under the
# terms of the GNU Public License (the "GPL"), in which case the
# provisions of the GPL are applicable instead of those above.
# If you wish to allow use of your version of this file only
# under the terms of the GPL and not to allow others to use your
# version of this file under the NPL, indicate your decision by
# deleting the provisions above and replace them with the notice
# and other provisions required by the GPL. If you do not delete
# the provisions above, a recipient may use your version of this
# file under either the NPL or the GPL.
#####################################################
# re-process a data run
# by default, use the most recent one
# Usage: process
# or
# Usage: process TIMESTAMP [args...]
# or
# Usage: process results/TIMESTAMP [args...]
if [ ! -x perl/bin/perl -o ! -f .license ] ; then # see if setup was ever run
echo "Critical files are missing. Run setup."
exit 2;
fi
if [ $# -lt 1 ] ; then # do most recent run
# since the directories are time stamps with fixed fields,
# alphabetical order is also time order
dir=`ls -d results/[0-9]*.[0-9]* | tail -1`
else # use specified run
if [ -d results/$1 ] ; then # timestamp
dir=results/$1
shift
elif [ -d $1 ] ; then # results/timestamp
dir=$1
shift
fi
fi
if [ -n "$dir" ] ; then
if [ -f $dir/all.wld ] ; then # unified workload file
perl/bin/perl -Ibin -- bin/process.pl -w $dir/all.wld "$@"
else # BACK COMPATIBILITY form
perl/bin/perl -Ibin -- bin/process.pl -c $dir/config.cfg "$@"
fi
else # pass in whatever they gave us
perl/bin/perl -Ibin -- bin/process.pl "$@"
fi

View File

@@ -1,371 +0,0 @@
#!/usr/bin/env perl
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Netscape Mailstone utility,
# released March 17, 2000.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1997-2000 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Dan Christian <robodan@netscape.com>
# Marcel DePaolis <marcel@netcape.com>
#
# Alternatively, the contents of this file may be used under the
# terms of the GNU Public License (the "GPL"), in which case the
# provisions of the GPL are applicable instead of those above.
# If you wish to allow use of your version of this file only
# under the terms of the GPL and not to allow others to use your
# version of this file under the NPL, indicate your decision by
# deleting the provisions above and replace them with the notice
# and other provisions required by the GPL. If you do not delete
# the provisions above, a recipient may use your version of this
# file under either the NPL or the GPL.
#####################################################
# Generate reports independently of mailmaster
# Can be used during a run or after mailmaster has finished
print "Netscape Mailstone\n";
print "Copyright (c) 1997-2000 Netscape Communications Corp.\n";
# this parses the command line and config file
do 'args.pl'|| die $@;
parseArgs(); # parse command line
setConfigDefaults(); # pick up any missing defaults
$resultdir = "$resultbase/$params{TSTAMP}";
$tmpdir = "$tmpbase/$params{TSTAMP}";
$resultstxt = "$resultdir/results.txt";
$resultshtml = "$resultdir/results.html";
if ($params{TESTBED}) { # BACK COMPATIBILITY
$params{TESTBED} = "$resultdir/testbed.tbd"; # use saved testbed
# open the saved testbed conf file
readTestbedFile($params{TESTBED}) || die "$@\n";
}
# Convert old style to new. Write the complete inclusive workload
writeWorkloadFile ("$resultdir/all.wld", \@workload)
unless ((-r "$resultdir/all.wld") || (-r "$resultdir/all.wld.gz"));
$testsecs = figureTimeSeconds ($params{TIME}, "minutes");
print "Starting data reduction\n";
sub readClientCSV {
my $file = shift;
my @fields;
my $line;
print "Reading client summary: $file\n";
open(CSV, "<$file") || # Summary of all clients
open(CSV, "gunzip -c $file.gz |") ||
return 0; # failed
# Title line: Verify that arguments are in the same order
$line = <CSV>;
unless ($line) {
print "readClientCSV: Error reading $file. \n";
return 0;
}
chomp $line; # strip newline
@fields = split /,/, $line; # turn into an array
my $cli = shift @fields; # pull off client header
my $cn = shift @fields; # pull off num header
my $pro = shift @fields; # pull off protocol header
# Client array, per variable, per protocol
foreach $p (@protocols) {
# This hash will hold the timers
$clidata{$p} = ArrayInstance->new();
foreach $t (@timers) {
# This hash will hold the values in the timer
$clidata{$p}->{$t} = ArrayInstance->new();
foreach $f (@{$timerFields{$t}}) {
# This hash that will hold the actual values per client
$clidata{$p}->{$t}->{$f} = ArrayInstance->new();
}
}
foreach $t (@scalarClientFields) { # non-timer fields
# This hash that will hold the actual values per client
$clidata{$p}->{$t} = ArrayInstance->new();
}
}
foreach $f (@commClientFields) { # proto independent
my $v = shift @fields;
if ($v !~ m/$f/i) {
print "readClientCSV: Protocol order mismatch '$v', '$f' \n";
return 0;
}
}
foreach $t (@timers) { # timers
foreach $f (@{$timerFields{$t}}) {
my $v = shift @fields;
if ($v !~ m/$t:$f/i) {
print "readClientCSV: Protocol order mismatch '$v', '$t:$f' \n";
return 0;
}
}
}
foreach $t (@scalarClientFields) { # scalars
my $v = shift @fields;
if ($v !~ m/$t/i) {
print "readClientCSV: Protocol order mismatch '$v', '$t' \n";
return 0;
}
}
# Now read actual data
while (<CSV>) {
chomp; # strip newline
@fields = split /,/; # turn into an array
my $cli = shift @fields; # pull off client header
my $cn = shift @fields; # pull off num header
my $p = shift @fields; # pull off protocol header
my $cp = $clidata{$p};
# Create the needed finals arrays
unless ($finals{$p}) {
#print "Creating finals{$p}\n"; # DEBUG
$finals{$p} = ArrayInstance->new();
foreach $t (@timers) {
$finals{$p}->{$t} = ArrayInstance->new();
}
}
foreach $f (@commClientFields) { # proto independent
$cliGen{$f}->{$cn} = shift @fields;
}
foreach $t (@timers) { # timers
foreach $f (@{$timerFields{$t}}) {
$cp->{$t}->{$f}->{$cn} = shift @fields;
$finals{$p}->{$t}->{$f} += $cp->{$t}->{$f}->{$cn};
}
}
foreach $t (@scalarClientFields) { # scalars
$cp->{$t}->{$cn} = shift @fields;
$finals{$p}->{$t} += $cp->{$t}->{$cn};
}
foreach $section (@workload) { # find thread count for this client
next unless ($section->{sectionTitle} =~ /CLIENT/i);
next unless ($section->{sectionParams} =~ /$cli/);
#print "Process $cli has threads $section->{THREADS}\n";
$reportingClients += ($section->{THREADS})
? $section->{THREADS} : 1;
last;
}
}
close (CSV);
return 1; # success
}
sub readTimeCSV {
my $file = shift;
my $p = shift;
my $gp = $graphs{$p};
my $line;
print "Reading time $p summary: $file\n";
open(CSV, "<$file") || # Summary over time
open(CSV, "gunzip -c $file.gz |") ||
return 0; # failed
# Verify that arguments are in the same order
$line = <CSV>;
unless ($line) {
print "readTimeCSV: Error reading $file. \n";
return 0;
}
chomp $line; # strip newline
@fields = split /,/, $line;
my $t = shift @fields; # pull off time header
foreach $t (@timers) {
foreach $f (@{$timerFields{$t}}) {
my $v = shift @fields;
if ($v !~ m/$t:$f/i) {
print "readTimeCSV: Protocol order mismatch '$v', '$t:$f' \n";
return 0;
}
}
}
foreach $t (@scalarGraphFields) {
my $v = shift @fields;
if ($v !~ m/$t/i) {
print "readTimeCSV: Protocol order mismatch '$v', '$t' \n";
return 0;
}
}
while (<CSV>) {
chomp;
#print "LINE: $_\n";
@fields = split /,/;
my $tm = shift @fields; # pull off time header
#print "t=$t ";
foreach $t (@timers) {
foreach $f (@{$timerFields{$t}}) {
$gp->{$t}->{$f}->{$tm} = shift @fields;
#print "$v=$gp->{$v}->{$tm} ";
}
}
foreach $t (@scalarGraphFields) {
$gp->{$t}->{$tm} = shift @fields;
#print "$v=$gp->{$v}->{$tm} ";
}
#print "\n";
}
close (CSV);
return 1; # success
}
sub loadCSV {
my @csvs = <$resultdir/time-*.csv>;
@csvs = <$resultdir/time-*.csv.gz> unless (@csvs);
return 0 unless (@csvs); # no time.csv files
# stuff normally done from reduce.pl (should all be in protoconf?)
# Basic sanity check
return 0 unless ($testsecs > 0);
$startTime = 0; # these are timeInSeconds/$timeStep
$endTime = 0;
# keep graphs with somewhat more precision than sample rate;
$timeStep = int ($params{FREQUENCY} / 2);
if ($timeStep < 1) { $timeStep = 1; }
# global results initialization
$reportingClients = 0;
$totalProcs = 0; # number of clients started
foreach $f (@commClientFields) { # protocol independent fields
$cliGen{$f} = ArrayInstance->new();
}
return 0 unless (readClientCSV ("$resultdir/clients.csv")); # client info
foreach $c (@csvs) { # read time info
$c =~ s/.gz$//; # strip .gz extension
my $p = $c; # strip down to protocol portion
$p =~ s/$resultdir\/time-//;
$p =~ s/.csv$//;
return 0 unless (readTimeCSV ($c, $p));
}
return 0 unless ($reportingClients > 0);
foreach $section (@workload) {
next unless ($section->{sectionTitle} =~ /CLIENT/i);
my $slist = $section->{sectionParams};
$slist =~ s/HOSTS=\s*//; # strip off initial bit
my @hlist = split /[\s,]/, $slist;
my $hcnt = (1 + $#hlist);
my $pcount = $section->{PROCESSES};
my $tcount = ($section->{THREADS}) ? $section->{THREADS} : 1;
$totalProcs += $pcount * $tcount * $hcnt;
}
# Find time extent for a key graph
($startTime, $endTime) = dataMinMax ("blocks", \@protocols,
$startTime, $endTime);
$realTestSecs = ($endTime - $startTime) * $timeStep;
$realTestSecs = 1 unless ($realTestSecs); # in case of small MaxBlocks
printf "Reported test duration %d seconds with %d second resolution\n",
$realTestSecs, $timeStep;
$realTestSecs = $testsecs if ($realTestSecs > $testsecs);
my @newProtos; # figure real protocol list
foreach $p (@protocols) {
my $gp = $graphs{$p};
my $numValid = 0;
# See if there is real data here
CHECKVAL: foreach $t (@timers) {
foreach $f (@{$timerFields{$t}}) {
my $vp = $gp->{$t}->{$f};
next unless ($vp); # no data
next unless (scalar %$vp); # redundant???
#print "Checking: $p $t $f => ENTRIES\n";
$numValid++;
last CHECKVAL;
}
}
($numValid > 0) || next;
push @newProtos, $p;
}
# update protocol list to only have what was used
@protocols = @newProtos;
@protocolsAll = @newProtos;
push @protocolsAll, "Total";
}
my $doFull = 1; # re-processing is currently broken
# if (!((-f "$resultdir/clients.csv")
# || (-f "$resultdir/clients.csv.gz"))) { # no processing yet
# $doFull = 1;
# } else { # see if any source is newer than csv
# foreach $section (@workload) {
# next unless ($section->{sectionTitle} =~ /CLIENT/i);
# my $slist = $section->{sectionParams};
# $slist =~ s/HOSTS=\s*//; # strip off initial bit
# foreach $cli (split /[\s,]/, $slist) {
# my $fname = getClientFilename ($cli, $section);
# if ((-r $fname) # raw source exists
# && ((-M "$resultdir/clients.csv")
# > (-M $fname))) { # newer
# #print "$fname is newer than $resultdir/clients.csv\n";
# $doFull++;
# last;
# }
# }
# }
# }
# unless ($doFull) { # do CSV load
# # if this is a csv only run, then these may not exist yet
# mkdir ("$tmpbase", 0775);
# mkdir ("$tmpdir", 0775);
# unless (-r "$resultbase/index.html") {
# do 'makeindex.pl' || warn "$@\n"; # html index
# }
# $doFull = 1 unless (loadCSV); # if CSV fails, fall back to full processing
# }
if ($doFull) {
do 'reduce.pl' || die "$@\n";
}
print "Generating results pages:\t", scalar (localtime), "\n";
do 'report.pl' || die "$@\n";
# Now display that data to console
if ($params{VERBOSE}) {
fileShow ($resultstxt);
print "\n";
}
pathprint ("\nResults (text):\t$resultstxt\n");
pathprint ( "Results (HTML):\t$resultshtml\n");
print "Index of runs: \tfile://$cwd/$resultbase/index.html\n";
print "Process done:\t", scalar (localtime), "\n";

View File

@@ -1,158 +0,0 @@
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Netscape Mailstone utility,
# released March 17, 2000.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1997-2000 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Dan Christian <robodan@netscape.com>
# Marcel DePaolis <marcel@netcape.com>
#
# Alternatively, the contents of this file may be used under the
# terms of the GNU Public License (the "GPL"), in which case the
# provisions of the GPL are applicable instead of those above.
# If you wish to allow use of your version of this file only
# under the terms of the GPL and not to allow others to use your
# version of this file under the NPL, indicate your decision by
# deleting the provisions above and replace them with the notice
# and other provisions required by the GPL. If you do not delete
# the provisions above, a recipient may use your version of this
# file under either the NPL or the GPL.
#####################################################
# This define the structures that hold summary, client, and graph data,
# This sets the names used for display. Can be internationalized.
# All top level names are here (both timers and scalars).
# Any unlisted names will map to themselves.
%timerNames
= (
#internal name, Printed name
"total", "total",
"conn", "connect",
"reconn", "reconnect",
"banner", "banner",
"login", "login",
"cmd", "command",
"submit", "submit",
"retrieve", "retrieve",
"logout", "logout",
"idle", "idle",
"connections", "connections",
"blocks", "blocks",
);
# This sets the names used for display. Can be internationalized.
%fieldNames
= (
#internal name, Printed name
"Try", "Try",
"Error", "Error",
"BytesR", "BytesR",
"BytesW", "BytesW",
"Time", "Time",
"TimeMin", "TMin",
"TimeMax", "TMax",
"Time2", "TStd",
);
# hold time graphs for each protocol
%graphs = ();
# Totals are done during plotting, if needed
%finals = (); # create base finals hash
# These are sections that dont get passed to mailclient (case insensitive)
@scriptWorkloadSections
= (
"Config", # special, references %params
"Client", # testbed client(s)
"Graph", # graph generation
"Setup", # things to run with ./setup
"Startup", # things to run before test
"Monitor", # other performance monitoring
"PreTest", # things to run before test
"PostTest", # things to run after test
);
# These are sections that arent protocols. Anything else must be.
@nonProtocolSections
= (@scriptWorkloadSections, ("Default"));
# These are the known workload parameters (as they will print)
# These are coerced to upper case internally (do NOT internationize)
@workloadParameters
= (
"addressFormat",
"arch",
"blockID",
"blockTime",
"chartHeight",
"chartPoints",
"chartWidth",
"clientCount",
"command",
"comments",
"file",
"firstAddress",
"firstLogin",
"frequency",
"gnuplot",
"group",
"idleTime",
"leaveMailOnServer",
"loginFormat",
"loopDelay",
"numAddresses",
"numLogins",
"numLoops",
"numRecips",
"mailClient",
"maxBlocks",
"maxClients",
"maxErrors",
"maxThreads",
"maxProcesses",
"passwdFormat",
"processes",
"rampTime",
"rcp",
"rsh",
"sequentialAddresses",
"sequentialLogins",
"server",
"smtpMailFrom",
"sysConfig",
"threads",
"telemetry",
"tempDir",
"time",
"title",
"TStamp",
"useAuthLogin",
"useEHLO",
"weight",
"wmapBannerCmds",
"wmapClientHeader",
"wmapInBoxCmds",
"wmapLoginCmd",
"wmapLoginData",
"wmapLogoutCmds",
"wmapMsgReadCmds",
"wmapMsgWriteCmds",
"workload",
);
return 1;

File diff suppressed because it is too large Load Diff

View File

@@ -1,605 +0,0 @@
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Netscape Mailstone utility,
# released March 17, 2000.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1997-2000 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Dan Christian <robodan@netscape.com>
# Marcel DePaolis <marcel@netcape.com>
#
# Alternatively, the contents of this file may be used under the
# terms of the GNU Public License (the "GPL"), in which case the
# provisions of the GPL are applicable instead of those above.
# If you wish to allow use of your version of this file only
# under the terms of the GPL and not to allow others to use your
# version of this file under the NPL, indicate your decision by
# deleting the provisions above and replace them with the notice
# and other provisions required by the GPL. If you do not delete
# the provisions above, a recipient may use your version of this
# file under either the NPL or the GPL.
#####################################################
# This file deals with the summary data only
# Should be packages
do 'genplot.pl' || die "$@\n";
sub walkSetupTotals {
my $a = shift; my $f = shift; my $p = shift;
if ($p =~ /(\w+):(\w+):$/) {
my $tm = $2;
if (!($finals{Total}->{$tm}->{$f})) {
$finals{Total}->{$tm}->{$f} = $a;
} elsif ($f =~ /Min$/) {
$finals{Total}->{$tm}->{$f} = $a
if (($a > 0.0) && ($a < $finals{Total}->{$tm}->{$f}));
} elsif ($f =~ /Max$/) {
$finals{Total}->{$tm}->{$f} = $a if ($a > $finals{Total}->{$tm}->{$f});
} else {
$finals{Total}->{$tm}->{$f} += $a;}
}
elsif ($p =~ /(\w+):$/) {
$finals{Total}->{$f} += $a;
}
}
sub setupTotals {
# Figure out combined timers for "Total" protocol
# We might do a smarter merge here (look at context and try to match order)
# As long as the first protocol is a superset, it wont matter
my @tnames;
foreach $proto (@protocols) {
foreach $n (@{$protocolFields{$proto}}) {
my $t = $n;
$t =~ s/([][{}*+?^.\/])/\\$1/g; # quote regex syntax
my $found = 0;
foreach $tn (@tnames) { # see if it is in the list already
next unless ($tn =~ /$t/);
$found = 1;
last;
}
#print "proto $proto: Found $n\n" if ($found > 0);
next if ($found > 0);
#print "proto $proto: Add $n\n";
push @tnames, $n; # add to list
}
}
#print "'Total' timers @tnames\n";
$protocolFields{"Total"} = \@tnames;
# Create "Total" hashes
$finals{Total} = ArrayInstance->new();
foreach $n (@{$protocolFields{"Total"}}) { # all timers
my $t = $n; # dont modify original list
if ($t =~ /^\[(\w+)\]$/) { # Timer case, strip off brackets
$finals{Total}->{$1} = ArrayInstance->new();
#print "Creating Total timer field $1\n";
} else { # scalar
$finals{Total}->{$n} = 0;
#print "Creating Total scalar field $n\n";
}
}
# Total finals array
foreach $proto (@protocols) {
foreach $t (@{$protocolFields{$proto}}) {
if ($t =~ /^\[(\w+)\]$/) { # Timer case, strip off brackets
my $tm = $1;
foreach $f (@timerFieldsAll) {
my $a = $finals{$proto}->{$tm}->{$f};
if (!($finals{Total}->{$tm}->{$f})) { # never touched
$finals{Total}->{$tm}->{$f} = $a;
} elsif ($f =~ /Min$/) {
$finals{Total}->{$tm}->{$f} = $a
if (($a > 0.0)
&& ($a < $finals{Total}->{$tm}->{$f}));
} elsif ($f =~ /Max$/) {
$finals{Total}->{$tm}->{$f} = $a
if ($a > $finals{Total}->{$tm}->{$f});
} else {
$finals{Total}->{$tm}->{$f} += $a;
}
}
} else {
$finals{Total}->{$t} += $finals{$proto}->{$t};
}
}
}
# Convert Time2 to standard deviation
foreach $proto (@protocolsAll) {
foreach $n (@{$protocolFields{$proto}}) {
my $t = $n; # dont modify original list
if ($t =~ /^\[(\w+)\]$/) { $t = $1; } # strip off brackets
next unless ($finals{$proto}->{$t}); # proto doesnt have timer
next unless ($finals{$proto}->{$t}->{Try});
next unless ($finals{$proto}->{$t}->{Time2} > 0);
my $ss = $finals{$proto}->{$t}->{Time2};
my $tot = $finals{$proto}->{$t}->{Time};
my $n = $finals{$proto}->{$t}->{Try};
next unless ($n > 0); # skip if this is 0
my $var = ($ss - (($tot * $tot) / $n)) / $n;
print "$proto->$t var < 0: Time2=$ss Time=$tot n=$n\n"
if ($var < 0);
$finals{$proto}->{$t}->{Time2} = ($var > 0) ? sqrt ($var) : 0.0;
}
}
# Divide total times by trys to get averate time
foreach $proto (@protocolsAll) {
foreach $n (@{$protocolFields{$proto}}) {
my $t = $n; # dont modify original list
if ($t =~ /^\[(\w+)\]$/) { $t = $1; } # strip off brackets
next unless ($finals{$proto}->{$t}); # proto doesnt have timer
($finals{$proto}->{$t}->{Try}) || next;
$finals{$proto}->{$t}->{Time} /= $finals{$proto}->{$t}->{Try}
}
}
}
# The text version is designed to be machine processable
# commify and kformat are not used
sub genTextReport {
fileBackup ($resultstxt); # if processing as we go, backup old file
# Open a text file to hold the results
open(RESULTSTXT, ">$resultstxt") ||
die "Couldn't open $resultstxt: $!";
# Store results as text
printf RESULTSTXT "---- Mozilla MailStone Results $params{TSTAMP} ----\n";
printf RESULTSTXT "\t\t%s\n", $params{TITLE};
printf RESULTSTXT "\t\t%s\n", $params{COMMENTS};
printf RESULTSTXT "\n";
printf RESULTSTXT "Test duration: %d %s. Rampup: %d %s. Reported duration %s seconds\n",
figureTimeNumber ($params{TIME}),
figureTimeUnits ($params{TIME}, "minutes"),
figureTimeNumber ($params{RAMPTIME}),
figureTimeUnits ($params{RAMPTIME}, "seconds"), $realTestSecs;
printf RESULTSTXT "Number of reporting clients: %s of %s\n",
$reportingClients, $totalProcs;
foreach $proto (@protocolsAll) {
# do op counters
printf RESULTSTXT "\n%-15s ", $proto;
foreach $f (@timerFieldsAll) {
#($f =~ m/^Time2$/o) && next;
printf RESULTSTXT "%13s",
($fieldNames{$f}) ? $fieldNames{$f} : $f;
}
foreach $n (@{$protocolFields{$proto}}) {
my $t = $n; # dont modify original list
unless ($t =~ /^\[(\w+)\]$/) { # scalar case
#next; # skip scalars for now
# do scalar counters. Column should line up with "Try"
printf RESULTSTXT "\n%-15s ",
$proto . ":" . (($timerNames{$t}) ? $timerNames{$t} : $t);
printf RESULTSTXT
"%13s", $finals{$proto}->{$t};
next;
} else { # strip off brackets
$t = $1;
}
printf RESULTSTXT "\n%-15s ",
$proto . ":" . (($timerNames{$t}) ? $timerNames{$t} : $t);
foreach $f (@timerFieldsAll) {
#($f =~ m/^Time2$/o) && next;
if ($f =~ m/Time/o) {
printf RESULTSTXT
"%13.3f", $finals{$proto}->{$t}->{$f};
} elsif ($f =~ m/Bytes/o) {
printf RESULTSTXT
"%13d", $finals{$proto}->{$t}->{$f};
} else {
printf RESULTSTXT
"%13s", $finals{$proto}->{$t}->{$f};
}
}
}
# do ops/sec
printf RESULTSTXT "\n\n%-15s ", $proto;
foreach $f (@timerFieldsAll) {
($f =~ m/^Time/o) && next;
printf RESULTSTXT "%9s/sec",
($fieldNames{$f}) ? $fieldNames{$f} : $f;
}
foreach $n (@{$protocolFields{$proto}}) {
my $t = $n; # dont modify original list
unless ($t =~ /^\[(\w+)\]$/) { # scalar case
#next; # skip scalars for now
# do scalar counter/sec. Column should line up with "Try"
printf RESULTSTXT "\n%-15s ",
$proto . ":" . (($timerNames{$t}) ? $timerNames{$t} : $t) . "/s";
printf RESULTSTXT
"%13.3f", $finals{$proto}->{$t} / $realTestSecs;
next;
} else {
$t = $1;
}
printf RESULTSTXT "\n%-15s ",
$proto . ":" . (($timerNames{$t}) ? $timerNames{$t} : $t) . "/s";
foreach $f (@timerFieldsAll) {
($f =~ m/^Time/o) && next;
if ($f =~ m/Bytes/o) {
printf RESULTSTXT
"%13d",
$finals{$proto}->{$t}->{$f} / $realTestSecs;
} else {
printf RESULTSTXT
"%13.3f",
$finals{$proto}->{$t}->{$f} / $realTestSecs;
}
}
}
printf RESULTSTXT "\n\n";
}
if ($params{SYSCONFIG}) {
print RESULTSTXT "\nSytem config details\n";
if (($params{SYSCONFIG} =~ m/^\S+$/o)
&& (open(SCFILE, "<$params{SYSCONFIG}"))) {
while (<SCFILE>) {
(m/^<\S+>\s*$/o) && next; # skip HTML only on them
s/<\S+>//g; # trim out obvious HTML commands
s/<!--.*-->//g; # trim out HTML comments
print RESULTSTXT $_;
}
close(SCFILE);
} else {
my $l = $params{SYSCONFIG}; # filter similar to above
$l =~ s/<\S+>//g; # trim out obvious HTML commands
$l =~ s/<!--.*-->//g; # trim out HTML comments
$l =~ s/\\\n/\n/g; # turn quoted newline to plain newline
print RESULTSTXT $l;
}
}
close(RESULTSTXT);
}
# Write the main part of the HTML page
sub genHTMLReportStart {
fileBackup ($resultshtml); # if processing as we go, backup old file
# Open an html file to hold the results
open(RESULTSHTML, ">$resultshtml") ||
die "Couldn't open $resultshtml: $!";
print RESULTSHTML <<END;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<A NAME=TitleSection>
<TITLE>
Mozilla MailStone Results $params{TSTAMP}
</TITLE>
</A>
<HEAD>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#FF0000" ALINK="#000088">
<CENTER>
<HR NOSHADE WIDTH="100%">
<H1>Mozilla MailStone Results $params{TSTAMP}</H1>
<H2>$params{TITLE}</H2>
<I>$params{COMMENTS}</I>
<HR WIDTH="100%">
</CENTER>
END
printf RESULTSHTML "<BR><B>Test duration:</B> %d %s. ",
figureTimeNumber ($params{TIME}),
figureTimeUnits ($params{TIME}, "minutes");
printf RESULTSHTML "<B>Rampup:</B> %d %s. ",
figureTimeNumber ($params{RAMPTIME}),
figureTimeUnits ($params{RAMPTIME}, "seconds");
printf RESULTSHTML "<B>Reported duration:</B> %s seconds\n",
commify ($realTestSecs);
printf RESULTSHTML "<BR><B>Reporting clients:</B> %s of %s\n",
commify ($reportingClients), commify ($totalProcs);
print RESULTSHTML <<END;
<BR>
Test <A HREF="all.wld">complete workload</a> description.
Filtered <A HREF="work.wld">workload</a> description.
<BR>
Plain <A HREF="results.txt">text version</a> of results.
Log of <A HREF="stderr">stderr</a> and debugging output.
<BR>
<A NAME=MonitoringSection></A>
END
{ # list user requested logging
my @logfiles = <$resultdir/*-pre.log>;
if (@logfiles) {
foreach $f (@logfiles) {
$f =~ s/$resultdir\///o; # strip directory out
$f =~ s/-pre\.log$//o; # strip extension off
print RESULTSHTML "Pre test log: <A HREF=\"$f-pre.log\">$f</a><BR>\n";
}
}
@logfiles = <$resultdir/*-run.log>;
if (@logfiles) {
foreach $f (@logfiles) {
$f =~ s/$resultdir\///o; # strip directory out
$f =~ s/-run\.log$//o; # strip extension off
print RESULTSHTML "Monitoring log: <A HREF=\"$f-run.log\">$f</a><BR>\n";
}
}
@logfiles = <$resultdir/*-post.log>;
if (@logfiles) {
foreach $f (@logfiles) {
$f =~ s/$resultdir\///o; # strip directory out
$f =~ s/-post\.log$//o; # strip extension off
print RESULTSHTML "Post test log: <A HREF=\"$f-post.log\">$f</a><BR>\n";
}
}
}
#print RESULTSHTML
#"<CENTER><H2>Results per protocol</H2></CENTER>\n";
foreach $proto (@protocolsAll) {
printf RESULTSHTML "<A NAME=%sTable></A>\n", $proto;
printf RESULTSHTML
"<TABLE BORDER=2 CELLSPACING=2 CELLPADDING=2 COLS=%d WIDTH=\"95%%\">",
2+$#{@{$protocolFields{$proto}}};
print RESULTSHTML
"<CAPTION>$proto Counters</CAPTION>\n";
# do op counters
print RESULTSHTML
"<TR><TH>$proto</TH>\n";
foreach $f (@timerFieldsAll) {
#($f =~ m/^Time2$/o) && next;
printf RESULTSHTML "<TH>%s</TH> ",
($fieldNames{$f}) ? $fieldNames{$f} : $f;
}
print RESULTSHTML
"</TR>\n";
foreach $n (@{$protocolFields{$proto}}) {
my $t = $n; # dont modify original list
unless ($t =~ /^\[(\w+)\]$/) { # scalar case
next; # skip scalars for now
# do scalar counters. Column should line up with "Try"
printf RESULTSHTML "<TR ALIGN=RIGHT><TH>%s</TH>\n",
($timerNames{$t}) ? $timerNames{$t} : $t;
printf RESULTSHTML
"<TD>%s</TD> ",
commify ($finals{$proto}->{$t});
next;
} else {
$t = $1;
}
printf RESULTSHTML "<TR ALIGN=RIGHT><TH>%s</TH>\n",
($timerNames{$t}) ? $timerNames{$t} : $t;
foreach $f (@timerFieldsAll) {
#($f =~ m/^Time2$/o) && next;
if ($f =~ m/Time/o) {
printf RESULTSHTML
"<TD>%s</TD> ",
tformat ($finals{$proto}->{$t}->{$f});
} elsif ($f =~ m/Bytes/o) {
printf RESULTSHTML
"<TD>%s</TD> ",
kformat ($finals{$proto}->{$t}->{$f});
} else {
printf RESULTSHTML
"<TD>%s</TD> ",
commify ($finals{$proto}->{$t}->{$f});
}
}
print RESULTSHTML "</TR>\n";
}
# do ops/sec
print RESULTSHTML
"<TR><TH>$proto</TH>\n";
foreach $f (@timerFieldsAll) {
($f =~ m/^Time/o) && next;
printf RESULTSHTML "<TH>%s/sec</TH> ",
($fieldNames{$f}) ? $fieldNames{$f} : $f;
}
print RESULTSHTML
"</TR>\n";
foreach $n (@{$protocolFields{$proto}}) {
my $t = $n; # dont modify original list
unless ($t =~ /^\[(\w+)\]$/) { # scalar case
next; # skip scalars for now
# do scalar counters. Column should line up with "Try"
printf RESULTSHTML "<TR ALIGN=RIGHT><TH>%s</TH>\n",
($timerNames{$t}) ? $timerNames{$t} : $t;
printf RESULTSHTML
"<TD>%.3f</TD> ",
$finals{$proto}->{$t} / $realTestSecs;
next;
} else {
$t = $1;
}
printf RESULTSHTML "<TR ALIGN=RIGHT><TH>%s</TH>\n",
($timerNames{$t}) ? $timerNames{$t} : $t;
foreach $f (@timerFieldsAll) {
($f =~ m/^Time/o) && next;
if ($f =~ m/Bytes/o) {
printf RESULTSHTML
"<TD>%s</TD> ",
kformat ($finals{$proto}->{$t}->{$f} / $realTestSecs);
} else {
printf RESULTSHTML
"<TD>%.3f</TD> ",
$finals{$proto}->{$t}->{$f} / $realTestSecs;
}
}
print RESULTSHTML "</TR>\n";
}
printf RESULTSHTML "</TABLE> <BR>\n\n";
}
print RESULTSHTML <<END;
<BR>
<CENTER>
<A NAME=GraphSection></A>
END
}
%genplotGraphs = ();
# Call genplot; and, if a graph is generated, insert the HTML reference to it
sub genHTMLReportGraph {
my $name = shift;
my $title = shift;
my $label = shift;
my $protos = shift || die "genHTMLReportGraph: '$name' missing protocols";
my $field = shift;
my $vars = shift || die "genHTMLReportGraph: '$name' missing vars";
if ($genplotGraphs{$name}) {
print "Graph $name has already been generated.\n";
return;
}
$genplotGraphs{$name} = $title;
# Delineate and tag each graph
print RESULTSHTML "<A NAME=$name><HR SIZE=4 WIDTH=\"90%\"></A>\n";
if (genPlot ($name, $title, $label, $protos, $field, $vars) > 0) {
print RESULTSHTML <<END;
<P><H3>$title</H3>
<IMG SRC=$name.$params{IMAGETYPE} ALT="$label"></P>
END
} else {
print RESULTSHTML "<BR>Graph \"$name\" contained no data (@{$vars}).<BR>\n";
}
}
# Write the final parts of the HTML page
sub genHTMLReportEnd {
print RESULTSHTML <<END;
<!-- INSERT IMAGES HERE - DO NOT DELETE THIS LINE -->
</CENTER>
<A NAME=EndSection></A>
END
if ($params{SYSCONFIG}) {
print RESULTSHTML "<HR WIDTH=\"100%\">";
print RESULTSHTML "<CENTER><H2>Details</H2></CENTER>\n";
if (($params{SYSCONFIG} =~ m/^\S+$/o)
&& (open(SCFILE, "<$params{SYSCONFIG}"))) { # see if its a file
while (<SCFILE>) {
print RESULTSHTML $_;
}
close(SCFILE);
} else { # output text directly
my $l = $params{SYSCONFIG};
$l =~ s/\\\n/\n/g; # turn quoted newline to plain newline
print RESULTSHTML $l;
}
}
print RESULTSHTML <<END;
<HR NOSHADE WIDTH="100%">
</BODY>
</HTML>
END
close(RESULTSHTML);
}
# Actually generate the standard stuff
setupTotals();
genTextReport();
genHTMLReportStart();
my $graphCount = 0;
foreach $section (@workload) {
next unless ($section->{sectionTitle} =~ /GRAPH/i);
my $name = $section->{sectionParams};
$name =~ s/name=\s*//; # strip off initial bit
my @varlist = split (/[\s,]+/, $section->{VARIABLES});
$graphCount++;
genHTMLReportGraph ($name, $section->{TITLE}, $section->{LABEL},
($section->{FIELD} =~ /Time/o)
? \@protocols : \@protocolsAll,
$section->{FIELD}, \@varlist);
}
if ($graphCount <= 0) { # use built ins
# generate the graphs we want
# NOTE: the first argument (name), must be unique; sets file name
genHTMLReportGraph ("connects",
"Number of connections attempted", "Connections/sec",
\@protocolsAll, "Try", ["conn" ]);
genHTMLReportGraph ("connections",
"Total connections", "Connections",
\@protocolsAll, "", ["connections" ]);
genHTMLReportGraph ("errors",
"Number of connection errors", "Errors/sec",
\@protocolsAll, "Error", ["conn", "banner", "login", "logout" ]);
genHTMLReportGraph ("retrieves",
"Number of messages read", "Messages/sec",
\@protocolsAll, "Try", ["retrieve" ]);
genHTMLReportGraph ("submits",
"Number of messages written", "Messages/sec",
\@protocolsAll, "Try", ["submit" ]);
genHTMLReportGraph ("commands",
"Protocol commands", "Commands/sec",
\@protocolsAll, "Try", ["cmd" ]);
genHTMLReportGraph ("readBytes",
"Bytes read", "Bytes/sec",
\@protocolsAll, "BytesR", ["login", "banner", "cmd", "retrieve", "submit", "logout" ]);
genHTMLReportGraph ("writeBytes",
"Bytes written", "Bytes/sec",
\@protocolsAll, "BytesW", ["login", "banner", "cmd", "retrieve", "submit", "logout" ]);
genHTMLReportGraph ("msgTime",
"Message transfer time", "Seconds per message",
\@protocols, "Time", ["cmd", "submit", "retrieve" ]);
genHTMLReportGraph ("setupTime",
"Connection setup time", "Seconds per connection",
\@protocols, "Time", ["conn", "banner", "login" ]);
genHTMLReportGraph ("blocks",
"Number of mailstone blocks executed", "Blocks/sec",
\@protocolsAll, "", ["blocks" ]);
}
if ($params{ADDGRAPHS}) { # pick up additional graphs
my @graphs = ();
readWorkloadFile ($params{ADDGRAPHS}, \@graphs);
foreach $section (@graphs) {
next unless ($section->{sectionTitle} =~ /GRAPH/i);
my $name = $section->{sectionParams};
$name =~ s/name=\s*//; # strip off initial bit
my @varlist = split (/[\s,]+/, $section->{VARIABLES});
$graphCount++;
genHTMLReportGraph ($name, $section->{TITLE}, $section->{LABEL},
($section->{FIELD} =~ /Time/o)
? \@protocols : \@protocolsAll,
$section->{FIELD}, \@varlist);
}
}
genHTMLReportEnd();
return 1;

View File

@@ -1,205 +0,0 @@
#!/bin/ksh
# global configuration parameters.
# Fill in defaults for anything that is not already set
# Look for testname$test_form, first
export test_form=${test_form:-""}
# string appended to every description
export desc_conf=${desc_conf:-""}
# extra arguments common to all tests
export extra_args=${extra_args:-""}
# error limit to abort sequence
export error_limit=${error_limit:-100}
# set this to only show what it will do
export only_show_it=${only_show_it:-0}
# time to allow the server to calm down after each run
export sleep_time=${sleep_time:-5}
# This is where we store the important runs
export save_dir=${save_dir:-"results.save"}
# Basic sanity test
if [[ ! -x /usr/bin/perl || ! -f .license ]] ; then # see if setup was ever run
echo "Critical files are missing. Run setup."
exit 2;
fi
find_timestamp () { # find the timestamp string from latest run
#OLD timestamp=`ls -d results/[0-9]*.[0-9][0-9][0-9][0-9]?(a-z) | tail -1`
# list all directories with the timestamp pattern
timestamp=`echo results/[0-9]*.[0-9][0-9][0-9][0-9]?([a-z])`
# strip all but the last one
timestamp=${timestamp##* }
# strip the top directory name out
timestamp=${timestamp#results/}
# return it
echo $timestamp
return 0
}
# copy last mailstone run from the current directory to good results directory
save_run () {
[[ -d $save_dir ]] || \
mkdir $save_dir
[[ $only_show_it -gt 0 ]] && return 0 # dont do anything important
if [[ -n "$last_timestamp" && -d "results/$last_timestamp/" ]] ; then
cp -pR results/$last_timestamp $save_dir/
# index probably has lots of extra junk, but its better than nothing
cp -pf results/index.html $save_dir/
fi
}
# Display and run a command. Skip if in only_show mode.
run () {
if [[ $only_show_it -gt 0 ]] ; then
echo "Would run:" "$@"
return 0
fi
echo "Running: " "$@"
"$@"
}
# Sleep. Skip if in only_show mode.
run_sleep () {
if [[ $only_show_it -gt 0 ]] ; then
echo "Would sleep:" "$@"
return 0
fi
echo "Sleeping: " "$@"
sleep "$@"
}
# for readability, just use sleep
alias sleep=run_sleep
# This runs the actual mstone run and check for errors
# compress tmp files
# Usage: run_test testname description [args...]
run_test () {
testname="$1"; shift;
desc="$1"; shift;
# see if a special version of this test exists
if [[ -f conf/$testname$test_form.wld ]] ; then
testname=$testname$test_form
fi
#oldtimestamp=`find_timestamp`
if [[ $only_show_it -gt 0 ]] ; then
echo "Would run:" mstone $testname -b "$desc $desc_conf" $extra_args "$@"
if [[ ! -f conf/$testname.wld ]] ; then
echo "Configuration Error: No such test $testname"
fi
return 0
fi
echo "\n##########################################################"
if [[ ! -f conf/$testname.wld ]] ; then
echo "CONFIGURATION ERROR: No such test $testname"
exit 2
fi
echo "\nRunning:" mstone $testname -b "$desc $desc_conf" $extra_args "$@"
# We actually bypass the mstone script
/usr/bin/perl -Ibin -- bin/mailmaster.pl -w conf/$testname.wld -b "$desc $desc_conf" $extra_args "$@"
stat=$?
# BUG if another test is running at the same time, this is wrong
timestamp="`find_timestamp`"
# test failed to even run
if [[ $stat -ne 0 ]]
then
echo "ABORT! Test failed to start"
[[ -n "$mail_list" ]] && \
mail_series "DotCom Failed run: `date`" "$mail_list"
exit 2
fi
# compress tmp files. get the csv files, too.
gzip tmp/$timestamp/* results/$timestamp/*.csv
# stick the timestamp someplace global for a save_run
export last_timestamp=$timestamp
export all_timestamps="$all_timestamps $timestamp"
# save the results
save_run
# see how many errors we hit
totline=`grep 'Total:total ' results/$timestamp/results.txt`
# strip label and first field
errors=${totline##+([+-z])+( )+([+-9])+( )}
# strip trailing fields
errors=${errors%% *}
echo "" # space things out
if [[ $errors -gt $error_limit ]] ; then
echo "ABORT! Errors ($errors) exceed error limit ($error_limit)"
[[ -n "$mail_list" ]] && \
mail_series "DotCom Aborted run: `date`" "$mail_list"
exit 1
fi
echo "Run completed OK ($errors errors). Timestamp $timestamp"
sleep $sleep_time
return 0
}
# Usage: mail_series subject "address,address,..."
mail_series () {
subject=$1; shift
file=/tmp/series$$.tar
if [[ $only_show_it -gt 0 ]] ; then
echo "Would mail results about $subject" to "$@"
return 0
fi
echo "Mailing results about $subject" to "$@"
tar cf $file $save_dir/index.html
for f in $all_timestamps ; do
tar rf $file $save_dir/$f
done
gzip $file
echo "$all_timestamps" | uuenview -b -30000 -s "$subject" -m "$@" $file.gz
rm -f $file.gz
}
# parse command line arguments
while [[ -n "$1" ]]
do
case $1 in
# -n mode, do not execute, just show
-n) only_show_it=1; shift;;
# set test form
-f) shift; test_form=$1; shift;;
# set test extra description
-d) shift; desc_conf=$1; shift;;
# Rest are to be passed in exactly
--) shift; break;;
#default, pick up as an extra arg
*) extra_args="$extra_args $1"; shift;;
esac
done

View File

@@ -1,464 +0,0 @@
#!/usr/bin/env perl
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Netscape Mailstone utility,
# released March 17, 2000.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1999-2000 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Dan Christian <robodan@netscape.com>
# Marcel DePaolis <marcel@netcape.com>
# Jim Salter <jsalter@netscape.com>
#
# Alternatively, the contents of this file may be used under the
# terms of the GNU Public License (the "GPL"), in which case the
# provisions of the GPL are applicable instead of those above.
# If you wish to allow use of your version of this file only
# under the terms of the GPL and not to allow others to use your
# version of this file under the NPL, indicate your decision by
# deleting the provisions above and replace them with the notice
# and other provisions required by the GPL. If you do not delete
# the provisions above, a recipient may use your version of this
# file under either the NPL or the GPL.
#####################################################
# usage: setup.pl setup|cleanup|checktime|timesync -m machine_file
# message files are expected to be in ./data/ and end with ".msg"
print "Netscape Mailstone.\nCopyright (c) 1997-2000 Netscape Communications Corp.\n";
$mode = shift; # mode must be first
# this parses the command line for -m machinefile
# also sets many defaults
do 'args.pl'|| die $@;
sub warn_system;
sub die_system;
parseArgs(); # parse command line
setConfigDefaults(); # setup RSH and RCP
$cpcmd = "cp"; # copy files... dir
$rmcmd = "rm -f"; # remove files...
die "Must specify workload file" unless (@workload);
# Add or change client machines
sub configClients {
print "\n You can enter multiple machines like this: host1,host2\n";
my @d = <bin/*/bin>;
if (@d) {
my @d2;
foreach (@d2 = @d) { s/^bin\/// }
foreach (@d = @d2) { s/\/bin$// }
print " These OS versions are available:\n@d\n";
}
foreach $section (@workload) {
next unless ($section->{sectionTitle} =~ /CLIENT/i);
my $slist = $section->{sectionParams};
$slist =~ s/HOSTS=\s*//; # strip off initial bit
my $arch = "default OS";
$arch = $section->{ARCH} if ($section->{ARCH});
print "\nWhat is the name of the client(s) for $arch [$slist]: ";
my $ans = <STDIN>; chomp $ans;
if ($ans) {
$ans =~ s/\s//g; # strip any whitespace
fileReplaceText ($params{WORKLOAD}, "<CLIENT", $slist, $ans);
}
}
while (1) {
print "\nWhat additional client(s) [none]: ";
my $ans = <STDIN>; chomp $ans;
last unless ($ans); # done
last if ($ans =~ /^none$/i);
$ans =~ s/\s//g; # strip any whitespace
my $block = "\n<CLIENT HOSTS=$ans>\n";
print "What OS type [default]: ";
my $ans = <STDIN>; chomp $ans;
$block .= " Arch\t$ans\n" if ($ans && !($ans =~ /^default$/i));
$block .= "</CLIENT>\n";
fileInsertAfter ($params{WORKLOAD}, "^</CLIENT>", $block);
}
}
# Create a user ldif file
sub configUserLdif {
my $name = "conf/$defaultSection->{SERVER}.ldif";
print "\nWhat file to you want to create [$name]? ";
$ans = <STDIN>; chomp $ans;
$name = $ans if ($ans);
my $mode = "users";
print "\nDo you want to create a broadcast account [y]? ";
$ans = <STDIN>;
$mode .= " broadcast" unless ($ans =~ /^n/i);
my $basedn = $defaultSection->{SERVER}; # pick a default
$basedn =~ s/^.*?\.//; # strip off before first dot
$basedn = "o=$basedn";
print "\nWhat is LDAP base DN [$basedn]? ";
$ans = <STDIN>; chomp $ans;
$basedn = $ans if ($ans);
my $args = $params{MAKEUSERSARGS};
print "\n Common additional makeusers arguments:\n";
print "\t-s storeName -x storeCount \tMultiple store partitions\n";
print "\t[-3|-4] \tConfigure for NSMS 3.x or 4.x\n";
print "Any extra arguments to makeusers [$args]? ";
$ans = <STDIN>; chomp $ans;
$args = $ans if ($ans);
my $perlbin = "/usr/bin/perl";
$params{DEBUG} &&
print "$perlbin -Ibin -- bin/makeusers.pl $mode -w $params{WORKLOAD} -b '$basedn' -o $name $args\n";
print "\nGenerating $name (this can take a while)\n";
warn_system "$perlbin -Ibin -- bin/makeusers.pl $mode -w $params{WORKLOAD} -b '$basedn' -o $name $args";
print "LDIF generation complete. See $name\n";
print "\tSee the manual or INSTALL to create users using the LDIF file.\n";
}
# This uses a match pattern plus text to text replacements.
# Could make all changes and then write out new workload
# You would have to be carefull about sections with multi-line support.
sub configWorkload {
my $ans;
print "\nWhat is the name of the mail host [$defaultSection->{SERVER}]: ";
$ans = <STDIN>; chomp $ans;
if ($ans) {
fileReplaceText ($params{WORKLOAD},
"(SERVER|SMTPMAILFROM|ADDRESSFORMAT)",
$defaultSection->{SERVER}, $ans);
$defaultSection->{SERVER} = $ans; # needed for ldif generation
}
print "\nWhat is the user name pattern [$defaultSection->{LOGINFORMAT}]: ";
$ans = <STDIN>; chomp $ans;
if ($ans) {
fileReplaceText ($params{WORKLOAD},
"(LOGINFORMAT|ADDRESSFORMAT)",
$defaultSection->{LOGINFORMAT}, $ans);
$ans =~ s/%ld/0/; # create smtpMailFrom user
my $olduser = $defaultSection->{SMTPMAILFROM};
$olduser =~ s/@.*$//; # strip off after @
fileReplaceText ($params{WORKLOAD},
"SMTPMAILFROM",
$olduser, $ans);
}
print "\nWhat is the password pattern [$defaultSection->{PASSWDFORMAT}]: ";
$ans = <STDIN>; chomp $ans;
fileReplaceText ($params{WORKLOAD}, "PASSWDFORMAT",
$defaultSection->{PASSWDFORMAT}, $ans);
$defaultSection->{NUMLOGINS} = 100 unless ($defaultSection->{NUMLOGINS});
print "\nHow many users [$defaultSection->{NUMLOGINS}]: ";
$ans = <STDIN>; chomp $ans;
fileReplaceText ($params{WORKLOAD}, "(NUMADDRESSES|NUMLOGINS)",
$defaultSection->{NUMLOGINS}, $ans);
$defaultSection->{FIRSTLOGIN} = 0 unless ($defaultSection->{FIRSTLOGIN});
print "\nWhat is the first user number [$defaultSection->{FIRSTLOGIN}]: ";
$ans = <STDIN>; chomp $ans;
fileReplaceText ($params{WORKLOAD}, "(FIRSTADDRESS|FIRSTLOGIN)",
$defaultSection->{FIRSTLOGIN}, $ans);
unless ($params{NT}) {
configClients ();
}
print "\nDo you want to view the edited $params{WORKLOAD} [y]? ";
$ans = <STDIN>;
unless ($ans =~ /^n/i) {
print "Here is the edited $params{WORKLOAD}:\n\n";
fileShow ($params{WORKLOAD});
print "\n";
}
print "\nDo you want to generate a user LDIF file [y]? ";
$ans = <STDIN>;
unless ($ans =~ /^n/i) {
configUserLdif ();
}
}
# See if license file has been displayed
if (($mode ne "cleanup") && (! -f ".license" )) {
fileShow ("LICENSE");
# SEAN: blow off annoying agreement message.
# print "\nDo you agree to the terms of the license? (yes/no) ";
# my $ans = <STDIN>;
# print "\n";
# unless ($ans =~ /^yes$/i) {
# print "License not agreed to.\n";
# exit 0;
# }
my ($sec, $min, $hour, $mday, $mon, $year) = localtime;
open (LIC, ">.license");
printf LIC "%04d$mon$mday$hour$min\n", $year+1900;
close (LIC);
}
if ($mode eq "config") { # re-run config
configWorkload ();
print "\nMake any additional changes to $params{WORKLOAD} and then re-run 'setup'\n";
exit 0;
} elsif ($mode ne "cleanup") { # check if configured
my $unconf = 0; # see if default values are in use
foreach $section (@workload) {
($section->{SERVER})
&& ($section->{SERVER} =~ /example\.com$/)
&& $unconf++;
($section->{SMTPMAILFROM})
&& ($section->{SMTPMAILFROM} =~ /example\.com$/)
&& $unconf++;
($section->{ADDRESSFORMAT})
&& ($section->{ADDRESSFORMAT} =~ /example\.com$/)
&& $unconf++;
last if ($unconf > 0);
}
if ($unconf > 0) {
print "Server has not been configured (example.com is an invalid address).\n";
print "Do you want to setup a simple configuration now [y]?";
my $ans = <STDIN>;
if ($ans =~ /^n/i) {
print "Re-run setup when you have edited the configuration.\n";
exit 0;
}
configWorkload ();
print "\nMake any additional changes to $params{WORKLOAD} and then re-run 'setup'\n";
exit 0;
}
}
if ($mode eq "timesync") {
if ($params{NT}) {
print "Timesync has no effect on NT\n";
exit 0;
}
my ($sec, $min, $hour, $mday, $mon, $year) = localtime;
$mon += 1; # adjust from 0 based to std
$systime = sprintf ("%02d%02d%02d%02d%04d.%02d",
$mon, $mday, $hour, $min, 1900+$year, $sec);
} elsif ($mode eq "checktime") {
if ($params{NT}) { # if running on NT, then only single client
print "Checktime not needed on NT\n";
exit 0;
}
mkdir ("$resultbase", 0775);
mkdir ("$tmpbase", 0775);
foreach $section (@workload) {
next unless ($section->{sectionTitle} =~ /CLIENT/i);
my $slist = $section->{sectionParams};
$slist =~ s/HOSTS=\s*//; # strip off initial bit
foreach $cli (split /[\s,]/, $slist) {
open MAKEIT, ">$tmpbase/$cli.tim";
close MAKEIT;
}
}
} elsif (($mode eq "setup") || ($mode eq "cleanup")) {
@msgs = <data/*.msg>;
foreach (@files = @msgs) { s/data\/// }
print "Found these message files:\n@files\n\n";
if ($params{NT}) { # handle NT localhost here
exit 0 if ($mode =~ /cleanup$/);
my $clipath = "bin/WINNT4.0/bin/mailclient.exe";
print "Copying $clipath and message files to $cli\n";
die_system "copy $clipath $params{TEMPDIR}";
foreach $f (@files) {
die_system "copy $f $params{TEMPDIR}";
}
exit 0; # without perl:fork, no more to do
}
}
# iterate over every client in the testbed, complete the cmd and rsh
foreach $section (@workload) {
next unless ($section->{sectionTitle} =~ /CLIENT/i);
my $slist = $section->{sectionParams};
$slist =~ s/HOSTS=\s*//; # strip off initial bit
foreach $cli (split /[\s,]/, $slist) {
my $rsh = ($section->{RSH}) ? $section->{RSH} : $params{RSH};
my $rcp = ($section->{RCP}) ? $section->{RCP} : $params{RCP};
my $tempdir;
if ($section->{TEMPDIR}) {
$tempdir = $section->{TEMPDIR};
} elsif ($params{TEMPDIR}) {
$tempdir = $params{TEMPDIR};
}
my $cliarch = $section->{ARCH};
# presumed architecture for bin/mailclient on localhost:
my $local_arch = `bin/nsarch`;
chomp $local_arch;
# Try to determine arch if it hasn't been explicitly set.
if (!$cliarch) {
if ($cli =~ /localhost/) {
$cliarch = `bin/nsarch`;
chomp $cliarch;
} else {
$cliarch = `$rsh $cli sh < bin/nsarch`;
chomp $cliarch;
}
}
# most time critical first
if ($mode eq "timesync") {
next if ($cli =~ /^localhost$/i); # dont reset our own time
# run all these in parallel to minimize skew
next if ($cliarch eq "NT4.0");
forkproc ($rsh, $cli, "date $systime");
}
elsif ($mode eq "checktime") {
# run all these in parallel to minimize skew
forkproc ($rsh, $cli, ($cliarch eq "NT4.0")
? "time" : "date",
"/dev/null", "$tmpbase/$cli.tim");
}
elsif ($mode eq "setup") {
my ($clibin) = split /\s/, (($section->{COMMAND})
? $section->{COMMAND}
: $params{CLIENTCOMMAND});
my $clipath = ''; # do nothing by default
# Look for architecture-specific binary.
if ($cliarch) {
# fallback to just os-name if we can't find an exact match.
my $approx = $cliarch;
$approx =~ s/^(\D+).*/$1/;
my $approx_bin = <"bin/${approx}*/bin/$clibin">;
if (-x "bin/$cliarch/bin/$clibin") {
# exact match.
$clipath = "bin/$cliarch/bin/$clibin";
} elsif (-x $approx_bin) {
# approximate match
$clipath = $approx_bin;
} elsif ($local_arch =~ /^$approx/) {
# same arch as localhost
$clipath = "bin/mailclient";
} else {
print STDERR
"Requested OS $cliarch for $cli not found. ",
"Not copying binary.\n";
}
} else {
# arch not found
print STDERR "Cannot determine architecture for $cli. ",
"Not copying binary.\n";
}
# See if we have anything to copy:
if ("$clipath @files" !~ /\S/) {
print STDERR "Nothing to copy to $cli. Skipping.\n";
next;
}
my $rdir = ($tempdir) ? "$tempdir/" : ".";
# chmod so that the remote files can be easily cleaned up
my $rcmd = "chmod g+w @files $clibin; uname -a";
$rcmd = "cd $tempdir; " . $rcmd if ($tempdir);
$rdir =~ s!/!\\!g if ($cliarch eq "NT4.0");
if ($cli =~ /^localhost$/i) {
die "TEMPDIR must be set for 'localhost'\n"
unless ($tempdir);
die "Invalid local NT copy. Should never get here.\n"
if ($cliarch eq "NT4.0"); # should never happen
print "Copying $clipath and message files to $rdir\n";
die_system ("$cpcmd @msgs $clipath $rdir");
die_system ($rcmd);
} else {
print "$rcp $clipath @msgs $cli:$rdir\n" if ($params{DEBUG});
print "Copying $clipath and message files to $cli:$rdir\n";
warn_system (split (/\s+/, $rcp), $clipath, @msgs, "$cli:$rdir");
next if ($cliarch eq "NT4.0"); # chmod not valid
print "rcmd='$rcmd'\n" if ($params{DEBUG});
die_system (split (/\s+/, $rsh), $cli, $rcmd);
}
print "\n";
}
elsif ($mode eq "cleanup") {
if ($params{DEBUG}) { # get debug files
print "Cleaning up debug files on $cli\n";
my $rcmd = ($cliarch eq "NT4.0") ? "DEL" : "$rmcmd";
$rmcmd .= " mstone-debug.[0-9]*";
$rcmd = "cd $tempdir; " . $rcmd if ($tempdir);
$rcmd =~ s/;/&&/g if ($cliarch eq "NT4.0");
if ($cli =~ /^localhost$/i) {
die "TEMPDIR must be set for 'localhost'\n"
unless ($tempdir);
warn_system ($rcmd);
} else {
warn_system (split (/\s+/, $rsh), $cli, $rcmd);
}
} else {
print "Cleaning $cli\n";
my $rcmd = ($cliarch eq "NT4.0") ? "DEL" : "$rmcmd";
$rcmd .= " $clibin @files";
$rcmd = "cd $tempdir; " . $rcmd if ($tempdir);
$rcmd =~ s/;/&&/g if ($cliarch eq "NT4.0");
if ($cli =~ /^localhost$/i) {
die "TEMPDIR must be set for 'localhost'\n"
unless ($tempdir);
warn_system ($rcmd);
} else {
warn_system (split (/\s+/, $rsh), $cli, $rcmd);
}
}
}
else {
die "Couldn't recognize mode $mode!\n";
}
}
}
# wait for children to finish
if (($mode eq "timesync") || ($mode eq "checktime")) {
$pid = wait();
while ($pid != -1) {
$pid = wait();
}
}
# Print the results of the time checks
if ($mode eq "checktime") {
print "Time from each client:\n";
foreach $section (@workload) {
next unless ($section->{sectionTitle} =~ /CLIENT/i);
my $slist = $section->{sectionParams};
$slist =~ s/HOSTS=\s*//; # strip off initial bit
foreach $cli (split /[\s,]/, $slist) {
open TIMEFILE, "$tmpbase/$cli.tim"
|| warn "Counldn't open $tmpbase/$cli.tim\n";
printf "%32s: ", $cli;
while (<TIMEFILE>) { print; last;} # single line (2 on NT)
close(TIMEFILE);
unlink "$tmpbase/$cli.tim";
}
}
}

View File

@@ -1,280 +0,0 @@
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Netscape Mailstone utility,
* released March 17, 2000.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s): Sean O'Rourke <sean@sendmail.com>
* Thom O'Connor <thom@sendmail.com>
* Sendmail, Inc.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License Version 2 or later (the "GPL"), in
* which case the provisions of the GPL are applicable instead of
* those above. If you wish to allow use of your version of this file
* only under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice and
* other provisions required by the GPL. If you do not delete the
* provisions above, a recipient may use your version of this file
* under either the NPL or the GPL.
*/
use Thread qw(async);
use FileHandle qw(_IOLBF);
use Socket;
use strict;
use Getopt::Long;
# options
my $maxconn = SOMAXCONN;
my $t_banner = 0;
my $t_from = 0;
my $t_rcpt = 0;
my $t_dot = 0;
my $port = 25;
my $cs = '';
my $log = '';
my $proto = getprotobyname('tcp');
# statistics
my ($cmds, $errs, $bytesw, $bytesr, $msgs);
GetOptions('maxconn:i' => \$maxconn,
'banner-delay:i' => \$t_banner,
'from-delay:i' => \$t_from,
'rcpt-delay:i' => \$t_rcpt,
'dot-delay:i' => \$t_dot,
'log:s' => \$log,
'checksums:s' => sub { use Digest::MD5; $cs = $_[0]; })
|| &usage;
if (@ARGV == 1) {
($port) = @ARGV;
}
if ($log) {
if (open(LOG, ">$log")) {
print STDERR "Logging messages to $log\n";
} else {
warn ("Cannot open logfile $log\n");
$log = '';
}
}
socket(S, PF_INET, SOCK_STREAM, $proto) || die $!;
setsockopt(S, SOL_SOCKET, SO_REUSEADDR, pack("l", 1)) || die $!;
(bind(S, sockaddr_in($port, INADDR_ANY))
&& listen(S, $maxconn))
|| die $!;
my $addr;
my $fh = new FileHandle;
my $cnt = 0;
$SIG{INT} = sub { close(LOG); print STDERR "done\n"; exit 0; };
while(my $addr = accept($fh, S)) {
if (++$cnt % 100 == 0) {
print STDERR "$cnt\r";
}
my $thr = async { do_smtp($addr, $fh); };
$thr->join;
$fh = new FileHandle;
}
sub usage
{
print STDERR <<EOS;
Usage: $0 [options] [port]
EOS
exit -1;
}
sub netline
{
my $fh = shift;
my $line = $fh->getline;
$line =~ s/\r\n$// if $line;
$line;
}
sub millisleep
{
my $t = shift;
select(undef, undef, undef, $t) if $t > 0;
}
sub netprint($@)
{
my ($fh, @stuff) = @_;
foreach (@_) {
s/([^\r])\n/$1\r\n/g;
$fh->print($_);
}
}
sub do_smtp
{
my ($addr, $s) = @_;
my $buf;
my ($port, $iaddr) = sockaddr_in($addr);
my $name = gethostbyaddr($iaddr, AF_INET);
$s->setvbuf($buf, _IOLBF, 1024);
millisleep($t_banner);
$s->print("220 wazzup, bro?\r\n");
my %state = ('conn' => $s,
'host' => $name);
my %funcs = ('helo' => \&do_helo,
'ehlo' => \&do_helo,
'word' => \&do_helo,
'quit' => \&do_quit,
'latr' => \&do_quit,
'mail' => \&do_from,
'rcpt' => \&do_rcpt,
'data' => \&do_data,
'rset' => \&do_ok,
'vrfy' => \&do_ok,
'noop' => \&do_ok,
);
while (my $line = netline($s))
{
my ($cmd, $arg) = ($line =~ /^\s*(\S+)\s*(.*)$/);
die "cmd = `$cmd'" unless ($cmd = lc($cmd));
# fail 1% of commands
if ($funcs{$cmd}) {
&{$funcs{$cmd}}(\%state, $cmd, $arg, \%funcs);
} else {
$s->print("500 5.0.0 no. Just... no.\r\n");
}
}
return 0;
}
sub already_said_that
{
my ($state, $cmd, $arg) = @_;
$state->{conn}->print("503 5.0.0 Dude, you already said that.\r\n");
}
sub do_helo
{
my ($state, $cmd, $arg) = @_;
$state->{helohost} = $arg;
die unless $cmd;
if ($cmd eq 'helo') {
if ($arg eq $state->{host}) {
$state->{conn}->print("221 hello Mr. Honest\r\n");
} else {
$state->{conn}->print("221 We know where you live, $state->{iaddr}\r\n");
}
} elsif ($cmd eq 'ehlo') {
my $esmtp = <<EOS;
250-localhost is pleased to make your acquaintance, and offers:
250 8bitmime
EOS
if ($arg) {
netprint($state->{conn}, $esmtp);
} else {
$state->{conn}->print("501 5.0.0 tell me more...\r\n");
return;
}
} else {
$state->{conn}->print("221 2.0.0 peace brother\r\n");
}
}
sub do_quit
{
my ($state, $cmd) = @_;
$state->{conn}->print( "221 2.0.0 drop in any time\r\n");
close ($state->{conn});
}
sub do_from
{
my ($state, $cmd, $args, $funcs) = @_;
millisleep($t_from);
$state->{conn}->print( "250 2.1.0 Okay, keep talking\r\n");
$funcs->{rcpt} = \&do_rcpt;
}
sub do_rcpt
{
my ($state, $cmd, $args, $funcs) = @_;
my ($rcpt) = ($args =~ /to\:\s*(.+)/i);
millisleep($t_rcpt);
$state->{conn}->print("250 2.1.5 ${rcpt}'s cool\r\n");
$funcs->{data} = \&do_data;
}
sub do_data
{
my ($state, $cmd, $args, $funcs) = @_;
$state->{conn}->print( "354 up to the dot...\r\n");
if ($cs) {
my $line;
my $md5 = Digest::MD5->new;
# skip headers
header: while ($_ = netline($state->{conn})) {
last header if /^$/;
last body if /^\.$/;
}
body: while ($_ = $state->{conn}->getline) {
if (/^=CS=MD5=(.+)\r/) {
my $sum = $1;
my $end = netline($state->{conn});
if ($end ne '.') {
print STDERR "Fake checksum?: $sum\n";
while (netline($state->{conn}) ne '.') { }
} elsif (lc($sum) eq lc($md5->hexdigest)) {
# print STDERR "MD5 sum OK.\n";
} else {
print STDERR "MD5 sum mismatch: $sum, ",
$md5->hexdigest, "\n";
}
last body;
} elsif (/^\.\r$/) {
print STDERR "no checksum\n" if $cs =~ /^r/;
last body;
}
print LOG $_ if $log;
$md5->add($_);
}
print LOG ".\r\n" if $log;
} else {
local ($/) = "\r\n.\r\n";
$state->{conn}->getline;
}
millisleep($t_dot);
if (rand() % 100 == 0) {
$state->{conn}->print("451 ohshit\r\n");
} else {
$state->{conn}->print("250 2.0.0 I will deliver\r\n");
}
}
sub do_ok
{
my ($state) = @_;
$state->{conn}->print("220 uhhuh\r\n");
}

View File

@@ -1,825 +0,0 @@
# util.pl -- utilities which used to live in bin/args.pl
sub my_system {
my ($file, $line);
$file = shift;
$line = shift;
my $ret;
if (($ret = system(@_)) != 0) {
my $msg = "$file:$line: @_\n\t";
my ($excode, $sig, $cored) = ($ret >> 8, $ret & 127, $ret & 128);
if ($sig) {
$msg .= "died with signal $sig";
$msg .= ' (core dumped)' if ($cored);
$msg .= "\n";
} else {
$msg .= "exited abnormally with code $excode\n";
}
return $msg;
}
undef;
}
sub warn_system {
my ($pack, $file, $line) = caller;
my $msg = my_system($file, $line, @_);
warn $msg if $msg;
}
sub die_system {
my ($pack, $file, $line) = caller;
my $msg = my_system($file, $line, @_);
die $msg if $msg;
}
# Utility functions
# Create a unique hash array. Programming Perl, 2nd edition, p291 (p217?)
package ArrayInstance;
sub new {
my $type = shift;
my %params = @_;
my $self = {};
return bless $self, $type;
}
package main;
# run a command in the background, return its PID
# Uses fork: will not run on NT in perl 5.004
# if the server is "localhost", ignore the rcmd part
# if stdin, stdout, and/or stderr is set, redirect those for the sub process
sub forkproc {
my $rcmd = shift;
my $server = shift;
my $command = shift;
my $stdin = shift;
my $stdout = shift;
my $stderr = shift;
if (my $pid = fork()) {
return $pid; # parent
}
# rest of this is in the child
if ($stdin) { # redirect stdin if needed
close (STDIN);
open STDIN, "<$stdin"
|| die "Couldn't open $stdin for input\n";
}
if ($stdout) { # redirect stdout if needed
close (STDOUT);
open STDOUT, ">>$stdout"
|| die "Couldn't open $stdout for output\n";
}
if ($stderr) { # redirect stderr if needed
close (STDERR);
open STDERR, ">>$stderr"
|| die "Couldn't open $stderr for output\n";
}
if ($server =~ /^localhost$/i) {
exec $command;
die "Coundn't exec $command:$!\n";
} else {
exec split (/\s+/, $rcmd), $server, $command;
die "Coundn't exec $rcmd $server $command:$!\n";
}
}
# Relocate file to tmp directory (if it is in the results directory),
# and put a ~ on the end of it.
# ASSUMES tmp and results are on the same partition (on NT, same drive).
# Usage: fileBackup (filename)
sub fileBackup {
my $filename = shift;
my $bfile = $filename;
(-f $filename) || return 0; # file doent exist
$bfile =~ s/$resultbase/$tmpbase/; # move to tmp
$bfile .= "~"; # indicate that this is a backup
(-f $bfile) && unlink ($bfile);
#print "Backing up $filename to $bfile\n"; # DEBUG
rename ($filename, $bfile) || unlink ($filename);
}
# Insert text into a file after a tagline
# fileInsertAfter (filename, tagstring, newtext)
sub fileInsertAfter {
my $filename = shift || die "fileInsertAfter: missing filename";
my $tagline = shift || die "fileInsertAfter: missing tagline";
my $newtext = shift || die "fileInsertAfter: missing text";
my $foundit = 0;
open(OLD, "<$filename") ||
open(OLD, "gunzip -c $filename |") ||
die "fileInsertAfter: Could not open input $filename: $!";
open(NEW, ">$filename+") ||
die "fileInsertAfter: Could not open output $filename+: $!";
while (<OLD>) {
print NEW $_; # copy (including tagline)
next unless (/$tagline/); # matched tagline
print NEW $newtext; # insert new text
$foundit++;
last; # only change first occurance
}
if ($foundit) { # copy rest of file
while (<OLD>) {
print NEW $_;
}
}
close (OLD);
close (NEW);
if ($foundit) {
fileBackup ($filename);
rename ("$filename+", "$filename");
#print "Updated $filename\n"; # DEBUG
return $foundit;
} else {
($params{DEBUG}) && print "No change to $filename\n"; # DEBUG
unlink ("$filename+");
return 0;
}
}
# Do text for text replacements in a file.
# Perl wildcards are automatically quoted.
# fileReplace (filename, matchPat, oldtext, newtext)
sub fileReplaceText {
my $filename = shift || die "fileReplaceText: missing filename";
my $tagline = shift || die "fileReplaceText: missing tagline ($filename)";
my $oldtext = shift;
my $newtext = shift;
my $foundit = 0;
return if ($newtext eq ""); # nothing to do
return if ($oldtext eq ""); # nothing can be done
open(OLD, "<$filename") ||
open(OLD, "gunzip -c $filename |") ||
die "fileReplaceText: Could not open input $filename: $!";
open(NEW, ">$filename+") ||
die "fileReplaceText: Could not open output $filename+: $!";
$oldtext =~ s/([][{}*+?^.\/])/\\$1/g; # quote regex syntax
while (<OLD>) {
if (/$tagline/i) { # matched tagline
$foundit++;
s/$oldtext/$newtext/; # do the replace
}
print NEW $_;
}
close (OLD);
close (NEW);
if ($foundit) {
fileBackup ($filename);
rename ("$filename+", "$filename");
#print "Updated $filename\n"; # DEBUG
return $foundit;
} else {
($params{DEBUG}) && print "No change to $filename\n"; # DEBUG
unlink ("$filename+");
return 0;
}
}
# copy a file to a new name. Handles possible compression. OS independent.
# fileCopy (filename, newname)
sub fileCopy {
my $filename = shift || die "fileReplaceText: missing filename";
my $newname = shift || die "fileReplaceText: missing newname ($filename)";
open(OLD, "<$filename") ||
open(OLD, "gunzip -c $filename |") ||
die "fileReplaceText: Could not open input $filename: $!";
open(NEW, ">$newname") ||
die "fileReplaceText: Could not open output $newname: $!";
while (<OLD>) { # copy it
print NEW $_;
}
close (OLD);
close (NEW);
return 0;
}
# display a file to STDOUT. Handles possible compression
sub fileShow {
my $filename = shift || die "fileShow: missing filename";
open(SHOWIT, "<$filename") ||
open(SHOWIT, "gunzip -c $filename.gz |") ||
die "fileShow: Couldn't open $filename: $!";
while (<SHOWIT>) { print; }
close(SHOWIT);
}
# sub function to figure time extents
# (start, end) = dataMinMax counterName \@protocols oldstarttime oldendtime
# Use 0 for uninitialized start or end
sub dataMinMax {
my $name = shift;
my $protos = shift;
my $start = shift;
my $end = shift;
# make global
# create the plot script and data files
# Figure out the encompassing time extent
foreach $p (@$protos) { # create the plot data files
my @times = sort numeric keys %{ $graphs{$p}->{$name}};
if ($#times <= 0) {
next;
}
if (($start == 0) || ($times[0] < $start)) {
$start = $times[0];
}
if (($end == 0) || ($times[0] > $end)) {
$end = $times[$#times];
}
}
#printf ("Data $name start=$start end=$end (%d points)...\n",
# $end - $start);
return ($start, $end);
}
# simple function to formatted a number into n, n K, n M, or n G
sub kformat {
my $n = shift;
my $r = "";
if ($n > (1024*1024*1024)) {
$r = sprintf "%.2fG", $n / (1024*1024*1024);
} elsif ($n > (1024*1024)) {
$r = sprintf "%.2fM", $n / (1024*1024);
} elsif ($n > 1024) {
$r = sprintf "%.2fK", $n / 1024;
} else {
$r = sprintf "%d ", $n;
}
return $r;
}
# simple function to formatted a time into Ns, Nms, or Nus
# the goal is to make a table of timss uncluttered and easy to read
# I dont convert to minutes or hours because the non-1000x multipliers
# are hard to back solve in your head for comparisons
sub tformat {
my $n = shift;
my $r = "";
if ($n == 0.0) {
$r = "0.0"; # make exactly 0 explicit
} elsif ($n < 0.001) {
$r = sprintf "%.2fus", $n * 1000 * 1000;
} elsif ($n < 1.0) {
$r = sprintf "%.2fms", $n * 1000;
} elsif ($n >= 1000.0) {
$r = sprintf "%.0fs", $n;
} elsif ($n >= 100.0) {
$r = sprintf "%.1fs", $n;
} else {
$r = sprintf "%.3fs", $n;
}
return $r;
}
#Usage: commify (1234567) returns 1,234,567
sub commify { # perl cookbook p64-65
my $text = reverse $_[0];
$text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
return scalar reverse $text;
}
# subroutine to enable numeric sorts. Programming Perl p218
# Use: sort numeric ...
sub numeric { $a <=> $b; }
# on NT, turn slash to backslash, then print. Else print.
sub pathprint {
my $str = shift;
$str =~ s!/!\\!g if ($params{NT}); # turn slash to back slash
print $str;
}
# figureTimeNumber number
# Given an number like: 60m, 1h, 100s, 4d, 200
# Return 60, 1, 100, 4, 200
sub figureTimeNumber {
my $arg = shift;
($arg =~ /([0-9]+)(s|sec|second|seconds|m|min|minute|minutes|h|hr|hour|hours|d|day|days)$/i)
&& return $1;
return $arg; # return default
}
# figureTimeUnits number, default
# Given an number like: 60m, 1h, 100s, 4d
# Return a string of minutes, hours, seconds, days
# Else return the second argument
sub figureTimeUnits {
my $arg = shift;
($arg =~ /(s|sec|second|seconds)$/i) && return "seconds";
($arg =~ /(m|min|minute|minutes)$/i) && return "minutes";
($arg =~ /(h|hr|hour|hours)$/i) && return "hours";
($arg =~ /(d|day|days)$/i) && return "days";
return shift; # return default
}
# figureTimeSeconds number, defaultUnits
# Given an number like: 60m, 2h, 100s, 4d
# Return 60*60, 2*60*60, 100, 4*24*60*60
sub figureTimeSeconds {
my $arg = shift;
($arg =~ /([0-9]+)(s|sec|second|seconds)$/i) && return $1;
($arg =~ /([0-9]+)(m|min|minute|minutes)$/i) && return (60*$1);
($arg =~ /([0-9]+)(h|hr|hour|hours)$/i) && return (60*60*$1);
($arg =~ /([0-9]+)(d|day|days)$/i) && return (24*60*60*$1);
if ($_) {
my $def = shift;
return $arg * figureTimeSeconds ("1$def"); # return scaled by default
} else {
return $arg; # return it
}
}
# BACK COMPATIBILITY (everything now in the workload file)
# read the testbed conf file, convert to workload sections
# machine, how many processes, how many threads/proc, arch
# only the first 2 fields are required. Lines starting with # are ignored.
# You can include other files using <include conf/filename.tbd>
# exampe:
# client1 5 10 SunOS5.5.1
sub readTestbedFile {
my $filename = shift;
foreach $section (@workload) {
next unless ($section->{sectionTitle} =~ /CLIENT/i);
print "Testbed $filename skipped, clients read in workload\n";
return 1; # clients already read in workload
}
my $level = 0;
if ($_) {
$level = 1 + shift;
die "Too many nested includes ($level) in $filename!"
unless ($level < 100);
}
my $handle = "$filename$level";
open($handle, "<$filename") ||
open($handle, "gunzip -c $filename.gz |") ||
die "Couldn't open testbed $filename: $!";
while(<$handle>) {
chomp;
s/#.*//; # strip any comments from line
m/^\s*$/o && next; # continue if blank line
# handle include statement
if (m/^<(include|INCLUDE)\s+([^\s]+)\s*>/o) {
#print "Including $2 from $filename\n";
readTestbedFile ($2, $level) || die;
next;
}
# get the server name and number of processes
my @line = split(/\s+/);
# create CLIENT entry in workload
my $sparm = ArrayInstance->new();
if ($line[1]) {
$sparm->{"sectionTitle"} = "CLIENT";
$sparm->{"sectionParams"} = "HOSTS=$line[0]";
$sparm->{"PROCESSES"} = $line[1];
$sparm->{"THREADS"} = $line[2] if ($line[2]);
$sparm->{"ARCH"} = $line[3] if ($line[3]);
} else {
$sparm->{"sectionTitle"} = "MONITOR";
$sparm->{"sectionParams"} = "HOSTS=$line[0]";
$sparm->{"COMMAND"} = $line[2];
}
($params{DEBUG})
&& print "<$sparm->{sectionTitle} $sparm->{sectionParams}>\n";
push @workload, $sparm;
}
close ($handle);
}
# BACK COMPATIBILITY (everything now in the saved workload file)
# This is now only needed to process mailstone4.1 runs
sub readConfigFile {
my $filename = shift;
open(CONFIG, "<$filename") ||
open(CONFIG, "gunzip -c $filename.gz |") ||
die "Couldn't open config file $filename: $!";
while(<CONFIG>) {
chomp;
s/#.*//; # strip any comments from line
m/^\s*$/o && next; # continue if blank line
# get the property and value
my @line = split(/=/);
$params{$line[0]} = $line[1];
}
close CONFIG;
}
# read the workload file and store it as a list of hashes
# Each hash always has the fields: sectionTitle and sectionParams
# usage: readWorkloadFile filename, \@list
sub readWorkloadFile {
my $filename = shift || die "readWorkloadFile: Missing file name";
my $plist = shift || die "readWorkloadFile: Missing return list";
my $level = 0; # file inclusion level
my @handles;
my $fh = "$filename$level";
($params{DEBUG}) && print "Reading workload from $filename.\n";
open($fh, "<$filename") ||
open($fh, "gunzip -c $filename.gz |") ||
die "readWorkloadFile Couldn't open testbed $filename: $!";
$includedFiles{$filename} = 1; # mark file as included
my $sparm=0;
my $conline = "";
while($fh) {
while(<$fh>) {
s/#.*//; # strip any comments from line (quoting?)
s/\s*$//; # strip trailing white space
if ($conline) { # utilize line continue
$_ = $conline . "\\\n" . $_;
$conline = "";
}
if (m/\\$/o) { # check for quoted line continue
s/\\$//; #
$conline = $_;
next;
}
s/^\s*//; # strip initial white space
m/^$/o && next; # continue if blank line
# handle include and includeOnce statements
if ((m/^<(include)\s+(\S+)\s*>/i)
|| (m/^<(includeonce)\s+(\S+)\s*>/i)) {
my $incfile = $2;
if (($1 =~ m/^includeonce/i) && ($includedFiles{$incfile})) {
($params{DEBUG})
&& print "readWorkloadFile:includeOnce $incfile already read.\n";
next;
}
($params{DEBUG})
&& print "readWorkloadFile include $incfile from $filename.\n";
$includedFiles{$incfile} = 1; # mark file
push @handles, $fh; # push current handle on to stack
if ($level++ > 99) { # check recursion and make handles unique
die "readWorkloadFile: include level too deep: $filename $level\n";
}
$fh = "$incfile$level";
open($fh, "<$incfile") ||
open($fh, "gunzip -c $incfile.gz |") ||
die "readWorkloadFile Couldn't open testbed file $incfile: $!";
$filename = $incfile; # for error messages
next;
}
if (m!^</(\w+)>$!o) { # end of section
my $end = $1;
unless ($sparm->{"sectionTitle"} =~ /$end/i) {
die "readWorkloadFile Mismatched section $filename: $. '$sparm->{sectionTitle}' '$end'\n";
return 0;
}
($params{DEBUG}) && print "</$sparm->{sectionTitle}>\n";
push @$plist, $sparm;
$sparm = 0;
next;
}
if (m!^<(\w+)\s*(.*)>$!o) { # start of section
my $sec = $1;
my $more = $2;
if ($sparm) {
die "readWorkloadFile Missing section end $filename: $. '$sparm->{sectionTitle}'\n";
}
if ($sec =~ /CONFIG/i) { # special case, map to existing global
$sparm = \%params;
} elsif ($sec =~ /DEFAULT/i) { # special case, only one DEFAULT
if ($defaultSection) { # use existing defaultSection
$sparm = $defaultSection;
} else { # create a new one
$sparm = ArrayInstance->new();
$sparm->{"sectionTitle"} = uc $sec; # ignore case
$sparm->{"lineList"} = ();
$defaultSection = $sparm;
}
} else {
$sparm = ArrayInstance->new();
$sparm->{"sectionTitle"} = uc $sec; # ignore case
$sparm->{"lineList"} = ();
}
$sparm->{"sectionParams"} = $more; # take newest more info
($params{DEBUG})
&& print "<$sparm->{sectionTitle} $sparm->{sectionParams}>\n";
next;
}
# must be in a section, get parameters
unless ($sparm) {
die "readWorkloadFile Entry encountered outside a section $filename: $. $_\n";
return 0;
}
my ($nm, $val) = split (/[\s=]+/, $_, 2);
$nm = uc $nm; # ignore case
($params{DEBUG}) && print " $nm = $val\n";
if ($nm =~ /ACCOUNTFORMAT/) { # BACK COMPATIBILITY
print "WARNING: 'accountFormat' is obsolete. Use 'addressFormat' and 'loginFormat'\n";
$sparm->{"addressFormat"} = $val;
push @{$sparm->{"lineList"}}, "addressFormat $val";
$val =~ s/@.+$//; # strip at and everything after
$sparm->{"loginFormat"} = $val;
push @{$sparm->{"lineList"}}, "loginFormat $val";
next;
} elsif ($nm =~ /NUMACCOUNTS/) { # BACK COMPATIBILITY
print "WARNING: 'numAccounts' is obsolete. Use 'numAddresses' and 'numLogins'\n";
$sparm->{"numAddresses"} = $val;
push @{$sparm->{"lineList"}}, "numAddresses $val";
$sparm->{"numLogins"} = $val;
push @{$sparm->{"lineList"}}, "numLogins $val";
next;
} elsif ($nm =~ /BEGINACCOUNTS/) { # BACK COMPATIBILITY
print "WARNING: 'beginAccounts' is obsolete. Use 'firstAddress' and 'firstLogin'\n";
$sparm->{"firstAddress"} = $val;
push @{$sparm->{"lineList"}}, "firstAddress $val";
$sparm->{"firstLogin"} = $val;
push @{$sparm->{"lineList"}}, "firstLogin $val";
next;
}
push @{$sparm->{"lineList"}}, $_; # save lines in original order
$sparm->{$nm} = $val;
next;
}
close ($fh);
$fh = pop @handles || last; # empty include stack
$filename = $fh;
$sparm = 0; # can only include whole sections
}
return 1; # success
}
# Write out a workload list to a file
# Optionally, pass in a list of sectionTitle's it should ignore
# usage: writeWorkloadFile filename \@list [\@skipList]
sub writeWorkloadFile {
my $filename = shift || die "writeWorkloadFile: Missing file name";
my $plist = shift || die "writeWorkloadFile: Missing return list";
my $skip = shift;
my @skipH;
my $configSeen = 0;
my $defaultSeen = 0;
my @paramH;
if ($skip) {
foreach $s (@$skip) { # turn list into a hash
$skipH{(uc $s)} = $s; # fix case for index
}
}
foreach $s (@workloadParameters) { # turn list into a hash
$paramH{(uc $s)} = $s; # fix case for index
}
($params{DEBUG}) && print "Writing workload to $filename.\n";
unless (open(WORKOUT, ">$filename")) {
die "Couldn't open testbed $filename: $!";
}
foreach $sparm (@$plist) { # each hash reference in the list
if (($skip)
&& ($skipH{$sparm->{"sectionTitle"}})) {
#($params{DEBUG}) &&
#print "Skipping section $sparm->{sectionTitle}\n";
next;
}
# all CONFIG,DEFAULT sections point to the same hash, output once only
if ($sparm->{"sectionTitle"} =~ /^CONFIG$/) {
next if $configSeen;
$configSeen++;
}
if ($sparm->{"sectionTitle"} =~ /^DEFAULT$/) {
next if $defaultSeen;
$defaultSeen++;
}
if ($sparm->{sectionParams}) { # write section with extra args
print WORKOUT "<$sparm->{sectionTitle} $sparm->{sectionParams}>\n";
} else {
print WORKOUT "<$sparm->{sectionTitle}>\n";
}
if ($sparm->{"sectionTitle"} =~ /^(CONFIG|CLIENT)$/) {
# for Config or Client, output the hash to get computed config
foreach $k (sort keys %$sparm) { # output each parameter
# skip sectionTitle and sectionParams
($k =~ /^(sectionTitle|sectionParams|lineList)$/) && next;
printf WORKOUT " %s\t%s\n",
($paramH{$k}) ? $paramH{$k} : $k,
$sparm->{$k};
}
} else { # write out the line list
foreach $l (@{$sparm->{"lineList"}}) {
print WORKOUT " $l\n";
}
}
print WORKOUT "</$sparm->{sectionTitle}>\n\n";
}
close WORKOUT;
}
# Usage: getClientFilename hostname section
sub getClientFilename {
my $cli = shift || die "Missing client name";
my $section = shift || die "Missing section hash";
return "$tmpdir/$cli-$section->{GROUP}.out"
if ($params{USEGROUPS} && $section->{GROUP});
return "$tmpdir/$cli.out"
}
sub setConfigDefaults { # set CONFIG defaults
# These are set after writing out the test copy to avoid clutter
# Path to gnuplot executable
$params{GNUPLOT}="gnuplot/gnuplot"
unless ($params{GNUPLOT});
# This is the directory the client lives in
$params{TEMPDIR} = "/var/tmp"
unless($params{TEMPDIR});
# Set default remote shell
#$params{RSH} = "rsh"
$params{RSH} = "ssh"
unless($params{RSH});
# Set default remote copy
#$params{RCP} = "rcp"
$params{RCP} = "scp"
unless($params{RCP});
# Size of generated gifs
$params{CHARTHEIGHT} = 480
unless($params{CHARTHEIGHT});
$params{CHARTWIDTH} = 640
unless($params{CHARTWIDTH});
$params{CHARTPOINTS} = int (($params{CHARTWIDTH}-60)*0.8)
unless($params{CHARTPOINTS});
# The name of the remote executable
$params{CLIENTCOMMAND} = "mailclient"
unless ($params{CLIENTCOMMAND});
# Set default monitoring command
$params{MONITORCOMMAND} = "vmstat %f"
unless($params{MONITORCOMMAND});
# Set default switches to makeusers
$params{MAKEUSERSARGS} = "-4"
unless ($params{MAKEUSERSARGS});
# Figure out @protocols, this sets the report order
@protocols = ();
{
my %skipH;
foreach $s (@nonProtocolSections) { # turn list into a hash
#print "$s ";
$skipH{(uc $s)} = $s; # fix case for index
}
print "\n";
foreach $sparm (@workload) { # each hash reference in the list
next if ($skipH{$sparm->{"sectionTitle"}});
($params{DEBUG}) &&
print "Found protocol ". $sparm->{"sectionTitle"} . "\n";
push @protocols, $sparm->{"sectionTitle"};
# add to skip list so only added once
$skipH{(uc $sparm->{"sectionTitle"})} = $sparm->{"sectionTitle"};
}
}
@protocolsAll = @protocols;
push @protocolsAll, "Total";
# figure out the graphs ???
}
sub parseArgs { # get args
while (@ARGV) {
my $arg = shift(@ARGV);
if ($arg =~ /^-a$/i) { # was undocumented feature in 4.1
$params{ADDGRAPHS} = shift(@ARGV); # extra graphs
next;
}
if ($arg =~ /^-b$/i) {
$params{TITLE} = shift(@ARGV); # banner
next;
}
# BACK COMPATIBILITY (everything now in the saved workload file)
if ($arg =~ /^-c$/i) { # config file, read when encountered
my $configFile = shift(@ARGV);
readConfigFile ($configFile);
next;
}
if ($arg =~ /^-d$/i) {
$params{DEBUG}++; # Debug
next;
}
if ($arg =~ /^-h$/i) { # Help
print "Usage: -w workfile [-t time] [-r ramptime] [-l load] [-v] [-d]\n";
print "\t[-b banner] [-n notes] [-s sysconfigfile] [-a add_graphs_file]\n";
print "\t[-c configfile] [-m machinefile] [-z] [PARAM=value]...\n";
die "Usage";
}
if ($arg =~ /^-l$/i) { # "load", FIX: naming conventions
$params{CLIENTCOUNT} = shift(@ARGV); # desired client count
next;
}
# BACK COMPATIBILITY (everything now in the saved workload file)
if ($arg =~ /^-m$/i) {
$params{TESTBED} = shift(@ARGV); # testbed machines file
next;
}
if ($arg =~ /^-n$/i) {
$params{COMMENTS} = shift(@ARGV); # notes
next;
}
if ($arg =~ /^-r$/i) {
$params{RAMPTIME} = shift(@ARGV); # ramptime
next;
}
if ($arg =~ /^-s$/i) {
$params{SYSCONFIG} = shift(@ARGV); # system config html file
next;
}
if ($arg =~ /^-t$/i) {
$params{TIME} = shift(@ARGV); # test time
next;
}
if ($arg =~ /^-v$/i) {
$params{VERBOSE} = 1; # verbose mode
next;
}
if ($arg =~ /^-w$/i) { # workload file (may occur multiple times)
my $f = shift(@ARGV);
readWorkloadFile ($f, \@workload) || die "Error reading workload: $@\n";
$params{WORKLOAD} = $f;
next;
}
if ($arg =~ /^-z$/i) {
$params{NT} = 1; # NT mode
next;
}
# any other CONFIG parameter: FIELD=value
if ($arg =~ /^(\w+)=(\S.*)$/) {
my $field = uc $1;
$params{$field} = $2;
next;
}
die "Unknown argument '$arg'";
}
if ($params{NT}) { # should use Cwd module
$cwd = `cd`; # NT get current directory
$cwd = `pwd` unless ($cwd); # in case we are really on UNIX
} else {
$cwd = `pwd`; # in case we are really on UNIX
}
chomp $cwd; # strip NL
}
return 1;

View File

@@ -1,271 +0,0 @@
I. Format
II. Workload Configuration Sections
III. Report Generation Sections
---------
I. Format
---------
The config-file format is very free-form -- for example, this text is
skipped as a "comment" because it doesn't look like anything else. A
section always starts with a line ending in a colon. Everything up to
the next section, end-of-file, or `__END__' is part of the current
section.
Name/value pairs within a section are pairs starting with whitespace,
and separated by a colon followed by whitespace. So you can write
something like this
# hello there: mister foo
and it will be ignored. Had the '#' before the "hello" not been
there, the attribute name would have been `hello there' and its value
would have been `mister foo'. Leading and trailing whitespace is
skipped, but internal whitespace is perfectly OK. Note that the
"comment" character doesn't have to be a '#', but can be anything you
want (except whitespace).
Leading whitespace also denotes continued values. So
foo: blah blah
and some more words which are part of foo's value.
creates a variable named 'foo' with this value (including the \n) --
"blah blah
and some more words which are part of foo's value."
Finally, anything after '__END__' on a line by itself gets inserted
literally into each .wld file. This is the place to put <monitor>
sections.
--------------------------
II. Workload Configuration
--------------------------
Parameters with no default are required.
Messages
--------
Message attributes are defined in the `message' section.
Parameter Default Description
--------- ------- -----------
size size distribution (including headers).
recipients number of recipients
headers ~unif(10, 30) number of headers
line length 60 line length
mime 0 number of MIME parts
Users
-----
User behavior parameters are described in the `user' section.
Parameter Default Description
--------- ------- -----------
messages per day
protocol mail read
activity `DURATION each TIME' or `START - STOP'
check interval how often user checks mail when active
read messages 0 number of old msgs each user has
read time 0 how long user takes to `read' a message
keep 0 proportion of messages kept on server
connection type <unlimited> `latency = X ; bandwidth = X'
drop rate 0 proportion of connections dropped before logout
Delivery
--------
Delivery parameters are described in the `delivery' section.
Parameter Default Description
--------- ------- -----------
messages per connection 1 messages sent per SMTP session
percent remote 0 % mail going to remote host (sink)
connection type <unlimited>
fluctuation <uniform> `START - END = X % ; ...'
Test
----
The `test' section configures the number of users, the time of day to
be simulated, etc.
Parameter Default Description
--------- ------- -----------
start time of day to start sim
end end time of day.
length duration. Either length or end
must be specified.
users total user base
percent active percentage of total user base active
during test period
messages per second messages per second to delivery for
SMTP-only simulation. Either
`messages per second' or `users'
and `percent active' must be
specified.
comments <nothing> notes on test.
preparer Anonymous Name to use on reports.
date <ctime(3)>
configuration <nothing> Configuration name for report.
Environment Configuration
-------------------------
Several sections describe the test environment:
Sink
----
The `sink' section describes the remote mail sink.
Parameter Default Description
--------- ------- -----------
addressFormat smuser%ld@ Like addressFormat, but used to
generate remote addresses.
`hostname' will be appended if it
ends in `@'.
hostname host on which SMTP sink lives. Used
for remote delivery.
Server
------
The `server' section describes the mail server to be sized:
Parameter Default Description
--------- ------- -----------
smtp port 25
pop port 110
imap port 143
web port 1066
hostname Mail server
addressFormat smuser%ld@ Passed to
sprintf(recipient, addressFormat,
userNum, domainNum). If
addressFormat ends in `@', `server'
is automatically appended.
loginFormat smuser%ld@ Same as addressFormat, but used to
generate usernames.
passwdFormat twang passed to sprintf(passwd, passwdFormat,
userNum, domainNum).
firstAddress 0 first userNum for addresses
firstLogin 0 first userNum for logins
smtpMailFrom $USER@$HOST sending address on test mail.
name Printable server name for reports.
hardware Brief hardware description.
software Brief software description.
Clients
-------
The `clients' section describes test client configuration.
Parameter Default Description
--------- ------- -----------
smtp localhost client machines for SMTP
imap localhost for IMAP
pop localhost for POP3
web localhost for WEBMAIL
rsh rsh rsh program to start remote clients
rcp rcp rcp program to distribute files
command mailclient program to run to start clients
cert file file containing SSL certificate
key file file containing SSL key
Ugly Mstone details
-------------------
The `mstone' section controls low-level details of how the workload
description is translated into mstone terms. The parameters make some
assumptions about the size of both the test clients and the server, so
they may have to be tweaked. For small- to mid-size configurations,
the defaults should work.
Parameter Default Description
--------- ------- -----------
preload rate 5 msgs/sec to deliver during preload.
preload per connection 100 messages per SMTP session
preload delivery time 750 msec expected message delivery time.
used to control throttling.
preload throttle 500 msec faster/slower than expected at
which to throttle
throttleFactor 1.1 factor by which to increase/decrease
delivery rate when throttling
read rate 40 msgs/sec to read when aging old
messages.
read clients 5 test clients to use for aging
read protocol (user:protocol) protocol to age messages (e.g. imap)
rampTime 0 test rampup time
smtp connection time 10s
pop user spacing 10s MULTIPOP: time between users
pop connections per client 10 MULTIPOP: connections per client
no event queues false use 1 thread per client
max threads per proc 250
clientCount 10000 artificial global clientCount
----------------------
III. Report Generation
----------------------
There are several additional configuration sections to provide
additional information for sizing reports. The code is in
`lib/{sizing,hardware}_defaults.pm'.
QoS Constraints
---------------
Quality of Service constraints are specified in the `qos' section.
See reports/qos.in for an example. The qos section can have any
number of members. The name of each member is a description which
will appear in the sizing report. The value is a block of perl code
which should return a pair of values when evaluated in a context where
`$run' is a reference to a hash containing data on the test run to be
evaluated. The first value is a value corresponding to this
constraint which will be printed in the report. The second is true if
the run passed this constraint.
Hardware
--------
The `machine' section describes the hardware under test. Unlike
previous, simple sections, it containts nested values (as hash refs).
Parameter Description
--------- -----------
processors
speed
cache
network
storage
controllers
disks
type
speed
model
timing
OS
parameters
disks
logging
Software
--------
The `software' section describes the software under test. If multiple
types of software are in use, multiple software sections should be
specified. The only default parameter for software is the `name'.
Other parameters should describe configuration information, version,
etc.

View File

@@ -1,53 +0,0 @@
test:
start: 8 AM
length: 1h
users: ** Number of users here ***
percent active: 100
comments: auto-generated Corporate workload.
-- mail server configuration --
server:
hostname: ** SERVER **
# defaults given below --
# addressFormat: smuser%ld@
# loginFormat: smuser%ld@
# passwdFormat: twang
-- test client configuration --
clients:
smtp: ** SMTP clients here **
imap: ** IMAP clients here **
# defaults are `rsh' and `rcp'
# rsh: ssh
# rcp: scp
-- Don't edit between here and the `__END__' marker --
mstone:
rampTime: 30s
message:
size: ~lognormal(4k,4.5)
recipients: ~lognormal(1,2) : [1, ]
mime: ~binomial(0.3)
delivery:
fluctuation: 8 AM - 4 PM = 90%
user:
messages per day: 50
read messages: 50
protocol: IMAP
check interval: ~unif(5m, 8m)
connection type: latency = 0; bandwidth = 56k
keep: 100%
activity: 8 AM - 4 PM; arrival rate = ~normal(20m, 10m)
__END__
# your monitor sections go here...

View File

@@ -1,2 +0,0 @@
<client HOSTS=localhost>
</client>

View File

@@ -1,38 +0,0 @@
# common setup info for tests
# See sample.wld for detailed usage
# Information on how the test is distributed and reported
# Test independent configuration
<CONFIG>
comments Netscape MSG4.15
sysConfig conf/sample.html # File for additonal system config
# Debug with short runs and a few clients, then increase test time
# These get overridden in the test specific files (or the command line)
clientCount 5 # nominal clientCount (usually overriden)
rampTime 10s
time 30s
# each test should set a title in their CONFIG section
# This is a reminder when using old test workloads
title Need to set test title
</CONFIG>
# Specify client machines
<CLIENT HOSTS=localhost>
</CLIENT>
# Information on the test itself
# Use the <Default> tag to set command defaults
<DEFAULT>
server mailhost.example.com
smtpMailFrom mailtestuser0@mailhost.example.com
loginFormat mailtestuser%ld
addressFormat mailtestuser%ld@mailhost.example.com
passwdFormat myPassword
numLogins 100
firstLogin 0
numAddresses 100
firstAddress 0
</DEFAULT>

View File

@@ -1,10 +0,0 @@
# MailStone workload configuration file. See sample.wld for detailed usage
# Typical HTTP GETs
<includeOnce conf/general.wld>
<HTTP>
weight 100
numLoops 1
httpcommand GET /
</HTTP>

View File

@@ -1,74 +0,0 @@
#!/bin/ksh
# fire off the series of Mailstone IMAP tests
# To test series setup, do: go_imap -n
# Look for testname$test_form, first. Override with: go_series -f <string>.
export test_form="_mail02"
export test_host="mail02"
# string appended to every description. Override with: go_series -d <string>.
export desc_conf="12 CPUs"
# Extra arguments common to all tests. Any other args go here.
# Note that arguments with embedded spaces wont work here.
# Instead use: go_series -- <args...>
export extra_args=""
# error limit to abort sequence
export error_limit=500
# time to allow the server to calm down after each run (seconds)
export sleep_time=120
# who to mail results to
#export mail_list="me@example.com,you@example.com"
export mail_list=""
# Get all the helper functions
. test_utils.ksh
### This is where the series of tests is defined
# clean and re-start server
if [[ $only_show_it -gt 0 ]] ; then
echo "Would run:" "$@"
return 0
else
# BUG: rsh never returns.
# individual commands in clean work fine, but fail as a whole
rsh -n $test_host /bin/ksh /iplanet/bin/clean$test_form &
sleep 300 && kill -9 $!
wait
fi
# check our setup
run timesync
###echo "DEBUG exit" && exit 0
run_test popdel 'Create mailboxes (random order)' -t 60m maxblocks=100000 "$@"
run_test allpop 'Create mailboxes (exhaustive)' "$@"
run_test imaplogin 'IMAP login rate' "$@"
run_test smtp10k-5-5k 'Deliver 5, 5k messages to 10k users' "$@"
sleep 200 # let queue drain (2000/(10 msg/sec))
run_test imapread10k 'IMAP Message downloads 5k from 10k users' "$@"
run_test smtp10k-5-5k 'Deliver 5, 5k messages to 10k users' "$@"
sleep 200 # let queue drain (2000/(10 msg/sec))
run_test imapread 'IMAP Message downloads 5k' "$@"
run_test imapsmtp-throttle 'Combined IMAP-SMTP load (1 of 3)' "$@"
run_test imapsmtp-throttle 'Combined IMAP-SMTP load (2 of 3)' "$@"
run_test imapsmtp-throttle 'Combined IMAP-SMTP load (3 of 3)' "$@"
# Some messages will be left from previous test
run_test imapmaxusers 'IMAP 30K simultaneous users' "$@"
# e-mail the whole batch
[[ -n "$mail_list" ]] && \
mail_series "DotCom IMAP: `date`" "$mail_list"

View File

@@ -1,19 +0,0 @@
# MailStone workload configuration file. See sample.wld for detailed usage
# Typical IMAP checks/reads
<includeOnce conf/general.wld>
<CONFIG> # test specific config
title IMAP reads
clientCount 100 # since IMAP has long sleeps, use lots of clients
</CONFIG>
<IMAP4>
weight 100
#leaveMailOnServer 1
idleTime 2s # time between login and first download check
loopDelay 5m # time between download checks
numLoops 10 # how many check to do before closing the connection
blockTime 2s # time between logout and next login (or other block)
</IMAP4>

View File

@@ -1,51 +0,0 @@
-- test size --
test:
length: 90m
users: ** Number of users here ***
percent active: 10
comments: Auto-generated ISP workload.
-- mail server configuration --
server:
hostname: ** SERVER **
# defaults --
# addressFormat: smuser%ld@
# firstAddress: 0
# loginFormat: smuser%ld@
# firstLogin: 0
# passwdFormat: twang
#
-- test client configuration --
clients:
smtp: ** SMTP clients here **
pop: ** POP clients go here **
# defaults are `rsh' and `rcp'
# rsh: rsh
# rcp: rcp
-- Do not edit between here and the `__END__' marker
message:
size: ~lognormal(3k,4.5)
recipients: ~lognormal(1,1.5) : [1, ]
mime: 30 %
user:
messages per day: 5
read messages: 0
protocol: POP
check interval: ~unif(5m, 8m)
connection type: latency = 0; bandwidth = 56k
keep: 5%
activity: 30 m each 24 h
drop rate: 0.5%
__END__
# other things (e.g. <monitor> sections) can go here...

View File

@@ -1,36 +0,0 @@
<default>
addressFormat smuser%ld@** DOMAIN **
loginFormat smuser%ld@** DOMAIN **
passwdFormat twang
server ** SERVER **
</default>
<smtp HOSTS=smtp>
blockTime 0
file auto
firstAddress 0
headers ~unif(10, 30)
mime ~binomial(0.3)
numAddresses 1000
numLoops 1
numRecips ~lognormal(1,2) : [1, ]
size ~lognormal(4k,4.5)
smtpMailFrom sender0@** DOMAIN **
useEHLO 2
portNum 2003
</smtp>
<client HOSTS=localhost>
clients 50
group smtp
</client>
<config>
comments lmtp delivery
rampTime 0
time 5m
title lmtp delivery - IMAP
useGroups 1
</config>
# other things (e.g. <monitor> sections) can go here...

View File

@@ -1,36 +0,0 @@
<default>
addressFormat smuser%ld@** DOMAIN **
loginFormat smuser%ld@** DOMAIN **
passwdFormat twang
server ** SERVER **
</default>
<smtp HOSTS=smtp>
blockTime 0
file auto
firstAddress 0
headers ~unif(10, 30)
mime 30 %
numAddresses 1000
numLoops 1
numRecips ~lognormal(1,1.5) : [1, ]
size ~lognormal(3k,4.5)
smtpMailFrom sender0@** DOMAIN **
useEHLO 2
portNum 2003
</smtp>
<client HOSTS=localhost>
clients 50
group smtp
</client>
<config>
comments lmtp delivery
rampTime 0
time 5m
title lmtp delivery - POP
useGroups 1
</config>
# other things (e.g. <monitor> sections) can go here...

View File

@@ -1,84 +0,0 @@
#!/bin/ksh
# fire off the series of Mailstone tests
# To test series, do: go_series -n
# Look for testname$test_form, first. Override with: go_series -f <string>.
export test_form="_mail02"
export test_host="mail02"
# string appended to every description. Override with: go_series -d <string>.
export desc_conf="12 CPUs"
# Extra arguments common to all tests. Any other args go here.
# Note that arguments with embedded spaces wont work here.
# Instead use: go_series -- <args...>
export extra_args=""
# error limit to abort sequence
export error_limit=500
# time to allow the server to calm down after each run (seconds)
export sleep_time=120
# who to mail results to
#export mail_list="me@example.com,you@example.com"
export mail_list=""
# Get all the helper functions
. test_utils.ksh
### This is where the series of tests is defined
# clean and re-start server
if [[ $only_show_it -gt 0 ]] ; then
echo "Would run:" "$@"
return 0
else
# BUG: this never returns. rsh never returns
# individual commands in clean work fine, but fail as a whole
rsh -n $test_host /bin/ksh /iplanet/bin/clean$test_form &
sleep 300 && kill -9 $!
wait
fi
# check our setup
run timesync
###echo "DEBUG exit" && exit 0
run_test popdel 'Create mailboxes (random order)' -t 60m maxblocks=100000 "$@"
run_test allpop 'Create mailboxes (exhaustive)' "$@"
run_test popdel 'Empty checks: never used (1 of 3)' "$@"
run_test popdel 'Empty checks: never used (2 of 3)' "$@"
run_test popdel 'Empty checks: never used (3 of 3)' "$@"
run_test smtp10k-5-5k 'Deliver 5, 5k messages to 10k users' "$@"
sleep 200 # let queue drain (2000/(10 msg/sec))
run_test popsave10k 'Message downloads 5k from 10k users (1 of 3)' "$@"
run_test popsave10k 'Message downloads 5k from 10k users (2 of 3)' "$@"
run_test popsave10k 'Message downloads 5k from 10k users (3 of 3)' "$@"
run_test popsave 'Message downloads 5k (1 of 3)' "$@"
run_test popsave 'Message downloads 5k (2 of 3)' "$@"
run_test popsave 'Message downloads 5k (3 of 3)' "$@"
run_test popsmtp-throttle 'Combined load (1 of 3)' "$@"
run_test popsmtp-throttle 'Combined load (2 of 3)' "$@"
run_test popsmtp-throttle 'Combined load (3 of 3)' "$@"
run_test smtp100k 'SMTP delivery rate' "$@"
run_test popclean 'Message downloads/delete 5k ' "$@"
run_test popdel 'Empty checks (1 of 3)' "$@"
run_test popdel 'Empty checks (2 of 3)' "$@"
run_test popdel 'Empty checks (3 of 3)' "$@"
# e-mail the whole batch
[[ -n "$mail_list" ]] && \
mail_series "DotCom POP: `date`" "$mail_list"

View File

@@ -1,15 +0,0 @@
# MailStone workload configuration file. See sample.wld for detailed usage
# Typical POP checks/reads
<includeOnce conf/general.wld>
<CONFIG> # test specific config
title POP reads
clientCount 50
</CONFIG>
<POP3>
weight 100
numLoops 9999 # will close when messages run out
#leaveMailOnServer 1
</POP3>

View File

@@ -1,44 +0,0 @@
# MailStone workload configuration file. See sample.wld for detailed usage
# Deliver mail using SMTP
# This can measure delivery rates for a specified message type.
# This also fills the store for POP or IMAP tests
<includeOnce conf/general.wld>
<CONFIG> # test specific config
title POP, IMAP, SMTP combined load
clientCount 100
</CONFIG>
# MailStone workload configuration file. See sample.wld for detailed usage
# Typical SMTP delivery with 1K message size and restricted accounts
<SMTP HOSTS=client1>
file en-1k.msg
weight 100
#numAddresses 200
</SMTP>
# MailStone workload configuration file. See sample.wld for detailed usage
# Typical POP checks/reads
<POP3 HOSTS=client2>
weight 100
#leaveMailOnServer 1
</POP3>
# MailStone workload configuration file. See sample.wld for detailed usage
# Typical IMAP checks/reads
# IMAP maintains a connection (unlike POP or SMTP)
# for combined load tests, run it on separate client machines
<IMAP4 HOSTS=client3>
weight 100
idleTime 5
checkMailInterval 10
numLoops 1000
</IMAP4>

View File

@@ -1,21 +0,0 @@
# MailStone workload configuration file. See sample.wld for detailed usage
# Deliver mail using SMTP
# This can measure delivery rates for a specified message type.
# This also fills the store for POP or IMAP tests
<includeOnce conf/general.wld>
<CONFIG> # test specific config
title POP reads with SMTP message deliveries
clientCount 50
</CONFIG>
<include conf/smtp1k.wld>
<include conf/smtp5k.wld>
<include conf/smtp17k.wld>
<POP3>
weight 100
#leaveMailOnServer 1
</POP3>

View File

@@ -1,12 +0,0 @@
<!-- this file provides system comments and is merged into reports -->
<PRE>
<B> Mailhost.example.com </B>
EXAMPLE SYSTEM CONFIGURATION
Netscape Messaging Server 4.15 (7/21/99)
E6000
26x250MHz UltraSPARC-II
6.5GB RAM
A3500 w/ 60x9GB 7200 RPM
store: 5 x (10x9 RAID-0)
queue: 1 x (10x9 RAID-0)
</PRE>

View File

@@ -1,281 +0,0 @@
# MailStone workload configuration file
#
# Include other workload files like this:
# <include conf/morework.wld>
#
# If you want a workload included ONLY ONCE in the test, use this
# <includeOnce conf/morework.wld>
#
# See Also:
# smtp.wld - typical SMTP delivery test
# pop.wld - typical POP3 check/download test
# imap.wld - typical IMAP4 check/download test
######################################################################
# These sections discribe how the test is run:
# CONFIG, CLIENT, MONITOR, PRETEST, POSTTEST
# The <CONFIG> section defines test setup and report parameters
# Multiple <CONFIG> sections will be merged into a one.
# The equivalent command line switch is shown in parenthesis.
<CONFIG>
title POP reads # title for report and index (-b)
comments Netscape MSG4.1 # additional info at top of report (-n)
time 3m # test time (-t)
rampTime 20s # portion of test to start things (-r)
clientCount 12 # number of client connections (-l)
maxErrors 10000 # set an error abort limit
maxBlocks 50000 # stop after this many blocks
#sysConfig conf/mailhost.txt # Pull in config file (-s)
sysConfig \ # Inline config text
<PRE>\
<B> mailhost.example.com </B>\
Netscape Messaging Server 4.11\
Linux 2.2.5\
4x400Mhz Xeon (1Mb)\
2Gb RAM\
</PRE>
useGroups 1 # use group names instead of host names
telemetry 1 # log telemetry (for debugging)
# These usually dont need to be set. These are the defaults
GnuPlot gnuplot/gnuplot
RSH ssh
# RSH /usr/bin/remsh # HP-UX uses this path
RCP scp
# RCP /usr/bin/rcp
tempDir /var/tmp # client machine directory
chartWidth 640
chartHeight 480
clientCommand mailclient # CLIENT command to run
monitorCommand vmstat %f # MONITOR command to run
makeUsersArgs -4 # args to makeusers
imageType png # gnuplot image type: png, gif, ...
</CONFIG>
# Each <Client> section defines one or more client machines
# Every machine in the section will run the same number of connections
# Note that there cannot be whitespace between the client hostnames
<CLIENT HOSTS=client1,client2>
arch Linux2.2_x86
maxClients 200
maxThreads 50
# the group is only used if "useGroups" is set
group A
command mailclient -m 100 # override the command to run
</CLIENT>
# Set a specific number of processes and threads
<CLIENT HOSTS=client3,client4>
arch SunOS5.6
processes 2
threads 10
# the group is only used if "useGroups" is set
group B
</CLIENT>
# Here is how to configure a WinNT client from a Unix mail master
# The NT rshd must interoperate with Unix rsh; allow redirection of
# stdin, stdout, and stderr; and must support binary file copies.
# Denicomp's wrshdnt has been used sucessfully. www.denicomp.com
<CLIENT HOSTS=winnt01>
Arch WINNT4.0
command mailclient.exe
tempDir c:\temp
</CLIENT>
# The PreTest sections will run before the test starts
<PRETEST HOSTS=mailhost.example.com>
# RSH rsh -l mailuser
command cd /usr/netscape/msg-mailhost; ./getconf
</PRETEST>
# Each <Monitor> section defines remote monitoring commands
# for one or more machines.
# Commands containing '%c' run to completion.
# Otherwise the command will be shutdown down
<MONITOR HOSTS=mailhost.example.com>
command vmstat,%f,%c
</MONITOR>
# The PostTest sections will run after the test completes
<POSTTEST HOSTS=mailhost.example.com>
command df
</POSTTEST>
######################################################################
# available protcols: SMTP, POP3, IMAP4
# (command names are not case sensitive)
#
# Time formats use suffixes of 's', 'm', 'h', 'd'
# for seconds, minutes, hours, days
# In account formats, "%ld" is replaced by user number
# These parameters apply to the protocol sections
# Command parameter applicable command Example
#-------------------------------------------------------------------
# server <ALL> mail.example.com
# portNum <ALL> 25
# (if no value is given, the default port for that service is used)
#
# weight <ALL> 20
#
# loginFormat <ALL> test%ld
# %ld=address %ld=domain
# firstLogin <ALL> 0
# numLogins <ALL> 2000
# sequentialLogins <ALL> 1
# passwdFormat <ALL> netscape
#
# addressFormat <ALL> test%ld@mail.example%ld.com
# %ld=address %ld=domain
# firstAddress <ALL> 0
# numAddresses <ALL> 2000
# sequentialAddresses <ALL> 1
#
# numDomains <ALL> 3
# firstDomain <ALL> 0
# sequentialDomains <ALL> 1
#
# idleTime <ALL> 5m
# numLoops <ALL> 200
# loopDelay <ALL> 1m
# blockTime <ALL> 5m
#
# numRecips SMTP 3
# smtpMailFrom SMTP mailstone@mail.example.com
# file SMTP en-3k.msg
# useEHLO SMTP 1 (default is HELO)
# useAUTHLOGIN SMTP 1 (no AUTHLOGIN by default)
#
# leaveMailOnServer POP3,IMAP4 1
# leaveMailUnSeen IMAP4 1
# The <Default> section sets command block defaults
# Multiple <Default> sections will be merged into one
<DEFAULT>
server mailhost.example.com
smtpMailFrom mailhost0@mailhost.example.com
addressFormat mailhost%ld@mailhost.example.com
loginFormat mailhost%ld
passwdFormat netscape
numLogins 1000
numAddresses 1000
</DEFAULT>
# Note: empty host list means all hosts
<SMTP>
file en-1k.msg
weight 10
numAddresses 200
</SMTP>
<include conf/smtp17.wld>
# Note: the host name must be the same as specified in the CLIENT section
<POP3 HOSTS=client1,client2>
weight 10
#leaveMailOnServer 1
</POP3>
<IMAP4 HOSTS=client3>
idleTime 300
#weight 15
</IMAP4>
######################################################################
# These sections are used to generate the right graphs for the test
# This is the built in defaults
<GRAPH name=connects>
title Number of connections attempted
label Connections/sec
variables conn
field Try
</GRAPH>
<GRAPH name=connections>
title Total connections
label Connections
variables connections
</GRAPH>
<GRAPH name=connErrors>
title Number of connection errors
label Errors/sec
variables conn, banner, login, logout
field Error
</GRAPH>
<GRAPH name=msgErrors>
title Number of command/message errors
label Errors/sec
variables cmd, submit, retrieve
field Error
</GRAPH>
<GRAPH name=retrieves>
Title Number of messages read
label Messages/sec
variables retrieve
field Try
</GRAPH>
<GRAPH name=submits>
title Number of messages written
label Messages/sec
variables submit
field Try
</GRAPH>
<GRAPH name=commands>
title Number of commands sent
label Commands/sec
variables cmd
field Try
</GRAPH>
<GRAPH name=readBytes>
title Bytes read
label Bytes/sec
variables login, banner, cmd, retrieve, submit, logout
field BytesR
</GRAPH>
<GRAPH name=writeBytes>
title Bytes written
label Bytes/sec
variables login, banner, cmd, retrieve, submit, logout
field BytesW
</GRAPH>
<GRAPH name=msgTime>
title Message transfer time
label Seconds per message
variables cmd, submit, retrieve
field Time
</GRAPH>
<GRAPH name=setupTime>
Title Connection setup time
label Seconds per connection
variables conn, banner, login
field Time
</GRAPH>
<GRAPH name=blocks>
title Number of mailstone blocks executed
label Blocks/sec
variables blocks
# this is a scalar. No "field" needed/allowed
</GRAPH>

View File

@@ -1,16 +0,0 @@
# MailStone workload configuration file. See sample.wld for detailed usage
# Deliver mail using SMTP
# This can measure delivery rates for a specified message type.
# This also fills the store for POP or IMAP tests
<includeOnce conf/general.wld>
<CONFIG> # test specific config
title SMTP message deliveries
clientCount 20
</CONFIG>
# if we include more than one, we get a distribution of all sizes
<include conf/smtp1k.wld>
<include conf/smtp5k.wld>
<include conf/smtp17k.wld>

View File

@@ -1,33 +0,0 @@
-- test size --
test:
length: 90m
users: 100
messages per second: ** Delivery Rate **
comments: Auto-generated SMTP-only workload
-- server configuration --
server:
hostname: ** SERVER **
# addressFormat: smuser%ld@
# firstAddress: 0
# loginFormat: smuser%ld@
# firstLogin: 0
# passwdFormat: twang
-- client configuration --
clients:
smtp: ** SMTP clients **
-- Do not edit between here and the `__END__' marker --
message:
size: ~lognormal(3k,4.5)
recipients: ~lognormal(1,1.5) : [1, ]
mime: 30 %
__END__
# other things (e.g. <monitor> sections) can go here...

View File

@@ -1,16 +0,0 @@
#MailSTone workload configuration
# Send 17k, 3 recipient messages from all clients
<SMTP>
weight 100
file en-17k.msg
# uncomment this line to just deliver to a subset of addresses
#numAddresses 200
# deliver each message to more than 1 address
numRecips 1
numLoops 1 # number of messages to send per login
</SMTP>

View File

@@ -1,16 +0,0 @@
# MailStone workload configuration file. See sample.wld for detailed usage
# Typical SMTP delivery with 1K message size and restricted accounts
<SMTP>
weight 100
file en-1k.msg
# uncomment this line to just deliver to a subset of addresses
#numAddresses 200
# deliver each message to more than 1 address
numRecips 1
numLoops 1 # number of messages to send per login
</SMTP>

View File

@@ -1,16 +0,0 @@
# MailStone workload configuration file. See sample.wld for detailed usage
# Typical SMTP delivery with 5K message size and restricted accounts
<SMTP>
weight 100
file en-5k.msg
# uncomment this line to just deliver to a subset of addresses
#numAddresses 200
# deliver each message to more than 1 address
numRecips 1
numLoops 1 # number of messages to send per login
</SMTP>

View File

@@ -1,33 +0,0 @@
-- NOT READY! --
test:
length: ?
users: ?
percent active: ?
server:
hostname: server goes here
addressFormat: smuser%ld@
firstAddress: 0
loginFormat: smuser%ld@
firstLogin: 0
passwdFormat: twang
clients:
smtp: ...
web: ...
message:
size: ~lognormal(3k,4.5)
recipients: ~lognormal(1,1.5)
mime: 30 %
user:
messages per day: 5
read messages: 50
protocol: web
check interval: 30s
connection type: latency = 0; bandwidth = 56k
keep: 95%
activity: 30 m each 24h
drop rate: 50%

View File

@@ -1,74 +0,0 @@
#!/bin/ksh
# fire off the series of Mailstone WEBMAIL tests
# To test series setup, do: go_webmail -n
# Look for testname$test_form, first. Override with: go_series -f <string>.
export test_form="_mail02"
export test_host="mail02"
# string appended to every description. Override with: go_series -d <string>.
export desc_conf="12 CPUs"
# Extra arguments common to all tests. Any other args go here.
# Note that arguments with embedded spaces wont work here.
# Instead use: go_series -- <args...>
export extra_args=""
# error limit to abort sequence
export error_limit=500
# time to allow the server to calm down after each run (seconds)
export sleep_time=120
# who to mail results to
#export mail_list="me@example.com,you@example.com"
export mail_list=""
# Get all the helper functions
. test_utils.ksh
### This is where the series of tests is defined
# clean and re-start server
if [[ $only_show_it -gt 0 ]] ; then
echo "Would run:" "$@"
return 0
else
# BUG: rsh never returns.
# individual commands in clean work fine, but fail as a whole
rsh -n $test_host /bin/ksh /iplanet/bin/clean$test_form &
sleep 300 && kill -9 $!
wait
fi
# check our setup
run timesync
###echo "DEBUG exit" && exit 0
run_test popdel 'Create mailboxes (random order)' -t 60m maxblocks=100000 "$@"
run_test allpop 'Create mailboxes (exhaustive)' "$@"
run_test webmaillogin 'WebMail login rate' "$@"
run_test smtp10k-5-5k 'Deliver 5, 5k messages to 10k users' "$@"
sleep 200 # let queue drain (2000/(10 msg/sec))
run_test webmailread10k 'WebMail Message downloads 5k from 10k users' "$@"
run_test smtp10k-5-5k 'Deliver 5, 5k messages to 10k users' "$@"
sleep 200 # let queue drain (2000/(10 msg/sec))
run_test webmailread 'WebMail Message downloads 5k' "$@"
run_test webmailsmtp-throttle 'Combined WebMail-SMTP load (1 of 3)' "$@"
run_test webmailsmtp-throttle 'Combined WebMail-SMTP load (2 of 3)' "$@"
run_test webmailsmtp-throttle 'Combined WebMail-SMTP load (3 of 3)' "$@"
# Some messages will be left from previous test
run_test webmailmaxusers 'WebMail 30K simultaneous users' "$@"
# e-mail the whole batch
[[ -n "$mail_list" ]] && \
mail_series "DotCom WebMail: `date`" "$mail_list"

View File

@@ -1,209 +0,0 @@
# MailStone workload configuration file. See sample.wld for detailed usage
# Typical WMAP checks/reads
<includeOnce conf/general.wld>
<CONFIG> # test specific config
title WMAP reads
clientCount 1 # since WMAP has long sleeps, use lots of clients
</CONFIG>
<DEFAULT>
# leaveMailOnServer 1
file en-1k.msg
#numAddresses 200
numRecips 1
idleTime 2s # time between login and first download check
loopDelay 5m # time between download checks
numLoops 10 # how many check to do before closing the connection
blockTime 2s # time between logout and next login (or other block)
</DEFAULT>
# This version pulls in everything (no caching)
<WMAP>
weight 20
# %s=referhost %s=host %d=content-length
wmapClientHeader "\
Referer: http://%s/\r\n\
Connection: Keep-Alive\r\n\
User-Agent: Mozilla/4.7 [en] (WinNT; U)\r\n\
Host: %s\r\n\
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*\r\n\
Accept-Encoding: gzip\r\n\
Accept-Language: en\r\n\
Accept-Charset: iso-8859-1,*,utf-8\r\n"
wmapBannerCmds "GET / HTTP/1.0"
wmapBannerCmds "GET /imx/N24b.gif HTTP/1.0"
wmapLoginCmd "POST /login.msc HTTP/1.0"
# %s=user %s=password
wmapLoginData "user=%s&password=%s"
# %s=sid
# (this one is done automatically from the redirect URL)
# wmapInboxCmds "GET /en/mail.html?sid=%s&\
#lang=en&host=http://toad.mcom.com/&cert=false HTTP/1.0"
wmapInboxCmds "GET /util.js HTTP/1.0"
wmapInboxCmds "GET /en/i18n.js HTTP/1.0"
wmapInboxCmds "GET /main.js HTTP/1.0"
wmapInboxCmds "GET /frame.html HTTP/1.0"
wmapInboxCmds "GET /cfg.msc?sid=%s&security=false HTTP/1.0"
wmapInboxCmds "GET /mbox_fs.html HTTP/1.0"
wmapInboxCmds "GET /imx/N16.gif HTTP/1.0"
wmapInboxCmds "GET /imx/spacer.gif HTTP/1.0"
wmapInboxCmds "GET /imx/pull.gif HTTP/1.0"
wmapInboxCmds "GET /imx/compose.gif HTTP/1.0"
wmapInboxCmds "GET /imx/search.gif HTTP/1.0"
wmapInboxCmds "GET /imx/divider.gif HTTP/1.0"
wmapInboxCmds "GET /imx/trash.gif HTTP/1.0"
wmapInboxCmds "GET /imx/read.gif HTTP/1.0"
wmapInboxCmds "GET /imx/sort_dn.gif HTTP/1.0"
wmapInboxCmds "GET /imx/high-0.gif HTTP/1.0"
wmapInboxCmds "GET /imx/read-1.gif HTTP/1.0"
# %s=sid
wmapCheckCmds "GET /mbox.msc?sid=%s&security=false&mbox=INBOX&\
start=-9999&count=9999&date=true&srch= HTTP/1.0"
# %s=sid, %d=message uid
wmapMsgReadCmds "GET /msg.msc?sid=%s&security=false&mbox=INBOX&\
uid=13&process=js,link,target,html,binhex&maxtext=30720 HTTP/1.0"
wmapMsgReadCmds "GET /msg_fs.html HTTP/1.0"
wmapMsgReadCmds "GET /reply.gif HTTP/1.0"
wmapMsgReadCmds "GET /reply_all.gif HTTP/1.0"
wmapMsgReadCmds "GET /forward.gif HTTP/1.0"
wmapMsgReadCmds "GET /prev-0.gif HTTP/1.0"
wmapMsgReadCmds "GET /all-0.gif HTTP/1.0"
wmapMsgReadCmds "GET /next-1.gif HTTP/1.0"
# %s=sid
#TODO wmapMsgDeleteCmds "GET / HTTP/1.0"
# %s=sid
#TODO wmapMsgComposeCmds "GET / HTTP/1.0"
# %s=sid
#TODO wmapMsgReplyCmds "GET / HTTP/1.0"
# %s=sid
#TODO wmapMsgReplyallCmds "GET / HTTP/1.0"
# %s=sid
#TODO wmapMsgForwardCmds "GET / HTTP/1.0"
# %s=sid
wmapMsgWriteCmds "GET / HTTP/1.0"
# %s=sid
wmapLogoutCmds "GET /cmd.msc?sid=%s&security=false&mbox=&cmd=logout HTTP/1.0"
</WMAP>
# This version assumes all static URLs are cached
<WMAP>
weight 80
# %s=referhost %s=host %d=content-length
wmapClientHeader "\
Referer: http://%s/\r\n\
Connection: Keep-Alive\r\n\
User-Agent: Mozilla/4.7 [en] (WinNT; U)\r\n\
Host: %s\r\n\
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*\r\n\
Accept-Encoding: gzip\r\n\
Accept-Language: en\r\n\
Accept-Charset: iso-8859-1,*,utf-8\r\n"
wmapBannerCmds "GET / HTTP/1.0"
wmapLoginCmd "POST /login.msc HTTP/1.0"
# %s=user %s=password
wmapLoginData "user=%s&password=%s"
# %s=sid
# (this one is done automatically from the redirect URL)
# wmapInboxCmds "GET /en/mail.html?sid=%s&\
#lang=en&host=http://toad.mcom.com/&cert=false HTTP/1.0"
wmapInboxCmds "GET /cfg.msc?sid=%s&security=false HTTP/1.0"
# %s=sid
wmapCheckCmds "GET /mbox.msc?sid=%s&security=false&mbox=INBOX&\
start=-9999&count=9999&date=true&srch= HTTP/1.0"
# %s=sid, %d=message uid
wmapMsgReadCmds "GET /msg.msc?sid=%s&security=false&mbox=INBOX&\
uid=13&process=js,link,target,html,binhex&maxtext=30720 HTTP/1.0"
# %s=sid
wmapMsgWriteCmds "GET / HTTP/1.0"
# %s=sid
wmapLogoutCmds "GET /cmd.msc?sid=%s&security=false&mbox=&cmd=logout HTTP/1.0"
</WMAP>
########################################################################
#
# Typical Communicator 4.7 to Messenger Express 4.1 dataflow
# High level requests (as seen using Network Monitor) and client [port] numbers
#
### Login
#
# GET /
# (gets login screen)
# GET /imx/N24b.gif
# (gets a gif as part of the screen)
# POST /login.msc
# Content-type: application/x-www-form-urlencoded
# user=x&password=x
# (performs the login, gets a Location: redirect with session ID)
# Location: http://mailhost/en/mail.html?sid=ebp32po0bt9u95rh&lang=en&host=http://mailhost/&cert=false
#
### INBOX Listing
#
# (first fetch the redirect url)
# GET /en/mail.html?sid=ebp32po0bt9u95rh&lang=en&host=http://mailhost/&cert=false
# (gets the inbox screen)
# GET /util.js
# GET /en/i18n.js
# GET /main.js
# GET /frame.html
# GET /frame.html
# GET /frame.html
# GET /cfg.msc?sid=ebp32po0bt9u95rh&security=false
# GET /frame.html
# GET /frame.html
#
# GET /mbox.msc?sid=ebp32po0bt9u95rh&security=false&mbox=INBOX&start=-9999&count=9999&date=true&srch=
# GET /mbox_fs.html
# GET /imx/N16.gif
# GET /imx/spacer.gif
# GET /imx/pull.gif
# GET /imx/compose.gif
# GET /imx/divider.gif
# GET /imx/trash.gif
# GET /imx/search.gif
# GET /imx/read.gif
# GET /imx/sort_dn.gif
# GET /imx/high-0.gif
# GET /imx/read-1.gif
#
### Reading a message
#
# GET /msg.msc?sid=ebp32po0bt9u95rh&security=false&mbox=INBOX&uid=13&process=js,link,target,html,binhex&maxtext=30720
# GET /msg_fs.html
# GET /imx/reply.gif
# GET /imx/reply_all.gif
# GET /imx/forward.gif
# GET /imx/prev-0.gif
# GET /imx/all-0.gif
# GET /imx/next-1.gif
#
### Logout
#
# GET /cmd.msc?sid=ebp32po0bt9u95rh&security=false&mbox=&cmd=logout
#
########################################################################

View File

@@ -1,227 +0,0 @@
# Figure out the OS sepecific setup stuff
# Define a flag for include-at-most-once
INCLUDED_CONFIG_MK = 1
# Mstone features to choose at compile-time:
# See doc/mstone_changes.html for details.
AUTOGEN = 1 # automatic body generation
IMAP_RAMPDOWN = 1 # ramp-down time for IMAP
SOCK_LINESPEED = 1 # (primitive) linespeed limitation
# SOCK_SSL = 1 # SSL/TLS and STARTTLS
SSL_INCLUDE = /usr/include/openssl
SSL_LIBS = /usr/lib/openssl
# MSG_READ_TIME = 1 # delay after message retrieval
USE_EVENTS = 1 # use event-queue model -- less threads
GEN_CHECKSUM = 1 # try to verify message integrity
DYNAMIC_THROTTLE = 1 # throttle preload dynamically
# These normally get overridden on the command line from ../Makefile
# This is the default build type
BUILD_VARIANT = release
ifeq ($(BUILD_VARIANT), debug)
BUILD_TYPE = DEBUG
OBJDIR_TAG = _DBG
else
BUILD_TYPE = RELEASE
OBJDIR_TAG = _OPT
endif
OS_ARCH := $(shell uname -s)
ifeq ("$(OBJDIR)", "")
ifeq ($(OS_ARCH), WINNT)
NSARCH := WIN32
else
NSARCH := $(shell $(topsrcdir)/nsarch)
endif
OBJDIR = $(topsrcdir)/build/$(NSARCH)$(OBJDIR_TAG).OBJ
PKGDIR = $(topsrcdir)/build/package/$(NSARCH)$(OBJDIR_TAG).OBJ/mstone
endif
########################################################################
# setup OS specific compilers and options
CC = gcc
AR = ar
INCLUDES = -I$(OBJDIR)
REL_OS_CFLAGS = -O
REL_OS_LFLAGS =
DBG_OS_CFLAGS = -g -D_DEBUG
DBG_OS_LFLAGS =
LIBS = -lm
OBJ_SUFFIX = o
LIB_SUFFIX = a
EXE_SUFFIX =
ECHO = echo
ifeq ($(OS_ARCH), WINNT)
CC = cl
OSDEFS = -DWIN32 -D_WIN32
LIBS = wsock32.lib libcmt.lib msvcrt.lib
REL_OS_CFLAGS =
REL_OS_LINKFLAGS = /link
DBG_OS_CFLAGS = -Od -Zi
DBG_OS_LINKFLAGS = /link /debug:full
OBJ_SUFFIX = obj
LIB_SUFFIX = .lib
DLL_SUFFIX = .dll
EXE_SUFFIX = .exe
PERL_OS = MSWin32-x86
# build perl manually, install to c:\perl. Then build everything else
# cd win32 && nmake && nmake install
PERL5_IMPORT = c:/perl/$(PERL_REV)/
PERL_FILES = $(PERL_DIR)/Artistic
PERL_BIN_FILES = \
$(PERL5_IMPORT)/bin/$(PERL_OS)/perl$(EXE_SUFFIX)
$(PERL5_IMPORT)/bin/$(PERL_OS)/perl$(DLL_SUFFIX) \
PERL_LIB_FILES = $(PERL5_IMPORT)/lib/*.pm $(PERL5_IMPORT)/lib/*.pl
PERL_LIB_OS_FILES = $(PERL5_IMPORT)/lib/$(PERL_OS)/*.pm
endif
ifeq ($(OS_ARCH), IRIX64)
ARCH = IRIX
endif
ifeq ($(OS_ARCH), IRIX)
# MIPSpro Compilers: Version 7.2.1
CC = /usr/bin/cc -n32
REL_OS_CFLAGS = -fullwarn
DBG_OS_CFLAGS = -fullwarn
OSDEFS = -D__IRIX__ -DHAVE_SELECT_H -DHAVE_WAIT_H -DUSE_PTHREADS -DUSE_LRAND48
LIBS = -lm -lpthread
# OS specific flags for perl Configure
PERL_OS_CONFIGURE = -Dnm=/usr/bin/nm -Dar=/usr/bin/ar
PERL_OS = IP27-irix
endif
ifeq ($(OS_ARCH), OSF1)
# DEC C V5.6-071 on Digital UNIX V4.0(D) (Rev. 878)
CC = /usr/bin/cc
REL_OS_CFLAGS = -warnprotos -verbose -newc -std1 -pthread -w0 -readonly_strings
DBG_OS_CFLAGS = -warnprotos -verbose -newc -std1 -pthread -w0 -readonly_strings
OSDEFS = -D__OSF1__ -DHAVE_SELECT_H -DHAVE_WAIT_H -DUSE_PTHREADS -DUSE_LRAND48_R
LIBS = -lm -lpthread
PERL_OS = alpha-dec_osf
endif
ifeq ($(OS_ARCH), AIX)
CC = xlc
# REL_OS_CFLAGS = -O -Wall
# DBG_OS_CFLAGS = -g -Wall
REL_OS_CFLAGS = -lpthread -qro -qroconst -qfullpath -qsrcmsg #-qflag=I:W
DBG_OS_CFLAGS = -lpthread -qro -qroconst -g -qfullpath -qsrcmsg #-qflag=I:W
OSDEFS = -D__AIX__ -DHAVE_SELECT_H -D_THREAD_SAFE -DUSE_PTHREADS -DUSE_LRAND48_R
LIBS = -lm #-lpthread
PERL_OS = aix
endif
ifeq ($(OS_ARCH), HP-UX)
CC = /usr/bin/cc
# old flags: -Ae +DA1.0 +ESlit
REL_OS_CFLAGS = +DAportable +DS2.0 -Ae +ESlit
DBG_OS_CFLAGS = +Z +DAportable +DS2.0 -g -Ae +ESlit
OSDEFS = -D__HPUX__ -DUSE_PTHREADS -DUSE_LRAND48
LIBS = -lm -lpthread
PERL_OS = PA-RISC2.0
endif
ifeq ($(OS_ARCH), SunOS)
# Sun Workshop Compilers 5.0
# CC = /tools/ns/workshop-5.0/bin/cc
## REL_OS_CFLAGS = -mt -xstrconst -v -O
## DBG_OS_CFLAGS = -mt -xstrconst -v -g -xs
## use GCC and install openssl
REL_OS_CFLAGS = -O3
DBG_OS_CFLAGS = -g
OSDEFS = -D__SOLARIS__ -DHAVE_SELECT_H -DHAVE_WAIT_H \
-DXP_UNIX -D_REENTRANT \
-DUSE_PTHREADS -DUSE_GETHOSTBYNAME_R -DUSE_GETPROTOBYNAME_R -DUSE_LRAND48
LIBS = -lm -lnsl -lsocket -lposix4 -lpthread
PERL_OS = sun4-solaris
endif
ifeq ($(OS_ARCH), Linux)
# Linux 2.1 kernels and above
CC = /usr/bin/gcc # gcc 2.7.2.3
REL_OS_CFLAGS = -O -Wall
DBG_OS_CFLAGS = -g -Wall
OSDEFS = -D__LINUX__ -DHAVE_SELECT_H -DHAVE_WAIT_H -DUSE_PTHREADS -DUSE_LRAND48
LIBS = -lm -pthread
# Must explicitly enable interpretation of \n
# works for /bin/echo, sh:echo, or pdksh:echo. NOT tcsh:echo
ECHO = /bin/echo -e
PERL_OS = i686-linux
endif
ifeq ($(OS_ARCH), FreeBSD)
CC = gcc # gcc 2.7.2.3
REL_OS_CFLAGS = -O -Wall
DBG_OS_CFLAGS = -g -Wall
OSDEFS = -D__FREEBSD__ -DHAVE_SELECT_H -DUSE_PTHREADS -DUSE_LRAND48
LIBS = -lm -pthread
# Must explicitly enable interpretation of \n
# works for /bin/echo, sh:echo, or pdksh:echo. NOT tcsh:echo
ECHO = /bin/echo -e
PERL_OS = i686-freebsd
endif
# pull in any OS extra config, if available
-include $(topsrcdir)/config/$(OS_ARCH)/config.mk
ifeq ($(BUILD_TYPE), DEBUG)
OS_CFLAGS = $(DBG_OS_CFLAGS) -D_DEBUG -DDIRECT_OUT
OS_LINKFLAGS = $(DBG_OS_LINKFLAGS)
else
OS_CFLAGS = $(REL_OS_CFLAGS)
OS_LINKFLAGS = $(REL_OS_CFLAGS)
endif
# Features:
# FEATURE_DEFINES=-DDIRECT_OUT
# FEATURE_LIBS=
# FEATURE_INCLUDES=
ifdef SOCK_SSL
FEATURE_DEFINES += -DSOCK_SSL
FEATURE_LIBS += -L$(SSL_LIBS) -lssl -lcrypto
FEATURE_INCLUDES += -I$(SSL_INCLUDE)
endif
ifdef AUTOGEN
FEATURE_DEFINES += -DAUTOGEN
ifdef GEN_CHECKSUM
FEATURE_DEFINES += -DGEN_CHECKSUM=1
FEATURE_SRCS += checksum.c md5.c
endif
endif
ifdef IMAP_RAMPDOWN
FEATURE_DEFINES += -DIMAP_RAMPDOWN
endif
ifdef DYNAMIC_THROTTLE
FEATURE_DEFINES += -DDYNAMIC_THROTTLE
endif
ifdef SOCK_LINESPEED
FEATURE_DEFINES += -DSOCK_LINESPEED
endif
ifdef MSG_READ_TIME
FEATURE_DEFINES += -DMSG_READ_TIME
endif
ifdef USE_EVENTS
FEATURE_DEFINES += -DUSE_EVENTS
FEATURE_SRCS += event.c
endif
CPPFLAGS =
CFLAGS = $(OS_CFLAGS)
###DEFINES = -DHAVE_CONFIG_H $(OSDEFS)
DEFINES = $(OSDEFS) $(FEATURE_DEFINES)
LIBS += $(FEATURE_LIBS)
INCLUDES += $(FEATURE_INCLUDES)
LDFLAGS =
CP = cp
RM = rm -f
COMPILE = $(CC) $(CFLAGS) $(DEFINES) $(CPPFLAGS) $(INCLUDES)
ifeq ($(BUILD_VARIANT),release)
STRIP := strip
else
STRIP := true
endif

View File

@@ -1,261 +0,0 @@
From MalclmKrstl@catlnml.com Mon Aug 2 15:53:54 2004
Return-Path: <MalclmKrstl@catlnml.com>
Received: from leggite.example.com ([207.111.254.118]) by snacker.example.com
(Netscape Messaging Server 4.15) with ESMTP id I1UA2T00.FEQ for
<exp@example.com>; Mon, 2 Aug 2004 14:52:05 -0700
Received: from 207.111.254.118 ([201.224.129.137])
by leggite.example.com (8.12.8/8.12.8) with SMTP id i72LsWgE015040
for <exp@example.com>; Mon, 2 Aug 2004 14:54:51 -0700
Received: from 24.4.45.15 by 201.224.129.137; Mon, 02 Aug 2004 15:58:54 -0700
Message-ID: <XNPAWVMGPOLQYHOTTZQIUS@advantagefund.com>
From: "Joey Lzrd" <MalclmKrstl@catlnml.com>
Reply-To: "Joey Lzrd" <MalclmKrstl@catlnml.com>
To: exp@example.com
Subject: S@ve BlG 0n @ll Adobe S0ftware at Santos's eSoft Inc.
Date: Mon, 02 Aug 2004 19:53:54 -0300
MIME-Version: 1.0
X-MimeOLE: Produced By Microsoft MimeOLE V4.71.2730.1
X-Sender: MalclmKrstl@catlnml.com
Organization: briton.ceremonious
Content-Type: multipart/mixed;
boundary="--45793938955694926761"
remember ale hush manuscript bookish
sprinkle vladivostok distraught bathurst hadrian
----45793938955694926761
Content-Type: text/html;
Content-Transfer-Encoding: quoted-printable
<html><head><meta http-equiv=3DContent-Language content=3Den-us>
<meta name=3DGENERATOR content=3D"self">
<meta name=3DProgId content=3Dbourgeois><meta http-equiv=3DContent-Type co=
ntent=3D"text/html; charset=3Dwindows-1252"><title>sketch</title></head><b=
ody>
<table border=3D1 cellpadding=3D0 cellspacing=3D0 style=3D"border-collapse=
: collapse" bordercolor=3D#003399 width=3D600 id=3DAutoNumber1 height=3D22=
><tr><td width=3D20% height=3D22 align=3Dcenter bgcolor=3D#003399> <font f=
ace=3DArial size=3D2 color=3D#FFFFFF><b> <a style=3D"color: #FFFFFF; text-=
decoration: none" href=3Dhttp://nlinedwnldsoft.net/?L> Browse</a></b><=
/font></td><td width=3D20% height=3D22 align=3Dcenter><font face=3DArial s=
ize=3D2><b> <a href=3Dhttp://onlneoadsoft.net/?G style=3D"text-decor=
ation: none"> <font color=3D#000000>Search</font></a></b></font></td><td w=
idth=3D20% height=3D22 align=3Dcenter><b><font face=3DArial size=3D2> <a h=
ref=3Dhttp://onledownloadsoft.net/?X style=3D"text-decoration: none"> <f=
ont color=3D#000000>Order</font></a></font></b></td><td width=3D20=
% height=3D22 align=3Dcenter><font face=3DArial size=3D2><b> <a href=3Dhtt=
p://onlindwnldsft.net/?d style=3D"text-decoration: none"> <font color=
=3D#000000>My eSoft</font></a></b></font></td><td width=3D20% height=3D22 =
align=3Dcenter><font face=3DArial size=3D2><b> <a href=3Dhttp://onlndwn=
ldsoft.net/?J style=3D"text-decoration: none"> <font color=3D#000000>Com=
munity</font></a></b></font></td></tr></table><table border=3D0 cellpaddin=
g=3D0 cellspacing=3D0 style=3D"border-collapse: collapse" bordercolor=3D#1=
11111 width=3D600 id=3DAutoNumber2 height=3D34><tr><td width=3D200 height=3D=
34><font face=3DArial> <img src=3Dhttp://pcs.bsttc.com/aw/pcs/viewi=
tem/backArrow_14x14.gif width=3D14 height=3D14> <font size=3D2><a href=3Dh=
ttp://onlindwnldsft.net/?Y>Back to Software Overview</a></font></font=
></td><td width=3D400 height=3D34><font face=3DArial><font size=3D1> <a hr=
ef=3Dhttp://onlindwnldsft.net/?5>Home</a> &gt; <a href=3Dhttp://onlin=
edownloadsoft.net/?Y>All Categories</a> &gt; <a href=3Dhttp://onlinedownlo=
adsoft.net/?B>Computers</a> &gt; <a href=3Dhttp://onlindwnldsft.net/?=
d>Software</a> &gt; <a href=3Dhttp://onlindwnldsft.net/?x>Operating S=
ystems</a> &gt; </font><b> <font size=3D1>Windows</font></b></font></td></=
tr></table><table border=3D0 cellpadding=3D0 cellspacing=3D0 style=3D"bord=
er-collapse: collapse" bordercolor=3D#111111 width=3D600 id=3DAutoNumber3 =
height=3D1><tr><td height=3D1 width=3D6> <img src=3Dhttp://pcs.bsttc=
com/aw/pcs/listings/allitems_firstDark_6x29.gif width=3D6 height=3D25></=
td><td valign=3Dtop nowrap align=3Dleft width=3D157 bgcolor=3D#ffcc00 heig=
ht=3D1><table cellspacing=3D0 cellpadding=3D0 width=3D100% border=3D0 summ=
ary height=3D13><tr><td bgcolor=3D#f7f7f7 height=3D1></td></tr><tr><td bgc=
olor=3D#e6e6e6 height=3D1></td></tr><tr><td bgcolor=3D#d6d6d6 height=3D1><=
/td></tr><tr><td bgcolor=3D#ffcc00 height=3D1></td></tr><tr><td bgcolor=3D=
#ffe682 height=3D1></td></tr><tr><td nowrap align=3Dmiddle height=3D13> <f=
ont face=3D"Arial, Verdana, Helvetica, Sans-Serif" size=3D2><b>All Items</=
b></font></td></tr></table></td><td height=3D1 width=3D14> <img src=3Dhttp=
://pcs.bsttc.com/aw/pcs/listings/allitems_midDarkOnLight_14x29.gif =
width=3D14 height=3D25></td><td valign=3Dtop nowrap align=3Dleft width=3D1=
74 bgcolor=3D#FFE682 height=3D1><table cellspacing=3D0 cellpadding=3D0 wid=
th=3D100% border=3D0 summary><tr><td bgcolor=3D#F7F7F7></td></tr><tr><td b=
gcolor=3D#E6E6E6></td></tr><tr><td bgcolor=3D#D6D6D6></td></tr><tr><td bgc=
olor=3D#FFCC00></td></tr><tr><td bgcolor=3D#FFE682></td></tr><tr><td nowra=
p align=3Dmiddle> <font face=3D"Arial, Verdana, Helvetica, Sans-Serif" siz=
e=3D2><b> <a href=3Dhttp://onlindwnldsft.net/?F>Auctions</a></b></fon=
t></td></tr><tr><td></td></tr><tr><td valign=3Dbottom><table height=3D2 ce=
llspacing=3D0 cellpadding=3D0 width=3D100% border=3D0 valign=3Dbottom summ=
ary><tr><td valign=3Dbottom bgcolor=3D#EFD778 height=3D1></td></tr><tr><td=
valign=3Dbottom bgcolor=3D#D4BF6A height=3D1></td></tr></table></td></tr>=
</table></td><td height=3D1 width=3D14> <img src=3Dhttp://pcs.bsttc.=
com/aw/pcs/listings/allitems_midLightLight_14x29.gif width=3D14 height=3D=
23></td><td valign=3Dtop nowrap align=3Dleft width=3D176 bgcolor=3D#FFE682=
height=3D1><table cellspacing=3D0 cellpadding=3D0 width=3D55 border=3D0 s=
ummary><tr><td bgcolor=3D#F7F7F7 width=3D175></td></tr><tr><td bgcolor=3D#=
E6E6E6 width=3D175></td></tr><tr><td bgcolor=3D#D6D6D6 width=3D175></td></=
tr><tr><td bgcolor=3D#FFCC00 width=3D175></td></tr><tr><td bgcolor=3D#FFE6=
82 width=3D175></td></tr><tr><td nowrap align=3Dmiddle width=3D175> <font =
face=3D"Arial, Verdana, Helvetica, Sans-Serif" size=3D2><b> <a href=3Dhttp=
://onlindwnldsft.net/?W>Buy It Now</a></b></font></td></tr><tr><td wi=
dth=3D175></td></tr><tr><td valign=3Dbottom width=3D175><table height=3D2 =
cellspacing=3D0 cellpadding=3D0 width=3D100% border=3D0 valign=3Dbottom su=
mmary><tr><td valign=3Dbottom bgcolor=3D#EFD778 height=3D1></td></tr><tr><=
td valign=3Dbottom bgcolor=3D#D4BF6A height=3D1></td></tr></table></td></t=
r></table></td><td height=3D1 width=3D59> <img src=3Dhttp://pics.ebaystati=
c.com/aw/pcs/listings/allitems_endLightTab_14x29.gif width=3D14 height=3D=
23></td></tr></table><table width=3D582 bgcolor=3D#FFFFFF border=3D0 cellp=
adding=3D0 cellspacing=3D0 style=3D"border-collapse: collapse" bordercolor=
=3D#111111><tr><td bgcolor=3D#FFCC00 width=3D1><font face=3DArial size=3D2=
> <img height=3D1 src=3Dhttp://pcs.bsttc.com/aw/pcs/s.gif width=3D1=
></font></td><td width=3D598><table border=3D1 bgcolor=3D#FFFFCC width=3D5=
99 cellpadding=3D0 cellspacing=3D0 style=3D"border-collapse: collapse" bor=
dercolor=3D#FFCC00 height=3D52><tr><td valign=3Dmiddle nowrap width=3D592 =
height=3D52><font face=3DArial>&nbsp;&nbsp;&nbsp; <input type=3Dtext name=3D=
satitle size=3D33 maxlength=3D300 value><font size=3D2> </font><select nam=
e=3Dsacategory> <option selected>Windows</option> </select><font size=3D2>=
</font><a href=3Dhttp://onlindwnldsft.net/?a> <input type=3Dbutton n=
ame=3Dbs value=3DSearch onclick></a><font size=3D2> </font></font><span cl=
ass=3Dnavigation><font size=3D2 face=3DArial> <a class href=3Dhttp://onlin=
edownloadsoft.net/?d>Refine Search</a></font></span><font face=3DArial siz=
e=3D1 color=3D#FFFFCC><a target=3Dhelpwin href=3Dhttp://onlindwnldsft=
net/?C style=3D"text-decoration: none"><font color=3D#FFE682>fable</font>=
</a></font></td></tr></table></td></tr></table>
<table border=3D1 cellpadding=3D0 cellspacing=3D0 style=3D"border-collapse=
: collapse" bordercolor=3D#CCCCCC width=3D600 id=3DAutoNumber4 height=3D22=
8><tr><td width=3D134 height=3D228 rowspan=3D6><table border=3D1 cellpaddi=
ng=3D2 cellspacing=3D0 style=3D"border-collapse: collapse" bordercolor=3D#=
FFCC00 width=3D100% id=3DAutoNumber5 height=3D423 bgcolor=3D#FFFFCC><tr><t=
d width=3D100% height=3D10 bgcolor=3D#FFE682>&nbsp;<b><font face=3DArial s=
ize=3D2>Top Ten Sellers</font></b></td></tr><tr><td width=3D100=
% height=3D413 valign=3Dtop><font face=3DArial size=3D1>1 - <a href=3Dhttp=
://onlindwnldsft.net/?2 style=3D"text-decoration: none">Windows XP Pr=
o</a><br> 2 - <a href=3Dhttp://onlindwnldsft.net/?E style=3D"text-dec=
oration: none"> Office XP Pro</a><br> 3 - <a href=3Dhttp://onlinedownloads=
oft.net/?7 style=3D"text-decoration: none"> Adobe Acrobat<br> &nbsp;&nbsp;=
&nbsp;&nbsp; 6.0 Professional</a><br> 4 - <a href=3Dhttp://onlinedownloads=
oft.net/?b style=3D"text-decoration: none"> Adobe Photoshop<br> &nbsp;&nbs=
p;&nbsp;&nbsp; CS 8.0</a><br> 5<a href=3Dhttp://onlindwnldsft.net/?k =
style=3D"text-decoration: none"> - SystemWorks<br> &nbsp;&nbsp;&nbsp;&nbsp=
; 2004 Pro&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </a><br> 6 - <a style=3D"text-dec=
oration: none" href=3Dhttp://onlindwnldsft.net/?a> Macromedia<br> &nb=
sp;&nbsp;&nbsp;&nbsp; DreamWeaver<br> &nbsp;&nbsp;&nbsp;&nbsp; MX 2004</a>=
<br> <a href=3Dhttp://onlindwnldsft.net/?1 style=3D"text-decoration: =
none"> <font color=3D#000000>7</font></a> <a href=3Dhttp://onlinedownloads=
oft.net/?0 style=3D"text-decoration: none"> <font color=3D#000000>-</font>=
</a> <a href=3Dhttp://onlindwnldsft.net/?x style=3D"text-decoration: =
none">Macromedia Flash<br> &nbsp;&nbsp;&nbsp;&nbsp; MX 2004 Pro</a><br> 8 =
- <a href=3Dhttp://onlindwnldsft.net/?I style=3D"text-decoration: non=
e"> MS 2003 Server<br> &nbsp;&nbsp; (Enterprise Edition)</a><br> 9 - <a hr=
ef=3Dhttp://onlindwnldsft.net/?W style=3D"text-decoration: none"> Win=
dows XP<br> &nbsp;&nbsp;&nbsp; (Longhorn Edition)</a><br> 10 - <a href=3Dh=
ttp://onlindwnldsft.net/?m style=3D"text-decoration: none">CorelDRAW<=
br> &nbsp; Graphics Suite 12.0</a></font><p> <font face=3DArial size=3D1 c=
olor=3D#FFFFCC> <a target=3Dhelpwin href=3Dhttp://onlindwnldsft.net/?=
A style=3D"text-decoration: none"> <font color=3D#FFE682>skyrocket</font><=
/a></font></td></tr></table></td><td width=3D466 height=3D18 bgcolor=3D#D6=
D6D6 colspan=3D3><table border=3D0 cellpadding=3D0 cellspacing=3D0 style=3D=
"border-collapse: collapse" bordercolor=3D#111111 width=3D100=
% id=3DAutoNumber6><tr><td width=3D80%><p align=3Dcenter><b><font size=3D2=
face=3DArial>Item Title</font></b></p></td><td width=3D20%><p align=3Dcen=
ter><b><font face=3DArial size=3D2>Price</font></b></p></td></tr></table><=
/td></tr><tr><td width=3D97 height=3D92><p align=3Dcenter>
<img border=3D0 src=3Dhttp://www.dara.es/soft/co/micro/xpPro.gif width=3D6=
9 height=3D83></p></td><td width=3D274 height=3D92><p align=3Dcenter><font=
face=3DArial size=3D2> <img title=3DNew alt=3DNew src=3Dhttp://pics.ebays=
tatic.com/aw/pcs/icon/iconNew_16x16.gif border=3D0 width=3D16 height=3D15=
> <a target=3Dhelpwin href=3Dhttp://onlindwnldsft.net/?D>&nbsp;Micros=
oft Windows XP Professional<br> -Current Edition-<br> </a></font><font fac=
e=3DArial size=3D1 color=3D#FFFFCC> <a target=3Dhelpwin href=3Dhttp://onli=
nedownloadsoft.net/?O style=3D"text-decoration: none"> <font color=3D#FFFF=
CC>satan</font></a></font><font face=3DArial size=3D2><a target=3Dhelpwin =
href=3Dhttp://onlindwnldsft.net/?j><br> <img title=3D"Gift Services" =
alt=3D"Gift Services" src=3Dhttp://pcs.bsttc.com/aw/pcs/bin_15x54.g=
if border=3D0 width=3D54 height=3D15></a></font></p></td><td width=3D95 he=
ight=3D92><p align=3Dcenter><b>
<font size=3D2 color=3D"#800080" face=3D"Arial">Only $49.95</font><font fa=
ce=3DArial color=3D#CC0000><br> </font></b><font size=3D2 face=3DArial>Sav=
e 80%!</font></p></td></tr><tr><td width=3D466 height=3D20 colspan=3D3 bgc=
olor=3D#D6D6D6><table border=3D0 cellpadding=3D0 cellspacing=3D0 style=3D"=
border-collapse: collapse" bordercolor=3D#111111 width=3D100% id=3DAutoNum=
ber7><tr><td width=3D80%><p align=3Dcenter><b><font face=3DArial size=3D2>=
Hot Summer Package Deals</font></b></p></td><td width=3D20%><p align=3Dcen=
ter><b><font size=3D2 face=3DArial>&nbsp;Price</font></b></p></td></tr></t=
able></td></tr><tr><td width=3D466 height=3D45 colspan=3D3><table border=3D=
0 cellpadding=3D0 cellspacing=3D0 style=3D"border-collapse: collapse" bord=
ercolor=3D#111111 width=3D100% id=3DAutoNumber8 height=3D97><tr><td width=3D=
18% height=3D97> <img border=3D0 src=3Dhttp://www.dara.es/soft/co/micro/xp=
Pro.gif width=3D69 height=3D83 align=3Dright></td><td width=3D3=
% height=3D97><p align=3Dright>+</p></td><td width=3D18% height=3D97> <img=
border=3D0 src=3Dhttp://www.pym.com.au/images/officexp.gif width=3D80 h=
eight=3D82></td><td width=3D3% height=3D97>+</td><td width=3D15=
% height=3D97> <img border=3D0 src=3Dhttp://www.gecadnet.ro/ufolder/photos=
hopcs.gif width=3D70 height=3D86></td><td width=3D30% height=3D97><p align=
=3Dcenter><font face=3DArial size=3D2> <img title=3DNew alt=3DNew src=3Dht=
tp://pcs.bsttc.com/aw/pcs/icon/iconNew_16x16.gif border=3D0 width=3D=
16 height=3D15> <a href=3Dhttp://onlindwnldsft.net/spo.html?l>Windows=
XP Pro + Office XP Pro + Adobe Photoshop CS 8.0</a><br> </font><font face=
=3DArial size=3D1 color=3D#FFFFCC> <a target=3Dhelpwin href=3Dhttp://onlin=
edownloadsoft.net/?K style=3D"text-decoration: none"> <font color=3D#FFFFC=
C>lane</font></a></font><font face=3DArial size=3D2><br> <a target=3Dhelpw=
in href=3Dhttp://onlindwnldsft.net/spo.html?u> <img title=3D"Gift Ser=
vices" alt=3D"Gift Services" src=3Dhttp://pcs.bsttc.com/aw/pcs/bin_=
15x54.gif border=3D0 width=3D54 height=3D15></a></font></p></td><td width=3D=
16% height=3D97><p align=3Dcenter><font face=3DArial size=3D2><b>
<font color=3D#800080>Only $150.95<br> </font> </b>Save<br> 90=
%!</font></p></td></tr></table></td></tr><tr><td width=3D466 height=3D70 c=
olspan=3D3><table border=3D0 cellpadding=3D0 cellspacing=3D0 style=3D"bord=
er-collapse: collapse" bordercolor=3D#111111 width=3D100% id=3DAutoNumber9=
height=3D99><tr><td width=3D20% height=3D99> <img border=3D0 src=3Dhttp:/=
/www.dara.es/soft/co/micro/xpPro.gif width=3D69 height=3D83 align=3Dright>=
</td><td width=3D8% height=3D99><p align=3Dcenter>+</p></td><td width=3D22=
% height=3D99> <img border=3D0 src=3Dhttp://www.jaeggi.ch/images/tipps_ueb=
ersicht/software/systemworks2004.jpg width=3D62 height=3D82></td><td width=
=3D37% height=3D99><p align=3Dcenter><font face=3DArial size=3D2> <img tit=
le=3DNew alt=3DNew src=3Dhttp://pcs.bsttc.com/aw/pcs/icon/iconNew_1=
6x16.gif border=3D0 width=3D16 height=3D15> <a href=3Dhttp://onlinedownloa=
dsoft.net/spo.html?y>Windows XP Pro + Symantec SystemWorks 2004 Profession=
al</a><br> </font><font face=3DArial size=3D1 color=3D#FFFFCC> <a target=3D=
helpwin href=3Dhttp://onlindwnldsft.net/?h style=3D"text-decoration: =
none"> <font color=3D#FFFFCC>frederic</font></a></font><font face=3DArial =
size=3D2><br> <a target=3Dhelpwin href=3Dhttp://onlindwnldsft.net/spo=
html?o> <img title=3D"Gift Services" alt=3D"Gift Services" src=3Dhttp://p=
ics.bysttc.com/aw/pcs/bin_15x54.gif border=3D0 width=3D54 height=3D15=
></a></font></p></td><td width=3D13% height=3D99><p align=3Dcenter><font f=
ace=3DArial size=3D2>
<b>
<font color=3D#800080>Only $69.95</font><br> </b>Save<br> 90=
%!</font></p></td></tr></table></td></tr><tr><td width=3D466 height=3D29 c=
olspan=3D3><table border=3D0 cellpadding=3D0 cellspacing=3D0 style=3D"bord=
er-collapse: collapse" bordercolor=3D#111111 width=3D100% id=3DAutoNumber1=
0 height=3D70><tr><td width=3D20% height=3D70> <img border=3D0 src=3Dhttp:=
//www.ntwrk-d.com.au/Images/flashMXpro.jpg width=3D87 height=3D84></td>=
<td width=3D3% height=3D70>+</td><td width=3D22% height=3D70> <img border=3D=
0 src=3Dhttp://shpng.trr.com.br/iguate/imgprod/Dreamweaver2004.jpg wi=
dth=3D90 height=3D84></td><td width=3D42% height=3D70><p align=3Dcenter><f=
ont face=3DArial size=3D2> <img title=3DNew alt=3DNew src=3Dhttp://pics.b=
ysttc.com/aw/pcs/icon/iconNew_16x16.gif border=3D0 width=3D16 height=3D=
15> <a href=3Dhttp://onlindwnldsft.net/spo.html?Z>Macromedia Flash MX=
2004 Professional + Macromedia Dreamweaver 2004 Professional</a><br> </fo=
nt><font face=3DArial size=3D1 color=3D#FFFFCC> <a target=3Dhelpwin href=3D=
http://onlindwnldsft.net/?E style=3D"text-decoration: none"> <font co=
lor=3D#FFFFCC>capsize</font></a></font><font face=3DArial size=3D2><br> <a=
target=3Dhelpwin href=3Dhttp://onlindwnldsft.net/spo.html?O> <img ti=
tle=3D"Gift Services" alt=3D"Gift Services" src=3Dhttp://pcs.bsttc.c=
om/aw/pcs/bin_15x54.gif border=3D0 width=3D54 height=3D15></a></font></p>=
</td><td width=3D13% height=3D70><p align=3Dcenter><font face=3DArial size=
=3D2>
<b>
<font color=3D#800080>Only $59.95</font><br> </b>Save<br> 95=
%!</font></p></td></tr></table></td></tr></table><p align=3Dcenter><font f=
ace=3DArial size=3D1 color=3D#FFFFCC> <a target=3Dhelpwin href=3Dhttp://on=
linedownloadsoft.net/?Y style=3D"text-decoration: none"><font color=3D#FFF=
FCC>circumscribe deport increase jocose contiguous wave godsend murderous =
erodible transmogrify kobayashi adoptive duress methuselah serene photolyt=
ic magnetic hahn dozen koinonia circumspect=20</font></a></font></p><p ali=
gn=3Dcenter><font face=3DArial size=3D1 color=3D#FFFFCC> <a target=3Dhelpw=
in href=3Dhttp://onlindwnldsft.net/?e style=3D"text-decoration: none"=
><font color=3D#FFFFCC>platitude dinah apostolic alistair unital boatmen b=
eneficiary toothpaste referee balfour coral=20</font></a></font></p></body=
></html>
----45793938955694926761--

View File

@@ -1,39 +0,0 @@
From Wd@rgsrdds.com Thu Feb 26 03:26:07 2004
Return-Path: <Wd@rgsrdds.com>
Received: from 24-196-112-88.fdl.wi.chrter.com (24-196-112-88.fdl.wi.charter.com [24.196.112.88])
by leggite.example.com (8.12.8/8.12.8) with SMTP id i1QBRUVf004909
for <exp@example.com>; Thu, 26 Feb 2004 03:27:39 -0800
Received: from 243.66.85.172 by 24.196.112.88; Thu, 26 Feb 2004 07:22:07 -0400
Message-ID: <UAEXRCYRSQWVZYJINKNBA@rtemedsr.com>
From: "Mil" <Wd@rgsrdds.com>
Reply-To: "Mil" <Wd@rgsrdds.com>
To: exp@example.com
Subject: compare our prices to other pharmacys
Date: Thu, 26 Feb 2004 14:26:07 +0300
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="--2159753839863261329"
----2159753839863261329
Content-Type: text/plain;
Content-Transfer-Encoding: quoted-printable
get your meds online
Your easy-to-use solution is here:
http://rtmdsr.com/gp/deflt.asp?id=3Djim
THX,
Elvin Hurd
Dac below is for u if u dislike e-commerce
http://rtmdsr.com/er/r.asp?Folder=3Dgp
----2159753839863261329--

View File

@@ -1,549 +0,0 @@
From anaspec@rthlnk.net Tue Aug 31 15:36:37 2004
Return-Path: <nspec@rthlnk.net>
Received: from localhost (localhost [127.0.0.1])
by smtp.example.com (8.12.11/8.12.5) with ESMTP id i811APdX006705
for <exp@localhost>; Tue, 31 Aug 2004 18:10:26 -0700
Received: from snacker.example.com [207.111.254.120]
by localhost with IMAP (fetchmail-6.2.5)
for exp@localhost (single-drop); Tue, 31 Aug 2004 18:10:26 -0700 (PDT)
Received: from leggte.example.com ([207.111.254.118]) by snacker.example.com
(Netscape Messaging Server 4.15) with ESMTP id I3C17600.438 for
<exp@example.com>; Tue, 31 Aug 2004 15:30:42 -0700
Received: from rthlnk.net (218-35-236-63.etheric.net [63.236.35.218] (may be forged))
by leggte.example.com (8.12.8/8.12.8) with ESMTP id i7VMbcCu000722
for <exp@example.com>; Tue, 31 Aug 2004 15:37:38 -0700
Message-ID: <20040831153637.D2409658E4524456@rthlnk.net>
From: nspec@rthlnk.net
To: exp@example.com
Subject: Peptide News
Reply-To: nspec@rthlnk.net
Date: 31 Aug 2004 15:36:37 -0700
MIME-Version: 1.0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<html xmlns:v=3D"urn:schemas-microsoft-com:vml"
xmlns:o=3D"urn:schemas-microsoft-com:office:office"
xmlns:w=3D"urn:schemas-microsoft-com:office:word"
xmlns=3D"http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3DContent-Type content=3D"text/html; charset=3Diso-8859-1">=
<meta name=3DProgId content=3DWord.Document>
<meta name=3DGenerator content=3D"Microsoft Word 9">
<meta name=3DOriginator content=3D"Microsoft Word 9">
<link rel=3DFile-List href=3D"./30%25savings_files/fillst.xml">
<link rel=3DEdit-Time-Data href=3D"./30%25savings_files/edidta.mso">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<title>SynPep Corporation</title>
<!--[if gte mso 9]><xml>
<o:DocumentProperties>
<o:Author>davids</o:Author>
<o:LastAuthor>davids</o:LastAuthor>
<o:Revision>2</o:Revision>
<o:TotalTime>32</o:TotalTime>
<o:Created>2004-08-30T23:39:00Z</o:Created>
<o:LastSaved>2004-08-30T23:39:00Z</o:LastSaved>
<o:Pages>1</o:Pages>
<o:Words>670</o:Words>
<o:Characters>3821</o:Characters>
<o:Lines>31</o:Lines>
<o:Paragraphs>7</o:Paragraphs>
<o:CharactersWithSpaces>4692</o:CharactersWithSpaces>
<o:Version>9.6926</o:Version>
</o:DocumentProperties>
</xml><![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;
mso-font-charset:2;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:0 268435456 0 0 -2147483648 0;}
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-pitch:variable;
mso-font-signature:536871559 0 0 0 415 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";
color:maroon;}
a:link, span.MsoHyperlink
{color:blue;}
a:visited, span.MsoHyperlinkFollowed
{color:blue;}
pre
{margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";
mso-fareast-font-family:"Courier New";
color:maroon;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.Section1
{page:Section1;}
/* List Definitions */
@list l0
{mso-list-id:410741857;
mso-list-type:hybrid;
mso-list-template-ids:784620064 286026972 -788265640 993687158 626055678 -1=
811375712 -151983676 -930189644 1334191436 815690794;}
@list l0:level1
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:.5in;
mso-level-number-position:left;
text-indent:-.25in;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1
{mso-list-id:573589179;
mso-list-type:hybrid;
mso-list-template-ids:1335506698 -287414814 -166539250 1278239692 20987546 =
-72418112 -735677686 -1233212756 288795288 889766454;}
@list l1:level1
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:.5in;
mso-level-number-position:left;
text-indent:-.25in;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l2
{mso-list-id:1811441157;
mso-list-type:hybrid;
mso-list-template-ids:868497156 -610104194 1657037930 -1004880116 -13919388=
22 -1255648344 -314401074 -609714884 -811151446 832969692;}
@list l2:level1
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:.5in;
mso-level-number-position:left;
text-indent:-.25in;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1028"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1"/>
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor=3Dsilver lang=3DEN-US link=3Dblue vlink=3Dblue style=3D'tab-in=
terval:.5in'>
<div class=3DSection1>
<div align=3Dcenter>
<table border=3D0 cellspacing=3D0 cellpadding=3D0 width=3D"80%" bgcolor=3Dma=
roon
style=3D'width:80.0%;mso-cellspacing:0in;background:maroon;mso-padding-alt:=
.6pt .6pt .6pt .6pt'>
<tr>
<td style=3D'padding:.6pt .6pt .6pt .6pt'><!-- Content Starts Here -->
<div align=3Dcenter>
<table border=3D0 cellspacing=3D0 cellpadding=3D0 width=3D"100%" bgcolor=
=3Dwhite
style=3D'width:100.0%;mso-cellspacing:0in;background:white;mso-padding-al=
t:
0in 0in 0in 0in'>
<tr>
<td style=3D'padding:0in 0in 0in 0in'>
<table border=3D0 cellspacing=3D0 cellpadding=3D0 width=3D"100%" style=
=3D'width:100.0%;
mso-cellspacing:0in;mso-padding-alt:3.0pt 3.0pt 3.0pt 3.0pt'>
<tr>
<td width=3D"100%" valign=3Dbottom style=3D'width:100.0%;padding:3.0pt=
3.0pt 3.0pt 3.0pt'>
<p class=3DMsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></=
o:p></p>
</td>
</tr>
<tr>
<td width=3D"100%" style=3D'width:100.0%;padding:3.0pt 3.0pt 3.0pt 3.0=
pt'>
<p class=3DMsoNormal align=3Dcenter style=3D'text-align:center'><b><sp=
an
style=3D'font-size:14.5pt;font-family:Verdana'>Are you or your staff i=
n
need of Quality Peptides?<o:p></o:p></span></b></p>
</td>
</tr>
<tr>
<td style=3D'background:#FFDD66;padding:3.0pt 3.0pt 3.0pt 3.0pt'>
<table border=3D0 cellspacing=3D0 cellpadding=3D0 width=3D"100%"
style=3D'width:100.0%;mso-cellspacing:0in;mso-padding-alt:0in 0in 0in=
0in'>
<tr>
<td width=3D"70%" style=3D'width:70.0%;background:#FFDD66;padding:0i=
n 0in 0in 0in'>
<p class=3DMsoNormal><span style=3D'font-size:18.0pt;mso-bidi-font-s=
ize:
7.0pt;font-family:Verdana;color:black'>If the answer is </span><stro=
ng><span
style=3D'font-size:18.0pt;mso-bidi-font-size:7.0pt;font-family:Verda=
na;
color:navy'>YES</span></strong><span style=3D'font-size:18.0pt;
mso-bidi-font-size:7.0pt;font-family:Verdana;color:black'>, </span><=
strong><span
style=3D'font-size:18.0pt;mso-bidi-font-size:7.0pt;font-family:Verda=
na;
color:navy'>nSpec</span></strong><span style=3D'font-size:18.0pt;
mso-bidi-font-size:7.0pt;font-family:Verdana;color:black'> is offeri=
ng
up to 30% off your first new order.<br>
</span><span style=3D'font-size:7.0pt;font-family:Verdana;color:blac=
k'><br>
We are the market leader in the manufacturing of Custom Peptides, an=
d Catalog
Peptides,. We offer high-throughput manufacturing under GLP conditio=
ns
to meet the demand for synthetic peptides in pharmaceuticals,
biotechnology, agrochemical industries and research institutes.<br>
<br>
With 11 plus years of experience and synthesizing over 10,000 HPLC
purified peptides per year, we believe that our innovative productio=
n
processes, inventory management system, strict quality-assurance and=
quality-controls insure the highest quality peptides in the industry=
.<br>
<br>
In addition to our superior quality, We provide competitive prices,
fast delivery, and an award-winning technical support team that resu=
lt
in the best value available on the market. <o:p></o:p></span></p>
</td>
<td width=3D"30%" style=3D'width:30.0%;background:#FFDD66;padding:0i=
n 0in 0in 0in'>
<p class=3DMsoNormal><img id=3D"_x0000_i1026"
src=3D"http://www.bpfrntln.com/sals/girl.jpg" border=3D0
align=3Dmiddle></p>
</td>
</tr>
</table>
<p class=3DMsoNormal><o:p></o:p></p>
</td>
</tr>
<tr>
<td style=3D'background:#FFDD66;padding:3.0pt 3.0pt 3.0pt 3.0pt'>
<table border=3D0 cellspacing=3D0 cellpadding=3D0 width=3D"100%"
style=3D'width:100.0%;mso-cellspacing:0in;mso-padding-alt:1.8pt 1.8pt=
1.8pt 1.8pt'>
<tr>
<td width=3D"30%" valign=3Dtop style=3D'width:30.0%;background:#FFDD=
66;
padding:1.8pt 1.8pt 1.8pt 1.8pt'>
<p class=3DMsoNormal><img width=3D249 height=3D249 id=3D"_x0000_i102=
7"
src=3D"http://www.bpfrntln.com/sals/chem.jpg" border=3D0></p>
</td>
<td width=3D"70%" style=3D'width:70.0%;background:#FFDD66;padding:1.=
8pt 1.8pt 1.8pt 1.8pt'>
<p class=3DMsoNormal style=3D'margin-bottom:12.0pt'><strong><span
style=3D'font-size:8.5pt;font-family:Verdana;color:navy'>Low Cost</s=
pan></strong><span
style=3D'font-size:7.0pt;font-family:Verdana;color:black'><br>
We provide the most competitive rates in the industry. Our
cost-effective high-throughput production facility allows us to pass=
the savings onto you! We have built our facility and capabilities
around state-of-the-art equipment and have meticulously fine-tuned o=
ur
process methodology to avoid the high cost of unnecessary labor. <a
href=3D"mailto:nspec@rthlnk.net?subject=3DREF.CODE:SeptemberSpe=
cial"><span style=3D'text-decoration:
none;text-underline:none'>Click here</span></a> to find out more abo=
ut
our low cost.<br>
<br>
</span><strong><span style=3D'font-size:8.5pt;font-family:Verdana;
color:navy'>Quality</span></strong><span style=3D'font-size:7.0pt;
font-family:Verdana;color:black'><br>
Under GLP conditions, our products are manufactured under protocol a=
nd
tracked using our Data Management System. All produced peptides are
shipped with HPLC, Mass Spectra Analysis, and UV Scan Data. Our QC
Department verification and signature stands with every product
produced and shipped by <strong>nSpec</strong>. <a
href=3D"mailto:nspec@rthlnk.net?subject=3DREF.CODE:SeptemberSpe=
cial"><span style=3D'text-decoration:
none;text-underline:none'>Click here</span></a> to find out more abo=
ut
our quality.<br>
<br>
</span><strong><span style=3D'font-size:8.5pt;font-family:Verdana;
color:navy'>Service</span></strong><span style=3D'font-size:7.0pt;
font-family:Verdana;color:black'><br>
We here at <strong>nSpec</strong>, are continuing to advance our
excellence to the customer. We provide our customers with 100%
satisfaction guarantee on our products, services, and delivery. Our
production turnaround time for delivery is around 3 weeks. <a
href=3D"mailto:nspec@rthlnk.net?subject=3DREF.CODE:SeptemberSpe=
cial"><span style=3D'text-decoration:
none;text-underline:none'>Click here</span></a> to find out more abo=
ut
our service.<o:p></o:p></span></p>
</td>
</tr>
</table>
<p class=3DMsoNormal><o:p></o:p></p>
</td>
</tr>
<tr>
<td style=3D'padding:3.0pt 3.0pt 3.0pt 3.0pt'
background=3D"http://www.bpfrntln.com/sals/bg.jpg">
<p class=3DMsoNormal><strong><span style=3D'font-size:8.5pt;font-famil=
y:Verdana;
color:black'>The nSpec Family</span></strong><span style=3D'font-siz=
e:
7.0pt;font-family:Verdana;color:black'><br>
In addition to producing the regular peptides, nSpechas the capacity=
to
offer almost every commercially available peptide modifications. <o:p>=
</o:p></span></p>
<div align=3Dcenter>
<table border=3D0 cellspacing=3D3 cellpadding=3D0 width=3D"80%" style=
=3D'width:
80.0%;mso-cellspacing:1.5pt'>
<tr>
<td valign=3Dtop style=3D'padding:.75pt .75pt .75pt .75pt'>
<ul type=3Ddisc>
<li class=3DMsoNormal style=3D'color:black;mso-margin-top-alt:auto;=
mso-margin-bottom-alt:auto;mso-list:l2 level1 lfo1;tab-stops:li=
st .5in'><span
style=3D'font-size:7.0pt;font-family:Verdana'>Long Peptide Synt=
hesis
up to 100-mer <o:p></o:p></span></li>
<li class=3DMsoNormal style=3D'color:black;mso-margin-top-alt:auto;=
mso-margin-bottom-alt:auto;mso-list:l2 level1 lfo1;tab-stops:li=
st .5in'><span
style=3D'font-size:7.0pt;font-family:Verdana'>Fluorescent Label=
ed
Peptides (such as): FITC/5 FAM, EDANS, TAMRA, Etc. <o:p></o:p><=
/span></li>
<li class=3DMsoNormal style=3D'color:black;mso-margin-top-alt:auto;=
mso-margin-bottom-alt:auto;mso-list:l2 level1 lfo1;tab-stops:li=
st .5in'><span
style=3D'font-size:7.0pt;font-family:Verdana'>Multiple Disulfid=
e
Bridges containing Peptides <o:p></o:p></span></li>
<li class=3DMsoNormal style=3D'color:black;mso-margin-top-alt:auto;=
mso-margin-bottom-alt:auto;mso-list:l2 level1 lfo1;tab-stops:li=
st .5in'><span
style=3D'font-size:7.0pt;font-family:Verdana'>Multiple Phospho
Related Peptides <o:p></o:p></span></li>
<li class=3DMsoNormal style=3D'color:black;mso-margin-top-alt:auto;=
mso-margin-bottom-alt:auto;mso-list:l2 level1 lfo1;tab-stops:li=
st .5in'><span
style=3D'font-size:7.0pt;font-family:Verdana'>Symmetrical and
Unsymmetrical Multiple Antigenic Peptides (MAPS) <o:p></o:p></s=
pan></li>
</ul>
</td>
<td valign=3Dtop style=3D'padding:.75pt .75pt .75pt .75pt'>
<ul type=3Ddisc>
<li class=3DMsoNormal style=3D'color:black;mso-margin-top-alt:auto;=
mso-margin-bottom-alt:auto;mso-list:l1 level1 lfo2;tab-stops:li=
st .5in'><span
style=3D'font-size:7.0pt;font-family:Verdana'>Fatty Acid and
Isoprenylated Peptides <o:p></o:p></span></li>
<li class=3DMsoNormal style=3D'color:black;mso-margin-top-alt:auto;=
mso-margin-bottom-alt:auto;mso-list:l1 level1 lfo2;tab-stops:li=
st .5in'><span
style=3D'font-size:7.0pt;font-family:Verdana'>Glycosylated Pept=
ides <o:p></o:p></span></li>
<li class=3DMsoNormal style=3D'color:black;mso-margin-top-alt:auto;=
mso-margin-bottom-alt:auto;mso-list:l1 level1 lfo2;tab-stops:li=
st .5in'><span
style=3D'font-size:7.0pt;font-family:Verdana'>Regio-Selective C=
onjugation
of Peptides with Antibiotics, Nucleotides, Proteins, Etc. <o:p>=
</o:p></span></li>
<li class=3DMsoNormal style=3D'color:black;mso-margin-top-alt:auto;=
mso-margin-bottom-alt:auto;mso-list:l1 level1 lfo2;tab-stops:li=
st .5in'><span
style=3D'font-size:7.0pt;font-family:Verdana'>Biotinylation <o:=
p></o:p></span></li>
</ul>
</td>
</tr>
</table>
</div>
<p class=3DMsoNormal><span style=3D'font-size:7.0pt;font-family:Verdan=
a;
color:black'>Our state-of-the-art facility and
innovative-industrial-processes provide additional services: <o:p></o:=
p></span></p>
<ul type=3Ddisc>
<li class=3DMsoNormal style=3D'color:black;mso-margin-top-alt:auto;
mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo3;tab-stops:list=
.5in'><b><span
style=3D'font-size:7.0pt;font-family:Verdana'>Purification</span>=
</b><span
style=3D'font-size:7.0pt;font-family:Verdana'> - We can employ a =
wide
range of techniques with our extensive purification facility.<o:p=
></o:p></span></li>
<li class=3DMsoNormal style=3D'color:black;mso-margin-top-alt:auto;
mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo3;tab-stops:list=
.5in'><strong><span
style=3D'font-size:7.0pt;font-family:Verdana'>Custom Synthesis</s=
pan></strong><span
style=3D'font-size:7.0pt;font-family:Verdana'> - Custom Synthesis=
of
Amino Acids &amp; Resins and General Organic Synthesis <o:p></o:p=
></span></li>
<li class=3DMsoNormal style=3D'color:black;mso-margin-top-alt:auto;
mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo3;tab-stops:list=
.5in'><strong><span
style=3D'font-size:7.0pt;font-family:Verdana'>Amino Acid Cartridg=
es</span></strong><span
style=3D'font-size:7.0pt;font-family:Verdana'> - Cost Effective R=
efill
Service <o:p></o:p></span></li>
<li class=3DMsoNormal style=3D'color:black;mso-margin-top-alt:auto;
mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo3;tab-stops:list=
.5in'><strong><span
style=3D'font-size:7.0pt;font-family:Verdana'>Mass Spectrometry</=
span></strong><span
style=3D'font-size:7.0pt;font-family:Verdana'> - Electrospray,
Electron Impact, APCI, LC, and Well Plate Analysis <o:p></o:p></s=
pan></li>
<li class=3DMsoNormal style=3D'color:black;mso-margin-top-alt:auto;
mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo3;tab-stops:list=
.5in'><strong><span
style=3D'font-size:7.0pt;font-family:Verdana'>Analytical Services=
</span></strong><span
style=3D'font-size:7.0pt;font-family:Verdana'> - Liquid
Chromatography, Capillary Electrophoresis, and Amino Acid Analysi=
s <o:p></o:p></span></li>
<li class=3DMsoNormal style=3D'color:black;mso-margin-top-alt:auto;
mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo3;tab-stops:list=
.5in'><strong><span
style=3D'font-size:7.0pt;font-family:Verdana'>Antibody Services</=
span></strong><span
style=3D'font-size:7.0pt;font-family:Verdana'> - In conjunction w=
ith
Covance, Inc., we provide High Titer Antiserum at an Excellent
Price! <o:p></o:p></span></li>
</ul>
<p class=3DMsoNormal><strong><span style=3D'font-size:7.0pt;font-famil=
y:Verdana;
color:black'>nSpec</span></strong><span style=3D'font-size:7.0pt;
font-family:Verdana;color:black'> is a privately held company establis=
hed
in 1993. nSpecis located in San Jose, California and occupies a 18,0=
00
sq. ft facility for our laboratories and administrative offices.<br>
<br>
For a FREE catalog and more information about <strong>nSpec</strong>=
,
please visit us on the Internet at <a href=3D"http://www.nspc.com/"=
>http://www.nspc.com/</a>.<br>
<br>
Reply via Fax, Phone, or <a
href=3D"mailto:nspc@rthlnk.net?subject=3DREF.CODE:SeptemberSpeci=
al">email</a>
with <strong>REF. CODE: September Special</strong> to see how you can
start your savings today with <strong>nSpec</strong>! <o:p></o:p></s=
pan></p>
<pre><span style=3D'font-size:7.0pt;font-family:Verdana;color:black'><=
![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre><pre><span
style=3D'font-size:7.0pt;font-family:Verdana;color:black'><![if !suppo=
rtEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre><pre><b><span
style=3D'font-size:7.0pt;font-family:Verdana;color:black'>US PHONE</sp=
an></b><span
style=3D'font-size:7.0pt;font-family:Verdana;color:black'>:<span
style=3D'mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>408 =
517 4223<o:p></o:p></span></pre><pre><b><span
style=3D'font-size:7.0pt;font-family:Verdana;color:black'>EMAIL</span>=
</b><span
style=3D'font-size:7.0pt;font-family:Verdana;color:black'>:<span
style=3D'mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><a
href=3D"mailto:nspec@rthlnk.net?subject=3DREF.CODE:SeptemberSpeci=
al">nspec@rthlnk.net</a></span></pre>
<p class=3DMsoNormal><img border=3D0 width=3D1 height=3D1 id=3D"_x0000=
_i1028"
src=3D"http://www.bpfrntln.com/sals/rddot.gif"></p>
<p class=3DMsoNormal align=3Dcenter style=3D'text-align:center'><span
style=3D'font-size:5.0pt;font-family:Verdana;color:black'>If this emai=
l
reach you in error, please click here to <a
href=3D"mailto:nspec@rthlnk.net?subject=3DRemove"><span
style=3D'color:red'>remove</span></a>. If this link is not working, pl=
ease
reply to this email with &quot;Remove&quot; in the subject line.<o:p><=
/o:p></span></p>
</td>
</tr>
</table>
<!-- Content ends here -->
<p class=3DMsoNormal><o:p></o:p></p>
</td>
</tr>
</table>
</div>
<p class=3DMsoNormal><o:p></o:p></p>
</td>
</tr>
</table>
</div>
<p class=3DMsoNormal><span style=3D'color:windowtext'><![if !supportEmptyPar=
as]>&nbsp;<![endif]><o:p></o:p></span></p>
</div>
</body>
</html>

View File

@@ -1,56 +0,0 @@
From dkt@kdku.net Sat May 8 21:00:39 2004
Return-Path: <dkt@kdku.net>
Received: from kaduku.net ([218.72.106.135])
by leggite.example.com (8.12.8/8.12.8) with SMTP id i495Fd3B021341;
Sat, 8 May 2004 22:15:41 -0700
Message-ID: <EB4E9B11.9430CE4@kaduku.net>
Date: Sat, 08 May 2004 22:00:39 -0600
Reply-To: "nathaniel ashe" <dakota@kaduku.net>
From: "nathaniel ashe" <dakota@kaduku.net>
User-Agent: 8.0 for Windows sub 6014
MIME-Version: 1.0
To: "wes estvz" <will@example.com>,
"jamey koontz" <hb@example.com>
Subject: Jsevrgtl bvy V~i_c_o`din 0n1ine For Less
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Status: RO
prcc pneumocystis racepoint
And to give you a general idea of what we specialize in:
Help relieve your pain V~ico.din
every0ne is app.roved
L H http://nds.idswthmr.com/wdj/
Give up: http://nds.idswthmr.com/wdj/rm.html
In England nobody under the age of 18 is allowed to drink in a public
bar.Mr. Thompson used to go to a bar near his house quite often, but he
never took his son, Tom, because he was too young. Then when Tom had his
eighteenth birthday, Mr. Thompson took him to his usual bar for the first
time. They drank for half an hour, and then Mr. Thompson said to his son,
"Now, Tom, I want to teach you a useful lesson. You must always be careful
not to drink too much. And how you know when you've had enough? Well, I'll
tell you. Do you see those two lights at the end of the bar? When they seem
to have become four, you've had enough and should go home.""But , Dad," said
Tom, " I can only see one light at the end of the bar".
The wedding date was set and the groom's three pals, a carpenter, an
electrician, and a dentist, were deciding what pranks to play on the couple
on their wedding night.The carpenter decided that he would saw the slats off
their bed. The electrician figured that wiring the bed with alternating
current would give them a few chuckles. The dentist would not tell the
others what he had done, and wore a sly grin, simply suggesting that his gag
would be a memorable one. The wedding and reception went as planned. A few
days later, each of the groom's three friends received a letter which read
as follows. Dear friends, We didn't mind the bed slats being sawed. The
electric shock was only a minor setback. But, I swear to God Almighty, I'm
going to kill the idiot who put Novocain in the K-Y Jelly.
dnrre9htmim05kobore,boyaboya aseton.

View File

@@ -1,666 +0,0 @@
From wfskr@fstml.us Wed Sep 1 17:37:30 2004
Return-Path: <wfskr@fstml.us>
Received: from 63.194.242.243 (adsl-63-194-242-243.dsl.lsan03.pacbell.net [63.194.242.243])
by leggite.example.com (8.12.8/8.12.8) with SMTP id i820cVCv002160
for <exp@example.com>; Wed, 1 Sep 2004 17:38:33 -0700
Message-Id: <200409020038.i820cVCv002160@leggite.example.com>
From: "wf skr" <wfskr@fstml.us>
To: <exp@example.com>
Subject: The wf skr...
Sender: "wf skr" <wfskr@fstml.us>
Mime-Version: 1.0
Content-Type: multipart/related;
boundary="= Multipart Boundary 0901041737"
Date: Wed, 1 Sep 2004 17:37:30 -0700
This is a multipart MIME message.
--= Multipart Boundary 0901041737
Content-Type: multipart/alternative;
boundary="= Multipart Boundary _EXTRA_0901041737"
--= Multipart Boundary _EXTRA_0901041737
Content-Type: text/plain;
charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by leggite.example.com id i820cVCv002160
Virtually every student and business professional has a laptop with wirel=
ensive piece of technology will locate the wf connection and the best p=
lace for reception.
Where to buy (eB): http://cgi.eb.com/ws/eBISAPI.dll?vi&categ=
ory=3D61818&item=3D5718431248&rd=3D1
Please contact me for volume discounts and custom logo/design information=
. We can do clamshell, bulk or custom packaging. Colors, school logos, =
etc. are not a problem and at minor additional cost or free if the quanti=
ty is large enough!!
Thank you, and reply with REMOVE to opt-out...
-Brian
reply to wfskr@fstml.us I will not be sending you multiple messag=
es on this.... Thanks again...
Tuesday, April 27, 2004 | by Eamon Hickey
=20
keychain-sized device that scans for active wf (802.11b) networks. It's=
also handy for measuring signal strength within a given coverage area.
=20
Gizmodo.com: Best Wi-Fi Signal Finder Yet, 04/22/2004 05:19
=20
stargeek: Best Wi-Fi Signal Finder Yet, 04/22/2004 05:19
=20
wf skr, which they designed to differentiate 80211b/g networks from=
other devices. Two previous Wi-Fi signal finders fell short in ways the =
active scan--but it can tell Wi-Fi from junk.
=20
ngdgt.com: The wf skr Apr 23, 2004
ll use ours fairly often). Anyway, Glenn Fleishman checks out a brand new=
He says it=92s the best of the bunch and that it should be on sale by Ju=
ne.=20
=20
Wi-Fi skr: Hotspot seeking keychain
=20
earth, finding wireless access points with the equivalent of a tiny divin=
g hotspots and junk interference, something this latest version is appare=
ntly much better at.
--= Multipart Boundary _EXTRA_0901041737
Content-Type: text/html;
charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by leggite.example.com id i820cVCv002160
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dwindows-1=
252">
<META content=3D"MSHTML 6.00.2800.1458" name=3DGENERATOR>
<STYLE>BODY {
FONT-FAMILY: arial
}
</STYLE>
</HEAD>
<BODY>
<DIV>
<DIV>
<DIV><SPAN class=3d3-4><SPAN class=3d7-0><F=
ONT=20
face=3DArial size=3D2>Virtually every student<SPAN class=3D458063818-1905=
2004>=20
and&nbsp;<SPAN class=3D450083818-19052004>b</SPAN></SPAN><SPAN=20
class=3D101323200-04052004>usiness&nbsp;<SPAN=20
class=3D450083818-19052004>p</SPAN>rofessional</SPAN> has a laptop=20
with&nbsp;wireless LAN&nbsp;capability, and wants to log anywhere and=20
everywhere.&nbsp; This inexpensive piece of technology will locate the Wi=
Fi=20
connection and the best place for reception.</FONT></SPAN></SPAN></DIV>
<DIV><SPAN class=3d3-4><SPAN class=3d7-0><F=
ONT=20
face=3DArial size=3D2></FONT></SPAN></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3d3-4><SPAN=20
class=3d7-0><STRONG><U><FONT face=3DArial size=3D2>What it=
=20
is:</FONT></U></STRONG></SPAN></SPAN></DIV>
<DIV><FONT size=3D2><FONT face=3DArial><SPAN class=3d3-4><=
SPAN=20
class=3d7-0><SPAN class=3d3-4><SPAN=20
class=3d7-0>T</SPAN>he wf skr</SPAN></SPAN>&nbsp;find=
<SPAN=20
class=3d7-0>s</SPAN>&nbsp;wireless hot spot<SPAN=20
class=3d7-0>s</SPAN> (<SPAN class=3d3-4>w</=
SPAN><SPAN=20
class=3d3-4>ithout having to boot-up your computer)=20
and&nbsp;</SPAN>finds the strongest wireless (802.11 b/g)=20
signal.&nbsp;&nbsp;W</SPAN>hether you're in an airport,&nbsp;<SPAN=20
class=3d7-0>coffee shop, classroom</SPAN> or&nbsp;at home,=
the wf=20
skr will&nbsp;zero-in on the best access point.&nbsp;<SPAN=20
class=3d3-4> </SPAN><BR></FONT></FONT></DIV>
<DIV><FONT size=3D2><FONT face=3DArial><SPAN=20
class=3d7-0></SPAN><STRONG><U></U></STRONG></FONT></FONT>&=
nbsp;</DIV>
<DIV><FONT size=3D2><FONT face=3DArial><STRONG><U>H<SPAN class=3D72630411=
5-06052004>ow=20
it works:</SPAN></U></STRONG><BR>Simply point the wf skr in any=20
direction<SPAN class=3d3-4>, p</SPAN>ush the button and ho=
ld it=20
down.<SPAN class=3d3-4> </SPAN>&nbsp;The red lights sweep =
back and=20
forth<SPAN class=3d3-4>, i</SPAN>f there is a wireless acc=
ess point=20
within 300 feet, the wf skr will find it<SPAN class=3D331482323-0305=
2004>.=20
</SPAN>&nbsp;When the red lights stop sweeping and remain lit, you've loc=
ated an=20
(802.11 b/g) access point<SPAN class=3d3-4>, t</SPAN>he mo=
re red=20
lights that stay lit, the stronger the signal.&nbsp;<BR><BR></FONT></FONT=
><SPAN=20
class=3d3-4><SPAN class=3d3-4><SPAN=20
class=3d7-0><FONT size=3D2><FONT face=3DArial><STRONG><SPA=
N><U>Where to=20
buy<SPAN class=3D717052920-06082004> (eB)</SPAN>:</U><SPAN=20
class=3D717052920-06082004>&nbsp; <U><A=20
href=3D"http://cgi.eb.com/ws/eBISAPI.dll?vi&amp;ctg=3D6181=
8&amp;item=3D5718431248&amp;rd=3D1">http://cgi.eb.com/ws/eBISAPI.dll?=
vi&amp;ctg=3D61818&amp;item=3D5718431248&amp;rd=3D1</A></U></S=
PAN></SPAN></STRONG><BR></FONT></FONT></SPAN></SPAN></SPAN></DIV>
<DIV><SPAN class=3d3-4><FONT size=3D2><FONT face=3DArial><=
SPAN=20
class=3d3-4><SPAN=20
class=3d7-0>Please&nbsp;c</SPAN></SPAN>ontact me for volum=
e=20
discount<SPAN class=3d7-0>s</SPAN>&nbsp;and custom=20
logo/design&nbsp;<SPAN class=3d7-0>information</SPAN>.<SPA=
N=20
class=3d7-0>&nbsp; We can do clamshell, bulk or custom=20
packaging.&nbsp; Colors, school logos, etc. are not&nbsp;a problem and at=
minor=20
additional cost<SPAN class=3D717052920-06082004> or free if the quantity =
is large=20
enough!!</SPAN></SPAN></FONT></FONT></SPAN></DIV>
<DIV><SPAN class=3d3-4><SPAN class=3d7-0><F=
ONT=20
face=3DArial size=3D2></FONT></SPAN></SPAN>&nbsp;</DIV>
<DIV>
<DIV><SPAN class=3d3-4><FONT face=3DArial=20
size=3D2></FONT></SPAN></DIV><SPAN class=3d3-4></SPAN></DI=
V>
<DIV><SPAN class=3d3-4><FONT face=3DArial size=3D2>Thank y=
ou, and reply=20
with REMOVE to opt-out...</FONT></SPAN></DIV>
<DIV><SPAN style=3D"FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"><A=20
href=3D"http://www.dnncrprtd.com/"><FONT face=3DArial size=3D2></FO=
NT></A><FONT=20
color=3D#000000></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN style=3D"FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"></S=
PAN><SPAN=20
style=3D"FONT-FAMILY: Arial"><SPAN style=3D"FONT-FAMILY: Arial"><SPAN=20
style=3D"FONT-FAMILY: Arial"><SPAN class=3D717052920-06082004><FONT=20
size=3D2>-Brian</FONT></SPAN></SPAN></SPAN></SPAN></DIV>
<DIV><SPAN style=3D"FONT-FAMILY: Arial"><SPAN style=3D"FONT-FAMILY: Arial=
"><SPAN=20
style=3D"FONT-FAMILY: Arial"><SPAN class=3D717052920-06082004><FONT face=3D=
Arial=20
size=3D2></FONT></SPAN></SPAN></SPAN></SPAN>&nbsp;</DIV>
<DIV><SPAN style=3D"FONT-FAMILY: Arial"><SPAN style=3D"FONT-FAMILY: Arial=
"><SPAN=20
style=3D"FONT-FAMILY: Arial"><SPAN class=3D717052920-06082004><FONT size=3D=
2>reply to=20
</FONT><A href=3D"mailto:wfskr@fstml.us"><FONT=20
size=3D2>wfskr@fstml.us</FONT></A><FONT size=3D2>&nbsp;<SPAN=20
class=3D072343215-26082004>I will not be sending you multiple messages on=
this....=20
Thanks again...</SPAN></FONT></SPAN></SPAN></SPAN></SPAN></DIV>
<DIV class=3DSection1>
<P align=3Dcenter><FONT size=3D3><SPAN style=3D"FONT-FAMILY: Arial"><FONT=
size=3D3><SPAN=20
style=3D"FONT-FAMILY: Arial"><FONT size=3D3><SPAN=20
style=3D"FONT-FAMILY: Arial"></SPAN></FONT></SPAN></FONT></SPAN></FONT></=
P>
<P align=3Dcenter><FONT size=3D3><SPAN style=3D"FONT-FAMILY: Arial"><FONT=
size=3D3><SPAN=20
style=3D"FONT-FAMILY: Arial"><FONT size=3D3><SPAN style=3D"FONT-FAMILY: A=
rial"><SPAN=20
style=3D"FONT-FAMILY: Arial"><SPAN=20
style=3D"FONT-FAMILY: Arial"><STRONG><U></U></STRONG></SPAN></SPAN></SPAN=
></FONT></SPAN></FONT></SPAN></FONT></P>
<P align=3Dleft><FONT size=3D3><SPAN style=3D"FONT-FAMILY: Arial"><FONT s=
ize=3D3><SPAN=20
style=3D"FONT-FAMILY: Arial"><FONT size=3D3><SPAN=20
style=3D"FONT-FAMILY: Arial"><SPAN><FONT size=3D4><IMG alt=3D"" hspace=3D=
0=20
src=3D"cid:2183279"=20
align=3Dbaseline border=3D0>Wi-Fi Networking News: Crsls wf=20
seeker&nbsp;&nbsp;<?xml:namespace prefix =3D o ns =3D=20
"urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT></SPAN></P>
<H1 class=3dmn style=3D"MARGIN: 0in 0in 0pt"><SPAN class=3Dbodytex=
tbold1><SPAN=20
style=3D"FONT-SIZE: 9pt; COLOR: black; LETTER-SPACING: 0pt">Tuesday,&nbsp=
;April&nbsp;27,&nbsp;2004</SPAN></SPAN><SPAN=20
style=3D"FONT-SIZE: 9pt; COLOR: black">&nbsp;|&nbsp;by Eamon Hickey</SPAN=
></H1>
<H1 class=3dmn style=3D"MARGIN: 0in 0in 0pt"><SPAN style=3D"COLOR:=
black"><FONT=20
size=3D2>&nbsp;<o:p></o:p></FONT></SPAN></H1></DIV>
<DIV class=3DSection1 style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 9pt; COLOR: black"><FONT size=3D2>Wi-Fi Networking Ne=
ws has=20
this<SPAN class=3d3-4> </SPAN><SPAN class=3D331482323-0305=
2004>brief=20
report on Crsls Wi Fi skr,&nbsp;</SPAN>a keychain-sized device tha=
t scans=20
for active wf (802.11b) networks. It's also handy for measuring signal=20
strength within a given coverage area.<o:p></o:p></FONT></SPAN></DIV>
<H1 class=3DSection1 style=3D"MARGIN: 0in 0in 0pt">
<P class=3dmn style=3D"MARGIN: 0in 0in 0pt"><FONT=20
size=3D2>&nbsp;<o:p></o:p></FONT></P>
<H1 style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D4><SPAN>Gizmd.com<SPAN=20
class=3D130050304-05052004>:</SPAN></SPAN> Best Wi-Fi Signal Finder=20
Yet</FONT><FONT size=3D3>, </FONT><SPAN style=3D"FONT-SIZE: 8.5pt">04/22/=
2004=20
05:19</SPAN><SPAN=20
style=3D"FONT-SIZE: 14pt; COLOR: #666699; FONT-FAMILY: Verdana; mso-bidi-=
font-size: 10.0pt"><o:p></o:p></SPAN></H1>
<P style=3D"MARGIN: 0in 0in 0pt; LINE-HEIGHT: 12pt"><SPAN=20
style=3D"FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: Arial"></SPAN></P>
<P class=3dmn style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"COLOR: black; FONT-FAMILY: 'Times New Roman'"><FONT=20
size=3D2>&nbsp;<o:p></o:p></FONT></SPAN></P></H1>
<H1 class=3DMsoBodyText style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D2>Glen=
n Fleishman=20
got a hold of the Crsls wf skr, a keychain-sized sniffer to dete=
ct=20
802.11b/g networks and says it's the best yet:</FONT></H1>
<H1 class=3DSection1 style=3D"MARGIN: 0in 0in 0pt">
<P class=3DMsoBodyText style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D2>Push =
the button on=20
signal strength in zero to four LEDs. Keep the button held down and it=92=
s a Wi-Fi=20
dowser, allowing you to move around and see immediate response to differe=
nt=20
signal strengths.</FONT></P>
<P class=3dmn style=3D"MARGIN: 0in 0in 0pt"><SPAN style=3D"COLOR: =
black"><FONT=20
size=3D2><FONT face=3DArial>&nbsp;<o:p></o:p></FONT></FONT></SPAN></P>
<P class=3dmn style=3D"MARGIN: 0in 0in 0pt"><FONT color=3D#000080>=
<SPAN=20
style=3D"FONT-SIZE: 14pt; COLOR: #333399; FONT-FAMILY: Verdana; mso-bidi-=
font-size: 10.0pt"><FONT=20
size=3D4>stargeek<SPAN class=3D130050304-05052004>:</SPAN><SPAN=20
class=3D130050304-05052004>&nbsp;</SPAN></FONT></SPAN><SPAN=20
style=3D"FONT-FAMILY: Georgia"><FONT size=3D2>Best Wi-Fi Signal Finder Ye=
t,=20
</FONT></SPAN><SPAN style=3D"FONT-SIZE: 8.5pt; FONT-FAMILY: Georgia">04/2=
2/2004=20
05:19</SPAN></FONT></P></H1>
<DIV class=3dmn style=3D"MARGIN: 0in 0in 0pt"><FONT color=3D#00008=
0><SPAN=20
style=3D"FONT-SIZE: 8.5pt; FONT-FAMILY: Georgia"></SPAN><SPAN=20
style=3D"FONT-FAMILY: Georgia"><o:p></o:p></SPAN></FONT><FONT=20
size=3D2>&nbsp;</FONT></DIV>
<DIV class=3dmn style=3D"MARGIN: 0in 0in 0pt"><FONT color=3D#00008=
0><FONT=20
size=3D2><SPAN style=3D"FONT-FAMILY: Georgia; LETTER-SPACING: 0.2pt">Chry=
salis=20
previous Wi-Fi signal finders fell short in ways the skr does not. The=
=20
displaying the results instant of a constant active scan--but it can tell=
Wi-Fi=20
from junk.</SPAN><SPAN=20
style=3D"COLOR: black"><o:p></o:p></SPAN></FONT></FONT></DIV>
<H1 class=3DSection1 style=3D"MARGIN: 0in 0in 0pt">
<P class=3dmn style=3D"MARGIN: 0in 0in 0pt"><SPAN style=3D"COLOR: =
black"><FONT=20
size=3D2>&nbsp;</FONT></SPAN><SPAN style=3D"COLOR: black"><FONT=20
size=3D2>&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=3dmn style=3D"MARGIN: 0in 0in 0pt"><SPAN><FONT=20
size=3D4>ngdgt.com<SPAN class=3d3-4>: The wf=20
skr</SPAN></FONT>&nbsp;</SPAN><FONT size=3D2>Apr 23, 2004</FONT></P>
<P class=3dmn style=3D"MARGIN: 0in 0in 0pt"><FONT=20
size=3D2></FONT>&nbsp;</P></H1>
<DIV class=3dmn style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D2>There=
were a=20
couple of&nbsp;credit card-sized&nbsp;wf detectors that came out last y=
ear,=20
signals occupying the 2.4GHz part of the spectrum. He says it=92s the bes=
t of the=20
bunch and that it should be on sale by&nbsp;June.&nbsp;</FONT></DIV>
<H1 class=3DSection1 style=3D"MARGIN: 0in 0in 0pt">
<P class=3dmn style=3D"MARGIN: 0in 0in 0pt"><FONT=20
size=3D2>&nbsp;<o:p></o:p></FONT></P>
<P class=3dmn style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 14pt; COLOR: #333399; FONT-FAMILY: Verdana; mso-bidi-=
font-size: 9.5pt"><A=20
href=3D"http://www.brdbndrprts.com/shnws/42831"></A><A=20
href=3D"http://www.brdbndrprts.com/shnws/42831"><SPAN=20
style=3D"COLOR: #333399; TEXT-DECORATION: none; mso-bidi-font-size: 10.0p=
t; text-underline: none"><FONT=20
color=3D#000000 size=3D4>Wi-Fi skr</FONT></SPAN></A><FONT color=3D#000=
000><FONT=20
size=3D4><SPAN class=3d3-4></SPAN>: </FONT></FONT><A=20
href=3D"http://www.brdbndrprts.com/shnws/42831"><SPAN=20
style=3D"COLOR: #333399; TEXT-DECORATION: none; text-underline: none"><FO=
NT=20
color=3D#000000 size=3D4>Hotspot seeking=20
keychain</FONT></SPAN></A><o:p></o:p></SPAN></P>
<P class=3dmn style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 9.5pt; COLOR: black; FONT-FAMILY: Verdana"><FONT=20
size=3D2>&nbsp;<o:p></o:p></FONT></SPAN></P></H1>
<DIV class=3dmn style=3D"MARGIN: 0in 0in 0pt"><SPAN class=3Dnews1>=
<SPAN=20
style=3D"FONT-SIZE: 9.5pt; COLOR: black; FONT-FAMILY: Verdana"><A=20
href=3D"http://wifntnws.com/archives/003248.html"><SPAN=20
style=3D"COLOR: black"><FONT size=3D2>Wi-Fi Networking News</FONT></SPAN>=
</A><FONT=20
size=3D2> takes a look at the new "</FONT><A=20
href=3D"http://wifntnws.com/archives/003248.html"><SPAN=20
style=3D"COLOR: black"><FONT size=3D2>Wi-Fi skr</FONT></SPAN></A><FONT=
size=3D2>"=20
and junk interference, something this latest version is apparently much b=
etter=20
at.</FONT></SPAN></SPAN></DIV></SPAN></FONT></SPAN></FONT></SPAN></FONT><=
/DIV></DIV></BODY></HTML>
--= Multipart Boundary _EXTRA_0901041737--
--= Multipart Boundary 0901041737
Content-Type: application/octet-stream;
name="retail.jpg"
Content-ID: <2183279>
Content-Disposition: attachment;
filename="retail.jpg"
Content-Transfer-Encoding: base64
/9j/6wJgRVBTAHic7ZjJigIxEIbn/Z/EiwfxoHjQgyfB5aKg4oKouIH7goow
UPAdDJPpZKxMO0N/l5+mO92V6qSWfHwkJCT8d87ns+hmsxGtVqui5XJZNJVK
ic7n8y/HX69X0VarJZrJZJ7G9fv9EGYHYzqdimI/mk6nRYvFomilUhFtNpui
+Xxe1Jw/yv16vf40LpvNiv4VP2Hvcrn0GsfzzJvr2+327Tju4793YzabiRYK
BdHJZBKLHcPhMJbvDgYDUeZvrnvWC/tFi6h1Y0J8Ox6Pqnas12tR1/nzn06n
k6odJp1OR/R+v3uN6/V6Kt/fbreixE3iHvvD9/9pcblcvJ4nv0Gj0VCxI5fL
icblh8ViIcq+0IL4/iqs39CMRiNRbT/YiCs//BWIi6vVKsj749pv2lBva8M+
IK+Hej/5kvxIXW0qcdK3PqaPCYV2PUrfQJ3gWx9QV+CvKLTitA3sob/05fF4
iOJnrXqJ/d9ut799jv7Et37ytaNUKv1oPH7xjWfUM/QttVpNlDxI/WfLU4fD
4el6PB57fd8X376Bde26XogTtrrdjEfcJ451u90vvw9a9bQN7HCNj5zr2NYN
72OezJv97Lre8D/7iPeZ5wb7/d7pfa/iGq/N8wlgv9DPaNdxvucp2rj2pZyP
sU52u50ofvmtOjoufOM1ceS3/ELfHRf0+VHgj9B+0erXtWB/kXdthM4b1Ffk
g3eDvGM7T7fZHeXXKDjPe/d4Rh4mX3FeEhW/8aurn+gD+Q/v7pdXwa9mvWdT
4jv/4b+cL7jCOqB+QUOfbyckJCTExSfQUQHQ/+AAEEpGSUYAAQIBAGAAYAAA
//4AJkNyZWF0ZWQgYnkgSW1hZ2VHZWFyLCBBY2N1U29mdCBDb3JwLv/AABEI
ASwBkAMBIgACEQEDEQH/2wCEAAcFBQYFBAcGBgYICAcJCxMMCwoKCxgREg4T
HBkeHRwZGxsfIy0mHyErIhsbJzYoKy8wMzMzHiY4PDcxOy0yMzEBCAgICwoL
FwwMFzEgGyAgMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTEx
MTExMTExMTExMTExMf/EAaIAAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkK
CxAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0Kx
wRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZ
WmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKz
tLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6
AQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgsRAAIBAgQEAwQHBQQEAAEC
dwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEX
GBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5
eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJ
ytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/aAAwDAQACEQMRAD8A+kaK
KKACiiigAooooAKKKKACiiigCK6/485v9w/yrnBXR3X/AB5zf7h/lXOVnMaD
8KWkpagYopeKaKdTELxRSUtABS0lLQAUtJRQAtFJRRYBaPak7UdqLALxRSUd
qACiikpALSUUnSiwBSUZpKACm0uaQ0WASkpaSkMQ11lcma6ytKYmFFFFaCCi
iigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAIrr/jzm/3D/Kub
rpLr/jzm/wBw/wAq5us5jQUtJUsETTzLGvU96SQDBS9q249Pt40+ZA2OpNRy
Q24QlYBgd6pQEZNFaPkRTKoWH7w4ZAf59KQaUrEg+YMd9w5p8gGfS1e/slcZ
xLx23jmmnScchZD7eZ0o5AKdFWzpDdAGPuZTxTDo8xGAij3Mzc/pRyAQUVP/
AGPOR9yMEdB5zHP6Un9jXGMhYgf7vmtj88UcgXIe1HSpv7FuByPJ56gu3FL/
AGHMDjdFj1y2aOQLkGaSrA0OUnBkjA7EbqX+w5T1kjH0Lf40cgXK1HarP9hy
7s+an5t/jTToc4PyyRkZ7swxRyBcr0lT/wBh3X3fMjxjht7Z/Kk/sS7wTmIE
dAJW5/SjkAgpKlOmXMa72VBjjaJXx+eKng06aIhzbhww6CTO388UuQLlKkq9
DFGXnUYDqOQ6/d9OKz53kjbDhAT0wODRyBcWkpiSb1zjFPrNqwxDXW1yVdbV
0wYUUUVoIKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAiuv
+POb/cP8q5uukuv+POb/AHD/ACrm6znuNBV7SB/pZ/3TVA9K0dHH+kufRKI7
gaVxJtAUfkKigTzmLEq0GMAddx75pty7CRioY47YqWdSkEcEGELHaMDoO9ao
kc9zbwkI0irjoKadQtAB+/U5OOOaWKyt4lwIlJ7lhkmphGigAIoA9BRoBAb6
3HHmH/vk0h1G2A++3/fB/wAKsbV/uj8qNq+go0GVTqlqDje2f9w0h1W1UgEv
/wB8GppJQnQYqubog9cUWAf/AGnbkZAkI9kNH9pQAgbZef8ApmazJPEunxKz
NcsVU4LxozLn6gEVXfxtoUfDaiAfQq3+FAGyNWt2TcEuCB/0xb/Cj+1IdpYQ
3OB/0wb/AArnLjxlpclvNNHq8SRRA/u0cebIfQA8gfhXO2njuKK6Lm9vGVj9
xyGVfz5/Wk2kI9FGqwn/AJZXI+sDD+lSLfxuuRFPj3jIrnF8f6EgVLi9MUpA
yhjc4/EDFO/4Tzw6ScarHx14bj9KYHQHUIwB+6n54/1RpRfIWAEM/wD37NVL
LV7W/t1mtLqKaNhkNG4Iq0LjnG6gY77YAceTN/3xS/axj/Uzf981JHIHFPpA
VJNQjRfmt7gj0ERNRLf2pP8AqbiMHuY2UVo0nanoBUktoLy1xFKwydyyK2SD
WDPH5hmjkXDRkjPv/wDXH862Zs2eqwOjBYrjKOv+11BH60moQM9xvUgDaM0C
ObgY5Ix1qyOlReUI55FHQGpV6VjNDQlddXImuup0xsKKKK0EFFFFABRRRQAU
UUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUARXX/AB5zf7h/lXNV0t1/x5zf
7jfyrmqznuNAa09FH7yU+wrL71q6L/y2/D+tEQLMob7TlMDkZ5qWYgXduvqW
/lUMwH2jO4/fXiluJQmpWqkgZz/KtUSSXMhjdMNjrQLtAPmIrH1vUbaJwJJ1
QgEjnk1xeoeJQVPlXQZR2AppaAehza3aQttMgB9Cay7vxbaxcBhn2NeX3evS
OMqzM2P73WsefXGOV38n3/pRZAemX/jmKH7vI9+K56/8bSTpIkcgG8bMHPQ9
a88m1VlYneP+AjFZdxqjY+WRs9aAOk1GW8vr5jcEtsOxRyQoHYe1ReRMo+RG
qhaeN7y0Zf8AR7aRAgXDJ6Drmr0fxQu1BH9l6ecDrsbP86jlAv6bptxdyASo
wWtxvCmI98bPn0rlU+KupbsLY6cgH/TNv/iqX/hbWthfltbAfSNv/iqXKM07
zSrq3ztDHHtWNLNdwtgpIMfWnN8WNcY/8e1gR7wn/wCKprfE7UpIyr6dprZ/
i8o8f+PUcoHXeCvEGyC4tLyNtpZTFKo+dHPHBrdtfHyBzDLIC6naTngkV5PN
451KeNkihtbbd1aCPDD6Ek4/CqdtqcqoPnyPfmrWwrH0Ba+NrX+PKmtyw8S2
d2PlnX8a+fLHWpNoBIx6HofyrZtbyZ+Vl8v2BosB7/HeRSAFSCPWpldWHFeS
aL4gubRsPMGQ8ZY13mk6yt5GoLLux0FFhlnXiqfYZT1S4BWrN+sZkUsVzt7j
ms/xFMv2G24588D6cGruqCMPE7A5wQMH6UCM1442huHRNpGO+e4qqtWZJT++
QgAFRj3FVV61lMaFNddXImuuogNhRRRWggooooAKKKKACiiigAooooAKKKKA
CiiigAooooAKKKKACiiigCK6/wCPOb/cb+VczXTXX/HlN/1zb+Vcx2rOY0Fa
2ifdn+o/rWRWvof3JvqKIiH3UqpOp2jd5i8Z9xWXqN+rapbyKeF64/Grmpys
nRekg5x2rm55AViOex/rWyJZxvjy9m+327CZR8r9T15FcVNqDLnc4zn+E1t/
EmbyruxYKCdrdfwrhpboMuWUhqFsM1JL7cAMkLjjmqktzu6ufzptoqyvFLIR
5WcYIPzeo61o3Ediuwx2ygd8MT/OqUbptB5GFJM23apOPrVUyE+9duttZLaI
psrRmZc7nXnn8azYNNsZZmMlshVQMknaCScDAyO/cnFP2ctPMLo5RpB0IqPc
A3cD1rqrvSCLeWXToINqbmMbqCcDhsFhnI7g4x15FZsIjTTY3+xxS7VJdiCT
1PvWkcPzaJkOdtzIRv3mMblBp24EnHA7c9Knl1GBGZFsIVbpkKeP1pdQN35C
maCKNM8bNmf05qXRSV7jUr9CqXx6cd6A47HFQjJU4IxUeXXkZxWBZdD89TU6
OVHUcVUtAk1xHHNL5aM2C4XO0fSu+b4W6hKJF069guniuGglVh5e0jbyM9R8
4ppAcpFckY2gAita11B2wueB2yRVvSfAeo397cRebAq21wLeUo285PcDpjkc
kitSL4a658rGayIxniQkqME88eimnYQWN6q7QxY+x/8A112OgaqLeRGVlxnH
DVhH4f6tbmLZdWg4VXLORhycEDrke/6VFeaRe6MYDKVdW+86IxCtuYYJOOfl
NMD1fVLpbnRbeQDP79efwNdDqRxFEQoY5wPUcV5VoOqvcW5tHkyA6uF/Tj86
9Uv2P2aHacEkfyqWBz9ywF22DjK5x6UgpL1sXmNv8PJoHSspjQ8111ch2rr6
KY2FFFFaCCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAIrv
/jym/wCubfyrmK6e7/48pv8Arm38q5es57jQnatfRGCwzE8fMKyDTo7qSAAJ
naWyQO9EBMs6y7iAFXGN+evXrXOSOMIcdj/WtnWpI/ssRJbJfgAdPlNYEr5C
jFaks83+J74ubDB52OP1FcCzgnmu0+KUh+3aeOmEc/qK4oCOOLzJF3ZxW1Cj
Kpe2yBtI2dO1G0FrHbXSKpQOA5ztZWGCDjkeoIzg9QR01mjguYVKqjI2NxyA
Om0nI45HUDPtiuU+02skaq0O0AdagtZZ+Vh3kg8FTirhGMXZy0aKlBtLlV2d
fc29vLfCUbD6EtUEloBbSqH/AHTHJwc8DB59Og/KsCSTVYx5rSz7Qc8SE4/W
q7vd6lmKMSyt3y2cVSrxs5SltsEsPVUlDkd2acl6sNrKyz+ZKzS/dORlxhiT
06dhms1J3itInU5AU8HoeTTn069srFjJbsVySWUg44p8enXM+h/alCCONDnJ
54Jp0sbh4QUnJbNfPohzy/FObjyPv8u5BLrLSxMhhgGRjiJBj6cVHfscD60a
foeo6lE0lrb+ZGvBYsAB+dadt4a1nXkLWtniMHHmO4AP09fwrmeY0Iwn7WaW
nkL6pVbi4xZz6thTzjigOe546Vr6n4R1rR2iW7tCqysER1YFST0GR0/Grkvw
88TW93BbPpjtLPnYEdW6YySQcDqOtcP17DWT9otdtV0LdOa0aMrRVsn1+xj1
Bitk06CdgcYTIzz9K7+ax8KyCS5h8Tyw+Yskgt0mJCsCCoJI3cgeh5AriTp9
34Z8X29vqNks01vNG8ltw+8cHbxkHI/nXWya/pi63YXOm+Ep4JrG6Mk4WPBI
wTtIA49eemOOK6ac4zjzRd0yGrF99O8Gec5i8V3ex5GJzJ0wPlJOM+nOD1x2
qKybw6uuTp/wkN5aWhtk8qZGLbmZcOp+XPUn8AfWpZL7T4WiRfAM8ZAjZmiR
ZNy43FfukdCCT97jBqxqmoQmC4sE8AukjRukUiRh/LLDcCCq8kBvXjA96uwi
vJZeFF06a6tNevJJY4TIULYywICryo5O7tnG01zdrqchi8oOxQncVDHGf8k1
kz2l3ZGMXNvLAZFDp5iFdy+oz1FPt5xG38J+tIZ6L4Mu1k1qOHaOcD6c17JP
qHmyLbnG0Pw3fp/+uvCPAN35niy0jOAWzwB7GvXo5WXUiM5j3kOufrj9aGLq
WL0sbxQoG3bxmlXpUN8f9JQg4G3pnpUq9KymUh/auwrjweK7CiAMKKKK0EFF
FFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAQ3f/HlP/1zb+Vc
vmuou/8Ajxn/AOubfyrlqznuNB2qN2IAx68U/tVebqADRETJtYlP2a3AjUkv
ySP9k1hSEnb06Vs6x532O3AYhA3r1G01hvuCDJzWhLPMPikA17Yf7j/zFcTD
P5ahXUkCu1+KKFr6x29o2/mK4iO5jKgSRZx3FdmEny3alb9RS9C2Ire4iBVc
EcEgYIqWJI4tNZRIY8/eYD3qobtY4tsCYz3NR2941upjlUPG1TiJRltv5HpY
StThL3uxoWFxaWquDdtIrdip4q1bxwx6M7LMYkc5MijJHNZ8NzYIdy2rMfTP
FSWmpfZDLbzxB4jk7TxtryK9GUlePc9jD46jTahUa2aVr6X7vf7i3p99p9gr
q+oNKr/wsh4rQ02OGbw5NHv2QMXG49lz/hVOws4r+XfYaFNLg4Mj/LGp92Jw
K6ODw/PFpM1ndzWdsZA3HmZxn8MfrXHVwtSavBO91vY6qePo07RnKLSjK1r9
baXfco6mksPh62i07aLN2VZHXrtJH862PEsOmQafaW19qM9jbDIUQxkhsAdc
DtTdFt9L0vTnsbvVBPEeNuxeAeo+8a1oH0OawFnqd0t5CvCF4QDjtk7uvuMV
w1MsxUZJqN1GTd01d3669UcNTHUKkW07XitNdLdPQy4vEnhweFTo66pNdyDA
iaWF87t2VGcdjitX4n+JtW8OW2nHSrnyDOzh22Kx4xjqDjrSXFjpCadLb6Ba
6aJJxgs8uHxntgN/MVg/EeXWNehtFbQZoBalmLRyCbg46henTvXNSyeTxdOT
pvku2+ble67LzPLrVk4tX18jhotV1bWfGFrfPItzqTzxhC8YIZgQFyoGCOB2
r0T7N4+0rXL/AFIzafBcXUYabjcrJEqjcBg9mA9eTx1ryoHZeOULhgwKsowR
/hUx1jU2JJv7rAOcmVs5xj+VfXwhGEVGKskcG56sbf4i2k8e7UtPV4FWIjeD
gPtXLYHGNi8nHt1qPTbj4h6tcXkEWoWYfT5/JdJU2gttPYrgjGT839a8rXUL
47Qb2fAxgeaeMdKDqN8lpLbLdTeRK4kkQMcMwyMn35NUFj07VfAfibW4bVr6
/smmt0MS5XYNg27cELkn58YIGK5fxP4Z/wCEXuLaF7xbh5kLErGVA54wT14r
kftU5JJlkz1J3GnCeRsFizY45PSi4Hd/DyVR43sAOnz/APoDV7KCE1ncG+YS
tx69a8K+HU23x5YAjnLjj/cavcXKjWnHIPnNt+uTSewupdvyDOhc/Nt5qaP7
oxVW+G2VASD8vBFWIsbBj0rOZSJhXY1xorsqKYMKKKK0EFFFFABRRRQAUUUU
AFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAQ3f/HjP/wBc2/lXK11V5/x4z/8A
XNv5VylZzGg7VXmIDj6VY7VVuMbqIiYurRoYLbMgzvyBj/ZNZEigADPatbVG
iCW4wxbd36D5TWU+DJWhLPLPikxW/slH/PM/zrhFQkHOK774mqG1az4yoiPf
3rhN4LEKOKa2GQtgLxURYmvSofh5pOoaVpaQaq8OrXtutwIpCGUrhy2FAyMB
eOec4pH+E7JYfvL+OOQO7mc7ivlCJZBlMZDYPr+HenYDzmCXY55A4ru/CGk2
EttPrepBXiQsI4nOQSo689eSAB069cYrN8VeA/8AhFtOgnfUBNO91JbsoTai
7QCDuPqCOP8ACqlitybGNftMJhg6ASeuT/jV0VGVRQb3CakocyR1l1qWoXOF
MpgjI+WOLjavpnrVUQ+pLE9yetdD4Z0i21/TmurrUIraOAhXXGZH/wB0Vu/Z
vDOnKRFYyXjBM77iU8n02rjFfSxVCi+WELteX6s8tupPWUtDhxCiIWIGAM8i
mxbJoydoBHY1vXHiaQ/Jb6Rp8KdAPskbf+h0638UlFbz9D0yQ+v2VAf/AB2u
jmqW+H8TK0e5zUsC5xgCmpdXdowMNzImP4c8flXWSaz4XvP3eoaQbNjwJ7Vy
uPwbg1n6z4bji006npl+l5YhgG3DZImTgZXuMkcis3GjUfLVhZ+a/VFXnFXh
Izp7PT/FWnXRdUg1uBd6yjjzh7nvzjOegORgAg+cFNiASqeCeM13NxaCGO7K
sRJFCpyP9p1Qj8mritWPlahcRMRuSVgT7g187jaUaVVxhsejQm5wTkUecnFG
T70xQSetTKVGBjNchuIqkngCnhSOODSlgVGBj2FCYz1waAOj+HpKeP8ASsDr
KR/46a94nYjWpBj/AJbnn8a8F8Ckp480j3uVH58V7vcE/wBsyHt5p/nUvYXU
v3xBaIqpC4IGanhP7tfpUF6xJjLLg4IxipYWBjXjtUTKROK7OuLFdpRTBhRR
RWggooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigCG8/48Z/+
ubfyrk66y8/48J/+ubfyrk6znuNAelVZz89WTVSc/vDilETDVZQVgURrwTyP
pWVIRn04rV1VpykOQdnP8qx5mwDxWhLPJvitPs1ayUf88j/OuFjuOeOK7T4q
Ef2xZggf6k/zrgx7ULYZqrf3HmROJ5A8QAjbecoB2HpSy6jeuHY3k53Elv3h
5JGDn8KzBJjGalWQMKYxZ726uFZJrmV0LbyrOSC2MZ+tXNNkZdsYJCtyR64q
iVBOas2BxdovoP611YP+NFea/MyrfA/Q7nwreGG8mj5IYAYrqdQMn2UZljQf
3VOD9K47wwXXUJmQDhRnP1rT1G6k87DYUei/419XWpOckoyseRTmox1VzRiX
ThCxkf8AeEcDBqSzNiyMJnAOMAEVzyTCRsHJ/wCBH+lK52Dcpb/vo1yyy2lJ
NOT1ZssVJWslodHZWNtdyFM457c8VJo2nQ2/iy3syQ0E0gUx4wp5A6VzttdO
HBWU5B79fzFdJpEs7+LdIlfBQ3EYz/wICk8POlzPnvHl28xe0jO2lnc5iY7r
bU2PU26E/wDf+OuD8QEjxLqa+l1KP/HjXoMrQxRaoJo2YCAcK2P+W8ftXHeI
5tOPijUsWcxb7XJuYTjBO9skfL9PyPrx4WZSarPS/wDwyO/CK8bXH+FvCU/i
WG/kguUj+xxiQxhGeRwT/CqjJA7+laUPww8WStAF0sjzk3qWlQADj73Pyn5h
wfWrPw0sNXv9auBok1vZSRQ+Y1zPAspQ9PlJB2k5P4Dvit7Q7zxlqmoajbz6
qIZtNgAlDWKSPKhIABG3LcYPNcSd0dLVnY5TxD4F1Dw3plnf3JBinQbwwCmO
QlspjPONvX3Fc6ABxivTdY0LxrrOmrZJdJeaf5UcypIkMOCVZwFA5zjd0wex
GK5bxB4Ju/DnhmDUr+VFuJLnyGtlIYoNgcEkHg4PSmIreDm2+NtH4/5e4/8A
0IV7vcAjVXYHjzOlfPvhKfHjTSCP+fuL/wBCFe/znOosQcHfUvYXU0r4uPL3
nJwe9S25zCnHGBVe8GFiw4brzU1sT5CZ9KzmUi0DxXa1xI6V21OmDCiiitBB
RRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAEN5/x4T/9c2/l
XJV1t7/x4XH/AFzb+VciKzmNC9qpTn96QKuE1QnP75h70oiYupKQYiXU8HgH
6VlTd61NRMe+EKW3YPXp2rLmyWYVbJPIPisf+JxZf9cT/OuCzxgV3vxYGNas
h/0xP864HpQthjgfloDEd677RPAmj6n4O0+9uNVe11K/laG3RiCjOHVQNuM9
GyTnjFOm+EuoQPNE2oW5nSAzpAqnfIAzKQoOM/cz9COKqwzghI2Kuaad10P9
0/zrpPG/gaHw3YW+o2V35lrK0cTRPnejtErnnABHJ/SsDSLYmJrjIwhCY+uT
/SurBfx4+q/Mxr/w36HT6A2Lqc89B061Y1i5eJkEURZmYIqk4yar6A22edgO
cCjVnP2i3LEZMw4/CvsZfGeKvhK//EyDHD2kZ9Pmb+lDPqSj/XWbj0O8f0qX
zeTSq/qCa05BXEs7qYzGKaEIwXcCrbgwrr9KfbrGksCxP2iM4J6fMK5O2wdR
QKmf3RP6iur05wb/AE9+AFmjzxjowrmrr3X6GlMyPEP+j3evR4+6pXH0uI64
jX8f8JJqRIHN1L/6Ea7bxgANV8RY9X/9KY64PxJIB4m1MZ6XUn/oRr5fHu9T
7vyR6uGXulvQ/Feq+G3lfS7oQmXbvBjVwSpyDhgeQehqGTxVqjzalIbn59SB
F0di/vMtu9OOfTFYfmjbt6VGzH0rhOg6yP4heJII4o49UZUiVVQCNOAqlR2/
usR+NVda8X63rthDaajqD3EEbBlRlX7wG0EkDJOOOa5sORTw3HUj2poDc8LO
R4t0gg9LuP8A9CFfQs5H9ptk4O4Zr5z8OyBPE2mNj7tzGf8Ax4V9FXGP7SYn
++KmQupqXYAjiCsSMnqKmtMi3T6VBeMHjjwoUAkcVLaf8e6c1nIpFxTXb1wy
13NOmDCiiitBBRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFA
EF7/AMeFx/1zb+VcjXXXv/IPuP8Arm38q5AVnMEKelUZhulJzyDV09KoyY81
ue9KIMTUXRpYVWMKcNzn6Vmy/eNamptOZIBICEw2OPpWVL95qtiPIviyD/bV
l/1xP86XwZ8O4vFHhm/1CaeWOZCUtFRlAdgMtnPYZXPTgk9sUfFUj+3LMf8A
TA/zNcpaatqGnwNHZ39zbxtyyQysoY+4Boi9BpHZeEvBsHiPS7OefV5rfZqn
2REWX5QCm4mPg/NkD24rZsPh9rT3kb6h4iu5bWeI+ckU7htrI7oNx4bocj3r
y+2vb2GJBb3M0aK/mBUcgBumeO+O9K2q6kqRIL66CR5Ma+a2Fzwcc8VWgM7H
xf4UuPDXhC2ur3UJ7u8a8EbK5JhAMIYYB6kA4yPp2rndMaSfTXlwiosioVRQ
MnDYP6frWZd315cWccNxdTypGRtR5CQvHGB9KfpUsiv5QYhDyV7Ejp/M104K
KeIi/NfmZ15NUmvI6rRJNkkoGByDUmsqJJbd17SjI/CodDIE0h9xzWnqNr9o
t8RvskVtwOM9q+yk7TPEirxMgHnpzU8ZBIBNRLY3m4k3MBwO8R/xqT7HeqoI
ubcg8f6o/wCNbOSISHLIiaqgCn/UnnPvXRWM4Q2zFflEinBPXkVgWFlI12ZZ
5Fd8bRtXAArUysBUHsQcVzVUmrGkdNRfHimLXfEakfxSEf8AgRGa8z8SuT4q
1Qg8fapP/QjXp3xMkUeJNbK8Bx/7UjNeW+ITnxNqRz1uZP8A0I18ljHefyX5
I9ehsZ+c0ozjFIBg0/FchuAA9KCM9KVR6U/bjGRSHYs6S5TWbNv7syH9RX0n
M2b9iB/EK+bbVwlzBgDiRT+tfR5YGZiB3HNJi6mxebjDEXGDnjjHFPs8eQuD
61HdZWGPcwY57HOKdZkeQPqf51MxouCu7rgx0rvKKYMKKKK0EFFFFABRRRQA
UUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAQXv/IPuP+ubfyrjxXYX3/IO
uP8Ark38q44Gs5ghSeKoSEea3+9V09KoO375hj+KkgYaigWeE+ajHa3Cn/dr
Nl6tWhqBiFxDs37tjdcY6rWdIRlqsR5H8Vv+Q3Z/9cP/AGY1wRcgc9K7z4q/
8hqz/wCuJ/nXAP0pIuOxPDcmNBipBdbiQVBqipwo/lSgkGqGWxIHd81Pph/0
v2waz1fBIzV/S/8AX5x2rswC/wBoj6o58T/DfodRpEvltKfcVsedGyt1OR1H
auesWwZB712Oh6RqFnfwS3lg/wBkmwjF8DhuBn05I619diZqnHmZ49CHO+Uw
d7FXI6Y61JHI/wC7jxjnNdf9jtLW1d1sgJNOQwyszqwaRgoUkfUmtTVfsWmv
bRzJH9onneNXFpG5YjaBknGMZ6gVw08w59OQ6auEVPaVzzm1uMXJ3cDnvUrX
I3sgOQDwaseJbT7P4tv4lOESUgHAHb0AArLZgZRtHOMfWvRVpx5u6ON3TsXf
iTceZrd5IMYdQePqleea3h/EF847zuf1rsvHTk3QJ6lFP/oNcTqB36nct6yH
+dfH45WqNen5I9nD6xIZVVXwOmBSdqV23NnPYU30riOglQc4BzUj/dXgcVCh
xTmdcYFAyaEgSxn0Yfzr6PVskntkV82Rtgr9RX0fC52ZxxgH9Kl7Evc3LnYL
ZAhLfNzke1SWZHkDjuainZGt02JtAPPOc8U+0P7r8TUyGi4CMV31efrXoFOm
DCiiitBBRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAEF9/y
Drj/AK5N/KuNHSuyvv8AkHXP/XJv5VxYrOYCk8VnOf37f71aB6Vmyf69uf4q
SAW/eNriERxBSEbJyT3Ws6Q/e4rT1FpzPD5iFV2Nj5cf3azJM5arYjyP4rkD
WbL/AK4n+dcAzfLXoHxWQtrNmR/zxP8AM150+4DFJFrYcn3BS55qJX2qKTzO
aqwXJB1NaWk/8fH/AAGssHitTSR+9J/2P6iu3L/94j6nPif4bOi08gM+SRzX
oqeJ9CM0U1+Bfzq6bZRa+W4Udd/OG7ce1eb2iusbMY2COflbHBxVjkkEA/lX
11ahGra72PFhUcFoeijxPpW9t9xE1x5e2O6EMmVG7OGOd3Pt0qQeKdBbykl8
ssDIxkjhYKuWUkBT/eAPPUV52OnINIwHoa5/qFPuzT28ux6LdeJ9H8i8dJbS
WQxP9mDW7Myk4wp3LjHH0rzue4aa8eZwNzks20ADJPYDpTQh7Bqjm/dLuYHL
cCt6OHhSTUepE5ue5V8Wz+d5L9flA/lXKS/PO7dyxroNecPHCoPRa50/fP1z
XyuYq1eXr+iPXwr9xDcCk9qcVxzSY9BXn2OkTNJnilpCeMUAPQ8gD1r6PtiT
AjZ6qD+lfOETsj5VipPHB7V9G2hJtIiDyY1PH0qXsJ7nQXMjNaIQioA2OBjP
FPssiE59TTbsTi2TzifvcAnpxS2nEZwf4qmQ0XAa9BrzwGvQ6dMGFFFFaCCi
iigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAK9/wD8g25/65N/
KuLB4rtL/wD5Btz/ANcm/lXFdqzmAE8VnSf69v8Aeq+TxWfKR57D3pIBdQRl
uIS0qv8AI3Rs/wB2s9+rc1dvhEs8OyQsdrfw4xytZ7nlvrViPKfis5XWLID/
AJ4n+dcA4V4zxzXd/Fk/8Tmy/wCuJ/nXAbuKSNFsRCImMMKhPBq2pxGB7VFJ
HxlRzVJktDA3y1qaRIPM+dtiDqxBx9KyCPlFWbK5ktZN0YUgjDIwyGHoa2o1
XSmpx6GdSCnHlZ2a6hG1vEjXW+JB+7TJwgPJGO3NPinimbbG+4+grlJ9RkvS
MwxReWMDylxn61WRZ5plhRmy5C4B616LzafY5Vg49zu4Skyjy5N3uOR+lOmZ
II2d2OFGTkEVnWMP2CNrRZg7wnaxHY9cU3UrtrXT3mkRZRkDY/RvY170ZRdD
23TlucDTU+TzLUOp2sqbkmU46ru5FSi9tHT52XHuc1zt7p9jcaMmsaRugZGC
XFvuJ2H1B9DVWzKT27/a5pFAjYgqAfmAO3Oe2a8JZs7/AA/id/1RdyxrlzDN
dH7OQURQOBgVkZ5HrROZEEYLfKVDAVGGIxXn4iu60+ZnTSpqEbImJ5xSZAqN
mO7igNWBqOYg8YpuR3pM80vGaQDkI3CvomwIOnQnpmFT/wCOivnQcMK+iNPY
f2VATwPIU/8AjopMXU6WaMRwKPMRzn+E9KfaY8s4/vVFOIVhUI7Oc85XFPtD
8hx61EhourXolecqa9Gp0wYUUUVoIKKKKACiiigAooooAKKKKACiiigAoooo
AKKKKACiiigAooooAr3/APyDbn/rk38jXEdq7fUP+QZc/wDXJv5GuHrOYAel
UJ8ecfrV09KoTn98aEA2+eNpYQkQQ7Wyck56VnueWrSvzcFoDLnZtOOntWY/
3mqhHlHxZ/5Clif+mTfzrz7PFeg/Fj/kKWH/AFyb+dedk4ojsWth4+6MUmeK
aGwKYW5pgKU6U5AQRQMECgYB4pkksP3HPvitfwreQ2PiuwuJ4leNZMENjGSC
AfwJB/CsZDiL6mu0+GngOXxvrUqOzR2duuZZV4IJB24/EUpbCbsYsF2+n6zd
W92rKzykkkdDmk1u7F3AFjJMYPJxXaeObbw63iGDRZbgx6hYxCKa+jTKyHnh
gO4GOfXI6AAUz4d8O29mfP8AEiTgjiO3t2LH2OcAfrXZHMav1f2HQx+rwc/a
HN6DEq+F9enlbCeWiIp7sW/pj9ay4WBgdParmtX6eXHpllE0NjC24Bj80jf3
mrMhf5setcS7m45mE0cYYY2Jt+vJpjRDbkelLGMZFPb7hpgivINrkdqTbxwK
dLy+fbtTOQKBi0CmjOaeM4wO9IYDqK+htNIOiwE5x9mXP/fIr58TaFIK5J6H
0r6C0vA0G3JXI+zLx/wEUmSzpJ/I8lRFvznndipbXHl/jUM8kbKoSIJz6k1N
a8R/jUyGiyK9IrzcYr0inTBhRRRWggooooAKKKKACiiigAooooAKKKKACiii
gAooooAKKKKACiiigCvqH/IMuv8Ark38jXC9q7nUf+QXdf8AXFv5GuFzUSAD
0qhcH9+1XSaoXP8Arj9BSQmNvFjDQFZdzYPG3HaqTfeb61au5I/9GCxYOSN2
f9mqjnDNVMDyb4tNjVbAf9Mm/nXnh5FegfFw/wDE2sP+uJ/nXnobihbFIMn0
pMUuaWmMUdKUUoXjpRiglirxHj3Ne7fBqXT9K8HXrzXyw3M7+bgngKBgZ/HP
5ivGLawa70yaWHDSQnLJ3x6/59/Smx6pfWoZY7qVMpsbDHlcYx9MUOzJauX3
mk1DVbrUZvv3ErSc+5zU4GAcVVsMi0QH649K0VjBQNkD1oKMzVbR5lSSNMkc
HFZ01nNaeQ0q4E0YkT6ZI/pXSBgxCIQaj1y48/SbKGSGJBa7kSRR8zgnOD7A
k0COcTuak6jFNXhcCtzw5ZSXzXkUVrBO5iwPNONpz1Bxj88fUUxnPONuPpUZ
r0iDTbg2wUeHNNkZcBd8yEtjHPH59f65qWugXdrHJDLodlKMsSJLlMrkjHPX
j69O1Kw0cEOtOrv7TToWmu4l0GwRocKxlnOMYJJHHI9/pWUvgvUL5pLuBLaG
BzuRDMMLk8L+AP6UrDOXA5r6E0fI8O2hwD/oqcH/AHRXhF5YyWNw8EwAkQDO
DkcjNe9aGG/4R6yK/e+zR4x/uihiZ0E0pk2gxov+6uKmtxiP8ahnMx8vzSxG
Plz6VPAP3QqJAiYCvSa83Ar0inTBhRRRWggooooAKKKKACiiigAooooAKKKK
ACiiigAooooAKKKKACiiigCtqP8AyC7r/ri/8jXB54rvNR/5BV3/ANcX/ka4
AGokA4niqN1/rPwq2TxVK5+/+FJALdtOIYA64jPT5cdqosOScVaulASAiVW/
2Rn0psVlc3EMrQoWC4zg9Pw79KqxJ4z8XB/xN7ADOPJP8688A5r33xh4Oi8S
6aF81YruLJibqM+h9q8qm+H3iGGQobEtjujAihO25SOZCjPJI+lKBiuh/wCE
G8QDk6dJ+lA8Ea//ANA6X8qLjuYSnAprEiuhHgvXgOdNm/Km/wDCFa9/0Dpf
youDMS1vJ7O5WeByrD071pWq2mqTnzWELnoBgAmrY8Fa7j/kHSflTv8AhCtc
J40+QU7oRL9jlgXJhcqOhXlfzFEcm7gRMXJxtAzmli8L+J7cjybedSPQ1K+h
+MZUKsk5U9RupAJLdi0T/SFSP/Y/i/8ArVgX1+97NuIwg4Va1D4L8RO257CR
j7kU4eCde/6B7/mKLoDABwMVe0y8s7SSRrywF2rLhVMjJtPrxWj/AMITr3T+
z3/MUh8E6/njT3/MUXKTF/tzRBMrL4eAUZOPtT/z/wA9vxRdf0wXMztoiNDI
EHlmU5XaD0bGeTgn6Un/AAhOv/8AQPf8xTv+EI1/H/IPf8xRzDuhW8QaRuLR
eH4o23qwJmZuAQSMHjnGPxqxH4m0zB3eH4TnkqszBc4wSF5A/pVf/hCdeA50
9/zFC+DNf6DT3p3C6K+rXunXcEIstPNrKM+ZiQsp9Ote2aArf2Bp6N8rfZ4x
zxj5RXnnhr4dXsl7HcasixwociEHJc++Ogr1BIxbpmTCKMDjtSZLfY0Jl2eW
d6tkdj0q1Af3QqpKqAoEfd+GKswnES1EgRYB4r0mvNAeK9Lp0wYUUUVoIKKK
KACiikJxQAtFNLhRkkCq4vDKWEERk2nBI4H60AWqKqfarnfs+xvnGeox+ecV
JFcF3KPGUcDO00AT0UUUAFFFFABRRRQAUUUUAFFFFAFbUv8AkFXf/XF/5GvP
s16DqX/IJu/+uL/yNeeZqJAKTxUW2KSUq23IGfmJFPNRsaSYD3jjaNUaRdi9
BuOB+lS297b2lrLCI1bzBgtlsiqTHioHbjinzAOlW2Lkgj/gRP8AQVWkWD/n
pCPxb/CmyNxVSU1PMIc6Wv8AFcR/QBv8KryR2x+7cQge+7/CoZKgYUcwE/l2
4/5eof8AvljTCLMHm7X8ImP9arstRlaXMBcBsO9y/wCEB/8Aiqd5mnD/AJby
f+A//wBlWfto49KOYZoiXTx/y3f8bb/7KgPp+f8Aj4f/AMBv/sqztwHalDj0
o5gNPdp+eJ2+n2c//FU4tppHDtn/AK5N/wDFVliQelOEg9KOYDSAsT0mI/4A
f/iqeEsu0+Pqp/xrMDinBhRzAaQjtz0uox9Vb/CnrHFji8t/xD//ABNZysKe
CKOYRoiKM9bq3P4sP5rUq28R6TQH/toBWauM1OmOKOZDN/TjZ2brK8cMzD+F
pV20kyR3M7uFQBmyVEi4rJjIzVqMinzBY0DBE2N3BHpIo/pSRY2DHT3OagQi
plOBxSbuOxMDxXp1eXg16hVUwYUUUVoIKKKKACqmpXDWti0qjkVbqG7hE9s0
ZHBFAFZ7W1ji33dwWBx8zvtH4Yps7s9gh0to0Qv8zjACjv1/Cq9u3m6cYpBm
Wzbv3X/9WfyqNI4JC9w8BlPmeXFCvRmxnJ/D+VAD/t8kVg0S3iz3Och0XIA+
vQ1bjlMotLjAzIm1iPX0/nTRGQqpd/YokPSILyB7HI5/CgW/2Oz2MQVSbMXP
UH/9ZoA0aKKKACiiigAooooAKKKKACiiigCtqX/IJu/+uL/yNefY4r0HUv8A
kE3f/XF/5GvPe1TJANYVC2fSrIAIpNoPapsIoPn0qB8+lahiU9qaYUI6UrDM
ZgfSoHQntW4bePH3aabaL+7SsI55oSR0qI27eldIbaL+7QLaLH3aVgOXNo56
Cm/YpMdDXV/Zov7tKLaL+7TsByX2GT0o+wS+ldeLaL+7S/Zov7tKwzj/ALBL
/dpPsMv92uyFtF/dFH2WL+7RYDjfsUv92k+xyf3a7T7LD/cpPskP9yiwWON+
yyf3aBbOP4a7D7HD/cpps4f7tFgOTELgfdNOETD+GunNnD/dpptIc/dpWA5x
VYdqeu4djW8bSHP3aT7LEB92iwGOrsD0q1FKeOKu/ZYs/dpRBGOgp2GMjk4q
wj8UwRKBwKeFAoAkDV6pXlIAFerVcAYUUUVoIKKKKACkNLSGgDKuAbHU47oc
RP8AJJ7D1qe2ihsd9uLtd0rEopIyOOMetXGVWGGAIqA2FqUKiCMA9QFxQBQG
lTNEUkSEMfvysSxPvU1uiTzRrFlra3XahP8AEfX/AD71N/Z1uQAwd1H8LuWH
5E4q0qhVAUAAdhQB/9k=
--= Multipart Boundary 0901041737--

View File

@@ -1,57 +0,0 @@
From bownrdstrm@attb.com Sun Jun 6 07:52:37 2004
Return-Path: <purgcrw@attb.com>
Received: from leggite.example.com ([207.111.254.118]) by snacker.example.com
(Netscape Messaging Server 4.15) with ESMTP id HYW65I00.GCU for
<exp@example.com>; Sun, 6 Jun 2004 07:41:42 -0700
Received: from accfd8ce.ipt.aol.com (ACCFD8CE.ipt.aol.com [172.207.216.206])
by leggite.example.com (8.12.8/8.12.8) with SMTP id i56EpkRt007759
for <exp@example.com>; Sun, 6 Jun 2004 07:52:03 -0700
Received: from [220.15.207.252] by 172.207.216.206 with dazzle SMTP;
Sun, 06 Jun 2004 08:52:37 -0600
X-Authentication-Warning: ryder ancestral
Date: Sun, 06 Jun 2004 08:52:37 -0600
From: "Stphn Hand" <bownrdstrm@attb.com>
Reply-To: "Stphn Hand" <resceflblb@attb.com>
Message-ID: <3749823059370.835538001008932913@chckwll>
To: exp@example.com
Subject:
References: <168425683841079245159@duke>
In-Reply-To: <7406146144666267721836@prevalent>
X-Mailer: silicic leafy
Content-Type: text/html;
charset=us-ascii
Content-Transfer-Encoding: 7bit
<html>
<body>
<p><br>
</p>
<p align="center"><a href="http://www.cFZ.phrnw.com/tp/indx.asp?ID=w">&nbsp;</p>
<p align="center"><img src="http://www.zP6.qwmeds.com/wlt.gif" border="0"></a></p>
<p><br>
<br>
<br><br><br><br>
<br><br><br><br>
To say adios muchachos head on over to go to: pharmnw.com/host/emlremve.asp<br>
<br><br><br><br>
broach glutamine gurkha disciplinarian brawl atypic ridicule dandy hereof difficulty yourself satellite courtney alicia elude mcleod consist dunedin charlotte shoe bequest aluminate handlebar nebular bent booty shutout concision algonquin more connector tuple barge downriver denebola urgent caleb gordon shield prima perhaps dar dreg weir ecuador edible broke compactify circuitry forsook fiske moscow tall influence alterman mountain such excuse railbird caw
</body>
</html>
<br><br>
ghana managua ptolemaic ritter tina aden travel wang morn someone cocoon apparatus manchester crime daniel florin aile handicapped effort hairy poodle allegation doubloon basis fantasia windward chisel brink bibb fashion aspire farcical sorority eastward callahan cyrillic thoroughgoing awoke thyrotoxic adopt dial simultaneous zeiss partisan elm commission eat ornately drumlin grandeur shields awaken meningitis aren't equipped intractable dwarf behest featherbrain
shell vacationland disseminate regurgitate decolonize jules methodology beverly drowse cried earl applied storeroom cattle revved kim sharp frizzle bevel continua hangable rhodonite carcinogen bodybuild dusenbury acapulco pine stormbound ark suspension katz fabulous lend lilly matthews firewood groggy gallop
apocalypse break valois emporium flown cookbook jeff fanout nathaniel mollify royalty twirl whittle amethystine ladylike plywood terpsichorean analyses avocate basis hemingway aluminate gladiolus levin polymer arkansan diagnostician danielson augustus deplore rachmaninoff assyriology model alexander importune civic sprite concise haughty wean peripatetic shove booky sonny book lyric presence cruz boisterous buttercup sidelong breed distributor

Some files were not shown because too many files have changed in this diff Show More