Commit | Line | Data |
---|---|---|
04c6839a WJ |
1 | /* ufn_aei.c - user-friendly aei lookup */ |
2 | ||
3 | #ifndef lint | |
4 | static char *rcsid = "$Header: /f/osi/dsap/common/RCS/ufn_aet.c,v 7.3 91/02/22 09:20:41 mrose Interim $"; | |
5 | #endif | |
6 | ||
7 | /* | |
8 | * $Header: /f/osi/dsap/common/RCS/ufn_aet.c,v 7.3 91/02/22 09:20:41 mrose Interim $ | |
9 | * | |
10 | * | |
11 | * $Log: ufn_aet.c,v $ | |
12 | * Revision 7.3 91/02/22 09:20:41 mrose | |
13 | * Interim 6.8 | |
14 | * | |
15 | * Revision 7.2 90/10/17 11:43:06 mrose | |
16 | * sync | |
17 | * | |
18 | * Revision 7.1 90/07/09 14:35:17 mrose | |
19 | * sync | |
20 | * | |
21 | * Revision 7.0 90/06/20 08:40:43 mrose | |
22 | * *** empty log message *** | |
23 | * | |
24 | */ | |
25 | ||
26 | /* | |
27 | * NOTICE | |
28 | * | |
29 | * Acquisition, use, and distribution of this module and related | |
30 | * materials are subject to the restrictions of a license agreement. | |
31 | * Consult the Preface in the User's Manual for the full terms of | |
32 | * this agreement. | |
33 | * | |
34 | */ | |
35 | ||
36 | ||
37 | #include "quipu/ufn.h" | |
38 | #include "quipu/list.h" | |
39 | #include "quipu/ds_search.h" | |
40 | #include "quipu/connection.h" /* ds_search uses di_block - include this for lint !!! */ | |
41 | #include "quipu/dua.h" | |
42 | ||
43 | extern LLog * log_dsap; | |
44 | extern LLog * addr_log; | |
45 | ||
46 | extern Filter ocfilter (); | |
47 | extern Filter joinfilter (); | |
48 | ||
49 | extern char PY_pepy[]; | |
50 | void PY_advise (); | |
51 | ||
52 | ||
53 | static Filter aet_filter (context) | |
54 | char * context; | |
55 | { | |
56 | Filter a,b; | |
57 | ||
58 | if ((a = ocfilter ("ApplicationEntity")) == NULLFILTER) | |
59 | return NULLFILTER; | |
60 | ||
61 | b = filter_alloc (); | |
62 | b->flt_next = a; | |
63 | b->flt_type = FILTER_ITEM; | |
64 | b->FUITEM.fi_type = FILTERITEM_EQUALITY; | |
65 | if ((b->FUITEM.UNAVA.ava_type = AttrT_new (APPLCTX_OID)) == NULLAttrT) { | |
66 | LLOG (log_dsap,LLOG_EXCEPTIONS,("supported application context attribute unknown")) | |
67 | return NULLFILTER; | |
68 | } | |
69 | b->FUITEM.UNAVA.ava_value = str2AttrV(context, | |
70 | b->FUITEM.UNAVA.ava_type->oa_syntax); | |
71 | if (b->FUITEM.UNAVA.ava_value == NULLAttrV) { | |
72 | LLOG (log_dsap,LLOG_EXCEPTIONS,("'%s' unknown OID",context)); | |
73 | return NULLFILTER; | |
74 | } | |
75 | ||
76 | return joinfilter (b,FILTER_AND); | |
77 | } | |
78 | ||
79 | static aet_search (base, subtree, filt, res) | |
80 | DN base; | |
81 | char subtree; | |
82 | Filter filt; | |
83 | DNS * res; | |
84 | { | |
85 | struct ds_search_arg search_arg; | |
86 | static struct ds_search_result result; | |
87 | struct DSError err; | |
88 | static CommonArgs ca = default_common_args; | |
89 | EntryInfo * ptr; | |
90 | DNS newdns, r = NULLDNS; | |
91 | ||
92 | search_arg.sra_baseobject = base; | |
93 | search_arg.sra_filter = filt; | |
94 | if (subtree) | |
95 | search_arg.sra_subset = SRA_WHOLESUBTREE; | |
96 | else | |
97 | search_arg.sra_subset = SRA_ONELEVEL; | |
98 | search_arg.sra_searchaliases = TRUE; | |
99 | search_arg.sra_common = ca; /* struct copy */ | |
100 | search_arg.sra_eis.eis_infotypes = TRUE; | |
101 | search_arg.sra_eis.eis_allattributes = TRUE; | |
102 | search_arg.sra_eis.eis_select = NULLATTR; | |
103 | ||
104 | if (ds_search (&search_arg, &err, &result) != DS_OK) { | |
105 | log_ds_error (&err); | |
106 | ds_error_free (&err); | |
107 | return FALSE; | |
108 | } | |
109 | ||
110 | correlate_search_results (&result); | |
111 | ||
112 | dn_free (result.CSR_object); | |
113 | ||
114 | if ( (result.CSR_limitproblem != LSR_NOLIMITPROBLEM) || (result.CSR_cr != NULLCONTINUATIONREF)) { | |
115 | crefs_free (result.CSR_cr); | |
116 | ||
117 | if ( ! result.CSR_entries) | |
118 | return FALSE; | |
119 | } | |
120 | ||
121 | for (ptr = result.CSR_entries; ptr != NULLENTRYINFO; ptr=ptr->ent_next) { | |
122 | cache_entry (ptr,FALSE,TRUE); | |
123 | newdns = dn_seq_alloc(); | |
124 | newdns->dns_next = r; | |
125 | newdns->dns_dn = dn_cpy (ptr->ent_dn); | |
126 | r = newdns; | |
127 | } | |
128 | entryinfo_free (result.CSR_entries,0); | |
129 | ||
130 | *res = r; | |
131 | ||
132 | return TRUE; | |
133 | } | |
134 | ||
135 | ||
136 | aet_match (c,v,interact,result,el,context) | |
137 | int c; | |
138 | char ** v; | |
139 | DNS *result; | |
140 | DNS (* interact) (); | |
141 | envlist el; | |
142 | char * context; | |
143 | { | |
144 | DNS ufnr = NULLDNS; | |
145 | DNS newap = NULLDNS; | |
146 | DNS apps = NULLDNS; | |
147 | DNS dns, DNS_append(); | |
148 | Filter filt; | |
149 | int ok = TRUE; | |
150 | ||
151 | if (!ufn_match (c,v,interact,&ufnr,el)) { | |
152 | if (PY_pepy[0]) { | |
153 | char buffer[BUFSIZ]; | |
154 | ||
155 | (void) sprintf (buffer, "ufn_match failed: %s", PY_pepy); | |
156 | (void) strcpy (PY_pepy, buffer); | |
157 | SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP, ("%s", PY_pepy)); | |
158 | } | |
159 | *result = NULLDNS; | |
160 | return FALSE; | |
161 | } | |
162 | ||
163 | filt = aet_filter(context); | |
164 | ||
165 | for (dns = ufnr; dns != NULLDNS; dns=dns->dns_next) { | |
166 | newap = NULLDNS; | |
167 | if (aet_search (dns->dns_dn,FALSE,filt,&newap)) | |
168 | apps = DNS_append (apps,newap); | |
169 | else | |
170 | ok = FALSE; | |
171 | } | |
172 | ||
173 | if ((apps == NULLDNS) && ok) { | |
174 | /* go deeper */ | |
175 | for (dns = ufnr; dns != NULLDNS; dns=dns->dns_next) { | |
176 | if (dns->dns_dn->dn_parent == NULLDN) | |
177 | /* too high for subtree search */ | |
178 | continue; | |
179 | newap = NULLDNS; | |
180 | if (aet_search (dns->dns_dn,TRUE,filt,&newap)) | |
181 | apps = DNS_append (apps,newap); | |
182 | else | |
183 | ok = FALSE; | |
184 | } | |
185 | } | |
186 | ||
187 | if (!ok && !apps) { | |
188 | PY_advise (NULLCP, | |
189 | "search for applicationEntity supporting \"%s\" failed", | |
190 | context); | |
191 | SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP, ("%s", PY_pepy)); | |
192 | } | |
193 | ||
194 | filter_free (filt); | |
195 | ||
196 | dn_seq_free (ufnr); | |
197 | ||
198 | *result = apps; | |
199 | ||
200 | return ok; | |
201 | } |