Skip to content

Commit

Permalink
Defined lib.ts (ffi library from .dll)
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Aug 30, 2021
1 parent 1034b25 commit 1a77ad2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
29 changes: 29 additions & 0 deletions models/saobracajna/lib.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import ffi from "ffi-napi";
import API_TYPES, { refTypeOf } from "./types";
import { SAOBRACAJNAAPI_DLL_PATH } from "../../util/get-saobracajnaApi-path";

export const createSaobracajnaApiLib = () =>
ffi.Library(SAOBRACAJNAAPI_DLL_PATH, {
sdStartup: ["long", ["long"]],
sdCleanup: ["long", []],
GetReaderName: ["long", ["long", "char*", "long*"]],
SelectReader: ["long", ["char*"]],
sdProcessNewCard: ["long", []],
sdReadDocumentData: ["long", [refTypeOf(API_TYPES.SD_DOCUMENT_DATA)]],
sdReadVehicleData: ["long", [refTypeOf(API_TYPES.SD_VEHICLE_DATA)]],
sdReadPersonalData: ["long", [refTypeOf(API_TYPES.SD_PERSONAL_DATA)]],
sdReadRegistration: [
"long",
[refTypeOf(API_TYPES.SD_REGISTRATION_DATA), "long"],
],

// long sdStartup(long version);
// long sdCleanup();
// long GetReaderName(long index, char* readerName, long* nameSize);
// long SelectReader(char* reader);
// long sdProcessNewCard();
// long sdReadDocumentData(SD_DOCUMENT_DATA* data);
// long sdReadVehicleData(SD_VEHICLE_DATA* data);
// long sdReadPersonalData(SD_PERSONAL_DATA* data);
// long sdReadRegistration(SD_REGISTRATION_DATA* data, long index);
});
9 changes: 9 additions & 0 deletions util/get-saobracajnaApi-path.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import path from "path";

export const SAOBRACAJNAAPI_DLL_PATH = path.resolve(
__dirname,
"..",
// "..", // because of dist folder
"saobracajnaAPI",
"eVehicleRegistrationAPI.dll"
);

0 comments on commit 1a77ad2

Please sign in to comment.