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