Header updates
[yaz-moved-to-github.git] / src / ber_null.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 1995-2011 Index Data
3  * See the file LICENSE for details.
4  */
5
6 /** 
7  * \file ber_null.c
8  * \brief Implements ber_null
9  *
10  * This source file implements BER encoding and decoding of
11  * the NULL type.
12  */
13 #if HAVE_CONFIG_H
14 #include <config.h>
15 #endif
16
17 #include "odr-priv.h"
18
19 /** 
20  * ber_null: BER-en/decoder for NULL type.
21  */
22 int ber_null(ODR o)
23 {
24     switch (o->direction)
25     {
26     case ODR_ENCODE:
27         if (odr_putc(o, 0X00) < 0)
28             return 0;
29         return 1;
30     case ODR_DECODE:
31         if (odr_max(o) < 1)
32         {
33             odr_seterror(o, OPROTO, 39);
34             return 0;
35         }
36         if (*(o->bp++) != 0X00)
37         {
38             odr_seterror(o, OPROTO, 12);
39             return 0;
40         }
41         return 1;
42     case ODR_PRINT:
43         return 1;
44     default:
45         odr_seterror(o, OOTHER, 13);
46         return 0;
47     }
48 }
49 /*
50  * Local variables:
51  * c-basic-offset: 4
52  * c-file-style: "Stroustrup"
53  * indent-tabs-mode: nil
54  * End:
55  * vim: shiftwidth=4 tabstop=8 expandtab
56  */
57