Skip to content

Commit a95763d

Browse files
committed
BNER support: Add -gen-BNER option
1 parent c79e4df commit a95763d

File tree

8 files changed

+37
-1
lines changed

8 files changed

+37
-1
lines changed

asn1c/asn1c.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ main(int ac, char **av) {
155155
asn1_compiler_flags |= A1C_GEN_PER;
156156
} else if(strcmp(optarg, "en-OER") == 0) {
157157
asn1_compiler_flags |= A1C_GEN_OER;
158+
} else if(strcmp(optarg, "en-BNER") == 0) {
159+
asn1_compiler_flags |= A1C_GEN_BNER;
158160
} else if(strcmp(optarg, "en-example") == 0) {
159161
asn1_compiler_flags |= A1C_GEN_EXAMPLE;
160162
} else if(strcmp(optarg, "en-autotools") == 0) {
@@ -171,6 +173,8 @@ main(int ac, char **av) {
171173
asn1_compiler_flags &= ~A1C_GEN_PER;
172174
} else if(strcmp(optarg, "o-gen-OER") == 0) {
173175
asn1_compiler_flags &= ~A1C_GEN_OER;
176+
} else if(strcmp(optarg, "o-gen-BNER") == 0) {
177+
asn1_compiler_flags &= ~A1C_GEN_BNER;
174178
} else if(strcmp(optarg, "o-gen-example") == 0) {
175179
asn1_compiler_flags &= ~A1C_GEN_EXAMPLE;
176180
} else if(strcmp(optarg, "o-gen-autotools") == 0) {

asn1c/unber.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
#define ASN_DISABLE_PER_SUPPORT 1
3131
#define ASN_DISABLE_OER_SUPPORT 1
32+
#define ASN_DISABLE_BNER_SUPPORT 1
3233

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

libasn1compiler/asn1c_C.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,10 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
14401440
OUT("per_type_decoder_f %s_decode_uper;\n", p);
14411441
OUT("per_type_encoder_f %s_encode_uper;\n", p);
14421442
}
1443+
if(arg->flags & A1C_GEN_BNER) {
1444+
OUT("bner_type_decoder_f %s_decode_bner;\n", p);
1445+
OUT("bner_type_encoder_f %s_encode_bner;\n", p);
1446+
}
14431447
}
14441448

14451449
REDIR(saved_target);

libasn1compiler/asn1c_fdeps.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ asn1c_read_file_dependencies(arg_t *arg, const char *datadir) {
124124
&& strcmp(p, "CODEC-PER:") == 0) {
125125
activate = 0;
126126
section = FDEP_CODEC_PER;
127+
} else if((arg->flags & A1C_GEN_BNER)
128+
&& strcmp(p, "CODEC-BNER:") == 0) {
129+
activate = 1;
130+
section = FDEP_CODEC_BNER;
127131
} else {
128132
section = FDEP_IGNORE;
129133
activate = 0;

libasn1compiler/asn1c_fdeps.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ typedef struct {
2929
FDEP_COMMON_FILES = (1 << 4), /* Section for mandatory dependencies */
3030
FDEP_CODEC_OER = (1 << 5), /* Use contents only if -gen-OER */
3131
FDEP_CODEC_PER = (1 << 6), /* Use contents only if -gen-PER */
32+
FDEP_CODEC_BNER = (1 << 7), /* Use contents only if -gen-BNER */
3233
} section; /* Some file refers to it */
3334

3435
/* Whether this chain is alive and has to be present in the output */

libasn1compiler/asn1c_save.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ asn1c__save_library_makefile(arg_t *arg, const asn1c_dep_chainset *deps,
145145
safe_fprintf(
146146
mkf,
147147
"\n"
148-
"ASN_MODULE_CFLAGS=%s%s",
148+
"ASN_MODULE_CFLAGS=%s%s%s",
149+
(arg->flags & A1C_GEN_BNER) ? "" : "-DASN_DISABLE_BNER_SUPPORT ",
149150
(arg->flags & A1C_GEN_OER) ? "" : "-DASN_DISABLE_OER_SUPPORT ",
150151
(arg->flags & A1C_GEN_PER) ? "" : "-DASN_DISABLE_PER_SUPPORT ");
151152

libasn1compiler/asn1compiler.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ enum asn1c_flags {
9797
* -debug-output-origin-lines
9898
*/
9999
A1C_DEBUG_OUTPUT_ORIGIN_LINES = 0x400000,
100+
/*
101+
* -gen-BNER
102+
* Generate BACnet Encoding Rules support code
103+
*/
104+
A1C_GEN_BNER = 0x800000,
100105
};
101106

102107
/*

skeletons/file-dependencies

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ per_support.h per_support.c # PER parsing
6565
per_decoder.h per_decoder.c # PER decoding support
6666
per_encoder.h per_encoder.c # PER encoding support
6767
per_opentype.h per_opentype.c # PER "open type" handling
68+
bner_support.h bner_support.c # BNER tag support
69+
bner_decoder.h bner_decoder.c # BNER decoding support
70+
bner_encoder.h bner_encoder.c # BNER encoding support
6871

6972
CONVERTER: # THIS IS A SPECIAL SECTION
7073
converter-example.c # A default name for the example transcoder
@@ -87,3 +90,16 @@ constr_SEQUENCE.h constr_SEQUENCE_oer.c
8790
constr_SET_OF.h constr_SET_OF_oer.c
8891

8992
CODEC-PER: # THIS IS A SPECIAL SECTION
93+
94+
CODEC-BNER: # THIS IS A SPECIAL SECTION
95+
constr_CHOICE.h constr_CHOICE_bner.c
96+
constr_SEQUENCE.h constr_SEQUENCE_bner.c
97+
constr_SEQUENCE_OF.h constr_SEQUENCE_OF_bner.c constr_SET_OF.h asn_SEQUENCE_OF.h asn_SET_OF.h
98+
ANY_bner.c ANY.h
99+
BOOLEAN_bner.c BOOLEAN.h
100+
INTEGER_bner.c INTEGER.h
101+
NativeInteger_bner.c NativeInteger.h
102+
NativeReal_bner.c NativeReal.h REAL.h
103+
NULL_bner.c NULL.h
104+
OCTET_STRING_bner.c OCTET_STRING.h
105+
REAL_bner.c REAL.h

0 commit comments

Comments
 (0)