vlm | 337167e | 2005-11-26 11:25:14 +0000 | [diff] [blame] | 1 | /* |
| 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 |
| 11 | extern "C" { |
| 12 | #endif |
| 13 | |
| 14 | /* |
| 15 | * This structure describes a position inside a PER bit stream. |
| 16 | */ |
| 17 | typedef struct asn_per_data_s { |
vlm | 4d2ca12 | 2005-12-07 05:46:03 +0000 | [diff] [blame] | 18 | 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 */ |
vlm | 337167e | 2005-11-26 11:25:14 +0000 | [diff] [blame] | 21 | } asn_per_data_t; |
| 22 | |
| 23 | /* |
vlm | 17af7cc | 2005-11-28 06:58:11 +0000 | [diff] [blame] | 24 | * Extract a small number of bits (<= 31) from the specified PER data pointer. |
vlm | 337167e | 2005-11-26 11:25:14 +0000 | [diff] [blame] | 25 | * This function returns -1 if the specified number of bits could not be |
| 26 | * extracted due to EOD or other conditions. |
| 27 | */ |
| 28 | int32_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 | */ |
| 35 | int 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 | */ |
| 41 | ssize_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 | */ |
| 48 | ssize_t uper_get_nsnnwn(asn_per_data_t *pd); |
| 49 | |
| 50 | #ifdef __cplusplus |
| 51 | } |
| 52 | #endif |
| 53 | |
| 54 | #endif /* _PER_SUPPORT_H_ */ |