modify OPTVAL::name type

This commit is contained in:
gb 2023-08-11 14:06:12 +08:00
parent ebbf7d2804
commit 8fda1b6d53
2 changed files with 6 additions and 6 deletions

View File

@ -2437,7 +2437,7 @@ OPTEN* hg_sane_middleware::get_control_enalbe_data(LPDEVINST dev, const SLAVEOP&
bzero(opt, size); bzero(opt, size);
opt->enabled = slave.enable_now; opt->enabled = slave.enable_now;
opt->name = slave.name; strcpy(opt->name, slave.name.c_str());
opt->master_count = 0; opt->master_count = 0;
for (size_t i = 0; i < master.size(); ++i) for (size_t i = 0; i < master.size(); ++i)
{ {
@ -2445,7 +2445,7 @@ OPTEN* hg_sane_middleware::get_control_enalbe_data(LPDEVINST dev, const SLAVEOP&
if (m == dev->cur_vals.end()) if (m == dev->cur_vals.end())
continue; continue;
opt->master[opt->master_count].name = master[i]; strcpy(opt->master[opt->master_count].name, master[i].c_str());
if (m->type == "string") if (m->type == "string")
{ {
opt->master[opt->master_count].data = malloc(m->val.length() + 4); opt->master[opt->master_count].data = malloc(m->val.length() + 4);
@ -2460,8 +2460,8 @@ OPTEN* hg_sane_middleware::get_control_enalbe_data(LPDEVINST dev, const SLAVEOP&
*((int*)opt->master[opt->master_count].data) = atoi(m->val.c_str()); *((int*)opt->master[opt->master_count].data) = atoi(m->val.c_str());
else else
*((double*)opt->master[opt->master_count].data) = atof(m->val.c_str()); *((double*)opt->master[opt->master_count].data) = atof(m->val.c_str());
opt->master_count++;
} }
opt->master_count++;
} }
return opt; return opt;

View File

@ -178,12 +178,12 @@ enum hg_control_code
}; };
typedef struct _opt_val typedef struct _opt_val
{ {
std::string name; // 配置项名称 char name[MAX_OPT_NAME_LEN];// 配置项名称
void* data; // 配置项数据 void* data; // 配置项数据
}OPTVAL; }OPTVAL;
typedef struct _opt_enabled // 配置项使能状态改变 typedef struct _opt_enabled // 配置项使能状态改变
{ {
std::string name; // 配置项名称 char name[MAX_OPT_NAME_LEN];// 配置项名称
int enabled; // 0 - 禁止1 - 可用 int enabled; // 0 - 禁止1 - 可用
int master_count; // 该配置项的依赖项数目 int master_count; // 该配置项的依赖项数目
OPTVAL master[1]; // 该配置项的依赖项当前值 OPTVAL master[1]; // 该配置项的依赖项当前值