+
+ // everything fine, continuing
+
+ Z_PresentResponse *pr = z3950_gdu->u.z3950->u.presentResponse;
+ Z_SRW_searchRetrieveResponse *sru_res = sru_pdu_res->u.response;
+
+
+ // checking non surrogate diagnostics in Z3950 present response package
+ if (!z3950_to_srw_diagnostics_ok(odr_en, sru_pdu_res->u.response,
+ pr->records))
+ return false;
+
+
+
+ // copy all records if existing
+ if (pr->records && pr->records->which == Z_Records_DBOSD)
+ {
+ // srw'fy number of returned records
+ sru_res->num_records
+ = pr->records->u.databaseOrSurDiagnostics->num_records;
+
+ sru_res->records
+ = (Z_SRW_record *) odr_malloc(odr_en,
+ sru_res->num_records
+ * sizeof(Z_SRW_record));
+
+
+ // srw'fy nextRecordPosition
+ // next position never zero or behind the last z3950 record
+ if (pr->nextResultSetPosition
+ && *(pr->nextResultSetPosition) > 0
+ && *(pr->nextResultSetPosition)
+ <= *(sru_pdu_res->u.response->numberOfRecords))
+ sru_res->nextRecordPosition
+ = odr_intdup(odr_en, *(pr->nextResultSetPosition));
+
+ // inserting all records
+ for (int i = 0; i < sru_res->num_records; i++)
+ {
+ Z_NamePlusRecord *npr
+ = pr->records->u.databaseOrSurDiagnostics->records[i];
+
+ sru_res->records[i].recordPosition
+ = odr_intdup(odr_en,
+ i + *(apdu->u.presentRequest->resultSetStartPoint));
+
+ sru_res->records[i].recordPacking = record_packing;
+
+ if (npr->which != Z_NamePlusRecord_databaseRecord)
+ {
+ sru_res->records[i].recordSchema = "diagnostic";
+ sru_res->records[i].recordData_buf = "67";
+ sru_res->records[i].recordData_len = 2;
+ }
+ else
+ {
+ Z_External *r = npr->u.databaseRecord;
+ const int *xml_oid = yaz_string_to_oid(yaz_oid_std(),
+ CLASS_RECSYN,
+ OID_STR_XML);
+ if (xml_oid && r->direct_reference
+ && !oid_oidcmp(r->direct_reference, xml_oid))
+ {
+ sru_res->records[i].recordSchema = "dc";
+ sru_res->records[i].recordData_buf
+ = odr_strdupn(odr_en,
+ (const char *)r->u.octet_aligned->buf,
+ r->u.octet_aligned->len);
+ sru_res->records[i].recordData_len
+ = r->u.octet_aligned->len;
+ }
+ else
+ {
+ sru_res->records[i].recordSchema = "diagnostic";
+ sru_res->records[i].recordData_buf = "67";
+ sru_res->records[i].recordData_len = 2;
+ }
+ }
+ }
+ }
+
+ return true;