aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlm <vlm@59561ff5-6e30-0410-9f3c-9617f08c8826>2004-08-19 13:26:36 +0000
committervlm <vlm@59561ff5-6e30-0410-9f3c-9617f08c8826>2004-08-19 13:26:36 +0000
commitaf9cf13e869be5140af18c346afafb77dec690c7 (patch)
tree166747ab987337fed706493f6dc5fcf74836c510
parent970f61dee43f8115b5049d028c068fa9c80b8c18 (diff)
BOOLEAN and NULL have changed their types
git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@142 59561ff5-6e30-0410-9f3c-9617f08c8826
-rw-r--r--skeletons/BOOLEAN.c20
-rw-r--r--skeletons/BOOLEAN.h9
-rw-r--r--skeletons/NULL.h14
3 files changed, 24 insertions, 19 deletions
diff --git a/skeletons/BOOLEAN.c b/skeletons/BOOLEAN.c
index eb89c9c2..4f9b3244 100644
--- a/skeletons/BOOLEAN.c
+++ b/skeletons/BOOLEAN.c
@@ -30,16 +30,16 @@ asn1_TYPE_descriptor_t asn1_DEF_BOOLEAN = {
*/
ber_dec_rval_t
BOOLEAN_decode_ber(asn1_TYPE_descriptor_t *td,
- void **bool_structure, void *buf_ptr, size_t size,
+ void **bool_value, void *buf_ptr, size_t size,
int tag_mode) {
- BOOLEAN_t *st = (BOOLEAN_t *)*bool_structure;
+ BOOLEAN_t *st = (BOOLEAN_t *)*bool_value;
ber_dec_rval_t rval;
ber_dec_ctx_t ctx = { 0, 0, 0, 0 };
ber_tlv_len_t length;
ber_tlv_len_t lidx;
if(st == NULL) {
- (void *)st = *bool_structure = CALLOC(1, sizeof(*st));
+ (void *)st = *bool_value = CALLOC(1, sizeof(*st));
if(st == NULL) {
rval.code = RC_FAIL;
rval.consumed = 0;
@@ -71,22 +71,22 @@ BOOLEAN_decode_ber(asn1_TYPE_descriptor_t *td,
/*
* Compute boolean value.
*/
- for(st->value = 0, lidx = 0;
- (lidx < length) && st->value == 0; lidx++) {
+ for(*st = 0, lidx = 0;
+ (lidx < length) && *st == 0; lidx++) {
/*
* Very simple approach: read bytes until the end or
* value is already TRUE.
* BOOLEAN is not supposed to contain meaningful data anyway.
*/
- st->value |= ((uint8_t *)buf_ptr)[lidx];
+ *st |= ((uint8_t *)buf_ptr)[lidx];
}
rval.code = RC_OK;
rval.consumed += length;
- ASN_DEBUG("Took %ld/%ld bytes to encode %s, value=%ld",
+ ASN_DEBUG("Took %ld/%ld bytes to encode %s, value=%d",
(long)rval.consumed, (long)length,
- td->name, (long)st->value);
+ td->name, *st);
return rval;
}
@@ -109,7 +109,7 @@ BOOLEAN_encode_der(asn1_TYPE_descriptor_t *td, void *sptr,
uint8_t bool_value;
ssize_t ret;
- bool_value = st->value?0xff:0; /* 0xff mandated by DER */
+ bool_value = *st?0xff:0; /* 0xff mandated by DER */
ret = cb(&bool_value, 1, app_key);
if(ret == -1) {
erval.encoded = -1;
@@ -133,7 +133,7 @@ BOOLEAN_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
(void)ilevel; /* Unused argument */
if(st) {
- if(st->value)
+ if(*st)
return cb("TRUE", 4, app_key);
else
return cb("FALSE", 5, app_key);
diff --git a/skeletons/BOOLEAN.h b/skeletons/BOOLEAN.h
index 234e9f8e..6ad69a45 100644
--- a/skeletons/BOOLEAN.h
+++ b/skeletons/BOOLEAN.h
@@ -7,9 +7,12 @@
#include <constr_TYPE.h>
-typedef struct BOOLEAN {
- int value;
-} BOOLEAN_t;
+/*
+ * The underlying integer may contain various values, but everything
+ * non-zero is capped to 0xff by the DER encoder. The BER decoder may
+ * yield non-zero values different from 1, beware.
+ */
+typedef int BOOLEAN_t;
extern asn1_TYPE_descriptor_t asn1_DEF_BOOLEAN;
diff --git a/skeletons/NULL.h b/skeletons/NULL.h
index 14f5ffab..003a5a63 100644
--- a/skeletons/NULL.h
+++ b/skeletons/NULL.h
@@ -2,18 +2,20 @@
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
-#ifndef _NULL_H_
-#define _NULL_H_
+#ifndef ASN_TYPE_NULL_H
+#define ASN_TYPE_NULL_H
#include <constr_TYPE.h>
-typedef struct NULL_s {
- int value;
-} NULL_t;
+/*
+ * The value of the NULL type is meaningless: see BOOLEAN if you want to
+ * carry true/false semantics.
+ */
+typedef int NULL_t;
extern asn1_TYPE_descriptor_t asn1_DEF_NULL;
der_type_encoder_f NULL_encode_der;
asn_struct_print_f NULL_print;
-#endif /* _NULL_H_ */
+#endif /* NULL_H */