A clearance can be initialized to ADMIN_LOW or ADMIN_HIGH and have its type checked. This example initializes undef to undefined (similar to NULL) and loclear to ADMIN_LOW. It then checks the type on loclear, sets the type to undefined, and checks it again. A clearance is undefined when its ID field is initialized to SUN_CLR_UN. An undefined clearance is invalid. A clearance is defined when the ID field in the label structure is initialized to SUN_CLR_ID.
#include <tsol/label.h>
main()
{
int retval;
bclear_t loclear, undef;
bclearlow(&loclear);
bclearundef(&undef);
retval = bltype(&loclear, SUN_CLR_ID);
printf("Is clearance defined? %d\n", retval);
setbltype(&loclear, SUN_CLR_UN);
retval = bltype(&loclear, SUN_CLR_ID);
printf("Is clearance defined? %d\n", retval);
}
The printf(1) statement prints the following where non-zero is True and 0 is False.
Is clearance defined? 1 Is clearance defined? 0 |