У меня есть небольшой код asn1:ASN1C компиляция
--------------------- ASN1 FILE ----------- -------------------
RectangleModule1 DEFINITIONS ::=
BEGIN
Rectangle ::= SEQUENCE (SIZE(1..10)) OF SEQUENCE {
item CHOICE {
height INTEGER,
width IA5String
} --# UNTAGGED
}
END
Когда я скомпилировать его с asn1c, это дает мне файлы Rectangle.c и Rectangle.h. Выход Rectangle выглядит следующим образом:
----------------------- Rectangle.h ------------ ------------------
/* Dependencies */
typedef enum item_PR {
item_PR_NOTHING, /* No components present */
item_PR_height,
item_PR_width
} item_PR;
/* Rectangle */
typedef struct Rectangle {
A_SEQUENCE_OF(struct Member {
struct item {
item_PR present;
union item_u {
long height;
IA5String_t width;
} choice;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} item;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
}) list;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} Rectangle_t;
, но я хотел, чтобы мой вывод выглядеть следующим образом:
/* Dependencies */
typedef enum item_PR_sl {
item_PR_NOTHING_sl, /* No components present */
item_PR_height_sl,
item_PR_width_sl
} item_PR_sl;
/* Rectangle */
typedef struct Rectangle {
A_SEQUENCE_OF(struct Member {
struct item_sl {
item_PR_sl present;
union item_u_sl {
long height;
IA5String_t width;
} choice;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} item;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
}) list;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} Rectangle_t;
т.е. _sl быть объединены в поля позиций. Я не смог сделать это, изменив файл asn. Я не знаю, как работают constr_CHOICE
и constr_SEQUENCE
. Любая помощь будет оценена по достоинству.
Какой asn1c вы используете? –
Почему для сгенерированного кода важно иметь определенные имена? –
@Errandir: ASN.1 Compiler, v0.9.24. Copyright (c) 2003, 2004, 2005, 2006 Lev Walkin <[email protected]> –