授权管理使用共享内存支持主从模式
This commit is contained in:
7
platform/tool/CMakeLists.txt
Normal file
7
platform/tool/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
add_executable(hasp_verify_demo ${CMAKE_SOURCE_DIR}/platform/tool/hasp_verify_demo.c)
|
||||
target_link_libraries(hasp_verify_demo pthread rt hasp-tools)
|
||||
install(TARGETS hasp_verify_demo RUNTIME DESTINATION bin COMPONENT Program)
|
||||
|
||||
add_executable(hasp_monitor ${CMAKE_SOURCE_DIR}/platform/tool/hasp_monitor.c)
|
||||
target_link_libraries(hasp_monitor pthread rt hasp-tools)
|
||||
install(TARGETS hasp_monitor RUNTIME DESTINATION bin COMPONENT Program)
|
||||
41
platform/tool/hasp_monitor.c
Normal file
41
platform/tool/hasp_monitor.c
Normal file
@@ -0,0 +1,41 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "hasp_verify.h"
|
||||
|
||||
static void usage(char *cmd)
|
||||
{
|
||||
fprintf(stderr, "USAGE: %s [OPTIONS]\n", cmd);
|
||||
fprintf(stderr, " -f -- set feature id\n");
|
||||
fprintf(stderr, " -i -- set interval second\n");
|
||||
fprintf(stderr, " -h -- show help\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int opt;
|
||||
uint64_t interval_s = 0;
|
||||
uint64_t feature_id = 100;
|
||||
|
||||
while ((opt = getopt(argc, argv, "f:i:h")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
case 'i':
|
||||
interval_s = atoi(optarg);
|
||||
break;
|
||||
case 'f':
|
||||
feature_id = atoi(optarg);
|
||||
break;
|
||||
case 'h': /* fall through */
|
||||
default:
|
||||
usage(argv[0]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
hasp_monitor(feature_id, interval_s);
|
||||
|
||||
return 0;
|
||||
}
|
||||
41
platform/tool/hasp_verify_demo.c
Normal file
41
platform/tool/hasp_verify_demo.c
Normal file
@@ -0,0 +1,41 @@
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "hasp_verify.h"
|
||||
|
||||
static void usage(char *cmd)
|
||||
{
|
||||
fprintf(stderr, "USAGE: %s [OPTIONS]\n", cmd);
|
||||
fprintf(stderr, " -f -- set feature id\n");
|
||||
fprintf(stderr, " -h -- show help\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int opt;
|
||||
uint64_t feature_id = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "f:h")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
case 'f':
|
||||
feature_id = atoi(optarg);
|
||||
break;
|
||||
case 'h': /* fall through */
|
||||
default:
|
||||
usage(argv[0]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
hasp_verify(feature_id);
|
||||
|
||||
while (1)
|
||||
{
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user