if ((*p != ':') || (*p != ',') || (*p != '.')) break; if (*p) type=(char *)p;
if ((*p == ':') || (*p == ',') || (*p == '.')) { p++; if(*p) type = p; break; }
static int make_REQ(req,pkey,attribs)X509_REQ *req;EVP_PKEY *pkey;int attribs;	{	int ret=0,i;	unsigned char *p,*q;	X509_REQ_INFO *ri;	char buf[100];	int nid,min,max;	char *type,*def,*tmp,*value,*tmp_attr;	STACK *sk,*attr=NULL;	CONF_VALUE *v;		tmp=CONF_get_string(req_conf,SECTION,DISTINGUISHED_NAME);	if (tmp == NULL)		{		BIO_printf(bio_err,"unable to find '%s' in config\n",			DISTINGUISHED_NAME);		goto err;		}	sk=CONF_get_section(req_conf,tmp);	if (sk == NULL)		{		BIO_printf(bio_err,"unable to get '%s' section\n",tmp);		goto err;		}	tmp_attr=CONF_get_string(req_conf,SECTION,ATTRIBUTES);	if (tmp_attr == NULL)		attr=NULL;	else		{		attr=CONF_get_section(req_conf,tmp_attr);		if (attr == NULL)			{			BIO_printf(bio_err,"unable to get '%s' section\n",tmp_attr);			goto err;			}		}	ri=req->req_info;	BIO_printf(bio_err,"You are about to be asked to enter information that will be incorporated\n");	BIO_printf(bio_err,"into your certificate request.\n");	BIO_printf(bio_err,"What you are about to enter is what is called a Distinguished Name or a DN.\n");	BIO_printf(bio_err,"There are quite a few fields but you can leave some blank\n");	BIO_printf(bio_err,"For some fields there will be a default value,\n");	BIO_printf(bio_err,"If you enter '.', the field will be left blank.\n");	BIO_printf(bio_err,"-----\n");	/* setup version number */	if (!ASN1_INTEGER_set(ri->version,0L)) goto err; /* version 1 */	if (sk_num(sk))		{		i= -1;start:		for (;;)			{			i++;			if ((int)sk_num(sk) <= i) break;			v=(CONF_VALUE *)sk_value(sk,i);			p=q=NULL;			type=v->name;			if(!check_end(type,"_min") || !check_end(type,"_max") ||				!check_end(type,"_default") ||					 !check_end(type,"_value")) continue;			/* Skip past any leading X. X: X, etc to allow for			 * multiple instances 			 */			for(p = v->name; *p ; p++) 				if ((*p != ':') || (*p != ',') ||							 (*p != '.')) break;			if (*p) type=(char *)p;			/* If OBJ not recognised ignore it */			if ((nid=OBJ_txt2nid(type)) == NID_undef) goto start;			sprintf(buf,"%s_default",v->name);			if ((def=CONF_get_string(req_conf,tmp,buf)) == NULL)				def="";							sprintf(buf,"%s_value",v->name);			if ((value=CONF_get_string(req_conf,tmp,buf)) == NULL)				value=NULL;			sprintf(buf,"%s_min",v->name);			min=(int)CONF_get_number(req_conf,tmp,buf);			sprintf(buf,"%s_max",v->name);			max=(int)CONF_get_number(req_conf,tmp,buf);			if (!add_DN_object(ri->subject,v->value,def,value,nid,				min,max))				goto err;			}		if (sk_num(ri->subject->entries) == 0)			{			BIO_printf(bio_err,"error, no objects specified in config file\n");			goto err;			}		if (attribs)			{			if ((attr != NULL) && (sk_num(attr) > 0))				{				BIO_printf(bio_err,"\nPlease enter the following 'extra' attributes\n");				BIO_printf(bio_err,"to be sent with your certificate request\n");				}			i= -1;start2:			for (;;)				{				i++;				if ((attr == NULL) || ((int)sk_num(attr) <= i))					break;				v=(CONF_VALUE *)sk_value(attr,i);				type=v->name;				if ((nid=OBJ_txt2nid(type)) == NID_undef)					goto start2;				sprintf(buf,"%s_default",type);				if ((def=CONF_get_string(req_conf,tmp_attr,buf))					== NULL)					def="";								sprintf(buf,"%s_value",type);				if ((value=CONF_get_string(req_conf,tmp_attr,buf))					== NULL)					value=NULL;				sprintf(buf,"%s_min",type);				min=(int)CONF_get_number(req_conf,tmp_attr,buf);				sprintf(buf,"%s_max",type);				max=(int)CONF_get_number(req_conf,tmp_attr,buf);				if (!add_attribute_object(ri->attributes,					v->value,def,value,nid,min,max))					goto err;				}			}		}	else		{		BIO_printf(bio_err,"No template, please set one up.\n");		goto err;		}	X509_REQ_set_pubkey(req,pkey);	ret=1;err:	return(ret);	}