⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 authoritykeyidentifier.c

📁 OpenLdap是LDAP的开源项目
💻 C
📖 第 1 页 / 共 5 页
字号:
         return -1;    }    elmtLen1 = BDecLen (b, &totalElmtsLen1 );        (k->choiceId) = GENERALNAME_IPADDRESS;		rc = 	BDecComponentOcts (mem_op, b, tagId1, elmtLen1, (&k->a.iPAddress), &totalElmtsLen1, DEC_ALLOC_MODE_0 );		if ( rc != LDAP_SUCCESS ) return rc;		(k->a.iPAddress)->identifier.bv_val = (k->a.iPAddress)->id_buf;		(k->a.iPAddress)->identifier.bv_len = strlen("iPAddress");		strcpy( (k->a.iPAddress)->identifier.bv_val, "iPAddress");	if (elmtLen0 == INDEFINITE_LEN)        BDecEoc (b, &totalElmtsLen1 );    break;       case MAKE_TAG_ID (CNTX, CONS, 8):if (BDecTag (b, &totalElmtsLen1 ) != MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))    {         Asn1Error ("Unexpected Tag\n");         return -1;    }    elmtLen1 = BDecLen (b, &totalElmtsLen1 );        (k->choiceId) = GENERALNAME_REGISTEREDID;		rc = 	BDecComponentOid (mem_op, b, tagId1, elmtLen1, (&k->a.registeredID), &totalElmtsLen1, DEC_ALLOC_MODE_0 );		if ( rc != LDAP_SUCCESS ) return rc;		(k->a.registeredID)->identifier.bv_val = (k->a.registeredID)->id_buf;		(k->a.registeredID)->identifier.bv_len = strlen("registeredID");		strcpy( (k->a.registeredID)->identifier.bv_val, "registeredID");	if (elmtLen0 == INDEFINITE_LEN)        BDecEoc (b, &totalElmtsLen1 );    break;    default:        Asn1Error ("ERROR - unexpected tag in CHOICE\n");        return -1;        break;    } /* end switch */	if( !(old_mode & DEC_ALLOC_MODE_1) ) {	*v = t = (ComponentGeneralName*) CompAlloc( mem_op, sizeof(ComponentGeneralName) );	if ( !t ) return -1;	*t = *k;	}	t->syntax = (Syntax*)NULL;	t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );	if ( !t->comp_desc ) {		free ( t );		return -1;	}	t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentGeneralName ;	t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentGeneralName ;	t->comp_desc->cd_free = (comp_free_func*)NULL;	t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentGeneralName;	t->comp_desc->cd_type = ASN_COMPOSITE;	t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;	t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentGeneralName;    (*bytesDecoded) += totalElmtsLen1;	return LDAP_SUCCESS;}  /* BDecGeneralNameContent */intGDecComponentGeneralName PARAMS (( mem_op,b, v, bytesDecoded, mode),void* mem_op _AND_GenBuf * b _AND_ComponentGeneralName **v _AND_AsnLen *bytesDecoded _AND_int mode){	char* peek_head,*peek_head2;	int i, strLen,strLen2, rc, old_mode = mode;	ComponentGeneralName *k,*t, c_temp;	if ( !(mode & DEC_ALLOC_MODE_1) ) {		memset(&c_temp,0,sizeof(c_temp));		 k = &c_temp;	} else		 k = t = *v;	mode = DEC_ALLOC_MODE_2;	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){		Asn1Error("Error during Reading identifier");		return LDAP_PROTOCOL_ERROR;	}	if( !(strLen2 = LocateNextGSERToken(mem_op,b,&peek_head2,GSER_NO_COPY)) ){		Asn1Error("Error during Reading identifier");		return LDAP_PROTOCOL_ERROR;	}	if(*peek_head2 != ':'){		Asn1Error("Missing : in encoded data");		return LDAP_PROTOCOL_ERROR;	}	if( strncmp("otherName",peek_head, strlen("otherName")) == 0){		(k->choiceId) = GENERALNAME_OTHERNAME;		rc = 	GDecComponentOtherName (mem_op, b, (&k->a.otherName), bytesDecoded, mode);		if ( rc != LDAP_SUCCESS ) return rc;		(k->a.otherName)->identifier.bv_val = peek_head;		(k->a.otherName)->identifier.bv_len = strLen;	}	else if( strncmp("rfc822Name",peek_head,strlen("rfc822Name")) == 0){		(k->choiceId) = GENERALNAME_RFC822NAME;		rc = 	GDecComponentIA5String (mem_op, b, (&k->a.rfc822Name), bytesDecoded, DEC_ALLOC_MODE_0 );		if ( rc != LDAP_SUCCESS ) return rc;		(k->a.rfc822Name)->identifier.bv_val = peek_head;		(k->a.rfc822Name)->identifier.bv_len = strLen;	}	else if( strncmp("dNSName",peek_head,strlen("dNSName")) == 0){		(k->choiceId) = GENERALNAME_DNSNAME;		rc = 	GDecComponentIA5String (mem_op, b, (&k->a.dNSName), bytesDecoded, DEC_ALLOC_MODE_0 );		if ( rc != LDAP_SUCCESS ) return rc;		(k->a.dNSName)->identifier.bv_val = peek_head;		(k->a.dNSName)->identifier.bv_len = strLen;	}	else if( strncmp("x400Address",peek_head,strlen("x400Address")) == 0){		(k->choiceId) = GENERALNAME_X400ADDRESS;		rc = 	GDecComponentORAddress (mem_op, b, (&k->a.x400Address), bytesDecoded, mode);		if ( rc != LDAP_SUCCESS ) return rc;		(k->a.x400Address)->identifier.bv_val = peek_head;		(k->a.x400Address)->identifier.bv_len = strLen;	}	else if( strncmp("directoryName",peek_head,strlen("directoryName")) == 0){		(k->choiceId) = GENERALNAME_DIRECTORYNAME;		rc = 	GDecComponentName (mem_op, b, (&k->a.directoryName), bytesDecoded, mode);		if ( rc != LDAP_SUCCESS ) return rc;		(k->a.directoryName)->identifier.bv_val = peek_head;		(k->a.directoryName)->identifier.bv_len = strLen;	}	else if( strncmp("ediPartyName",peek_head,strlen("ediPartyName")) == 0){		(k->choiceId) = GENERALNAME_EDIPARTYNAME;		rc = 	GDecComponentEDIPartyName (mem_op, b, (&k->a.ediPartyName), bytesDecoded, mode);		if ( rc != LDAP_SUCCESS ) return rc;		(k->a.ediPartyName)->identifier.bv_val = peek_head;		(k->a.ediPartyName)->identifier.bv_len = strLen;	}	else if( strncmp("uniformResourceIdentifier",peek_head,strlen("uniformResourceIdentifier")) == 0){		(k->choiceId) = GENERALNAME_UNIFORMRESOURCEIDENTIFIER;		rc = 	GDecComponentIA5String (mem_op, b, (&k->a.uniformResourceIdentifier), bytesDecoded, DEC_ALLOC_MODE_0 );		if ( rc != LDAP_SUCCESS ) return rc;		(k->a.uniformResourceIdentifier)->identifier.bv_val = peek_head;		(k->a.uniformResourceIdentifier)->identifier.bv_len = strLen;	}	else if( strncmp("iPAddress",peek_head,strlen("iPAddress")) == 0){		(k->choiceId) = GENERALNAME_IPADDRESS;		rc = 	GDecComponentOcts (mem_op, b, (&k->a.iPAddress), bytesDecoded, DEC_ALLOC_MODE_0 );		if ( rc != LDAP_SUCCESS ) return rc;		(k->a.iPAddress)->identifier.bv_val = peek_head;		(k->a.iPAddress)->identifier.bv_len = strLen;	}	else if( strncmp("registeredID",peek_head,strlen("registeredID")) == 0){		(k->choiceId) = GENERALNAME_REGISTEREDID;		rc = 	GDecComponentOid (mem_op, b, (&k->a.registeredID), bytesDecoded, DEC_ALLOC_MODE_0 );		if ( rc != LDAP_SUCCESS ) return rc;		(k->a.registeredID)->identifier.bv_val = peek_head;		(k->a.registeredID)->identifier.bv_len = strLen;	}	else {		Asn1Error("Undefined Identifier");		return LDAP_PROTOCOL_ERROR;	}	if( !(old_mode & DEC_ALLOC_MODE_1) ) {	*v = t = (ComponentGeneralName*) CompAlloc( mem_op, sizeof(ComponentGeneralName) );	if ( !t ) return -1;	*t = *k;	}	t->syntax = (Syntax*)NULL;	t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );	if ( !t->comp_desc ) {		free ( t );		return -1;	}	t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentGeneralName ;	t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentGeneralName ;	t->comp_desc->cd_free = (comp_free_func*)NULL;	t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentGeneralName;	t->comp_desc->cd_type = ASN_COMPOSITE;	t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;	t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentGeneralName;	return LDAP_SUCCESS;}  /* GDecGeneralNameContent */intMatchingComponentGeneralNames ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {	int rc;	MatchingRule* mr;	void* component1, *component2;	AsnList *v1, *v2, t_list;	if ( oid ) {		mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);		if ( mr ) return component_value_match( mr, csi_attr, csi_assert );	}	v1 = &((ComponentGeneralNames*)csi_attr)->comp_list;	v2 = &((ComponentGeneralNames*)csi_assert)->comp_list;	FOR_EACH_LIST_PAIR_ELMT(component1, component2, v1, v2)	{		if( MatchingComponentGeneralName(oid, (ComponentSyntaxInfo*)component1, (ComponentSyntaxInfo*)component2) == LDAP_COMPARE_FALSE) {			return LDAP_COMPARE_FALSE;		}	} /* end of for */	AsnListFirst( v1 );	AsnListFirst( v2 );	if( (!component1 && component2) || (component1 && !component2))		return LDAP_COMPARE_FALSE;	else		return LDAP_COMPARE_TRUE;}  /* BMatchingComponentGeneralNamesContent */void*ExtractingComponentGeneralNames ( void* mem_op, ComponentReference* cr, ComponentGeneralNames *comp ){	int count = 0;	int total;	AsnList *v = &comp->comp_list;	ComponentInt *k;	ComponentGeneralName *component;	switch ( cr->cr_curr->ci_type ) {	case LDAP_COMPREF_FROM_BEGINNING :		count = cr->cr_curr->ci_val.ci_from_beginning;		FOR_EACH_LIST_ELMT( component , v ) {			if( --count == 0 ) {				if( cr->cr_curr->ci_next == NULL )					return component;				else {					cr->cr_curr = cr->cr_curr->ci_next;					return 	ExtractingComponentGeneralName ( mem_op, cr, component );				}			}		}		break;	case LDAP_COMPREF_FROM_END :		total = AsnListCount ( v );		count = cr->cr_curr->ci_val.ci_from_end;		count = total + count +1;		FOR_EACH_LIST_ELMT ( component, v ) {			if( --count == 0 ) {				if( cr->cr_curr->ci_next == NULL ) 					return component;				else {					cr->cr_curr = cr->cr_curr->ci_next;					return 	ExtractingComponentGeneralName ( mem_op, cr, component );				}			}		}		break;	case LDAP_COMPREF_ALL :		return comp;	case LDAP_COMPREF_COUNT :		k = (ComponentInt*)CompAlloc( mem_op, sizeof(ComponentInt));		k->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );		k->comp_desc->cd_tag = (-1);		k->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentInt;		k->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentInt;		k->comp_desc->cd_extract_i = (extract_component_from_id_func*)NULL;		k->comp_desc->cd_type = ASN_BASIC;		k->comp_desc->cd_type_id = BASICTYPE_INTEGER;		k->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentInt;		k->value = AsnListCount(v);		return k;	default :		return NULL;	}}  /* ExtractingComponentGeneralNames */intBDecComponentGeneralNames PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),void* mem_op _AND_GenBuf * b _AND_AsnTag tagId0 _AND_AsnLen elmtLen0 _AND_ComponentGeneralNames **v _AND_AsnLen *bytesDecoded _AND_int mode){	int seqDone = FALSE;	AsnLen totalElmtsLen1 = 0;	AsnLen elmtLen1;	AsnTag tagId1;	int mandatoryElmtCount1 = 0;	int old_mode = mode;	int rc;	ComponentGeneralNames *k, *t, c_temp;	if ( !(mode & DEC_ALLOC_MODE_1) ) {		memset(&c_temp,0,sizeof(c_temp));		 k = &c_temp;	} else		 k = t = *v;	mode = DEC_ALLOC_MODE_2;	AsnListInit(&k->comp_list,sizeof(ComponentGeneralName));    for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);)    {        ComponentGeneralName **tmpVar;    tagId1 = BDecTag (b, &totalElmtsLen1 );    if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))    {        BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )        break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/    }        elmtLen1 = BDecLen (b, &totalElmtsLen1);    tmpVar = (ComponentGeneralName**) CompAsnListAppend (mem_op,&k->comp_list);		rc = 	BDecComponentGeneralName (mem_op, b, tagId1, elmtLen1, tmpVar, &totalElmtsLen1, mode);		if ( rc != LDAP_SUCCESS ) return rc;    } /* end of for */	if( !(old_mode & DEC_ALLOC_MODE_1) ) {	*v = t = (ComponentGeneralNames*) CompAlloc( mem_op, sizeof(ComponentGeneralNames) );	if ( !t ) return -1;	*t = *k;	}	t->syntax = (Syntax*)NULL;	t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );	if ( !t->comp_desc ) {		free ( t );		return -1;	}	t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentGeneralNames ;	t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentGeneralNames ;	t->comp_desc->cd_free = (comp_free_func*)NULL;	t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentGeneralNames;	t->comp_desc->cd_type = ASN_COMPOSITE;	t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;	t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentGeneralNames;    (*bytesDecoded) += totalElmtsLen1;	return LDAP_SUCCESS;}  /* BDecGeneralNamesContent */intGDecComponentGeneralNames PARAMS (( mem_op,b, v, bytesDecoded, mode),void* mem_op _AND_GenBuf * b _AND_ComponentGeneralNames **v _AND_AsnLen *bytesDecoded _AND_int mode){	char* peek_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -