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 19, 2017
1 parent 848bf92 commit bc863e3
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 2 deletions.
2 changes: 2 additions & 0 deletions asn1c/asn1c.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,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 Down
4 changes: 4 additions & 0 deletions libasn1compiler/asn1c_C.c
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,10 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
OUT("asn_struct_free_f %s_free;\n", p);
OUT("asn_struct_print_f %s_print;\n", p);
OUT("asn_constr_check_f %s_constraint;\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);
}
OUT("ber_type_decoder_f %s_decode_ber;\n", p);
OUT("der_type_encoder_f %s_encode_der;\n", p);
OUT("xer_type_decoder_f %s_decode_xer;\n", p);
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
2 changes: 1 addition & 1 deletion libasn1compiler/asn1c_fdeps.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ typedef struct {
int column;
} asn1c_dep_filename;


/*
* Format:
* <observed-name> [<dependent-name> ...]
Expand All @@ -29,6 +28,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_ENABLE_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 @@ -92,6 +92,11 @@ enum asn1c_flags {
* Generate top-level configure.ac and Makefile.am
*/
A1C_GEN_AUTOTOOLS_EXAMPLE = 0x200000,
/*
* -gen-BNER
* Generate BACnet Encoding Rules support code
*/
A1C_GEN_BNER = 0x400000,
};

/*
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
primitive_bner.h primitive_bner.c # BNER primative support
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 bc863e3

Please sign in to comment.