blob: 44f0bb40f86430b57be5b9f8fe6b7e9a90bea88f [file] [log] [blame]
Lev Walkin59b176e2005-11-26 11:25:14 +00001/*
2 * Copyright (c) 2005 Lev Walkin <vlm@lionet.info>. All rights reserved.
3 * Redistribution and modifications are permitted subject to BSD license.
4 */
5#ifndef _PER_SUPPORT_H_
6#define _PER_SUPPORT_H_
7
8#include <asn_system.h> /* Platform-specific types */
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14/*
15 * This structure describes a position inside a PER bit stream.
16 */
17typedef struct asn_per_data_s {
Lev Walkin1d9e8dd2005-12-07 05:46:03 +000018 const uint8_t *buffer; /* Pointer to the octet stream */
19 size_t nboff; /* Bit offset to the meaningful bit */
20 size_t nbits; /* Number of bits in the stream */
Lev Walkin59b176e2005-11-26 11:25:14 +000021} asn_per_data_t;
22
23/*
Lev Walkin60364882005-11-28 06:58:11 +000024 * Extract a small number of bits (<= 31) from the specified PER data pointer.
Lev Walkin59b176e2005-11-26 11:25:14 +000025 * This function returns -1 if the specified number of bits could not be
26 * extracted due to EOD or other conditions.
27 */
28int32_t per_get_few_bits(asn_per_data_t *per_data, int get_nbits);
29
30/*
31 * Extract a large number of bits from the specified PER data pointer.
32 * This function returns -1 if the specified number of bits could not be
33 * extracted due to EOD or other conditions.
34 */
35int per_get_many_bits(asn_per_data_t *pd, uint8_t *dst, int right_align,
36 int get_nbits);
37
38/*
39 * Get the length "n" from the Unaligned PER stream.
40 */
41ssize_t uper_get_length(asn_per_data_t *pd,
42 int effective_bound_bits,
43 int *repeat);
44
45/*
46 * Get the normally small non-negative whole number.
47 */
48ssize_t uper_get_nsnnwn(asn_per_data_t *pd);
49
50#ifdef __cplusplus
51}
52#endif
53
54#endif /* _PER_SUPPORT_H_ */