Jean-Marc Desperrier wrote:
>
>
> In non-debug version, we have :
> #define ASN1_UTF8STRING ASN1_STRING
>
> and
>
> #define DECLARE_STACK_OF(type) \
> typedef struct stack_st_##type \
> { \
> STACK stack; \
> } STACK_OF(type); \
> STACK_OF(type) *sk_##type##_new(int (*cmp)(type **,type **)); \
> STACK_OF(type) *sk_##type##_new_null(void); \
> void sk_##type##_free(STACK_OF(type) *sk); \
>
> and
> #define IMPLEMENT_STACK_OF(type) \
> STACK_OF(type) *sk_##type##_new(int (*cmp)(type **,type **)) \
> { return (STACK_OF(type) *)sk_new(cmp); } \
> STACK_OF(type) *sk_##type##_new_null() \
> { return (STACK_OF(type) *)sk_new_null(); } \
> void sk_##type##_free(STACK_OF(type) *sk) \
> { sk_free((STACK *)sk); } \
>
> and
>
> #define STACK_OF(type) STACK_##type
>
> In DECLARE_STACK_OF, the precompiler makes concatenation first.
> Then replaces ASN1_UTF8STRING with ASN1_STRING everywhere.
> Then the sub-macros are handled.
> This gives :
> typedef struct stack_st_ASN1_UTF8STRING { STACK stack; }
> STACK_ASN1_STRING ;
> STACK_ASN1_STRING *sk_ASN1_UTF8STRING_new(int (*cmp)( ASN1_STRING
> **, ASN1_STRING **));
> STACK_ASN1_STRING *sk_ASN1_UTF8STRING_new_null(void);
> void sk_ASN1_UTF8STRING_free(STACK_ASN1_STRING *sk);
>
> which sound like what we want.
> The names have ASN1_UTF8STRING in them, but the type is actually
> ASN1_STRING.
>
> But now when I declare :
> STACK_OF(ASN1_UTF8STRING) in my code, the deepness of the call is one so
> I get STACK_ASN1_UTF8STRING instead of the STACK_ASN1_STRING I had in
> DECLARE_STACK_OF.
>
> Is this solved in 0.9.5 ?
>
> I think the deepness of DECLARE_STACK_OF should be increased by one so
> that the behaviour becomes constant:
>
> <#define STACK_OF(type) STACK_##type
> >#define INTERNAL_STACK_OF(type) STACK_##type
> >#define STACK_OF(type) INTERNAL_STACK_OF(type)
>
There's a problem with this solution. If you need another ASN1_STRING
equivalent STACK_OF such as ASN1_IA5STRING you get a conflict because
the structure STACK_ASN1_STRING gets declared twice.
If the STACK_OF macro is removed from the definitions and written in
full as STACK_##type then it should expand to STACK_ASN1_UTF8STRING
which avoids this.
Steve.
--
Dr Stephen N. Henson. http://www.drh-consultancy.demon.co.uk/
Personal Email: [EMAIL PROTECTED]
Senior crypto engineer, Celo Communications: http://www.celocom.com/
Core developer of the OpenSSL project: http://www.openssl.org/
Business Email: [EMAIL PROTECTED] PGP key: via homepage.
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]