/*
* 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 <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdarg.h>
#include <stddef.h>
#include <inttypes.h>
#include <pthread.h>
#include "adr_name.h"
/*
* For the most part an adr_name is what is looks like, with one exception.
* All string values are stored in a string space pointed to by an_domain
* (the beginning of which happens to be the domain name). This greatly
* simplifies allocation, freeing, and especially parsing, and increases
* locality as well.
*/
struct adr_name {
int an_refs;
int an_count;
char *an_domain;
};
static void
{
}
static adr_name_t *
adr_name_create_common(int n)
{
return (NULL);
return (NULL);
}
return (result);
}
/*
* Sort keys and reject duplicates.
*/
static adr_name_t *
{
for (int i = 0; i < c; i++) {
}
for (int i = 0; i < c - 1; i++) {
for (int j = i + 1; j < c; j++) {
if (res == 0) {
return (NULL);
}
if (res > 0) {
}
}
}
return (name);
}
/*
* Copy key and value string pointers from input arrays to adr_name_t arrays.
* Tally total space required for strings.
*/
static int
const char const * const *k, const char const * const *v)
{
for (int i = 0; i < n; i++) {
}
return (len);
}
/*
* Copy key and value string pointers from va_list to adr_name_t arrays.
* Tally total space required for strings.
*/
static int
{
for (int i = 0; i < n; i++) {
}
return (len);
}
/*
* Copies the strings pointed to by an_keys[] and an_values[] into the
* name's string space and update the pointers to point to the copies.
*/
static boolean_t
{
return (B_FALSE);
return (B_FALSE);
return (B_FALSE);
return (B_FALSE);
}
return (B_TRUE);
}
const char * const *k, const char * const *v)
{
return (NULL);
return (NULL);
}
return (adr_name_normalize(result));
}
{
return (NULL);
va_list l;
va_start(l, n);
va_end(l);
return (NULL);
}
return (adr_name_normalize(result));
}
/*
* Constructs a new adr_name_t by combining the new key-value pairs
* with those from the original. Will fail if there is overlap.
*/
const char * const *v)
{
return (NULL);
return (NULL);
}
return (adr_name_normalize(result));
}
/*
* Constructs a new adr_name_t by combining the new key-value pairs
* with those from the original. Will fail if there is overlap.
*/
{
return (NULL);
va_list l;
va_start(l, n);
va_end(l);
return (NULL);
}
return (adr_name_normalize(result));
}
const char *
{
}
const char *
{
return (NULL);
}
int
{
}
const char *
{
}
const char *
{
}
/*
* Construct a name given a string.
*/
{
char *data;
goto error;
goto error;
(*dst++) = '\0';
pos++;
int keys = 0;
char c = *pos;
if (c == ',') {
goto error;
keys++;
(*dst++) = '\0';
continue;
} else if (c == '=') {
goto error;
(*dst++) = '\0';
continue;
} else if (c == '\\') {
if (*(++pos) == '\0')
goto error;
switch (c = *pos) {
case 'C':
c = ',';
break;
case 'E':
c = '=';
break;
case 'S':
c = '\\';
break;
}
}
(*dst++) = c;
}
goto error;
keys++;
(*dst++) = '\0';
goto error;
for (int i = 0; i < keys; i++) {
}
return (adr_name_normalize(result));
return (NULL);
}
{
}
/*
* Count the number of characters in an unquoted string that will need quoting.
*/
static int
{
int count = 0;
count++;
return (count);
}
/*
* Quote the string pointed to src, putting the result in dst.
* dst must be large enough to hold strlen(src) + count_quoted(src).
*/
static int
{
char c, nc;
/* LINTED */
switch (c) {
case '\\':
nc = 'S';
break;
case ',':
nc = 'C';
break;
case '=':
nc = 'E';
break;
}
if (nc != c)
*dst++ = '\\';
}
}
/*
* Convert a name into its canonical string form:
* domain:key1=value1,key2=value2,etc.
*/
char *
{
/* domain + ":" + '\0' */
/* key + '=' + value */
if (i != 0) {
/* ',' separator */
length++;
}
}
return (NULL);
if (i != 0) {
*str++ = ',';
}
*str++ = '=';
}
*str++ = '\0';
/* Ensure we've allocated exactly what we need */
return (result);
}
/*
* Compares two adr_name_ts. Two adr_name_ts are equal if their domains
* are equals, and they contain the same set of keys with the same values.
*/
int
{
int res;
if (res != 0)
return (res);
return (-1);
return (1);
if (res != 0)
return (res);
if (res != 0)
return (res);
}
return (0);
}
/*
* Compares an adr_name_t to a pattern. A pattern is just a partial
* adr_name_t. A name is considered a match if everything present in
* the pattern is present in the name and has the same value.
*/
{
return (B_TRUE);
return (B_FALSE);
return (B_FALSE);
}
return (B_TRUE);
}
{
return (name);
}
void
{
return;
return;
}
}