From 6293bcf2e2aeb3c52caf7e1b68dd76d778eb0205 Mon Sep 17 00:00:00 2001 From: Jon Ringle Date: Tue, 21 Nov 2017 09:23:33 -0500 Subject: [PATCH] BNER support: Add -gen-BNER option --- asn1c/asn1c.c | 4 ++++ asn1c/unber.c | 1 + libasn1compiler/asn1c_C.c | 4 ++++ libasn1compiler/asn1c_fdeps.c | 4 ++++ libasn1compiler/asn1c_fdeps.h | 1 + libasn1compiler/asn1c_save.c | 3 ++- libasn1compiler/asn1compiler.h | 5 +++++ skeletons/file-dependencies | 16 ++++++++++++++++ 8 files changed, 37 insertions(+), 1 deletion(-) diff --git a/asn1c/asn1c.c b/asn1c/asn1c.c index b67f9e710..611f36b30 100644 --- a/asn1c/asn1c.c +++ b/asn1c/asn1c.c @@ -155,6 +155,8 @@ main(int ac, char **av) { asn1_compiler_flags |= A1C_GEN_PER; } else if(strcmp(optarg, "en-OER") == 0) { asn1_compiler_flags |= A1C_GEN_OER; + } else if(strcmp(optarg, "en-BNER") == 0) { + asn1_compiler_flags |= A1C_GEN_BNER; } else if(strcmp(optarg, "en-example") == 0) { asn1_compiler_flags |= A1C_GEN_EXAMPLE; } else if(strcmp(optarg, "en-autotools") == 0) { @@ -171,6 +173,8 @@ main(int ac, char **av) { asn1_compiler_flags &= ~A1C_GEN_PER; } else if(strcmp(optarg, "o-gen-OER") == 0) { asn1_compiler_flags &= ~A1C_GEN_OER; + } else if(strcmp(optarg, "o-gen-BNER") == 0) { + asn1_compiler_flags &= ~A1C_GEN_BNER; } else if(strcmp(optarg, "o-gen-example") == 0) { asn1_compiler_flags &= ~A1C_GEN_EXAMPLE; } else if(strcmp(optarg, "o-gen-autotools") == 0) { diff --git a/asn1c/unber.c b/asn1c/unber.c index a34492116..8904c3aba 100644 --- a/asn1c/unber.c +++ b/asn1c/unber.c @@ -29,6 +29,7 @@ #define ASN_DISABLE_PER_SUPPORT 1 #define ASN_DISABLE_OER_SUPPORT 1 +#define ASN_DISABLE_BNER_SUPPORT 1 #include /* For static string tables */ diff --git a/libasn1compiler/asn1c_C.c b/libasn1compiler/asn1c_C.c index 53831f918..5caa12802 100644 --- a/libasn1compiler/asn1c_C.c +++ b/libasn1compiler/asn1c_C.c @@ -1440,6 +1440,10 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) { OUT("per_type_decoder_f %s_decode_uper;\n", p); OUT("per_type_encoder_f %s_encode_uper;\n", p); } + if(arg->flags & A1C_GEN_BNER) { + OUT("bner_type_decoder_f %s_decode_bner;\n", p); + OUT("bner_type_encoder_f %s_encode_bner;\n", p); + } } REDIR(saved_target); diff --git a/libasn1compiler/asn1c_fdeps.c b/libasn1compiler/asn1c_fdeps.c index 60a52cbb9..d508e4cbc 100644 --- a/libasn1compiler/asn1c_fdeps.c +++ b/libasn1compiler/asn1c_fdeps.c @@ -124,6 +124,10 @@ asn1c_read_file_dependencies(arg_t *arg, const char *datadir) { && strcmp(p, "CODEC-PER:") == 0) { activate = 0; section = FDEP_CODEC_PER; + } else if((arg->flags & A1C_GEN_BNER) + && strcmp(p, "CODEC-BNER:") == 0) { + activate = 1; + section = FDEP_CODEC_BNER; } else { section = FDEP_IGNORE; activate = 0; diff --git a/libasn1compiler/asn1c_fdeps.h b/libasn1compiler/asn1c_fdeps.h index 7b025babb..480fac0ba 100644 --- a/libasn1compiler/asn1c_fdeps.h +++ b/libasn1compiler/asn1c_fdeps.h @@ -29,6 +29,7 @@ typedef struct { FDEP_COMMON_FILES = (1 << 4), /* Section for mandatory dependencies */ FDEP_CODEC_OER = (1 << 5), /* Use contents only if -gen-OER */ FDEP_CODEC_PER = (1 << 6), /* Use contents only if -gen-PER */ + FDEP_CODEC_BNER = (1 << 7), /* Use contents only if -gen-BNER */ } section; /* Some file refers to it */ /* Whether this chain is alive and has to be present in the output */ diff --git a/libasn1compiler/asn1c_save.c b/libasn1compiler/asn1c_save.c index 79f3b244c..a957af59c 100644 --- a/libasn1compiler/asn1c_save.c +++ b/libasn1compiler/asn1c_save.c @@ -145,7 +145,8 @@ asn1c__save_library_makefile(arg_t *arg, const asn1c_dep_chainset *deps, safe_fprintf( mkf, "\n" - "ASN_MODULE_CFLAGS=%s%s", + "ASN_MODULE_CFLAGS=%s%s%s", + (arg->flags & A1C_GEN_BNER) ? "" : "-DASN_DISABLE_BNER_SUPPORT ", (arg->flags & A1C_GEN_OER) ? "" : "-DASN_DISABLE_OER_SUPPORT ", (arg->flags & A1C_GEN_PER) ? "" : "-DASN_DISABLE_PER_SUPPORT "); diff --git a/libasn1compiler/asn1compiler.h b/libasn1compiler/asn1compiler.h index 2901d4079..9337f5984 100644 --- a/libasn1compiler/asn1compiler.h +++ b/libasn1compiler/asn1compiler.h @@ -97,6 +97,11 @@ enum asn1c_flags { * -debug-output-origin-lines */ A1C_DEBUG_OUTPUT_ORIGIN_LINES = 0x400000, + /* + * -gen-BNER + * Generate BACnet Encoding Rules support code + */ + A1C_GEN_BNER = 0x800000, }; /* diff --git a/skeletons/file-dependencies b/skeletons/file-dependencies index 59e2ce68f..f10c38a16 100644 --- a/skeletons/file-dependencies +++ b/skeletons/file-dependencies @@ -65,6 +65,9 @@ per_support.h per_support.c # PER parsing per_decoder.h per_decoder.c # PER decoding support per_encoder.h per_encoder.c # PER encoding support per_opentype.h per_opentype.c # PER "open type" handling +bner_support.h bner_support.c # BNER tag support +bner_decoder.h bner_decoder.c # BNER decoding support +bner_encoder.h bner_encoder.c # BNER encoding support CONVERTER: # THIS IS A SPECIAL SECTION converter-example.c # A default name for the example transcoder @@ -87,3 +90,16 @@ constr_SEQUENCE.h constr_SEQUENCE_oer.c constr_SET_OF.h constr_SET_OF_oer.c CODEC-PER: # THIS IS A SPECIAL SECTION + +CODEC-BNER: # THIS IS A SPECIAL SECTION +constr_CHOICE.h constr_CHOICE_bner.c +constr_SEQUENCE.h constr_SEQUENCE_bner.c +constr_SEQUENCE_OF.h constr_SEQUENCE_OF_bner.c constr_SET_OF.h asn_SEQUENCE_OF.h asn_SET_OF.h +ANY_bner.c ANY.h +BOOLEAN_bner.c BOOLEAN.h +INTEGER_bner.c INTEGER.h +NativeInteger_bner.c NativeInteger.h +NativeReal_bner.c NativeReal.h REAL.h +NULL_bner.c NULL.h +OCTET_STRING_bner.c OCTET_STRING.h +REAL_bner.c REAL.h