Fix URL of SRU diagnostics list.
[yaz-moved-to-github.git] / src / odr_enum.c
1 /*
2  * Copyright (C) 1995-2005, Index Data ApS
3  * See the file LICENSE for details.
4  *
5  * $Id: odr_enum.c,v 1.5 2005-06-25 15:46:04 adam Exp $
6  */
7 /**
8  * \file odr_enum.c
9  * \brief Implements ODR ENUM codec
10  */
11 #if HAVE_CONFIG_H
12 #include <config.h>
13 #endif
14
15 #include "odr-priv.h"
16
17 /*
18  * Top level enum en/decoder.
19  * Returns 1 on success, 0 on error.
20  */
21 int odr_enum(ODR o, int **p, int opt, const char *name)
22 {
23     int res, cons = 0;
24
25     if (o->error)
26         return 0;
27     if (o->t_class < 0)
28     {
29         o->t_class = ODR_UNIVERSAL;
30         o->t_tag = ODR_ENUM;
31     }
32     if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
33         return 0;
34     if (!res)
35         return odr_missing(o, opt, name);
36     if (o->direction == ODR_PRINT)
37     {
38         odr_prname(o, name);
39         odr_printf(o, "%d\n", **p);
40         return 1;
41     }
42     if (cons)
43     {
44         odr_seterror(o, OPROTO, 54);
45         return 0;
46     }
47     if (o->direction == ODR_DECODE)
48         *p = (int *)odr_malloc(o, sizeof(int));
49     return ber_integer(o, *p);
50 }
51 /*
52  * Local variables:
53  * c-basic-offset: 4
54  * indent-tabs-mode: nil
55  * End:
56  * vim: shiftwidth=4 tabstop=8 expandtab
57  */
58