[ xcsdsgn @ 28.09.2010. 14:16 ] @
Originalni fajl:


// CelikApi.h
//
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#ifndef WINAPI
#define WINAPI __stdcall
#endif

#ifndef EID_API
#define EID_API
#endif

//
// Constants
//

// Size of all UTF-8 fields in bytes

const int EID_MAX_DocRegNo = 9;
const int EID_MAX_IssuingDate = 10;
const int EID_MAX_ExpiryDate = 10;
const int EID_MAX_IssuingAuthority = 30;

const int EID_MAX_PersonalNumber = 13;
const int EID_MAX_Surname = 60;
const int EID_MAX_GivenName = 40;
const int EID_MAX_ParentGivenName = 25;
const int EID_MAX_Sex = 2;
const int EID_MAX_PlaceOfBirth = 25;
const int EID_MAX_StateOfBirth = 25;
const int EID_MAX_DateOfBirth = 10;
const int EID_MAX_CommunityOfBirth = 25;

const int EID_MAX_State = 3;
const int EID_MAX_Community = 25;
const int EID_MAX_Place = 25;
const int EID_MAX_Street = 36;
const int EID_MAX_HouseNumber = 5;
const int EID_MAX_HouseLetter = 2;
const int EID_MAX_Entrance = 3;
const int EID_MAX_Floor = 3;
const int EID_MAX_ApartmentNumber = 6;

const int EID_MAX_Portrait = 7700;

//
// Function return values
//

const int EID_OK = 0;
const int EID_E_GENERAL_ERROR = -1;
const int EID_E_INVALID_PARAMETER = -2;
const int EID_E_VERSION_NOT_SUPPORTED = -3;
const int EID_E_NOT_INITIALIZED = -4;
const int EID_E_UNABLE_TO_EXECUTE = -5;
const int EID_E_READER_ERROR = -6;
const int EID_E_CARD_MISSING = -7;
const int EID_E_CARD_UNKNOWN = -8;
const int EID_E_CARD_MISMATCH = -9;
const int EID_E_UNABLE_TO_OPEN_SESSION = -10;
const int EID_E_DATA_MISSING = -11;
const int EID_E_CARD_SECFORMAT_CHECK_ERROR = -12;
const int EID_E_SECFORMAT_CHECK_CERT_ERROR = -13;

//
// Structures
//

// NOTE: char arrays DO NOT have zero char at the end

typedef struct tagEID_DOCUMENT_DATA
{
char docRegNo[EID_MAX_DocRegNo];
int docRegNoSize;
char issuingDate[EID_MAX_IssuingDate];
int issuingDateSize;
char expiryDate[EID_MAX_ExpiryDate];
int expiryDateSize;
char issuingAuthority[EID_MAX_IssuingAuthority];
int issuingAuthoritySize;
} EID_DOCUMENT_DATA, *PEID_DOCUMENT_DATA;

typedef struct tagEID_FIXED_PERSONAL_DATA
{
char personalNumber[EID_MAX_PersonalNumber];
int personalNumberSize;
char surname[EID_MAX_Surname];
int surnameSize;
char givenName[EID_MAX_GivenName];
int givenNameSize;
char parentGivenName[EID_MAX_ParentGivenName];
int parentGivenNameSize;
char sex[EID_MAX_Sex];
int sexSize;
char placeOfBirth[EID_MAX_PlaceOfBirth];
int placeOfBirthSize;
char stateOfBirth[EID_MAX_StateOfBirth];
int stateOfBirthSize;
char dateOfBirth[EID_MAX_DateOfBirth];
int dateOfBirthSize;
char communityOfBirth[EID_MAX_CommunityOfBirth];
int communityOfBirthSize;
} EID_FIXED_PERSONAL_DATA, *PEID_FIXED_PERSONAL_DATA;

typedef struct tagEID_VARIABLE_PERSONAL_DATA
{
char state[EID_MAX_State];
int stateSize;
char community[EID_MAX_Community];
int communitySize;
char place[EID_MAX_Place];
int placeSize;
char street[EID_MAX_Street];
int streetSize;
char houseNumber[EID_MAX_HouseNumber];
int houseNumberSize;
char houseLetter[EID_MAX_HouseLetter];
int houseLetterSize;
char entrance[EID_MAX_Entrance];
int entranceSize;
char floor[EID_MAX_Floor];
int floorSize;
char apartmentNumber[EID_MAX_ApartmentNumber];
int apartmentNumberSize;
} EID_VARIABLE_PERSONAL_DATA, *PEID_VARIABLE_PERSONAL_DATA;

typedef struct tagEID_PORTRAIT
{
BYTE portrait[EID_MAX_Portrait];
int portraitSize;
} EID_PORTRAIT, *PEID_PORTRAIT;


//
// Functions
//
EID_API int WINAPI EidStartup(int nApiVersion);
EID_API int WINAPI EidCleanup();

EID_API int WINAPI EidBeginRead(LPCSTR szReader);
EID_API int WINAPI EidEndRead();

EID_API int WINAPI EidReadDocumentData(PEID_DOCUMENT_DATA pData);
EID_API int WINAPI EidReadFixedPersonalData(PEID_FIXED_PERSONAL_DATA pData);
EID_API int WINAPI EidReadVariablePersonalData(PEID_VARIABLE_PERSONAL_DATA pData);
EID_API int WINAPI EidReadPortrait(PEID_PORTRAIT pData);


#ifdef __cplusplus
};
#endif
[ orfej78 @ 17.07.2017. 07:55 ] @
Code:


{******************************************************************}
{                                                                  }
{ Borland Delphi Runtime Library                                   }
{ Celik interface unit                                             }
{                                                                  }
{ The original file is: CelikApi.h                                 }
{ The original Pascal code is: CelikApi.pas                        }
{ The initial developer of the Pascal code is Davor Nikolic        }
{ (davornik@yahoo.com).                                            }
{                                                                  }
{ h. file obtained through:                                        }
{ MUP RS official site                                             }
{                                                                  }
{ The contents of this file are used with permission, subject to   }
{ the Mozilla Public License Version 1.1 (the "License"); you may  }
{ not use this file except in compliance with the License. You may }
{ obtain a copy of the License at                                  }
{ http://www.mozilla.org/MPL/MPL-1.1.html                          }
{                                                                  }
{ Software distributed under the License is distributed on an      }
{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or   }
{ implied. See the License for the specific language governing     }
{ rights and limitations under the License.                        }
{                                                                  }
{******************************************************************}

unit CelikApi;

interface

uses
  Windows;

{$IFDEF CelikApi_LINKONREQUEST}
  {$DEFINE CelikApi_DYNLINK}
{$ENDIF}

// Constants

const

// Option identifiers, used in function EidSetOption
  EID_O_KEEP_CARD_CLOSED: Integer     = 1;

// Certificate types, used in function EidReadCertificate
  EID_Cert_MoiIntermediateCA: Integer = 1;
  EID_Cert_User1: Integer             = 2;
  EID_Cert_User2: Integer             = 3;

// Block types, used in function EidVerifySignature
  EID_SIG_CARD: Integer               = 1;
  EID_SIG_FIXED: Integer              = 2;
  EID_SIG_VARIABLE: Integer           = 3;
  EID_SIG_PORTRAIT: Integer           = 4;

// For new card version EidVerifySignature function will return EID_E_UNABLE_TO_EXECUTE for
// parameter EID_SIG_PORTRAIT. Portrait is in new cards part of EID_SIG_FIXED. To determine
// the card version use second parameter of function EidBeginRead

// Function return values
  EID_OK: Integer                            =  0;
  EID_E_GENERAL_ERROR: Integer               = -1;
  EID_E_INVALID_PARAMETER: Integer           = -2;
  EID_E_VERSION_NOT_SUPPORTED: Integer       = -3;
  EID_E_NOT_INITIALIZED: Integer             = -4;
  EID_E_UNABLE_TO_EXECUTE: Integer           = -5;
  EID_E_READER_ERROR: Integer                = -6;
  EID_E_CARD_MISSING: Integer                = -7;
  EID_E_CARD_UNKNOWN: Integer                = -8;
  EID_E_CARD_MISMATCH: Integer               = -9;
  EID_E_UNABLE_TO_OPEN_SESSION: Integer      = -10;
  EID_E_DATA_MISSING: Integer                = -11;
  EID_E_CARD_SECFORMAT_CHECK_ERROR: Integer  = -12;
  EID_E_SECFORMAT_CHECK_CERT_ERROR: Integer  = -13;
  EID_E_INVALID_PASSWORD: Integer            = -14;
  EID_E_PIN_BLOCKED: Integer                 = -15;

// Structures
// NOTE: char arrays DO NOT have zero char at the end

type
  PEID_DOCUMENT_DATA = ^EID_DOCUMENT_DATA;
  EID_DOCUMENT_DATA = record
    docRegNo:             array[0..8] of AnsiChar;
    docRegNoSize:         Integer;
    documentType:         array[0..1] of AnsiChar;
    documentTypeSize:     Integer;
    issuingDate:          array[0..9] of AnsiChar;
    issuingDateSize:      Integer;
    expiryDate:           array[0..9] of AnsiChar;
    expiryDateSize:       Integer;
    issuingAuthority:     array[0..99] of AnsiChar;
    issuingAuthoritySize: Integer;
  end;

type
  PEID_FIXED_PERSONAL_DATA = ^EID_FIXED_PERSONAL_DATA;
  EID_FIXED_PERSONAL_DATA = record
    personalNumber:       array[0..12] of AnsiChar;
    personalNumberSize:   Integer;
    surname:              array[0..199] of AnsiChar;
    surnameSize:          Integer;
    givenName:            array[0..199] of AnsiChar;
    givenNameSize:        Integer;
    parentGivenName:      array[0..199] of AnsiChar;
    parentGivenNameSize:  Integer;
    sex:                  array[0..1] of AnsiChar;
    sexSize:              Integer;
    placeOfBirth:         array[0..199] of AnsiChar;
    placeOfBirthSize:     Integer;
    stateOfBirth:         array[0..199] of AnsiChar;
    stateOfBirthSize:     Integer;
    dateOfBirth:          array[0..9] of AnsiChar;
    dateOfBirthSize:      Integer;
    communityOfBirth:     array[0..199] of AnsiChar;
    communityOfBirthSize: Integer;
  end;

type
  PEID_VARIABLE_PERSONAL_DATA = ^EID_VARIABLE_PERSONAL_DATA;
  EID_VARIABLE_PERSONAL_DATA = record
    state:               array[0..99] of AnsiChar;
    stateSize:           Integer;
    community:           array[0..199] of AnsiChar;
    communitySize:       Integer;
    place:               array[0..199] of AnsiChar;
    placeSize:           Integer;
    street:              array[0..199] of AnsiChar;
    streetSize:          Integer;
    houseNumber:         array[0..19] of AnsiChar;
    houseNumberSize:     Integer;
    houseLetter:         array[0..7] of AnsiChar;
    houseLetterSize:     Integer;
    entrance:            array[0..9] of AnsiChar;
    entranceSize:        Integer;
    floor:               array[0..5] of AnsiChar;
    floorSize:           Integer;
    apartmentNumber:     array[0..11] of AnsiChar;
    apartmentNumberSize: Integer;
    addressDate:         array[0..9] of AnsiChar;
    addressDateSize:     Integer;
    addressLabel:        array[0..59] of AnsiChar;
    addressLabelSize:    Integer;
  end;

type
  PEID_PORTRAIT = ^EID_PORTRAIT;
  EID_PORTRAIT = record
    portrait:     array[0..7699] of Byte;
    portraitSize: Integer;
  end;

type
  PEID_CERTIFICATE = ^EID_CERTIFICATE;
  EID_CERTIFICATE = record
    certificate:     array[0..2047] of Byte;
    certificateSize: Integer;
  end;

// Functions

{$IFDEF CelikApi_DYNLINK}  
  TEidSetOption = function(nOptionID: Integer; nOptionValue: UINT_PTR): Integer; stdcall;
  TEidStartup = function(nApiVersion: Integer): Integer; stdcall;
  TEidCleanup = function: Integer; stdcall;
  TEidBeginRead = function(const szReader: PAnsiChar; pnCardVersion: PInteger = nil): Integer; stdcall;
  TEidEndRead = function: Integer; stdcall;
  TEidReadDocumentData = function(var pData: EID_DOCUMENT_DATA): Integer; stdcall;
  TEidReadFixedPersonalData = function(var pData: EID_FIXED_PERSONAL_DATA): Integer; stdcall;
  TEidReadVariablePersonalData = function(var pData: EID_VARIABLE_PERSONAL_DATA): Integer; stdcall;
  TEidReadPortrait = function(var pData: EID_PORTRAIT): Integer; stdcall;
  TEidReadCertificate = function(var pData: EID_CERTIFICATE; certificateType: Integer): Integer; stdcall;
  TEidChangePassword = function(const szOldPassword: PAnsiChar; const szNewPassword: PAnsiChar; var pnTriesLeft: Integer): Integer; stdcall;
  TEidVerifySignature = function(nSignatureID: UINT): Integer; stdcall;

{$ELSE}
  function EidSetOption(nOptionID: Integer; nOptionValue: UINT_PTR): Integer; stdcall; 
  function EidStartup(nApiVersion: Integer): Integer; stdcall;
  function EidCleanup: Integer; stdcall;
  function EidBeginRead(const szReader: PAnsiChar; pnCardVersion: PInteger = nil): Integer; stdcall;
  function EidEndRead: Integer; stdcall; 
  function EidReadDocumentData(var pData: EID_DOCUMENT_DATA): Integer; stdcall;
  function EidReadFixedPersonalData(var pData: EID_FIXED_PERSONAL_DATA): Integer; stdcall;
  function EidReadVariablePersonalData(var pData: EID_VARIABLE_PERSONAL_DATA): Integer; stdcall;
  function EidReadPortrait(var pData: EID_PORTRAIT): Integer; stdcall;
  function EidReadCertificate(var pData: EID_CERTIFICATE; certificateType: Integer): Integer; stdcall;
  function EidChangePassword(const szOldPassword: PAnsiChar; const szNewPassword: PAnsiChar; var pnTriesLeft: Integer): Integer; stdcall;
  function EidVerifySignature(nSignatureID: UINT): Integer; stdcall;
  
{$ENDIF}

{$IFDEF CelikApi_DYNLINK}
var
   EidSetOption:                  TEidSetOption = nil;
   EidStartup:                    TEidStartup = nil;
   EidCleanup:                    TEidCleanup = nil;
   EidBeginRead:                  TEidBeginRead = nil;
   EidEndRead:                    TEidEndRead = nil;
   EidReadDocumentData:           TEidReadDocumentData = nil;
   EidReadFixedPersonalData:      TEidReadFixedPersonalData = nil;
   EidReadVariablePersonalData:   TEidReadVariablePersonalData = nil;
   EidReadPortrait:               TEidReadPortrait = nil;
   EidReadCertificate:            TEidReadCertificate = nil;
   EidChangePassword:             TEidChangePassword = nil;
   EidVerifySignature:            TEidVerifySignature = nil;
   bPCSCLoaded: Boolean; 
   hCelikApiDLL: THandle;

   { load PC/SC DLL, pass variable for handle to unload DLL later }
   function PCSCLoadDLL: Boolean;
   {$EXTERNALSYM PCSCLoadDLL}
   procedure PCSCUnloadDLL;
   {$EXTERNALSYM PCSCUnloadDLL}
{$ENDIF}

implementation

{$IFDEF CelikApi_DYNLINK}
procedure PCSCUnloadDLL;
begin
   if hCelikApiDLL <> 0 then
      FreeLibrary(hCelikApiDLL);
end;

function PCSCLoadDLL: Boolean;
begin

   if hCelikApiDLL = 0 then
      hCelikApiDLL := LoadLibrary('CelikApi.dll');

   if hCelikApiDLL = 0 then
   begin
      Result := False;
      Exit;
   end;
   
   @EidSetOption                 := GetProcAddress(hCelikApiDLL, 'EidSetOption');
   @EidStartup                   := GetProcAddress(hCelikApiDLL, 'EidStartup');
   @EidCleanup                   := GetProcAddress(hCelikApiDLL, 'EidCleanup');
   @EidBeginRead                 := GetProcAddress(hCelikApiDLL, 'EidBeginRead');
   @EidEndRead                   := GetProcAddress(hCelikApiDLL, 'EidEndRead');
   @EidReadDocumentData          := GetProcAddress(hCelikApiDLL, 'EidReadDocumentData');
   @EidReadFixedPersonalData     := GetProcAddress(hCelikApiDLL, 'EidReadFixedPersonalData');
   @EidReadVariablePersonalData  := GetProcAddress(hCelikApiDLL, 'EidReadVariablePersonalData');
   @EidReadPortrait              := GetProcAddress(hCelikApiDLL, 'EidReadPortrait');
   @EidReadCertificate           := GetProcAddress(hCelikApiDLL, 'EidReadCertificate');
   @EidChangePassword            := GetProcAddress(hCelikApiDLL, 'EidChangePassword');
   @EidVerifySignature           := GetProcAddress(hCelikApiDLL, 'EidVerifySignature');

   Result := True;

end;
{$ELSE}
const
   CelikApiDLL = 'CelikApi.dll';

   function EidSetOption;                     external CelikApiDLL name 'EidSetOption';
   function EidStartup;                       external CelikApiDLL name 'EidStartup';
   function EidCleanup;                       external CelikApiDLL name 'EidCleanup';
   function EidBeginRead;                     external CelikApiDLL name 'EidBeginRead';
   function EidEndRead;                       external CelikApiDLL name 'EidEndRead';
   function EidReadDocumentData;              external CelikApiDLL name 'EidReadDocumentData';
   function EidReadFixedPersonalData;         external CelikApiDLL name 'EidReadFixedPersonalData';
   function EidReadVariablePersonalData;      external CelikApiDLL name 'EidReadVariablePersonalData';
   function EidReadPortrait;                  external CelikApiDLL name 'EidReadPortrait';
   function EidReadCertificate;               external CelikApiDLL name 'EidReadCertificate';
   function EidChangePassword;                external CelikApiDLL name 'EidChangePassword';
   function EidVerifySignature;               external CelikApiDLL name 'EidVerifySignature';
   
{$ENDIF}

{$IFDEF CelikApi_DYNLINK}
initialization
   bPCSCLoaded := PCSCLoadDLL;

finalization
   PCSCUnloadDll;
{$ENDIF}

end.


[ savkic @ 17.07.2017. 09:14 ] @
Ako si ovo sad radio, verovatno nisi znao ali ovo već imamo (potraži poruke od pre neku godinu) zajedno sa primerima. U svakom slučaju pogledaj, možda i tebi bude korisno.