SRW, CQL, 2003
[yaz-moved-to-github.git] / odr / ber_null.c
1 /*
2  * Copyright (c) 1995-2003, Index Data
3  * See the file LICENSE for details.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Id: ber_null.c,v 1.13 2003-01-06 08:20:27 adam Exp $
7  */
8 #if HAVE_CONFIG_H
9 #include <config.h>
10 #endif
11
12 #include "odr-priv.h"
13
14 /*
15  * BER-en/decoder for NULL type.
16  */
17 int ber_null(ODR o)
18 {
19     switch (o->direction)
20     {
21     case ODR_ENCODE:
22         if (odr_putc(o, 0X00) < 0)
23             return 0;
24 #ifdef ODR_DEBUG
25         fprintf(stderr, "[NULL]\n");
26 #endif
27         return 1;
28     case ODR_DECODE:
29         if (*(o->bp++) != 0X00)
30         {
31             o->error = OPROTO;
32             return 0;
33         }
34 #ifdef ODR_DEBUG
35         fprintf(stderr, "[NULL]\n");
36 #endif
37         return 1;
38     case ODR_PRINT: return 1;
39     default: o->error = OOTHER; return 0;
40     }
41 }