diff --git a/cpp/nativecall/msvc/nativecall.suo b/cpp/nativecall/msvc/nativecall.suo index ad73bc0..6386fe5 100644 Binary files a/cpp/nativecall/msvc/nativecall.suo and b/cpp/nativecall/msvc/nativecall.suo differ diff --git a/java/native/nativecall.dll b/java/native/nativecall.dll deleted file mode 100644 index 6f54b0b..0000000 Binary files a/java/native/nativecall.dll and /dev/null differ diff --git a/java/src/com/eaio/nativecall/Holder.java b/java/src/com/eaio/nativecall/Holder.java deleted file mode 100644 index 6c1ee68..0000000 --- a/java/src/com/eaio/nativecall/Holder.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Holder.java - * - * Created on 14.09.2004. - * - * eaio: NativeCall - calling operating system methods from Java - * Copyright (c) 2004-2006 Johann Burkard () - * - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - */ -package com.eaio.nativecall; - -/** - * Holder is a class that encapsulates another Object. Use this class for output - * parameters. - * - * @author Johann Burkard - * @version $Id: Holder.java,v 1.3 2006/04/19 20:54:58 grnull Exp $ - */ -public class Holder { - - /** - * The encapsulated object. - *

- * Accessed by native code. DO NOT RENAME THIS FIELD. - */ - private Object o; - - /** - * Constructor for Holder. - * - * @param o the Object to encapsulate, may be null, but cannot - * be of type Holder - * @throws ClassCastException if o is of type Holder - */ - public Holder(Object o) { - if (o instanceof Holder) { - throw new ClassCastException(); - } - else if (o == null) { - o = new Integer(0); - } - this.o = o; - } - - /** - * Returns the referenced Object. - * - * @return an Object - */ - public final Object get() { - return o; - } - - /** - * Returns the hashCode of the encapsulated Object or - * {@link java.lang.Object#hashCode()} if the Object is null. - * - * @return the hashCode - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - return getClass().getName().hashCode() ^ (o == null ? 0 : o.hashCode()); - } - - /** - * Returns if this Object is equal to another Object. - * - * @param obj the other Object, may be null - * @return if both Objects are equal - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof Holder)) { - return false; - } - Holder h = (Holder) obj; - return o == null ? h.o == null : o.equals(h.o); - } - - /** - * Returns a String representation of this Object. - * - * @return a String, never null - * @see java.lang.Object#toString() - * @see #toStringBuffer(StringBuffer) - */ - public final String toString() { - return toStringBuffer(null).toString(); - } - - /** - * Appends a String representation of this Object to the given - * {@link StringBuffer} or creates a new one if none is given. - * - * @param in the StringBuffer to append to, may be null - * @return a StringBuffer, never null - */ - public StringBuffer toStringBuffer(StringBuffer in) { - if (in == null) { - in = new StringBuffer(32); - } - else { - in.ensureCapacity(in.length() + 32); - } - in.append("{ Holder: o = "); - in.append(o); - in.append(" }"); - return in; - } - -} diff --git a/java/src/com/eaio/nativecall/IntCall.java b/java/src/com/eaio/nativecall/IntCall.java deleted file mode 100644 index 97c6362..0000000 --- a/java/src/com/eaio/nativecall/IntCall.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * IntCall.java - * - * Created on 07.09.2004. - * - * eaio: NativeCall - calling operating system methods from Java - * Copyright (c) 2004-2006 Johann Burkard () - * - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - */ -package com.eaio.nativecall; - -/** - * An IntCall instance encapsulates an operating system method that returns - * an integer. - * - * @author Johann Burkard - * @version $Id: IntCall.java,v 1.1 2006/01/05 20:02:44 grnull Exp $ - */ -public class IntCall extends NativeCall { - - /** - * Constructor for IntCall. - * - * @see NativeCall#NativeCall(String) - */ - public IntCall(String function) throws SecurityException, - IllegalArgumentException, NullPointerException { - super(function); - } - - /** - * Constructor for IntCall. - * - * @see NativeCall#NativeCall(String, String) - */ - public IntCall(String module, String function) throws SecurityException, - IllegalArgumentException, NullPointerException { - super(module, function); - } - - /** - * Returns false if calling {@link #executeCall()} returned - * 0, true otherwise. - *

- * Updates the error code field. See {@link #getLastError()}. - * - * @return true or false - */ - public boolean executeBooleanCall() { - return executeCall() == 0 ? false : true; - } - - /** - * Returns false if calling {@link #executeCall(Object)} - * returned 0, true otherwise. - *

- * Updates the error code field. See {@link #getLastError()}. - * - * @param param the parameter, may be null - * @return true or false - * @see #executeBooleanCall(Object[]) - */ - public boolean executeBooleanCall(Object param) { - return executeCall(param) == 0 ? false : true; - } - - /** - * Returns false if calling - * {@link #executeCall(Object[])} returned 0, true otherwise. - *

- * Updates the error code field. See {@link #getLastError()}. - *

- * During this operation, the contents of the array might be changed. - * - * @param params the parameter array, may be null - * @return true or false - */ - public boolean executeBooleanCall(Object[] params) { - return executeCall(params) == 0 ? false : true; - } - - /** - * Calls the function, returning its output. - *

- * Updates the error code field. See {@link #getLastError()}. - * - * @return an int - */ - public native int executeCall(); - - /** - * Calls the function using the given parameter. - *

- * Updates the error code field. See {@link #getLastError()}. - * - * @param param the parameter, may be null - * @return an int - * @see #executeCall(Object[]) - */ - public int executeCall(Object param) { - return executeCall(new Object[] { param }); - } - - /** - * Calls the function using the given parameters. - *

- * Updates the error code field. See {@link #getLastError()}. - *

- * During this operation, the contents of the array might be changed. - * - * @param params the parameter array, may be null - * @return an int - */ - public int executeCall(Object[] params) { - if (params == null || params.length == 0) { - return executeCall(); - } - check(params); - return executeCall0(params); - } - - private native int executeCall0(Object[] params); - -} diff --git a/java/src/com/eaio/nativecall/NativeCall.java b/java/src/com/eaio/nativecall/NativeCall.java deleted file mode 100644 index ce1c820..0000000 --- a/java/src/com/eaio/nativecall/NativeCall.java +++ /dev/null @@ -1,355 +0,0 @@ -/* - * NativeCall.java - * - * Created on 07.09.2004. - * - * eaio: NativeCall - calling operating system methods from Java - * Copyright (c) 2004-2006 Johann Burkard () - * - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - */ -package com.eaio.nativecall; - -import java.io.IOException; - -import sun.misc.ServiceConfigurationError; - -import com.eaio.util.lang.NativeLoader; - -/** - * NativeCall loads the native library and prepares the matching - * {@link com.eaio.nativecall.Verifier}. - *

- * Before being able to use NativeCall, the {@link #init()} method must have - * been called: - *

- * try {
- *     NativeCall.init();
- * }
- * catch (IOException ex) { ... }
- * catch (SecurityException ex) { ... }
- * catch (UnsatisfiedLinkError er) { ... }
- * catch (sun.misc.ServiceConfigurationError) { ... }
- * catch (UnsupportedOperationException) { ... }
- * 
- * After usage, each NativeCall object must be destroyed to release - * resources. This is done by calling the {@link #destroy()} method. Failure - * to call this method might result in memory leaks. - * - * @see #destroy() - * @see #init() - * @author Johann Burkard - * @version $Id: NativeCall.java,v 1.3 2006/04/19 20:54:58 grnull Exp $ - */ -public abstract class NativeCall { - - /** - * The error code of the last call. - *

- * Accessed by native code. DO NOT RENAME THIS FIELD. - */ - private int lastErrorCode; - - /** - * The internal handle to the function and the module. - *

- * These are set in native code, so ignore any warnings. - *

- * Accessed by native code. DO NOT RENAME THIS FIELD. - */ - private int functionHandle, moduleHandle; - - /** - * The name of the function to call. - *

- * Accessed by native code. DO NOT RENAME THIS FIELD. - */ - private String function; - - /** - * The name of the module to call. - *

- * Accessed by native code. DO NOT RENAME THIS FIELD. - */ - private String module; - - /** - * Initialize JNI field and method IDs - */ - private static native void initIDs(); - - /** - * Whether the class has been initialized properly. - */ - private static boolean initialized = false; - - /** - * Before NativeCall may be used, this method must be called. - * It loads the native library, prepares JNI field and method IDs and loads - * the matching {@link Verifier}. - *

- * Multiple calls are ignored. - * - * @throws IOException if an IOException occured during unpacking of - * the native library - * @throws SecurityException if accessing system properties was forbidden - * by the {@link SecurityManager} - * @throws UnsatisfiedLinkError if the NativeCall.dll could - * not be found - * @throws sun.misc.ServiceConfigurationError - * @throws UnsupportedOperationException if no matching - * {@link Verifier} could be found - */ - public static synchronized void init() - throws - IOException, - SecurityException, - UnsatisfiedLinkError, - ServiceConfigurationError, - UnsupportedOperationException { - if (!initialized) { - Verifiers.init(); - if (Verifiers.getInstance() == null) { - throw new UnsupportedOperationException(); - } - new NativeLoader("NativeCall").load(); - initIDs(); - initialized = true; - } - } - - /** - * Constructor for NativeCall. - * - * @param function the name of the function to use, may not be - * null - * @throws IllegalArgumentException if the function could not be found - * @throws NullPointerException if function is null - * @see Verifier#getDefaultModule() - * @see NativeCall#NativeCall(String, String) - */ - public NativeCall(String function) - throws IllegalArgumentException, NullPointerException { - this(Verifiers.getInstance().getDefaultModule(), function); - } - - /** - * Constructor for NativeCall. - * - * @param module the name of the module the function is stored in, may be - * null - * @param function the name of the function to use, may not be - * null - * @throws IllegalArgumentException if the function could not be found - * @throws NullPointerException if function is null - */ - public NativeCall(String module, String function) - throws IllegalArgumentException, NullPointerException { - Verifier v = Verifiers.getInstance(); - this.function = v.verifyFunctionName(function); - this.module = v.verifyModuleName(module); - if (!initHandles()) { - if (lastErrorCode != 0) { - throw new IllegalArgumentException(getLastError()); - } - throw new IllegalArgumentException(); - } - } - - /** - * Attempts to acquire handles to the functions. Returns if these could be - * acquired. - * - * @return if the handles could be acquired - */ - private native boolean initHandles(); - - /** - * Returns the error code that was returned during the last method call or - * 0 if the last method call did not produce an error. - * - * @see #getLastError() - * @return the last error code or 0 - */ - public final int getLastErrorCode() { - return lastErrorCode; - } - - /** - * Returns a formatted String containing the last error code or - * null if the last call did not produce an error. - * - * @see #getLastErrorCode() - * @return a String or null if the last error code is 0 - */ - public final native String getLastError(); - - /** - * Releases acquired module handles. This method must be called if the - * instance is not used anymore. After this method is called, methods of this - * NativeCall Object cannot be called anymore. - *

- * Failure to call this method might result in memory leaks. - *

- * Updates the error code field. See {@link #getLastError()}. - */ - public native synchronized void destroy(); - - /** - * Checks the supplied Object array for illegal/unsupported types. - *

- * During the verification, the contents of the array might be - * changed. - * - * @param params the Object array, may be null - * @throws ClassCastException if the type of one argument is not supported - */ - protected void check(Object[] params) throws ClassCastException { - if (params == null) { - return; - } - for (int i = 0; i < params.length; ++i) { - checkParam(params[i]); - if (params[i] instanceof String) { - params[i] = - Verifiers.getInstance().handleString( - (String) params[i], - module, - function); - } - } - } - - /** - * Checks one Object for illegal/unsupported types. - * - * @param o the Object, may be null - * @throws ClassCastException if the type of one argument is not supported - */ - protected void checkParam(Object o) throws ClassCastException { - if (o == null - || o instanceof Boolean - || o instanceof Integer - || o instanceof byte[] - || o instanceof char[] - || o instanceof String) { - return; - } - if (o instanceof Holder) { - checkParam(((Holder) o).get()); - return; - } - throw new ClassCastException(o.getClass().getName()); - } - - /** - * Returns if this Object is equal to another Object. The other Object must - * be an instance of the same type as this Object. Also, both the module - * and the function field must be equal. - * - * @param obj the other Object - * @return if this and the other Object are equal - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof NativeCall)) { - return false; - } - if (!getClass().getName().equals(obj.getClass().getName())) { - return false; - } - NativeCall c = (NativeCall) obj; - return module.equals(c.module) && function.equals(c.function); - } - - /** - * Returns the hashCode of this Object. The hashCode is computed by XOR'ing - * the hash codes of the function and the module names. - * - * @return the hashCode - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - int out = function.hashCode(); - out ^= module.hashCode(); - return out; - } - - /** - * Calls {@link #destroy()}. - * - * @see java.lang.Object#finalize() - */ - protected void finalize() throws Throwable { - try { - destroy(); - } - finally { - super.finalize(); - // in case NativeCall is a subclass of a class other than Object - } - } - - /** - * Returns a String representation of this Object. - * - * @return a String, never null - * @see java.lang.Object#toString() - * @see #toStringBuffer(StringBuffer) - */ - public final String toString() { - return toStringBuffer(null).toString(); - } - - /** - * Appends a String representation of this Object to the given - * {@link StringBuffer} or creates a new one if none is given. - * - * @param in the StringBuffer to append to, may be null - * @return a StringBuffer, never null - */ - public StringBuffer toStringBuffer(StringBuffer in) { - if (in == null) { - in = new StringBuffer(64); - } - else { - in.ensureCapacity(in.length() + 64); - } - in.append("{ "); - int idx = getClass().getName().lastIndexOf("."); - if (idx > -1) { - in.append(getClass().getName().substring(++idx)); - } - else { - in.append(getClass().getName()); - } - in.append(": module = "); - in.append(module); - in.append(", function = "); - in.append(function); - in.append(" }"); - return in; - } - -} diff --git a/java/src/com/eaio/nativecall/Verifier.java b/java/src/com/eaio/nativecall/Verifier.java deleted file mode 100644 index 1780cfc..0000000 --- a/java/src/com/eaio/nativecall/Verifier.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Verifier.java - * - * Created on 07.09.2004. - * - * eaio: NativeCall - calling operating system methods from Java - * Copyright (c) 2004-2006 Johann Burkard () - * - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - */ -package com.eaio.nativecall; - -/** - * A Verifier implements method and module name checking for one given - * operating system. Classes implementing Verifier must be public and have - * a public no-argument constructor. - * - * @author Johann Burkard - * @version $Id: Verifier.java,v 1.1 2006/01/05 20:02:44 grnull Exp $ - */ -public interface Verifier { - - /** - * If there is a default module that system functions are stored in, the - * module's name may be returned here. - * - * @return the name of a default module or null - * @see NativeCall#NativeCall(String) - */ - String getDefaultModule(); - - /** - * Returns if this Verifier supports the given operating system. - * - * @return if this operating system is supported - * @throws SecurityException because {@link java.lang.System} properties - * may be queried - */ - boolean supports() throws SecurityException; - - /** - * Verifies that the given module name is correct. - * - * @param module the module name, may be null - * @return a module name, possibly modified, never null - * @throws NullPointerException if the module name is null - * and there is no default module defined - * @throws IllegalArgumentException if the module is illegal in the - * operating system - * @see #getDefaultModule() - */ - String verifyModuleName(String module) - throws NullPointerException, IllegalArgumentException; - - /** - * Verifies that the given function name is correct. - * - * @param function the function name, may be null - * @return a function name, possibly modified, never null - * @throws NullPointerException if the function name is null - * @throws IllegalArgumentException if the function is illegal in the - * operating system - */ - String verifyFunctionName(String function) - throws NullPointerException, IllegalArgumentException; - - /** - * Converts the given String to one of the following data types, based on the - * module and the function name: - *
- *

- * - * @param val the String, never null - * @param module the module name, never null - * @param function the function name, never null - * @return the String converted, never null - */ - Object handleString(String val, String module, String function); - -} diff --git a/java/src/com/eaio/nativecall/Verifiers.java b/java/src/com/eaio/nativecall/Verifiers.java deleted file mode 100644 index 5fc674b..0000000 --- a/java/src/com/eaio/nativecall/Verifiers.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Verifiers.java - * - * Created on 07.09.2004. - * - * eaio: NativeCall - calling operating system methods from Java - * Copyright (c) 2004-2006 Johann Burkard () - * - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - */ -package com.eaio.nativecall; - -import java.util.Iterator; - -import sun.misc.Service; -import sun.misc.ServiceConfigurationError; - -/** - * Verifiers instantiates the matching {@link com.eaio.nativecall.Verifier} for - * the current operating system. - * - * @author Johann Burkard - * @version $Id: Verifiers.java,v 1.2 2006/01/06 10:58:33 grnull Exp $ - */ -final class Verifiers { - - /** - * No instances needed. - */ - private Verifiers() {} - - /** - * The Verifier. - */ - private static Verifier v = null; - - /** - * Find the matching Verifier. - * - * @throws ServiceConfigurationError - * @throws SecurityException - */ - static void init() throws ServiceConfigurationError, SecurityException { - Iterator i = - Service.providers(Verifier.class, Verifier.class.getClassLoader()); - Verifier ver = null; - while (i.hasNext()) { - ver = (Verifier) i.next(); - if (ver.supports()) { - v = ver; - break; - } - } - } - - /** - * Returns the Verifier. - * - * @return a Verifier or null - */ - static Verifier getInstance() { - return v; - } - -} diff --git a/java/src/com/eaio/nativecall/VoidCall.java b/java/src/com/eaio/nativecall/VoidCall.java deleted file mode 100644 index 21ea7a0..0000000 --- a/java/src/com/eaio/nativecall/VoidCall.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * VoidCall.java - * - * Created on 16.09.2004 - * - * eaio: NativeCall - calling operating system methods from Java - * Copyright (c) 2004-2006 Johann Burkard () - * - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - */ -package com.eaio.nativecall; - -/** - * A VoidCall instance encapsulates an operating system method that returns - * nothing. - * - * @author Johann Burkard - * @version $Id: VoidCall.java,v 1.1 2006/01/05 20:02:44 grnull Exp $ - */ -public class VoidCall extends NativeCall { - - /** - * Constructor for VoidCall. - * - * @see NativeCall#NativeCall(String) - */ - public VoidCall(String function) throws SecurityException, - IllegalArgumentException, NullPointerException { - super(function); - } - - /** - * Constructor for VoidCall. - * - * @see NativeCall#NativeCall(String, String) - */ - public VoidCall(String module, String function) throws SecurityException, - IllegalArgumentException, NullPointerException { - super(module, function); - } - - /** - * Calls the function. - *

- * Updates the error code field. See {@link #getLastError()}. - */ - public native void executeCall(); - - /** - * Calls the function using the given parameter. - *

- * Updates the error code field. See {@link #getLastError()}. - * - * @param param the parameter, may be null - * @see #executeCall(Object[]) - */ - public void executeCall(Object param) { - executeCall(new Object[] { param }); - } - - /** - * Calls the function using the given parameters. - *

- * Updates the error code field. See {@link #getLastError()}. - *

- * During this operation, the contents of the array might be changed. - * - * @param params the parameter array, may be null - */ - public void executeCall(Object[] params) { - if (params == null || params.length == 0) { - executeCall(); - return; - } - check(params); - executeCall0(params); - } - - private native void executeCall0(Object[] params); - -} diff --git a/java/src/com/eaio/nativecall/Win32Verifier.java b/java/src/com/eaio/nativecall/Win32Verifier.java deleted file mode 100644 index b07f2cc..0000000 --- a/java/src/com/eaio/nativecall/Win32Verifier.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Win32Verifier.java - * - * Created on 08.09.2004. - * - * eaio: NativeCall - calling operating system methods from Java - * Copyright (c) 2004-2006 Johann Burkard () - * - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - */ -package com.eaio.nativecall; - -/** - * A {@link com.eaio.nativecall.Verifier} for the Windows environment. - * - * @author Johann Burkard - * @version $Id: Win32Verifier.java,v 1.3 2006/04/19 20:54:58 grnull Exp $ - */ -public class Win32Verifier implements Verifier { - - /** - * Constructor for Win32Verifier. Does nothing. - */ - public Win32Verifier() {} - - /** - * Verifies that the {@link java.lang.System} property "os.name" starts - * with "Windows". - * - * @see Verifier#supports() - */ - public boolean supports() throws SecurityException { - return System.getProperty("os.name").startsWith("Windows"); - } - - /** - * Returns the default module name if the module name is null - * or an empty String. If the module name contains forward slashes (/), they - * are converted to backward slashes (\). - * - * @see - * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/loadlibrary.asp - * - * @see com.eaio.nativecall.Verifier#verifyModuleName(java.lang.String) - */ - public String verifyModuleName(String module) { - if (module == null || module.length() == 0) { - return getDefaultModule(); - } - if (module.indexOf('/') != -1) { - module = module.replace('/', '\\'); - } - return module; - } - - /** - * Throws a {@link java.lang.NullPointerException} if the function - * name is null or an empty String. No further processing is - * done. - * - * @see com.eaio.nativecall.Verifier#verifyFunctionName(java.lang.String) - */ - public String verifyFunctionName(String function) { - if (function == null || function.length() == 0) { - throw new NullPointerException(); - } - return function; - } - - /** - * Returns "kernel32". - * - * @return "kernel32" - * @see com.eaio.nativecall.Verifier#getDefaultModule() - */ - public String getDefaultModule() { - return "kernel32"; - } - - /** - * If the function name ends on 'W' (Windows' Unicode functions), a - * char array is returned, otherwise a byte array - * is returned. - *

- * The arrays are always null-terminated. - * - * @see com.eaio.nativecall.Verifier#handleString(java.lang.String, - * java.lang.String, - * java.lang.String) - */ - public Object handleString(String val, String module, String function) { - if (function.charAt(function.length() - 1) == 'W') { - char[] buf = new char[val.length() + 1]; - val.getChars(0, val.length(), buf, 0); - return buf; - } - byte[] buf = new byte[val.length() + 1]; - val.getBytes(0, val.length(), buf, 0); - return buf; - } - -} diff --git a/java/src/com/eaio/nativecall/package.html b/java/src/com/eaio/nativecall/package.html deleted file mode 100644 index ebbd694..0000000 --- a/java/src/com/eaio/nativecall/package.html +++ /dev/null @@ -1,15 +0,0 @@ - - - -Untitled Document - - -

Contains the main NativeCall classes.

-

For instant API information, see:

-
    -
  • {@link com.eaio.nativecall.NativeCall}
  • -
  • {@link com.eaio.nativecall.IntCall}
  • -
  • {@link com.eaio.nativecall.VoidCall}
  • -
- -