xref: /illumos-gate/usr/src/lib/libnisdb/ldap_val.h (revision 533affcbc7fc4d0c8132976ea454aaa715fe2307)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2001-2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_LDAP_VAL_H
28 #define	_LDAP_VAL_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 #include <rpcsvc/nis.h>
35 
36 #include "ldap_parse.h"
37 #include "ldap_ruleval.h"
38 
39 /*
40  * If we got values for the columns in the ruleval struct (from LDAP
41  * or got from the query itself) then we assign the status to
42  * NP_LDAP_MAP_SUCCESS. If we have enough NIS+ columns for the
43  * rules to produce a value, but none of the rules produce a
44  * value, then we pass NP_LDAP_RULES_NO_VALUE from
45  * createLdapRequest() as an indication to proceed to the next
46  * table mapping. NP_LDAP_NO_VALUE is used to indicate that
47  * the element didn't have an entry in the LDAP.
48  */
49 #define	NP_LDAP_MAP_SUCCESS 1
50 #define	NP_LDAP_RULES_NO_VALUE 2
51 #define	NP_LDAP_NO_VALUE 3
52 
53 /* Exported functions */
54 __nis_mapping_format_t	*cloneMappingFormat(__nis_mapping_format_t *m);
55 void			freeMappingFormat(__nis_mapping_format_t *m);
56 void			copyIndex(__nis_index_t *old, __nis_index_t *nnew,
57 				int *err);
58 __nis_index_t		*cloneIndex(__nis_index_t *old);
59 void			freeIndex(__nis_index_t *old, bool_t doFree);
60 char			**cloneName(char **name, int numNames);
61 void			freeValue(__nis_value_t *val, int count);
62 __nis_value_t		*cloneValue(__nis_value_t *val, int count);
63 __nis_value_t		*getMappingItemVal(__nis_mapping_item_t *i,
64 				__nis_mapping_item_type_t native,
65 				__nis_rule_value_t *rv, char *berstring,
66 				int *np_ldap_stat);
67 __nis_value_t		*getMappingFormat(__nis_mapping_format_t *f,
68 				__nis_rule_value_t *rv, __nis_format_arg_t at,
69 				void *a, int *numArg);
70 __nis_value_t		*explodeValues(__nis_value_t *v1, __nis_value_t *v2);
71 __nis_value_t		*getMappingFormatArray(__nis_mapping_format_t *a,
72 				__nis_rule_value_t *rv, __nis_format_arg_t at,
73 				int numArgs, void *arg);
74 char			*getIndex(__nis_index_t *i, int *len);
75 char			*getObjSpec(__nis_obj_spec_t *o, int *len);
76 char			*getScope(int scope);
77 char			*getSearchTriple(__nis_search_triple_t *s, int *len);
78 __nis_value_t		*getMappingItem(__nis_mapping_item_t *i,
79 				__nis_mapping_item_type_t native,
80 				__nis_rule_value_t *rv, char *berstring,
81 				int *np_ldap_stat);
82 void			copyObjSpec(__nis_obj_spec_t *old,
83 				__nis_obj_spec_t *nnew, int *err);
84 __nis_obj_spec_t	*cloneObjSpec(__nis_obj_spec_t *old);
85 void			freeObjSpec(__nis_obj_spec_t *old, bool_t doFree);
86 void			copySearchTriple(__nis_search_triple_t *old,
87 				__nis_search_triple_t *nnew, int *err);
88 __nis_search_triple_t	*cloneSearchTriple(__nis_search_triple_t *old);
89 void			freeSearchTriple(__nis_search_triple_t *old,
90 				bool_t doFree);
91 void			copyTripleOrObj(__nis_mapping_item_type_t type,
92 				__nis_triple_or_obj_t *old,
93 				__nis_triple_or_obj_t *nnew, int *err);
94 __nis_triple_or_obj_t	*cloneTripleOrObj(__nis_mapping_item_type_t type,
95 				__nis_triple_or_obj_t *old);
96 void			freeTripleOrObj(__nis_mapping_item_type_t type,
97 				__nis_triple_or_obj_t *old,
98 				bool_t doFree);
99 void			copyItem(__nis_mapping_item_t *old,
100 				__nis_mapping_item_t *nnew, int *err);
101 __nis_mapping_item_t	*cloneItem(__nis_mapping_item_t *old);
102 void			freeMappingItem(__nis_mapping_item_t *item,
103 				int numItems);
104 __nis_mapping_item_t	*concatenateMappingItem(__nis_mapping_item_t *old,
105 				int numItems, __nis_mapping_item_t *cat);
106 __nis_value_t		*concatenateValues(__nis_value_t *v1,
107 				__nis_value_t *v2);
108 __nis_value_t		*splitMappingItem(__nis_mapping_item_t *item,
109 				char delim, __nis_rule_value_t *rv);
110 char			*scanMappingFormat(__nis_mapping_format_t *f,
111 				int curf, int nf, char *str, char **val,
112 				char **fmtstart, char *sepset);
113 int			verifyMappingMatch(__nis_mapping_format_t *f,
114 				char *str);
115 __nis_value_t		**matchMappingItem(__nis_mapping_format_t *f,
116 				__nis_value_t *inVal, int *numVals,
117 				char *sepset, char **outstr);
118 __nis_value_t		*extractMappingItem(__nis_mapping_item_t *item,
119 				__nis_mapping_format_t *f,
120 				__nis_rule_value_t *rv, int *np_ldap_stat);
121 void			stringElide(__nis_value_t *val, char elide);
122 __nis_value_t		*getMappingSubElement(__nis_mapping_sub_element_t *e,
123 				__nis_rule_value_t *rv, int *np_ldap_stat);
124 __nis_value_t		*getMappingElement(__nis_mapping_element_t *e,
125 				__nis_mapping_item_type_t native,
126 				__nis_rule_value_t *rv, int *stat);
127 
128 #ifdef	__cplusplus
129 }
130 #endif
131 
132 #endif	/* _LDAP_VAL_H */
133