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

📄 authoritykeyidentifier.c

📁 ldap服务器源码
💻 C
📖 第 1 页 / 共 5 页
字号:
        return -1;    {		rc = SetAnyTypeByComponentOid ((&k->value), (&k->type_id)); 	rc = BDecComponentAnyDefinedBy (mem_op,b, (&k->value), &totalElmtsLen1, mode );		if ( rc != LDAP_SUCCESS ) return rc;		(&k->value)->identifier.bv_val = (&k->value)->id_buf;		(&k->value)->identifier.bv_len = strlen("value");		strcpy( (&k->value)->identifier.bv_val, "value");    if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0))        seqDone = TRUE;    else    {        tagId1 = BDecTag (b, &totalElmtsLen1 );         if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID))        {            BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )            seqDone = TRUE;        }    }    }    if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) ||(tagId1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))))    {    elmtLen1 = BDecLen (b, &totalElmtsLen1 );		rc = 	BDecComponentOcts (mem_op, b, tagId1, elmtLen1, (&k->extension), &totalElmtsLen1, mode);		if ( rc != LDAP_SUCCESS ) return rc;		(&k->extension)->identifier.bv_val = (&k->extension)->id_buf;		(&k->extension)->identifier.bv_len = strlen("extension");		strcpy( (&k->extension)->identifier.bv_val, "extension");        seqDone = TRUE;        if (elmtLen0 == INDEFINITE_LEN)            BDecEoc (b, &totalElmtsLen1 );        else if (totalElmtsLen1 != elmtLen0)        return -1;    }    if (!seqDone)        return -1;	if( !(old_mode & DEC_ALLOC_MODE_1) ) {	*v = t = (ComponentORAddress*) CompAlloc( mem_op, sizeof(ComponentORAddress) );	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*)GDecComponentORAddress ;	t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentORAddress ;	t->comp_desc->cd_free = (comp_free_func*)NULL;	t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentORAddress;	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*)MatchingComponentORAddress;    (*bytesDecoded) += totalElmtsLen1;	return LDAP_SUCCESS;}  /* BDecORAddress*/intGDecComponentORAddress PARAMS (( mem_op,b, v, bytesDecoded, mode),void* mem_op _AND_GenBuf * b _AND_ComponentORAddress **v _AND_AsnLen *bytesDecoded _AND_int mode){	char* peek_head,*peek_head2;	int i, strLen,strLen2, rc, old_mode = mode;	ComponentORAddress *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;	*bytesDecoded = 0;	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){		Asn1Error("Error during Reading { in encoded data");		return LDAP_PROTOCOL_ERROR;	}	if(*peek_head != '{'){		Asn1Error("Missing { in encoded data");		return LDAP_PROTOCOL_ERROR;	}	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){		Asn1Error("Error during Reading identifier");		return LDAP_PROTOCOL_ERROR;	}	if ( strncmp( peek_head, "type_id", strlen("type_id") ) == 0 ) {		rc = 	GDecComponentOid (mem_op, b, (&k->type_id), bytesDecoded, mode);		if ( rc != LDAP_SUCCESS ) return rc;	(&k->type_id)->identifier.bv_val = peek_head;	(&k->type_id)->identifier.bv_len = strLen;	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){		Asn1Error("Error during Reading , ");		return LDAP_PROTOCOL_ERROR;	}	if(*peek_head != ','){		Asn1Error("Missing , in encoding");		return LDAP_PROTOCOL_ERROR;	}	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){	  Asn1Error("Error during Reading identifier");		return LDAP_PROTOCOL_ERROR;	}	}	if ( strncmp( peek_head, "value", strlen("value") ) == 0 ) {		rc = SetAnyTypeByComponentOid ((&k->value), (&k->type_id));	rc = GDecComponentAnyDefinedBy (mem_op, b, (&k->value), bytesDecoded, mode );		if ( rc != LDAP_SUCCESS ) return rc;	(&k->value)->identifier.bv_val = peek_head;	(&k->value)->identifier.bv_len = strLen;	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){		Asn1Error("Error during Reading , ");		return LDAP_PROTOCOL_ERROR;	}	if(*peek_head != ','){		Asn1Error("Missing , in encoding");		return LDAP_PROTOCOL_ERROR;	}	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){	  Asn1Error("Error during Reading identifier");		return LDAP_PROTOCOL_ERROR;	}	}	if ( strncmp( peek_head, "extension", strlen("extension") ) == 0 ) {		rc = 	GDecComponentOcts (mem_op, b, (&k->extension), bytesDecoded, mode);		if ( rc != LDAP_SUCCESS ) return rc;	(&k->extension)->identifier.bv_val = peek_head;	(&k->extension)->identifier.bv_len = strLen;	}	if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {		Asn1Error("Error during Reading } in encoding");		return LDAP_PROTOCOL_ERROR;	}	if(*peek_head != '}'){		Asn1Error("Missing } in encoding");		return LDAP_PROTOCOL_ERROR;	}	if( !(old_mode & DEC_ALLOC_MODE_1) ) {	*v = t = (ComponentORAddress*) CompAlloc( mem_op, sizeof(ComponentORAddress) );	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*)GDecComponentORAddress ;	t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentORAddress ;	t->comp_desc->cd_free = (comp_free_func*)NULL;	t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentORAddress;	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*)MatchingComponentORAddress;	return LDAP_SUCCESS;}  /* GDecORAddress*/intMatchingComponentDirectoryString ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {	int rc;	MatchingRule* mr;	ComponentDirectoryString *v1, *v2;	v1 = (ComponentDirectoryString*)csi_attr;	v2 = (ComponentDirectoryString*)csi_assert;	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 );	}	if( (v1->choiceId != v2->choiceId ) )		return LDAP_COMPARE_FALSE;	switch( v1->choiceId )	{	   case DIRECTORYSTRING_TELETEXSTRING :		rc = 	MatchingComponentTeletexString ( oid, (ComponentSyntaxInfo*)(v1->a.teletexString), (ComponentSyntaxInfo*)(v2->a.teletexString) );		break;	   case DIRECTORYSTRING_PRINTABLESTRING :		rc = 	MatchingComponentPrintableString ( oid, (ComponentSyntaxInfo*)(v1->a.printableString), (ComponentSyntaxInfo*)(v2->a.printableString) );		break;	   case DIRECTORYSTRING_UNIVERSALSTRING :		rc = 	MatchingComponentUniversalString ( oid, (ComponentSyntaxInfo*)(v1->a.universalString), (ComponentSyntaxInfo*)(v2->a.universalString) );		break;	   case DIRECTORYSTRING_UTF8STRING :		rc = 	MatchingComponentUTF8String ( oid, (ComponentSyntaxInfo*)(v1->a.utf8String), (ComponentSyntaxInfo*)(v2->a.utf8String) );		break;	   case DIRECTORYSTRING_BMPSTRING :		rc = 	MatchingComponentBMPString ( oid, (ComponentSyntaxInfo*)(v1->a.bmpString), (ComponentSyntaxInfo*)(v2->a.bmpString) );		break;	default : 		 return LDAP_PROTOCOL_ERROR;	}	return rc;}  /* BMatchingComponentDirectoryStringContent */void*ExtractingComponentDirectoryString ( void* mem_op, ComponentReference* cr, ComponentDirectoryString *comp ){	if( (comp->choiceId) ==  DIRECTORYSTRING_TELETEXSTRING &&		 (( comp->a.teletexString->identifier.bv_val && strncmp(comp->a.teletexString->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) ||		 ( strncmp(comp->a.teletexString->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) {		if ( cr->cr_curr->ci_next == NULL )			return (comp->a.teletexString);		else {			cr->cr_curr = cr->cr_curr->ci_next;			return 	ExtractingComponentTeletexString ( mem_op, cr, (comp->a.teletexString) );		};	}	if( (comp->choiceId) ==  DIRECTORYSTRING_PRINTABLESTRING &&		 (( comp->a.printableString->identifier.bv_val && strncmp(comp->a.printableString->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) ||		 ( strncmp(comp->a.printableString->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) {		if ( cr->cr_curr->ci_next == NULL )			return (comp->a.printableString);		else {			cr->cr_curr = cr->cr_curr->ci_next;			return 	ExtractingComponentPrintableString ( mem_op, cr, (comp->a.printableString) );		};	}	if( (comp->choiceId) ==  DIRECTORYSTRING_UNIVERSALSTRING &&		 (( comp->a.universalString->identifier.bv_val && strncmp(comp->a.universalString->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) ||		 ( strncmp(comp->a.universalString->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) {		if ( cr->cr_curr->ci_next == NULL )			return (comp->a.universalString);		else {			cr->cr_curr = cr->cr_curr->ci_next;			return 	ExtractingComponentUniversalString ( mem_op, cr, (comp->a.universalString) );		};	}	if( (comp->choiceId) ==  DIRECTORYSTRING_UTF8STRING &&		 (( comp->a.utf8String->identifier.bv_val && strncmp(comp->a.utf8String->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) ||		 ( strncmp(comp->a.utf8String->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) {		if ( cr->cr_curr->ci_next == NULL )			return (comp->a.utf8String);		else {			cr->cr_curr = cr->cr_curr->ci_next;			return 	ExtractingComponentUTF8String ( mem_op, cr, (comp->a.utf8String) );		};	}	if( (comp->choiceId) ==  DIRECTORYSTRING_BMPSTRING &&		 (( comp->a.bmpString->identifier.bv_val && strncmp(comp->a.bmpString->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) ||		 ( strncmp(comp->a.bmpString->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) {		if ( cr->cr_curr->ci_next == NULL )			return (comp->a.bmpString);		else {			cr->cr_curr = cr->cr_curr->ci_next;			return 	ExtractingComponentBMPString ( mem_op, cr, (comp->a.bmpString) );		};	}	return NULL;}  /* ExtractingComponentDirectoryString */intBDecComponentDirectoryString PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),void* mem_op _AND_GenBuf * b _AND_AsnTag tagId0 _AND_AsnLen elmtLen0 _AND_ComponentDirectoryString **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;	ComponentDirectoryString *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;    switch (tagId0)    {       case MAKE_TAG_ID (UNIV, PRIM, TELETEXSTRING_TAG_CODE):       case MAKE_TAG_ID (UNIV, CONS, TELETEXSTRING_TAG_CODE):        (k->choiceId) = DIRECTORYSTRING_TELETEXSTRING;		rc = 	BDecComponentTeletexString (mem_op, b, tagId0, elmtLen0, (&k->a.teletexString), &totalElmtsLen1, DEC_ALLOC_MODE_0 );		if ( rc != LDAP_SUCCESS ) return rc;		(k->a.teletexString)->identifier.bv_val = (k->a.teletexString)->id_buf;		(k->a.teletexString)->identifier.bv_len = strlen("teletexString");		strcpy( (k->a.teletexString)->identifier.bv_val, "teletexString");    break;       case MAKE_TAG_ID (UNIV, PRIM, PRINTABLESTRING_TAG_CODE):       case MAKE_TAG_ID (UNIV, CONS, PRINTABLESTRING_TAG_CODE):        (k->choiceId) = DIRECTORYSTRING_PRINTABLESTRING;		rc = 	BDecComponentPrintableString (mem_op, b, tagId0, elmtLen0, (&k->a.printableString), &totalElmtsLen1, DEC_ALLOC_MODE_0 );		if ( rc != LDAP_SUCCESS ) return rc;		(k->a.printableString)->identifier.bv_val = (k->a.printableString)->id_buf;		(k->a.printableString)->identifier.bv_len = strlen("printableString");		strcpy( (k->a.printableString)->identifier.bv_val, "printableString");    break;       case MAKE_TAG_ID (UNIV, PRIM, UNIVERSALSTRING_TAG_CODE):       case MAKE_TAG_ID (UNIV, CONS, UNIVERSALSTRING_TAG_CODE):        (k->choiceId) = DIRECTORYSTRING_UNIVERSALSTRING;		rc = 	BDecComponentUniversalString (mem_op, b, tagId0, elmtLen0, (&k->a.universalString), &totalElmtsLen1, DEC_ALLOC_MODE_0 );		if ( rc != LDAP_SUCCESS ) return rc;		(k->a.universalString)->identifier.bv_val = (k->a.universalString)->id_buf;		(k->a.universalString)->identifier.bv_len = strlen("universalString");		strcpy( (k->a.universalString)->identifier.bv_val, "universalString");    break;       case MAKE_TAG_ID (UNIV, PRIM, UTF8STRING_TAG_CODE):       case MAKE_TAG_ID (UNIV, CONS, UTF8STRING_TAG_CODE):        (k->choiceId) = DIRECTORYSTRING_UTF8STRING;		rc = 	BDecComponentUTF8String (mem_op, b, tagId0, elmtLen0, (&k->a.utf8String), &totalElmtsLen1, DEC_ALLOC_MODE_0 );		if ( rc != LDAP_SUCCESS ) return rc;		(k->a.utf8String)->identifier.bv_val = (k->a.utf8String)->id_buf;		(k->a.utf8String)->identifier.bv_len = strlen("utf8String");		strcpy( (k->a.utf8String)->identifier.bv_val, "utf8String");    break;       case MAKE_TAG_ID (UNIV, PRIM, BMPSTRING_TAG_CODE):

⌨️ 快捷键说明

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