op_ici_attr_set_int32()
摘要
为指定 ICI 中的 32 位整数属性赋值。
语法
op_ici_attr_set_int32 (iciptr, attr_name, value)
| 参数 | 类型 | 说明 |
|---|---|---|
iciptr |
Ici * |
指向目标 ICI 的指针 [指向 ICI 的指针可以从两个内核过程获得: op_ici_create() 返回指向新分配 ICI 的指针(在 ICI 发送进程中),以及 op_intrpt_ici() 返回与传入中断关联的 ICI 的指针(在 ICI 接收进程中)。] |
attr_name |
const char * |
目标属性的名称 |
value |
OpT_Int32 |
要赋给指定属性的新值 |
返回类型
Compcode
如果成功获取属性值,返回 OPC_COMPCODE_SUCCESS,否则返回 OPC_COMPCODE_FAILURE。
示例
OpT_Int32 call_number = 45419;
/* If the H.323 Manager was found then send an interrupt */
/* denoting the failed call connection. */
if (h323_mgr_prohandle != OPC_NIL)
{
/* Create the necessary ICI. */
Ici *call_info = op_ici_create ("h323_connection_status_interrupt_ici");
/* Place the number for this call so that the H.323 Manager */
/* can distinguish which call failed. */
op_ici_attr_set_int32 (call_info, "call_number", call_number);
/* Send the interrupt to the H.323 Manager. */
op_ici_install (call_info);
op_intrpt_schedule_process (*h323_mgr_prohandle, op_sim_time (), H323_CALL_FAILED);
op_ici_install (OPC_NIL);
}
详情
指定的属性名称必须是作为 iciptr 所指 ICI 之基础的 ICI 格式中所定义的属性之一。注意,该内核过程赋的值将覆盖此前赋给该属性的任何值。此外,赋给该属性的新值对任何持有该 ICI 指针的其他进程都是可见的。
用途
为进程提供了一种设置 ICI 内容以便与另一个进程通信的机制。这一能力构成了进程之间基于 ICI 通信的“发送”端。属性既可以在新创建的 ICI 中设置(如逐数据包传递参数的场合),也可以在已经发送给一个或多个目标进程的 ICI 中设置(如持久共享内存的安排)。由于被修改的 ICI 可能仍被其发起进程持有指针,op_ici_attr_set_int32() 可用于设置结果,发起进程随后可以通过 op_ici_attr_get_int32() 获取这些结果。这种以 ICI 实现的双向通信通常与伴随强制中断(forced interrupt)的 ICI 一起使用,以便发起进程能够立即获取结果。
错误
- 程序中止:Segmentation violation.(由于无效的 ICI 指针、格式错误的 ICI 数据结构,或声明不正确的
value参数)。 - 程序中止:内核过程需要进程上下文。
- 可恢复错误:属性名称(
<attr_name>)在格式为(<format_name>)的 ICI 中无法识别。
参考
- 使用内核过程 op_ici_attr_get_dbl()、op_ici_attr_get_int32()、op_ici_attr_get_int64() 和 op_ici_attr_get_ptr() 执行相反操作,访问 ICI 属性的值
- 使用内核过程 op_ici_attr_set_dbl() 为指定 ICI 中的 double 类型属性赋值
- 使用内核过程 op_ici_attr_set_int64() 为指定 ICI 中的 64 位整数属性赋值
- 使用内核过程 op_ici_attr_set_ptr() 为指定 ICI 中的指针属性赋值
- 使用内核过程 op_ici_create() 获取新创建的 ICI
- 使用内核过程 op_ici_install() 安装 ICI 以与传出中断关联
- 使用内核过程 op_ici_attr_exists() 确定某属性是否存在于 ICI 的格式中