Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Solaris Trusted Extensions Developer's Guide
Previous Next

Obtaining the Color Names of Labels

This code example uses the label_to_str() function to obtain the color name of a label. The mappings between color names and labels are defined in the label_encodings file.

#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);
}

If the label_encodings file maps the color blue to the label CONFIDENTIAL, the program prints the following:

The color for the "CONFIDENTIAL" label is "BLUE".
Previous Next

 
 
  Published under the terms fo the Public Documentation License Version 1.01. Design by Interspire