Remove the extensive logging
[yaz-moved-to-github.git] / src / copy_types.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 1995-2010 Index Data
3  * See the file LICENSE for details.
4  */
5
6 /** \file copy_types.c
7     \brief Copies various Z39.50 types
8  */
9
10 #include <yaz/copy_types.h>
11
12 /** macro clone_z_type copies a given ASN.1 type */
13 #define clone_z_type(x) \
14 Z_##x *yaz_clone_z_##x(Z_##x *q, NMEM nmem_out) \
15 { \
16     Z_##x *q1 = 0; \
17     ODR enc = odr_createmem(ODR_ENCODE); \
18     ODR dec = odr_createmem(ODR_DECODE); \
19     if (z_##x(enc, &q, 0, 0)) \
20     { \
21         int len; \
22         char *buf = odr_getbuf(enc, &len, 0); \
23         if (buf) \
24         { \
25             odr_setbuf(dec, buf, len, 0); \
26             z_##x(dec, &q1, 0, 0); \
27             nmem_transfer(nmem_out, dec->mem);  \
28         } \
29     } \
30     odr_destroy(enc); \
31     odr_destroy(dec); \
32     return q1; \
33 }
34
35 clone_z_type(NamePlusRecord)
36 clone_z_type(RPNQuery)
37 clone_z_type(Query)
38 clone_z_type(RecordComposition)
39
40 Z_RPNQuery *yaz_copy_z_RPNQuery(Z_RPNQuery *q, ODR out)
41 {
42     return yaz_clone_z_RPNQuery(q, out->mem);
43 }
44
45 Z_Query *yaz_copy_Z_Query(Z_Query *q, ODR out)
46 {
47     return yaz_clone_z_Query(q, out->mem);
48 }
49
50 /*
51  * Local variables:
52  * c-basic-offset: 4
53  * c-file-style: "Stroustrup"
54  * indent-tabs-mode: nil
55  * End:
56  * vim: shiftwidth=4 tabstop=8 expandtab
57  */
58