vold_props.c revision 18c2aff776a775d34a4c9893a4c72e0434d68e36
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdlib.h>
#include <string.h>
#include "vold.h"
/*
* Functions to get, put, and delete generic properties.
* It is illegal (and not checked) for either attributes or
* values to have '=' or '; ' in them.
*/
/*
* The user uses an opaque string and asks for the get, put,
* and del operations to be performed on it. The model
* is attribute = value, and is represented in the string
* as "attribute=value; attribute1=value1; ...".
*/
struct prop {
char *attr;
char *value;
int seen;
};
#ifndef NULLC
#define NULLC '\0'
#endif
/*
* Return the "value" for an "attribute" from a "property" string.
* Returns NULL if the named attribute does not exist in the string.
*/
char *
{
char *rv;
return (rv);
}
ps++;
}
return (NULL);
}
/*
* Return a new "property" string with the "attribute" and "value" in
* it. I Free the old one. If the named "attribute" already exists,
* it is modified, if it does not, the new <attribute, value> pair
* is appended to the end of the list.
*
* if the input value for the specified attribute is a null pointer
* or null string, then delete that attribute
*/
char *
{
char *prop_attr_del(char *, char *);
int found;
char *rp;
/* if the attribute is to be cleared our job is simpler */
return (rp);
}
/* scan through attribute list, looking for one we want to set */
/* found our attr -- set it to new value */
found++;
break;
}
}
/* get length of all current attrubute strings */
plen = 0;
}
/* if not found then we have to add in room for new attr=value pari */
if (!found) {
}
/* allocate room for a string and fill it in */
}
if (!found) {
}
return (rp);
}
/*
* remove an attribute from the property list.
*/
char *
{
char *rp;
plen = 0;
continue;
}
}
continue;
}
}
return (rp);
}
char *
{
int plen;
char *rp;
/* found one */
}
}
}
plen = 0;
/* the "to" array */
plen += 2;
}
/* the "from" array */
continue;
}
plen += 2;
}
/* the "to" array */
}
/* the "from" array */
continue;
}
}
return (rp);
}
static struct prop *
{
char *s;
char *p;
int pcnt;
int i;
}
/*
* Count the number for attribute=value pairs.
*/
s = props;
pcnt = 0;
pcnt++;
s++;
}
break;
}
*p = NULLC;
*p = '=';
s = p;
*p = NULLC;
}
if (p == NULL) {
break;
}
*p++ = ';';
s = p;
}
return (ps);
}
static void
{
lp++;
}
}