From 8d405b265285c368df2e9cf1c14acee7532e0ee7 Mon Sep 17 00:00:00 2001 From: nancy.liao <huihui.liao@greentest.com.cn> Date: ćšć, 29 5æ 2025 18:14:38 +0800 Subject: [PATCH] Merge branch 'develop' of http://139.9.88.116:3000/r/module/open-license-manager into develop --- src/library/os/os.h | 68 ++++++++++++++++++++++----------- 1 files changed, 45 insertions(+), 23 deletions(-) diff --git a/src/library/os/os.h b/src/library/os/os.h index 7e0e3e7..36a1c69 100644 --- a/src/library/os/os.h +++ b/src/library/os/os.h @@ -2,46 +2,68 @@ * os-dependent.hpp * * Created on: Mar 29, 2014 - * Author: devel + * */ #ifndef OS_DEPENDENT_HPP_ #define OS_DEPENDENT_HPP_ -#ifdef __cplusplus -extern "C" { +#include <stddef.h> +#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 +#include <licensecc/datatypes.h> #include "../base/base.h" -#include <stddef.h> - -typedef enum { - NONE, VMWARE -} VIRTUALIZATION; typedef struct { int id; - char description[1024]; - unsigned char mac_address[6]; - unsigned char ipv4_address[4]; -} AdapterInfo; - -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(AdapterInfo * 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]); -VIRTUALIZATION getVirtualization(); -void os_initialize(); +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. + * In Linux it uses: + * http://stackoverflow.com/questions/328936/getting-a-unique-id-from-a-unix-like-system + * + * <ul> + * <li>Dbus if available</li> + * </ul> + * Can be used as a fallback in case no other methods are available. + * Windows: + * HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\ CurrentVersion\ProductId + * http://sowkot.blogspot.it/2008/08/generating-unique-keyfinger-print-for.html + * http://stackoverflow.com/questions/2842116/reliable-way-of-generating-unique-hardware-id + * + * + * @param identifier + * @return + */ +FUNCTION_RETURN getOsSpecificIdentifier(unsigned char identifier[6]); -#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