min,max))
goto err;
}
- if (sk_num(ri->subject->entries) == 0)
+ if (sk_X509_NAME_ENTRY_num(ri->subject->entries) == 0)
{
BIO_printf(bio_err,"error, no objects specified in config file\n");
goto err;
M_ASN1_D2I_get_imp_set(r,func,free_func, \
V_ASN1_SET,V_ASN1_UNIVERSAL);
+#define M_ASN1_D2I_get_set_type(type,r,func,free_func) \
+ M_ASN1_D2I_get_imp_set_type(type,r,func,free_func, \
+ V_ASN1_SET,V_ASN1_UNIVERSAL);
+
#define M_ASN1_D2I_get_set_opt(r,func,free_func) \
if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \
V_ASN1_CONSTRUCTED|V_ASN1_SET)))\
static int i2d_X509_NAME_entries(X509_NAME *a)
{
X509_NAME_ENTRY *ne,*fe=NULL;
- STACK *sk;
+ STACK_OF(X509_NAME_ENTRY) *sk;
BUF_MEM *buf=NULL;
int set=0,r,ret=0;
int i;
int size=0;
sk=a->entries;
- for (i=0; i<sk_num(sk); i++)
+ for (i=0; i<sk_X509_NAME_ENTRY_num(sk); i++)
{
- ne=(X509_NAME_ENTRY *)sk_value(sk,i);
+ ne=sk_X509_NAME_ENTRY_value(sk,i);
if (fe == NULL)
{
fe=ne;
ASN1_put_object(&p,1,ret,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
set= -1;
- for (i=0; i<sk_num(sk); i++)
+ for (i=0; i<sk_X509_NAME_ENTRY_num(sk); i++)
{
- ne=(X509_NAME_ENTRY *)sk_value(sk,i);
+ ne=sk_X509_NAME_ENTRY_value(sk,i);
if (set != ne->set)
{
set=ne->set;
M_ASN1_D2I_vars(a,X509_NAME *,X509_NAME_new);
orig= *pp;
- if (sk_num(ret->entries) > 0)
+ if (sk_X509_NAME_ENTRY_num(ret->entries) > 0)
{
- while (sk_num(ret->entries) > 0)
- X509_NAME_ENTRY_free((X509_NAME_ENTRY *)
- sk_pop(ret->entries));
+ while (sk_X509_NAME_ENTRY_num(ret->entries) > 0)
+ X509_NAME_ENTRY_free(
+ sk_X509_NAME_ENTRY_pop(ret->entries));
}
M_ASN1_D2I_Init();
for (;;)
{
if (M_ASN1_D2I_end_sequence()) break;
- M_ASN1_D2I_get_set(ret->entries,d2i_X509_NAME_ENTRY,
- X509_NAME_ENTRY_free);
- for (; idx < sk_num(ret->entries); idx++)
+ M_ASN1_D2I_get_set_type(X509_NAME_ENTRY,ret->entries,
+ d2i_X509_NAME_ENTRY,
+ X509_NAME_ENTRY_free);
+ for (; idx < sk_X509_NAME_ENTRY_num(ret->entries); idx++)
{
- ((X509_NAME_ENTRY *)sk_value(ret->entries,idx))->set=
- set;
+ sk_X509_NAME_ENTRY_value(ret->entries,idx)->set=set;
}
set++;
}
ASN1_CTX c;
M_ASN1_New_Malloc(ret,X509_NAME);
- if ((ret->entries=sk_new(NULL)) == NULL)
+ if ((ret->entries=sk_X509_NAME_ENTRY_new(NULL)) == NULL)
{ c.line=__LINE__; goto err2; }
M_ASN1_New(ret->bytes,BUF_MEM_new);
ret->modified=1;
return;
BUF_MEM_free(a->bytes);
- sk_pop_free(a->entries,X509_NAME_ENTRY_free);
- Free((char *)a);
+ sk_X509_NAME_ENTRY_pop_free(a->entries,X509_NAME_ENTRY_free);
+ Free(a);
}
void X509_NAME_ENTRY_free(X509_NAME_ENTRY *a)
if (a == NULL) return;
ASN1_OBJECT_free(a->object);
ASN1_BIT_STRING_free(a->value);
- Free((char *)a);
+ Free(a);
}
int X509_NAME_set(X509_NAME **xn, X509_NAME *name)
return(*xn != NULL);
}
+IMPLEMENT_STACK_OF(X509_NAME_ENTRY)
+IMPLEMENT_ASN1_SET_OF(X509_NAME_ENTRY)
void sk_##type##_zero(STACK_OF(type) *sk); \
int sk_##type##_push(STACK_OF(type) *sk,type *v); \
int sk_##type##_find(STACK_OF(type) *sk,type *v); \
-void sk_##type##_delete(STACK_OF(type) *sk,int n); \
+type *sk_##type##_delete(STACK_OF(type) *sk,int n); \
void sk_##type##_delete_ptr(STACK_OF(type) *sk,type *v); \
+int sk_##type##_insert(STACK_OF(type) *sk,type *v,int n); \
void sk_##type##_set_cmp_func(STACK_OF(type) *sk,int (*cmp)(type **,type **)); \
STACK_OF(type) *sk_##type##_dup(STACK_OF(type) *sk); \
void sk_##type##_pop_free(STACK_OF(type) *sk,void (*func)(type *)); \
{ return sk_push((STACK *)sk,(char *)v); } \
int sk_##type##_find(STACK_OF(type) *sk,type *v) \
{ return sk_find((STACK *)sk,(char *)v); } \
-void sk_##type##_delete(STACK_OF(type) *sk,int n) \
- { sk_delete((STACK *)sk,n); } \
+type *sk_##type##_delete(STACK_OF(type) *sk,int n) \
+ { return (type *)sk_delete((STACK *)sk,n); } \
void sk_##type##_delete_ptr(STACK_OF(type) *sk,type *v) \
{ sk_delete_ptr((STACK *)sk,(char *)v); } \
+int sk_##type##_insert(STACK_OF(type) *sk,type *v,int n) \
+ { return sk_insert((STACK *)sk,(char *)v,n); } \
void sk_##type##_set_cmp_func(STACK_OF(type) *sk,int (*cmp)(type **,type **)) \
{ sk_set_cmp_func((STACK *)sk,cmp); } \
STACK_OF(type) *sk_##type##_dup(STACK_OF(type) *sk) \
int size; /* temp variable */
} X509_NAME_ENTRY;
+DECLARE_STACK_OF(X509_NAME_ENTRY)
+DECLARE_ASN1_SET_OF(X509_NAME_ENTRY)
+
/* we always keep X509_NAMEs in 2 forms. */
typedef struct X509_name_st
{
- STACK *entries; /* of X509_NAME_ENTRY */
+ STACK_OF(X509_NAME_ENTRY) *entries;
int modified; /* true if 'bytes' needs to be built */
#ifdef HEADER_BUFFER_H
BUF_MEM *bytes;
int i,j;
X509_NAME_ENTRY *na,*nb;
- if (sk_num(a->entries) != sk_num(b->entries))
- return(sk_num(a->entries)-sk_num(b->entries));
- for (i=sk_num(a->entries)-1; i>=0; i--)
+ if (sk_X509_NAME_ENTRY_num(a->entries)
+ != sk_X509_NAME_ENTRY_num(b->entries))
+ return sk_X509_NAME_ENTRY_num(a->entries)
+ -sk_X509_NAME_ENTRY_num(b->entries);
+ for (i=sk_X509_NAME_ENTRY_num(a->entries)-1; i>=0; i--)
{
- na=(X509_NAME_ENTRY *)sk_value(a->entries,i);
- nb=(X509_NAME_ENTRY *)sk_value(b->entries,i);
+ na=sk_X509_NAME_ENTRY_value(a->entries,i);
+ nb=sk_X509_NAME_ENTRY_value(b->entries,i);
j=na->value->length-nb->value->length;
if (j) return(j);
j=memcmp(na->value->data,nb->value->data,
/* We will check the object types after checking the values
* since the values will more often be different than the object
* types. */
- for (i=sk_num(a->entries)-1; i>=0; i--)
+ for (i=sk_X509_NAME_ENTRY_num(a->entries)-1; i>=0; i--)
{
- na=(X509_NAME_ENTRY *)sk_value(a->entries,i);
- nb=(X509_NAME_ENTRY *)sk_value(b->entries,i);
+ na=sk_X509_NAME_ENTRY_value(a->entries,i);
+ nb=sk_X509_NAME_ENTRY_value(b->entries,i);
j=OBJ_cmp(na->object,nb->object);
if (j) return(j);
}
len--; /* space for '\0' */
l=0;
- for (i=0; (int)i<sk_num(a->entries); i++)
+ for (i=0; i<sk_X509_NAME_ENTRY_num(a->entries); i++)
{
- ne=(X509_NAME_ENTRY *)sk_value(a->entries,i);
+ ne=sk_X509_NAME_ENTRY_value(a->entries,i);
n=OBJ_obj2nid(ne->object);
if ((n == NID_undef) || ((s=OBJ_nid2sn(n)) == NULL))
{
int X509_NAME_entry_count(X509_NAME *name)
{
if (name == NULL) return(0);
- return(sk_num(name->entries));
+ return(sk_X509_NAME_ENTRY_num(name->entries));
}
int X509_NAME_get_index_by_NID(X509_NAME *name, int nid, int lastpos)
{
int n;
X509_NAME_ENTRY *ne;
- STACK *sk;
+ STACK_OF(X509_NAME_ENTRY) *sk;
if (name == NULL) return(-1);
if (lastpos < 0)
lastpos= -1;
sk=name->entries;
- n=sk_num(sk);
+ n=sk_X509_NAME_ENTRY_num(sk);
for (lastpos++; lastpos < n; lastpos++)
{
- ne=(X509_NAME_ENTRY *)sk_value(sk,lastpos);
+ ne=sk_X509_NAME_ENTRY_value(sk,lastpos);
if (OBJ_cmp(ne->object,obj) == 0)
return(lastpos);
}
X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc)
{
- if ( (name == NULL) || (sk_num(name->entries) <= loc) || (loc < 0))
+ if(name == NULL || sk_X509_NAME_ENTRY_num(name->entries) <= loc
+ || loc < 0)
return(NULL);
else
- return((X509_NAME_ENTRY *)sk_value(name->entries,loc));
+ return(sk_X509_NAME_ENTRY_value(name->entries,loc));
}
X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc)
{
X509_NAME_ENTRY *ret;
int i,n,set_prev,set_next;
- STACK *sk;
+ STACK_OF(X509_NAME_ENTRY) *sk;
- if ((name == NULL) || (sk_num(name->entries) <= loc) || (loc < 0))
+ if (name == NULL || sk_X509_NAME_ENTRY_num(name->entries) <= loc
+ || loc < 0)
return(NULL);
sk=name->entries;
- ret=(X509_NAME_ENTRY *)sk_delete(sk,loc);
- n=sk_num(sk);
+ ret=sk_X509_NAME_ENTRY_delete(sk,loc);
+ n=sk_X509_NAME_ENTRY_num(sk);
name->modified=1;
if (loc == n) return(ret);
/* else we need to fixup the set field */
if (loc != 0)
- set_prev=((X509_NAME_ENTRY *)sk_value(sk,loc-1))->set;
+ set_prev=(sk_X509_NAME_ENTRY_value(sk,loc-1))->set;
else
set_prev=ret->set-1;
- set_next=((X509_NAME_ENTRY *)sk_value(sk,loc))->set;
+ set_next=sk_X509_NAME_ENTRY_value(sk,loc)->set;
/* set_prev is the previous set
* set is the current set
* re-number down by 1 */
if (set_prev+1 < set_next)
for (i=loc; i<n; i++)
- ((X509_NAME_ENTRY *)sk_value(sk,i))->set--;
+ sk_X509_NAME_ENTRY_value(sk,i)->set--;
return(ret);
}
{
X509_NAME_ENTRY *new_name=NULL;
int n,i,inc;
- STACK *sk;
+ STACK_OF(X509_NAME_ENTRY) *sk;
if (name == NULL) return(0);
sk=name->entries;
- n=sk_num(sk);
+ n=sk_X509_NAME_ENTRY_num(sk);
if (loc > n) loc=n;
else if (loc < 0) loc=n;
}
else
{
- set=((X509_NAME_ENTRY *)sk_value(sk,loc-1))->set;
+ set=sk_X509_NAME_ENTRY_value(sk,loc-1)->set;
inc=0;
}
}
if (loc >= n)
{
if (loc != 0)
- set=((X509_NAME_ENTRY *)
- sk_value(sk,loc-1))->set+1;
+ set=sk_X509_NAME_ENTRY_value(sk,loc-1)->set+1;
else
set=0;
}
else
- set=((X509_NAME_ENTRY *)sk_value(sk,loc))->set;
+ set=sk_X509_NAME_ENTRY_value(sk,loc)->set;
inc=(set == 0)?1:0;
}
if ((new_name=X509_NAME_ENTRY_dup(ne)) == NULL)
goto err;
new_name->set=set;
- if (!sk_insert(sk,(char *)new_name,loc))
+ if (!sk_X509_NAME_ENTRY_insert(sk,new_name,loc))
{
X509err(X509_F_X509_NAME_ADD_ENTRY,ERR_R_MALLOC_FAILURE);
goto err;
}
if (inc)
{
- n=sk_num(sk);
+ n=sk_X509_NAME_ENTRY_num(sk);
for (i=loc+1; i<n; i++)
- ((X509_NAME_ENTRY *)sk_value(sk,i-1))->set+=1;
+ sk_X509_NAME_ENTRY_value(sk,i-1)->set+=1;
}
return(1);
err: