|
13 | 13 | #include <asn1fix_crange.h> /* constraint groker from libasn1fix */
|
14 | 14 | #include <asn1fix_export.h> /* other exportables from libasn1fix */
|
15 | 15 | #include <asn1parser.h>
|
| 16 | +#include <regex.h> |
16 | 17 |
|
17 | 18 | typedef struct tag2el_s {
|
18 | 19 | struct asn1p_type_tag_s el_tag;
|
@@ -75,6 +76,24 @@ enum etd_spec {
|
75 | 76 | };
|
76 | 77 | static int emit_type_DEF(arg_t *arg, asn1p_expr_t *expr, enum tvm_compat tv_mode, int tags_count, int all_tags_count, int elements_count, enum etd_spec);
|
77 | 78 |
|
| 79 | +static int is_bner_pdu_regex_init = 0; |
| 80 | +static regex_t bner_pdu_regex; |
| 81 | + |
| 82 | +static int init_bner(void) { |
| 83 | + int ret = 0; |
| 84 | + |
| 85 | + if(!is_bner_pdu_regex_init) { |
| 86 | + ret = regcomp(&bner_pdu_regex, "BACnet.*PDU", 0); |
| 87 | + if(ret == 0) is_bner_pdu_regex_init = 1; |
| 88 | + } |
| 89 | + |
| 90 | + return ret; |
| 91 | +} |
| 92 | +static int is_bner_fixed_pdu(const char *pdu_type_name) { |
| 93 | + init_bner(); |
| 94 | + return (regexec(&bner_pdu_regex, pdu_type_name, 0, NULL, 0) == 0); |
| 95 | +} |
| 96 | + |
78 | 97 | #define C99_MODE (!(arg->flags & A1C_NO_C99))
|
79 | 98 | #define UNNAMED_UNIONS (arg->flags & A1C_UNNAMED_UNIONS)
|
80 | 99 | #define HIDE_INNER_DEFS (arg->embed && !(arg->flags & A1C_ALL_DEFS_GLOBAL))
|
@@ -2980,7 +2999,12 @@ emit_type_DEF(arg_t *arg, asn1p_expr_t *expr, enum tvm_compat tv_mode, int tags_
|
2980 | 2999 | if (!p2)
|
2981 | 3000 | p2 = strdup(p);
|
2982 | 3001 |
|
2983 |
| - OUT("&asn_OP_%s,\n", p2); |
| 3002 | + if(arg->flags & A1C_GEN_BNER |
| 3003 | + && is_bner_fixed_pdu(expr->Identifier)) { |
| 3004 | + OUT("&asn_OP_%s,\n", expr_id); |
| 3005 | + } else { |
| 3006 | + OUT("&asn_OP_%s,\n", p2); |
| 3007 | + } |
2984 | 3008 |
|
2985 | 3009 | if(tags_count) {
|
2986 | 3010 | OUT("asn_DEF_%s_tags_%d,\n",
|
|
0 commit comments