c++ - ASN1C编译

标签 c++ c encoding asn.1

我有一个小的 asn1 代码:

--------------------ASN1 文件------------------------ ------

RectangleModule1 DEFINITIONS ::= 
BEGIN
Rectangle ::= SEQUENCE (SIZE(1..10)) OF SEQUENCE {

 item CHOICE    {

  height INTEGER,

  width  IA5String

 } --# UNTAGGED
}

END

当我用 asn1c 编译它时,它会给我 Rectangle.c 和 Rectangle.h 文件。 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_CHOICEconstr_SEQUENCE 是如何工作的。任何帮助将不胜感激。

最佳答案

经过几个小时的时间,我发现不能通过修改asn文件来完成。只能通过编辑编译asn文件生成的.h.c文件来完成。

关于c++ - ASN1C编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19388524/

相关文章:

c++ - 在Matlab中将固定长度的字节数组写入二进制文件

c - 在 C 中初始化结构体 GHashTable

ios - 具有特殊字符的 NSURL 编码

Python Nltk :UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 50: invalid continuation byte

c++ - 使用 boost::algorithm::split 拆分字符串

c++ - 如何将 qlabel 文本更改为看起来像窗口标题文本

c++ - C 中的结构声明

c++ - while true 循环函数

将具有动态数组的结构转换为双指针

java - 如何从以 latin1 编码的结果集中以 UTF-8 编码字符串