Dr Stephen Henson wrote:
> > #define DECLARE_STACK_OF(type) \
> > #define IMPLEMENT_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.
Yes, but then if somewhere inside my code, I expand the STACK_OF call, we
could as well remove the STACK_OF macro, because modifying it in the futur
will break the code.
You probably mean expand inside asn1_mac.h
As this problem does not appear only with STACK_OF, what you suggest here is
in fact that the deepness of concatenations should always be one in
asn1_mac.h.
This means you can't use any macro that does concatenation inside asn1_mac.h
anymore, you have to expand instead.
I don't believe this is good.
But still we need coherent behaviour for the macro of asn1_mac.h when the
argument has been #defined.
So I think instead the deepness of all the concatenations inside asn1_mac.h
should be increased so that it's always at least 2.
Here are some other macro they are problems with.
Calls to
M_ASN1_I2D_len_SEQUENCE_opt_type(ASN1_UTF8STRING,a->statusString,
i2d_ASN1_UTF8STRING);
M_ASN1_I2D_put_SEQUENCE_opt_type(ASN1_UTF8STRING,a->statusString,
i2d_ASN1_UTF8STRING);
M_ASN1_D2I_get_seq_opt_type(ASN1_UTF8STRING, ret->statusString,
d2i_ASN1_UTF8STRING, ASN1_UTF8STRING_free);
will with 0.9.4 expand to calls to functions names with either
ASN1_UTF8STRING, or ASN1_STRING in a rather random way.
If we do the modifications above to asn1_mac.h, we will only declare and
implement the ASN1_STRING.
IMPLEMENT_STACK_OF(ASN1_STRING)
DECLARE_STACK_OF(ASN1_STRING)
and all macro calls inside the user code will expand to ASN1_STRING when they
are called with ASN1_UTF8STRING as an argument.
If later ASN1_UTF8STRING becomes defined as an actual independent type, we
only need to add IMPLEMENT_STACK_OF(ASN1_UTF8STRING) and
DECLARE_STACK_OF(ASN1_UTF8STRING) and do not need to change anything in the
rest of the code.
If IMPLEMENT_STACK_OF(ASN1_STRING), DECLARE_STACK_OF(ASN1_STRING) is added
inside the standard OpenSSL header, later changing ASN1_UTF8STRING,
ASN1_IA5STRING, etc... to an actual type will only mean to add new
IMPLEMENT_STACK_OF(), DECLARE_STACK_OF() inside the OpenSSL code and change
nothing to user code.
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]