📄 componentlib.c
字号:
*k2 = (ComponentBool*) CompAlloc( mem_op, sizeof( ComponentBool ) ); if ( !*k2 ) return LDAP_DECODING_ERROR; k = *k2; } if ( GDecAsnBoolContent( 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_BOOLEAN); return LDAP_SUCCESS;}/* * Component BER Decoder : BOOLEAN */intBDecComponentBoolTag ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode ) { return BDecComponentBool ( mem_op, b, 0, 0, v, bytesDecoded, mode|CALL_TAG_DECODER );}intBDecComponentBool ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *v, AsnLen *bytesDecoded, int mode ){ char* peek_head; int i, strLen, rc; ComponentBool* k, **k2; AsnBool result; k = (ComponentBool*) v; if ( mode & DEC_ALLOC_MODE_0 ) { k2 = (ComponentBool**) v; *k2 = (ComponentBool*) CompAlloc( mem_op, sizeof( ComponentBool ) ); if ( !*k2 ) return LDAP_DECODING_ERROR; k = *k2; } if ( mode & CALL_TAG_DECODER ){ mode = mode & CALL_CONTENT_DECODER; rc = BDecAsnBool ( mem_op, b, &result, bytesDecoded ); } else { rc = BDecAsnBoolContent( 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_BOOLEAN); return LDAP_SUCCESS;}/* * Matching function : ENUMERATE */intMatchingComponentEnum ( char* oid, ComponentSyntaxInfo *csi_attr, ComponentSyntaxInfo *csi_assert ){ int rc; MatchingRule* mr; ComponentEnum *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 = ((ComponentEnum*)csi_attr); b = ((ComponentEnum*)csi_assert); rc = (a->value == b->value); return rc ? LDAP_COMPARE_TRUE:LDAP_COMPARE_FALSE;}/* * GSER Encoder : ENUMERATE */intGEncComponentEnum ( GenBuf *b, ComponentEnum *in ){ GAsnEnum t = {0}; if ( !in ) return (-1); t.value = in->value; return GEncAsnEnumContent ( b, &t );}/* * GSER Decoder : ENUMERATE */intGDecComponentEnum ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode ){ char* peek_head; int i, strLen; void* component_values; ComponentEnum* k, **k2; GAsnEnum result; k = (ComponentEnum*) v; if ( mode & DEC_ALLOC_MODE_0 ) { k2 = (ComponentEnum**) v; *k2 = (ComponentEnum*) CompAlloc( mem_op, sizeof( ComponentEnum ) ); if ( !*k2 ) return LDAP_DECODING_ERROR; k = *k2; } if ( GDecAsnEnumContent ( mem_op, b, &result, bytesDecoded ) < 0 ) { if ( k ) CompFree ( mem_op, k ); return LDAP_DECODING_ERROR; } k->value_identifier.bv_val = result.value_identifier; k->value_identifier.bv_len = result.len; k->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) ); if ( !k->comp_desc ) { if ( k ) CompFree ( mem_op, k ); return LDAP_DECODING_ERROR; } k->comp_desc->cd_gser_encoder = (encoder_func*)GEncComponentEnum; k->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentEnum; k->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentEnum; k->comp_desc->cd_free = (comp_free_func*)NULL; k->comp_desc->cd_extract_i = NULL; k->comp_desc->cd_type = ASN_BASIC; k->comp_desc->cd_type_id = BASICTYPE_ENUMERATED; k->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentEnum; return LDAP_SUCCESS;}/* * Component BER Decoder : ENUMERATE */intBDecComponentEnumTag ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode ) { return BDecComponentEnum ( mem_op, b, 0, 0, v, bytesDecoded, mode|CALL_TAG_DECODER );}intBDecComponentEnum ( 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; ComponentEnum* k, **k2; AsnEnum result; k = (ComponentEnum*) v; if ( mode & DEC_ALLOC_MODE_0 ) { k2 = (ComponentEnum**) v; *k2 = (ComponentEnum*) CompAlloc( mem_op, sizeof( ComponentEnum ) ); if ( k ) return LDAP_DECODING_ERROR; k = *k2; } if ( mode & CALL_TAG_DECODER ){ mode = mode & CALL_CONTENT_DECODER; rc = BDecAsnEnum ( mem_op, b, &result, bytesDecoded ); } else { rc = BDecAsnEnumContent ( 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 = CompAlloc( mem_op, sizeof( ComponentDesc ) ); if ( !k->comp_desc ) { if ( k ) CompFree ( mem_op, k ); return LDAP_DECODING_ERROR; } k->comp_desc->cd_gser_encoder = (encoder_func*)GEncComponentEnum; k->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentEnum; k->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentEnum; k->comp_desc->cd_free = (comp_free_func*)NULL; k->comp_desc->cd_extract_i = NULL; k->comp_desc->cd_type = ASN_BASIC; k->comp_desc->cd_type_id = BASICTYPE_ENUMERATED; k->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentEnum; return LDAP_SUCCESS;}/* * Component GSER Encoder : IA5String */intGEncComponentIA5Stirng ( GenBuf *b, ComponentIA5String* in ){ GIA5String t = {0}; t.value = in->value; if ( !in || in->value.octetLen <= 0 ) return (-1); return GEncIA5StringContent( b, &t );}/* * Component BER Decoder : IA5String */intBDecComponentIA5StringTag ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode ) { return BDecComponentIA5String ( mem_op, b, 0, 0, v, bytesDecoded, mode|CALL_TAG_DECODER );}intBDecComponentIA5String ( 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; ComponentIA5String* k, **k2; IA5String result; k = (ComponentIA5String*) v; if ( mode & DEC_ALLOC_MODE_0 ) { k2 = (ComponentIA5String**) v; *k2 = (ComponentIA5String*) CompAlloc( mem_op, sizeof( ComponentIA5String ) ); if ( !*k2 ) return LDAP_DECODING_ERROR; k = *k2; } if ( mode & CALL_TAG_DECODER ){ mode = mode & CALL_CONTENT_DECODER; rc = BDecIA5String ( mem_op, b, &result, bytesDecoded ); } else { rc = BDecIA5StringContent ( 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 = CompAlloc( mem_op, sizeof( ComponentDesc ) ); if ( !k->comp_desc ) { if ( k ) CompFree ( mem_op, k ); return LDAP_DECODING_ERROR; } k->comp_desc->cd_gser_encoder = (encoder_func*)GEncComponentIA5String; k->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentIA5String; k->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentIA5String; k->comp_desc->cd_free = (comp_free_func*)FreeComponentIA5String; k->comp_desc->cd_extract_i = NULL; k->comp_desc->cd_type = ASN_BASIC; k->comp_desc->cd_type_id = BASICTYPE_IA5_STR; k->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentIA5String; return LDAP_SUCCESS;}/* * Matching function : INTEGER */intMatchingComponentInt(char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ){ MatchingRule* mr; ComponentInt *a, *b; if( oid ) { /* check if this ASN type's matching rule is overrided */ mr = retrieve_matching_rule(oid, csi_attr->csi_comp_desc->cd_type_id ); /* if existing function is overrided, call the overridingfunction*/ if ( mr ) return component_value_match( mr, csi_attr , csi_assert ); } a = ((ComponentInt*)csi_attr); b = ((ComponentInt*)csi_assert); return ( a->value == b->value ) ? LDAP_COMPARE_TRUE:LDAP_COMPARE_FALSE;}/* * GSER Encoder : INTEGER */intGEncComponentInt ( GenBuf *b, ComponentInt* in ){ GAsnInt t = {0}; if ( !in ) return (-1); t.value = in->value; return GEncAsnIntContent ( b, &t );}/* * GSER Decoder : INTEGER */intGDecComponentInt( void* mem_op, GenBuf * b, void *v, AsnLen *bytesDecoded, int mode){ char* peek_head; int i, strLen; void* component_values; ComponentInt* k, **k2; GAsnInt result; k = (ComponentInt*) v; if ( mode & DEC_ALLOC_MODE_0 ) { k2 = (ComponentInt**) v; *k2 = (ComponentInt*) CompAlloc( mem_op, sizeof( ComponentInt ) ); if ( !*k2 ) return LDAP_DECODING_ERROR; k = *k2; } if ( GDecAsnIntContent ( 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_INTEGER ); return LDAP_SUCCESS;}/* * Component BER Decoder : INTEGER */intBDecComponentIntTag ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode ) { return BDecComponentInt ( mem_op, b, 0, 0, v, bytesDecoded, mode|CALL_TAG_DECODER );}intBDecComponentInt ( 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; ComponentInt* k, **k2; AsnInt result; k = (ComponentInt*) v; if ( mode & DEC_ALLOC_MODE_0 ) { k2 = (ComponentInt**) v; *k2 = (ComponentInt*) CompAlloc( mem_op, sizeof( ComponentInt ) ); if ( !*k2 ) return LDAP_DECODING_ERROR; k = *k2; } if ( mode & CALL_TAG_DECODER ){ mode = mode & CALL_CONTENT_DECODER; rc = BDecAsnInt ( mem_op, b, &result, bytesDecoded ); } else { rc = BDecAsnIntContent ( mem_op, b, tagId, len, &result, bytesDecoded ); } k->value = result; k->comp_desc = get_component_description (BASICTYPE_INTEGER ); return LDAP_SUCCESS;}/* * Matching function : NULL */intMatchingComponentNull ( char *oid, ComponentSyntaxInfo *csi_attr, ComponentSyntaxInfo *csi_assert ){ MatchingRule* mr; ComponentNull *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 = ((ComponentNull*)csi_attr); b = ((ComponentNull*)csi_assert); return (a->value == b->value) ? LDAP_COMPARE_TRUE:LDAP_COMPARE_FALSE;}/* * GSER Encoder : NULL */intGEncComponentNull ( GenBuf *b, ComponentNull *in ){ GAsnNull t = {0}; if ( !in ) return (-1); t.value = in->value; return GEncAsnNullContent ( b, &t );}/* * GSER Decoder : NULL */intGDecComponentNull ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode ){ char* peek_head; int i, strLen; void* component_values; ComponentNull* k, **k2; GAsnNull result; k = (ComponentNull*) v; if ( mode & DEC_ALLOC_MODE_0 ) { k2 = (ComponentNull**) v; *k2 = (ComponentNull*) CompAlloc( mem_op, sizeof( ComponentNull ) ); if ( !*k2 ) return LDAP_DECODING_ERROR; k = *k2; } if ( GDecAsnNullContent ( mem_op, b, &result, bytesDecoded ) < 0 ) { if ( k ) CompFree ( mem_op, k ); return LDAP_DECODING_ERROR; } k->value = result.value; k->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -