+Z_Records *yf::BackendTest::Rep::fetch(
+ ODR odr, Odr_oid *preferredRecordSyntax,
+ Z_ElementSetNames *esn,
+ int start, int number, int &error_code, std::string &addinfo,
+ int *number_returned, int *next_position)
+{
+ oident *prefformat;
+ oid_value form;
+
+ if (number + start - 1 > result_set_size || start < 1)
+ {
+ error_code = YAZ_BIB1_PRESENT_REQUEST_OUT_OF_RANGE;
+ return 0;
+ }
+
+ if (!(prefformat = oid_getentbyoid(preferredRecordSyntax)))
+ form = VAL_NONE;
+ else
+ form = prefformat->value;
+ switch(form)
+ {
+ case VAL_NONE:
+ case VAL_USMARC:
+ break;
+ default:
+ error_code = YAZ_BIB1_RECORD_SYNTAX_UNSUPP;
+ return 0;
+ }
+
+ // no element set, "B" and "F" are supported
+ if (esn)
+ {
+ if (esn->which != Z_ElementSetNames_generic)
+ {
+ error_code
+ = YAZ_BIB1_SPECIFIED_ELEMENT_SET_NAME_NOT_VALID_FOR_SPECIFIED_;
+ return 0;
+ }
+ const char *name = esn->u.generic;
+ if (strcmp(name, "B") && strcmp(name, "F"))
+ {
+ error_code
+ = YAZ_BIB1_SPECIFIED_ELEMENT_SET_NAME_NOT_VALID_FOR_SPECIFIED_;
+ addinfo = std::string(name);
+ return 0;
+ }
+ }
+ Z_Records *rec = (Z_Records *) odr_malloc(odr, sizeof(Z_Records));
+ rec->which = Z_Records_DBOSD;
+ rec->u.databaseOrSurDiagnostics = (Z_NamePlusRecordList *)
+ odr_malloc(odr, sizeof(Z_NamePlusRecordList));
+ rec->u.databaseOrSurDiagnostics->num_records = number;
+ rec->u.databaseOrSurDiagnostics->records = (Z_NamePlusRecord **)
+ odr_malloc(odr, sizeof(Z_NamePlusRecord *) * number);
+ int i;
+ for (i = 0; i<number; i++)
+ {
+ rec->u.databaseOrSurDiagnostics->records[i] = (Z_NamePlusRecord *)
+ odr_malloc(odr, sizeof(Z_NamePlusRecord));
+ Z_NamePlusRecord *npr = rec->u.databaseOrSurDiagnostics->records[i];
+ npr->databaseName = 0;
+ npr->which = Z_NamePlusRecord_databaseRecord;
+
+ char *tmp_rec = odr_strdup(odr, marc_record);
+ char offset_str[30];
+ sprintf(offset_str, "test__%09d_", i+start);
+ memcpy(tmp_rec+186, offset_str, strlen(offset_str));
+ npr->u.databaseRecord = z_ext_record(odr, VAL_USMARC,
+ tmp_rec, strlen(tmp_rec));
+
+ }
+ *number_returned = number;
+ if (start + number > result_set_size)
+ *next_position = 0;
+ else
+ *next_position = start + number;
+ return rec;
+}
+
+void yf::BackendTest::process(Package &package) const