Files
Cnomicon/src/libasn1/oer_get_bits.c
2021-01-22 10:16:20 -05:00

72 lines
2.6 KiB
C

/*****************************************************************************
* Copyright (C) 2004-2021
* ProbeStar Technical Systems, LLC
* All Rights Reserved. Proprietary and Confidential.
*============================================================================
*****************************************************************************/
/*****************************************************************************
* includes
*****************************************************************************/
#include "embtypes.h"
#include "asn1oer.h"
/*****************************************************************************
* defines
*****************************************************************************/
/*****************************************************************************
* macros
*****************************************************************************/
#define min(A,B) ((A)<(B)?(A):(B))
#define max(A,B) ((A)>(B)?(A):(B))
/*****************************************************************************
* structs & typedefs
*****************************************************************************/
/*****************************************************************************
* global constants
*****************************************************************************/
/*****************************************************************************
* global variables
*****************************************************************************/
/*****************************************************************************
* static constants
*****************************************************************************/
/*****************************************************************************
* static variables
*****************************************************************************/
/*****************************************************************************
* static prototypes
*****************************************************************************/
/*****************************************************************************
* C functions
*****************************************************************************/
uint64_t oer_get_bitstream(OER_Stream *oer, OER_BitStream *bs, uint max)
{
if (!oer || !bs || !max)
return 0;
bs->value = oer_get_value(oer, max);
bs->max = max;
return max;
}
// from the front (high->low bits)
uint64_t oer_get_bit_bstream(OER_BitStream *bs, uint bit)
{
if (!bs || (bit>=bs->max))
return 0;
return (bs->value & 1<<(bs->max-bit-1));
}