YAZ  5.25.0
ber_tag.c File Reference

Implements BER tags encoding and decoding. More...

#include <stdio.h>
#include "odr-priv.h"

Go to the source code of this file.


int ber_tag (ODR o, void *p, int zclass, int tag, int *constructed, int opt, const char *name)
 Encode/decode BER tags. More...
int ber_enctag (ODR o, int zclass, int tag, int constructed)
 BER-encode a zclass/tag/constructed package (identifier octets). More...
int ber_dectag (const char *cp, int *zclass, int *tag, int *constructed, int max)
 Decodes BER identifier octets. More...

Detailed Description

Implements BER tags encoding and decoding.

This source file implements BER encoding and decoding of the tags.

Definition in file ber_tag.c.

Function Documentation

◆ ber_dectag()

int ber_dectag ( const char *  cp,
int *  zclass,
int *  tag,
int *  constructed,
int  max 

Decodes BER identifier octets.

Returns number of bytes read or -1 for error.

Definition at line 165 of file ber_tag.c.

Referenced by ber_tag(), completeBER_n(), do_dumpBER(), odr_choice(), and odr_peektag().

◆ ber_enctag()

int ber_enctag ( ODR  o,
int  zclass,
int  tag,
int  constructed 

BER-encode a zclass/tag/constructed package (identifier octets).

Return number of bytes encoded, or -1 if out of bounds.

Definition at line 123 of file ber_tag.c.

References odr_putc.

Referenced by ber_tag().

◆ ber_tag()

int ber_tag ( ODR  o,
void *  p,
int  zclass,
int  tag,
int *  constructed,
int  opt,
const char *  name 

Encode/decode BER tags.

On encoding:

*      if  p: write tag. return 1 (success) or -1 (error).
*      if !p: return 0.

On decoding:

*      if tag && zclass match up, advance pointer and return 1. set cons.
*      else leave pointer unchanged. Return 0.

Definition at line 34 of file ber_tag.c.

References ber_dectag(), ber_enctag(), Odr_private::bp, Odr_ber_tag::br, Odr_private::buf, odr::direction, Odr_ber_tag::lclass, Odr_ber_tag::lcons, Odr_ber_tag::ltag, Odr_private::odr_ber_tag, odr_constructed_more(), ODR_DECODE, ODR_ENCODE, odr_max, ODR_PRINT, ODR_S_SET, odr_seek(), odr_setelement(), odr_seterror(), ODR_STACK_EMPTY, ODR_STACK_NOT_EMPTY, OOTHER, odr::op, OPROTO, OREQUIRED, Odr_private::t_class, and Odr_private::top.

Referenced by odr_bitstring(), odr_bool(), odr_constructed_begin(), odr_cstring(), odr_enum(), odr_iconv_string(), odr_integer(), odr_null(), odr_octetstring(), and odr_oid().