/*
* Copyright (c) 2001 Sendmail, Inc. and its suppliers.
* All rights reserved.
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#if NETINFO
#include <ctype.h>
#include <stdlib.h>
/*
** NI_PROPVAL -- NetInfo property value lookup routine
**
** Parameters:
** keydir -- the NetInfo directory name in which to search
** for the key.
** keyprop -- the name of the property in which to find the
** property we are interested. Defaults to "name".
** keyval -- the value for which we are really searching.
** valprop -- the property name for the value in which we
** are interested.
** sepchar -- if non-nil, this can be multiple-valued, and
** we should return a string separated by this
** character.
**
** Returns:
** NULL -- if:
** 1. the directory is not found
** 2. the property name is not found
** 3. the property contains multiple values
** 4. some error occurred
** else -- the value of the lookup.
**
** Example:
** To search for an alias value, use:
** ni_propval("/aliases", "name", aliasname, "members", ',')
**
** Notes:
** Caller should free the return value of ni_proval
*/
char *
char *keydir;
char *keyprop;
char *keyval;
char *valprop;
int sepchar;
{
int i;
int j, alen, l;
register char *p;
/*
** Create the full key from the two parts.
**
** Note that directory can end with, e.g., "name=" to specify
** an alternate search property.
*/
if (i >= sizeof keybuf)
return NULL;
{
}
#if 0
sm_dprintf("ni_propval(%s, %s, %s, %s, %d) keybuf='%s'\n",
#endif /* 0 */
/*
** If the passed directory and property name are found
** in one of netinfo domains we need to search (starting
** from the local domain moving all the way back to the
** root domain) set propval to the property's value
** and return it.
*/
{
if (i == 0)
{
#if 0
#endif /* 0 */
}
else
{
#if 0
#endif /* 0 */
}
/*
** Don't bother if we didn't get a handle on a
** proper domain. This is not necessarily an error.
** We would get a positive ni_status if, for instance
** we never found the directory or property and tried
** to open the parent of the root domain!
*/
if (nis != 0)
break;
/*
** Find the path to the server information.
*/
continue;
/*
** Find associated value information.
*/
continue;
#if 0
sm_dprintf("ni_lookupprop: len=%d\n",
#endif /* 0 */
/*
** See if we have an acceptable number of values.
*/
if (ninl.ni_namelist_len <= 0)
continue;
{
continue;
}
/*
** Calculate number of bytes needed and build result
*/
alen = 1;
for (j = 0; j < ninl.ni_namelist_len; j++)
goto cleanup;
for (j = 0; j < ninl.ni_namelist_len; j++)
{
l = strlen(p);
p += l;
*p++ = sepchar;
alen -= l + 1;
}
*--p = '\0';
}
#if 0
#endif /* 0 */
return propval;
}
#endif /* NETINFO */