/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <strings.h>
#include <ctype.h>
#include <libgen.h>
#include <libintl.h>
#include <kmfapiP.h>
#include "util.h"
/* Supporting structures and global variables for getopt_av(). */
typedef struct av_opts_s {
} av_opts;
static int _save_numopts = 0;
void
{
return;
while (n != NULL) {
old = n;
kmf_free_policy_record(&n->plc);
n = n->next;
}
}
int
{
/* Create a parser context */
ctxt = xmlNewParserCtxt();
return (KMF_ERR_POLICY_DB_FORMAT);
/* Read the policy DB and verify it against the schema. */
goto end;
}
goto end;
}
char *c;
/*
* Search for the policy that matches the given name.
*/
(const xmlChar *)KMF_POLICY_ELEMENT)) {
/* Check the name attribute */
c = (char *)xmlGetProp(node,
(const xmlChar *)KMF_POLICY_NAME_ATTR);
/* If a match, parse the rest of the data */
if (c != NULL) {
xmlFree(c);
sizeof (POLICY_LIST));
} else {
goto end;
}
/* add to linked list */
} else {
POLICY_LIST *n = plist;
n = n->next;
}
}
}
}
end:
rv = KC_ERR_LOADDB;
} else {
*policy_list = plist;
}
return (rv);
}
/*
* Return 0 if there is any error in the input string.
*/
{
char *p;
while (p != NULL) {
cur_bit = kmf_string_to_ku(p);
if (cur_bit == 0) {
kubits = 0;
break;
}
}
return (kubits);
}
static void
{
}
}
}
int
{
char *p;
return (0);
/*
* The list should be comma separated list of EKU Names.
*/
/* If no tokens found, then maybe its just a single EKU value */
if (p == NULL) {
} else {
rv = KC_ERR_USAGE;
}
}
while (p != NULL) {
newoid = kmf_ekuname_to_oid(p);
} else {
rv = KC_ERR_USAGE;
break;
}
}
return (rv);
}
int
{
char *p;
return (0);
/*
* The list should be comma separated list of EKU Names.
*/
if (p == NULL) {
} else {
rv = KC_ERR_USAGE;
}
}
} else {
rv = KC_ERR_USAGE;
break;
}
}
return (rv);
}
int
{
return (-1);
return (1);
return (0);
return (-1);
}
/*
* This function processes the input string. It removes the beginning
* and ending blank's first, makes a copy of the resulting string and
* return it.
*
* This function returns NULL, if there is an error in the
* input string or when the system is out of memory. The output
* "err_flag" argument will record the error code, if it is not NULL.
*/
char *
{
char *p;
int len, i;
*err_flag = KC_ERR_USAGE;
return (NULL);
}
/* Remove beginning whitespace */
p = str;
p++;
if (p == NULL) {
*err_flag = KC_ERR_USAGE;
return (NULL);
}
/* Remove the trailing blanks */
len--;
if (len == 0) {
*err_flag = KC_ERR_USAGE;
return (NULL);
}
/* Check if there is any non-printable character */
i = 0;
while (i < len) {
if (isprint(p[i]))
i++;
else {
*err_flag = KC_ERR_USAGE;
return (NULL);
}
}
/* Make a copy of the string and return it */
return (NULL);
}
return (retstr);
}
/*
* Breaks out the getopt-style option string into a structure that can be
* traversed later for calls to getopt_av(). Option string is NOT altered,
* but the struct fields point to locations within option string.
*/
static int
{
int i;
char *marker;
return (0);
/*
* This tries to imitate getopt(3c) Each option must conform to:
* <short name char> [ ':' ] [ '(' <long name string> ')' ]
* If long name is missing, the short name is used for long name.
*/
for (i = 0; *optstring != '\0'; i++) {
return (0);
} else
marker++;
}
marker++;
} else {
/* use short name option character */
}
}
return (i);
}
/*
* getopt_av() is very similar to getopt(3c) in that the takes an option
* string, compares command line arguments for matches, and returns a single
* letter option when a match is found. However, getopt_av() differs from
* getopt(3c) by allowing both longname options and values be found
* on the command line.
*/
int
{
int i;
int len;
return (EOF);
/* First time or when optstring changes from previous one */
if (_save_optstr != optstring) {
}
for (i = 0; i < _save_numopts; i++) {
optind_av++;
break;
}
/* matched */
optind_av++;
}
/* needs optarg */
optind_av++;
}
optind_av++;
return ((int)'?');
}
}
return (EOF);
}
void
{
switch (ret) {
case KMF_ERR_POLICY_NAME:
break;
case KMF_ERR_TA_POLICY:
gettext("Error in trust anchor attributes\n"));
break;
case KMF_ERR_OCSP_POLICY:
gettext("Error in OCSP policy attributes\n"));
break;
default:
break;
}
}
{
if (kstore_name == NULL)
return (NULL);
return (NULL);
break;
}
return (rtn_entry);
}