First code bits of record retrieval code
[yaz-moved-to-github.git] / include / yaz / retrieval.h
1 /*
2  * Copyright (C) 2005-2006, Index Data ApS
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and
5  * its documentation, in whole or in part, for any purpose, is hereby granted,
6  * provided that:
7  *
8  * 1. This copyright and permission notice appear in all copies of the
9  * software and its documentation. Notices of copyright or attribution
10  * which appear at the beginning of any file must remain unchanged.
11  *
12  * 2. The name of Index Data or the individual authors may not be used to
13  * endorse or promote products derived from this software without specific
14  * prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
18  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
19  * IN NO EVENT SHALL INDEX DATA BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
20  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
21  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR
22  * NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24  * OF THIS SOFTWARE.
25  *
26  * $Id: retrieval.h,v 1.1 2006-05-04 20:00:45 adam Exp $
27  */
28 /**
29  * \file retrieval.h
30  * \brief Retrieval Utility
31  */
32
33 #ifndef YAZ_RETRIEVAL_H
34 #define YAZ_RETRIEVAL_H
35
36 #include <stddef.h>
37 #include <yaz/wrbuf.h>
38 #include <yaz/yconfig.h>
39
40 #include <yaz/record_conv.h>
41
42 YAZ_BEGIN_CDECL
43
44 /** retrieval handle  */
45 typedef struct yaz_retrieval_struct *yaz_retrieval_t;
46
47 /** creates retrieval handle
48     \return retrieval handle
49 */
50 YAZ_EXPORT yaz_retrieval_t yaz_retrieval_create(void);
51
52 /** destroys retrieval handle
53     \param p retrieval handle
54 */
55 YAZ_EXPORT void yaz_retrieval_destroy(yaz_retrieval_t p);
56
57 /** configures retrieval
58     \param p retrieval handle
59     \param node xmlNode pointer (root element of XML config)
60     \retval 0 success
61     \retval -1 failure
62
63     On failure, use yaz_retrieval_get_error to get error string.
64     
65     For retrieval:
66     \verbatim
67     <retrievalinfo>
68        <retrieval syntax="usmarc" name="marcxml"
69             identifier="info:srw/schema/1/marcxml-v1.1"
70        >
71          <title>MARCXML</title>
72          <backend syntax="xml" name="dc" charset="utf-8"/>
73          <convert>
74             <marc inputformat="marc" outputformat="marcxml"
75                          inputcharset="marc-8"/>
76             <xslt stylesheet="marcxml2mods.xsl"/>
77             <xslt stylesheet="mods2dc.xsl"/>
78          </convert>
79        </retrieval>
80     </retrievalinfo>
81     \endverbatim
82 */
83 YAZ_EXPORT
84 int yaz_retrieval_configure(yaz_retrieval_t p, const void *node);
85
86
87 /** performs retrieval request based on schema and format
88     \param p retrieval handle
89     \param schema record schema / element set name (Z39.50)
90     \param format record format (syntax)
91     \param rc record conversion reference (holds conversion upon success)
92     \retval 0 success
93     \retval -1 falure
94 */
95 YAZ_EXPORT
96 int yaz_retrieval_request(yaz_retrieval_t p, const char *schema,
97                           const char *format, yaz_record_conv_t *rc);
98
99 /** returns error string (for last error)
100     \param p record conversion handle
101     \return error string
102 */    
103 YAZ_EXPORT
104 const char *yaz_retrieval_get_error(yaz_retrieval_t p);
105
106
107 /** set path for opening stylesheets etc.
108     \param p record conversion handle
109     \param path file path (UNIX style with : / Windows with ;)
110 */    
111 YAZ_EXPORT
112 void yaz_retrieval_set_path(yaz_retrieval_t p, const char *path);
113
114 YAZ_END_CDECL
115
116 #endif
117 /*
118  * Local variables:
119  * c-basic-offset: 4
120  * indent-tabs-mode: nil
121  * End:
122  * vim: shiftwidth=4 tabstop=8 expandtab
123  */
124