modules/graphics/src/main/java/com/sun/glass/ui/monocle/linux/LinuxSystem.java

Print this page




  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.glass.ui.monocle.linux;
  27 
  28 import com.sun.glass.ui.monocle.util.C;
  29 import com.sun.glass.utils.NativeLibLoader;
  30 
  31 import java.nio.ByteBuffer;
  32 import java.security.Permission;

  33 
  34 public class LinuxSystem {

  35     private static Permission permission = new RuntimePermission("loadLibrary.*");
  36 
  37     private static LinuxSystem instance = new LinuxSystem();
  38 
  39     public static LinuxSystem getLinuxSystem() {
  40         checkPermissions();
  41         return instance;
  42     }
  43 
  44     private static void checkPermissions() {
  45         SecurityManager security = System.getSecurityManager();
  46         if (security != null) {
  47             security.checkPermission(permission);
  48         }
  49     }
  50 
  51     private LinuxSystem() {

  52     }
  53 
  54     public void loadLibrary() {
  55         NativeLibLoader.loadLibrary("glass_monocle");
  56     }





  57 
  58     // stdlib.h
  59     public native void setenv(String key, String value, boolean overwrite);
  60 
  61     // fcntl.h
  62 
  63     public static final int O_RDONLY = 0;
  64     public static final int O_WRONLY = 1;
  65     public static final int O_RDWR = 2;
  66     public static final int O_NONBLOCK = 00004000;
  67 
  68     public native long open(String path, int flags);
  69 
  70     // unistd.h
  71     public native int close(long fd);
  72     public native long lseek(long fd, long offset, int whence);
  73     public native long write(long fd, ByteBuffer buf, int position, int limit);
  74     public native long read(long fd, ByteBuffer buf, int position, int limit);
  75 
  76     public static final int SEEK_SET = 0;




  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.glass.ui.monocle.linux;
  27 
  28 import com.sun.glass.ui.monocle.util.C;
  29 import com.sun.glass.utils.NativeLibLoader;
  30 
  31 import java.nio.ByteBuffer;
  32 import java.security.Permission;
  33 import com.sun.glass.utils.NativeLibLoader;
  34 
  35 public class LinuxSystem {
  36 
  37     private static Permission permission = new RuntimePermission("loadLibrary.*");
  38 
  39     private static LinuxSystem instance = new LinuxSystem();
  40 
  41     public static LinuxSystem getLinuxSystem() {
  42         checkPermissions();
  43         return instance;
  44     }
  45 
  46     private static void checkPermissions() {
  47         SecurityManager security = System.getSecurityManager();
  48         if (security != null) {
  49             security.checkPermission(permission);
  50         }
  51     }
  52 
  53     private LinuxSystem() {
  54         loadLibrary();
  55     }
  56 
  57     public void loadLibrary() {
  58         NativeLibLoader.loadLibrary("glass_monocle");
  59     }
  60 
  61     // dlfcn.h
  62     public static final int RTLD_LAZY = 0x00001;
  63     public static final int RTLD_GLOBAL = 0x00100;
  64 
  65 
  66     // stdlib.h
  67     public native void setenv(String key, String value, boolean overwrite);
  68 
  69     // fcntl.h
  70 
  71     public static final int O_RDONLY = 0;
  72     public static final int O_WRONLY = 1;
  73     public static final int O_RDWR = 2;
  74     public static final int O_NONBLOCK = 00004000;
  75 
  76     public native long open(String path, int flags);
  77 
  78     // unistd.h
  79     public native int close(long fd);
  80     public native long lseek(long fd, long offset, int whence);
  81     public native long write(long fd, ByteBuffer buf, int position, int limit);
  82     public native long read(long fd, ByteBuffer buf, int position, int limit);
  83 
  84     public static final int SEEK_SET = 0;