X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Ffilter_backend_test.cpp;h=57f6b391bccce008cba449e14237f6513a687f84;hb=409ac276e7194d9aa669b924c1514e1d41a1c482;hp=e025cf9429c483983e1224f79b2416c13777aa28;hpb=a0158b296868f0ebccd31910eed80f2a2f5878cc;p=metaproxy-moved-to-github.git diff --git a/src/filter_backend_test.cpp b/src/filter_backend_test.cpp index e025cf9..57f6b39 100644 --- a/src/filter_backend_test.cpp +++ b/src/filter_backend_test.cpp @@ -1,7 +1,22 @@ -/* $Id: filter_backend_test.cpp,v 1.23 2007-03-08 09:38:31 adam Exp $ +/* $Id: filter_backend_test.cpp,v 1.26 2007-05-09 21:23:09 adam Exp $ Copyright (c) 2005-2007, Index Data. - See the LICENSE file for details +This file is part of Metaproxy. + +Metaproxy is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Metaproxy; see the file LICENSE. If not, write to the +Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ #include "config.hpp" @@ -22,6 +37,7 @@ #include #include #include +#include namespace mp = metaproxy_1; namespace yf = mp::filter; @@ -91,8 +107,6 @@ Z_Records *yf::BackendTest::Rep::fetch( int start, int number, int &error_code, std::string &addinfo, int *number_returned, int *next_position) { - oident *prefformat; - oid_value form; const char *element_set_name = "F"; // default to use if (number + start - 1 > result_set_size || start < 1) @@ -101,21 +115,20 @@ Z_Records *yf::BackendTest::Rep::fetch( return 0; } - if (!(prefformat = oid_getentbyoid(preferredRecordSyntax))) - form = VAL_NONE; - else - form = prefformat->value; - switch(form) + if (!preferredRecordSyntax) + preferredRecordSyntax = odr_oiddup(odr, yaz_oid_recsyn_usmarc); + + if (preferredRecordSyntax) { - case VAL_NONE: - form = VAL_USMARC; - break; - case VAL_USMARC: - case VAL_TEXT_XML: - break; - default: - error_code = YAZ_BIB1_RECORD_SYNTAX_UNSUPP; - return 0; + if (!oid_oidcmp(preferredRecordSyntax, yaz_oid_recsyn_xml)) + ; + else if (!oid_oidcmp(preferredRecordSyntax, yaz_oid_recsyn_usmarc)) + ; + else + { + error_code = YAZ_BIB1_RECORD_SYNTAX_UNSUPP; + return 0; + } } // no element set, "B" and "F" are supported @@ -129,11 +142,14 @@ Z_Records *yf::BackendTest::Rep::fetch( } element_set_name = esn->u.generic; } - if (!strcmp(element_set_name, "B") && form == VAL_USMARC) + if (!strcmp(element_set_name, "B") + && !oid_oidcmp(preferredRecordSyntax, yaz_oid_recsyn_usmarc)) ; // Brief - else if (!strcmp(element_set_name, "F") && form == VAL_USMARC) + else if (!strcmp(element_set_name, "F") + && !oid_oidcmp(preferredRecordSyntax, yaz_oid_recsyn_usmarc)) ; // Full - else if (!strncmp(element_set_name, "FF", 2) && form == VAL_TEXT_XML) + else if (!strncmp(element_set_name, "FF", 2) + && !oid_oidcmp(preferredRecordSyntax, yaz_oid_recsyn_xml)) ; // Huge XML test record else { @@ -171,7 +187,7 @@ Z_Records *yf::BackendTest::Rep::fetch( memcpy(tmp_rec, "", 3); memcpy(tmp_rec + sz - 4, "", 4); - npr->u.databaseRecord = z_ext_record(odr, VAL_TEXT_XML, tmp_rec, sz); + npr->u.databaseRecord = z_ext_record_xml(odr, tmp_rec, sz); xfree(tmp_rec); } else @@ -180,8 +196,8 @@ Z_Records *yf::BackendTest::Rep::fetch( 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)); + npr->u.databaseRecord = z_ext_record_usmarc( + odr, tmp_rec, strlen(tmp_rec)); } }