+
+void yf::Virt_db::Frontend::fixup_npr(Z_Records *records, std::string database,
+ ODR odr)
+{
+ if (records && records->which == Z_Records_DBOSD)
+ {
+ Z_NamePlusRecordList *nprlist = records->u.databaseOrSurDiagnostics;
+ int i;
+ for (i = 0; i < nprlist->num_records; i++)
+ {
+ Z_NamePlusRecord *npr = nprlist->records[i];
+ npr->databaseName = odr_strdup(odr, database.c_str());
+ }
+ }
+}
+
+void yf::Virt_db::Frontend::fixup_npr(Package &p, BackendPtr b)
+{
+ Z_GDU *gdu = p.response().get();
+ mp::odr odr;
+ std::string database = "dummy";
+ std::list<std::string>::const_iterator db_it =
+ b->m_frontend_databases.begin();
+ if (db_it != b->m_frontend_databases.end())
+ database = *db_it;
+
+ if (gdu && gdu->which == Z_GDU_Z3950 && gdu->u.z3950->which ==
+ Z_APDU_presentResponse)
+ {
+ fixup_npr(gdu->u.z3950->u.presentResponse->records, database, odr);
+ p.response() = gdu;
+ }
+ if (gdu && gdu->which == Z_GDU_Z3950 && gdu->u.z3950->which ==
+ Z_APDU_searchResponse)
+ {
+ fixup_npr(gdu->u.z3950->u.searchResponse->records, database, odr);
+ p.response() = gdu;
+ }
+
+}
+