Bump year
[yaz-moved-to-github.git] / src / odr_any.c
1 /*
2  * Copyright (C) 1995-2005, Index Data ApS
3  * See the file LICENSE for details.
4  *
5  * $Id: odr_any.c,v 1.4 2005-01-15 19:47:14 adam Exp $
6  */
7
8 /**
9  * \file odr_any.c
10  * \brief Implements ODR ANY codec
11  */
12
13 #if HAVE_CONFIG_H
14 #include <config.h>
15 #endif
16
17 #include "odr-priv.h"
18
19 /**
20  * This is a catch-all type. It stuffs a random ostring (assumed to be properly
21  * encoded) into the stream, or reads a full data element. Implicit tagging
22  * does not work, and neither does the optional flag, unless the element
23  * is the last in a sequence.
24  */
25 int odr_any(ODR o, Odr_any **p, int opt, const char *name)
26 {
27     if (o->error)
28         return 0;
29     if (o->direction == ODR_PRINT)
30     {
31         odr_prname(o, name);
32         odr_printf(o, "ANY (len=%d)\n", (*p)->len);
33         return 1;
34     }
35     if (o->direction == ODR_DECODE)
36         *p = (Odr_oct *)odr_malloc(o, sizeof(**p));
37     if (ber_any(o, p))
38         return 1;
39     *p = 0;
40     return odr_missing(o, opt, name);
41 }