Fix sample PQF
[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.14 2003-03-11 11:03:31 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 (odr_max(o) < 1)
30         {
31             odr_seterror(o, OPROTO, 39);
32             return 0;
33         }
34         if (*(o->bp++) != 0X00)
35         {
36             odr_seterror(o, OPROTO, 12);
37             return 0;
38         }
39 #ifdef ODR_DEBUG
40         fprintf(stderr, "[NULL]\n");
41 #endif
42         return 1;
43     case ODR_PRINT: return 1;
44     default: odr_seterror(o, OOTHER, 13); return 0;
45     }
46 }