Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "serialkey.h"
00015 #include <xsens/xsstring.h>
00016 #include <xsens/xscontrol.h>
00017 #include <stdio.h>
00018 #include <iostream>
00019
00020 #define SERIAL_KEY_SIZE 30
00021
00022 extern "C"
00023 int setSerialKey()
00024 {
00025 if (strcmp(SERIAL_KEY, "enter serial key here") == 0)
00026 {
00027 {
00028 char serialKey[256];
00029 FILE* fp;
00030 memset(serialKey, 0, 256);
00031 fp = fopen("serial.key", "r");
00032 if (fp)
00033 {
00034 size_t result = fread(serialKey, 1, SERIAL_KEY_SIZE, fp);
00035 fclose(fp);
00036
00037 if (result == SERIAL_KEY_SIZE)
00038 {
00039 if (XsControl::setSerialKey(serialKey))
00040 return 1;
00041 }
00042 }
00043 }
00044
00045
00046 std::cout << "Please enter valid serial key" << std::endl;
00047 std::cout << "If you built this example yourself you can enter the key in \"serialkey.h\"" << std::endl;
00048 char serialKey[256];
00049 std::cin.getline(serialKey, 256);
00050 XsString serial(serialKey);
00051
00052 if (XsControl::setSerialKey(serial))
00053 {
00054
00055 FILE* fp = fopen("serial.key", "w");
00056 fwrite(serial.c_str(), sizeof(char), serial.size(), fp);
00057 fclose(fp);
00058 return 1;
00059 }
00060 return 0;
00061 }
00062 return XsControl::setSerialKey(SERIAL_KEY);
00063 }
00064