Package com.sun.jna

Examples of com.sun.jna.Pointer


  public String currentUser()
  {
    int euid = CLibrary.INSTANCE.geteuid();
    // log("current user euid "+ euid);
    Pointer p = CLibrary.INSTANCE.getpwuid(euid);
    if (p == null)
      log("could not get current user");
    return new CLibrary.passwd(p).getName();

  }
View Full Code Here


  public String currentGroup()
  {
    int egid = CLibrary.INSTANCE.getegid();
    // System.out.println("current group egid "+ egid);
    Pointer pg = CLibrary.INSTANCE.getgrgid(egid);
    if (pg == null)
    {
      log("could not get current group");
      return null;
    }
View Full Code Here

    return new CLibrary.group(pg).getName();
  }

  public String defaultGroup(String user)
  {
    Pointer p = CLibrary.INSTANCE.getpwnam(user);
    if (p == null)
    {
      log("could not get user " + user);
      return null;
    }
    int gid = new CLibrary.passwd(p).getGid();
    System.out.println("default group gid " + gid);
    Pointer pg = CLibrary.INSTANCE.getgrgid(gid);
    if (pg == null)
    {
      log("could not get default group for user " + user);
      return null;
    }
View Full Code Here

    log("switch group " + currentGroup + " -> " + group);

    if (currentGroup != null && !currentGroup.equals(group))
    {
      Pointer p = CLibrary.INSTANCE.getgrnam(group);
      CLibrary.group g = new CLibrary.group(p);
      int newGid = g.getGid();
      String nam = g.getName();
      if (newGid == 0)
        log("could not get group " + group);
      // System.out.println("switching to group name/id "+nam+"/"+newGid);
      int res = CLibrary.INSTANCE.setregid(newGid, newGid);
      if (res != 0)
        log("could not change to group " + group);
    }

    log("switch user " + currentUser + " -> " + user);

    if (currentUser != null && !currentUser.equals(user))
    {
      Pointer p = CLibrary.INSTANCE.getpwnam(user);
      int newUid = new CLibrary.passwd(p).getUid();
      if (newUid == 0)
        log("could not get user " + user);
      int res = CLibrary.INSTANCE.setreuid(newUid, newUid);
      if (res != 0)
View Full Code Here

        Matcher m = p.matcher(status);
        m.find();
        // get ruid
        int ruid = Integer.parseInt(m.group(1));
        System.out.println("rudi " + ruid);
        Pointer po = CLibrary.INSTANCE.getpwuid(ruid);
        if (po == null)
          System.out.println("could not get user");
        return new CLibrary.passwd(po).getName().trim();
      }
      catch (Exception ex)
View Full Code Here

        }
        return new JNAMemoryPointer(context.getRuntime(), io, 0, size);
    }
    @JRubyMethod(name = "to_s", optional = 1)
    public IRubyObject to_s(ThreadContext context, IRubyObject[] args) {
        Pointer address = getAddress();
        String hex = address != null ? address.toString() : "native@0x0";
        return RubyString.newString(context.getRuntime(), MEMORY_POINTER_NAME + "[address=" + hex + "]");
    }
View Full Code Here

                RubyNumeric.fix2long(value));
    }
   
    @JRubyMethod(name = "put_pointer", required = 2)
    public IRubyObject put_pointer(ThreadContext context, IRubyObject offset, IRubyObject value) {
        Pointer ptr;
        if (value instanceof JNAMemoryPointer) {
            ptr = ((JNAMemoryPointer) value).getAddress();
        } else if (value.isNil()) {
            ptr = Pointer.NULL;
        } else {
View Full Code Here

     *
     * @param pointer pointer
     * @return string, or <code>null</code> if the pointer is <code>null</code>
     */
    private String getString(PointerByReference pointer) {
        Pointer value = pointer.getValue();
        return value != null ? value.getString(0) : null;
    }
View Full Code Here

     *
     * @param hWnd native window handle
     * @return native monitor information
     */
    private MONITORINFO getMonitorInfo(HWND hWnd) {
        Pointer hMonitor = ExtendedUser32.INSTANCE.MonitorFromWindow(hWnd, ExtendedUser32.MONITOR_DEFAULTTONEAREST);
        MONITORINFO monitorInfo = new MONITORINFO();
        ExtendedUser32.INSTANCE.GetMonitorInfoA(hMonitor, monitorInfo);
        return monitorInfo;
    }
View Full Code Here

            NativeLibrary.addSearchPath("lua5.1", LUA_PATH);
        }

        LibLua lua = LibLua.INSTANCE;

        Pointer instance = lua.luaL_newstate();
        System.out.println("instance: " + instance);

        lua.luaL_openlibs(instance);

        int loadFile;
View Full Code Here

TOP

Related Classes of com.sun.jna.Pointer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.