1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2011 Index Data
3 * See the file LICENSE for details.
6 \brief Copies various Z39.50 types
12 #include <yaz/copy_types.h>
14 /** macro clone_z_type copies a given ASN.1 type */
15 #define clone_z_type(x) \
16 Z_##x *yaz_clone_z_##x(Z_##x *q, NMEM nmem_out) \
19 ODR enc = odr_createmem(ODR_ENCODE); \
20 ODR dec = odr_createmem(ODR_DECODE); \
21 if (z_##x(enc, &q, 0, 0)) \
24 char *buf = odr_getbuf(enc, &len, 0); \
27 odr_setbuf(dec, buf, len, 0); \
28 z_##x(dec, &q1, 0, 0); \
29 nmem_transfer(nmem_out, dec->mem); \
37 clone_z_type(NamePlusRecord)
38 clone_z_type(RPNQuery)
40 clone_z_type(RecordComposition)
42 Z_RPNQuery *yaz_copy_z_RPNQuery(Z_RPNQuery *q, ODR out)
44 return yaz_clone_z_RPNQuery(q, out->mem);
47 Z_Query *yaz_copy_Z_Query(Z_Query *q, ODR out)
49 return yaz_clone_z_Query(q, out->mem);
55 * c-file-style: "Stroustrup"
56 * indent-tabs-mode: nil
58 * vim: shiftwidth=4 tabstop=8 expandtab