// Path: src/main/java/org/pkcs11/jacknji11/CK_SESSION_INFO.java
// public class CK_SESSION_INFO {
// 
//     public static final long CKF_RW_SESSION     = 0x00000002;
//     public static final long CKF_SERIAL_SESSION = 0x00000004;
// 
//     /** Maps from long value to String description (variable name). */
//     private static final Map<Long, String> L2S = C.createL2SMap(CK_SESSION_INFO.class);
//     /**
//      * Convert long constant value to name.
//      * @param ckf value
//      * @return name
//      */
//     public static final String I2S(long ckf) { return C.l2s(L2S, "CKF", ckf); }
//     /**
//      * Convert flags to string.
//      * @param flags flags
//      * @return string format
//      */
//     public static String f2s(long flags) { return C.f2s(L2S, flags); }
// 
//     public long slotID;
//     public long state;
//     public long flags;
//     public long ulDeviceError;
// 
//     /** @return True, if the provided flag is set */
//     public boolean isFlagSet(long CKF_FLAG) {
//         return (flags & CKF_FLAG) != 0L;
//     }
//     
//     /** @return string */
//     public String toString() {
//         return String.format("(\n  slotID=0x%08x\n  state=0x%08x{%s}\n  flags=0x%08x{%s}\n  deviceError=%d\n)",
//                 slotID, state, CKS.L2S(state), flags, f2s(flags), ulDeviceError);
//     }
// }


import org.pkcs11.jacknji11.CK_SESSION_INFO;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.NativeLong;
import com.sun.jna.Structure;
/*
 * Copyright 2010-2011 Joel Hockey (joel.hockey@gmail.com). All rights reserved.
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package org.pkcs11.jacknji11.jna;




/**
 * JNA wrapper for PKCS#11 CK_SESSION_INFO struct.
 * @author Joel Hockey (joel.hockey@gmail.com)
 */
public class JNA_CK_SESSION_INFO extends Structure {
    public NativeLong slotID;
    public NativeLong state;
    public NativeLong flags;
    public NativeLong ulDeviceError;

    @Override
    protected List<String> getFieldOrder() {
        return Arrays.asList("slotID", "state", "flags", "ulDeviceError");
    }

    public JNA_CK_SESSION_INFO readFrom(CK_SESSION_INFO info) {
        slotID = new NativeLong(info.slotID);
        state = new NativeLong(info.state);
        flags = new NativeLong(info.flags);
        ulDeviceError = new NativeLong(info.ulDeviceError);
        return this;
    }

// Path: src/main/java/org/pkcs11/jacknji11/CK_SESSION_INFO.java
// public class CK_SESSION_INFO {
// 
//     public static final long CKF_RW_SESSION     = 0x00000002;
//     public static final long CKF_SERIAL_SESSION = 0x00000004;
// 
//     /** Maps from long value to String description (variable name). */
//     private static final Map<Long, String> L2S = C.createL2SMap(CK_SESSION_INFO.class);
//     /**
//      * Convert long constant value to name.
//      * @param ckf value
//      * @return name
//      */
//     public static final String I2S(long ckf) { return C.l2s(L2S, "CKF", ckf); }
//     /**
//      * Convert flags to string.
//      * @param flags flags
//      * @return string format
//      */
//     public static String f2s(long flags) { return C.f2s(L2S, flags); }
// 
//     public long slotID;
//     public long state;
//     public long flags;
//     public long ulDeviceError;
// 
//     /** @return True, if the provided flag is set */
//     public boolean isFlagSet(long CKF_FLAG) {
//         return (flags & CKF_FLAG) != 0L;
//     }
//     
//     /** @return string */
//     public String toString() {
//         return String.format("(\n  slotID=0x%08x\n  state=0x%08x{%s}\n  flags=0x%08x{%s}\n  deviceError=%d\n)",
//                 slotID, state, CKS.L2S(state), flags, f2s(flags), ulDeviceError);
//     }
// }


// Path: src/main/java/org/pkcs11/jacknji11/jna/JNA_CK_SESSION_INFO.java
import org.pkcs11.jacknji11.CK_SESSION_INFO;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.NativeLong;
import com.sun.jna.Structure;

/*
 * Copyright 2010-2011 Joel Hockey (joel.hockey@gmail.com). All rights reserved.
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package org.pkcs11.jacknji11.jna;




/**
 * JNA wrapper for PKCS#11 CK_SESSION_INFO struct.
 * @author Joel Hockey (joel.hockey@gmail.com)
 */
public class JNA_CK_SESSION_INFO extends Structure {
    public NativeLong slotID;
    public NativeLong state;
    public NativeLong flags;
    public NativeLong ulDeviceError;

    @Override
    protected List<String> getFieldOrder() {
        return Arrays.asList("slotID", "state", "flags", "ulDeviceError");
    }

    public JNA_CK_SESSION_INFO readFrom(CK_SESSION_INFO info) {
        slotID = new NativeLong(info.slotID);
        state = new NativeLong(info.state);
        flags = new NativeLong(info.flags);
        ulDeviceError = new NativeLong(info.ulDeviceError);
        return this;
    }

    public CK_SESSION_INFO writeTo(CK_SESSION_INFO info) {