96 Z_PresentRequest *pr = apdu->u.presentRequest;
98 Odr_int total = *pr->numberOfRecordsRequested;
99 Odr_int start = *pr->resultSetStartPoint;
101 Z_NamePlusRecordList *npl = (Z_NamePlusRecordList *)
102 odr_malloc(odr,
sizeof(*npl));
103 npl->num_records = total;
104 npl->records = (Z_NamePlusRecord **)
105 odr_malloc(odr,
sizeof(*npl->records) * total);
106 while (offset < total)
108 Odr_int left = total - offset;
110 Package pp(package.session(), package.origin());
112 *pr->numberOfRecordsRequested =
115 *pr->resultSetStartPoint = start + offset;
117 pp.copy_filter(package);
122 if (pp.session().is_closed())
124 package.session().close();
127 Z_GDU *gdu_res = pp.response().get();
128 if (gdu_res && gdu_res->which == Z_GDU_Z3950 &&
129 gdu_res->u.z3950->which == Z_APDU_presentResponse)
131 Z_PresentResponse *pres =
132 gdu_res->u.z3950->u.presentResponse;
134 pres->records->which == Z_Records_DBOSD)
136 Z_NamePlusRecordList *nprl =
137 pres->records->u.databaseOrSurDiagnostics;
139 for (i = 0; i < nprl->num_records; i++)
142 npl->records[offset+i] = yaz_clone_z_NamePlusRecord(
143 nprl->records[i], o->mem);
145 offset += nprl->num_records;
149 package.response() = pp.response();
155 package.response() = pp.response();
160 yaz_log(YLOG_LOG,
"building response . %lld", offset);
162 Z_APDU *a = zget_APDU(odr, Z_APDU_presentResponse);
163 Z_PresentResponse *pres = a->u.presentResponse;
164 pres->records = (Z_Records *)
165 odr_malloc(odr,
sizeof(Z_Records));
166 pres->records->which = Z_Records_DBOSD;
167 pres->records->u.databaseOrSurDiagnostics = npl;
168 npl->num_records = offset;
169 *pres->numberOfRecordsReturned = offset;
171 package.response() = a;