/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Binary label to label string translations.
*/
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <wchar.h>
#include "clnt.h"
#include "labeld.h"
#if !defined(TEXT_DOMAIN) /* should be defined by Makefiles */
#endif /* TEXT_DOMAIN */
static int
{
char *cpyptr;
return (0);
**string = '\0';
return (0);
}
return (val_len);
}
void
{
if (flags&VIEW_INTERNAL) {
} else if (flags&VIEW_EXTERNAL) {
}
}
int
{
return (0);
} else {
return (0);
}
}
return (ALLOC_CHUNK);
}
/*
* bsltos - Convert Binary Sensitivity Label to Sensitivity Label string.
*
* Entry label = Binary Sensitivity Label to be converted.
* string = NULL ((char *) 0), if memory to be allocated,
* otherwise, pointer to preallocated memory.
* str_len = Length of preallocated memory, else ignored.
* flags = Logical sum of:
* LONG_CLASSIFICATION or SHORT_CLASSIFICATION,
* LONG_WORDS or SHORT_WORDS,
* VIEW_INTERNAL or VIEW_EXTERNAL, and
* NO_CLASSIFICATION.
* LONG_CLASSIFICATION, use long classification names.
* SHORT_CLASSIFICATION, use short classification
* names (default).
* NO_CLASSIFICATION, don't translate classification.
* LONG_WORDS, use the long form of words (default).
* SHORTWORDS, use the short form of words where available.
*
* Exit string = Sensitivity Label string, or empty string if
* not enough preallocated memory.
*
* Returns -1, If unable to access label encodings database.
* 0, If unable to allocate string,
* or allocated string to short
* (and **string = '\0').
* length (including null) of Sensitivity Label string,
* If successful.
*
* Calls RPC - LABELS_BSLTOS, BCLHIGH, BCLLOW, BCLTOSL, BLEQUAL,
* BLTYPE, SETBSLABEL, UCLNT, memcpy, clnt_call,
* clnt_perror, malloc, strcat, strlen.
*
* Uses ADMIN_HIGH, ADMIN_LOW, shigh, slow.
*/
int flags)
{
int rval;
return (-1);
}
LABELS_SHORT_WORDS : 0;
return (-1);
/* unpack Sensitivity Label */
return (rval);
/* server not present */
/* special case admin_high and admin_low */
/* initialize static labels */
}
}
}
return (-1);
} /* bsltos */
/*
* bcleartos - Convert Binary Clearance to Clearance string.
*
* Entry clearance = Binary Clearance to be converted.
* string = NULL ((char *) 0), if memory to be allocated,
* otherwise, pointer to preallocated memory.
* str_len = Length of preallocated memory, else ignored.
* flags = Logical sum of:
* LONG_CLASSIFICATION or SHORT_CLASSIFICATION,
* LONG_WORDS or SHORT_WORDS,
* VIEW_INTERNAL or VIEW_EXTERNAL.
* LONG_CLASSIFICATION, use long classification names.
* SHORT_CLASSIFICATION, use short classification
* names (default).
* LONG_WORDS, use the long form of words (default).
* SHORTWORDS, use the short form of words where available.
*
* Exit string = Clearance string, or empty string if not
* enough preallocated memory.
*
* Returns -1, If unable to access label encodings database.
* 0, If unable to allocate string,
* or allocated string to short
* (and **string = '\0').
* length (including null) of Clearance string,
* If successful.
*
* Calls RPC - LABELS_BSLTOS, BCLHIGH, BCLLOW, BCLTOSL, BLEQUAL,
* BLTYPE, SETBSLABEL, UCLNT, memcpy, clnt_call,
* clnt_perror, malloc, strcat, strlen.
*
* Uses ADMIN_HIGH, ADMIN_LOW, clrhigh, clrlow.
*/
int flags)
{
int rval;
return (-1);
}
LABELS_SHORT_WORDS : 0;
return (-1);
/* unpack Clearance */
/* release return buffer */
return (rval);
/* server not present */
/* special case admin_high and admin_low */
/* initialize static labels */
}
}
}
return (-1);
} /* bcleartos */
/*
* sbsltos - Convert Sensitivity Label to canonical clipped form.
*
* Entry label = Sensitivity Label to be converted.
* len = Maximum length of translated string, excluding NULL.
* 0, full string.
* sstring = address of string to translate into.
* ssize = size of memory currently allocated to sstring.
*
* Exit sstring = Newly translated string.
* ssize = Updated if more memory pre-allocated.
*
* Returns NULL, If error, len too small, unable to translate, or get
* memory for string.
* Address of string containing converted value.
*
* Calls alloc_string, bsltos, strcpy.
*
* Uses ssize, sstring.
*/
char *
{
int wccount;
if (ssize == 0) {
/* Allocate string memory. */
/* can't get initial memory for string */
return (NULL);
}
(SHORT_CLASSIFICATION | LONG_WORDS))) <= 0) {
/* error in translation */
if (slen == 0) {
if (*sstring == '\0') {
int newsize;
/* sstring not long enough */
's')) == 0) {
/* Can't get more memory */
return (NULL);
}
goto again;
}
}
return (NULL);
}
if (len == 0) {
return (sstring);
} else if (len < MIN_SL_LEN) {
return (NULL);
}
return (NULL);
return (NULL);
}
/* Adjust string size to desired length */
clipp[0] = L'<';
int newsize;
/* sstring not long enough */
0) {
/* Can't get more memory */
return (NULL);
}
}
return (NULL);
}
}
return (sstring);
} /* sbsltos */
/*
* sbcleartos - Convert Clearance to canonical clipped form.
*
* Entry clearance = Clearance to be converted.
* len = Maximum length of translated string, excluding NULL.
* 0, full string.
* sstring = address of string to translate into.
* ssize = size of memory currently allocated to sstring.
*
* Exit sstring = Newly translated string.
* ssize = Updated if more memory pre-allocated.
*
* Returns NULL, If error, len too small, unable to translate, or get
* memory for string.
* Address of string containing converted value.
*
* Calls alloc_string, bcleartos, strcpy.
*
* Uses ssize, sstring.
*/
char *
{
int wccount;
if (ssize == 0) {
/* Allocate string memory. */
/* can't get initial memory for string */
return (NULL);
}
(SHORT_CLASSIFICATION | LONG_WORDS))) <= 0) {
/* error in translation */
if (slen == 0) {
if (*sstring == '\0') {
int newsize;
/* sstring not long enough */
'c')) == 0) {
/* Can't get more memory */
return (NULL);
}
goto again;
}
}
return (NULL);
}
if (len == 0) {
return (sstring);
} else if (len < MIN_CLR_LEN) {
return (NULL);
}
return (NULL);
return (NULL);
}
/* Adjust string size to desired length */
clipp[0] = L'<';
int newsize;
/* sstring not long enough */
0) {
/* Can't get more memory */
return (NULL);
}
}
return (NULL);
}
}
return (sstring);
} /* sbcleartos */