First code bits of record retrieval code
[yaz-moved-to-github.git] / src / retrieval.c
1 /*
2  * Copyright (C) 2005-2006, Index Data ApS
3  * See the file LICENSE for details.
4  *
5  * $Id: retrieval.c,v 1.1 2006-05-04 20:00:45 adam Exp $
6  */
7 /**
8  * \file retrieval.c
9  * \brief Retrieval utility
10  */
11
12 #if HAVE_CONFIG_H
13 #include <config.h>
14 #endif
15
16 #include <string.h>
17 #include <yaz/retrieval.h>
18 #include <yaz/wrbuf.h>
19 #include <yaz/xmalloc.h>
20 #include <yaz/nmem.h>
21 #include <yaz/tpath.h>
22
23 #if HAVE_XSLT
24 #include <libxml/parser.h>
25 #include <libxml/tree.h>
26 #include <libxml/xinclude.h>
27 #include <libxslt/xsltutils.h>
28 #include <libxslt/transform.h>
29
30 /** \brief The internal structure for yaz_retrieval_t */
31 struct yaz_retrieval_struct {
32     /** \brief memory for configuration */
33     NMEM nmem;
34
35     /** \brief string buffer for error messages */
36     WRBUF wr_error;
37
38     /** \brief record conversion */
39     yaz_record_conv_t record_conv;
40 };
41
42 yaz_retrieval_t yaz_retrieval_create()
43 {
44     yaz_retrieval_t p = xmalloc(sizeof(*p));
45     p->nmem = nmem_create();
46     p->wr_error = wrbuf_alloc();
47     p->record_conv = yaz_record_conv_create();
48     return p;
49 }
50
51 void yaz_retrieval_destroy(yaz_retrieval_t p)
52 {
53     if (p)
54     {
55         nmem_destroy(p->nmem);
56         wrbuf_free(p->wr_error, 1);
57         yaz_record_conv_destroy(p->record_conv);
58         xfree(p);
59     }
60 }
61
62 int yaz_retrieval_configure(yaz_retrieval_t p, const void *node)
63 {
64     wrbuf_rewind(p->wr_error);
65     wrbuf_printf(p->wr_error, "yaz_retrieval_request: not implemented");
66     return -1;
67 }
68
69 int yaz_retrieval_request(yaz_retrieval_t p, const char *schema,
70                           const char *format, yaz_record_conv_t *rc)
71 {
72     wrbuf_rewind(p->wr_error);
73     wrbuf_printf(p->wr_error, "yaz_retrieval_request: not implemented");
74     return -1;
75 }
76
77 const char *yaz_retrieval_get_error(yaz_retrieval_t p)
78 {
79     return wrbuf_buf(p->wr_error);
80 }
81
82 void yaz_retrieval_set_path(yaz_retrieval_t p, const char *path)
83 {
84     yaz_record_conv_set_path(p->record_conv, path);
85 }
86
87 #endif
88
89 /*
90  * Local variables:
91  * c-basic-offset: 4
92  * indent-tabs-mode: nil
93  * End:
94  * vim: shiftwidth=4 tabstop=8 expandtab
95  */
96