1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2010 Index Data
3 * See the file LICENSE for details.
7 \brief Copies various Z39.50 types
10 #include <yaz/copy_types.h>
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) \
17 ODR enc = odr_createmem(ODR_ENCODE); \
18 ODR dec = odr_createmem(ODR_DECODE); \
19 if (z_##x(enc, &q, 0, 0)) \
22 char *buf = odr_getbuf(enc, &len, 0); \
25 odr_setbuf(dec, buf, len, 0); \
26 z_##x(dec, &q1, 0, 0); \
27 nmem_transfer(nmem_out, dec->mem); \
35 clone_z_type(NamePlusRecord)
36 clone_z_type(RPNQuery)
38 clone_z_type(RecordComposition)
40 Z_RPNQuery *yaz_copy_z_RPNQuery(Z_RPNQuery *q, ODR out)
42 return yaz_clone_z_RPNQuery(q, out->mem);
45 Z_Query *yaz_copy_Z_Query(Z_Query *q, ODR out)
47 return yaz_clone_z_Query(q, out->mem);
53 * c-file-style: "Stroustrup"
54 * indent-tabs-mode: nil
56 * vim: shiftwidth=4 tabstop=8 expandtab