YAZ  5.34.0
odr_tag.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  */
9 #if HAVE_CONFIG_H
10 #include <config.h>
11 #endif
12 
13 #include "odr-priv.h"
14 
15 int odr_peektag(ODR o, int *zclass, int *tag, int *cons)
16 {
17  if (o->direction != ODR_DECODE)
18  {
19  odr_seterror(o, OOTHER, 48);
20  return 0;
21  }
23  return 0;
24  if (ber_dectag(o->op->bp, zclass, tag, cons, odr_max(o)) <= 0)
25  {
26  odr_seterror(o, OREQUIRED, 49);
27  return 0;
28  }
29  return 1;
30 }
31 
32 int odr_implicit_settag(ODR o, int zclass, int tag)
33 {
34  if (o->error)
35  return 0;
36  if (o->op->t_class < 0)
37  {
38  o->op->t_class = zclass;
39  o->op->t_tag = tag;
40  }
41  return 1;
42 }
43 
44 int odr_initmember(ODR o, void *p, int size)
45 {
46  char **pp = (char **) p;
47 
48  if (o->error)
49  return 0;
50  if (o->direction == ODR_DECODE)
51  *pp = (char *)odr_malloc(o, size);
52  else if (!*pp)
53  {
54  o->op->t_class = -1;
55  return 0;
56  }
57  return 1;
58 }
59 /*
60  * Local variables:
61  * c-basic-offset: 4
62  * c-file-style: "Stroustrup"
63  * indent-tabs-mode: nil
64  * End:
65  * vim: shiftwidth=4 tabstop=8 expandtab
66  */
67 
int ber_dectag(const char *cp, int *zclass, int *tag, int *constructed, int max)
Decodes BER identifier octets.
Definition: ber_tag.c:165
Internal ODR definitions.
#define odr_max(o)
Definition: odr-priv.h:47
#define ODR_STACK_NOT_EMPTY(x)
Definition: odr-priv.h:119
void odr_seterror(ODR o, int error, int id)
Definition: odr.c:118
#define ODR_DECODE
Definition: odr.h:95
#define OREQUIRED
Definition: odr.h:154
#define OOTHER
Definition: odr.h:156
int odr_constructed_more(ODR o)
Definition: odr_cons.c:136
void * odr_malloc(ODR o, size_t size)
Definition: odr_mem.c:31
int odr_initmember(ODR o, void *p, int size)
Definition: odr_tag.c:44
int odr_peektag(ODR o, int *zclass, int *tag, int *cons)
Definition: odr_tag.c:15
int odr_implicit_settag(ODR o, int zclass, int tag)
Definition: odr_tag.c:32
const char * bp
Definition: odr-priv.h:85
int t_class
Definition: odr-priv.h:107
Definition: odr.h:125
struct Odr_private * op
Definition: odr.h:132
int error
Definition: odr.h:128
int direction
Definition: odr.h:126