Skip to content

Commit

Permalink
BNER support: Add -gen-BNER option
Browse files Browse the repository at this point in the history
  • Loading branch information
ringlej committed Nov 21, 2017
1 parent 5fcc699 commit 6293bcf
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 1 deletion.
4 changes: 4 additions & 0 deletions asn1c/asn1c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions asn1c/unber.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#define ASN_DISABLE_PER_SUPPORT 1
#define ASN_DISABLE_OER_SUPPORT 1
#define ASN_DISABLE_BNER_SUPPORT 1

#include <asn1parser.h> /* For static string tables */

Expand Down
4 changes: 4 additions & 0 deletions libasn1compiler/asn1c_C.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions libasn1compiler/asn1c_fdeps.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions libasn1compiler/asn1c_fdeps.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
3 changes: 2 additions & 1 deletion libasn1compiler/asn1c_save.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ");

Expand Down
5 changes: 5 additions & 0 deletions libasn1compiler/asn1compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

/*
Expand Down
16 changes: 16 additions & 0 deletions skeletons/file-dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 6293bcf

Please sign in to comment.