Update header about CQL grammar
[yaz-moved-to-github.git] / src / odr_null.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 1995-2013 Index Data
3  * See the file LICENSE for details.
4  */
5 /**
6  * \file odr_null.c
7  * \brief Implements ODR NULL codec
8  */
9 #if HAVE_CONFIG_H
10 #include <config.h>
11 #endif
12
13 #include "odr-priv.h"
14
15 /*
16  * Top level null en/decoder.
17  * Returns 1 on success, 0 on error.
18  */
19 int odr_null(ODR o, Odr_null **p, int opt, const char *name)
20 {
21     int res, cons = 0;
22
23     if (o->error)
24         return 0;
25     if (o->op->t_class < 0)
26     {
27         o->op->t_class = ODR_UNIVERSAL;
28         o->op->t_tag = ODR_NULL;
29     }
30     res = ber_tag(o, p, o->op->t_class, o->op->t_tag, &cons, opt, name);
31     if (res < 0)
32         return 0;
33     if (!res)
34         return odr_missing(o, opt, name);
35     if (o->direction == ODR_PRINT)
36     {
37         odr_prname(o, name);
38         odr_printf(o, "NULL\n");
39         return 1;
40     }
41     if (cons)
42     {
43 #ifdef ODR_STRICT_NULL
44         odr_seterror(OPROTO, 42);
45         return 0;
46 #else
47         /* Warning: Bad NULL */
48 #endif
49     }
50     if (o->direction == ODR_DECODE)
51         *p = odr_nullval();
52     return ber_null(o);
53 }
54 /*
55  * Local variables:
56  * c-basic-offset: 4
57  * c-file-style: "Stroustrup"
58  * indent-tabs-mode: nil
59  * End:
60  * vim: shiftwidth=4 tabstop=8 expandtab
61  */
62