--- /dev/null
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tomcat.jni;
+
+import java.nio.ByteBuffer;
+
+/** Buffer
+ *
+ * @author Mladen Turk
+ * @version $Revision$, $Date$
+ */
+
+public class Buffer {
+
+ /**
+ * Allocate a new ByteBuffer from memory
+ * @param size The amount of memory to allocate
+ * @return The ByteBuffer with allocated memory
+ */
+ public static native ByteBuffer malloc(int size);
+
+ /**
+ * Allocate a new ByteBuffer from memory and set all of the memory to 0
+ * @param num Number of elements.
+ * @param size Length in bytes of each element.
+ * @return The ByteBuffer with allocated memory
+ */
+ public static native ByteBuffer calloc(int num, int size);
+
+ /**
+ * Allocate a new ByteBuffer from a pool
+ * @param p The pool to allocate from
+ * @param size The amount of memory to allocate
+ * @return The ByteBuffer with allocated memory
+ */
+ public static native ByteBuffer palloc(long p, int size);
+
+ /**
+ * Allocate a new ByteBuffer from a pool and set all of the memory to 0
+ * @param p The pool to allocate from
+ * @param size The amount of memory to allocate
+ * @return The ByteBuffer with allocated memory
+ */
+ public static native ByteBuffer pcalloc(long p, int size);
+
+ /**
+ * Allocate a new ByteBuffer from already allocated memory.
+ * <br />Allocated memory must be provided from call to the
+ * Stdlib.alloc or Stdlib.calloc methods.
+ * @param mem The memory to use
+ * @param size The amount of memory to use
+ * @return The ByteBuffer with attached memory
+ */
+ public static native ByteBuffer create(long mem, int size);
+
+ /**
+ * Deallocates or frees a memory block used by ByteBuffer
+ * <br /><b>Warning :</b> Call this method only on ByteBuffers
+ * that were created by calling Buffer.alloc or Buffer.calloc.
+ * @param buf Previously allocated ByteBuffer to be freed.
+ */
+ public static native void free(ByteBuffer buf);
+
+ /**
+ * Returns the memory address of the ByteBuffer.
+ * @param buf Previously allocated ByteBuffer.
+ */
+ public static native long address(ByteBuffer buf);
+
+ /**
+ * Returns the allocated memory size of the ByteBuffer.
+ * @param buf Previously allocated ByteBuffer.
+ */
+ public static native long size(ByteBuffer buf);
+
+}
public static native int stat(FileInfo finfo, String fname, int wanted, long pool);
/**
+ * Get the specified file's stats. The file is specified by filename,
+ * instead of using a pre-opened file.
+ * @param fname The name of the file to stat.
+ * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ values
+ * @param pool the pool to use to allocate the new file.
+ * @return FileInfo object.
+ */
+ public static native FileInfo getStat(String fname, int wanted, long pool);
+
+ /**
* Get the specified file's stats.
* @param finfo Where to store the information about the file.
* @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ values
*/
public static native int infoGet(FileInfo finfo, int wanted, long thefile);
+
+ /**
+ * Get the specified file's stats.
+ * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ values
+ * @param thefile The file to get information about.
+ * @return FileInfo object.
+ */
+ public static native FileInfo getInfo(int wanted, long thefile);
+
}
* @param val The the value to set
* @return If the function succeeds, the return value is 0
*/
- public static native int setValueJ(long key, String name, int val);
+ public static native int setValueJ(long key, String name, long val);
/**
* Set the Registry value for REG_SZ
public static native int initialize(String engine);
/**
- * Set source of entropy to use in SSL
- * @param filename Filename containing random data
- */
- public static native boolean randSet(String filename);
-
- /**
* Add content of the file to the PRNG
* @param filename Filename containing random data.
* If null the default file will be tested.
boolean base64);
/**
+ * Sets global random filename.
+ * @param filename Filename to use.
+ * If set it will be used for SSL initialization
+ * and all contexts where explicitly not set.
+ */
+ public static native void randSet(String filename);
+
+ /**
* Initialize new BIO
* @param pool The pool to use.
* @param callback BIOCallback to use
throws Exception;
/**
+ * Set file for randomness
+ * @param ctx Server or Client context to use.
+ * @param file random file.
+ */
+ public static native void setRandom(long ctx, String file)
+
+ /**
* Set SSL connection shutdown type
* <br />
* The following levels are available for level:
* @param ctx Server or Client context to use.
* @param type Shutdown type to use.
*/
- public static native void setShutdowType(long ctx, int type);
+ public static native void setShutdownType(long ctx, int type);
/**
* Set Type of Client Certificate verification and Maximum depth of CA Certificates
* made the connection request. This is the socket which should
* be used for all future communication.
*/
+ public static native long acceptx(long sock, long pool)
+ throws Exception;
+
+ /**
+ * Accept a new connection request
+ * @param sock The socket we are listening on.
+ * @return A copy of the socket that is connected to the socket that
+ * made the connection request. This is the socket which should
+ * be used for all future communication.
+ */
public static native long accept(long sock)
throws Exception;
*/
public static native int sendb(long sock, ByteBuffer buf,
int offset, int len);
+
+ /**
+ * Send data over a network without retry
+ * <PRE>
+ * This functions acts like a blocking write by default. To change
+ * this behavior, use apr_socket_timeout_set() or the APR_SO_NONBLOCK
+ * socket option.
+ *
+ * It is possible for both bytes to be sent and an error to be returned.
+ *
+ * </PRE>
+ * @param sock The socket to send the data over.
+ * @param buf The Byte buffer which contains the data to be sent.
+ * @param offset The offset within the buffer array of the first buffer from
+ * which bytes are to be retrieved; must be non-negative
+ * and no larger than buf.length
+ * @param len The maximum number of buffers to be accessed; must be non-negative
+ * and no larger than buf.length - offset
+ * @return The number of bytes send.
+ *
+ */
+ public static native int sendib(long sock, ByteBuffer buf,
+ int offset, int len);
+
/**
* Send data over a network using internally set ByteBuffer
*/
int offset, int len);
/**
+ * Send data over a network using internally set ByteBuffer
+ * without internal retry.
+ */
+ public static native int sendibb(long sock,
+ int offset, int len);
+
+ /**
* Send multiple packets of data over a network.
* <PRE>
* This functions acts like a blocking write by default. To change
* @param buf The ByteBuffer
*/
public static native void setrbb(long sock, ByteBuffer buf);
+
+ /**
+ * Set the data associated with the current socket.
+ * @param sock The currently open socket.
+ * @param data The user data to associate with the socket.
+ * @param key The key to associate with the data.
+ * @param cleanup The cleanup to call when the socket is destroyed.
+ */
+ public static native int dataSet(long sock, String key, Object data);
+
+ /**
+ * Return the data associated with the current socket
+ * @param data The user data associated with the socket.
+ * @param key The key to associate with the user data.
+ * @param sock The currently open socket.
+ * @return Data or null in case of error.
+ */
+ public static native Object dataGet(long sock, String key);
}
* @param num Number of elements.
* @param sz Length in bytes of each element.
*/
- public static native long calloc(long num, int sz);
+ public static native long calloc(int num, int sz);
/**
* Deallocates or frees a memory block.
--- /dev/null
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tomcat.jni;
+
+/** Thread
+ *
+ * @author Mladen Turk
+ * @version $Revision$, $Date$
+ */
+
+public class Thread {
+
+ /**
+ * Get the current thread ID handle.
+ */
+ public static native long current();
+
+}