/*++

Copyright (c) 1996  Microsoft Corporation

Module Name:

    SCardSrv

Abstract:

    IDL source for SCardSrv.DLL. This in-process server (DLL)
    encapsulates the services oriented COM interfaces for the
    Smart Card Service Provider (SSP) ISO 7816 Services.
    
Author:

    Michael Gallagher (a-mgalla) 10/21/1996

Environment:

    Win32

Revision History:

    Mike Gallagher (a-mgalla) 2/4/1997
    Chris Dudley (cdudley) 4/11/1997
    Chris Dudley (cdudley) 7/7/1997

Notes:

    1. This file will be processed by the MIDL tool to produce
        the type library (SCardSrv.tlb) and marshalling code. A
        header file named SCardSrv.h will be generated by the
        MIDL compiler for the ATL CPP code to use.

    2. Rather than create separate IDL files for the C/C++, VB
        and Java languages, the decision has been made to create
        one IDL file that can be used by any language environment
        using standardized OLE Automation types.

    3. The #define'd constants in this MIDL file will NOT be
        registered into the type library! You will need to define
        these constants in your Visual Basic, Delphi, etc. code
        as needed unless the constant is not defined as a const
        variable in this IDL file. The constants will be defined
        for Java users. And, of course, the C/C++ coders can use
        the header file generated by the MIDL compiler as described
        above.

--*/


cpp_quote("//+-------------------------------------------------------------------------")
cpp_quote("//")
cpp_quote("//  Microsoft Smart Cards Support")
cpp_quote("//  Copyright (C) Microsoft Corporation, 1996.")
cpp_quote("//")
cpp_quote("//")
cpp_quote("// File: SCardSrv.h")
cpp_quote("//")
cpp_quote("//--------------------------------------------------------------------------")


cpp_quote("")
cpp_quote("//////////////////////////////////////////////////////////////////")
cpp_quote("//")
cpp_quote("// Imports")
cpp_quote("//")

#ifndef DO_NO_IMPORTS
    import "SspsIdl.idl";
#endif

interface ISCardISO7816;


cpp_quote("")
cpp_quote("//////////////////////////////////////////////////////////////////")
cpp_quote("//")
cpp_quote("// Constants and Types")
cpp_quote("//")

cpp_quote("#ifndef _NULL_DEFINED")
    cpp_quote("#define _NULL_DEFINED")
    #define NULL    0
cpp_quote("#endif // !_NULL_DEFINED")

cpp_quote("#ifndef _NULL_BYTE_DEFINED")
    cpp_quote("#define _NULL_BYTE_DEFINED")
    cpp_quote("#define NULL_BYTE    (0x00)")
    #define NULL_BYTE               (0x00)
cpp_quote("#endif  // !_NULL_BYTE_DEFINED")

//
// The following values are merely defined as default states for use
// here in this IDL file. They will NOT be bound into the type library
// for use.
//
// These codes are defined in \\nt\private\ispu\calais\ssps\inc\IsoCodes.h
// for use and redefinition, if wanted, in the sources of the SCardSrv.DLL.
//
//
#define ISO_OPEN_LOGICAL_CHANNEL    (0x00)
#define ISO_CLOSE_LOGICAL_CHANNEL   (0x80)

#define ISO_LOGICAL_CHANNEL_0       (0x00)
#define ISO_LOGICAL_CHANNEL_1       (0x01)
#define ISO_LOGICAL_CHANNEL_2       (0x02)
#define ISO_LOGICAL_CHANNEL_3       (0x03)
//
//


cpp_quote("")
cpp_quote("//////////////////////////////////////////////////////////////////")
cpp_quote("//")
cpp_quote("// ISCardISO7816 Interface Definition")
cpp_quote("//")

cpp_quote("#ifndef _LPSCARDISO7816_DEFINED")
cpp_quote("#define _LPSCARDISO7816_DEFINED")
    [
        object,
        uuid(53B6AA68-3F56-11D0-916B-00AA00C18068),
        dual,
        helpstring("ISCardISO7816 Interface"),
        //hidden,
        //restricted,       // prevent macro programming?
        //version(1.0),
        pointer_default(unique)
    ]
    interface ISCardISO7816 : IDispatch
    {
        // Include(s) -

        import "oaidl.idl";
                
        // Pointer(s) -

        typedef [unique] ISCardISO7816 *LPSCARDISO;
        typedef [unique] LPSCARDISO LPSCARDISO7816;
        
        // Methods -

        [id(0),
         helpstring("Write a record to the end of an EF of linear structure of location one of a cyclic structure")]
        HRESULT AppendRecord([in, defaultvalue(NULL_BYTE)] BYTE byRefCtrl, // currently selected EF
                             [in] LPBYTEBUFFER pData,
                             [in, out] LPSCARDCMD *ppCmd);

        [id(1),
         helpstring("Set part of an EF file content to its erased state sequentially")]
        HRESULT EraseBinary([in] BYTE byP1,
                            [in] BYTE byP2,
                            [in, defaultvalue(NULL)]LPBYTEBUFFER pData,
                            [in, out] LPSCARDCMD *ppCmd);

        [id(2),
         helpstring("Update the card after a GET CHALLENGE command serviced")]
        HRESULT ExternalAuthenticate([in,defaultvalue(NULL_BYTE)]BYTE byAlgorithmRef,
                                     [in, defaultvalue(NULL_BYTE)] BYTE bySecretRef,
                                     [in, defaultvalue(NULL)] LPBYTEBUFFER pChallenge,
                                     [in, out] LPSCARDCMD *ppCmd);

        [id(3),
         helpstring("Issue a challenge for use in a security related procedure")]
        HRESULT GetChallenge([in, defaultvalue(0)] LONG lBytesExpected,
                             [in, out] LPSCARDCMD *ppCmd);

        [id(4),
         helpstring("Retrieve a primitive data object")]
        HRESULT GetData([in] BYTE byP1,
                        [in] BYTE byP2,
                        [in, defaultvalue(0)] LONG lBytesToGet,
                        [in, out] LPSCARDCMD *ppCmd);

        [id(5),
         helpstring("Retrieve further data")]
        HRESULT GetResponse([in, defaultvalue(0)] BYTE byP1, //=0
                            [in, defaultvalue(0)] BYTE byP2, //=0
                            [in, defaultvalue(0)] LONG lDataLength, // =0
                            [in, out] LPSCARDCMD *ppCmd);

        [id(6),
         helpstring("Compute authentication data on card using challenge data sent to card")]
        HRESULT InternalAuthenticate([in, defaultvalue(NULL_BYTE)] BYTE byAlgorithmRef,
                                     [in, defaultvalue(NULL_BYTE)] BYTE bySecretRef,
                                     [in] LPBYTEBUFFER pChallenge,
                                     [in, defaultvalue(0)] LONG lReplyBytes,
                                     [in, out] LPSCARDCMD *ppCmd);

        [id(7),
         helpstring("Open or close a logical channel")]
        HRESULT ManageChannel([in, defaultvalue(ISO_CLOSE_LOGICAL_CHANNEL)] BYTE byChannelState,
                              [in, defaultvalue(ISO_LOGICAL_CHANNEL_0)] BYTE byChannel,
                              [in, out] LPSCARDCMD *ppCmd);

        [id(8),
         helpstring("Write a primitive data object")]
        HRESULT PutData([in] BYTE byP1,
                        [in] BYTE byP2,
                        [in] LPBYTEBUFFER pData,
                        [in, out] LPSCARDCMD *ppCmd);

        [id(9),
         helpstring("Read part of the content of an EF with transparent structure")]
        HRESULT ReadBinary([in] BYTE byP1,
                           [in] BYTE byP2,
                           [in, defaultvalue(0)] LONG lBytesToRead,
                           [in, out] LPSCARDCMD *ppCmd);

        [id(10),
         helpstring("Read contents of a specified record from an EF")]
        HRESULT ReadRecord([in, defaultvalue(NULL_BYTE)] BYTE byRecordId, // current record
                           [in] BYTE byRefCtrl,
                           [in, defaultvalue(0)] LONG lBytesToRead,
                           [in, out] LPSCARDCMD *ppCmd);

        [id(11),
         helpstring("Set a current file within a logical channel")]
        HRESULT SelectFile([in] BYTE byP1,
                           [in] BYTE byP2,
                           [in, defaultvalue(NULL)] LPBYTEBUFFER pData,
                           [in, defaultvalue(0)] LONG lBytesToRead,
                           [in, out] LPSCARDCMD *ppCmd);

        [id(12),
         helpstring("Change the default class ID used in command construction")]
        HRESULT SetDefaultClassId([in] BYTE byClass);

        [id(13),
         helpstring("Update bits already present in an EF with command APDU bits")]
        HRESULT UpdateBinary([in] BYTE byP1,
                             [in] BYTE byP2,
                             [in] LPBYTEBUFFER pData,
                             [in, out] LPSCARDCMD *ppCmd);

        [id(14),
         helpstring("Update a specific record with the APDU bits")]
        HRESULT UpdateRecord([in, defaultvalue(NULL_BYTE)] BYTE byRecordId, // current record
                             [in, defaultvalue(NULL_BYTE)] BYTE byRefCtrl, // first record in currently selected EF
                             [in] LPBYTEBUFFER pData,
                             [in, out] LPSCARDCMD *ppCmd);

        [id(15),
         helpstring("Compare the verification data sent to the card with its stored reference data")]
        HRESULT Verify([in, defaultvalue(NULL_BYTE)] BYTE byRefCtrl, // no info is given
                       [in, defaultvalue(NULL)] LPBYTEBUFFER pData,
                       [in, out] LPSCARDCMD *ppCmd);

        [id(16),
         helpstring("Write binary values into an EF")]
        HRESULT WriteBinary([in] BYTE byP1,
                            [in] BYTE byP2,
                            [in] LPBYTEBUFFER pData,
                            [in, out] LPSCARDCMD *ppCmd);

        [id(17),
         helpstring("Write to the specified record in an EF")]
        HRESULT WriteRecord([in, defaultvalue(NULL_BYTE)] BYTE byRecordId, // current record
                            [in, defaultvalue(NULL_BYTE)] BYTE byRefCtrl, // first record in currently selected EF
                            [in] LPBYTEBUFFER pData,
                            [in, out] LPSCARDCMD *ppCmd);
    };
cpp_quote("#endif //!_LPSCARDISO7816_DEFINED")


cpp_quote("")
cpp_quote("//////////////////////////////////////////////////////////////////")
cpp_quote("//")
cpp_quote("// SCardSrv Type Library")
cpp_quote("//")

[
    uuid(53B6AA61-3F56-11D0-916B-00AA00C18068),
    version(1.0),
    //hidden,
    //lcid(0x0409),     // general language
    helpstring("SCardSrv 1.0 Type Library")
]
library SCardSrvLib
{
    // NOTE: must include stdole2.tlb due to problems with the Alpha stdole32.tlb.
    // This will generate warnings during build, but compile is successful.
    #ifdef _ALPHA_
    importlib("stdole2.tlb");
    #else
    importlib("stdole32.tlb");
    #endif

    [
        uuid(53B6AA6C-3F56-11D0-916B-00AA00C18068),
        helpstring("SCardISO7816 Class"),
        //hidden,
        //licensed,
        aggregatable
    ]
    coclass CSCardISO7816
    {
        [default] interface ISCardISO7816;
    };
    
};
