2 * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
4 * Redistribution and modifications are permitted subject to BSD license.
6 #include <asn_internal.h>
10 BOOLEAN_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
11 const asn_TYPE_descriptor_t *td,
12 const asn_per_constraints_t *constraints, void **sptr,
15 BOOLEAN_t *st = (BOOLEAN_t *)*sptr;
22 st = (BOOLEAN_t *)(*sptr = MALLOC(sizeof(*st)));
23 if(!st) ASN__DECODE_FAILED;
27 * Extract a single bit
29 switch(per_get_few_bits(pd, 1)) {
30 case 1: *st = 1; break;
31 case 0: *st = 0; break;
32 case -1: default: ASN__DECODE_STARVED;
35 ASN_DEBUG("%s decoded as %s", td->name, *st ? "TRUE" : "FALSE");
44 BOOLEAN_encode_uper(const asn_TYPE_descriptor_t *td,
45 const asn_per_constraints_t *constraints, const void *sptr,
47 const BOOLEAN_t *st = (const BOOLEAN_t *)sptr;
48 asn_enc_rval_t er = { 0, 0, 0 };
52 if(!st) ASN__ENCODE_FAILED;
54 if(per_put_few_bits(po, *st ? 1 : 0, 1))