yaz_use_attribute_create based on get_attributeList DRY
[yaz-moved-to-github.git] / src / odr_any.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) Index Data
3  * See the file LICENSE for details.
4  */
5
6 /**
7  * \file odr_any.c
8  * \brief Implements ODR ANY codec
9  */
10
11 #if HAVE_CONFIG_H
12 #include <config.h>
13 #endif
14
15 #include "odr-priv.h"
16
17 /**
18  * This is a catch-all type. It stuffs a random ostring (assumed to be properly
19  * encoded) into the stream, or reads a full data element. Implicit tagging
20  * does not work, and neither does the optional flag, unless the element
21  * is the last in a sequence.
22  */
23 int odr_any(ODR o, Odr_any **p, int opt, const char *name)
24 {
25     if (o->error)
26         return 0;
27     if (o->direction == ODR_PRINT)
28     {
29         odr_prname(o, name);
30         odr_printf(o, "ANY (len=%d)\n", (*p)->len);
31         return 1;
32     }
33     if (o->direction == ODR_DECODE)
34         *p = (Odr_oct *)odr_malloc(o, sizeof(**p));
35     if (ber_any(o, p))
36         return 1;
37     *p = 0;
38     return odr_missing(o, opt, name);
39 }
40 /*
41  * Local variables:
42  * c-basic-offset: 4
43  * c-file-style: "Stroustrup"
44  * indent-tabs-mode: nil
45  * End:
46  * vim: shiftwidth=4 tabstop=8 expandtab
47  */
48