Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Eikon.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include "bsapi.h"
- #include <stdlib.h>
- #include "C:\Users\Tadas\Desktop\magistrantura\Informaciniu technologiju sauga\I lab\1lab\Eikon\Eikon\\dirent.h"
- #include <string.h>
- /* Used to supress compiler warnings */
- #ifndef UNREFERENCED_PARAMETER
- #define UNREFERENCED_PARAMETER(param) (void)param
- #endif
- //Pirstu sablonu kiekis
- #define TSET_SIZE 16
- int sablonu_kiekis;
- //Sesijos kintamasis su irenginiu
- static ABS_CONNECTION conn = 0;
- //Sablonu nuorodu masyvas
- static ABS_BIR* tset[TSET_SIZE];
- //Operacijos "callback" funkcija
- static void BSAPI
- callback(const ABS_OPERATION* p_operation, ABS_DWORD msg, void* data)
- {
- UNREFERENCED_PARAMETER(p_operation);
- switch (msg) {
- /* These messages just inform us how the interactive operation
- * progresses. Typical applications do not need it. */
- case ABS_MSG_PROCESS_BEGIN:
- case ABS_MSG_PROCESS_END:
- break;
- /* On some platforms, the biometric operastion can be suspended
- * when other process acquires sensor for other operation. */
- case ABS_MSG_PROCESS_SUSPEND:
- printf(" operation has been suspended\n");
- break;
- case ABS_MSG_PROCESS_RESUME:
- printf(" operation has been resumed\n");
- break;
- /* Sometimes some info how the operation progresses is sent. */
- case ABS_MSG_PROCESS_PROGRESS:
- {
- ABS_PROCESS_PROGRESS_DATA* progress_data =
- (ABS_PROCESS_PROGRESS_DATA*)data;
- if (progress_data->Percentage <= 100) {
- printf(" operation in progress (%d%%)...\n",
- (int)progress_data->Percentage);
- }
- else {
- printf(" operation in progress...\n");
- }
- break;
- }
- case ABS_MSG_PROCESS_SUCCESS:
- printf(" success\n");
- break;
- case ABS_MSG_PROCESS_FAILURE:
- printf(" failure\n");
- break;
- /* Prompt messages should inform the user that he should do
- * something. */
- case ABS_MSG_PROMPT_SCAN:
- printf(" swipe the finger\n");
- break;
- case ABS_MSG_PROMPT_TOUCH:
- printf(" touch the sensor\n");
- break;
- case ABS_MSG_PROMPT_KEEP:
- printf(" keep finger on the sensor\n");
- break;
- case ABS_MSG_PROMPT_LIFT:
- printf(" lift your finger away from the sensor\n");
- break;
- case ABS_MSG_PROMPT_CLEAN:
- printf(" clean the sensor\n");
- break;
- /* Quality messages come if something went wrong. E.g. the user
- * did not scan his finger in the right way. */
- case ABS_MSG_QUALITY_CENTER_HARDER:
- printf(" bad quality: center and harder\n");
- break;
- case ABS_MSG_QUALITY_CENTER:
- printf(" bad quality: center\n");
- break;
- case ABS_MSG_QUALITY_TOO_LEFT:
- printf(" bad quality: too left\n");
- break;
- case ABS_MSG_QUALITY_TOO_RIGHT:
- printf(" bad quality: too right\n");
- break;
- case ABS_MSG_QUALITY_HARDER:
- printf(" bad quality: harder\n");
- break;
- case ABS_MSG_QUALITY_TOO_LIGHT:
- printf(" bad quality: too light\n");
- break;
- case ABS_MSG_QUALITY_TOO_DRY:
- printf(" bad quality: too dry\n");
- break;
- case ABS_MSG_QUALITY_TOO_SMALL:
- printf(" bad quality: too small\n");
- break;
- case ABS_MSG_QUALITY_TOO_SHORT:
- printf(" bad quality: too short\n");
- break;
- case ABS_MSG_QUALITY_TOO_HIGH:
- printf(" bad quality: too high\n");
- break;
- case ABS_MSG_QUALITY_TOO_LOW:
- printf(" bad quality: too low\n");
- break;
- case ABS_MSG_QUALITY_TOO_FAST:
- printf(" bad quality: too fast\n");
- break;
- case ABS_MSG_QUALITY_TOO_SKEWED:
- printf(" bad quality: too skewed\n");
- break;
- case ABS_MSG_QUALITY_TOO_DARK:
- printf(" bad quality: too dark\n");
- break;
- case ABS_MSG_QUALITY_BACKWARD:
- printf(" bad quality: backward movement detected\n");
- break;
- case ABS_MSG_QUALITY_JOINT:
- printf(" bad quality: joint detected\n");
- break;
- /* Navigation messages are sent only from ABSNavigate */
- case ABS_MSG_NAVIGATE_CHANGE:
- {
- ABS_NAVIGATION_DATA* msgdata = (ABS_NAVIGATION_DATA*)data;
- printf(" Navigation X = %d, Y = %d\n", (int)msgdata->DeltaX, (int)msgdata->DeltaY);
- break;
- }
- case ABS_MSG_NAVIGATE_CLICK:
- printf(" Navigation - CLICK\n");
- break;
- /* Real application would probably use some GUI to provide feedback
- * for user. On these messages the GUI dialog should be made vsiible
- * and invisible respectivelly. */
- case ABS_MSG_DLG_SHOW:
- case ABS_MSG_DLG_HIDE:
- break;
- /* Idle message can come only if flag ABS_OPERATION_FLAG_USE_IDLE
- * was specified in ABS_OPERATION::dwFlags (i.e. never in this sample).
- * If the flag is specified, this message comes very often, hence
- * giving the callback a chance to cancel the operation with
- * ABSCancelOperation() without long time delays. In multithreaded
- * applications, canceling the operation from another thread can be
- * better alternative. Consult BSAPI documentation for more info about
- * the topic. */
- case ABS_MSG_IDLE:
- break;
- }
- }
- static ABS_OPERATION op = {
- /* ID of the operation. We don't need to identify the operation in this
- * sample. When non-zero, the ID identifies the operation and allows it
- * to be canceled from any other thread with ABSCancelOperation(). */
- 0,
- /* Arbitrary pointer, which allows application to pass any data into
- * the callback. Not used in this sample. */
- NULL,
- /* Pointer to a simple callback implementation function. */
- callback,
- /* Timeout. For example, lets set timeout to 60 sec. Note the value does
- * not limit how long the operation (e.g. ABSVerify()) can take. The
- * timeout only specifies time the operation waits for user to put his
- * finger on a sensor. Zero would mean no timeout (i.e. the operation can
- * never end if user never puts his finger on the sensor.) */
- 60000,
- /* By default BSAPI places short time delays between sending some important
- * callback messages. The purpose of this is to guarantee that if multiple
- * messages come very closely in sequence, then the user still has enough
- * time to see all the messages and not just the lat one of the fast
- * sequence.
- *
- * For application developer, this simplifies callback implementation
- * which in most cases can be just showing an appropriate message in a
- * window or dialog.
- *
- * However the time delays are not needed when user can see all history
- * of the messages, e.g. (as in this sample) the messages are outputted
- * to standard output stream. Hence we disable the time delays with with
- * the flag ABS_OPERATION_FLAG_LL_CALLBACK here. */
- ABS_OPERATION_FLAG_LL_CALLBACK
- };
- static void klaida(void)
- {
- printf("KLAIDA\n");
- }
- // 5.4
- static void nauja_sesija(void)
- {
- //sukuriam nauja sesija su skaitytuvu
- ABS_STATUS res;
- res = ABSOpen("usb", &conn);
- if (res == ABS_STATUS_OK)
- {
- printf("Sukurta nauja sesija\n");
- }
- else
- {
- klaida();
- }
- }
- static int tikrinimas(void) {
- printf("tikrinam...\n");
- ABS_BIR * tmp_tset = NULL;
- ABS_STATUS res = ABSEnroll(conn, &op, &tmp_tset, 0);
- ABS_BOOL match;
- int rasta = 0;
- if (res == ABS_STATUS_OK)
- {
- //anspaudas sekmingai nuskaitytas galima toliau atlikti veiksmus
- for (int i = 0; i < sablonu_kiekis; i++) {
- res = ABSVerifyMatch(conn, tmp_tset, tset[i], &match, 0);
- if (match) {
- rasta = 1;
- break;
- }
- }
- }
- else
- {
- klaida();
- return 1;
- }
- if (rasta == 0)
- {
- printf("Pirstas nerastas!\n");
- return 1;
- }
- else {
- printf("Pirstas rastas...\n");
- return 0;
- }
- }
- static void siusti_zinute(char *tekstas, char *url, char *nr) {
- char text[500];
- snprintf(text, 500, "C:\\Users\\Tadas\\Desktop\\curl\\curl.exe \"http://%s&number=%s&text=%s\"", url, nr, tekstas);
- system(text);
- printf("Zinute issiusta! Zinutes tekstas: %s\n", tekstas);
- }
- static void failo_uzkrovimas(void)
- {
- int slot = 0;
- char path[300];
- DIR *dir;
- struct dirent *ent;
- FILE *f;
- if ((dir = opendir("D:\\sablonai")) != NULL) {
- while ((ent = readdir(dir)) != NULL) {
- if (strcmp(".", ent->d_name) == 0 || strcmp("..", ent->d_name) == 0)
- continue;
- sprintf_s(path, "D:\\sablonai\\%s", ent->d_name);
- f = fopen(path, "rb");
- fseek(f, 0, SEEK_END); // seek to end of file
- int size = ftell(f); // get current file pointer
- printf("Failo dydis: %d\n", size);
- fseek(f, 0, SEEK_SET); // seek back to beginning of file
- // proceed with allocating memory and reading the file
- tset[slot] = (ABS_BIR*)malloc(size);
- printf("KINTAMOJO TIKRINIMAS: %d\n", tset[slot]);
- if (tset[slot] == NULL) {
- printf("Negaliu issiskirti %ld baitu atminties\n", size);
- fclose(f);
- return;
- }
- if (fread(tset[slot], size, 1, f) != 1) {
- printf("Negaliu nuskaityti %ld baitu is failo '%s'\n", size, "D:\\sablonai\\sablonas.txt");
- free(tset[slot]);
- tset[slot] = NULL;
- fclose(f);
- return;
- }
- //nuskaitau faila i tset sablonu nuorodu masyva
- fread(tset[slot], size, 1, f);
- fclose(f);
- slot++;
- }
- }
- sablonu_kiekis = slot + 1;
- return;
- }
- static void pagalba(void)
- {
- printf("Komandas sarasas:\n");
- printf("'h ... Pagalba\n");
- printf(" x ... Iseiti\n");
- printf(" s ... Sukuriama nauja sesija su irenginiu\n");
- printf(" n ... Sukuriamas naujas pirsto antspaudo sablonas SLOT1 ir issaugojamas masyve\n");
- printf(" m ... Sukuriamas naujas pirsto antspaudo sablonas SLOT2 ir issaugojamas masyve\n");
- printf(" l ... Palyginamas naujas pirsto atspaudas su SLOT1 sablonu\n");
- printf(" o ... Palyginamas naujas pirsto atspaudas su visais pirstu antspaudu sablonais\n");
- printf(" c ... Atliekamas palyginimas tarp irasytu sablonu SLOT1 ir SLOT2\n");
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- char buffer[256];
- ABS_STATUS res;
- int baigti = 0;
- //Pries kvieciant kitas funkcijas, turim inicializuoti BSAPI biblioteka
- res = ABSInitialize();
- if (res == ABS_STATUS_OK) {
- printf("Inicializavom BSAPI\n\n");
- }
- //pagalba();
- nauja_sesija();
- failo_uzkrovimas();
- while (1) {
- if (tikrinimas() != 0) {
- siusti_zinute("Nesekmingas bandymas", "192.168.1.1/cgi-bin/sms_send?username=admin&password=Kaunastlt1!", "+37063729704");
- siusti_zinute("Nesekmingas bandymas", "192.168.1.1/cgi-bin/sms_send?username=admin&password=Kaunastlt1!", "+37063977973");
- //siunciam sms
- }
- else {
- //viskas gerai
- siusti_zinute("Sekmingas bandymas", "192.168.1.1/cgi-bin/sms_send?username=admin&password=Kaunastlt1!", "+37063729704");
- siusti_zinute("Sekmingas bandymas", "192.168.1.1/cgi-bin/sms_send?username=admin&password=Kaunastlt1!", "+37063977973");
- }
- }
- ABSTerminate();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement