| ナビゲーションリンクをスキップ | |
| 印刷ビューの終了 | |
|
Trusted Extensions 開発者ガイド Oracle Solaris 10 1/13 Information Library (日本語) |
1. Trusted Extensions API およびセキュリティーポリシー
9. Solaris Trusted Extensions ラベル API のための試験的な Java バインディング
このコード例では、label_to_str() 関数を使用してラベルのカラー名を取得します。カラー名とラベルの対応付けは label_encodings ファイルで定義されます。
#include <stdlib.h>
#include <stdio.h>
#include <tsol/label.h>
int
main()
{
m_label_t *plabel;
char *label = NULL;
char *color = NULL;
plabel = m_label_alloc(MAC_LABEL);
if (getplabel(plabel) == -1) {
perror("getplabel");
exit(1);
}
if (label_to_str(plabel, &color, M_COLOR, 0) != 0) {
perror("label_to_string(M_COLOR)");
exit(1);
}
if (label_to_str(plabel, &label, M_LABEL, DEF_NAMES) != 0) {
perror("label_to_str(M_LABEL)");
exit(1);
}
printf("The color for the \"%s\" label is \"%s\".\n, label, color);
m_label_free(plabel);
return (0);
}
label_encodings ファイルで青色がラベル CONFIDENTIAL に対応付けられている場合、このプログラムは次を出力します。
The color for the "CONFIDENTIAL" label is "BLUE".