libjna-posix-java-1.0.1.orig/0000755000175000017500000000000011313156246014432 5ustar niconicolibjna-posix-java-1.0.1.orig/.hg_archival.txt0000644000175000017500000000013611176403715017523 0ustar niconicorepo: 4a6b7858fa8903cd9f591bcacb3b474d6d7e8888 node: 398dca0a1c215b9414bf7c6667c2c6a8ff6f0a6f libjna-posix-java-1.0.1.orig/src/0000755000175000017500000000000011313156245015220 5ustar niconicolibjna-posix-java-1.0.1.orig/src/org/0000755000175000017500000000000011313156245016007 5ustar niconicolibjna-posix-java-1.0.1.orig/src/org/jruby/0000755000175000017500000000000011313156245017142 5ustar niconicolibjna-posix-java-1.0.1.orig/src/org/jruby/ext/0000755000175000017500000000000011313156245017742 5ustar niconicolibjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/0000755000175000017500000000000011313156246021105 5ustar niconicolibjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/NativePasswd.java0000644000175000017500000000021011176403715024354 0ustar niconicopackage org.jruby.ext.posix; import com.sun.jna.Structure; public abstract class NativePasswd extends Structure implements Passwd { } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/util/0000755000175000017500000000000011313156246022062 5ustar niconicolibjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/util/FieldAccess.java0000644000175000017500000000146111176403715025077 0ustar niconico/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package org.jruby.ext.posix.util; import java.lang.reflect.Field; /** * * @author nicksieger */ public class FieldAccess { public static Field getProtectedField(Class klass, String fieldName) { Field field = null; try { field = klass.getDeclaredField(fieldName); field.setAccessible(true); } catch (Exception e) { } return field; } public static Object getProtectedFieldValue(Class klass, String fieldName, Object instance) { try { Field f = getProtectedField(klass, fieldName); return f.get(instance); } catch (Exception e) { throw new IllegalArgumentException(e); } } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/util/ExecIt.java0000644000175000017500000001371211176403715024115 0ustar niconico/***** BEGIN LICENSE BLOCK ***** * Version: CPL 1.0/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Common 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.eclipse.org/legal/cpl-v10.html * * 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. * * Copyright (C) 2008 JRuby Community * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the CPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the CPL, the GPL or the LGPL. ***** END LICENSE BLOCK *****/ package org.jruby.ext.posix.util; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import org.jruby.ext.posix.POSIXHandler; public class ExecIt { POSIXHandler handler; /** Creates a new instance of ShellLauncher */ public ExecIt(POSIXHandler handler) { this.handler = handler; } public int runAndWait(String... args) throws IOException, InterruptedException { return runAndWait(handler.getOutputStream(), args); } public int runAndWait(OutputStream output, String... args) throws IOException, InterruptedException { Process process = run(args); handleStreams(process, handler.getInputStream(), output, handler.getErrorStream()); return process.waitFor(); } public Process run(String... args) throws IOException { File cwd = handler.getCurrentWorkingDirectory(); return Runtime.getRuntime().exec(args, handler.getEnv(), cwd); } private static class StreamPumper extends Thread { private InputStream in; private OutputStream out; private boolean onlyIfAvailable; private volatile boolean quit; private final Object waitLock = new Object(); StreamPumper(InputStream in, OutputStream out, boolean avail) { this.in = in; this.out = out; this.onlyIfAvailable = avail; } public void run() { byte[] buf = new byte[1024]; int numRead; boolean hasReadSomething = false; try { while (!quit) { // The problem we trying to solve below: STDIN in Java is blocked and // non-interruptible, so if we invoke read on it, we might never be able to // interrupt such thread. So, we use in.available() to see if there is any // input ready, and only then read it. But this approach can't tell whether // the end of stream reached or not, so we might end up looping right at the // end of the stream. Well, at least, we can improve the situation by checking // if some input was ever available, and if so, not checking for available // anymore, and just go to read. if (onlyIfAvailable && !hasReadSomething) { if (in.available() == 0) { synchronized (waitLock) { waitLock.wait(10); } continue; } else { hasReadSomething = true; } } if ((numRead = in.read(buf)) == -1) { break; } out.write(buf, 0, numRead); } } catch (Exception e) { } finally { if (onlyIfAvailable) { // We need to close the out, since some // processes would just wait for the stream // to be closed before they process its content, // and produce the output. E.g.: "cat". try { out.close(); } catch (IOException ioe) {} } } } public void quit() { this.quit = true; synchronized (waitLock) { waitLock.notify(); } } } private void handleStreams(Process p, InputStream in, OutputStream out, OutputStream err) throws IOException { InputStream pOut = p.getInputStream(); InputStream pErr = p.getErrorStream(); OutputStream pIn = p.getOutputStream(); StreamPumper t1 = new StreamPumper(pOut, out, false); StreamPumper t2 = new StreamPumper(pErr, err, false); StreamPumper t3 = new StreamPumper(in, pIn, true); t1.start(); t2.start(); t3.start(); try { t1.join(); } catch (InterruptedException ie) {} try { t2.join(); } catch (InterruptedException ie) {} t3.quit(); try { err.flush(); } catch (IOException io) {} try { out.flush(); } catch (IOException io) {} try { pIn.close(); } catch (IOException io) {} try { pOut.close(); } catch (IOException io) {} try { pErr.close(); } catch (IOException io) {} } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/util/Platform.java0000644000175000017500000001216211176403715024516 0ustar niconico/***** BEGIN LICENSE BLOCK ***** * Version: CPL 1.0/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Common 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.eclipse.org/legal/cpl-v10.html * * 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 contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the CPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the CPL, the GPL or the LGPL. ***** END LICENSE BLOCK *****/ /** * $Id: $ */ package org.jruby.ext.posix.util; import java.util.HashMap; import java.util.Map; public class Platform { public static final String OS_NAME = System.getProperty("os.name"); public static final String OS_NAME_LC = OS_NAME.toLowerCase(); // Generic Windows designation private static final String WINDOWS = "windows"; // For Windows 95, 98... Would these platforms actually work? private static final String WINDOWS_9X = "windows 9"; // TODO: Windows ME? private static final String WINDOWS_NT = "nt"; private static final String WINDOWS_20X = "windows 2"; private static final String WINDOWS_XP = "windows xp"; // TODO: For Windows Server 2003, 2008 private static final String WINDOWS_VISTA = "vista"; private static final String MAC_OS = "mac os"; private static final String DARWIN = "darwin"; private static final String FREEBSD = "freebsd"; private static final String OPENBSD = "openbsd"; private static final String LINUX = "linux"; private static final String SOLARIS = "sunos"; // TODO: investigate supported platforms for OpenJDK7? public static final boolean IS_WINDOWS = OS_NAME_LC.indexOf(WINDOWS) != -1; public static final boolean IS_WINDOWS_9X = OS_NAME_LC.indexOf(WINDOWS_9X) > -1; public static final boolean IS_WINDOWS_NT = IS_WINDOWS && OS_NAME_LC.indexOf(WINDOWS_NT) > -1; public static final boolean IS_WINDOWS_20X = OS_NAME_LC.indexOf(WINDOWS_20X) > -1; public static final boolean IS_WINDOWS_XP = OS_NAME_LC.indexOf(WINDOWS_XP) > -1; public static final boolean IS_WINDOWS_VISTA = IS_WINDOWS && OS_NAME_LC.indexOf(WINDOWS_VISTA) > -1; public static final boolean IS_MAC = OS_NAME_LC.startsWith(MAC_OS) || OS_NAME_LC.startsWith(DARWIN); public static final boolean IS_FREEBSD = OS_NAME_LC.startsWith(FREEBSD); public static final boolean IS_OPENBSD = OS_NAME_LC.startsWith(OPENBSD); public static final boolean IS_LINUX = OS_NAME_LC.startsWith(LINUX); public static final boolean IS_SOLARIS = OS_NAME_LC.startsWith(SOLARIS); public static final boolean IS_BSD = IS_MAC || IS_FREEBSD || IS_OPENBSD; public static final String envCommand() { if (IS_WINDOWS) { if (IS_WINDOWS_9X) { return "command.com /c set"; } else if (IS_WINDOWS_NT || IS_WINDOWS_20X || IS_WINDOWS_XP || IS_WINDOWS_VISTA) { return "cmd.exe /c set"; } } return "env"; } public static final boolean IS_32_BIT = "32".equals(getProperty("sun.arch.data.model", "32")); public static final boolean IS_64_BIT = "64".equals(getProperty("sun.arch.data.model", "64")); public static final String ARCH = System.getProperty("os.arch"); public static final Map OS_NAMES = new HashMap(); static { OS_NAMES.put("Mac OS X", DARWIN); OS_NAMES.put("Darwin", DARWIN); OS_NAMES.put("Linux", LINUX); } public static String getOSName() { String theOSName = OS_NAMES.get(OS_NAME); return theOSName == null ? OS_NAME : theOSName; } /** * An extension over System.getProperty method. * Handles security restrictions, and returns the default * value if the access to the property is restricted. * @param property The system property name. * @param defValue The default value. * @return The value of the system property, * or the default value. */ public static String getProperty(String property, String defValue) { try { return System.getProperty(property, defValue); } catch (SecurityException se) { return defValue; } } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/util/Chmod.java0000644000175000017500000000740511176403715023770 0ustar niconicopackage org.jruby.ext.posix.util; import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /** * Honor semantics of chmod as best we can in pure Java. Note, this uses reflection to be * more tolerant of different Java versions. */ public class Chmod { private static final boolean CHMOD_API_AVAILABLE; private static final Method setWritable; private static final Method setReadable; private static final Method setExecutable; static { boolean apiAvailable = false; Method setWritableVar = null; Method setReadableVar = null; Method setExecutableVar = null; try { setWritableVar = File.class.getMethod("setWritable", new Class[] {Boolean.TYPE, Boolean.TYPE}); setReadableVar = File.class.getMethod("setReadable", new Class[] {Boolean.TYPE, Boolean.TYPE}); setExecutableVar = File.class.getMethod("setExecutable", new Class[] {Boolean.TYPE, Boolean.TYPE}); apiAvailable = true; } catch (Exception e) { // failed to load methods, no chmod API available } setWritable = setWritableVar; setReadable = setReadableVar; setExecutable = setExecutableVar; CHMOD_API_AVAILABLE = apiAvailable; } public static int chmod(File file, String mode) { if (CHMOD_API_AVAILABLE) { // fast version char other = '0'; if (mode.length() >= 1) { other = mode.charAt(mode.length() - 1); } //char group = mode.charAt(mode.length() - 2); char user = '0'; if (mode.length() >= 3) { user = mode.charAt(mode.length() - 3); } //char setuidgid = mode.charAt(mode.length() - 3); // group and setuid/gid are ignored, no way to do them fast. Should we fall back on slow? if (!setPermissions(file, other, false)) return -1; if (!setPermissions(file, user, true)) return -1; } else { // slow version try { Process chmod = Runtime.getRuntime().exec("/bin/chmod " + mode + " " + file.getAbsolutePath()); chmod.waitFor(); return chmod.exitValue(); } catch (IOException ioe) { // FIXME: ignore? } catch (InterruptedException ie) { // FIXME: ignore? } } return -1; } private static boolean setPermissions(File file, char permChar, boolean userOnly) { int permValue = Character.digit(permChar, 8); try { if ((permValue & 1) != 0) { setExecutable.invoke(file, new Object[] {Boolean.TRUE, Boolean.valueOf(userOnly)}); } else { setExecutable.invoke(file, new Object[] {Boolean.FALSE, Boolean.valueOf(userOnly)}); } if ((permValue & 2) != 0) { setWritable.invoke(file, new Object[] {Boolean.TRUE, Boolean.valueOf(userOnly)}); } else { setWritable.invoke(file, new Object[] {Boolean.FALSE, Boolean.valueOf(userOnly)}); } if ((permValue & 4) != 0) { setReadable.invoke(file, new Object[] {Boolean.TRUE, Boolean.valueOf(userOnly)}); } else { setReadable.invoke(file, new Object[] {Boolean.FALSE, Boolean.valueOf(userOnly)}); } return true; } catch (IllegalAccessException iae) { // ignore, return false below } catch (InvocationTargetException ite) { // ignore, return false below } return false; } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/POSIXHandler.java0000644000175000017500000000404311176403715024154 0ustar niconicopackage org.jruby.ext.posix; import java.io.File; import java.io.InputStream; import java.io.PrintStream; /** * The POSIXHandler class allows you do implement the runtime-specific behavior you need in * such a way that it is insulated from the implementation of the POSIX library. Implementing * each of the methods in this interface should give you are working POSIX implementation. * */ public interface POSIXHandler { public enum WARNING_ID { DUMMY_VALUE_USED("DUMMY_VALUE_USED"); private String messageID; WARNING_ID(String messageID) { this.messageID = messageID; } } public void error(POSIX.ERRORS error, String extraData); /** * Specify that posix method is unimplemented. In JRuby we generate an * exception with this. */ public void unimplementedError(String methodName); public void warn(WARNING_ID id, String message, Object... data); /** * Should we provide verbose output about POSIX activities */ public boolean isVerbose(); /** * Get current working directory of your runtime. */ public File getCurrentWorkingDirectory(); /** * Get current set of environment variables of your runtime. */ public String[] getEnv(); /** * Get your runtime's current InputStream */ public InputStream getInputStream(); /** * Get your runtime's current OutputStream */ public PrintStream getOutputStream(); /** * Get your runtimes process ID. This is only intended for non-native POSIX support (e.g. * environments where JNA cannot load or security restricted environments). In JRuby we * found a number of packages which would rather have some identity for the runtime than * nothing. * * Note: If you do not want this to work you impl can just call unimplementedError(String). */ public int getPID(); /** * Get your runtime's current ErrorStream */ public PrintStream getErrorStream(); } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/FileStat.java0000644000175000017500000000566311176403715023500 0ustar niconicopackage org.jruby.ext.posix; public interface FileStat { public static final int S_IFIFO = 0010000; // named pipe (fifo) public static final int S_IFCHR = 0020000; // character special public static final int S_IFDIR = 0040000; // directory public static final int S_IFBLK = 0060000; // block special public static final int S_IFREG = 0100000; // regular public static final int S_IFLNK = 0120000; // symbolic link public static final int S_IFSOCK = 0140000; // socket public static final int S_IFMT = 0170000; // file mask for type checks public static final int S_ISUID = 0004000; // set user id on execution public static final int S_ISGID = 0002000; // set group id on execution public static final int S_ISVTX = 0001000; // save swapped text even after use public static final int S_IRUSR = 0000400; // read permission, owner public static final int S_IWUSR = 0000200; // write permission, owner public static final int S_IXUSR = 0000100; // execute/search permission, owner public static final int S_IRGRP = 0000040; // read permission, group public static final int S_IWGRP = 0000020; // write permission, group public static final int S_IXGRP = 0000010; // execute/search permission, group public static final int S_IROTH = 0000004; // read permission, other public static final int S_IWOTH = 0000002; // write permission, other public static final int S_IXOTH = 0000001; // execute permission, other public static final int ALL_READ = S_IRUSR | S_IRGRP | S_IROTH; public static final int ALL_WRITE = S_IWUSR | S_IWGRP | S_IWOTH; public static final int S_IXUGO = S_IXUSR | S_IXGRP | S_IXOTH; public long atime(); public long blocks(); public long blockSize(); public long ctime(); public long dev(); public String ftype(); public int gid(); public boolean groupMember(int gid); public long ino(); public boolean isBlockDev(); public boolean isCharDev(); public boolean isDirectory(); public boolean isEmpty(); public boolean isExecutable(); public boolean isExecutableReal(); public boolean isFifo(); public boolean isFile(); public boolean isGroupOwned(); public boolean isIdentical(FileStat other); public boolean isNamedPipe(); public boolean isOwned(); public boolean isROwned(); public boolean isReadable(); public boolean isReadableReal(); public boolean isWritable(); public boolean isWritableReal(); public boolean isSetgid(); public boolean isSetuid(); public boolean isSocket(); public boolean isSticky(); public boolean isSymlink(); public int major(long dev); public int minor(long dev); public int mode(); public long mtime(); public int nlink(); public long rdev(); /** * Note: Name 'st_size' since Structure has a 'size' method already */ public long st_size(); public int uid(); } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/BaseNativePOSIX.java0000644000175000017500000001521311176403715024621 0ustar niconicopackage org.jruby.ext.posix; import com.sun.jna.FromNativeContext; import com.sun.jna.FromNativeConverter; import com.sun.jna.Native; import com.sun.jna.NativeLibrary; import com.sun.jna.Pointer; import java.io.FileDescriptor; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.charset.Charset; public abstract class BaseNativePOSIX implements POSIX { protected String libraryName; protected LibC libc; protected POSIXHandler handler; protected JavaLibCHelper helper; public BaseNativePOSIX(String libraryName, LibC libc, POSIXHandler handler) { this.libc = libc; this.handler = handler; this.libraryName = libraryName; helper = new JavaLibCHelper(handler); } public int chmod(String filename, int mode) { return libc.chmod(filename, mode); } public int chown(String filename, int user, int group) { return libc.chown(filename, user, group); } public FileStat fstat(FileDescriptor fileDescriptor) { FileStat stat = allocateStat(); int fd = helper.getfd(fileDescriptor); if (libc.fstat(fd, stat) < 0) handler.error(ERRORS.ENOENT, ""+fd); return stat; } public int getegid() { return libc.getegid(); } public int geteuid() { return libc.geteuid(); } public int getgid() { return libc.getgid(); } public String getlogin() { return libc.getlogin(); } public int getpgid() { return libc.getpgid(); } public int getpgrp() { return libc.getpgrp(); } public int getpid() { return libc.getpid(); } public int getppid() { return libc.getppid(); } public Passwd getpwent() { return libc.getpwent(); } public Passwd getpwuid(int which) { return libc.getpwuid(which); } public Passwd getpwnam(String which) { return libc.getpwnam(which); } public Group getgrent() { return libc.getgrent(); } public Group getgrgid(int which) { return libc.getgrgid(which); } public Group getgrnam(String which) { return libc.getgrnam(which); } public int setpwent() { return libc.setpwent(); } public int endpwent() { return libc.endpwent(); } public int setgrent() { return libc.setgrent(); } public int endgrent() { return libc.endgrent(); } public int getuid() { return libc.getuid(); } public int setegid(int egid) { return libc.setegid(egid); } public int seteuid(int euid) { return libc.seteuid(euid); } public int setgid(int gid) { return libc.setgid(gid); } public int getfd(FileDescriptor descriptor) { return helper.getfd(descriptor); } public int getpgid(int pid) { return libc.getpgid(pid); } public int setpgid(int pid, int pgid) { return libc.setpgid(pid, pgid); } public int setpgrp(int pid, int pgrp) { return libc.setpgrp(pid, pgrp); } public int setsid() { return libc.setsid(); } public int setuid(int uid) { return libc.setuid(uid); } public int kill(int pid, int signal) { return libc.kill(pid, signal); } public int lchmod(String filename, int mode) { return libc.lchmod(filename, mode); } public int lchown(String filename, int user, int group) { return libc.lchown(filename, user, group); } public int link(String oldpath, String newpath) { return libc.link(oldpath, newpath); } public FileStat lstat(String path) { FileStat stat = allocateStat(); if (libc.lstat(path, stat) < 0) handler.error(ERRORS.ENOENT, path); return stat; } public int mkdir(String path, int mode) { return libc.mkdir(path, mode); } public FileStat stat(String path) { FileStat stat = allocateStat(); if (libc.stat(path, stat) < 0) handler.error(ERRORS.ENOENT, path); return stat; } public int symlink(String oldpath, String newpath) { return libc.symlink(oldpath, newpath); } public String readlink(String oldpath) throws IOException { // TODO: this should not be hardcoded to 256 bytes ByteBuffer buffer = ByteBuffer.allocate(256); int result = libc.readlink(oldpath, buffer, buffer.capacity()); if (result == -1) return null; buffer.position(0); buffer.limit(result); return Charset.forName("ASCII").decode(buffer).toString(); } public int umask(int mask) { return libc.umask(mask); } public int utimes(String path, long[] atimeval, long[] mtimeval) { Timeval[] times = null; if (atimeval != null && mtimeval != null) { times = ((Timeval[])new DefaultNativeTimeval().toArray(2)); times[0].setTime(atimeval); times[1].setTime(mtimeval); } return libc.utimes(path, times); } public int fork() { return libc.fork(); } public int waitpid(int pid, int[] status, int flags) { return libc.waitpid(pid, status, pid); } public int wait(int[] status) { return libc.wait(status); } public int getpriority(int which, int who) { return libc.getpriority(which, who); } public int setpriority(int which, int who, int prio) { return libc.setpriority(which, who, prio); } public boolean isatty(FileDescriptor fd) { return libc.isatty(helper.getfd(fd)) != 0; } public int errno() { return Native.getLastError(); } public void errno(int value) { Native.setLastError(value); } public abstract FileStat allocateStat(); /** * Does the loaded library have the method specified * @param name of method to look for * @return true if found. false otherwise */ protected boolean hasMethod(String name) { try { NativeLibrary.getInstance(libraryName).getFunction(name); } catch (UnsatisfiedLinkError e) { return false; } return true; } public static abstract class PointerConverter implements FromNativeConverter { public Class nativeType() { return Pointer.class; } } public static final PointerConverter GROUP = new PointerConverter() { public Object fromNative(Object arg, FromNativeContext ctx) { return arg != null ? new DefaultNativeGroup((Pointer) arg) : null; } }; } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/LinuxPasswd.java0000644000175000017500000000235711176403715024243 0ustar niconico/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package org.jruby.ext.posix; import com.sun.jna.Pointer; /** * */ public class LinuxPasswd extends NativePasswd implements Passwd { public String pw_name; // user name public String pw_passwd; // password (encrypted) public int pw_uid; // user id public int pw_gid; // user id public String pw_gecos; // login info public String pw_dir; // home directory public String pw_shell; // default shell LinuxPasswd(Pointer memory) { useMemory(memory); read(); } public String getAccessClass() { return ""; } public String getGECOS() { return pw_gecos; } public long getGID() { return pw_gid; } public String getHome() { return pw_dir; } public String getLoginName() { return pw_name; } public String getPassword() { return pw_passwd; } public String getShell() { return pw_shell; } public long getUID() { return pw_uid; } public int getPasswdChangeTime() { return 0; } public int getExpire() { return Integer.MAX_VALUE; } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/MacOSHeapFileStat.java0000644000175000017500000000677711176403715025170 0ustar niconico/***** BEGIN LICENSE BLOCK ***** * Version: CPL 1.0/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Common 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.eclipse.org/legal/cpl-v10.html * * 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 contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the CPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the CPL, the GPL or the LGPL. ***** END LICENSE BLOCK *****/ /** * $Id: $ */ package org.jruby.ext.posix; public final class MacOSHeapFileStat extends BaseHeapFileStat { public final class time_t extends Long { } public final Int32 st_dev = new Int32(); public final Int32 st_ino = new Int32(); public final Int16 st_mode = new Int16(); public final Int16 st_nlink = new Int16(); public final Int32 st_uid = new Int32(); public final Int32 st_gid = new Int32(); public final Int32 st_rdev = new Int32(); public final time_t st_atime = new time_t(); public final Long st_atimensec = new Long(); public final time_t st_mtime = new time_t(); public final Long st_mtimensec = new Long(); public final time_t st_ctime = new time_t(); public final Long st_ctimensec = new Long(); public final Int64 st_size = new Int64(); public final Int64 st_blocks = new Int64(); public final Int32 st_blksize = new Int32(); public final Int32 st_flags = new Int32(); public final Int32 st_gen = new Int32(); public final Int32 st_lspare = new Int32(); public final Int64 st_qspare0 = new Int64(); public final Int64 st_qspare1 = new Int64(); public MacOSHeapFileStat() { this(null); } public MacOSHeapFileStat(POSIX posix) { super(posix); } public long atime() { return st_atime.get(); } public long blocks() { return st_blocks.get(); } public long blockSize() { return st_blksize.get(); } public long ctime() { return st_ctime.get(); } public long dev() { return st_dev.get(); } public int gid() { return st_gid.get(); } public long ino() { return st_ino.get(); } public int mode() { return st_mode.get() & 0xffff; } public long mtime() { return st_mtime.get(); } public int nlink() { return st_nlink.get(); } public long rdev() { return st_rdev.get(); } public long st_size() { return st_size.get(); } public int uid() { return st_uid.get(); } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/FreeBSDPasswd.java0000644000175000017500000000552311176403715024354 0ustar niconico/***** BEGIN LICENSE BLOCK ***** * Version: CPL 1.0/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Common 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.eclipse.org/legal/cpl-v10.html * * 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 contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the CPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the CPL, the GPL or the LGPL. ***** END LICENSE BLOCK *****/ /** * $Id: $ */ package org.jruby.ext.posix; import com.sun.jna.NativeLong; import com.sun.jna.Pointer; public class FreeBSDPasswd extends NativePasswd implements Passwd { public String pw_name; // user name public String pw_passwd; // password (encrypted) public int pw_uid; // user id public int pw_gid; // user id public NativeLong pw_change; // password change time public String pw_class; // user access class public String pw_gecos; // login info public String pw_dir; // home directory public String pw_shell; // default shell public NativeLong pw_expire; // account expiration public int pw_fields; // internal: fields filled in FreeBSDPasswd(Pointer memory) { useMemory(memory); read(); } public String getAccessClass() { return pw_class; } public String getGECOS() { return pw_gecos; } public long getGID() { return pw_gid; } public String getHome() { return pw_dir; } public String getLoginName() { return pw_name; } public int getPasswdChangeTime() { return pw_change.intValue(); } public String getPassword() { return pw_passwd; } public String getShell() { return pw_shell; } public long getUID() { return pw_uid; } public int getExpire() { return pw_expire.intValue(); } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/DefaultNativeGroup.java0000644000175000017500000000472311176403715025531 0ustar niconico/***** BEGIN LICENSE BLOCK ***** * Version: CPL 1.0/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Common 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.eclipse.org/legal/cpl-v10.html * * 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 contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the CPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the CPL, the GPL or the LGPL. ***** END LICENSE BLOCK *****/ package org.jruby.ext.posix; import com.sun.jna.Pointer; import java.util.ArrayList; import java.util.List; /** * The default native group layout. * *

* This implementation should work on Solaris, Linux and MacOS. *

*/ public final class DefaultNativeGroup extends NativeGroup implements Group { public String gr_name; // name public String gr_passwd; // group password (encrypted) public int gr_gid; // group id public Pointer gr_mem; DefaultNativeGroup(Pointer memory) { useMemory(memory); read(); } public String getName() { return gr_name; } public String getPassword() { return gr_passwd; } public long getGID() { return gr_gid; } public String[] getMembers() { int size = Pointer.SIZE; int i=0; List lst = new ArrayList(); while(gr_mem.getPointer(i) != null) { lst.add(gr_mem.getPointer(i).getString(0)); i+=size; } return lst.toArray(new String[0]); } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/SolarisFileStat.java0000644000175000017500000000351611176403715025030 0ustar niconicopackage org.jruby.ext.posix; import com.sun.jna.Structure; public class SolarisFileStat extends BaseNativeFileStat { public static class TimeStruct extends Structure { public volatile int tv_sec; public volatile int tv_nsec; } public volatile int st_dev; public volatile int[] st_pad1; public volatile int st_ino; public volatile int st_mode; public volatile int st_nlink; public volatile int st_uid; public volatile int st_gid; public volatile int st_rdev; public volatile int[] st_pad2; public volatile int st_size; public volatile int st_pad3; public volatile TimeStruct st_atim; public volatile TimeStruct st_mtim; public volatile TimeStruct st_ctim; public volatile int st_blksize; public volatile int st_blocks; public volatile int pad7; public volatile int pad8; public volatile String st_fstype; public volatile int[] st_pad4; public SolarisFileStat(POSIX posix) { super(posix); st_pad1 = new int[3]; st_pad2 = new int[2]; st_pad4 = new int[8]; } public long atime() { return st_atim.tv_sec; } public long blocks() { return st_blocks; } public long blockSize() { return st_blksize; } public long ctime() { return st_ctim.tv_sec; } public long dev() { return st_dev; } public int gid() { return st_gid; } public long ino() { return st_ino; } public int mode() { return st_mode; } public long mtime() { return st_mtim.tv_sec; } public int nlink() { return st_nlink; } public long rdev() { return st_rdev; } public long st_size() { return st_size; } public int uid() { return st_uid; } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/SolarisPasswd.java0000644000175000017500000000234511176403715024555 0ustar niconico package org.jruby.ext.posix; import com.sun.jna.Pointer; /** * */ public class SolarisPasswd extends NativePasswd implements Passwd { public String pw_name; // user name public String pw_passwd; // password (encrypted) public int pw_uid; // user id public int pw_gid; // user id public Pointer pw_age; // unused public Pointer pw_comment;// unused public String pw_gecos; // login info public String pw_dir; // home directory public String pw_shell; // default shell SolarisPasswd(Pointer memory) { useMemory(memory); read(); } public String getAccessClass() { return "unknown"; } public String getGECOS() { return pw_gecos; } public long getGID() { return pw_gid; } public String getHome() { return pw_dir; } public String getLoginName() { return pw_name; } public int getPasswdChangeTime() { return 0; } public String getPassword() { return pw_passwd; } public String getShell() { return pw_shell; } public long getUID() { return pw_uid; } public int getExpire() { return Integer.MAX_VALUE; } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/POSIX.java0000644000175000017500000000445011176403715022660 0ustar niconicopackage org.jruby.ext.posix; import java.io.FileDescriptor; import java.io.IOException; public interface POSIX { // When we use JNA-3 we can get errno, Then these values should match proper machine values. // If by chance these are not the same values on all systems we will have to have concrete // impls provide these values and stop using an enum. public enum ERRORS { ENOENT, ENOTDIR, ENAMETOOLONG, EACCESS, ELOOP, EFAULT, EIO, EBADF }; public int chmod(String filename, int mode); public int chown(String filename, int user, int group); public int fork(); public FileStat fstat(FileDescriptor descriptor); public int getegid(); public int geteuid(); public int seteuid(int euid); public int getgid(); public String getlogin(); public int getpgid(); public int getpgid(int pid); public int getpgrp(); public int getpid(); public int getppid(); public int getpriority(int which, int who); public Passwd getpwent(); public Passwd getpwuid(int which); public Passwd getpwnam(String which); public Group getgrgid(int which); public Group getgrnam(String which); public Group getgrent(); public int endgrent(); public int setgrent(); public int endpwent(); public int setpwent(); public int getuid(); public boolean isatty(FileDescriptor descriptor); public int kill(int pid, int signal); public int lchmod(String filename, int mode); public int lchown(String filename, int user, int group); public int link(String oldpath,String newpath); public FileStat lstat(String path); public int mkdir(String path, int mode); public String readlink(String path) throws IOException; public int setsid(); public int setgid(int gid); public int setegid(int egid); public int setpgid(int pid, int pgid); public int setpgrp(int pid, int pgrp); public int setpriority(int which, int who, int prio); public int setuid(int uid); public FileStat stat(String path); public int symlink(String oldpath,String newpath); public int umask(int mask); public int utimes(String path, long[] atimeval, long[] mtimeval); public int waitpid(int pid, int[] status, int flags); public int wait(int[] status); public int errno(); public void errno(int value); } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/OpenBSDHeapFileStat.java0000644000175000017500000000723011176403715025441 0ustar niconico/***** BEGIN LICENSE BLOCK ***** * Version: CPL 1.0/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Common 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.eclipse.org/legal/cpl-v10.html * * 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 contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the CPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the CPL, the GPL or the LGPL. ***** END LICENSE BLOCK *****/ /** * $Id: $ */ package org.jruby.ext.posix; public final class OpenBSDHeapFileStat extends BaseHeapFileStat { public final class time_t extends Long {} public final class dev_t extends Int32 {} public final dev_t st_dev = new dev_t(); public final Int32 st_ino = new Int32(); public final Int16 st_mode = new Int16(); public final Int16 st_nlink = new Int16(); public final Int32 st_uid = new Int32(); public final Int32 st_gid = new Int32(); public final dev_t st_rdev = new dev_t(); public final time_t st_atime = new time_t(); public final Long st_atimensec = new Long(); public final time_t st_mtime = new time_t(); public final Long st_mtimensec = new Long(); public final time_t st_ctime = new time_t(); public final Long st_ctimensec = new Long(); public final Int64 st_size = new Int64(); public final Int64 st_blocks = new Int64(); public final Int32 st_blksize = new Int32(); public final Int32 st_flags = new Int32(); public final Int32 st_gen = new Int32(); public final Int32 st_lspare = new Int32(); public final time_t st_birthtime = new time_t(); public final Long st_birthtimensec = new Long(); public final Int64 st_qspare0 = new Int64(); public final Int64 st_qspare1 = new Int64(); public OpenBSDHeapFileStat() { this(null); } public OpenBSDHeapFileStat(POSIX posix) { super(posix); } public long atime() { return st_atime.get(); } public long blocks() { return st_blocks.get(); } public long blockSize() { return st_blksize.get(); } public long ctime() { return st_ctime.get(); } public long dev() { return st_dev.get(); } public int gid() { return st_gid.get(); } public long ino() { return st_ino.get(); } public int mode() { return st_mode.get() & 0xffff; } public long mtime() { return st_mtime.get(); } public int nlink() { return st_nlink.get(); } public long rdev() { return st_rdev.get(); } public long st_size() { return st_size.get(); } public int uid() { return st_uid.get(); } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/WindowsFileStat.java0000644000175000017500000000664311176403715025052 0ustar niconicopackage org.jruby.ext.posix; public class WindowsFileStat extends BaseNativeFileStat { public int st_dev; public short st_ino; public short st_mode; public short st_nlink; public short st_uid; public short st_gid; public int st_rdev; public long st_size; public int st_atime; public int spare1; public int st_mtime; public int spare2; public int st_ctime; public long st_blksize; public long st_blocks; public WindowsFileStat(POSIX posix) { super(posix); } public long atime() { return st_atime; } public long blockSize() { return st_blksize; } public long blocks() { return st_blocks; } public long ctime() { return st_ctime; } public long dev() { return st_dev; } public int gid() { return st_gid; } public long ino() { return st_ino; } public int mode() { return st_mode & 0xffff; } public long mtime() { return st_mtime; } public int nlink() { return st_nlink; } public long rdev() { return st_rdev; } public long st_size() { return st_size; } public int uid() { return st_uid; } // FIXME: Implement @Override public boolean groupMember(int gid) { return true; } @Override public boolean isExecutable() { if (isOwned()) return (mode() & S_IXUSR) != 0; if (isGroupOwned()) return (mode() & S_IXGRP) != 0; if ((mode() & S_IXOTH) != 0) return false; return true; } @Override public boolean isExecutableReal() { if (isROwned()) return (mode() & S_IXUSR) != 0; if (groupMember(gid())) return (mode() & S_IXGRP) != 0; if ((mode() & S_IXOTH) != 0) return false; return true; } // FIXME: Implement @Override public boolean isOwned() { return true; } // FIXME: Implement @Override public boolean isROwned() { return true; } @Override public boolean isReadable() { if (isOwned()) return (mode() & S_IRUSR) != 0; if (isGroupOwned()) return (mode() & S_IRGRP) != 0; if ((mode() & S_IROTH) != 0) return false; return true; } @Override public boolean isReadableReal() { if (isROwned()) return (mode() & S_IRUSR) != 0; if (groupMember(gid())) return (mode() & S_IRGRP) != 0; if ((mode() & S_IROTH) != 0) return false; return true; } @Override public boolean isWritable() { if (isOwned()) return (mode() & S_IWUSR) != 0; if (isGroupOwned()) return (mode() & S_IWGRP) != 0; if ((mode() & S_IWOTH) != 0) return false; return true; } @Override public boolean isWritableReal() { if (isROwned()) return (mode() & S_IWUSR) != 0; if (groupMember(gid())) return (mode() & S_IWGRP) != 0; if ((mode() & S_IWOTH) != 0) return false; return true; } @Override public String toString() { return "st_dev: " + st_dev + ", st_mode: " + Integer.toOctalString(st_mode) + ", st_nlink: " + st_nlink + ", st_rdev: " + st_rdev + ", st_size: " + st_size + ", st_uid: " + st_uid + ", st_gid: " + st_gid + ", st_atime: " + st_atime + ", st_ctime: " + st_ctime + ", st_mtime: " + st_mtime + ", st_ino: " + st_ino; } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/FreeBSDPOSIX.java0000644000175000017500000000403511176403715024012 0ustar niconico/***** BEGIN LICENSE BLOCK ***** * Version: CPL 1.0/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Common 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.eclipse.org/legal/cpl-v10.html * * 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 contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the CPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the CPL, the GPL or the LGPL. ***** END LICENSE BLOCK *****/ /** * $Id: $ */ package org.jruby.ext.posix; import com.sun.jna.FromNativeContext; import com.sun.jna.Pointer; public final class FreeBSDPOSIX extends BaseNativePOSIX { public FreeBSDPOSIX(String libraryName, LibC libc, POSIXHandler handler) { super(libraryName, libc, handler); } public FileStat allocateStat() { return new FreeBSDHeapFileStat(this); } public static final PointerConverter PASSWD = new PointerConverter() { public Object fromNative(Object arg, FromNativeContext ctx) { return arg != null ? new FreeBSDPasswd((Pointer) arg) : null; } }; } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/WindowsPOSIX.java0000644000175000017500000001064411176403715024235 0ustar niconicopackage org.jruby.ext.posix; import java.io.FileDescriptor; public class WindowsPOSIX extends BaseNativePOSIX { // We fall back to Pure Java Posix impl when windows does not support something JavaLibCHelper helper; public WindowsPOSIX(String libraryName, LibC libc, POSIXHandler handler) { super(libraryName, libc, handler); helper = new JavaLibCHelper(handler); } @Override public FileStat allocateStat() { return new WindowsFileStat(this); } @Override public int kill(int pid, int signal) { handler.unimplementedError("kill"); return -1; } @Override public int chown(String filename, int user, int group) { return 0; } @Override public int getegid() { handler.unimplementedError("egid"); return -1; } @Override public int setegid(int egid) { handler.unimplementedError("setegid"); return -1; } @Override public int geteuid() { return 0; } @Override public int seteuid(int euid) { handler.unimplementedError("seteuid"); return -1; } @Override public int getuid() { return 0; } @Override public int setuid(int uid) { handler.unimplementedError("setuid"); return -1; } @Override public int getgid() { handler.unimplementedError("getgid"); return -1; } @Override public int setgid(int gid) { handler.unimplementedError("setgid"); return -1; } @Override public int getpgid(int pid) { handler.unimplementedError("getpgid"); return -1; } @Override public int getpgid() { handler.unimplementedError("getpgid"); return -1; } @Override public int setpgid(int pid, int pgid) { handler.unimplementedError("setpgid"); return -1; } @Override public int getpriority(int which, int who) { handler.unimplementedError("getpriority"); return -1; } @Override public int setpriority(int which, int who, int prio) { handler.unimplementedError("setpriority"); return -1; } @Override public int getppid() { return 0; } @Override public int lchmod(String filename, int mode) { handler.unimplementedError("lchmod"); return -1; } @Override public int lchown(String filename, int user, int group) { handler.unimplementedError("lchown"); return -1; } @Override public FileStat lstat(String path) { return stat(path); } @Override public String readlink(String oldpath) { handler.unimplementedError("readlink"); return null; } @Override public int utimes(String path, long[] atimeval, long[] mtimeval) { UTimBuf64 times = null; if (atimeval != null && mtimeval != null) { times = new UTimBuf64(atimeval[0], mtimeval[0]); } return ((WindowsLibC)libc)._utime64(path, times); } @Override public int wait(int[] status) { handler.unimplementedError("wait"); return -1; } @Override public int waitpid(int pid, int[] status, int flags) { handler.unimplementedError("waitpid"); return -1; } @Override public String getlogin() { return helper.getlogin(); } @Override public int endgrent() { return 0; } @Override public int endpwent() { return helper.endpwent(); } @Override public Group getgrent() { return null; } @Override public Passwd getpwent() { return null; } @Override public Group getgrgid(int which) { return null; } @Override public Passwd getpwnam(String which) { return null; } @Override public Group getgrnam(String which) { return null; } @Override public int setgrent() { return 0; } @Override public int setpwent() { return helper.setpwent(); } @Override public Passwd getpwuid(int which) { return null; } @Override public boolean isatty(FileDescriptor fd) { int handle = (int)helper.gethandle(fd); int crtfd = ((WindowsLibC)libc)._open_osfhandle(handle, 0/*_O_RDONLY*/); return libc.isatty(crtfd) != 0; } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/POSIXFactory.java0000644000175000017500000000726611176403715024220 0ustar niconicopackage org.jruby.ext.posix; import com.sun.jna.Library; import java.util.HashMap; import org.jruby.ext.posix.util.Platform; import com.sun.jna.Native; import java.util.Map; public class POSIXFactory { static final String LIBC = Platform.IS_LINUX ? "libc.so.6" : "c"; static LibC libc = null; static final Map defaultOptions = new HashMap() {{ put(Library.OPTION_TYPE_MAPPER, POSIXTypeMapper.INSTANCE); }}; public static POSIX getPOSIX(POSIXHandler handler, boolean useNativePOSIX) { POSIX posix = null; if (useNativePOSIX) { try { if (Platform.IS_MAC) { posix = loadMacOSPOSIX(handler); } else if (Platform.IS_LINUX) { posix = loadLinuxPOSIX(handler); } else if (Platform.IS_FREEBSD) { posix = loadFreeBSDPOSIX(handler); } else if (Platform.IS_OPENBSD) { posix = loadOpenBSDPOSIX(handler); } else if (Platform.IS_32_BIT) {// No 64 bit structures defined yet. if (Platform.IS_WINDOWS) { posix = loadWindowsPOSIX(handler); } else if (Platform.IS_SOLARIS) { posix = loadSolarisPOSIX(handler); } } // ENEBO: Should printing be done through a handler+log method? if (handler.isVerbose()) { if (posix != null) { System.err.println("Successfully loaded native POSIX impl."); } else { System.err.println("Failed to load native POSIX impl; falling back on Java impl. Unsupported OS."); } } } catch (Throwable t) { if (handler.isVerbose()) { System.err.println("Failed to load native POSIX impl; falling back on Java impl. Stacktrace follows."); t.printStackTrace(); } } } if (posix == null) { posix = getJavaPOSIX(handler); } return posix; } public static POSIX getJavaPOSIX(POSIXHandler handler) { return new JavaPOSIX(handler); } public static POSIX loadLinuxPOSIX(POSIXHandler handler) { return new LinuxPOSIX(LIBC, loadLibC(LIBC, LinuxLibC.class, defaultOptions), handler); } public static POSIX loadMacOSPOSIX(POSIXHandler handler) { return new MacOSPOSIX(LIBC, loadLibC(LIBC, LibC.class, defaultOptions), handler); } public static POSIX loadSolarisPOSIX(POSIXHandler handler) { return new SolarisPOSIX(LIBC, loadLibC(LIBC, LibC.class, defaultOptions), handler); } public static POSIX loadFreeBSDPOSIX(POSIXHandler handler) { return new FreeBSDPOSIX(LIBC, loadLibC(LIBC, LibC.class, defaultOptions), handler); } public static POSIX loadOpenBSDPOSIX(POSIXHandler handler) { return new OpenBSDPOSIX(LIBC, loadLibC(LIBC, LibC.class, defaultOptions), handler); } public static POSIX loadWindowsPOSIX(POSIXHandler handler) { String name = "msvcrt"; Map options = new HashMap(); options.put(com.sun.jna.Library.OPTION_FUNCTION_MAPPER, new WindowsLibCFunctionMapper()); return new WindowsPOSIX(name, loadLibC(name, WindowsLibC.class, options), handler); } public static LibC loadLibC(String libraryName, Class libCClass, Map options) { if (libc != null) return libc; libc = (LibC) Native.loadLibrary(libraryName, libCClass, options); return libc; } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/SolarisLibC.java0000644000175000017500000000011411176403715024115 0ustar niconicopackage org.jruby.ext.posix; public interface SolarisLibC extends LibC { } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/Passwd.java0000644000175000017500000000056011176403715023215 0ustar niconicopackage org.jruby.ext.posix; public interface Passwd { public String getLoginName(); public String getPassword(); public long getUID(); public long getGID(); public int getPasswdChangeTime(); public String getAccessClass(); public String getGECOS(); public String getHome(); public String getShell(); public int getExpire(); } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/WindowsLibC.java0000644000175000017500000000027611176403715024144 0ustar niconicopackage org.jruby.ext.posix; public interface WindowsLibC extends LibC { public int _open_osfhandle(int handle, int flags); public int _utime64(String filename, UTimBuf64 times); } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/JavaPOSIX.java0000644000175000017500000001633211176403715023464 0ustar niconicopackage org.jruby.ext.posix; import java.io.BufferedReader; import java.io.File; import java.io.FileDescriptor; import java.io.IOException; import java.io.InputStreamReader; import java.nio.ByteBuffer; import java.nio.charset.Charset; import org.jruby.ext.posix.util.Platform; public class JavaPOSIX implements POSIX { POSIXHandler handler; JavaLibCHelper helper; public JavaPOSIX(POSIXHandler handler) { this.handler = handler; helper = new JavaLibCHelper(handler); } public FileStat allocateStat() { return new JavaFileStat(this, handler); } public int chmod(String filename, int mode) { return helper.chmod(filename, mode); } public int chown(String filename, int user, int group) { return helper.chown(filename, user, group); } public FileStat fstat(FileDescriptor descriptor) { handler.unimplementedError("fstat unimplemented"); return null; } public int getegid() { return GIDHolder.GID; } public int geteuid() { return UIDHolder.UID; } public int getgid() { return GIDHolder.GID; } public String getlogin() { return helper.getlogin(); } public int getpgid() { return unimplementedInt("getpgid"); } public int getpgrp() { return unimplementedInt("getpgrp"); } public int getpid() { return helper.getpid(); } public int getppid() { return unimplementedInt("getppid"); } public Passwd getpwent() { return helper.getpwent(); } public Passwd getpwuid(int which) { handler.unimplementedError("getpwuid unimplemented"); return null; } public Group getgrgid(int which) { handler.unimplementedError("getgrgid unimplemented"); return null; } public Passwd getpwnam(String which) { handler.unimplementedError("getpwnam unimplemented"); return null; } public Group getgrnam(String which) { handler.unimplementedError("getgrnam unimplemented"); return null; } public Group getgrent() { handler.unimplementedError("getgrent unimplemented"); return null; } public int setpwent() { return helper.setpwent(); } public int endpwent() { return helper.endpwent(); } public int setgrent() { return unimplementedInt("setgrent"); } public int endgrent() { return unimplementedInt("endgrent"); } public int getuid() { return UIDHolder.UID; } public int fork() { return -1; } public boolean isatty(FileDescriptor fd) { return (fd == FileDescriptor.in || fd == FileDescriptor.out || fd == FileDescriptor.err); } public int kill(int pid, int signal) { return unimplementedInt("kill"); // FIXME: Can be implemented } public int lchmod(String filename, int mode) { return unimplementedInt("lchmod"); // FIXME: Can be implemented } public int lchown(String filename, int user, int group) { return unimplementedInt("lchown"); // FIXME: Can be implemented } public int link(String oldpath, String newpath) { return helper.link(oldpath, newpath); } public FileStat lstat(String path) { FileStat stat = allocateStat(); if (helper.lstat(path, stat) < 0) handler.error(ERRORS.ENOENT, path); return stat; } public int mkdir(String path, int mode) { return helper.mkdir(path, mode); } public String readlink(String path) throws IOException { // TODO: this should not be hardcoded to 256 bytes ByteBuffer buffer = ByteBuffer.allocateDirect(256); int result = helper.readlink(path, buffer, buffer.capacity()); if (result == -1) return null; buffer.position(0); buffer.limit(result); return Charset.forName("ASCII").decode(buffer).toString(); } public FileStat stat(String path) { FileStat stat = allocateStat(); if (helper.stat(path, stat) < 0) handler.error(ERRORS.ENOENT, path); return stat; } public int symlink(String oldpath, String newpath) { return helper.symlink(oldpath, newpath); } public int setegid(int egid) { return unimplementedInt("setegid"); } public int seteuid(int euid) { return unimplementedInt("seteuid"); } public int setgid(int gid) { return unimplementedInt("setgid"); } public int getpgid(int pid) { return unimplementedInt("getpgid"); } public int setpgid(int pid, int pgid) { return unimplementedInt("setpgid"); } public int setpgrp(int pid, int pgrp) { return unimplementedInt("setpgrp"); } public int setsid() { return unimplementedInt("setsid"); } public int setuid(int uid) { return unimplementedInt("setuid"); } public int umask(int mask) { // TODO: We can possibly maintain an internal mask and try and apply it to individual // libc methods. return 0; } public int utimes(String path, long[] atimeval, long[] mtimeval) { long mtimeMillis; if (mtimeval != null) { assert mtimeval.length == 2; mtimeMillis = (mtimeval[0] * 1000) + (mtimeval[1] / 1000); } else { mtimeMillis = System.currentTimeMillis(); } new File(path).setLastModified(mtimeMillis); return 0; } public int wait(int[] status) { return unimplementedInt("wait"); } public int waitpid(int pid, int[] status, int flags) { return unimplementedInt("waitpid"); } public int getpriority(int which, int who) { return unimplementedInt("getpriority"); } public int setpriority(int which, int who, int prio) { return unimplementedInt("setpriority"); } public int errno() { return 0; } public void errno(int value) { // do nothing, errno is unsupported } private int unimplementedInt(String message) { handler.unimplementedError(message); return -1; } private static final class UIDHolder { public static final int UID = IDHelper.getID("-u"); } private static final class GIDHolder { public static final int GID = IDHelper.getID("-g"); } private static final class IDHelper { private static final String ID_CMD = Platform.IS_SOLARIS ? "/usr/xpg4/bin/id" : "/usr/bin/id"; private static final int NOBODY = Platform.IS_WINDOWS ? 0 : Short.MAX_VALUE; public static int getID(String option) { try { Process p = Runtime.getRuntime().exec(new String[] { ID_CMD, option }); BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream())); return Integer.parseInt(r.readLine()); } catch (IOException ex) { return NOBODY; } catch (NumberFormatException ex) { return NOBODY; } catch (SecurityException ex) { return NOBODY; } } } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/Group.java0000644000175000017500000000026311176403715023050 0ustar niconicopackage org.jruby.ext.posix; public interface Group { public String getName(); public String getPassword(); public long getGID(); public String[] getMembers(); } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/NativeGroup.java0000644000175000017500000000020611176403715024214 0ustar niconicopackage org.jruby.ext.posix; import com.sun.jna.Structure; public abstract class NativeGroup extends Structure implements Group { } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/Linux64FileStat.java0000644000175000017500000000317211176403715024663 0ustar niconicopackage org.jruby.ext.posix; public class Linux64FileStat extends BaseNativeFileStat { public long st_dev; public long st_ino; public long st_nlink; public int st_mode; public int st_uid; public int st_gid; public long st_rdev; public long st_size; public long st_blksize; public long st_blocks; public long st_atime; // Time of last access (time_t) public long st_atimensec; // Time of last access (nanoseconds) public long st_mtime; // Last data modification time (time_t) public long st_mtimensec; // Last data modification time (nanoseconds) public long st_ctime; // Time of last status change (time_t) public long st_ctimensec; // Time of last status change (nanoseconds) public long __unused4; public long __unused5; public long __unused6; public Linux64FileStat(POSIX posix) { super(posix); } public long atime() { return st_atime; } public long blockSize() { return st_blksize; } public long blocks() { return st_blocks; } public long ctime() { return st_ctime; } public long dev() { return st_dev; } public int gid() { return st_gid; } public long ino() { return st_ino; } public int mode() { return st_mode; } public long mtime() { return st_mtime; } public int nlink() { return (int) st_nlink; } public long rdev() { return st_rdev; } public long st_size() { return st_size; } public int uid() { return st_uid; } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/JavaFileStat.java0000644000175000017500000002007011176403715024267 0ustar niconicopackage org.jruby.ext.posix; import java.io.File; import java.io.IOException; import org.jruby.ext.posix.POSIXHandler.WARNING_ID; public class JavaFileStat implements FileStat { private POSIXHandler handler; short st_mode; int st_blksize; long st_size; int st_ctime; int st_mtime; POSIX posix; public JavaFileStat(POSIX posix, POSIXHandler handler) { this.handler = handler; this.posix = posix; } public void setup(String path) { // ENEBO: This was originally JRubyFile, but I believe we use JRuby file for normalization // of paths. So we should be safe. File file = new JavaSecuredFile(path); // Limitation: We cannot determine, so always return 4096 (better than blowing up) st_blksize = 4096; st_mode = calculateMode(file, st_mode); st_size = file.length(); // Parent file last modified will only represent when something was added or removed. // This is not correct, but it is better than nothing and does work in one common use // case. st_mtime = (int) (file.lastModified() / 1000); if (file.getParentFile() != null) { st_ctime = (int) (file.getParentFile().lastModified() / 1000); } else { st_ctime = st_mtime; } } private short calculateMode(File file, short st_mode) { // implementation to lowest common denominator... // Windows has no file mode, but C ruby returns either 0100444 or 0100666 if (file.canRead()) st_mode |= ALL_READ; if (file.canWrite()) st_mode |= ALL_WRITE; if (file.isDirectory()) { st_mode |= S_IFDIR; } else if (file.isFile()) { st_mode |= S_IFREG; } try { st_mode = calculateSymlink(file, st_mode); } catch (IOException e) { // Not sure we can do much in this case... } return st_mode; } private short calculateSymlink(File file, short st_mode) throws IOException { if (file.getAbsoluteFile().getParentFile() == null) { return st_mode; } File absoluteParent = file.getAbsoluteFile().getParentFile(); File canonicalParent = absoluteParent.getCanonicalFile(); if (canonicalParent.getAbsolutePath().equals(absoluteParent.getAbsolutePath())) { // parent doesn't change when canonicalized, compare absolute and canonical file directly if (!file.getAbsolutePath().equalsIgnoreCase(file.getCanonicalPath())) { st_mode |= S_IFLNK; return st_mode; } } // directory itself has symlinks (canonical != absolute), so build new path with canonical parent and compare file = new JavaSecuredFile(canonicalParent.getAbsolutePath() + "/" + file.getName()); if (!file.getAbsolutePath().equalsIgnoreCase(file.getCanonicalPath())) { st_mode |= S_IFLNK; } return st_mode; } /** * Limitation: Java has no access time support, so we return mtime as the next best thing. */ public long atime() { return st_mtime; } public long blocks() { handler.unimplementedError("stat.st_blocks"); return -1; } public long blockSize() { return st_blksize; } public long ctime() { return st_ctime; } public long dev() { handler.unimplementedError("stat.st_dev"); return -1; } public String ftype() { if (isFile()) { return "file"; } else if (isDirectory()) { return "directory"; } return "unknown"; } public int gid() { handler.unimplementedError("stat.st_gid"); return -1; } public boolean groupMember(int gid) { return posix.getgid() == gid || posix.getegid() == gid; } /** * Limitation: We have no pure-java way of getting inode. webrick needs this defined to work. */ public long ino() { return 0; } public boolean isBlockDev() { handler.unimplementedError("block device detection"); return false; } /** * Limitation: [see JRUBY-1516] We just pick more likely value. This is a little scary. */ public boolean isCharDev() { return false; } public boolean isDirectory() { return (mode() & S_IFDIR) != 0; } public boolean isEmpty() { return st_size() == 0; } // At least one major library depends on this method existing. public boolean isExecutable() { handler.warn(WARNING_ID.DUMMY_VALUE_USED, "executable? does not in this environment and will return a dummy value", "executable"); return true; } // At least one major library depends on this method existing. public boolean isExecutableReal() { handler.warn(WARNING_ID.DUMMY_VALUE_USED, "executable_real? does not work in this environmnt and will return a dummy value", "executable_real"); return true; } public boolean isFifo() { handler.unimplementedError("fifo file detection"); return false; } public boolean isFile() { return (mode() & S_IFREG) != 0; } public boolean isGroupOwned() { return groupMember(gid()); } public boolean isIdentical(FileStat other) { handler.unimplementedError("identical file detection"); return false; } public boolean isNamedPipe() { handler.unimplementedError("piped file detection"); return false; } public boolean isOwned() { return posix.geteuid() == uid(); } public boolean isROwned() { return posix.getuid() == uid(); } public boolean isReadable() { int mode = mode(); if ((mode & S_IRUSR) != 0) return true; if ((mode & S_IRGRP) != 0) return true; if ((mode & S_IROTH) != 0) return true; return false; } // We do both readable and readable_real through the same method because public boolean isReadableReal() { return isReadable(); } public boolean isSymlink() { return (mode() & S_IFLNK) == S_IFLNK; } public boolean isWritable() { int mode = mode(); if ((mode & S_IWUSR) != 0) return true; if ((mode & S_IWGRP) != 0) return true; if ((mode & S_IWOTH) != 0) return true; return false; } // We do both readable and readable_real through the same method because // in our java process effective and real userid will always be the same. public boolean isWritableReal() { return isWritable(); } public boolean isSetgid() { handler.unimplementedError("setgid detection"); return false; } public boolean isSetuid() { handler.unimplementedError("setuid detection"); return false; } public boolean isSocket() { handler.unimplementedError("socket file type detection"); return false; } public boolean isSticky() { handler.unimplementedError("sticky bit detection"); return false; } public int major(long dev) { handler.unimplementedError("major device"); return -1; } public int minor(long dev) { handler.unimplementedError("minor device"); return -1; } public int mode() { return st_mode & 0xffff; } public long mtime() { return st_mtime; } public int nlink() { handler.unimplementedError("stat.nlink"); return -1; } public long rdev() { handler.unimplementedError("stat.rdev"); return -1; } public long st_size() { return st_size; } // Limitation: We have no pure-java way of getting uid. RubyZip needs this defined to work. public int uid() { return -1; } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/SolarisHeapFileStat.java0000644000175000017500000000516711176403715025632 0ustar niconico/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package org.jruby.ext.posix; /** * * @author enebo */ public class SolarisHeapFileStat extends BaseHeapFileStat { public final Int32 st_dev = new Int32(); public final Int32 st_pad1_0 = new Int32(); public final Int32 st_pad1_1 = new Int32(); public final Int32 st_pad1_2 = new Int32(); public final Int64 st_ino = new Int64(); public final Int32 st_mode = new Int32(); public final Int32 st_nlink = new Int32(); public final Int32 st_uid = new Int32(); public final Int32 st_gid = new Int32(); public final Int64 st_rdev = new Int64(); public final Int32 st_pad2_0 = new Int32(); public final Int64 st_size = new Int64(); public final Int32 st_atim_sec = new Int32(); public final Int32 st_atim_nsec = new Int32(); public final Int32 st_mtim_sec = new Int32(); public final Int32 st_mtim_nsec = new Int32(); public final Int32 st_ctim_sec = new Int32(); public final Int32 st_ctim_nsec = new Int32(); public final Int32 st_blksize = new Int32(); public final Int64 st_blocks = new Int64(); public final Int32 st_pad7 = new Int32(); public final Int32 st_pad8 = new Int32(); public final Int32 st_pad9 = new Int32(); public final Int32 st_pad4_0 = new Int32(); public final Int32 st_pad4_1 = new Int32(); public final Int32 st_pad4_2 = new Int32(); public final Int32 st_pad4_3 = new Int32(); public final Int32 st_pad4_4 = new Int32(); public final Int32 st_pad4_5 = new Int32(); public final Int32 st_pad4_6 = new Int32(); public final Int32 st_pad4_7 = new Int32(); public SolarisHeapFileStat() { this(null); } public SolarisHeapFileStat(POSIX posix) { super(posix); } public long atime() { return st_atim_sec.get(); } public long blocks() { return st_blocks.get(); } public long blockSize() { return st_blksize.get(); } public long ctime() { return st_ctim_sec.get(); } public long dev() { return st_dev.get(); } public int gid() { return st_gid.get(); } public long ino() { return st_ino.get(); } public int mode() { return st_mode.get() & 0xffff; } public long mtime() { return st_mtim_sec.get(); } public int nlink() { return st_nlink.get(); } public long rdev() { return st_rdev.get(); } public long st_size() { return st_size.get(); } public int uid() { return st_uid.get(); } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/LibC.java0000644000175000017500000000712611176403715022572 0ustar niconico/* **** BEGIN LICENSE BLOCK ***** * Version: CPL 1.0/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Common 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.eclipse.org/legal/cpl-v10.html * * 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. * * Copyright (C) 2007 Thomas E Enebo * Copyright (C) 2007 Charles O Nutter * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the CPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the CPL, the GPL or the LGPL. ***** END LICENSE BLOCK *****/ package org.jruby.ext.posix; import com.sun.jna.Library; import java.nio.ByteBuffer; public interface LibC extends Library { public int chmod(String filename, int mode); public int chown(String filename, int user, int group); public int fstat(int fd, FileStat stat); public int fstat64(int fd, FileStat stat); public int getegid(); public int setegid(int egid); public int geteuid(); public int seteuid(int euid); public int getgid(); public String getlogin(); public int setgid(int gid); public int getpgid(); public int getpgid(int pid); public int setpgid(int pid, int pgid); public int getpgrp(); public int setpgrp(int pid, int pgrp); public int getppid(); public int getpid(); public NativePasswd getpwent(); public NativePasswd getpwuid(int which); public NativePasswd getpwnam(String which); public NativeGroup getgrent(); public NativeGroup getgrgid(int which); public NativeGroup getgrnam(String which); public int setpwent(); public int endpwent(); public int setgrent(); public int endgrent(); public int getuid(); public int setsid(); public int setuid(int uid); public int kill(int pid, int signal); public int lchmod(String filename, int mode); public int lchown(String filename, int user, int group); public int link(String oldpath,String newpath); public int lstat(String path, FileStat stat); public int lstat64(String path, FileStat stat); public int mkdir(String path, int mode); public int stat(String path, FileStat stat); public int stat64(String path, FileStat stat); public int symlink(String oldpath,String newpath); public int readlink(String oldpath,ByteBuffer buffer,int len); public int umask(int mask); public int utimes(String path, Timeval[] times); public int fork(); public int waitpid(int pid, int[] status, int options); public int wait(int[] status); public int getpriority(int which, int who); public int setpriority(int which, int who, int prio); public int isatty(int fd); } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/OpenBSDPasswd.java0000644000175000017500000000543011176403715024371 0ustar niconico/***** BEGIN LICENSE BLOCK ***** * Version: CPL 1.0/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Common 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.eclipse.org/legal/cpl-v10.html * * 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 contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the CPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the CPL, the GPL or the LGPL. ***** END LICENSE BLOCK *****/ /** * $Id: $ */ package org.jruby.ext.posix; import com.sun.jna.NativeLong; import com.sun.jna.Pointer; public class OpenBSDPasswd extends NativePasswd implements Passwd { public String pw_name; // user name public String pw_passwd; // password (encrypted) public int pw_uid; // user id public int pw_gid; // user id public NativeLong pw_change; // password change time public String pw_class; // user access class public String pw_gecos; // login info public String pw_dir; // home directory public String pw_shell; // default shell public NativeLong pw_expire; // account expiration OpenBSDPasswd(Pointer memory) { useMemory(memory); read(); } public String getAccessClass() { return pw_class; } public String getGECOS() { return pw_gecos; } public long getGID() { return pw_gid; } public String getHome() { return pw_dir; } public String getLoginName() { return pw_name; } public int getPasswdChangeTime() { return pw_change.intValue(); } public String getPassword() { return pw_passwd; } public String getShell() { return pw_shell; } public long getUID() { return pw_uid; } public int getExpire() { return pw_expire.intValue(); } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/JavaPasswd.java0000644000175000017500000000264711176403715024027 0ustar niconicopackage org.jruby.ext.posix; public class JavaPasswd implements Passwd { private POSIXHandler handler; public JavaPasswd(POSIXHandler handler) { this.handler = handler; } public String getAccessClass() { handler.unimplementedError("passwd.pw_access unimplemented"); return null; } public String getGECOS() { handler.unimplementedError("passwd.pw_gecos unimplemented"); return null; } public long getGID() { handler.unimplementedError("passwd.pw_gid unimplemented"); return -1; } public String getHome() { return System.getProperty("user.home"); } public String getLoginName() { return System.getProperty("user.name"); } public int getPasswdChangeTime() { handler.unimplementedError("passwd.pw_change unimplemented"); return 0; } public String getPassword() { handler.unimplementedError("passwd.pw_passwd unimplemented"); return null; } public String getShell() { handler.unimplementedError("passwd.pw_env unimplemented"); return null; } public long getUID() { handler.unimplementedError("passwd.pw_uid unimplemented"); return -1; } public int getExpire() { handler.unimplementedError("passwd.expire unimplemented"); return -1; } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/MacOSPOSIX.java0000644000175000017500000000223311176403715023540 0ustar niconicopackage org.jruby.ext.posix; import com.sun.jna.FromNativeContext; import com.sun.jna.Pointer; public final class MacOSPOSIX extends BaseNativePOSIX { private final boolean hasLchmod; private final boolean hasLchown; public MacOSPOSIX(String libraryName, LibC libc, POSIXHandler handler) { super(libraryName, libc, handler); hasLchmod = hasMethod("lchmod"); hasLchown = hasMethod("lchown"); } public FileStat allocateStat() { return new MacOSHeapFileStat(this); } @Override public int lchmod(String filename, int mode) { if (!hasLchmod) handler.unimplementedError("lchmod"); return libc.lchmod(filename, mode); } @Override public int lchown(String filename, int user, int group) { if (!hasLchown) handler.unimplementedError("lchown"); return super.lchown(filename, user, group); } public static final PointerConverter PASSWD = new PointerConverter() { public Object fromNative(Object arg, FromNativeContext ctx) { return arg != null ? new MacOSPasswd((Pointer) arg) : null; } }; } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/UTimBuf64.java0000644000175000017500000000042211176403715023436 0ustar niconicopackage org.jruby.ext.posix; import com.sun.jna.Structure; public class UTimBuf64 extends Structure { public long actime; public long modtime; public UTimBuf64(long actime, long modtime) { this.actime = actime; this.modtime = modtime; } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/NativeTimeval.java0000644000175000017500000000021211176403715024516 0ustar niconicopackage org.jruby.ext.posix; import com.sun.jna.Structure; public abstract class NativeTimeval extends Structure implements Timeval { } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/Linux64HeapFileStat.java0000644000175000017500000000424011176403715025456 0ustar niconicopackage org.jruby.ext.posix; public final class Linux64HeapFileStat extends BaseHeapFileStat { public final Int64 st_dev = new Int64(); public final Int64 st_ino = new Int64(); public final Int64 st_nlink = new Int64(); public final Int32 st_mode = new Int32(); public final Int32 st_uid = new Int32(); public final Int32 st_gid = new Int32(); public final Int64 st_rdev = new Int64(); public final Int64 st_size = new Int64(); public final Int64 st_blksize = new Int64(); public final Int64 st_blocks = new Int64(); public final Int64 st_atime = new Int64(); // Time of last access (time_t) public final Int64 st_atimensec = new Int64(); // Time of last access (nanoseconds) public final Int64 st_mtime = new Int64(); // Last data modification time (time_t) public final Int64 st_mtimensec = new Int64(); // Last data modification time (nanoseconds) public final Int64 st_ctime = new Int64(); // Time of last status change (time_t) public final Int64 st_ctimensec = new Int64(); // Time of last status change (nanoseconds) public final Int64 __unused4 = new Int64(); public final Int64 __unused5 = new Int64(); public final Int64 __unused6 = new Int64(); public Linux64HeapFileStat() { super(null); } public Linux64HeapFileStat(POSIX posix) { super(posix); } public long atime() { return st_atime.get(); } public long blockSize() { return st_blksize.get(); } public long blocks() { return st_blocks.get(); } public long ctime() { return st_ctime.get(); } public long dev() { return st_dev.get(); } public int gid() { return st_gid.get(); } public long ino() { return st_ino.get(); } public int mode() { return st_mode.get(); } public long mtime() { return st_mtime.get(); } public int nlink() { return (int) st_nlink.get(); } public long rdev() { return st_rdev.get(); } public long st_size() { return st_size.get(); } public int uid() { return st_uid.get(); } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/LinuxPOSIX.java0000644000175000017500000000564611176403715023710 0ustar niconicopackage org.jruby.ext.posix; import com.sun.jna.FromNativeContext; import com.sun.jna.Pointer; import java.io.FileDescriptor; import org.jruby.ext.posix.util.Platform; public final class LinuxPOSIX extends BaseNativePOSIX { private final boolean hasFxstat; private final boolean hasLxstat; private final boolean hasXstat; private final boolean hasFstat; private final boolean hasLstat; private final boolean hasStat; private final int statVersion; public LinuxPOSIX(String libraryName, LibC libc, POSIXHandler handler) { super(libraryName, libc, handler); statVersion = Platform.IS_32_BIT ? 3 : 0; /* * Most linux systems define stat/lstat/fstat as macros which force * us to call these weird signature versions. */ hasFxstat = hasMethod("__fxstat64"); hasLxstat = hasMethod("__lxstat64"); hasXstat = hasMethod("__xstat64"); /* * At least one person is using uLibc on linux which has real * definitions for stat/lstat/fstat. */ hasFstat = !hasFxstat && hasMethod("fstat64"); hasLstat = !hasLxstat && hasMethod("lstat64"); hasStat = !hasXstat && hasMethod("stat64"); } @Override public FileStat allocateStat() { if (Platform.IS_32_BIT) { return new LinuxHeapFileStat(this); } else { return new Linux64HeapFileStat(this); } } @Override public FileStat fstat(FileDescriptor fileDescriptor) { if (!hasFxstat) { if (hasFstat) return super.fstat(fileDescriptor); handler.unimplementedError("fstat"); } FileStat stat = allocateStat(); int fd = helper.getfd(fileDescriptor); if (((LinuxLibC) libc).__fxstat64(statVersion, fd, stat) < 0) handler.error(ERRORS.ENOENT, "" + fd); return stat; } @Override public FileStat lstat(String path) { if (!hasLxstat) { if (hasLstat) return super.lstat(path); handler.unimplementedError("lstat"); } FileStat stat = allocateStat(); if (((LinuxLibC) libc).__lxstat64(statVersion, path, stat) < 0) handler.error(ERRORS.ENOENT, path); return stat; } @Override public FileStat stat(String path) { if (!hasXstat) { if (hasStat) return super.stat(path); handler.unimplementedError("stat"); } FileStat stat = allocateStat(); if (((LinuxLibC) libc).__xstat64(statVersion, path, stat) < 0) handler.error(ERRORS.ENOENT, path); return stat; } public static final PointerConverter PASSWD = new PointerConverter() { public Object fromNative(Object arg, FromNativeContext ctx) { return arg != null ? new LinuxPasswd((Pointer) arg) : null; } }; } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/JavaSecuredFile.java0000644000175000017500000001536211176403715024756 0ustar niconico/***** BEGIN LICENSE BLOCK ***** * Version: CPL 1.0/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Common 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.eclipse.org/legal/cpl-v10.html * * 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. * * Copyright (C) 2008 Google Inc. All Rights Reserved. * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the CPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the CPL, the GPL or the LGPL. ***** END LICENSE BLOCK *****/ package org.jruby.ext.posix; import java.io.File; import java.io.FileFilter; import java.io.FilenameFilter; import java.io.IOException; import java.net.URI; /** *

This file catches any SecurityExceptions raised when access * to a file is denied and responds as if the file didn't exist * instead.

* */ public class JavaSecuredFile extends File { public JavaSecuredFile(File parent, String child) { super(parent, child); } public JavaSecuredFile(String pathname) { super(pathname); } public JavaSecuredFile(String parent, String child) { super(parent, child); } public JavaSecuredFile(URI uri) { super(uri); } @Override public File getParentFile() { String parent = getParent(); if (parent != null) { return new JavaSecuredFile(parent); } else { return null; } } @Override public File getAbsoluteFile() { String absolute = getAbsolutePath(); if (absolute != null) { return new JavaSecuredFile(absolute); } else { return null; } } @Override public String getCanonicalPath() throws IOException { try { return super.getCanonicalPath(); } catch (SecurityException ex) { throw new IOException(ex.getMessage()); } } @Override public File getCanonicalFile() throws IOException { String canonical = getCanonicalPath(); if (canonical != null) { return new JavaSecuredFile(canonical); } else { return null; } } @Override public boolean canRead() { try { return super.canRead(); } catch (SecurityException ex) { return false; } } @Override public boolean canWrite() { try { return super.canWrite(); } catch (SecurityException ex) { return false; } } @Override public boolean exists() { try { return super.exists(); } catch (SecurityException ex) { return false; } } @Override public boolean isDirectory() { try { return super.isDirectory(); } catch (SecurityException ex) { return false; } } @Override public boolean isFile() { try { return super.isFile(); } catch (SecurityException ex) { return false; } } @Override public boolean isHidden() { try { return super.isHidden(); } catch (SecurityException ex) { return false; } } @Override public long lastModified() { try { return super.lastModified(); } catch (SecurityException ex) { return 0L; } } @Override public long length() { try { return super.length(); } catch (SecurityException ex) { return 0L; } } @Override public boolean createNewFile() throws IOException { try { return super.createNewFile(); } catch (SecurityException ex) { throw new IOException(ex.getMessage()); } } @Override public boolean delete() { try { return super.delete(); } catch (SecurityException ex) { return false; } } @Override public String[] list() { try { return super.list(); } catch (SecurityException ex) { return null; } } @Override public String[] list(FilenameFilter filter) { try { return super.list(filter); } catch (SecurityException ex) { return null; } } @Override public File[] listFiles() { try { return super.listFiles(); } catch (SecurityException ex) { return null; } } @Override public File[] listFiles(FilenameFilter filter) { try { return super.listFiles(filter); } catch (SecurityException ex) { return null; } } @Override public File[] listFiles(FileFilter filter) { try { return super.listFiles(filter); } catch (SecurityException ex) { return null; } } @Override public boolean mkdir() { try { return super.mkdir(); } catch (SecurityException ex) { return false; } } @Override public boolean mkdirs() { try { return super.mkdirs(); } catch (SecurityException ex) { return false; } } @Override public boolean renameTo(File dest) { try { return super.renameTo(dest); } catch (SecurityException ex) { return false; } } @Override public boolean setLastModified(long time) { try { return super.setLastModified(time); } catch (SecurityException ex) { return false; } } @Override public boolean setReadOnly() { try { return super.setReadOnly(); } catch (SecurityException ex) { return false; } } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/MacOSPasswd.java0000644000175000017500000000264211176403715024103 0ustar niconico package org.jruby.ext.posix; import com.sun.jna.NativeLong; import com.sun.jna.Pointer; /** * */ public final class MacOSPasswd extends NativePasswd implements Passwd { public String pw_name; // user name public String pw_passwd; // password (encrypted) public int pw_uid; // user id public int pw_gid; // user id public NativeLong pw_change; // password change time public String pw_class; // user access class public String pw_gecos; // login info public String pw_dir; // home directory public String pw_shell; // default shell public NativeLong pw_expire; // account expiration MacOSPasswd(Pointer memory) { useMemory(memory); read(); } public String getAccessClass() { return pw_class; } public String getGECOS() { return pw_gecos; } public long getGID() { return pw_gid; } public String getHome() { return pw_dir; } public String getLoginName() { return pw_name; } public int getPasswdChangeTime() { return pw_change.intValue(); } public String getPassword() { return pw_passwd; } public String getShell() { return pw_shell; } public long getUID() { return pw_uid; } public int getExpire() { return pw_expire.intValue(); } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/BaseNativeFileStat.java0000644000175000017500000001004111176403715025424 0ustar niconicopackage org.jruby.ext.posix; import com.sun.jna.Structure; public abstract class BaseNativeFileStat extends Structure implements FileStat { protected POSIX posix; public BaseNativeFileStat(POSIX posix) { super(); this.posix = posix; } public String ftype() { if (isFile()) { return "file"; } else if (isDirectory()) { return "directory"; } else if (isCharDev()) { return "characterSpecial"; } else if (isBlockDev()) { return "blockSpecial"; } else if (isFifo()) { return "fifo"; } else if (isSymlink()) { return "link"; } else if (isSocket()) { return "socket"; } return "unknown"; } public boolean groupMember(int gid) { if (posix.getgid() == gid || posix.getegid() == gid) { return true; } // FIXME: Though not Posix, windows has different mechanism for this. return false; } public boolean isBlockDev() { return (mode() & S_IFMT) == S_IFBLK; } public boolean isCharDev() { return (mode() & S_IFMT) == S_IFCHR; } public boolean isDirectory() { return (mode() & S_IFMT) == S_IFDIR; } public boolean isEmpty() { return st_size() == 0; } public boolean isExecutable() { if (posix.geteuid() == 0) return (mode() & S_IXUGO) != 0; if (isOwned()) return (mode() & S_IXUSR) != 0; if (isGroupOwned()) return (mode() & S_IXGRP) != 0; return (mode() & S_IXOTH) != 0; } public boolean isExecutableReal() { if (posix.getuid() == 0) return (mode() & S_IXUGO) != 0; if (isROwned()) return (mode() & S_IXUSR) != 0; if (groupMember(gid())) return (mode() & S_IXGRP) != 0; return (mode() & S_IXOTH) != 0; } public boolean isFile() { return (mode() & S_IFMT) == S_IFREG; } public boolean isFifo() { return (mode() & S_IFMT) == S_IFIFO; } public boolean isGroupOwned() { return groupMember(gid()); } public boolean isIdentical(FileStat other) { return dev() == other.dev() && ino() == other.ino(); } public boolean isNamedPipe() { return (mode() & S_IFIFO) != 0; } public boolean isOwned() { return posix.geteuid() == uid(); } public boolean isROwned() { return posix.getuid() == uid(); } public boolean isReadable() { if (posix.geteuid() == 0) return true; if (isOwned()) return (mode() & S_IRUSR) != 0; if (isGroupOwned()) return (mode() & S_IRGRP) != 0; return (mode() & S_IROTH) != 0; } public boolean isReadableReal() { if (posix.getuid() == 0) return true; if (isROwned()) return (mode() & S_IRUSR) != 0; if (groupMember(gid())) return (mode() & S_IRGRP) != 0; return (mode() & S_IROTH) != 0; } public boolean isSetgid() { return (mode() & S_ISGID) != 0; } public boolean isSetuid() { return (mode() & S_ISUID) != 0; } public boolean isSocket() { return (mode() & S_IFMT) == S_IFSOCK; } public boolean isSticky() { return (mode() & S_ISVTX) != 0; } public boolean isSymlink() { return (mode() & S_IFMT) == S_IFLNK; } public boolean isWritable() { if (posix.geteuid() == 0) return true; if (isOwned()) return (mode() & S_IWUSR) != 0; if (isGroupOwned()) return (mode() & S_IWGRP) != 0; return (mode() & S_IWOTH) != 0; } public boolean isWritableReal() { if (posix.getuid() == 0) return true; if (isROwned()) return (mode() & S_IWUSR) != 0; if (groupMember(gid())) return (mode() & S_IWGRP) != 0; return (mode() & S_IWOTH) != 0; } public int major(long dev) { return (int) (dev >> 24) & 0xff; } public int minor(long dev) { return (int) (dev & 0xffffff); } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/SolarisPOSIX.java0000644000175000017500000000273711176403715024223 0ustar niconicopackage org.jruby.ext.posix; import com.sun.jna.FromNativeContext; import com.sun.jna.Pointer; import java.io.FileDescriptor; public class SolarisPOSIX extends BaseNativePOSIX { public SolarisPOSIX(String libraryName, LibC libc, POSIXHandler handler) { super(libraryName, libc, handler); } public FileStat allocateStat() { return new SolarisHeapFileStat(this); } @Override public FileStat fstat(FileDescriptor fileDescriptor) { FileStat stat = allocateStat(); int fd = helper.getfd(fileDescriptor); if (libc.fstat64(fd, stat) < 0) handler.error(ERRORS.ENOENT, ""+fd); return stat; } @Override public int lchmod(String filename, int mode) { handler.unimplementedError("lchmod"); return -1; } @Override public FileStat lstat(String path) { FileStat stat = allocateStat(); if (libc.lstat64(path, stat) < 0) handler.error(ERRORS.ENOENT, path); return stat; } @Override public FileStat stat(String path) { FileStat stat = allocateStat(); if (libc.stat64(path, stat) < 0) handler.error(ERRORS.ENOENT, path); return stat; } public static final PointerConverter PASSWD = new PointerConverter() { public Object fromNative(Object arg, FromNativeContext ctx) { return arg != null ? new SolarisPasswd((Pointer) arg) : null; } }; } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/LinuxFileStat.java0000644000175000017500000000316511176403715024513 0ustar niconicopackage org.jruby.ext.posix; public class LinuxFileStat extends BaseNativeFileStat { public long st_dev; public short __pad1; public int st_ino; public int st_mode; public int st_nlink; public int st_uid; public int st_gid; public long st_rdev; public short __pad2; public int st_size; public int st_blksize; public int st_blocks; public int st_atime; // Time of last access (time_t) public int st_atimensec; // Time of last access (nanoseconds) public int st_mtime; // Last data modification time (time_t) public int st_mtimensec; // Last data modification time (nanoseconds) public int st_ctime; // Time of last status change (time_t) public int st_ctimensec; // Time of last status change (nanoseconds) public int __unused4; public int __unused5; public LinuxFileStat(POSIX posix) { super(posix); } public long atime() { return st_atime; } public long blockSize() { return st_blksize; } public long blocks() { return st_blocks; } public long ctime() { return st_ctime; } public long dev() { return st_dev; } public int gid() { return st_gid; } public long ino() { return st_ino; } public int mode() { return st_mode; } public long mtime() { return st_mtime; } public int nlink() { return st_nlink; } public long rdev() { return st_rdev; } public long st_size() { return st_size; } public int uid() { return st_uid; } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/LinuxLibC.java0000644000175000017500000000072011176403715023603 0ustar niconicopackage org.jruby.ext.posix; public interface LinuxLibC extends LibC { public int __fxstat(int version, int fd, FileStat stat); public int __lxstat(int version, String path, FileStat stat); public int __xstat(int version, String path, FileStat stat); public int __fxstat64(int version, int fd, FileStat stat); public int __lxstat64(int version, String path, FileStat stat); public int __xstat64(int version, String path, FileStat stat); } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/JavaLibCHelper.java0000644000175000017500000001543511176403715024536 0ustar niconico /* **** BEGIN LICENSE BLOCK ***** * Version: CPL 1.0/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Common 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.eclipse.org/legal/cpl-v10.html * * 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. * * Copyright (C) 2007 * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the CPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the CPL, the GPL or the LGPL. ***** END LICENSE BLOCK *****/ package org.jruby.ext.posix; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileDescriptor; import java.io.IOException; import java.lang.reflect.Field; import java.nio.ByteBuffer; import org.jruby.ext.posix.POSIX.ERRORS; import org.jruby.ext.posix.util.Chmod; import org.jruby.ext.posix.util.ExecIt; import org.jruby.ext.posix.util.FieldAccess; /** * This libc implementation is created one per runtime instance versus the others which * are expected to be one static instance for whole JVM. Because of this it is no big * deal to make reference to a POSIXHandler directly. */ // FIXME: we ignore all exceptions with shell launcher...should we do something better public class JavaLibCHelper { public static final int STDIN = 0; public static final int STDOUT = 1; public static final int STDERR = 2; POSIXHandler handler; Field fdField, handleField; public JavaLibCHelper(POSIXHandler handler) { this.handler = handler; this.handleField = FieldAccess.getProtectedField(FileDescriptor.class, "handle"); this.fdField = FieldAccess.getProtectedField(FileDescriptor.class, "fd"); } public int chmod(String filename, int mode) { return Chmod.chmod(new JavaSecuredFile(filename), Integer.toOctalString(mode)); } public int chown(String filename, int user, int group) { ExecIt launcher = new ExecIt(handler); int chownResult = -1; int chgrpResult = -1; try { if (user != -1) chownResult = launcher.runAndWait("chown", ""+user, filename); if (group != -1) chgrpResult = launcher.runAndWait("chgrp ", ""+user, filename); } catch (Exception e) {} return chownResult != -1 && chgrpResult != -1 ? 0 : 1; } public int getfd(FileDescriptor descriptor) { if (descriptor == null || fdField == null) return -1; try { return fdField.getInt(descriptor); } catch (SecurityException e) { } catch (IllegalArgumentException e) { } catch (IllegalAccessException e) { } return -1; } public long gethandle(FileDescriptor descriptor) { if (descriptor == null || handleField == null) return -1; try { return handleField.getLong(descriptor); } catch (SecurityException e) { } catch (IllegalArgumentException e) { } catch (IllegalAccessException e) { } return -1; } public String getlogin() { return System.getProperty("user.name"); } public int getpid() { return handler.getPID(); } public Passwd getpwent() { return new JavaPasswd(handler); } public int setpwent() { return 0; } public int endpwent() { return 0; } public int isatty(int fd) { return (fd == STDOUT || fd == STDIN || fd == STDERR) ? 1 : 0; } public int link(String oldpath, String newpath) { try { return new ExecIt(handler).runAndWait("ln", oldpath, newpath); } catch (Exception e) {} return -1; // We tried and failed for some reason. Indicate error. } public int lstat(String path, FileStat stat) { File file = new JavaSecuredFile(path); if (!file.exists()) handler.error(ERRORS.ENOENT, path); // FIXME: Bulletproof this or no? JavaFileStat jstat = (JavaFileStat) stat; jstat.setup(path); // TODO: Add error reporting for cases we can calculate: ENOTDIR, ENAMETOOLONG, ENOENT // EACCES, ELOOP, EFAULT, EIO return 0; } public int mkdir(String path, int mode) { File dir = new JavaSecuredFile(path); if (!dir.mkdir()) return -1; chmod(path, mode); return 0; } public int stat(String path, FileStat stat) { // FIXME: Bulletproof this or no? JavaFileStat jstat = (JavaFileStat) stat; try { File file = new JavaSecuredFile(path); if (!file.exists()) handler.error(ERRORS.ENOENT, path); jstat.setup(file.getCanonicalPath()); } catch (IOException e) { // TODO: Throw error when we have problems stat'ing canonicalizing } // TODO: Add error reporting for cases we can calculate: ENOTDIR, ENAMETOOLONG, ENOENT // EACCES, ELOOP, EFAULT, EIO return 0; } public int symlink(String oldpath, String newpath) { try { return new ExecIt(handler).runAndWait("ln", "-s", oldpath, newpath); } catch (Exception e) {} return -1; // We tried and failed for some reason. Indicate error. } public int readlink(String oldpath, ByteBuffer buffer, int length) throws IOException { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); new ExecIt(handler).runAndWait(baos, "readlink", oldpath); byte[] bytes = baos.toByteArray(); if (bytes.length > length || bytes.length == 0) return -1; buffer.put(bytes, 0, bytes.length - 1); // trim off \n return buffer.position(); } catch (InterruptedException e) { } return -1; // We tried and failed for some reason. Indicate error. } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/OpenBSDPOSIX.java0000644000175000017500000000403511176403715024032 0ustar niconico/***** BEGIN LICENSE BLOCK ***** * Version: CPL 1.0/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Common 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.eclipse.org/legal/cpl-v10.html * * 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 contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the CPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the CPL, the GPL or the LGPL. ***** END LICENSE BLOCK *****/ /** * $Id: $ */ package org.jruby.ext.posix; import com.sun.jna.FromNativeContext; import com.sun.jna.Pointer; public final class OpenBSDPOSIX extends BaseNativePOSIX { public OpenBSDPOSIX(String libraryName, LibC libc, POSIXHandler handler) { super(libraryName, libc, handler); } public FileStat allocateStat() { return new FreeBSDHeapFileStat(this); } public static final PointerConverter PASSWD = new PointerConverter() { public Object fromNative(Object arg, FromNativeContext ctx) { return arg != null ? new OpenBSDPasswd((Pointer) arg) : null; } }; } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/BaseHeapFileStat.java0000644000175000017500000001276411176403715025071 0ustar niconico/***** BEGIN LICENSE BLOCK ***** * Version: CPL 1.0/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Common 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.eclipse.org/legal/cpl-v10.html * * 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 contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the CPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the CPL, the GPL or the LGPL. ***** END LICENSE BLOCK *****/ /** * $Id: $ */ package org.jruby.ext.posix; import com.sun.jna.NativeMapped; /** * */ public abstract class BaseHeapFileStat extends HeapStruct implements FileStat, NativeMapped { protected final POSIX posix; public BaseHeapFileStat(POSIX posix) { super(); this.posix = posix; } public String ftype() { if (isFile()) { return "file"; } else if (isDirectory()) { return "directory"; } else if (isCharDev()) { return "characterSpecial"; } else if (isBlockDev()) { return "blockSpecial"; } else if (isFifo()) { return "fifo"; } else if (isSymlink()) { return "link"; } else if (isSocket()) { return "socket"; } return "unknown"; } public boolean groupMember(int gid) { if (posix.getgid() == gid || posix.getegid() == gid) { return true; } // FIXME: Though not Posix, windows has different mechanism for this. return false; } public boolean isBlockDev() { return (mode() & S_IFMT) == S_IFBLK; } public boolean isCharDev() { return (mode() & S_IFMT) == S_IFCHR; } public boolean isDirectory() { return (mode() & S_IFMT) == S_IFDIR; } public boolean isEmpty() { return st_size() == 0; } public boolean isExecutable() { if (posix.geteuid() == 0) return (mode() & S_IXUGO) != 0; if (isOwned()) return (mode() & S_IXUSR) != 0; if (isGroupOwned()) return (mode() & S_IXGRP) != 0; return (mode() & S_IXOTH) != 0; } public boolean isExecutableReal() { if (posix.getuid() == 0) return (mode() & S_IXUGO) != 0; if (isROwned()) return (mode() & S_IXUSR) != 0; if (groupMember(gid())) return (mode() & S_IXGRP) != 0; return (mode() & S_IXOTH) != 0; } public boolean isFile() { return (mode() & S_IFMT) == S_IFREG; } public boolean isFifo() { return (mode() & S_IFMT) == S_IFIFO; } public boolean isGroupOwned() { return groupMember(gid()); } public boolean isIdentical(FileStat other) { return dev() == other.dev() && ino() == other.ino(); } public boolean isNamedPipe() { return (mode() & S_IFIFO) != 0; } public boolean isOwned() { return posix.geteuid() == uid(); } public boolean isROwned() { return posix.getuid() == uid(); } public boolean isReadable() { if (posix.geteuid() == 0) return true; if (isOwned()) return (mode() & S_IRUSR) != 0; if (isGroupOwned()) return (mode() & S_IRGRP) != 0; return (mode() & S_IROTH) != 0; } public boolean isReadableReal() { if (posix.getuid() == 0) return true; if (isROwned()) return (mode() & S_IRUSR) != 0; if (groupMember(gid())) return (mode() & S_IRGRP) != 0; return (mode() & S_IROTH) != 0; } public boolean isSetgid() { return (mode() & S_ISGID) != 0; } public boolean isSetuid() { return (mode() & S_ISUID) != 0; } public boolean isSocket() { return (mode() & S_IFMT) == S_IFSOCK; } public boolean isSticky() { return (mode() & S_ISVTX) != 0; } public boolean isSymlink() { return (mode() & S_IFMT) == S_IFLNK; } public boolean isWritable() { if (posix.geteuid() == 0) return true; if (isOwned()) return (mode() & S_IWUSR) != 0; if (isGroupOwned()) return (mode() & S_IWGRP) != 0; return (mode() & S_IWOTH) != 0; } public boolean isWritableReal() { if (posix.getuid() == 0) return true; if (isROwned()) return (mode() & S_IWUSR) != 0; if (groupMember(gid())) return (mode() & S_IWGRP) != 0; return (mode() & S_IWOTH) != 0; } public int major(long dev) { return (int) (dev >> 24) & 0xff; } public int minor(long dev) { return (int) (dev & 0xffffff); } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/HeapStruct.java0000644000175000017500000002105011176403715024033 0ustar niconico/***** BEGIN LICENSE BLOCK ***** * Version: CPL 1.0/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Common 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.eclipse.org/legal/cpl-v10.html * * 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 contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the CPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the CPL, the GPL or the LGPL. ***** END LICENSE BLOCK *****/ /** * $Id: $ */ package org.jruby.ext.posix; import com.sun.jna.FromNativeContext; import com.sun.jna.Platform; import com.sun.jna.Pointer; import java.nio.ByteBuffer; import java.nio.ByteOrder; /** * */ public class HeapStruct implements com.sun.jna.NativeMapped { private static final String arch = System.getProperty("os.arch").toLowerCase(); private static final boolean isSPARC = "sparc".equals(arch); /* * Most arches align long/double on the same size as a native long (or a pointer) * Sparc (32bit) requires it to be aligned on an 8 byte boundary */ private static final int LONG_SIZE = (Platform.isWindows() ? 4 : Pointer.SIZE) * 8; private static final int LONG_ALIGN = isSPARC ? 64 : LONG_SIZE; private static final long LONG_MASK = LONG_SIZE == 32 ? 0x7FFFFFFFL : 0x7FFFFFFFFFFFFFFFL; private static final int DOUBLE_ALIGN = isSPARC ? 64 : LONG_SIZE; private static final int FLOAT_ALIGN = isSPARC ? 64 : 32; private ByteBuffer buffer; private int size = 0; public Object fromNative(Object arg0, FromNativeContext arg1) { throw new UnsupportedOperationException("Not supported yet."); } public Object toNative() { return getByteBuffer(); } public Class nativeType() { return ByteBuffer.class; } protected final ByteBuffer getByteBuffer() { if (buffer == null) { buffer = ByteBuffer.allocate(size).order(ByteOrder.nativeOrder()); } return buffer; } public final int getStructSize() { return size; } protected final int addField(int size, int align) { int mask = (align / 8) - 1; if ((this.size & mask) != 0) { this.size = (this.size & ~mask) + (align / 8); } int off = this.size; this.size += size / 8; return off; } protected abstract class Field { public final int size; public final int align; public final int offset; public Field(int size) { this(size, size); } public Field(int size, int align) { this.size = size; this.align = align; this.offset = addField(size, align); } } protected class Int8 extends Field { public Int8() { super(8); } public Int8(byte value) { this(); set(value); } public final byte get() { return getByteBuffer().get(offset); } public final void set(byte value) { getByteBuffer().put(offset, value); } } protected class UInt8 extends Field { public UInt8() { super(8); } public UInt8(short value) { this(); set(value); } public final short get() { final short value = getByteBuffer().get(offset); return value < 0 ? (short) ((value & 0x7F) + 0x80) : value; } public final void set(short value) { getByteBuffer().put(offset, (byte) value); } } protected final class Byte extends Int8 { public Byte() { } public Byte(byte value) { super(value); } } protected class Int16 extends Field { public Int16() { super(16); } public Int16(short value) { this(); set(value); } public final short get() { return getByteBuffer().getShort(offset); } public final void set(short value) { getByteBuffer().putShort(offset, value); } } protected class UInt16 extends Field { public UInt16() { super(16); } public UInt16(short value) { this(); set(value); } public final int get() { final int value = getByteBuffer().getShort(offset); return value < 0 ? (int)((value & 0x7FFF) + 0x8000) : value; } public final void set(int value) { getByteBuffer().putShort(offset, (short) value); } } protected class Short extends Int16 { public Short() {} public Short(short value) { super(value); } } protected class Int32 extends Field { public Int32() { super(32); } public Int32(int value) { this(); set(value); } public final int get() { return getByteBuffer().getInt(offset); } public final void set(int value) { getByteBuffer().putInt(offset, value); } } protected class UInt32 extends Field { public UInt32() { super(32); } public UInt32(long value) { this(); set(value); } public final long get() { final long value = getByteBuffer().getInt(offset); return value < 0 ? (long)((value & 0x7FFFFFFFL) + 0x80000000L) : value; } public final void set(long value) { getByteBuffer().putInt(offset, (int) value); } } protected class Integer extends Int32 { public Integer() {} public Integer(int value) { super(value); } } protected class Int64 extends Field { public Int64() { super(64, LONG_ALIGN); } public Int64(long value) { this(); set(value); } public final long get() { return getByteBuffer().getLong(offset); } public final void set(long value) { getByteBuffer().putLong(offset, value); } } protected class Long extends Field { public Long() { super(LONG_SIZE, LONG_ALIGN); } public Long(long value) { this(); set(value); } public final long get() { return LONG_SIZE == 32 ? getByteBuffer().getInt(offset) : getByteBuffer().getLong(offset); } public final void set(long value) { if (LONG_SIZE == 32) { getByteBuffer().putInt(offset, (int) value); } else { getByteBuffer().putLong(offset, value); } } } protected class ULong extends Field { public ULong() { super(LONG_SIZE, LONG_ALIGN); } public ULong(long value) { this(); set(value); } public final long get() { final long value = LONG_SIZE == 32 ? getByteBuffer().getInt(offset) : getByteBuffer().getLong(offset); return value < 0 ? (long) ((value & LONG_MASK) + LONG_MASK + 1) : value; } public final void set(long value) { if (LONG_SIZE == 32) { getByteBuffer().putInt(offset, (int) value); } else { getByteBuffer().putLong(offset, value); } } } protected class LongLong extends Int64 { public LongLong() { } public LongLong(long value) { super(value); } } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/POSIXTypeMapper.java0000644000175000017500000000223211176403715024663 0ustar niconicopackage org.jruby.ext.posix; import com.sun.jna.FromNativeConverter; import com.sun.jna.ToNativeConverter; import com.sun.jna.TypeMapper; import org.jruby.ext.posix.util.Platform; class POSIXTypeMapper implements TypeMapper { public static final TypeMapper INSTANCE = new POSIXTypeMapper(); private POSIXTypeMapper() {} public FromNativeConverter getFromNativeConverter(Class klazz) { if (Passwd.class.isAssignableFrom(klazz)) { if (Platform.IS_MAC) { return MacOSPOSIX.PASSWD; } else if (Platform.IS_LINUX) { return LinuxPOSIX.PASSWD; } else if (Platform.IS_SOLARIS) { return SolarisPOSIX.PASSWD; } else if (Platform.IS_FREEBSD) { return FreeBSDPOSIX.PASSWD; } else if (Platform.IS_OPENBSD) { return OpenBSDPOSIX.PASSWD; } return null; } else if (Group.class.isAssignableFrom(klazz)) { return BaseNativePOSIX.GROUP; } return null; } public ToNativeConverter getToNativeConverter(Class klazz) { return null; } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/WindowsLibCFunctionMapper.java0000644000175000017500000000176411176403715027022 0ustar niconico/* * POSIXFunctionMapper.java */ package org.jruby.ext.posix; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; import com.sun.jna.FunctionMapper; import com.sun.jna.NativeLibrary; public class WindowsLibCFunctionMapper implements FunctionMapper { private Map methodNameMap; public WindowsLibCFunctionMapper() { methodNameMap = new HashMap(); methodNameMap.put("getpid", "_getpid"); methodNameMap.put("chmod", "_chmod"); methodNameMap.put("fstat", "_fstat"); methodNameMap.put("stat", "_stat64"); methodNameMap.put("mkdir", "_mkdir"); methodNameMap.put("umask", "_umask"); methodNameMap.put("isatty", "_isatty"); } public String getFunctionName(NativeLibrary library, Method method) { String originalName = method.getName(); String name = methodNameMap.get(originalName); return name != null ? name : originalName; } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/POSIXFunctionMapper.java0000644000175000017500000000125211176403715025530 0ustar niconico/* * POSIXFunctionMapper.java */ package org.jruby.ext.posix; import java.lang.reflect.Method; import com.sun.jna.FunctionMapper; import com.sun.jna.NativeLibrary; public class POSIXFunctionMapper implements FunctionMapper { public POSIXFunctionMapper() {} public String getFunctionName(NativeLibrary library, Method method) { String name = method.getName(); if (library.getName().equals("msvcrt")) { // FIXME: We should either always _ name for msvcrt or get good list of _ methods if (name.equals("getpid") || name.equals("chmod")) { name = "_" + name; } } return name; } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/DefaultNativeTimeval.java0000644000175000017500000000060311176403715026027 0ustar niconicopackage org.jruby.ext.posix; import com.sun.jna.NativeLong; public final class DefaultNativeTimeval extends NativeTimeval { public NativeLong tv_sec; public NativeLong tv_usec; public DefaultNativeTimeval() {} public void setTime(long[] timeval) { assert timeval.length == 2; tv_sec.setValue(timeval[0]); tv_usec.setValue(timeval[1]); } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/Timeval.java0000644000175000017500000000014411176403715023353 0ustar niconicopackage org.jruby.ext.posix; public interface Timeval { public void setTime(long[] timeval); } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/LinuxHeapFileStat.java0000644000175000017500000000722011176403715025305 0ustar niconico/***** BEGIN LICENSE BLOCK ***** * Version: CPL 1.0/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Common 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.eclipse.org/legal/cpl-v10.html * * 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 contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the CPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the CPL, the GPL or the LGPL. ***** END LICENSE BLOCK *****/ /** * $Id: $ */ package org.jruby.ext.posix; public final class LinuxHeapFileStat extends BaseHeapFileStat { public final Int64 st_dev = new Int64(); public final Short __pad1 = new Short(); public final Int32 st_ino = new Int32(); public final Int32 st_mode = new Int32(); public final Int32 st_nlink = new Int32(); public final Int32 st_uid = new Int32(); public final Int32 st_gid = new Int32(); public final Int64 st_rdev = new Int64(); public final Short __pad2 = new Short(); public final Int64 st_size = new Int64(); public final Int32 st_blksize = new Int32(); public final Int32 st_blocks = new Int32(); public final Int32 __unused4 = new Int32(); public final Int32 st_atim_sec = new Int32(); // Time of last access (time_t) public final Int32 st_atim_nsec = new Int32(); // Time of last access (nanoseconds) public final Int32 st_mtim_sec = new Int32(); // Last data modification time (time_t) public final Int32 st_mtim_nsec = new Int32(); // Last data modification time (nanoseconds) public final Int32 st_ctim_sec = new Int32(); // Time of last status change (time_t) public final Int32 st_ctim_nsec = new Int32(); // Time of last status change (nanoseconds) public final Int64 __unused5 = new Int64(); public LinuxHeapFileStat() { this(null); } public LinuxHeapFileStat(POSIX posix) { super(posix); } public long atime() { return st_atim_sec.get(); } public long blocks() { return st_blocks.get(); } public long blockSize() { return st_blksize.get(); } public long ctime() { return st_ctim_sec.get(); } public long dev() { return st_dev.get(); } public int gid() { return st_gid.get(); } public long ino() { return st_ino.get(); } public int mode() { return st_mode.get() & 0xffff; } public long mtime() { return st_mtim_sec.get(); } public int nlink() { return st_nlink.get(); } public long rdev() { return st_rdev.get(); } public long st_size() { return st_size.get(); } public int uid() { return st_uid.get(); } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/FreeBSDHeapFileStat.java0000644000175000017500000000723011176403715025421 0ustar niconico/***** BEGIN LICENSE BLOCK ***** * Version: CPL 1.0/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Common 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.eclipse.org/legal/cpl-v10.html * * 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 contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the CPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the CPL, the GPL or the LGPL. ***** END LICENSE BLOCK *****/ /** * $Id: $ */ package org.jruby.ext.posix; public final class FreeBSDHeapFileStat extends BaseHeapFileStat { public final class time_t extends Long {} public final class dev_t extends Int32 {} public final dev_t st_dev = new dev_t(); public final Int32 st_ino = new Int32(); public final Int16 st_mode = new Int16(); public final Int16 st_nlink = new Int16(); public final Int32 st_uid = new Int32(); public final Int32 st_gid = new Int32(); public final dev_t st_rdev = new dev_t(); public final time_t st_atime = new time_t(); public final Long st_atimensec = new Long(); public final time_t st_mtime = new time_t(); public final Long st_mtimensec = new Long(); public final time_t st_ctime = new time_t(); public final Long st_ctimensec = new Long(); public final Int64 st_size = new Int64(); public final Int64 st_blocks = new Int64(); public final Int32 st_blksize = new Int32(); public final Int32 st_flags = new Int32(); public final Int32 st_gen = new Int32(); public final Int32 st_lspare = new Int32(); public final time_t st_birthtime = new time_t(); public final Long st_birthtimensec = new Long(); /* FIXME: This padding isn't quite correct */ public final Int64 st_qspare0 = new Int64(); public FreeBSDHeapFileStat() { this(null); } public FreeBSDHeapFileStat(POSIX posix) { super(posix); } public long atime() { return st_atime.get(); } public long blocks() { return st_blocks.get(); } public long blockSize() { return st_blksize.get(); } public long ctime() { return st_ctime.get(); } public long dev() { return st_dev.get(); } public int gid() { return st_gid.get(); } public long ino() { return st_ino.get(); } public int mode() { return st_mode.get() & 0xffff; } public long mtime() { return st_mtime.get(); } public int nlink() { return st_nlink.get(); } public long rdev() { return st_rdev.get(); } public long st_size() { return st_size.get(); } public int uid() { return st_uid.get(); } } libjna-posix-java-1.0.1.orig/src/org/jruby/ext/posix/MacOSFileStat.java0000644000175000017500000000554011176403715024355 0ustar niconicopackage org.jruby.ext.posix; public class MacOSFileStat extends BaseNativeFileStat { public volatile int st_dev; // device inode resides on (dev_t) public volatile int st_ino; // inode's number (ino_t) public volatile short st_mode; // inode protection mode (mode_t - uint16) public volatile short st_nlink; // number or hard links to the file (nlink_y - uint16) public volatile int st_uid; // user-id of owner (uid_t) public volatile int st_gid; // group-id of owner (gid_t) public volatile int st_rdev; // device type, for special file inode (st_rdev - dev_t) public volatile int st_atime; // Time of last access (time_t) public volatile int st_atimensec; // Time of last access (nanoseconds) public volatile int st_mtime; // Last data modification time (time_t) public volatile int st_mtimensec; // Last data modification time (nanoseconds) public volatile int st_ctime; // Time of last status change (time_t) public volatile int st_ctimensec; // Time of last status change (nanoseconds) public volatile long st_size; // file size, in bytes public volatile long st_blocks; // blocks allocated for file public volatile int st_blksize; // optimal file system I/O ops blocksize public volatile int st_flags; // user defined flags for file public volatile int st_gen; // file generation number public volatile int st_lspare; // RESERVED: DO NOT USE! public volatile long[] st_qspare; // RESERVED: DO NOT USE! public MacOSFileStat(POSIX posix) { super(posix); this.st_qspare = new long[2]; } public long atime() { return st_atime; } public long blocks() { return st_blocks; } public long blockSize() { return st_blksize; } public long ctime() { return st_ctime; } public long dev() { return st_dev; } public int gid() { return st_gid; } public long ino() { return st_ino; } public int mode() { return st_mode & 0xffff; } public long mtime() { return st_mtime; } public int nlink() { return st_nlink; } public long rdev() { return st_rdev; } public long st_size() { return st_size; } public int uid() { return st_uid; } public String toString() { return "Stat {DEV: " + st_dev + ", INO: " + st_ino + ", MODE: " + st_mode + ", NLINK: " + st_nlink + ", UID: " + st_uid + ", GID: " + st_gid + ", RDEV: " + st_rdev + ", BLOCKS: " + st_blocks + ", SIZE: " + st_size + ", BLKSIZE: " + st_blksize + ", FLAGS: " + st_flags + ", GEN: " + st_gen + ", ATIME: " + st_atime + ", MTIME: " + st_mtime + ", CTIME: " + st_ctime; } } libjna-posix-java-1.0.1.orig/pom.xml0000644000175000017500000000712611176403715015760 0ustar niconico 4.0.0 org.jruby.ext.posix jna-posix jar 1.0.1 JNA-POSIX Common cross-project/cross-platform POSIX APIs JIRA http://jira.codehaus.org/browse/JRUBY scm:svn:http://svn.codehaus.org/jruby-contrib scm:svn:https://svn.codehaus.org/jruby-contrib http://svn.codehaus.org/jruby-contrib Common Public License - v 1.0 http://www-128.ibm.com/developerworks/library/os-cpl.html repo GNU General Public License Version 2 http://www.gnu.org/copyleft/gpl.html repo GNU Lesser General Public License Version 2.1 http://www.gnu.org/licenses/lgpl.html repo codehaus-jruby-repository JRuby Central Repository dav:https://dav.codehaus.org/repository/jruby codehaus-jruby-snapshot-repository JRuby Central Development Repository dav:https://dav.codehaus.org/snapshots.repository/jruby codehaus-jruby-site JRuby Maven site dav:https://dav.codehaus.org/jruby/info codehaus Codehaus Repository true false http://repository.codehaus.org enebo Thomas E Enebo tom.enebo@gmail.com junit junit 4.4 test net.java.dev.jna jna 3.0.9 provided src test org.apache.maven.wagon wagon-webdav maven-compiler-plugin 1.5 1.5 maven-jar-plugin MANIFEST.MF libjna-posix-java-1.0.1.orig/.hgignore0000644000175000017500000000003511176403715016236 0ustar niconicobuild dist target nbproject libjna-posix-java-1.0.1.orig/LICENSE.txt0000644000175000017500000015025511176403715016270 0ustar niconicojna-posix is released under a tri CPL/GPL/LGPL license. You can use it, redistribute it and/or modify it under the terms of the license of your choice. === Common Public License - v 1.0 THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 1. DEFINITIONS "Contribution" means: a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and b) in the case of each subsequent Contributor: i) changes to the Program, and ii) additions to the Program; where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. "Contributor" means any person or entity that distributes the Program. "Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. "Program" means the Contributions distributed in accordance with this Agreement. "Recipient" means anyone who receives the Program under this Agreement, including all Contributors. 2. GRANT OF RIGHTS a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form. b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program. d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. 3. REQUIREMENTS A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: a) it complies with the terms and conditions of this Agreement; and b) its license agreement: i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. When the Program is made available in source code form: a) it must be made available under this Agreement; and b) a copy of this Agreement must be included with each copy of the Program. Contributors may not remove or alter any copyright notices contained within the Program. Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. 4. COMMERCIAL DISTRIBUTION Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. 5. NO WARRANTY EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. 6. DISCLAIMER OF LIABILITY EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 7. GENERAL If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. === GPL 2.0 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS == GNU LGPL 2.1 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! libjna-posix-java-1.0.1.orig/build.xml0000644000175000017500000000633711176403715016267 0ustar niconico Builds, tests, and runs the project jna-posix. libjna-posix-java-1.0.1.orig/nbproject/0000755000175000017500000000000011313156244016416 5ustar niconicolibjna-posix-java-1.0.1.orig/nbproject/genfiles.properties0000644000175000017500000000067711176403715022347 0ustar niconicobuild.xml.data.CRC32=ff132349 build.xml.script.CRC32=03cd8af7 build.xml.stylesheet.CRC32=be360661 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=ff132349 nbproject/build-impl.xml.script.CRC32=424c9197 nbproject/build-impl.xml.stylesheet.CRC32=487672f9 libjna-posix-java-1.0.1.orig/nbproject/project.properties0000644000175000017500000000355611176403715022220 0ustar niconicoapplication.title=jna-posix application.vendor=nicksieger build.classes.dir=${build.dir}/classes build.classes.excludes=**/*.java,**/*.form # This directory is removed when the project is cleaned: build.dir=build build.generated.dir=${build.dir}/generated # Only compile against the classpath explicitly listed here: build.sysclasspath=ignore build.test.classes.dir=${build.dir}/test/classes build.test.results.dir=${build.dir}/test/results debug.classpath=\ ${run.classpath} debug.test.classpath=\ ${run.test.classpath} # This directory is removed when the project is cleaned: dist.dir=dist dist.jar=${dist.dir}/jna-posix.jar dist.javadoc.dir=${dist.dir}/javadoc excludes= file.reference.jna.jar=lib/jna.jar file.reference.junit.jar=lib/junit-4.4.jar includes=** jar.compress=false javac.classpath=\ ${file.reference.jna.jar}:\ ${file.reference.junit.jar} # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false javac.source=1.5 javac.target=1.5 javac.test.classpath=\ ${javac.classpath}:\ ${build.classes.dir}:\ ${libs.junit.classpath}:\ ${libs.junit_4.classpath} javadoc.additionalparam= javadoc.author=false javadoc.encoding=${source.encoding} javadoc.noindex=false javadoc.nonavbar=false javadoc.notree=false javadoc.private=false javadoc.splitindex=true javadoc.use=true javadoc.version=false javadoc.windowtitle= meta.inf.dir=${src.dir}/META-INF platform.active=default_platform run.classpath=\ ${javac.classpath}:\ ${build.classes.dir} # Space-separated list of JVM arguments used when running the project # (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value # or test-sys-prop.name=value to set system properties for unit tests): run.jvmargs= run.test.classpath=\ ${javac.test.classpath}:\ ${build.test.classes.dir} source.encoding=UTF-8 src.dir=src test.src.dir=test libjna-posix-java-1.0.1.orig/nbproject/project.xml0000644000175000017500000000106311176403715020613 0ustar niconico org.netbeans.modules.java.j2seproject jna-posix 1.6.5 libjna-posix-java-1.0.1.orig/nbproject/build-impl.xml0000644000175000017500000007747111176403715021223 0ustar niconico Must set src.dir Must set test.src.dir Must set build.dir Must set dist.dir Must set build.classes.dir Must set dist.javadoc.dir Must set build.test.classes.dir Must set build.test.results.dir Must set build.classes.excludes Must set dist.jar Must set javac.includes Must select some files in the IDE or set javac.includes To run this application from the command line without Ant, try: java -cp "${run.classpath.with.dist.jar}" ${main.class} To run this application from the command line without Ant, try: java -jar "${dist.jar.resolved}" Must select one file in the IDE or set run.class Must select one file in the IDE or set debug.class Must set fix.includes Must select some files in the IDE or set javac.includes Some tests failed; see details above. Must select some files in the IDE or set test.includes Some tests failed; see details above. Must select one file in the IDE or set test.class Must select one file in the IDE or set applet.url Must select one file in the IDE or set applet.url libjna-posix-java-1.0.1.orig/nbproject/private/0000755000175000017500000000000011313156244020070 5ustar niconicolibjna-posix-java-1.0.1.orig/nbproject/private/private.xml0000644000175000017500000000031711176403715022272 0ustar niconico libjna-posix-java-1.0.1.orig/nbproject/private/private.properties.tmpl0000644000175000017500000000016311176403715024640 0ustar niconico# This is where Xcode installs junit on mac; customize for yourself libs.junit.classpath=/usr/share/junit/junit.jarlibjna-posix-java-1.0.1.orig/MANIFEST.MF0000644000175000017500000000007411176403715016070 0ustar niconicoImplementation-Title: JNA-POSIX Implementation-Version: 0.5 libjna-posix-java-1.0.1.orig/test/0000755000175000017500000000000011313156246015411 5ustar niconicolibjna-posix-java-1.0.1.orig/test/org/0000755000175000017500000000000011313156246016200 5ustar niconicolibjna-posix-java-1.0.1.orig/test/org/jruby/0000755000175000017500000000000011313156246017333 5ustar niconicolibjna-posix-java-1.0.1.orig/test/org/jruby/ext/0000755000175000017500000000000011313156246020133 5ustar niconicolibjna-posix-java-1.0.1.orig/test/org/jruby/ext/posix/0000755000175000017500000000000011313156246021275 5ustar niconicolibjna-posix-java-1.0.1.orig/test/org/jruby/ext/posix/DummyPOSIXHandler.java0000644000175000017500000000270511176403715025363 0ustar niconico/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package org.jruby.ext.posix; import java.io.File; import java.io.InputStream; import java.io.PrintStream; import org.jruby.ext.posix.POSIX.ERRORS; /** * * @author wayne */ public class DummyPOSIXHandler implements POSIXHandler { public void error(ERRORS error, String extraData) { throw new UnsupportedOperationException("Not supported yet."); } public void unimplementedError(String methodName) { throw new UnsupportedOperationException("Not supported yet."); } public void warn(WARNING_ID id, String message, Object... data) { throw new UnsupportedOperationException("Not supported yet."); } public boolean isVerbose() { return false; } public File getCurrentWorkingDirectory() { return new File("/tmp"); } public String[] getEnv() { throw new UnsupportedOperationException("Not supported yet."); } public InputStream getInputStream() { throw new UnsupportedOperationException("Not supported yet."); } public PrintStream getOutputStream() { throw new UnsupportedOperationException("Not supported yet."); } public int getPID() { throw new UnsupportedOperationException("Not supported yet."); } public PrintStream getErrorStream() { throw new UnsupportedOperationException("Not supported yet."); } } libjna-posix-java-1.0.1.orig/test/org/jruby/ext/posix/GroupTest.java0000644000175000017500000000230611176403715024100 0ustar niconico package org.jruby.ext.posix; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import static org.junit.Assert.*; /** * */ public class GroupTest { public GroupTest() { } private static POSIX posix; @BeforeClass public static void setUpClass() throws Exception { posix = POSIXFactory.getPOSIX(new DummyPOSIXHandler(), true); } @AfterClass public static void tearDownClass() throws Exception { } @Before public void setUp() { } @After public void tearDown() { } // TODO add test methods here. // The methods must be annotated with annotation @Test. For example: // // @Test // public void hello() {} @Test public void getgrnam() { final String LOGIN = "nobody"; Group grp = posix.getgrnam(LOGIN); assertNotNull(grp); assertEquals("Login name not equal", LOGIN, grp.getName()); } @Test public void nonExistantGroupReturnsNull() { final String LOGIN = "dkjhfjkdsfhjksdhfsdjkhfsdkjhfdskj"; assertNull("getpwnam for non-existant group should return null", posix.getgrnam(LOGIN)); } } libjna-posix-java-1.0.1.orig/test/org/jruby/ext/posix/IDTest.java0000644000175000017500000000465311176403715023307 0ustar niconico/***** BEGIN LICENSE BLOCK ***** * Version: CPL 1.0/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Common 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.eclipse.org/legal/cpl-v10.html * * 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 contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the CPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the CPL, the GPL or the LGPL. ***** END LICENSE BLOCK *****/ /** * $Id: $ */ package org.jruby.ext.posix; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import static org.junit.Assert.*; public class IDTest { public IDTest() { } private static POSIX nativePosix, javaPosix; @BeforeClass public static void setUpClass() throws Exception { nativePosix = POSIXFactory.getPOSIX(new DummyPOSIXHandler(), true); javaPosix = POSIXFactory.getPOSIX(new DummyPOSIXHandler(), false); } @AfterClass public static void tearDownClass() throws Exception { } @Before public void setUp() { } @After public void tearDown() { } @Test public void getuid() { assertEquals("Java posix did not return same value as native posix", nativePosix.getuid(), javaPosix.getuid()); } @Test public void getgid() { assertEquals("Java posix did not return same value as native posix", nativePosix.getgid(), javaPosix.getgid()); } }libjna-posix-java-1.0.1.orig/test/org/jruby/ext/posix/HeapStructTest.java0000644000175000017500000000411711176403715025070 0ustar niconico/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package org.jruby.ext.posix; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import static org.junit.Assert.*; /** * */ public class HeapStructTest { public HeapStructTest() { } @BeforeClass public static void setUpClass() throws Exception { } @AfterClass public static void tearDownClass() throws Exception { } @Before public void setUp() { } @After public void tearDown() { } private static final class Unsigned8Test extends HeapStruct { public final UInt8 u8 = new UInt8(); } @Test public void unsigned8() { Unsigned8Test s = new Unsigned8Test(); final short MAGIC = (short) Byte.MAX_VALUE + 1; s.u8.set(MAGIC); assertEquals("Incorrect unsigned byte value", MAGIC, s.u8.get()); } private static final class Unsigned16Test extends HeapStruct { public final UInt16 u16 = new UInt16(); } @Test public void unsigned16() { Unsigned16Test s = new Unsigned16Test(); final int MAGIC = (int) Short.MAX_VALUE + 1; s.u16.set(MAGIC); assertEquals("Incorrect unsigned short value", MAGIC, s.u16.get()); } private static final class Unsigned32Test extends HeapStruct { public final UInt32 u32 = new UInt32(); } @Test public void unsigned32() { Unsigned32Test s = new Unsigned32Test(); final long MAGIC = (long) Integer.MAX_VALUE + 1; s.u32.set(MAGIC); assertEquals("Incorrect unsigned int value", MAGIC, s.u32.get()); } private static final class UnsignedLongTest extends HeapStruct { public final ULong ul = new ULong(); } @Test public void unsignedLong() { UnsignedLongTest s = new UnsignedLongTest(); final long MAGIC = (long) Integer.MAX_VALUE + 1; s.ul.set(MAGIC); assertEquals("Incorrect unsigned long value", MAGIC, s.ul.get()); } }libjna-posix-java-1.0.1.orig/test/org/jruby/ext/posix/PasswdTest.java0000644000175000017500000000331511176403715024246 0ustar niconico package org.jruby.ext.posix; import org.jruby.ext.posix.util.Platform; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import static org.junit.Assert.*; /** * */ public class PasswdTest { public PasswdTest() { } private static POSIX posix; private static Class passwdClass; @BeforeClass public static void setUpClass() throws Exception { if (Platform.IS_MAC) { passwdClass = MacOSPasswd.class; } else if (Platform.IS_LINUX) { passwdClass = LinuxPasswd.class; } else if (Platform.IS_FREEBSD) { passwdClass = FreeBSDPasswd.class; } else if (Platform.IS_OPENBSD) { passwdClass = OpenBSDPasswd.class; } else if (Platform.IS_SOLARIS) { passwdClass = SolarisPasswd.class; } else { throw new IllegalArgumentException("Platform not supported"); } posix = POSIXFactory.getPOSIX(new DummyPOSIXHandler(), true); } @AfterClass public static void tearDownClass() throws Exception { } @Before public void setUp() { } @After public void tearDown() { } @Test public void getpwnam() { final String LOGIN = "root"; Passwd pwd = posix.getpwnam(LOGIN); assertNotNull(pwd); assertEquals("Login name not equal", LOGIN, pwd.getLoginName()); assertTrue(pwd.getClass().equals(passwdClass)); } @Test public void nonExistantUserReturnsNull() { final String LOGIN = "dkjhfjkdsfhjksdhfsdjkhfsdkjhfdskj"; assertNull("getpwnam for non-existant user should return null", posix.getpwnam(LOGIN)); } } libjna-posix-java-1.0.1.orig/test/org/jruby/ext/posix/JavaFileStatTest.java0000644000175000017500000000103311176403715025315 0ustar niconico/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package org.jruby.ext.posix; import junit.framework.TestCase; import org.jruby.ext.posix.util.Platform; /** * * @author nicksieger */ public class JavaFileStatTest extends TestCase { public void testSetup() { JavaFileStat fs = new JavaFileStat(null, null); if (Platform.IS_WINDOWS) { fs.setup("c:/"); } else { fs.setup("/"); } assertFalse(fs.isSymlink()); } } libjna-posix-java-1.0.1.orig/README.txt0000644000175000017500000000071111176403715016132 0ustar niconicojna-posix is a lightweight cross-platform POSIX emulation layer for Java, written in Java and leveraging the JNA library (https://jna.dev.java.net/). = Building JNA should build fine from within NetBeans. Otherwise, copy the file nbproject/private/private.properties.tmpl to nbproject/private/private.properties and edit it to point at a local junit.jar. The one mentioned in the template file is in the default location on Mac OS X with Xcode installed. libjna-posix-java-1.0.1.orig/.hgtags0000644000175000017500000000034111176403715015711 0ustar niconicob2569b1e4284f03ffc599edc8581e0b36bea584c 0.8 751d0f95713124e976e6f2cf8d807a1ff352f14b 0.8 51e2de4701712ca90ea852c64e45d2bf881d93d4 0.8 9a7fbcb7173b042d0083ede98b98d7d65c4c0560 0.9 e666a203a21eed50d0f337e845a122754bd7ca61 1.0 libjna-posix-java-1.0.1.orig/lib/0000755000175000017500000000000011313156355015201 5ustar niconico