1 /* $Id: util.cpp,v 1.3 2005-10-30 18:51:21 adam Exp $
2 Copyright (c) 2005, Index Data.
10 #include <yaz/pquery.h>
13 bool yp2::util::pqf(ODR odr, Z_APDU *apdu, const std::string &q) {
14 YAZ_PQF_Parser pqf_parser = yaz_pqf_create();
16 Z_RPNQuery *rpn = yaz_pqf_parse(pqf_parser, odr, q.c_str());
19 yaz_pqf_destroy(pqf_parser);
22 yaz_pqf_destroy(pqf_parser);
23 Z_Query *query = (Z_Query *) odr_malloc(odr, sizeof(Z_Query));
24 query->which = Z_Query_type_1;
25 query->u.type_1 = rpn;
27 apdu->u.searchRequest->query = query;
31 yp2::odr::odr(int type)
33 m_odr = odr_createmem(type);
38 m_odr = odr_createmem(ODR_ENCODE);
46 yp2::odr::operator ODR() const
51 Z_APDU *yp2::odr::create_close(int reason, const char *addinfo)
53 Z_APDU *apdu = zget_APDU(m_odr, Z_APDU_close);
55 *apdu->u.close->closeReason = reason;
57 apdu->u.close->diagnosticInformation = odr_strdup(m_odr, addinfo);
61 Z_APDU *yp2::odr::create_initResponse(int error, const char *addinfo)
63 Z_APDU *apdu = zget_APDU(m_odr, Z_APDU_initResponse);
66 apdu->u.initResponse->userInformationField =
67 zget_init_diagnostics(m_odr, error, addinfo);
68 *apdu->u.initResponse->result = 0;
76 * indent-tabs-mode: nil
77 * c-file-style: "stroustrup"
79 * vim: shiftwidth=4 tabstop=8 expandtab