From 7e4e14dde5fbfade46311fbf75386d5371062d7d Mon Sep 17 00:00:00 2001 From: gcontini <1121667+gcontini@users.noreply.github.com> Date: 周六, 24 10月 2020 19:59:33 +0800 Subject: [PATCH] review of disk strategy linux --- src/library/os/os.h | 52 +++++++++++++++++++++------------------------------- 1 files changed, 21 insertions(+), 31 deletions(-) diff --git a/src/library/os/os.h b/src/library/os/os.h index 741efe5..36a1c69 100644 --- a/src/library/os/os.h +++ b/src/library/os/os.h @@ -2,53 +2,40 @@ * os-dependent.hpp * * Created on: Mar 29, 2014 - * + * */ #ifndef OS_DEPENDENT_HPP_ #define OS_DEPENDENT_HPP_ -#ifdef __cplusplus -extern "C" { -#endif - -#include "../base/base.h" #include <stddef.h> -//definition of size_t +#include <string.h> +#include <ctype.h> +#include <sys/types.h> +// definition of size_t #include <stdlib.h> +#include <vector> #ifdef __unix__ +#include <unistd.h> #include <stdbool.h> #endif -typedef enum { - NONE, VMWARE -} VIRTUALIZATION; - -typedef enum { - IFACE_TYPE_ETHERNET, IFACE_TYPE_WIRELESS -} IFACE_TYPE; +#include <licensecc/datatypes.h> +#include "../base/base.h" typedef struct { int id; - char description[1024]; - unsigned char mac_address[6]; - unsigned char ipv4_address[4]; - IFACE_TYPE type; -} OsAdapterInfo; - -typedef struct { - int id; - char device[255]; + char device[MAX_PATH]; unsigned char disk_sn[8]; + bool sn_initialized; char label[255]; + bool label_initialized; bool preferred; } DiskInfo; -FUNCTION_RETURN getAdapterInfos(OsAdapterInfo * adapterInfos, - size_t * adapter_info_size); -FUNCTION_RETURN getDiskInfos(DiskInfo * diskInfos, size_t * disk_info_size); +FUNCTION_RETURN getDiskInfos(std::vector<DiskInfo>& diskInfos); FUNCTION_RETURN getUserHomePath(char[MAX_PATH]); -FUNCTION_RETURN getCpuId(unsigned char identifier[6]); +FUNCTION_RETURN getModuleName(char buffer[MAX_PATH]); FUNCTION_RETURN getMachineName(unsigned char identifier[6]); /** * Get an identifier of the machine in an os specific way. @@ -69,11 +56,14 @@ * @return */ FUNCTION_RETURN getOsSpecificIdentifier(unsigned char identifier[6]); -VIRTUALIZATION getVirtualization(); -void os_initialize(); -#ifdef __cplusplus -} + +#ifdef _WIN32 +#define SETENV(VAR, VAL) _putenv_s(VAR, VAL); +#define UNSETENV(P) _putenv_s(P, ""); +#else +#define SETENV(VAR, VAL) setenv(VAR, VAL, 1); +#define UNSETENV(P) unsetenv(P); #endif #endif /* OS_DEPENDENT_HPP_ */ -- Gitblit v1.9.1