remove dependency on APR library

This commit is contained in:
Livox-SDK
2020-12-04 22:01:38 +08:00
parent eb19d42ce4
commit 7cf759a760
564 changed files with 2880 additions and 181270 deletions
-7
View File
@@ -3,13 +3,6 @@ cmake_minimum_required(VERSION 3.0)
set(DEMO_NAME lidar_sample)
add_executable(${DEMO_NAME} main.c)
if (WIN32)
add_custom_command(TARGET ${DEMO_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${PROJECT_SOURCE_DIR}/third_party/apr/bin/libapr-1.dll"
$<TARGET_FILE_DIR:${DEMO_NAME}>)
endif()
target_link_libraries(${DEMO_NAME}
PRIVATE
${PROJECT_NAME}_static
-83
View File
@@ -30,8 +30,6 @@
#include <unistd.h>
#endif
#include <string.h>
#include <apr_general.h>
#include <apr_getopt.h>
#include "livox_sdk.h"
typedef enum {
@@ -236,88 +234,7 @@ void OnDeviceBroadcast(const BroadcastDeviceInfo *info) {
}
}
/** Set the program options.
* You can input the registered device broadcast code and decide whether to save the log file.
*/
int SetProgramOption(int argc, const char *argv[]) {
apr_status_t rv;
apr_pool_t *mp = NULL;
static const apr_getopt_option_t opt_option[] = {
/** Long-option, short-option, has-arg flag, description */
{ "code", 'c', 1, "Register device broadcast code" },
{ "log", 'l', 0, "Save the log file" },
{ "help", 'h', 0, "Show help" },
{ NULL, 0, 0, NULL },
};
apr_getopt_t *opt = NULL;
int optch = 0;
const char *optarg = NULL;
if (apr_initialize() != APR_SUCCESS) {
return -1;
}
if (apr_pool_create(&mp, NULL) != APR_SUCCESS) {
return -1;
}
rv = apr_getopt_init(&opt, mp, argc, argv);
if (rv != APR_SUCCESS) {
printf("Program options initialization failed.\n");
return -1;
}
/** Parse the all options based on opt_option[] */
bool is_help = false;
while ((rv = apr_getopt_long(opt, opt_option, &optch, &optarg)) == APR_SUCCESS) {
switch (optch) {
case 'c':
printf("Register broadcast code: %s\n", optarg);
char *sn_list = (char *)malloc(sizeof(char)*(strlen(optarg) + 1));
strncpy(sn_list, optarg, sizeof(char)*(strlen(optarg) + 1));
char *sn_list_head = sn_list;
sn_list = strtok(sn_list, "&");
int i = 0;
while (sn_list) {
strncpy(broadcast_code_list[i], sn_list, kBroadcastCodeSize);
sn_list = strtok(NULL, "&");
i++;
}
lidar_count = i;
free(sn_list_head);
sn_list_head = NULL;
break;
case 'l':
printf("Save the log file.\n");
SaveLoggerFile();
break;
case 'h':
printf(
" [-c] Register device broadcast code\n"
" [-l] Save the log file\n"
" [-h] Show help\n"
);
is_help = true;
break;
}
}
if (rv != APR_EOF) {
printf("Invalid options.\n");
}
apr_pool_destroy(mp);
mp = NULL;
apr_terminate();
if (is_help)
return 1;
return 0;
}
int main(int argc, const char *argv[]) {
/** Set the program options. */
if (SetProgramOption(argc, argv))
return 0;
printf("Livox SDK initializing.\n");
/** Initialize Livox-SDK. */
if (!Init()) {