X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=include%2Fyaz%2Fpquery.h;h=026baa9abeb178bee2b1cb2a3698acc3713319d9;hp=f0a4a5303ce234daa92646c99a3720fb1cb43320;hb=77aaeaf4801a896d3eaa93b8d76a81be82d95bad;hpb=d9ee01635f03f9095a66f71b73580560d48798e8 diff --git a/include/yaz/pquery.h b/include/yaz/pquery.h index f0a4a53..026baa9 100644 --- a/include/yaz/pquery.h +++ b/include/yaz/pquery.h @@ -1,58 +1,33 @@ -/* - * Copyright (c) 1995-1996, Index Data. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation, in whole or in part, for any purpose, is hereby granted, - * provided that: - * - * 1. This copyright and permission notice appear in all copies of the - * software and its documentation. Notices of copyright or attribution - * which appear at the beginning of any file must remain unchanged. - * - * 2. The name of Index Data or the individual authors may not be used to - * endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * IN NO EVENT SHALL INDEX DATA BE LIABLE FOR ANY SPECIAL, INCIDENTAL, - * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR - * NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - * - * $Log: pquery.h,v $ - * Revision 1.1 1999-11-30 13:47:11 adam - * Improved installation. Moved header files to include/yaz. - * - * Revision 1.8 1997/09/01 08:49:50 adam - * New windows NT/95 port using MSV5.0. To export DLL functions the - * YAZ_EXPORT modifier was added. Defined in yconfig.h. - * - * Revision 1.7 1997/05/14 06:53:43 adam - * C++ support. - * - * Revision 1.6 1996/08/12 14:09:24 adam - * Default prefix query attribute set defined by using p_query_attset. +/* This file is part of the YAZ toolkit. + * Copyright (C) 1995-2011 Index Data. + * All rights reserved. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * Revision 1.5 1996/03/15 11:01:46 adam - * Extra argument to p_query_rpn: protocol. - * Extra arguments to p_query_scan: protocol and attributeSet. - * - * Revision 1.4 1995/09/29 17:12:05 quinn - * Smallish - * - * Revision 1.3 1995/09/27 15:02:49 quinn - * Modified function heads & prototypes. - * - * Revision 1.2 1995/05/26 08:56:05 adam - * New function: p_query_scan. - * - * Revision 1.1 1995/05/22 15:31:05 adam - * New function, p_query_rpn, to convert from prefix (ascii) to rpn (asn). + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Index Data nor the names of its contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * \file pquery.h + * \brief Header for PQF parsing */ #ifndef PQUERY_H @@ -61,18 +36,70 @@ #include #include -#ifdef __cplusplus -extern "C" { -#endif +YAZ_BEGIN_CDECL -YAZ_EXPORT Z_RPNQuery *p_query_rpn (ODR o, oid_proto proto, const char *qbuf); +typedef struct yaz_pqf_parser *YAZ_PQF_Parser; -YAZ_EXPORT Z_AttributesPlusTerm *p_query_scan (ODR o, oid_proto proto, - Odr_oid **attributeSetP, const char *qbuf); -YAZ_EXPORT int p_query_attset (const char *arg); +YAZ_EXPORT Z_RPNQuery *p_query_rpn(ODR o, const char *qbuf); -#ifdef __cplusplus -} -#endif +YAZ_EXPORT YAZ_PQF_Parser yaz_pqf_create(void); +YAZ_EXPORT Z_RPNQuery *yaz_pqf_parse(YAZ_PQF_Parser p, ODR o, + const char *qbuf); +YAZ_EXPORT Z_AttributesPlusTerm *yaz_pqf_scan(YAZ_PQF_Parser p, ODR o, + Odr_oid **attributeSetId, + const char *qbuf); + +YAZ_EXPORT Z_AttributeList *yaz_pqf_scan_attribute_list(YAZ_PQF_Parser p, ODR o, + Odr_oid **attributeSetId, + const char *qbuf); + +YAZ_EXPORT +Z_FacetList *yaz_pqf_parse_facet_list(ODR odr, const char *args ); + +YAZ_EXPORT void yaz_pqf_destroy(YAZ_PQF_Parser p); + +YAZ_EXPORT int yaz_pqf_error(YAZ_PQF_Parser p, const char **msg, size_t *off); + +YAZ_EXPORT +Z_Term *z_Term_create(ODR o, int term_type, const char *buf, size_t len); + + +/* no error */ +#define YAZ_PQF_ERROR_NONE 0 + +/* extra token (end of query expected) */ +#define YAZ_PQF_ERROR_EXTRA 1 + +/* missing token (at least one token expected) */ +#define YAZ_PQF_ERROR_MISSING 2 + +/* bad attribute set (for @attr and @attrset) */ +#define YAZ_PQF_ERROR_ATTSET 3 + +/* too many items (limit reached - too many attributes, etc) */ +#define YAZ_PQF_ERROR_TOOMANY 4 + +/* bad format of attribute (missing =) */ +#define YAZ_PQF_ERROR_BADATTR 5 + +/* internal failure */ +#define YAZ_PQF_ERROR_INTERNAL 6 + +/* bad proximity args */ +#define YAZ_PQF_ERROR_PROXIMITY 7 + +/* bad unsigned integer */ +#define YAZ_PQF_ERROR_BAD_INTEGER 8 + +YAZ_END_CDECL #endif +/* + * Local variables: + * c-basic-offset: 4 + * c-file-style: "Stroustrup" + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +