Fixed possible buf in proto.c
[yaz-moved-to-github.git] / odr / ber_null.c
1 /*
2  * Copyright (C) 1994, Index Data I/S 
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: ber_null.c,v $
7  * Revision 1.3  1995-03-08 12:12:09  quinn
8  * Added better error checking.
9  *
10  * Revision 1.2  1995/02/09  15:51:46  quinn
11  * Works better now.
12  *
13  * Revision 1.1  1995/02/02  16:21:52  quinn
14  * First kick.
15  *
16  */
17
18 #include <odr.h>
19
20 /*
21  * BER-en/decoder for NULL type.
22  */
23 int ber_null(ODR o, int *val)
24 {
25     switch (o->direction)
26     {
27         case ODR_ENCODE:
28             if (!o->left)
29             {
30                 o->error = OSPACE;
31                 return 0;
32             }
33             *(o->bp++) = 0X00;
34             o->left--;
35 #ifdef ODR_DEBUG
36             fprintf(stderr, "[NULL]\n");
37 #endif
38             return 1;
39         case ODR_DECODE:
40             if (*(o->bp++) != 0X00)
41             {
42                 o->error = OPROTO;
43                 return 0;
44             }
45             o->left--;
46 #ifdef ODR_DEBUG
47             fprintf(stderr, "[NULL]\n");
48 #endif
49             return 1;
50         case ODR_PRINT: return 1;
51         default: o->error = OOTHER; return 0;
52     }
53 }