Initial commit of files
This commit is contained in:
77
include/asn1common.h
Normal file
77
include/asn1common.h
Normal file
@ -0,0 +1,77 @@
|
||||
#ifndef __ASN1COMMON_INCLUDE__
|
||||
#define __ASN1COMMON_INCLUDE__
|
||||
|
||||
/******************************************************************************
|
||||
* includes
|
||||
*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <memory.h>
|
||||
|
||||
#include "embtypes.h"
|
||||
|
||||
/******************************************************************************
|
||||
* defines
|
||||
*****************************************************************************/
|
||||
|
||||
#define ASN1_UPER_ALIGNED 0
|
||||
#define ASN1_APER_ALIGNED 1
|
||||
#define ASN1_OER_ALIGNED 2
|
||||
|
||||
#define asn1_get_error(S) ((S)->error)
|
||||
|
||||
#define asn1_get_bits_consumed(O) ((O)->consumed)
|
||||
#define asn1_get_bytes_consumed(O) ((O)->consumed?(((O)->consumed-1)/8+1):0)
|
||||
|
||||
#define asn1_init_extension(E) memset((E),0,sizeof(ASN1_Extension))
|
||||
#define asn1_init_bitstream(E) memset((E),0,sizeof(ASN1_BitStream))
|
||||
|
||||
/******************************************************************************
|
||||
* structs & typedefs
|
||||
*****************************************************************************/
|
||||
|
||||
typedef struct _asn1_stream {
|
||||
uint8_t *buf; // pointer to first byte
|
||||
uint8_t *ptr; // pointer to current byte
|
||||
uint8_t alloc; // set if alloc'd
|
||||
uint8_t align; // alignment
|
||||
uint8_t error; // set if error
|
||||
uint16_t bit; // current bit in byte
|
||||
uint16_t max; // maximum bits
|
||||
uint16_t consumed;// bits consumed
|
||||
} ASN1_Stream;
|
||||
|
||||
typedef struct _asn1_bitstream {
|
||||
uint64_t value; // value
|
||||
uint16_t max; // maximum bits
|
||||
} ASN1_BitStream;
|
||||
|
||||
typedef struct _asn1_extension {
|
||||
uint64_t value; // extension+option bits
|
||||
uint8_t ellipses; // 0 or 1
|
||||
uint8_t options; // # options
|
||||
uint16_t length; // length of extension
|
||||
} ASN1_Extension;
|
||||
|
||||
/******************************************************************************
|
||||
* function prototypes
|
||||
*****************************************************************************/
|
||||
/* export C functions to C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void asn1_set_debug(uint8_t flag);
|
||||
extern uint8_t _asn1_debug_on_;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/******************************************************************************
|
||||
* Macros
|
||||
* ***************************************************************************/
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user