Package com.sun.jna

Examples of com.sun.jna.NativeLong


    }

    @Override
    public List<GenericTerminal> list() throws ScardException {
        ShortByReference requiredSize = new ShortByReference();
        NativeLong status = win32PCSC.SCardListReadersW(new NativeLong(contextId), null, null, requiredSize);
        List<GenericTerminal> terminalsList;
        if (SCARD_E_NO_READERS_AVAILABLE == status.longValue()) {
            terminalsList = new ArrayList<GenericTerminal>(0);
            return Collections.unmodifiableList(terminalsList);
        }
        if (SCARD_S_SUCCESS != status.longValue()) {
            throw new PcScException(status.intValue());
        }
        short nativeOut[] = new short[requiredSize.getValue()];
        status = win32PCSC.SCardListReadersW(new NativeLong(contextId), null, nativeOut, requiredSize);
        if (SCARD_S_SUCCESS != status.longValue()) {
            throw new PcScException(status.intValue());
        }
        String[] readerNames=AStringUtilities.shortsToStrings(nativeOut);
        terminalsList = new ArrayList<GenericTerminal>(readerNames.length);

View Full Code Here


    }*/

    static long SCardConnect(long contextId, String readerName, int shareMode, int preferredProtocols) throws PcScException {
        NativeLongByReference phCard = new NativeLongByReference();
        IntByReference pdwActiveProtocol = new IntByReference();
        NativeLong status = win32PCSC.SCardConnectW(new NativeLong(contextId), new WString(readerName), shareMode, preferredProtocols,
                phCard,
                pdwActiveProtocol);
        if (SCARD_S_SUCCESS != status.longValue()) {
            throw new PcScException(status.intValue());
        }
        return phCard.getValue().longValue();
    }
View Full Code Here

    }

    static long SCardReconnect(long cardId, int shareMode, int preferredProtocols, int activationPolicy) throws PcScException {
        NativeLongByReference phCard = new NativeLongByReference();
        IntByReference pdwActiveProtocol = new IntByReference();
        NativeLong status = win32PCSC.SCardReconnect(new NativeLong(cardId), shareMode, preferredProtocols,
                activationPolicy,
                pdwActiveProtocol);
        if (SCARD_S_SUCCESS != status.longValue()) {
            throw new PcScException(status.intValue());
        }
        return phCard.getValue().longValue();
    }
View Full Code Here

            for (int i = 0; i < len; i++) {
                temp[i] = buf[ofs + i];
            }
            buf = temp;
        }
        NativeLong callStatus = win32PCSC.SCardTransmit(new NativeLong(cardId),
                pioSendPci,
                buf, len,
                (Win32PCSC.SCARD_IO_REQUEST) null,
                pbRecvBuffer, pcbRecvLength);
        if (SCARD_S_SUCCESS != callStatus.longValue()) {
            throw new PcScException("buf.length="+buf.length+", len="+len,callStatus.intValue());
        }
        byte out[] = new byte[pcbRecvLength.getValue()];
        for (int i = 0; i < pcbRecvLength.getValue(); i++) {
            out[i] = pbRecvBuffer[i];
        }
View Full Code Here

    static byte[] SCardGetAttrib(long cardId, int dwAttrId) throws PcScException {
        IntByReference pcbRecvLength = new IntByReference();
        byte pbRecvBuffer[] = new byte[200];
        pcbRecvLength.setValue(200);

        NativeLong callStatus = win32PCSC.SCardGetAttrib(new NativeLong(cardId),
                dwAttrId,
                pbRecvBuffer /*null*/, pcbRecvLength);
        if (SCARD_S_SUCCESS != callStatus.longValue()) {
            /*if (ERROR_NOT_SUPPORTED != callStatus.longValue()) {
                throw new PcScException("win32PCSC.SCardGetAttrib: attribute not supported",callStatus.intValue());
            }*/
        throw new PcScException("win32PCSC.SCardGetAttrib",callStatus.intValue());
        }
        byte out[] = new byte[pcbRecvLength.getValue()];
        for (int i = 0; i < pcbRecvLength.getValue(); i++) {
            out[i] = pbRecvBuffer[i];
        }
View Full Code Here

        IntByReference pdwState = new IntByReference();
        IntByReference pdwProtocol = new IntByReference();
        byte pbAtr[] = new byte[36];
        IntByReference pcbAtrLen = new IntByReference();
        pcbAtrLen.setValue(36);
        NativeLong callStatus = win32PCSC.SCardStatusW(new NativeLong(cardId), null, pcchReaderLen, pdwState, pdwProtocol, pbAtr, pcbAtrLen);
        if (SCARD_S_SUCCESS != callStatus.longValue()) {
            throw new PcScException(callStatus.intValue());
        }
        byte out[] = new byte[pcbAtrLen.getValue()];
        for (int i = 0; i < pcbAtrLen.getValue(); i++) {
            out[i] = pbAtr[i];
        }
View Full Code Here

        status[1]=(byte) pdwProtocol.getValue();
        return out;
    }

    static void SCardDisconnect(long cardId, int disposition) throws PcScException {
        NativeLong status = win32PCSC.SCardDisconnect(new NativeLong(cardId), disposition);
        if (SCARD_S_SUCCESS != status.longValue()) {
            throw new PcScException(status.intValue());
        }
    }
View Full Code Here

            readerStates[i].dwEventState = SCARD_STATE_UNAWARE;
            readerStates[i].cbAtr = 0;
            readerStates[i].rgbAtr = new byte[36];
        }

        NativeLong status = win32PCSC.SCardGetStatusChangeW(new NativeLong(contextId), (int) timeout, readerStates, readerNames.length);
        if (SCARD_S_SUCCESS != status.longValue()) {
            throw new PcScException(status.intValue());
        }
        int out[] = new int[readerNames.length];
        for (int i = 0; i < readerNames.length; i++) {
            out[i] = readerStates[i].dwEventState;
        }
View Full Code Here

    }

    static public /*synchronized*/ void initContext() throws ScardException {
  if (contextId == 0) {
            NativeLongByReference phContext = new NativeLongByReference();
            phContext.setValue(new NativeLong((long) 0));
            NativeLong status = nimpPcscDll.NimpSCardEstablishContext(SCARD_SCOPE_USER, Pointer.NULL, Pointer.NULL, phContext);
            Runtime.getRuntime().addShutdownHook(new Thread() {
                @Override
                public void run() {
                    if(0!=contextId)
                        nimpPcscDll.NimpSCardReleaseContext(new NativeLong(contextId));
                }
            });
            if (0 != status.longValue()) {
                throw new PcScException(status.intValue());
            }
      contextId = phContext.getValue().longValue();
  }
    }
View Full Code Here

    }

    @Override
    public List<GenericTerminal> list() throws ScardException {
        ShortByReference requiredSize = new ShortByReference();
        NativeLong status = nimpPcscDll.NimpSCardListReadersW(new NativeLong(contextId), null, null, requiredSize);
        List<GenericTerminal> terminalsList;
        if (SCARD_E_NO_READERS_AVAILABLE == status.longValue()) {
            terminalsList = new ArrayList<GenericTerminal>(0);
            return Collections.unmodifiableList(terminalsList);
        }
        if (SCARD_S_SUCCESS != status.longValue()) {
            throw new PcScException(status.intValue());
        }
        short nativeOut[] = new short[requiredSize.getValue()];
        status = nimpPcscDll.NimpSCardListReadersW(new NativeLong(contextId), null, nativeOut, requiredSize);
        if (SCARD_S_SUCCESS != status.longValue()) {
            throw new PcScException(status.intValue());
        }
        String[] readerNames=AStringUtilities.shortsToStrings(nativeOut);
        terminalsList = new ArrayList<GenericTerminal>(readerNames.length);

View Full Code Here

TOP

Related Classes of com.sun.jna.NativeLong

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.