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

📄 componentlib.c

📁 ldap服务器源码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* * Component BER Decoder : PrintiableString */intBDecComponentPrintableStringTag ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode ){	return BDecComponentPrintableString ( mem_op, b, 0, 0, v, bytesDecoded, mode|CALL_TAG_DECODER );}intBDecComponentPrintableString( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *v, AsnLen *bytesDecoded, int mode ){        char* peek_head;        int i, strLen, rc;        void* component_values;        ComponentPrintableString* k, **k2;	AsnOid result;                                                                                  k = (ComponentPrintableString*) v;                                                                                  if ( mode & DEC_ALLOC_MODE_0 ) {                k2 = (ComponentPrintableString**) v;                *k2 = (ComponentPrintableString*) CompAlloc( mem_op, sizeof( ComponentPrintableString ) );		if ( !*k2 ) return LDAP_DECODING_ERROR;                k = *k2;        }	if ( mode & CALL_TAG_DECODER ) {		mode = mode & CALL_CONTENT_DECODER;		rc = BDecPrintableString ( mem_op, b, &result, bytesDecoded );	} else {		rc = BDecPrintableStringContent ( mem_op, b, tagId, len, &result, bytesDecoded );	}	if ( rc < 0 ) {		if ( k ) CompFree ( mem_op, k );		return LDAP_DECODING_ERROR;	}	k->value = result;	k->comp_desc = get_component_description (BASICTYPE_PRINTABLE_STR);	return LDAP_SUCCESS;}/* * Component BER Decoder : TeletexString */intBDecComponentTeletexStringTag ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode ){	return BDecComponentTeletexString ( mem_op, b, 0, 0, v, bytesDecoded, mode|CALL_TAG_DECODER );}intBDecComponentTeletexString( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *v, AsnLen *bytesDecoded, int mode ){        char* peek_head;        int i, strLen, rc;        void* component_values;        ComponentTeletexString* k, **k2;	AsnOid result;                                                                                  k = (ComponentTeletexString*) v;                                                                                  if ( mode & DEC_ALLOC_MODE_0 ) {                k2 = (ComponentTeletexString**) v;                *k2 = (ComponentTeletexString*) CompAlloc( mem_op, sizeof( ComponentTeletexString ) );		if ( !*k2 ) return LDAP_DECODING_ERROR;                k = *k2;        }	if ( mode & CALL_TAG_DECODER ) {		mode = mode & CALL_CONTENT_DECODER;		rc = BDecTeletexString ( mem_op, b, &result, bytesDecoded );	} else {		rc = BDecTeletexStringContent ( mem_op, b, tagId, len, &result, bytesDecoded );	}	if ( rc < 0 ) {		if ( k ) CompFree ( mem_op, k );		return LDAP_DECODING_ERROR;	}	k->value = result;	k->comp_desc = get_component_description (BASICTYPE_T61_STR);	return LDAP_SUCCESS;}/* * Matching function : Real */intMatchingComponentReal (char* oid, ComponentSyntaxInfo *csi_attr,			ComponentSyntaxInfo *csi_assert ){        int rc;        MatchingRule* mr;        ComponentReal *a, *b;                                                                                  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 );        }        a = (ComponentReal*)csi_attr;        b = (ComponentReal*)csi_assert;        rc = (a->value == b->value);                                                                                  return rc ? LDAP_COMPARE_TRUE:LDAP_COMPARE_FALSE;}/* * GSER Encoder : Real */intGEncComponentReal ( GenBuf *b, ComponentReal *in ){	GAsnReal t = {0};	if ( !in )		return (-1);	t.value = in->value;	return GEncAsnRealContent ( b, &t );}/* * GSER Decoder : Real */intGDecComponentReal ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode ){        char* peek_head;        int i, strLen;        void* component_values;        ComponentReal* k, **k2;	GAsnReal result;                                                                                  k = (ComponentReal*) v;                                                                                  if ( mode & DEC_ALLOC_MODE_0 ) {                k2 = (ComponentReal**) v;                *k2 = (ComponentReal*) CompAlloc( mem_op, sizeof( ComponentReal ) );		if ( !*k2 ) return LDAP_DECODING_ERROR;                k = *k2;        }	if ( GDecAsnRealContent ( mem_op, b, &result, bytesDecoded ) < 0 ) {		if ( k ) CompFree ( mem_op, k );		return LDAP_DECODING_ERROR;	}	k->value = result.value;	k->comp_desc = get_component_description (BASICTYPE_REAL);        return LDAP_SUCCESS;}/* * Component BER Decoder : Real */intBDecComponentRealTag ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode ) {	return BDecComponentReal ( mem_op, b, 0, 0, v, bytesDecoded, mode|CALL_TAG_DECODER );}intBDecComponentReal ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *v, AsnLen *bytesDecoded, int mode ){        char* peek_head;        int i, strLen, rc;        void* component_values;        ComponentReal* k, **k2;	AsnReal result;                                                                                  k = (ComponentReal*) v;                                                                                  if ( mode & DEC_ALLOC_MODE_0 ) {                k2 = (ComponentReal**) v;                *k2 = (ComponentReal*) CompAlloc( mem_op, sizeof( ComponentReal ) );		if ( !*k2 ) return LDAP_DECODING_ERROR;                k = *k2;        }	if ( mode & CALL_TAG_DECODER ){		mode = mode & CALL_CONTENT_DECODER;		rc = BDecAsnReal ( mem_op, b, &result, bytesDecoded );	} else {		rc = BDecAsnRealContent ( mem_op, b, tagId, len, &result, bytesDecoded );	}	if ( rc < 0 ) {		if ( k ) CompFree ( mem_op, k );		return LDAP_DECODING_ERROR;	}	k->value = result;	k->comp_desc = get_component_description (BASICTYPE_REAL);        return LDAP_SUCCESS;}/* * Matching function : Relative OID */intMatchingComponentRelativeOid ( char* oid, ComponentSyntaxInfo *csi_attr,					ComponentSyntaxInfo *csi_assert ){        int rc;        MatchingRule* mr;        ComponentRelativeOid *a, *b;                                                                                  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 );        }        a = (ComponentRelativeOid*)csi_attr;        b = (ComponentRelativeOid*)csi_assert;	if ( a->value.octetLen != b->value.octetLen )		return LDAP_COMPARE_FALSE;        rc = ( strncmp( a->value.octs, b->value.octs, a->value.octetLen ) == 0 );                                                                                  return rc ? LDAP_COMPARE_TRUE:LDAP_COMPARE_FALSE;}/* * GSER Encoder : RELATIVE_OID. */intGEncComponentRelativeOid ( GenBuf *b, ComponentRelativeOid *in ){	GAsnRelativeOid t = {0};	if ( !in || in->value.octetLen <= 0 )		return (-1);	t.value = in->value;	return GEncAsnRelativeOidContent ( b , (GAsnOcts*)&t );}/* * GSER Decoder : RELATIVE_OID. */intGDecComponentRelativeOid ( void* mem_op, GenBuf *b,void *v, AsnLen *bytesDecoded, int mode ){        char* peek_head;        int i, strLen;        void* component_values;        ComponentRelativeOid* k, **k2;	GAsnRelativeOid result;                                                                                  k = (ComponentRelativeOid*) v;                                                                                  if ( mode & DEC_ALLOC_MODE_0 ) {                k2 = (ComponentRelativeOid**) v;                *k2 = (ComponentRelativeOid*) CompAlloc( mem_op, sizeof( ComponentRelativeOid ) );		if ( !*k2 ) return LDAP_DECODING_ERROR;                k = *k2;        }		if ( GDecAsnRelativeOidContent ( mem_op, b, &result, bytesDecoded ) < 0 ) {		if ( k ) CompFree ( mem_op, k );		return LDAP_DECODING_ERROR;	}	k->value = result.value;	k->comp_desc = get_component_description (BASICTYPE_OID);	return LDAP_SUCCESS;}/* * Component BER Decoder : RELATIVE_OID. */intBDecComponentRelativeOidTag ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode ) {	return BDecComponentRelativeOid ( mem_op, b, 0, 0, v, bytesDecoded, mode|CALL_TAG_DECODER );}intBDecComponentRelativeOid ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *v, AsnLen *bytesDecoded, int mode ){        char* peek_head;        int i, strLen, rc;        void* component_values;        ComponentRelativeOid* k, **k2;	AsnRelativeOid result;                                                                                  k = (ComponentRelativeOid*) v;                                                                                  if ( mode & DEC_ALLOC_MODE_0 ) {                k2 = (ComponentRelativeOid**) v;                *k2 = (ComponentRelativeOid*) CompAlloc( mem_op, sizeof( ComponentRelativeOid ) );		if ( !*k2 ) return LDAP_DECODING_ERROR;                k = *k2;        }		if ( mode & CALL_TAG_DECODER ){		mode = mode & CALL_CONTENT_DECODER;		rc = BDecAsnRelativeOid ( mem_op, b, &result, bytesDecoded );	} else {		rc = BDecAsnRelativeOidContent ( mem_op, b, tagId, len, &result, bytesDecoded );	}	if ( rc < 0 ) {		if ( k ) CompFree ( mem_op, k );		return LDAP_DECODING_ERROR;	}	k->value = result;	k->comp_desc = get_component_description (BASICTYPE_OID);	return LDAP_SUCCESS;}/* * GSER Encoder : UniversalString */intGEncComponentUniversalString ( GenBuf *b, ComponentUniversalString *in ){	GUniversalString t = {0};	if ( !in || in->value.octetLen <= 0 )		return (-1);	t.value = in->value;	return GEncUniversalStringContent( b, &t );}/* * GSER Decoder : UniversalString */static intUTF8toUniversalString( char* octs, int len){	/* Need to be Implemented */	return LDAP_SUCCESS;}intGDecComponentUniversalString ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode ){	if ( GDecComponentUTF8String ( mem_op, b, v, bytesDecoded, mode) < 0 )	UTF8toUniversalString( ((ComponentUniversalString*)v)->value.octs, ((ComponentUniversalString*)v)->value.octetLen );		return LDAP_DECODING_ERROR;}/* * Component BER Decoder : UniverseString */intBDecComponentUniversalStringTag ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode ) {	return BDecComponentUniversalString ( mem_op, b, 0, 0, v, bytesDecoded, mode|CALL_TAG_DECODER );}intBDecComponentUniversalString ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *v, AsnLen *bytesDecoded, int mode ){        char* peek_head;        int i, strLen, rc;        void* component_values;        ComponentUniversalString* k, **k2;	UniversalString result;        k = (ComponentUniversalString*) v;        if ( mode & DEC_ALLOC_MODE_0 ) {                k2 = (ComponentUniversalString**) v;                *k2 = (ComponentUniversalString*) CompAlloc( mem_op, sizeof( ComponentUniversalString ) );		if ( !*k2 ) return LDAP_DECODING_ERROR;                k = *k2;        }		if ( mode & CALL_TAG_DECODER ){		mode = mode & CALL_CONTENT_DECODER;		rc = BDecUniversalString ( mem_op, b, &result, bytesDecoded );	} else {		rc = BDecUniversalStringContent ( mem_op, b, tagId, len, &result, bytesDecoded );	}	if ( rc < 0 ) {		if ( k ) CompFree ( mem_op, k );		return LDAP_DECODING_ERROR;	}	k->value = result;	k->comp_desc = get_component_description (BASICTYPE_UNIVERSAL_STR);	return LDAP_SUCCESS;}/* * Component BER Decoder : VisibleString */intBDecComponentVisibleStringTag ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode ) {	return BDecComponentVisibleString ( mem_op, b, 0, 0, v, bytesDecoded, mode|CALL_TAG_DECODER );}intBDecComponentVisibleString ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *v, AsnLen *bytesDecoded, int mode ){        char* peek_head;        int i, strLen, rc;        void* component_values;        ComponentVisibleString* k, **k2;	VisibleString result;                                                                                  k = (ComponentVisibleString*) v;                                                                                  if ( mode & DEC_ALLOC_MODE_0 ) {                k2 = (ComponentVisibleString**) v;                *k2 = (ComponentVisibleString*) CompAlloc( mem_op, sizeof( ComponentVisibleString ) );		if ( !*k2 ) return LDAP_DECODING_ERROR;                k = *k2;        }		if ( mode & CALL_TAG_DECODER ){		mode = mode & CALL_CONTENT_DECODER;		rc = BDecVisibleString ( mem_op, b, &result, bytesDecoded );	} else {		rc = BDecVisibleStringContent ( mem_op, b, tagId, len, &result, bytesDecoded );	}	k->value = result;	k->comp_desc = get_component_description (BASICTYPE_VISIBLE_STR);	return LDAP_SUCCESS;}/* * Routines for handling an ANY DEFINED Type *//* Check if the <select> type CR and the OID of the given ANY type */intCheckSelectTypeCorrect ( void* mem_op, ComponentAnyInfo* cai, struct berval* select ) {	int strLen;	AttributeType* ad_type;	char* oid;	char* result;	if ( IsNumericOid ( select->bv_val , select->bv_len ) ) {		oid = select->bv_val;		strLen = select->bv_len;	} else {

⌨️ 快捷键说明

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