Changed include/yaz/diagbib1.h and added include/yaz/diagsrw.h with
[yaz-moved-to-github.git] / src / ber_null.c
1 /*
2  * Copyright (C) 1995-2005, Index Data ApS
3  * See the file LICENSE for details.
4  *
5  * $Id: ber_null.c,v 1.3 2005-01-15 19:47:11 adam Exp $
6  */
7
8 /** 
9  * \file ber_null.c
10  * \brief Implements ber_null
11  *
12  * This source file implements BER encoding and decoding of
13  * the NULL type.
14  */
15 #if HAVE_CONFIG_H
16 #include <config.h>
17 #endif
18
19 #include "odr-priv.h"
20
21 /** 
22  * ber_null: BER-en/decoder for NULL type.
23  */
24 int ber_null(ODR o)
25 {
26     switch (o->direction)
27     {
28     case ODR_ENCODE:
29         if (odr_putc(o, 0X00) < 0)
30             return 0;
31 #ifdef ODR_DEBUG
32         fprintf(stderr, "[NULL]\n");
33 #endif
34         return 1;
35     case ODR_DECODE:
36         if (odr_max(o) < 1)
37         {
38             odr_seterror(o, OPROTO, 39);
39             return 0;
40         }
41         if (*(o->bp++) != 0X00)
42         {
43             odr_seterror(o, OPROTO, 12);
44             return 0;
45         }
46 #ifdef ODR_DEBUG
47         fprintf(stderr, "[NULL]\n");
48 #endif
49         return 1;
50     case ODR_PRINT:
51         return 1;
52     default:
53         odr_seterror(o, OOTHER, 13);
54         return 0;
55     }
56 }