2013-10-15 37 views
0

我有一个小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_CHOICEconstr_SEQUENCE是如何工作的。任何帮助,将不胜感激。

+0

你用什么asn1c? –

+1

为什么生成的代码具有特定名称很重要? –

+0

@Errandir:ASN.1 Compiler,v0.9.24。 Copyright(c)2003,2004,2005,2006 Lev Walkin <[email protected]> –

回答

2

花了几个小时的时间后,我想通过修改asn文件无法完成。它只能通过编辑通过编译asn文件生成的文件.h.c来完成。