YAZ  5.34.0
ber_null.c
Go to the documentation of this file.
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) Index Data
3  * See the file LICENSE for details.
4  */
5 
13 #if HAVE_CONFIG_H
14 #include <config.h>
15 #endif
16 
17 #include "odr-priv.h"
18 
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->op->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 
int ber_null(ODR o)
Definition: ber_null.c:22
Internal ODR definitions.
#define odr_putc(o, c)
Definition: odr-priv.h:129
#define odr_max(o)
Definition: odr-priv.h:47
void odr_seterror(ODR o, int error, int id)
Definition: odr.c:118
#define ODR_DECODE
Definition: odr.h:95
#define ODR_PRINT
Definition: odr.h:97
#define OOTHER
Definition: odr.h:156
#define ODR_ENCODE
Definition: odr.h:96
#define OPROTO
Definition: odr.h:157
const char * bp
Definition: odr-priv.h:85
Definition: odr.h:125
struct Odr_private * op
Definition: odr.h:132
int direction
Definition: odr.h:126