The reentrant (MT-SAFE) routine bcleartoh_r(3TSOL) requires the allocation and freeing of memory for the value returned. The h_alloc(3TSOL) routine is used to allocate this memory, sizing it appropriately for the type of label (in this case hexadecimal) to be converted.
type where type is a hexadecimal value that indicates that a defined clearance (SUN_CLR_ID) is translated to hexadecimal.
This example allocates memory for the translation type, translates the binary process clearance to hexadecimal, and frees the memory at the end.
#include <tsol/label.h> main() { bclear_t hclear; char *string, *hex; getclearance(&hclear); hex = h_alloc(SUN_CLR_ID); if((string = bcleartoh_r(&hclear, hex)) != 0); printf("Hex string = %s\n", string); h_free(hex); }
The printf statement prints the binary clearance in the following hexadecimal format:
Hex string = 0x0006cc0000000000000000000000000000000000000 000000003ffffffffffff0000 |