ldap_val.c revision 36e852a172cba914383d7341c988128b2c667fbd
/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <lber.h>
#include <ldap.h>
#include <strings.h>
#include <errno.h>
#include "nisdb_mt.h"
#include "ldap_util.h"
#include "ldap_op.h"
#include "ldap_ruleval.h"
#include "ldap_attr.h"
#include "ldap_val.h"
#include "ldap_ldap.h"
extern int yp2ldap;
char *myself = "cloneMappingFormat";
if (m == 0)
return (0);
nf++;
if (new == 0)
return (0);
/* Copy the whole array */
/* Make copies of allocated stuff */
switch (m[i].type) {
case mmt_string:
err++;
break;
case mmt_single:
err++;
err++;
break;
case mmt_berstring:
err++;
break;
case mmt_item:
case mmt_limit:
case mmt_any:
case mmt_begin:
case mmt_end:
default:
break;
}
}
/* If there were memory allocation errors, free the copy */
if (err > 0) {
new = 0;
}
return (new);
}
void
int i;
if (m == 0)
return;
switch (m[i].type) {
case mmt_string:
break;
case mmt_single:
break;
case mmt_berstring:
break;
case mmt_item:
case mmt_limit:
case mmt_any:
case mmt_begin:
case mmt_end:
default:
break;
}
}
free(m);
}
void
int i;
char *myself = "copyIndex";
return;
}
for (i = 0; i < old->numIndexes; i++) {
return;
}
return;
}
}
}
char *myself = "cloneIndex";
int err = 0;
if (old == 0)
return (0);
if (new != 0) {
if (err != 0) {
new = 0;
}
}
return (new);
}
void
int i;
if (old == 0)
return;
for (i = 0; i < old->numIndexes; i++) {
}
if (doFree)
}
char **
char **new;
int i;
char *myself = "cloneName";
return (0);
if (new == 0)
return (0);
for (i = 0; i < numNames; i++) {
if (name[i] != 0) {
if (new[i] == 0) {
for (i--; i >= 0; i--) {
}
return (0);
}
} else {
new[i] = 0;
}
}
return (new);
}
void
int c, i;
if (val == 0)
return;
for (c = 0; c < count; c++) {
}
}
}
}
__nis_value_t *n;
int c, i;
char *myself = "cloneValue";
return (0);
if (n == 0)
return (0);
for (c = 0; c < count; c++) {
if (n[c].numVals > 0) {
sizeof (n[c].val[0]));
if (n[c].val == 0) {
freeValue(n, c);
return (0);
}
} else {
n[c].val = 0;
}
for (i = 0; i < n[c].numVals; i++) {
/*
* The functions that create string values try to
* make sure that there's a NUL at the end. However,
* both NIS+ and LDAP have a tendency to store strings
* without a NUL, so the value length may not include
* the NUL (even though it's there). In order to
* preserve that NUL, we add a byte to the length if
* the type is vt_string, and there isn't already a
* NUL at the end. The memory allocation function
* (am()) will take care of actually putting the NUL
* in place, since it allocates zero-initialized
* memory.
*/
'\0') {
amlen++;
}
freeValue(n, c);
return (0);
}
}
}
return (n);
}
/* Define LBER_USE_DER per ber_decode(3LDAP) */
#ifndef LBER_USE_DER
#define LBER_USE_DER 0x01
#endif /* LBER_USE_DER */
/*
* Return a copy of 'valIn' where each value has been replaced by the
* BER encoded equivalent specified by 'berstring'. 'valIn' is unchanged.
*/
char *myself = "berEncode";
int i;
return (0);
if (val == 0)
return (0);
int ret;
if (ber == 0) {
myself);
return (0);
}
} else {
ret = -1;
}
if (str != 0) {
} else {
ret = -1;
}
} else {
ret = -1;
}
if (ret == -1) {
myself);
return (0);
}
myself);
return (0);
}
}
return (val);
}
int i;
char *myself = "berDecode";
return (0);
if (val == 0)
return (0);
void *v = 0;
continue;
if (ber == 0) {
myself);
return (0);
}
len = sizeof (int);
if (v != 0) {
} else {
ret = -1;
}
long llen;
if (ret != -1) {
}
ret = 0;
if (bv != 0) {
} else {
ret = -1;
}
/* Only free 'bv' itself */
} else {
ret = -1;
}
if (ret != -1) {
}
} else {
ret = -1;
}
if (ret == -1) {
myself);
return (0);
}
/* Free the old value, and replace it with the decoded one */
}
return (val);
}
/*
* Return the value of the specified item.
*/
int i, j, k;
char **name;
unsigned char fromldap = '\0';
if (item == 0)
return (0);
/*
* First, we decide if we should look for the value in 'rv',
* directly from NIS+/LDAP, or both.
*/
case mit_nisplus:
/*
* use it. Otherwise, return error.
*/
if (rv != 0) {
caseInsens = 0;
} else {
return (0);
}
} else {
/*
* Valid index, so skip the rule-value and do
* a direct NIS+ lookup.
*/
check = lookupOnly;
}
break;
case mit_ldap:
if (rv != 0) {
caseInsens = 1;
fromldap = '1';
}
/* Do we have a valid triple ? */
/*
* No valid triple. If we have a rule-value, use it.
* Otherwise, return error.
*/
if (rv != 0) {
} else {
return (0);
}
/*
* We have a valid triple, but it points to the
* current LDAP container. Thus, first look in
* the rule-value; if that fails, perform a direct
* LDAP lookup.
*/
if (rv != 0) {
} else {
check = lookupOnly;
}
} else {
/*
* Valid triple, and it's not the current container
* (at least not in the trivial sense). Hence, do
* a direct LDAP lookup.
*/
check = lookupOnly;
}
break;
default:
return (0);
}
/* Check the rule-value */
for (i = 0; i < numName; i++) {
if (caseInsens)
else
if (cmp == 0) {
break;
if (berstring == 0) {
} else {
}
if (val != 0) {
/*
* If value for nis+ column is
* passed with value, val is
* manipulated in cloneValue().
* To decide whether there are
* enough nis+ column values
* for rule to produce a value,
* we need nis+ column values
* as well as nis_mapping_element
* from the rule. If we are here,
* it indicates that the 'val has
* an valid value for the column
* item-> name. So set
* NP_LDAP_MAP_SUCCESS
* to np_ldap-stat.
*/
if (np_ldap_stat != NULL)
*np_ldap_stat =
}
break;
}
}
}
/* Do a direct lookup ? */
int err = 0;
char *baseDN;
/*
* If item->searchSpec.triple.base is NULL, or ends
* in a comma, append the current search base from
* the TSD (put there by an upper layer).
*
* Special case for N2L mode:
* if item->searchSpec.triple.base ends in a comma,
* the current domain Context is used.
*/
} else {
}
if (err == 0) {
fromldap = '1';
} else {
val = 0;
}
}
}
/* Special processing for NIS to LDAP mode */
/*
* Escape special chars from dn before sending to DIT,
* provided val is not ldap-based
*/
if (escapeSpecialChars(val) < 0) {
return (0);
}
/* Remove escape chars from data received from DIT */
(void) removeEscapeChars(val);
}
/*
* Remove from 'val', any values obtained using
* the 'removespec' syntax
*/
/* Obtain exVal */
/* delete */
if (exVal != 0) {
== 0)
break;
}
}
} else
i++;
}
/*
* If val->numVals <= 0, then we have no val to
* return. So free up stuff.
*/
return (0);
}
}
}
return (val);
}
char *myself = "getMappingFormat";
__nis_value_t *val = 0;
__nis_buffer_t b = {0, 0};
int i;
if (f == 0)
return (0);
if (rv == 0) {
if (val == 0)
return (0);
switch (f->type) {
case mmt_item:
break;
case mmt_string:
break;
case mmt_single:
else
}
break;
case mmt_limit:
break;
case mmt_any:
break;
case mmt_berstring:
break;
case mmt_begin:
case mmt_end:
break;
default:
}
return (0);
}
} else {
switch (f->type) {
case mmt_item:
case mmt_berstring:
if (a != 0) {
(__nis_mapping_item_t *)a,
if (numArg != 0)
(*numArg)++;
} else {
val = cloneValue(
(__nis_value_t *)a, 1);
if (numArg != 0)
(*numArg)++;
}
}
break;
case mmt_string:
if (val == 0)
return (0);
return (0);
}
break;
case mmt_single:
case mmt_limit:
case mmt_any:
case mmt_begin:
case mmt_end:
/* Not an error, so return an empty value */
if (val == 0)
return (0);
break;
default:
/* Do nothing */
val = 0;
break;
}
}
return (val);
}
/*
* Used when evaluating an expression. Typically, the value of the
* expression so far will be kept in 'v1', and 'v2' is the value
* of the current component of the expression. In the general case,
* both will be multi-valued, and the result is an "explosion"
* resulting in N*M new values (if 'v1' had N values, and 'v2'
* M ditto).
*
* For example, if v1 = {"ab", "cd", "ef"}, and v2 = {"gh", "ij", "kl"},
* the result will be {"abgh", "abij", "abkl", "cdgh", "cdij", "cdkl",
* "efgh", "efij", "efkl"}.
*
* Repeat mostly makes sense with single values; for example, if
* v1 = {"x="} with repeat on, and v2 = {"1", "2", "3"}, the result
* is {"x=1", "x=2", "x=3"}.
*
* The result if v2 also had repeat on would be {"x=1x=2x=3"}. It's
* not clear if there's a useful application for this, but the code's
* there for the sake of orthogonality.
*/
__nis_value_t *v;
__nis_buffer_t b = {0, 0};
char *myself = "explodeValues";
/*
* XXX What should we do if (v1->type != v2->type) ?
* Policy: Just explode anyway, even though the result is
* unlikely to be very useful.
*/
if (v == 0)
return (0);
else /* v1->repeat && v2->repeat */
nv = 1;
if (v->val == 0) {
free(v);
return (0);
}
/*
* Four different cases, depending on the 'repeat' flags.
*/
&b);
else
&b);
&b);
else
&b);
n++;
b.buf = 0;
b.len = 0;
}
}
&b);
else
&b);
&b);
else
&b);
}
n++;
b.buf = 0;
b.len = 0;
}
&b);
else
&b);
&b);
else
&b);
}
n++;
b.buf = 0;
b.len = 0;
}
} else { /* v1->repeat && v2->repeat */
&b);
else
&b);
&b);
else
&b);
}
}
n++;
b.buf = 0;
b.len = 0;
}
#ifdef NISDB_LDAP_DEBUG
/* Sanity check */
if (n != nv)
abort();
#endif /* NISD__LDAP_DEBUG */
v->repeat = 0;
v->numVals = n;
return (v);
}
int i, ia = 0;
__nis_value_t *val, *v = 0;
bool_t moreFormat = (a != 0);
for (i = 0; moreFormat; i++) {
} else {
}
if (val != 0) {
freeValue(v, 1);
if (new == 0)
return (0);
v = new;
} else {
freeValue(v, 1);
return (0);
}
/*
* If we run out of arguments, but still have format
* remaining, repeat the last argument. Keep track of
* the fact that we've really consumed all arguments.
*/
}
}
/*
* We've run out of format, so if we still have arguments
* left, start over on the format.
*/
/*
* However, if we didn't consume any arguments going
* through the format once, abort to avoid an infinite
* loop.
*/
freeValue(v, 1);
return (0);
}
moreFormat = 1;
}
}
return (v);
}
/*
* Returns a string representation (such as "[name=foo, value=bar]")
* of a nis_index_t.
*/
char *
int n;
__nis_buffer_t b = {0, 0};
char *myself = "getIndex";
if (i == 0)
return (0);
if (i->numIndexes > 0) {
for (n = 0; n < i->numIndexes; n++) {
int j;
0, fa_any, 0, 0);
if (n > 0)
if (val != 0) {
}
} else {
}
}
}
if (len != 0)
return (b.buf);
}
char *
__nis_buffer_t b = {0, 0};
char *myself = "getObjSpec";
if (o == 0)
return (0);
if (len != 0)
return (b.buf);
}
/*
* Returns a string representation of the LDAP scope. Note that the
* returned value is a static entity, and must be copied by the
* caller (but, obviously, must not be freed).
*/
char *
switch (scope) {
case LDAP_SCOPE_BASE:
return ("base");
case LDAP_SCOPE_ONELEVEL:
return ("one");
case LDAP_SCOPE_SUBTREE:
return ("sub");
default:
return ("one");
}
}
/*
* Return a string representation of an LDAP search triple (such as
* "ou=Hosts,dc=eng,dc=sun,dc=com?one?cn=xyzzy").
*/
char *
__nis_buffer_t b = {0, 0};
char *a;
int l;
char *myself = "getSearchTriple";
/* If the scope is LDAP_SCOPE_UNKNOWN, the search triple is unused */
if (s == 0 || s->scope == LDAP_SCOPE_UNKNOWN) {
if (len != 0)
*len = 0;
return (0);
}
if (s->base != 0)
if (!(s->scope == LDAP_SCOPE_ONELEVEL &&
}
/*
* The parser usually keeps any white space from the
* want it.
*/
if (a != 0) {
int i, la;
for (i = 0, la = 0; i < l; i++) {
if (s->attrs[i] != ' ' &&
s->attrs[i] != '\t')
}
sfree(a);
} else {
}
}
if (len != 0)
return (b.buf);
}
char *myself = "getMappingItem";
__nis_value_t *val = 0;
__nis_buffer_t b = {0, 0};
int len = 0;
char *buf;
if (i == 0)
return (0);
if (rv != 0)
np_ldap_stat));
if (val == 0)
return (0);
switch (i->type) {
case mit_nisplus:
if (native != mit_nisplus)
}
return (0);
}
break;
case mit_ldap:
}
return (0);
}
break;
default:
break;
}
return (val);
}
void
char *myself = "copyObjSpec";
return;
}
return;
}
return;
}
}
return;
}
}
char *myself = "cloneObjSpec";
int err = 0;
if (new != 0) {
if (err != 0) {
new = 0;
}
}
return (new);
}
void
if (old == 0)
return;
if (doFree)
}
void
int *err) {
char *myself = "copySearchTriple";
*err = 0;
return;
}
else
else
return;
}
/*
* XXX Really should have a cloneMappingElement() function.
* However, since whatever the 'element' field points to
* is allocated at parse time, and never is freed or modified,
* it's sufficient to copy the pointer value.
*/
}
char *myself = "cloneSearchTriple";
int err = 0;
if (new != 0) {
if (err != 0) {
new = 0;
}
}
return (new);
}
void
if (old == 0)
return;
/*
* Since we only copied the element pointer when this structure
* was created, we don't free old->element.
*/
if (doFree)
}
void
int *err) {
*err = 0;
return;
}
if (type == mit_nisplus) {
}
}
char *myself = "cloneTripleOrObj";
int err = 0;
if (new != 0) {
if (err != 0) {
new = 0;
}
}
return (new);
}
void
if (old == 0)
return;
if (type == mit_nisplus)
if (doFree)
}
void
*err = 0;
return;
}
return;
}
} else {
}
err);
else
}
int err = 0;
char *myself = "cloneItem";
if (old == 0)
return (0);
if (new == 0)
return (0);
if (err != 0) {
return (0);
}
return (new);
}
void
int i;
if (item == 0)
return;
for (i = 0; i < numItems; i++) {
}
}
int i, err = 0;
char *myself = "concatenateMappingItem";
if (new == 0)
return (0);
for (i = 0; i < numItems; i++) {
if (err != 0) {
freeMappingItem(new, i);
return (0);
}
}
if (err != 0) {
new = 0;
}
return (new);
}
int i, n, a;
__nis_value_t *v;
char *myself = "concatenateValues";
return (0);
if (v == 0)
return (0);
if (v->val == 0) {
free(v);
return (0);
}
v->numVals = 0;
for (a = 0; a < 2; a++) {
for (i = 0; i < numv; i++) {
/*
* Make sure there's a NUL at the end of a string,
* but avoid adding to the allocated length if there's
* already a NUL at the end.
*/
alen += 1;
freeValue(v, 1);
return (0);
}
v->numVals++;
}
}
return (v);
}
__nis_rule_value_t *rv) {
int i, n, nv;
if (val == 0)
return (0);
return (0);
}
/* In N2L, space and tab delimiters are treated the same */
delim = ' ';
/* If the item has multiple values, we split each one independently */
for (i = 0; i < nv; i++) {
char *str;
int s, e;
char *newstr;
continue;
/* Find the next delimiter, or end-of-string */
/*
* 'str[e]' is either a delimiter, or the concluding
* NUL. Make sure it's NUL.
*/
str[e] = '\0';
/* Add to val->val */
if (newval != 0)
for (n = i; n < nv; n++) {
}
return (0);
}
}
}
/* Already freed the nval[i].value's as we traversed nval */
return (val);
}
/*
* Match the format spec 'f[curf]' to the input value string 'str'.
*
* If successful, returns the updated position in the value string 'str'.
* Otherwise, NULL is returned.
*
* curf Current index (i.e., the one we should look at) in 'f'
* nf Number of elements in 'f', including 'mmt_end'
* str The value string we're scanning
* val Pointer to where an item value (if any) should be returned
* Set to NULL if not an 'mmt_item'.
* fmtstart If non-zero on entry, skip characters in 'str' until we find
* the f[curf].type data, if doing so makes any sense. On exit,
* set to the start of the fmt element data (which will be 'str',
* unless we did skip characters)
* sepset List of separators
*/
char *
int i, len;
char *myself = "scanMappingFormat";
/* N2L variables */
int af, skipspaces = 0;
return (0);
/*
* If separator list is NULL (which will be the case for
* nis+2ldap), then simply use empty string
*/
if (sepset == 0)
/* OK if the string also is exhausted */
return (str);
else
return (0);
}
case mmt_berstring:
/* Not a matchable element */
return (0);
}
/*
* If here, it means it's an IP address (N2L case)
* So continue processing as if it was mmt_item
*/
case mmt_item:
/*
* In order to find the end of the item value, we must look
* ahead and determine the start of the next formatting element.
* If successful, 'next' will be the start of the fmt element
* after the next one; we don't care about that, other than to
* check for error.
*
* Since an item match is somewhat like an any match, in that
* we don't know a priori if the first occurence of the next
* element really is the one we want, we have to scan ahead
* until we've reached the end.
*/
int cf;
0, sepset);
if (tmp == 0)
break;
}
if (tmp == 0) {
break;
} else {
return (0);
}
}
return (0);
if (val != 0) {
if (*val == 0)
return (0);
/*
* In N2L, we need to check if *val is truly an
* IP address
*/
if (af == -2) {
"%s:Internal error while "
"processing IPaddress %s",
return (0);
} else if (af == -1) {
"%s:%s is not an IP address",
return (0);
} else if (af == 0) {
"%s:IP address %s is not "
"supported by rfc2307bis",
return (0);
"%s:IPaddress %s converted "
}
}
}
if (fmtstart != 0)
return (start);
case mmt_string:
/*
* Count this as a successful match of an empty
* string.
*/
if (fmtstart != 0)
return (str);
}
/*
* In N2L, if the format string 'mstr' contains only
* whitespaces (spaces and tabs), then it should
* match one or more whitespaces from the input
* string 'str'.
*/
skipspaces = 1;
/*
* Even if there is no whitespace in 'str',
* it's OK. This is to allow formats like
* "%s %s %s" to match inputs like "foo bar".
*/
if (*next == '\0')
} else {
/* No match string in 'str' => failure */
return (0);
}
/* If 'fmtstart' == 0, we require 'next' == 'str' */
return (0);
/* Success; save start of match string if requested */
if (fmtstart != 0)
/* Update position in the value string */
/* Skip whitespaces for N2L */
if (skipspaces == 1)
return (str);
case mmt_single:
if (fmtstart != 0) {
/* Skip ahead until we match */
i++) {
break;
}
}
if (match)
break;
}
if (!match)
return (0);
} else {
break;
}
}
if (!match)
return (0);
}
/* Step over the matched character */
str++;
return (str);
case mmt_any:
/*
* Look ahead to find the beginning of the next element.
* Because a wildcard-match isn't necessarily uniquely
* determined until we've reached the end, we then continue
* to scan ahead.
*/
int cf;
0, sepset);
if (tmp == 0)
break;
}
if (tmp == 0) {
} else if (*tmp == '\0') {
break;
} else {
return (0);
}
}
return (0);
if (fmtstart != 0)
return (start);
case mmt_limit:
if (fmtstart != 0) {
/* Skip to the end */
return (0);
}
}
return (str);
case mmt_begin:
if (fmtstart != 0)
return (str);
case mmt_end:
if (fmtstart != 0) {
/* Skip to the end */
return (str);
}
/* No skipping, so we must be at the end of the value */
return (0);
return (str);
default:
break;
}
return (0);
}
/*
* Verify that the string 'str' matches the mapping format array 'f'.
* Returns 1 in case of a match, 0 otherwise.
*/
int
int n, nf;
/* Count the number of format elements in the format */
nf++;
}
/* Count the mmt_end as well */
nf++;
for (n = 0; n < nf; n++) {
if (str == 0)
break;
}
return ((str != 0) ? 1 : 0);
}
/*
* Perform a match operation. For example, given the rule
* ("{%s}%s", auth_name, public_data)=nisPublicKey
* and assuming that 'nisPublicKey' has the value "{dh640-0}abcdef12345",
* assign "dh640-0" to 'auth_name' and "abcdef12345" to 'public_data'.
*
* Note that this function doesn't perform the actual assignment. Rather,
* it returns an array of __nis_value_t's, with element zero of the value
* array being the new value of the first matched item, element one the
* value of the second matched item, etc. In the example above, we'd
* return a value array with two elements.
*
* If there is more than one input value (inVal->numVals > 1), the
* output array elements will also be multi-valued.
*
* f The match format
* inVal Input value(s)
* numVal Number of elements in the output value array
* sepset List of separators
* outstr Points to the updated position upto which the
* input string has been matched
*/
__nis_value_t **v = 0;
char *myself = "matchMappingItem";
if (f == 0 ||
return (0);
/* Count the number of format elements and items in the format */
nf++;
/*
* Count mmt_item and mmt_berstring (used by N2L to
* represent address %a)
*/
numItems++;
numItems++;
}
/* Count the mmt_end as well */
nf++;
/*
* If no items, there will be no values. This isn't exactly an error
* from the limited point of view of this function, so we return a
* __nis_value_t with zero values.
*/
if (numItems <= 0) {
if (v == 0)
return (0);
if (v[0] == 0) {
sfree(v);
return (0);
}
v[0]->numVals = 0;
v[0]->val = 0;
if (numVals != 0)
*numVals = 1;
return (v);
}
/* Allocate and initialize the return array */
if (v == 0)
return (0);
for (n = 0; n < numItems; n++) {
if (v[n] == 0) {
int j;
for (j = 0; j < n; j++)
freeValue(v[j], 1);
sfree(v);
return (0);
}
v[n]->numVals = 0;
if (v[n]->val == 0) {
int j;
for (j = 0; j < n; j++)
freeValue(v[j], 1);
sfree(v);
return (0);
}
}
}
/* For each input value, perform the match operation */
if (str == 0)
continue;
valstr = 0;
0, sepset);
if (str == 0)
break;
ni++;
} else if (valstr != 0) {
}
}
if (str == 0) {
for (n = 0; n < numItems; n++)
freeValue(v[n], 1);
sfree(v);
return (0);
}
}
if (numVals != 0)
/*
* Update the return string upto the point it has been matched
* This string will be used by the N2L code in its next call
* to this function
*/
if (outstr != 0)
return (v);
}
/*
* Perform an extract operation. For example, given the expression
* (name, "%s.*")
* and assuming 'name' is an item with the value "some.thing", the
* value returned by the extract is "some".
*/
if (val == 0)
return (0);
return (0);
}
/* Sanity check the format; it must have one and only one mmt_item */
{
int numitem;
ftmp++) {
nf++;
numitem++;
}
/* Count the mmt_end as well */
nf++;
if (numitem != 1) {
return (0);
}
}
/* If the item has multiple values, we extract each one independently */
for (i = 0; i < nv; i++) {
char *newstr = 0;
continue;
/*
* We match the whole string, even if we find a value for
* the item before exhausting all format elements. By doing
* this, we ensure that the string really matches the complete
* format specification.
*/
for (n = 0; n < nf; n++) {
if (str == 0)
break;
}
/*
* *str should now be NUL, meaning we've reached the end of
* the string (value), and it completely matched the format.
* If 'str' is NULL, there was an error, and if 'newstr' is
* 0, we somehow failed to obtain a value.
*/
for (n = 0; n < nv; n++) {
}
return (0);
}
}
return (val);
}
/*
* For each value in 'val', remove the last character, provided that
* it matches 'elide'.
*/
void
int i;
continue;
/*
* If the NUL was counted in the length, step back
* over it.
*/
end--;
}
}
}
}
/*
* Obtain the value for the mapping sub-element 'e', given the input
* rule-value 'rv'.
*/
if (e == 0)
return (0);
switch (e->type) {
case me_item:
break;
case me_print:
break;
case me_split:
rv);
break;
case me_extract:
rv, np_ldap_stat);
break;
case me_match:
default:
val = 0;
break;
}
return (val);
}
/*
* Obtain the value of the mapping element 'e', given the input rule-
* value 'rv'. The 'native' mapping type is used when 'rv' is NULL,
* and the result is a string representation of the mapping element;
* in that case, items of the 'native' type are printed without their
* type designation ("nis+" or "ldap").
*/
int *np_ldap_stat;
char *myself = "getMappingElement";
switch (e->type) {
case me_item:
break;
case me_print:
sizeof (tv[0]));
(tv == 0 || np_ldap_stat == 0)) {
val = 0;
break;
}
np_ldap_stat[i] = 0;
tv[i] = getMappingSubElement(
rv, &np_ldap_stat[i]);
}
/*
* if we get NP_LDAP_NO_VALUE to any of the subelement
* and we get NP_LDAP_MAP_SUCCESS to all other subelement
* then we had enough nis+ column values which can
* produce value for this rule, but didn't. So return
* NP_LDAP_RULES_NO_VALUE to indicate to proceed to
* next database id.
*/
if (np_ldap_stat[i] == NP_LDAP_MAP_SUCCESS)
success++;
if (np_ldap_stat[i] == NP_LDAP_NO_VALUE)
novalue++;
}
tv);
}
break;
case me_split:
rv);
break;
case me_match:
/*
* A match doesn't produce an assignable value per se,
* so we shouldn't get one here.
*/
val = 0;
break;
case me_extract:
break;
default:
val = 0;
break;
}
return (val);
}