User's Manual

51
/* Read the function */
k.net_command = NET_KEY_ACCESS;
k.command = READING_MODE;
smartlink(&k);
if (k.status != ST_OK) {
printf("Error in READING_MODE\n");
exit(EXIT_FAILURE);
}
/* Copy data in buffer */
memcpy(my_func_data,k.data,DATA_LENGTH);
memcpy(my_func_data + DATA_LENGTH,k.ext_data,EXTENDED_DATA_LENGTH);
/* If the function pointer */
my_func_ptr = (my_func_t*)my_func_data;
/* Calls function */
result = my_func_ptr(2,3);
if (result != 6) {
printf("Error in function result\n");
exit(EXIT_FAILURE);
}
printf("Result of the stored function %d\n",result);
/* Close */
k.net_command = NET_KEY_CLOSE;
smartlink(&k);
if (k.status != ST_OK) {
printf("Error in NET_KEY_CLOSE\n");
exit(EXIT_FAILURE);
}
return EXIT_SUCCESS;
}
10.3.4 Example 5 – Control of the DLL checksum
This example shows how to calculate and control a simple checksum of the SMARTLINK.DLL file
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
FILE* f;
int c;
unsigned checksum;
/* Initialize the checksum */
checksum = 0;
/* Compute the checksum of the DLL */
f = fopen("skeylink.dll","rb");
if (!f) {
printf("Error opening the DLL\n");
exit(EXIT_FAILURE);
}
c = fgetc(f);
while (c != EOF) {
checksum += c;
c = fgetc(f);
}
fclose(f);