1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2009 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)) \
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)
41 Z_RPNQuery *yaz_copy_z_RPNQuery(Z_RPNQuery *q, ODR out)
43 return yaz_clone_z_RPNQuery(q, out->mem);
46 Z_Query *yaz_copy_Z_Query(Z_Query *q, ODR out)
48 return yaz_clone_z_Query(q, out->mem);
54 * c-file-style: "Stroustrup"
55 * indent-tabs-mode: nil
57 * vim: shiftwidth=4 tabstop=8 expandtab