B.1.8 可信軟件基上下文數據結構
B.1.8.1 數據結構
typedef struct tsb_context
{
int (*get_int_value)(TSBContext *context,const char *var_name,long *pvalue);
int (get_pointer_value)(TSBContext *context,const char *var_name,const void *pvalue);
int (*set_measure_result)(TSBContext *context,const char *value,int length);
TSBMeasureResult (get_measure_result_by_name)(TSBContext *context,const char *measure_name);
TSBMeasureResult (get_measure_result_by_index)(TSBContext *context,int index);
int (*get_estimate_result_by_name)(TSBContext *context,const char *estimate_name);
int (*get_estimate_result_by_index)(TSBContext *context,int index);
}TSBContext;
成員函數:
get_int_value 讀取環境變量,從環境上下文讀取長整數變量
get_pointer_value 讀取環境變量,從環境上下文讀取指針變量
set_measure_result 設置度量結果
get_measure_result_by_name 讀取度量結果
get_measure_result_by_index 讀取度量結果
get_estimate_result_by_name 讀取判定結果
get_estimate_result_by_index 讀取判定結果
B.1.8.2 函數操作
結構體中的操作函數
B.1.8.2.1 get_int_value
定義:
int get_int_value
(
TSBContext *context,
const char *var_name,
long *pvalue
)
輸入參數:
context 環境上下文
var_name 指定變量名稱
pvalue 值保存到pvalue指向的區域
返回值:
0 成功
非0(錯誤碼) 失敗
B.1.8.2.2 get_pointer_value
*定義: *
int get_pointer_value
(
TSBContext *context,
const char *var_name,
const void **pvalue
)
輸入參數:
context 環境上下文
var_name 指定變量名稱
pvalue 值保存到pvalue指向的區域
返回值:
0 成功
非0(錯誤碼) 失敗
B.1.8.2.3 set_measure_result
定義:
int set_measure_result
(
TSBContext *context,
const char *value,
int length
)
輸入參數:
context 環境上下文
*value 指向度量結果
length 度量結果的長度
返回值:
0 成功
非0(錯誤碼) 失敗
B.1.8.2.4 get_measure_result_by_name
定義:
TSBMeasureResult (get_measure_result_by_name)
(
TSBContext *context,
const char *measure_name
)
輸入參數:
*context 環境上下文
*measure_name 度量名稱
返回值:
度量結果
如果度量結果不存在,則返回空值
B.1.8.2.5 get_measure_result_by_index
定義:
TSBMeasureResult (get_measure_result_by_index)
(
TSBContext *context,
int index
)
輸入參數:
*context 環境上下文
index 度量名稱
返回值:
度量結果
如果判定結果不存在,則返回-1
B.1.8.2.6 get_estimate_result_by_name
定義:
int (*get_estimate_result_by_name)
(
TSBContext *context,
const char *estimate_name
)
輸入參數:
*context 環境上下文
*estimate_name 判定名稱
返回值:
判定結果
如果判定結果不存在,則返回-1
B.1.8.2.7 get_estimate_result_by_index
定義:
int (*get_estimate_result_by_index)
(
TSBContext *context,
int index
)
輸入參數:
*context 環境上下文
index 序號
返回值:
判定結果
如果判定結果不存在,則返回-1
推薦文章: