Commit | Line | Data |
---|---|---|
04c6839a WJ |
1 | /* correlate.c - correlate search results */ |
2 | ||
3 | #ifndef lint | |
4 | static char *rcsid = "$Header: /f/osi/dsap/common/RCS/correlate.c,v 7.2 91/02/22 09:18:51 mrose Interim $"; | |
5 | #endif | |
6 | ||
7 | /* | |
8 | * $Header: /f/osi/dsap/common/RCS/correlate.c,v 7.2 91/02/22 09:18:51 mrose Interim $ | |
9 | * | |
10 | * | |
11 | * $Log: correlate.c,v $ | |
12 | * Revision 7.2 91/02/22 09:18:51 mrose | |
13 | * Interim 6.8 | |
14 | * | |
15 | * Revision 7.1 90/07/09 14:34:13 mrose | |
16 | * sync | |
17 | * | |
18 | * Revision 7.0 89/11/23 21:41:58 mrose | |
19 | * Release 6.0 | |
20 | * | |
21 | */ | |
22 | ||
23 | /* | |
24 | * NOTICE | |
25 | * | |
26 | * Acquisition, use, and distribution of this module and related | |
27 | * materials are subject to the restrictions of a license agreement. | |
28 | * Consult the Preface in the User's Manual for the full terms of | |
29 | * this agreement. | |
30 | * | |
31 | */ | |
32 | ||
33 | ||
34 | /* LINTLIBRARY */ | |
35 | ||
36 | #include "quipu/util.h" | |
37 | #include "quipu/list.h" /* to get LSR # defs */ | |
38 | #include "quipu/ds_search.h" | |
39 | ||
40 | extern LLog * log_dsap; | |
41 | int entryinfo_print(); | |
42 | int dn_print(); | |
43 | ||
44 | correlate_search_results(sr_res) | |
45 | struct ds_search_result * sr_res; | |
46 | { | |
47 | struct ds_search_result * sr_tmp; | |
48 | struct ds_search_result * sr_last; | |
49 | ||
50 | DLOG(log_dsap, LLOG_DEBUG, ("correlate_search_results() ")); | |
51 | ||
52 | if(sr_res->srr_correlated) | |
53 | { | |
54 | DLOG(log_dsap, LLOG_DEBUG, ("Already correlated! ")); | |
55 | return; | |
56 | } | |
57 | ||
58 | DLOG(log_dsap, LLOG_DEBUG, ("Not yet correlated! ")); | |
59 | ||
60 | for(sr_tmp = sr_res->srr_un.srr_parts; sr_tmp != NULLSRR; sr_tmp = sr_tmp->srr_next) | |
61 | { | |
62 | DLOG(log_dsap, LLOG_DEBUG, ("correlate_search_results(A Result Part)")); | |
63 | correlate_search_results(sr_tmp); | |
64 | } | |
65 | ||
66 | sr_tmp = sr_res->srr_un.srr_parts; | |
67 | sr_res->srr_correlated = TRUE; | |
68 | sr_res->srr_un.srr_unit = (struct ds_search_unit *) malloc(sizeof(struct ds_search_unit)); | |
69 | sr_res->CSR_object = NULLDN; | |
70 | sr_res->CSR_entries = NULLENTRYINFO; | |
71 | sr_res->CSR_limitproblem = LSR_NOLIMITPROBLEM; | |
72 | sr_res->CSR_cr = NULLCONTINUATIONREF; | |
73 | sr_res->CSR_common.cr_requestor = NULLDN; | |
74 | sr_res->CSR_common.cr_aliasdereferenced = FALSE; | |
75 | ||
76 | while(sr_tmp != NULLSRR) | |
77 | { | |
78 | merge_search_results(sr_res, sr_tmp); | |
79 | sr_last = sr_tmp; | |
80 | sr_tmp = sr_tmp->srr_next; | |
81 | sr_last->srr_next = NULLSRR; | |
82 | DLOG(log_dsap, LLOG_DEBUG, ("Before search_results_free")); | |
83 | search_result_free(sr_last); | |
84 | DLOG(log_dsap, LLOG_DEBUG, ("After search_results_free")); | |
85 | } | |
86 | } | |
87 | ||
88 | merge_search_results(sr_res, sr_tmp) | |
89 | struct ds_search_result * sr_res; | |
90 | struct ds_search_result * sr_tmp; | |
91 | { | |
92 | ContinuationRef cr_tmp; | |
93 | ||
94 | DLOG(log_dsap, LLOG_DEBUG, ("merge_search_results")); | |
95 | ||
96 | if(sr_tmp == NULLSRR) | |
97 | return; | |
98 | ||
99 | if (sr_res->CSR_entries == NULLENTRYINFO) | |
100 | { | |
101 | DLOG(log_dsap, LLOG_DEBUG, ("Before inserting entries")); | |
102 | sr_res->CSR_entries = sr_tmp->CSR_entries; | |
103 | } | |
104 | else | |
105 | { | |
106 | #ifdef HEAVYDEBUG | |
107 | pslog(log_dsap, LLOG_DEBUG, "Before merging entries", entryinfo_print, (caddr_t) sr_res->CSR_entries); | |
108 | #endif | |
109 | entryinfo_merge (sr_res->CSR_entries,sr_tmp->CSR_entries); | |
110 | } | |
111 | sr_tmp->CSR_entries = NULLENTRYINFO; | |
112 | ||
113 | DLOG(log_dsap, LLOG_DEBUG, ("Before merging limitproblems")); | |
114 | ||
115 | if(sr_res->CSR_limitproblem == LSR_NOLIMITPROBLEM) | |
116 | sr_res->CSR_limitproblem = sr_tmp->CSR_limitproblem; | |
117 | ||
118 | DLOG(log_dsap, LLOG_DEBUG, ("Before merging ContinuationRefs")); | |
119 | ||
120 | if(sr_tmp->CSR_cr != NULLCONTINUATIONREF) | |
121 | { | |
122 | for(cr_tmp = sr_tmp->CSR_cr; cr_tmp->cr_next != NULLCONTINUATIONREF; cr_tmp = cr_tmp->cr_next) | |
123 | { | |
124 | #ifdef DEBUG | |
125 | pslog(log_dsap, LLOG_DEBUG, "Another new ref:", dn_print, (caddr_t) cr_tmp->cr_name); | |
126 | #endif | |
127 | } | |
128 | #ifdef DEBUG | |
129 | pslog(log_dsap, LLOG_DEBUG, "Another new ref:", dn_print, (caddr_t) cr_tmp->cr_name); | |
130 | #endif | |
131 | cr_tmp->cr_next = sr_res->CSR_cr; | |
132 | sr_res->CSR_cr = sr_tmp->CSR_cr; | |
133 | sr_tmp->CSR_cr = NULLCONTINUATIONREF; | |
134 | } | |
135 | else | |
136 | { | |
137 | DLOG(log_dsap, LLOG_DEBUG, ("No new references to merge")); | |
138 | } | |
139 | ||
140 | #ifdef DEBUG | |
141 | if(sr_res->CSR_cr != NULLCONTINUATIONREF) | |
142 | { | |
143 | for(cr_tmp = sr_res->CSR_cr; cr_tmp != NULLCONTINUATIONREF; cr_tmp = cr_tmp->cr_next) | |
144 | { | |
145 | pslog(log_dsap, LLOG_DEBUG, "ref entry:", dn_print, (caddr_t) cr_tmp->cr_name); | |
146 | } | |
147 | } | |
148 | else | |
149 | { | |
150 | DLOG(log_dsap, LLOG_DEBUG, ("No references")); | |
151 | } | |
152 | #endif | |
153 | DLOG(log_dsap, LLOG_DEBUG, ("After merging results:")); | |
154 | ||
155 | } | |
156 | ||
157 | search_result_free(arg) | |
158 | struct ds_search_result * arg; | |
159 | { | |
160 | DLOG(log_dsap, LLOG_DEBUG, ("search_result_free")); | |
161 | ||
162 | if(arg == NULLSRR) | |
163 | { | |
164 | LLOG(log_dsap, LLOG_EXCEPTIONS, ("Lost part of search structure somewhere!")); | |
165 | return; | |
166 | } | |
167 | ||
168 | if(arg->srr_correlated) | |
169 | { | |
170 | DLOG(log_dsap, LLOG_DEBUG, ("search_result_free - correlated")); | |
171 | /* | |
172 | dn_free (arg->CSR_common.cr_requestor); | |
173 | */ | |
174 | dn_free (arg->CSR_object); | |
175 | entryinfo_free (arg->CSR_entries,0); | |
176 | crefs_free (arg->CSR_cr); | |
177 | free((char *)arg->srr_un.srr_unit); | |
178 | } | |
179 | else | |
180 | { | |
181 | DLOG(log_dsap, LLOG_DEBUG, ("search_result_free - uncorrelated")); | |
182 | search_result_free(arg->srr_un.srr_parts); | |
183 | free((char *)arg->srr_un.srr_parts); | |
184 | } | |
185 | ||
186 | DLOG(log_dsap, LLOG_DEBUG, ("After freeing parts")); | |
187 | ||
188 | if(arg->srr_next != NULLSRR) | |
189 | { | |
190 | search_result_free(arg->srr_next); | |
191 | free((char *)arg->srr_next); | |
192 | } | |
193 | ||
194 | DLOG(log_dsap, LLOG_DEBUG, ("After freeing next")); | |
195 | ||
196 | return; | |
197 | } | |
198 |