Trusted Solaris Developer's Guide

Binary and Hexadecimal Label Translation Routines

This example converts a binary CMW label to hexadecimal and back again. Converting a sensitivity label is similar.

#include <tsol/label.h>
#include <stdio.h>

main()
{
	int retval;
	bclabel_t hcmwlabel, hexcmw;
	char *string;

	getcmwplabel(&hcmwlabel);
	if((string = bcltoh(&hcmwlabel)) != NULL)
		printf("Hex string = %s\n", string);

	retval = htobcl(string, &hexcmw);
	printf("Return Value = %d\n", retval);
}

The first printf statements print the binary CMW label in the following hexadecimal format:

Hex string = ADMIN_LOW [0xsensitivity label value]

The second printf statement prints the following where non-zero indicates a successful translation:


Return Value = 1