/*
* 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
*/
/*
*/
#include "lint.h"
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <secdb.h>
#include <ctype.h>
#include <alloca.h>
static char *do_unescape(char *, boolean_t *);
/*
* kva_match(): Given a key-value array and a key, return a pointer to the
* value that matches the key.
*/
char *
{
int i;
return (NULL);
}
}
}
return (NULL);
}
/*
* _kva_free(): Free up memory.
*/
void
{
int i;
return;
}
}
}
}
}
/*
* _kva_free_value(): Free up memory (value) for all the occurrences of
* the given key.
*/
void
{
int ctr;
return;
}
while (ctr--) {
}
data++;
}
}
/*
* new_kva(): Allocate a key-value array.
*/
kva_t *
{
return (NULL);
}
return (NULL);
}
return (new_kva);
}
/*
* _str2kva(): Given a string (s) of key-value pairs, separated by delimeter
* (del), place the values into the key value array (nkva).
*/
kva_t *
{
int n = 0;
int m;
char *buf;
char *p;
char *pair;
char *key;
char *last_pair;
char *last_key;
if (s == NULL ||
*s == '\0' ||
*s == '\n' ||
(strlen(s) <= 1)) {
return (NULL);
}
p = s;
n++;
p++;
}
if (n > size) {
m = n/size;
if (n%size) {
++m;
}
size = m * KV_ADD_KEYS;
}
return (NULL);
}
return (NULL);
}
do {
}
!err);
if (err) {
return (NULL);
}
return (nkva);
}
/*
* Returns the escaped string; if new memory is allocated, it is written
* to *res else *res will be set to NULL so it is safe to call free(*res).
* Error is flagged in *err; the application needs to set it to B_FALSE.
*/
static char *
{
char *tmp;
/* Nothing to escape. */
return ((char *)src);
return ((char *)src);
}
return (tmp);
}
/*
* _kva2str(): Given an array of key-value pairs, place them into a string
* (buf). Use delimeter (del) to separate pairs. Use assignment character
* (ass) to separate keys and values.
*
* This is the inverse of _str2kva; the keys and values must be escaped.
* This version also escapes the second delimiter, typically a colon.
*
* Return Values: 0 Success 1 Buffer too small
*/
int
const char *del2)
{
int i;
int len;
int off = 0;
buf[0] = '\0';
return (0);
/* Suppress unset and empty values. */
return (1);
}
}
return (0);
}
int
{
}
int
{
int i;
return (0);
}
return (0);
}
}
return (1);
}
kva_t *
{
int i;
int size;
return (NULL);
}
return (NULL);
}
}
return (nkva);
}
static void
{
char *p, *start;
/* Find first non-white space character and return pointer to it */
;
if (*p == '\0')
return;
p = p + strlen(p) - 1;
/* Remove trailing spaces */
p--;
p[1] = '\0';
}
static char *
{
char *tmp;
return (src);
strip_spaces(&src);
/* Unescape should only unescape the standard seperators */
return (tmp);
}
/*
* Always allocates new memory, for some reason when allocate fails we try
* to return an empty string (but allocating that might also fail).
*/
char *
{
char *tmp;
return (_strdup_null(NULL));
else
return (tmp);
}
#ifdef DEBUG
void
{
int i;
(void) printf(" (empty)\n");
return;
}
(void) printf(" %s = %s\n",
}
}
#endif /* DEBUG */