Initial commit of files
This commit is contained in:
71
src/libasn1/oer_get_bits.c
Normal file
71
src/libasn1/oer_get_bits.c
Normal file
@ -0,0 +1,71 @@
|
||||
/*****************************************************************************
|
||||
* 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));
|
||||
}
|
||||
Reference in New Issue
Block a user