+ // let non surrogate dioagnostics in Z3950 present response package
+ // pass to frontend - just return
+ if (pr_res->records
+ && pr_res->records->which == Z_Records_NSD
+ && pr_res->records->u.nonSurrogateDiagnostic)
+ {
+ // we might do more clever tricks to "reverse"
+ // these error(s).
+
+ //*pr_res->records->u.nonSurrogateDiagnostic->condition =
+ // YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS;
+ }
+
+ // record transformation must take place
+ if (rc && pr_res
+ && pr_res->numberOfRecordsReturned
+ && *(pr_res->numberOfRecordsReturned) > 0
+ && pr_res->records
+ && pr_res->records->which == Z_Records_DBOSD
+ && pr_res->records->u.databaseOrSurDiagnostics->num_records)
+ {
+ //transform all records
+ for (int i = 0;
+ i < pr_res->records->u.databaseOrSurDiagnostics->num_records;
+ i++)
+ {
+ Z_NamePlusRecord *npr
+ = pr_res->records->u.databaseOrSurDiagnostics->records[i];
+ if (npr->which == Z_NamePlusRecord_databaseRecord)
+ {
+ WRBUF output_record = wrbuf_alloc();
+ Z_External *r = npr->u.databaseRecord;
+ int ret_trans = 0;
+ if (r->which == Z_External_OPAC)
+ {
+#if YAZ_VERSIONL >= 0x030011
+ ret_trans =
+ yaz_record_conv_opac_record(rc, r->u.opac,
+ output_record);
+#else
+ ;
+#endif
+ }
+ else if (r->which == Z_External_octet)
+ {
+ ret_trans =
+ yaz_record_conv_record(rc, (const char *)
+ r->u.octet_aligned->buf,
+ r->u.octet_aligned->len,
+ output_record);
+ }
+ if (ret_trans == 0)
+ {
+ npr->u.databaseRecord =
+ z_ext_record_oid(odr_en, match_syntax,
+ wrbuf_buf(output_record),
+ wrbuf_len(output_record));
+ }
+ else
+ {
+ pr_res->records->
+ u.databaseOrSurDiagnostics->records[i]
+ = zget_surrogateDiagRec(
+ odr_en, npr->databaseName,
+ YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS,
+ yaz_record_conv_get_error(rc));
+ }
+ wrbuf_destroy(output_record);
+ }
+ }
+ }
+ package.response() = gdu_res;