Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update to new jnr project locations.

  • Loading branch information...
commit 29d200e6f4442db76904734f05fd18c84c8acfbf 1 parent c8a21c2
@headius headius authored
View
31 src/main/java/jnr/unixsocket/Native.java
@@ -18,23 +18,22 @@
package jnr.unixsocket;
-import com.kenai.constantine.platform.ProtocolFamily;
-import com.kenai.constantine.platform.Sock;
-import com.kenai.constantine.platform.SocketLevel;
-import com.kenai.constantine.platform.SocketOption;
-import com.kenai.jaffl.LastError;
-import com.kenai.jaffl.Library;
-import com.kenai.jaffl.Platform;
-import com.kenai.jaffl.annotations.In;
-import com.kenai.jaffl.annotations.Out;
-import com.kenai.jaffl.annotations.Transient;
-import com.kenai.jaffl.byref.IntByReference;
+import jnr.constants.platform.ProtocolFamily;
+import jnr.constants.platform.Sock;
+import jnr.constants.platform.SocketLevel;
+import jnr.constants.platform.SocketOption;
+import jnr.ffi.*;
+import jnr.ffi.annotations.In;
+import jnr.ffi.annotations.Out;
+import jnr.ffi.annotations.Transient;
+import jnr.ffi.byref.IntByReference;
+
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
class Native {
- static final String[] libnames = Platform.getPlatform().getOS() == Platform.OS.SOLARIS
+ static final String[] libnames = Platform.getNativePlatform().getOS() == Platform.OS.SOLARIS
? new String[] { "socket", "nsl", "c" }
: new String[] { "c" };
public static interface LibC {
@@ -66,7 +65,7 @@ static final LibC libc() {
}
static int socket(ProtocolFamily domain, Sock type, int protocol) throws IOException {
- int fd = libsocket().socket(domain.value(), type.value(), protocol);
+ int fd = libsocket().socket(domain.intValue(), type.intValue(), protocol);
if (fd < 0) {
throw new IOException(getLastErrorString());
}
@@ -74,7 +73,7 @@ static int socket(ProtocolFamily domain, Sock type, int protocol) throws IOExcep
}
static int socketpair(ProtocolFamily domain, Sock type, int protocol, int[] sv) throws IOException {
- if (libsocket().socketpair(domain.value(), type.value(), protocol, sv) < 0) {
+ if (libsocket().socketpair(domain.intValue(), type.intValue(), protocol, sv) < 0) {
throw new IOException("socketpair(2) failed " + Native.getLastErrorString());
}
return 0;
@@ -97,7 +96,7 @@ static int connect(int fd, SockAddrUnix addr, int len) {
}
static String getLastErrorString() {
- return strerror(LastError.getLastError());
+ return strerror(LastError.getLastError(jnr.ffi.Runtime.getSystemRuntime()));
}
static String strerror(int error) {
@@ -118,6 +117,6 @@ public static int setsockopt(int s, SocketLevel level, SocketOption optname, boo
ByteBuffer buf = ByteBuffer.allocate(4);
buf.order(ByteOrder.BIG_ENDIAN);
buf.putInt(optval ? 1 : 0).flip();
- return libsocket().setsockopt(s, level.value(), optname.value(), buf, buf.remaining());
+ return libsocket().setsockopt(s, level.intValue(), optname.intValue(), buf, buf.remaining());
}
}
View
9 src/main/java/jnr/unixsocket/SockAddrUnix.java
@@ -19,8 +19,7 @@
package jnr.unixsocket;
import com.kenai.constantine.platform.ProtocolFamily;
-import com.kenai.jaffl.Platform;
-import com.kenai.jaffl.struct.Struct;
+import jnr.ffi.*;
/**
* Native unix domain socket address structure.
@@ -31,6 +30,10 @@
protected abstract UTF8String getPathField();
protected abstract NumberField getFamilyField();
+ public SockAddrUnix() {
+ super(jnr.ffi.Runtime.getSystemRuntime());
+ }
+
/**
* Sets the protocol family of this unix socket address.
*
@@ -97,7 +100,7 @@ static SockAddrUnix create() {
}
private static final int strlen(UTF8String str) {
- int end = str.getMemoryIO().indexOf(str.offset(), (byte) 0);
+ int end = str.getMemory().indexOf(str.offset(), (byte) 0);
return end >= 0 ? end : str.length();
}
View
7 src/main/java/jnr/unixsocket/UnixServerSocketChannel.java
@@ -18,10 +18,11 @@
package jnr.unixsocket;
-import com.kenai.constantine.platform.ProtocolFamily;
-import com.kenai.constantine.platform.Sock;
-import com.kenai.jaffl.byref.IntByReference;
+import jnr.constants.platform.ProtocolFamily;
+import jnr.constants.platform.Sock;
import jnr.enxio.channels.NativeServerSocketChannel;
+import jnr.ffi.byref.IntByReference;
+
import java.io.IOException;
import java.nio.channels.SelectionKey;
import java.nio.channels.spi.SelectorProvider;
View
9 src/main/java/jnr/unixsocket/UnixSocket.java
@@ -18,10 +18,11 @@
package jnr.unixsocket;
-import com.kenai.constantine.platform.SocketLevel;
-import com.kenai.constantine.platform.SocketOption;
-import com.kenai.jaffl.byref.IntByReference;
+import jnr.constants.platform.SocketLevel;
+import jnr.constants.platform.SocketOption;
import jnr.enxio.channels.NativeSocketChannel;
+import jnr.ffi.byref.IntByReference;
+
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.Channel;
@@ -46,7 +47,7 @@ public final boolean getKeepAlive() {
buf.order(ByteOrder.BIG_ENDIAN);
IntByReference ref = new IntByReference(4);
- Native.libsocket().getsockopt(channel.getFD(), SocketLevel.SOL_SOCKET.value(), SocketOption.SO_KEEPALIVE.value(), buf, ref);
+ Native.libsocket().getsockopt(channel.getFD(), SocketLevel.SOL_SOCKET.intValue(), SocketOption.SO_KEEPALIVE.intValue(), buf, ref);
return buf.getInt(0) != 0;
}
View
13 src/main/java/jnr/unixsocket/UnixSocketChannel.java
@@ -18,12 +18,13 @@
package jnr.unixsocket;
-import com.kenai.constantine.platform.Errno;
-import com.kenai.constantine.platform.ProtocolFamily;
-import com.kenai.constantine.platform.Sock;
-import com.kenai.jaffl.LastError;
-import com.kenai.jaffl.byref.IntByReference;
+import jnr.constants.platform.Errno;
+import jnr.constants.platform.ProtocolFamily;
+import jnr.constants.platform.Sock;
import jnr.enxio.channels.NativeSocketChannel;
+import jnr.ffi.*;
+import jnr.ffi.byref.IntByReference;
+
import java.io.IOException;
import java.nio.channels.SelectionKey;
@@ -80,7 +81,7 @@ private UnixSocketChannel() throws IOException {
private final boolean doConnect(SockAddrUnix remote) throws IOException {
if (Native.connect(getFD(), remote, remote.length()) != 0) {
- Errno error = Errno.valueOf(LastError.getLastError());
+ Errno error = Errno.valueOf(LastError.getLastError(jnr.ffi.Runtime.getSystemRuntime()));
switch (error) {
case EAGAIN:
Please sign in to comment.
Something went wrong with that request. Please try again.