1 /* $Id: t7.c,v 1.9 2005-05-11 12:39:38 adam Exp $
2 Copyright (C) 1995-2005
5 This file is part of the Zebra server.
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with Zebra; see the file LICENSE.zebra. If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
26 #include <yaz/sortspec.h>
28 const char *recs[] = {
30 " <title>My title</title>\n"
35 int main(int argc, char **argv)
37 const char *setname1 = "set1";
38 const char *setname2 = "set2";
39 const char *setname3 = "set3";
42 ZebraService zs = start_up(0, argc, argv);
43 ZebraHandle zh = zebra_open (zs);
44 ODR odr_input = odr_createmem (ODR_DECODE);
45 ODR odr_output = odr_createmem (ODR_ENCODE);
46 YAZ_PQF_Parser parser = yaz_pqf_create();
47 Z_RPNQuery *query = yaz_pqf_parse(parser, odr_input, "@attr 1=4 my");
48 Z_SortKeySpecList *spec = yaz_sort_spec (odr_output, "1=4 <");
53 zebra_begin_trans(zh, 0);
55 ret = zebra_search_RPN(zh, odr_input, query, setname1, &hits);
56 if (ret == ZEBRA_FAIL)
58 int code = zebra_errCode(zh);
59 printf("search returned ERROR, OK was expected ret=%d "
60 "code=%d\n", ret, code);
63 ret = zebra_sort(zh, odr_output, 1, &setname1, setname2, spec, &status);
64 if (ret == ZEBRA_FAIL)
66 int code = zebra_errCode(zh);
67 printf("sort A returned ERROR, OK was expected ret=%d status=%d "
68 "code=%d\n", ret, status, code);
72 ret = zebra_sort(zh, odr_output, 1, &setname2, setname3, spec, &status);
73 if (ret == ZEBRA_FAIL)
75 int code = zebra_errCode(zh);
76 printf("sort B returned ERROR, OK was expected ret=%d status=%d "
77 "code=%d\n", ret, status, code);
81 spec = yaz_sort_spec(odr_output, "1=5 <"); /* invalid sort spec */
83 ret = zebra_sort(zh, odr_output, 1, &setname1, setname2, spec, &status);
86 printf("sort C returned OK, ERROR was expected ret=%d status=%d\n",
91 yaz_pqf_destroy(parser);
94 zebra_deleteResultSet(zh, Z_DeleteRequest_list,
95 1, &setnamep, &status);
97 odr_destroy(odr_input);
98 odr_destroy(odr_output);
102 return close_down(zh, zs, 0);