Package jnr.ffi

Examples of jnr.ffi.Pointer


            byReference.unmarshal(pointer, 0);
        }
    }

    public Pointer toNative(ByReference value, ToNativeContext context) {
        Pointer memory =  Memory.allocate(runtime, value.nativeSize(runtime));
        if (ParameterFlags.isIn(flags)) {
            value.marshal(memory, 0);
        }
        return memory;
    }
View Full Code Here


            setNamePointer(null);
            setNameLen(0);
            return;
        }
        byte[] nameBytes = name.getBytes(Charset.forName("US-ASCII"));
        Pointer p = Runtime.getSystemRuntime().getMemoryManager().allocateTemporary(nameBytes.length, true);
        p.put(0, nameBytes, 0, nameBytes.length);
        setNamePointer(p);
        setNameLen(nameBytes.length);
    }
View Full Code Here

        setNamePointer(p);
        setNameLen(nameBytes.length);
    }

    public String getName() {
        Pointer ptr = getNamePointer();
        if (ptr == null) {
            return null;
        }
        return ptr.getString(0, getNameLen(), Charset.forName( "US-ASCII" ));
    }
View Full Code Here

        int totalSize = 0;
        for (int i = 0; i < dataLengths.length; ++i) {
            totalSize += posix.socketMacros().CMSG_SPACE(dataLengths[i]);
        }

        Pointer ptr = posix.getRuntime().getMemoryManager().allocateDirect(totalSize);

        int offset = 0;
        for (int i = 0; i < dataLengths.length; ++i) {
            int eachLen = posix.socketMacros().CMSG_SPACE(dataLengths[i]);
            CmsgHdr each = allocateCmsgHdrInternal(posix, ptr.slice(offset, eachLen), eachLen);
            cmsgs[i] = each;
            offset += eachLen;
        }

        setControlPointer(ptr);
View Full Code Here

        List<CmsgHdr> control = new ArrayList<CmsgHdr>();

        int offset = 0;

        Pointer controlPtr = getControlPointer();

        while (offset < len) {
            CmsgHdr each = allocateCmsgHdrInternal(posix, controlPtr.slice(offset), -1);
            offset += each.getLen();
            control.add(each);
        }

        return control.toArray(new CmsgHdr[control.size()]);
View Full Code Here

        return control.toArray(new CmsgHdr[control.size()]);
    }

    public void setIov(ByteBuffer[] buffers) {
        Pointer iov = Runtime.getSystemRuntime().getMemoryManager().allocateDirect(BaseIovec.layout.size() * buffers.length);

        for (int i = 0; i < buffers.length; ++i) {
            Pointer eachIovecPtr = iov.slice(BaseIovec.layout.size() * i);
            BaseIovec eachIovec = new BaseIovec(posix, eachIovecPtr);
            eachIovec.set(buffers[i]);
        }

        setIovPointer(iov);
View Full Code Here

    public ByteBuffer[] getIov() {
        int len = getIovLen();

        ByteBuffer[] buffers = new ByteBuffer[len];

        Pointer iov = getIovPointer();

        for (int i = 0; i < len; ++i) {
            Pointer eachPtr = iov.slice(BaseIovec.layout.size() * i);
            BaseIovec eachIov = new BaseIovec(posix, eachPtr);
            buffers[i] = eachIov.get();
        }

        return buffers;
View Full Code Here

       
        int creationFlags = WindowsLibC.NORMAL_PRIORITY_CLASS | WindowsLibC.CREATE_UNICODE_ENVIRONMENT;
        WindowsProcessInformation processInformation = new WindowsProcessInformation(getRuntime());

        // FIXME: Convert envp into useful wideEnv
        Pointer wideEnv = null;
        byte[] programW = WindowsHelpers.toWString(program);
        byte[] cwd = WindowsHelpers.toWString(WindowsHelpers.escapePath(handler.getCurrentWorkingDirectory().toString()) +"\\");
        ByteBuffer commandW = ByteBuffer.wrap(WindowsHelpers.toWString(command));
        boolean returnValue = wlibc().CreateProcessW(programW, commandW,
                securityAttributes, securityAttributes,
View Full Code Here

        buf.append("msghdr {\n");
        buf.append("  msg_name=").append(getName()).append(",\n");
        buf.append("  msg_namelen=").append(getNameLen()).append(",\n");

        buf.append("  msg_iov=[\n");
        Pointer iovp = layout.msg_iov.get(this.memory);

        int numIov = getIovLen();
        for (int i = 0; i < numIov; ++i) {
            Pointer eachp = iovp.slice(i * BaseIovec.layout.size());
            buf.append(new BaseIovec(posix, eachp).toString("    "));
            if (i < (numIov - 1)) {
                buf.append(",\n");
            } else {
                buf.append("\n");
View Full Code Here

        buf.append("msghdr {\n");
        buf.append("  msg_name=").append(getName()).append(",\n");
        buf.append("  msg_namelen=").append(getNameLen()).append(",\n");

        buf.append("  msg_iov=[\n");
        Pointer iovp = layout.msg_iov.get(this.memory);

        int numIov = getIovLen();
        for (int i = 0; i < numIov; ++i) {
            Pointer eachp = iovp.slice(i * BaseIovec.layout.size());
            buf.append(new BaseIovec(posix, eachp).toString("    "));
            if (i < (numIov - 1)) {
                buf.append(",\n");
            } else {
                buf.append("\n");
View Full Code Here

TOP

Related Classes of jnr.ffi.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.