Back to index

openldap  2.4.31
authorityKeyIdentifier.c
Go to the documentation of this file.
00001 /*
00002  *    authorityKeyIdentifier.c
00003  *    "AuthorityKeyIdentifierDefinition" ASN.1 module encode/decode/extracting/matching/free C src.
00004  *    This file was generated by modified eSMACC compiler Wed Dec  8 22:22:49 2004
00005  *    The generated files are supposed to be compiled as a module for OpenLDAP Software
00006  */
00007 
00008 #include "authorityKeyIdentifier.h"
00009 
00010 BDecComponentAuthorityKeyIdentifierTop( void* mem_op, GenBuf* b, void *v, AsnLen* bytesDecoded,int mode) {
00011        AsnTag tag;
00012        AsnLen elmtLen;
00013 
00014        tag = BDecTag ( b, bytesDecoded );
00015        elmtLen = BDecLen ( b, bytesDecoded );
00016        if ( elmtLen <= 0 ) return (-1);
00017        if ( tag != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE) ) {
00018               return (-1);
00019        }
00020               
00021        return BDecComponentAuthorityKeyIdentifier( mem_op, b, tag, elmtLen, ( ComponentAuthorityKeyIdentifier**)v, (AsnLen*)bytesDecoded, mode );
00022 }
00023 
00024 
00025 void init_module_AuthorityKeyIdentifierDefinition() {
00026        InstallOidDecoderMapping( "2.5.29.35", NULL,
00027                             GDecComponentAuthorityKeyIdentifier,
00028                             BDecComponentAuthorityKeyIdentifierTop,
00029                             ExtractingComponentAuthorityKeyIdentifier,
00030                             MatchingComponentAuthorityKeyIdentifier   );
00031 }
00032 
00033 int
00034 MatchingComponentOtherName ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
00035        int rc;
00036        MatchingRule* mr;
00037 
00038        if ( oid ) {
00039               mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
00040               if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
00041        }
00042 
00043        rc = 1;
00044        rc =   MatchingComponentOid ( oid, (ComponentSyntaxInfo*)&((ComponentOtherName*)csi_attr)->type_id, (ComponentSyntaxInfo*)&((ComponentOtherName*)csi_assert)->type_id );
00045        if ( rc != LDAP_COMPARE_TRUE )
00046               return rc;
00047        rc =   SetAnyTypeByComponentOid ((ComponentSyntaxInfo*)&((ComponentOtherName*)csi_attr)->value, (&((ComponentOtherName*)csi_attr)->type_id));
00048        rc = MatchingComponentAnyDefinedBy ( oid, (ComponentAny*)&((ComponentOtherName*)csi_attr)->value, (ComponentAny*)&((ComponentOtherName*)csi_assert)->value);
00049        if ( rc != LDAP_COMPARE_TRUE )
00050               return rc;
00051        return LDAP_COMPARE_TRUE;
00052 }  /* BMatchingComponentOtherName */
00053 
00054 void*
00055 ExtractingComponentOtherName ( void* mem_op, ComponentReference* cr, ComponentOtherName *comp )
00056 {
00057 
00058        if ( ( comp->type_id.identifier.bv_val && strncmp(comp->type_id.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->type_id.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
00059               if ( cr->cr_curr->ci_next == NULL )
00060               return &comp->type_id;
00061               else
00062               return NULL;
00063        }
00064        if ( ( comp->value.identifier.bv_val && strncmp(comp->value.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->value.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
00065               if ( cr->cr_curr->ci_next == NULL )
00066               return &comp->value;
00067               else
00068               return NULL;
00069        }
00070        return NULL;
00071 }  /* ExtractingComponentOtherName */
00072 
00073 int
00074 BDecComponentOtherName PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
00075 void* mem_op _AND_
00076 GenBuf * b _AND_
00077 AsnTag tagId0 _AND_
00078 AsnLen elmtLen0 _AND_
00079 ComponentOtherName **v _AND_
00080 AsnLen *bytesDecoded _AND_
00081 int mode)
00082 {
00083        int seqDone = FALSE;
00084        AsnLen totalElmtsLen1 = 0;
00085        AsnLen elmtLen1;
00086        AsnTag tagId1;
00087        int mandatoryElmtCount1 = 0;
00088        AsnLen totalElmtsLen2 = 0;
00089        AsnLen elmtLen2;
00090        AsnTag tagId2;
00091        int old_mode = mode;
00092        int rc;
00093        ComponentOtherName *k, *t, c_temp;
00094 
00095 
00096        if ( !(mode & DEC_ALLOC_MODE_1) ) {
00097               memset(&c_temp,0,sizeof(c_temp));
00098                k = &c_temp;
00099        } else
00100                k = t = *v;
00101        mode = DEC_ALLOC_MODE_2;
00102     tagId1 = BDecTag (b, &totalElmtsLen1 );
00103 
00104     if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))))
00105     {
00106     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
00107               rc =   BDecComponentOid (mem_op, b, tagId1, elmtLen1, (&k->type_id), &totalElmtsLen1, mode);
00108               if ( rc != LDAP_SUCCESS ) return rc;
00109               (&k->type_id)->identifier.bv_val = (&k->type_id)->id_buf;
00110               (&k->type_id)->identifier.bv_len = strlen("type_id");
00111               strcpy( (&k->type_id)->identifier.bv_val, "type_id");
00112     tagId1 = BDecTag (b, &totalElmtsLen1);
00113     }
00114     else
00115         return -1;
00116 
00117 
00118 
00119     if (((tagId1 == MAKE_TAG_ID (CNTX, CONS, 0))))
00120     {
00121     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
00122               rc = SetAnyTypeByComponentOid ((&k->value), (&k->type_id));
00123        rc = BDecComponentAnyDefinedBy (mem_op,b, (&k->value), &totalElmtsLen1, mode );
00124               if ( rc != LDAP_SUCCESS ) return rc;
00125               (&k->value)->identifier.bv_val = (&k->value)->id_buf;
00126               (&k->value)->identifier.bv_len = strlen("value");
00127               strcpy( (&k->value)->identifier.bv_val, "value");
00128        if (elmtLen1 == INDEFINITE_LEN)
00129         BDecEoc (b, &totalElmtsLen1 );
00130         seqDone = TRUE;
00131         if (elmtLen0 == INDEFINITE_LEN)
00132             BDecEoc (b, &totalElmtsLen1 );
00133         else if (totalElmtsLen1 != elmtLen0)
00134         return -1;
00135 
00136     }
00137     else
00138         return -1;
00139 
00140 
00141 
00142     if (!seqDone)
00143         return -1;
00144 
00145        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
00146        *v = t = (ComponentOtherName*) CompAlloc( mem_op, sizeof(ComponentOtherName) );
00147        if ( !t ) return -1;
00148        *t = *k;
00149        }
00150        t->syntax = (Syntax*)NULL;
00151        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
00152        if ( !t->comp_desc ) {
00153               free ( t );
00154               return -1;
00155        }
00156        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentOtherName ;
00157        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentOtherName ;
00158        t->comp_desc->cd_free = (comp_free_func*)NULL;
00159        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentOtherName;
00160        t->comp_desc->cd_type = ASN_COMPOSITE;
00161        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
00162        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentOtherName;
00163     (*bytesDecoded) += totalElmtsLen1;
00164        return LDAP_SUCCESS;
00165 }  /* BDecOtherName*/
00166 
00167 int
00168 GDecComponentOtherName PARAMS (( mem_op,b, v, bytesDecoded, mode),
00169 void* mem_op _AND_
00170 GenBuf * b _AND_
00171 ComponentOtherName **v _AND_
00172 AsnLen *bytesDecoded _AND_
00173 int mode)
00174 {
00175        char* peek_head,*peek_head2;
00176        int i, strLen,strLen2, rc, old_mode = mode;
00177        ComponentOtherName *k,*t, c_temp;
00178 
00179 
00180        if ( !(mode & DEC_ALLOC_MODE_1) ) {
00181               memset(&c_temp,0,sizeof(c_temp));
00182                k = &c_temp;
00183        } else
00184                k = t = *v;
00185        mode = DEC_ALLOC_MODE_2;
00186        *bytesDecoded = 0;
00187        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00188               Asn1Error("Error during Reading { in encoded data");
00189               return LDAP_PROTOCOL_ERROR;
00190        }
00191        if(*peek_head != '{'){
00192               Asn1Error("Missing { in encoded data");
00193               return LDAP_PROTOCOL_ERROR;
00194        }
00195 
00196        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00197               Asn1Error("Error during Reading identifier");
00198               return LDAP_PROTOCOL_ERROR;
00199        }
00200        if ( strncmp( peek_head, "type_id", strlen("type_id") ) == 0 ) {
00201               rc =   GDecComponentOid (mem_op, b, (&k->type_id), bytesDecoded, mode);
00202               if ( rc != LDAP_SUCCESS ) return rc;
00203        (&k->type_id)->identifier.bv_val = peek_head;
00204        (&k->type_id)->identifier.bv_len = strLen;
00205        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00206               Asn1Error("Error during Reading , ");
00207               return LDAP_PROTOCOL_ERROR;
00208        }
00209        if(*peek_head != ','){
00210               Asn1Error("Missing , in encoding");
00211               return LDAP_PROTOCOL_ERROR;
00212        }
00213        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00214          Asn1Error("Error during Reading identifier");
00215               return LDAP_PROTOCOL_ERROR;
00216        }
00217        }
00218        if ( strncmp( peek_head, "value", strlen("value") ) == 0 ) {
00219               rc = SetAnyTypeByComponentOid ((&k->value), (&k->type_id));
00220        rc = GDecComponentAnyDefinedBy (mem_op, b, (&k->value), bytesDecoded, mode );
00221               if ( rc != LDAP_SUCCESS ) return rc;
00222        (&k->value)->identifier.bv_val = peek_head;
00223        (&k->value)->identifier.bv_len = strLen;
00224        }
00225        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
00226               Asn1Error("Error during Reading } in encoding");
00227               return LDAP_PROTOCOL_ERROR;
00228        }
00229        if(*peek_head != '}'){
00230               Asn1Error("Missing } in encoding");
00231               return LDAP_PROTOCOL_ERROR;
00232        }
00233        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
00234        *v = t = (ComponentOtherName*) CompAlloc( mem_op, sizeof(ComponentOtherName) );
00235        if ( !t ) return -1;
00236        *t = *k;
00237        }
00238        t->syntax = (Syntax*)NULL;
00239        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
00240        if ( !t->comp_desc ) {
00241               free ( t );
00242               return -1;
00243        }
00244        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentOtherName ;
00245        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentOtherName ;
00246        t->comp_desc->cd_free = (comp_free_func*)NULL;
00247        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentOtherName;
00248        t->comp_desc->cd_type = ASN_COMPOSITE;
00249        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
00250        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentOtherName;
00251        return LDAP_SUCCESS;
00252 }  /* GDecOtherName*/
00253 
00254 
00255 int
00256 MatchingComponentORAddress ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
00257        int rc;
00258        MatchingRule* mr;
00259 
00260        if ( oid ) {
00261               mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
00262               if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
00263        }
00264 
00265        rc = 1;
00266        rc =   MatchingComponentOid ( oid, (ComponentSyntaxInfo*)&((ComponentORAddress*)csi_attr)->type_id, (ComponentSyntaxInfo*)&((ComponentORAddress*)csi_assert)->type_id );
00267        if ( rc != LDAP_COMPARE_TRUE )
00268               return rc;
00269        rc =   SetAnyTypeByComponentOid ((ComponentSyntaxInfo*)&((ComponentORAddress*)csi_attr)->value, (&((ComponentORAddress*)csi_attr)->type_id));
00270        rc = MatchingComponentAnyDefinedBy ( oid, (ComponentAny*)&((ComponentORAddress*)csi_attr)->value, (ComponentAny*)&((ComponentORAddress*)csi_assert)->value);
00271        if ( rc != LDAP_COMPARE_TRUE )
00272               return rc;
00273        rc =   MatchingComponentOcts ( oid, (ComponentSyntaxInfo*)&((ComponentORAddress*)csi_attr)->extension, (ComponentSyntaxInfo*)&((ComponentORAddress*)csi_assert)->extension );
00274        if ( rc != LDAP_COMPARE_TRUE )
00275               return rc;
00276        return LDAP_COMPARE_TRUE;
00277 }  /* BMatchingComponentORAddress */
00278 
00279 void*
00280 ExtractingComponentORAddress ( void* mem_op, ComponentReference* cr, ComponentORAddress *comp )
00281 {
00282 
00283        if ( ( comp->type_id.identifier.bv_val && strncmp(comp->type_id.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->type_id.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
00284               if ( cr->cr_curr->ci_next == NULL )
00285               return &comp->type_id;
00286               else
00287               return NULL;
00288        }
00289        if ( ( comp->value.identifier.bv_val && strncmp(comp->value.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->value.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
00290               if ( cr->cr_curr->ci_next == NULL )
00291               return &comp->value;
00292               else
00293               return NULL;
00294        }
00295        if ( ( comp->extension.identifier.bv_val && strncmp(comp->extension.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->extension.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
00296               if ( cr->cr_curr->ci_next == NULL )
00297               return &comp->extension;
00298               else
00299               return NULL;
00300        }
00301        return NULL;
00302 }  /* ExtractingComponentORAddress */
00303 
00304 int
00305 BDecComponentORAddress PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
00306 void* mem_op _AND_
00307 GenBuf * b _AND_
00308 AsnTag tagId0 _AND_
00309 AsnLen elmtLen0 _AND_
00310 ComponentORAddress **v _AND_
00311 AsnLen *bytesDecoded _AND_
00312 int mode)
00313 {
00314        int seqDone = FALSE;
00315        AsnLen totalElmtsLen1 = 0;
00316        AsnLen elmtLen1;
00317        AsnTag tagId1;
00318        int mandatoryElmtCount1 = 0;
00319        int old_mode = mode;
00320        int rc;
00321        ComponentORAddress *k, *t, c_temp;
00322 
00323 
00324        if ( !(mode & DEC_ALLOC_MODE_1) ) {
00325               memset(&c_temp,0,sizeof(c_temp));
00326                k = &c_temp;
00327        } else
00328                k = t = *v;
00329        mode = DEC_ALLOC_MODE_2;
00330     tagId1 = BDecTag (b, &totalElmtsLen1 );
00331 
00332     if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))))
00333     {
00334     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
00335               rc =   BDecComponentOid (mem_op, b, tagId1, elmtLen1, (&k->type_id), &totalElmtsLen1, mode);
00336               if ( rc != LDAP_SUCCESS ) return rc;
00337               (&k->type_id)->identifier.bv_val = (&k->type_id)->id_buf;
00338               (&k->type_id)->identifier.bv_len = strlen("type_id");
00339               strcpy( (&k->type_id)->identifier.bv_val, "type_id");
00340     }
00341     else
00342         return -1;
00343 
00344 
00345 
00346     {
00347               rc = SetAnyTypeByComponentOid ((&k->value), (&k->type_id));
00348        rc = BDecComponentAnyDefinedBy (mem_op,b, (&k->value), &totalElmtsLen1, mode );
00349               if ( rc != LDAP_SUCCESS ) return rc;
00350               (&k->value)->identifier.bv_val = (&k->value)->id_buf;
00351               (&k->value)->identifier.bv_len = strlen("value");
00352               strcpy( (&k->value)->identifier.bv_val, "value");
00353     if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0))
00354         seqDone = TRUE;
00355     else
00356     {
00357         tagId1 = BDecTag (b, &totalElmtsLen1 );
00358 
00359          if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID))
00360         {
00361             BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
00362             seqDone = TRUE;
00363         }
00364     }
00365     }
00366 
00367 
00368     if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) ||
00369 (tagId1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))))
00370     {
00371     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
00372               rc =   BDecComponentOcts (mem_op, b, tagId1, elmtLen1, (&k->extension), &totalElmtsLen1, mode);
00373               if ( rc != LDAP_SUCCESS ) return rc;
00374               (&k->extension)->identifier.bv_val = (&k->extension)->id_buf;
00375               (&k->extension)->identifier.bv_len = strlen("extension");
00376               strcpy( (&k->extension)->identifier.bv_val, "extension");
00377         seqDone = TRUE;
00378         if (elmtLen0 == INDEFINITE_LEN)
00379             BDecEoc (b, &totalElmtsLen1 );
00380         else if (totalElmtsLen1 != elmtLen0)
00381         return -1;
00382 
00383     }
00384 
00385 
00386     if (!seqDone)
00387         return -1;
00388 
00389        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
00390        *v = t = (ComponentORAddress*) CompAlloc( mem_op, sizeof(ComponentORAddress) );
00391        if ( !t ) return -1;
00392        *t = *k;
00393        }
00394        t->syntax = (Syntax*)NULL;
00395        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
00396        if ( !t->comp_desc ) {
00397               free ( t );
00398               return -1;
00399        }
00400        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentORAddress ;
00401        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentORAddress ;
00402        t->comp_desc->cd_free = (comp_free_func*)NULL;
00403        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentORAddress;
00404        t->comp_desc->cd_type = ASN_COMPOSITE;
00405        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
00406        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentORAddress;
00407     (*bytesDecoded) += totalElmtsLen1;
00408        return LDAP_SUCCESS;
00409 }  /* BDecORAddress*/
00410 
00411 int
00412 GDecComponentORAddress PARAMS (( mem_op,b, v, bytesDecoded, mode),
00413 void* mem_op _AND_
00414 GenBuf * b _AND_
00415 ComponentORAddress **v _AND_
00416 AsnLen *bytesDecoded _AND_
00417 int mode)
00418 {
00419        char* peek_head,*peek_head2;
00420        int i, strLen,strLen2, rc, old_mode = mode;
00421        ComponentORAddress *k,*t, c_temp;
00422 
00423 
00424        if ( !(mode & DEC_ALLOC_MODE_1) ) {
00425               memset(&c_temp,0,sizeof(c_temp));
00426                k = &c_temp;
00427        } else
00428                k = t = *v;
00429        mode = DEC_ALLOC_MODE_2;
00430        *bytesDecoded = 0;
00431        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00432               Asn1Error("Error during Reading { in encoded data");
00433               return LDAP_PROTOCOL_ERROR;
00434        }
00435        if(*peek_head != '{'){
00436               Asn1Error("Missing { in encoded data");
00437               return LDAP_PROTOCOL_ERROR;
00438        }
00439 
00440        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00441               Asn1Error("Error during Reading identifier");
00442               return LDAP_PROTOCOL_ERROR;
00443        }
00444        if ( strncmp( peek_head, "type_id", strlen("type_id") ) == 0 ) {
00445               rc =   GDecComponentOid (mem_op, b, (&k->type_id), bytesDecoded, mode);
00446               if ( rc != LDAP_SUCCESS ) return rc;
00447        (&k->type_id)->identifier.bv_val = peek_head;
00448        (&k->type_id)->identifier.bv_len = strLen;
00449        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00450               Asn1Error("Error during Reading , ");
00451               return LDAP_PROTOCOL_ERROR;
00452        }
00453        if(*peek_head != ','){
00454               Asn1Error("Missing , in encoding");
00455               return LDAP_PROTOCOL_ERROR;
00456        }
00457        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00458          Asn1Error("Error during Reading identifier");
00459               return LDAP_PROTOCOL_ERROR;
00460        }
00461        }
00462        if ( strncmp( peek_head, "value", strlen("value") ) == 0 ) {
00463               rc = SetAnyTypeByComponentOid ((&k->value), (&k->type_id));
00464        rc = GDecComponentAnyDefinedBy (mem_op, b, (&k->value), bytesDecoded, mode );
00465               if ( rc != LDAP_SUCCESS ) return rc;
00466        (&k->value)->identifier.bv_val = peek_head;
00467        (&k->value)->identifier.bv_len = strLen;
00468        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00469               Asn1Error("Error during Reading , ");
00470               return LDAP_PROTOCOL_ERROR;
00471        }
00472        if(*peek_head != ','){
00473               Asn1Error("Missing , in encoding");
00474               return LDAP_PROTOCOL_ERROR;
00475        }
00476        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00477          Asn1Error("Error during Reading identifier");
00478               return LDAP_PROTOCOL_ERROR;
00479        }
00480        }
00481        if ( strncmp( peek_head, "extension", strlen("extension") ) == 0 ) {
00482               rc =   GDecComponentOcts (mem_op, b, (&k->extension), bytesDecoded, mode);
00483               if ( rc != LDAP_SUCCESS ) return rc;
00484        (&k->extension)->identifier.bv_val = peek_head;
00485        (&k->extension)->identifier.bv_len = strLen;
00486        }
00487        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
00488               Asn1Error("Error during Reading } in encoding");
00489               return LDAP_PROTOCOL_ERROR;
00490        }
00491        if(*peek_head != '}'){
00492               Asn1Error("Missing } in encoding");
00493               return LDAP_PROTOCOL_ERROR;
00494        }
00495        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
00496        *v = t = (ComponentORAddress*) CompAlloc( mem_op, sizeof(ComponentORAddress) );
00497        if ( !t ) return -1;
00498        *t = *k;
00499        }
00500        t->syntax = (Syntax*)NULL;
00501        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
00502        if ( !t->comp_desc ) {
00503               free ( t );
00504               return -1;
00505        }
00506        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentORAddress ;
00507        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentORAddress ;
00508        t->comp_desc->cd_free = (comp_free_func*)NULL;
00509        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentORAddress;
00510        t->comp_desc->cd_type = ASN_COMPOSITE;
00511        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
00512        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentORAddress;
00513        return LDAP_SUCCESS;
00514 }  /* GDecORAddress*/
00515 
00516 
00517 int
00518 MatchingComponentDirectoryString ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
00519        int rc;
00520        MatchingRule* mr;
00521        ComponentDirectoryString *v1, *v2;
00522 
00523 
00524        v1 = (ComponentDirectoryString*)csi_attr;
00525        v2 = (ComponentDirectoryString*)csi_assert;
00526        if ( oid ) {
00527               mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
00528               if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
00529        }
00530 
00531        if( (v1->choiceId != v2->choiceId ) )
00532               return LDAP_COMPARE_FALSE;
00533        switch( v1->choiceId )
00534        {
00535           case DIRECTORYSTRING_TELETEXSTRING :
00536               rc =   MatchingComponentTeletexString ( oid, (ComponentSyntaxInfo*)(v1->a.teletexString), (ComponentSyntaxInfo*)(v2->a.teletexString) );
00537               break;
00538           case DIRECTORYSTRING_PRINTABLESTRING :
00539               rc =   MatchingComponentPrintableString ( oid, (ComponentSyntaxInfo*)(v1->a.printableString), (ComponentSyntaxInfo*)(v2->a.printableString) );
00540               break;
00541           case DIRECTORYSTRING_UNIVERSALSTRING :
00542               rc =   MatchingComponentUniversalString ( oid, (ComponentSyntaxInfo*)(v1->a.universalString), (ComponentSyntaxInfo*)(v2->a.universalString) );
00543               break;
00544           case DIRECTORYSTRING_UTF8STRING :
00545               rc =   MatchingComponentUTF8String ( oid, (ComponentSyntaxInfo*)(v1->a.utf8String), (ComponentSyntaxInfo*)(v2->a.utf8String) );
00546               break;
00547           case DIRECTORYSTRING_BMPSTRING :
00548               rc =   MatchingComponentBMPString ( oid, (ComponentSyntaxInfo*)(v1->a.bmpString), (ComponentSyntaxInfo*)(v2->a.bmpString) );
00549               break;
00550        default : 
00551                return LDAP_PROTOCOL_ERROR;
00552        }
00553        return rc;
00554 }  /* BMatchingComponentDirectoryStringContent */
00555 
00556 void*
00557 ExtractingComponentDirectoryString ( void* mem_op, ComponentReference* cr, ComponentDirectoryString *comp )
00558 {
00559 
00560 
00561        if( (comp->choiceId) ==  DIRECTORYSTRING_TELETEXSTRING &&
00562                (( 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) ||
00563                ( 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))) {
00564               if ( cr->cr_curr->ci_next == NULL )
00565                      return (comp->a.teletexString);
00566               else {
00567                      cr->cr_curr = cr->cr_curr->ci_next;
00568                      return        ExtractingComponentTeletexString ( mem_op, cr, (comp->a.teletexString) );
00569               };
00570        }
00571        if( (comp->choiceId) ==  DIRECTORYSTRING_PRINTABLESTRING &&
00572                (( 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) ||
00573                ( 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))) {
00574               if ( cr->cr_curr->ci_next == NULL )
00575                      return (comp->a.printableString);
00576               else {
00577                      cr->cr_curr = cr->cr_curr->ci_next;
00578                      return        ExtractingComponentPrintableString ( mem_op, cr, (comp->a.printableString) );
00579               };
00580        }
00581        if( (comp->choiceId) ==  DIRECTORYSTRING_UNIVERSALSTRING &&
00582                (( 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) ||
00583                ( 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))) {
00584               if ( cr->cr_curr->ci_next == NULL )
00585                      return (comp->a.universalString);
00586               else {
00587                      cr->cr_curr = cr->cr_curr->ci_next;
00588                      return        ExtractingComponentUniversalString ( mem_op, cr, (comp->a.universalString) );
00589               };
00590        }
00591        if( (comp->choiceId) ==  DIRECTORYSTRING_UTF8STRING &&
00592                (( 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) ||
00593                ( 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))) {
00594               if ( cr->cr_curr->ci_next == NULL )
00595                      return (comp->a.utf8String);
00596               else {
00597                      cr->cr_curr = cr->cr_curr->ci_next;
00598                      return        ExtractingComponentUTF8String ( mem_op, cr, (comp->a.utf8String) );
00599               };
00600        }
00601        if( (comp->choiceId) ==  DIRECTORYSTRING_BMPSTRING &&
00602                (( 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) ||
00603                ( 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))) {
00604               if ( cr->cr_curr->ci_next == NULL )
00605                      return (comp->a.bmpString);
00606               else {
00607                      cr->cr_curr = cr->cr_curr->ci_next;
00608                      return        ExtractingComponentBMPString ( mem_op, cr, (comp->a.bmpString) );
00609               };
00610        }
00611        return NULL;
00612 }  /* ExtractingComponentDirectoryString */
00613 
00614 int
00615 BDecComponentDirectoryString PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
00616 void* mem_op _AND_
00617 GenBuf * b _AND_
00618 AsnTag tagId0 _AND_
00619 AsnLen elmtLen0 _AND_
00620 ComponentDirectoryString **v _AND_
00621 AsnLen *bytesDecoded _AND_
00622 int mode)
00623 {
00624        int seqDone = FALSE;
00625        AsnLen totalElmtsLen1 = 0;
00626        AsnLen elmtLen1;
00627        AsnTag tagId1;
00628        int mandatoryElmtCount1 = 0;
00629        int old_mode = mode;
00630        int rc;
00631        ComponentDirectoryString *k, *t, c_temp;
00632 
00633 
00634        if ( !(mode & DEC_ALLOC_MODE_1) ) {
00635               memset(&c_temp,0,sizeof(c_temp));
00636                k = &c_temp;
00637        } else
00638                k = t = *v;
00639        mode = DEC_ALLOC_MODE_2;
00640     switch (tagId0)
00641     {
00642        case MAKE_TAG_ID (UNIV, PRIM, TELETEXSTRING_TAG_CODE):
00643        case MAKE_TAG_ID (UNIV, CONS, TELETEXSTRING_TAG_CODE):
00644         (k->choiceId) = DIRECTORYSTRING_TELETEXSTRING;
00645               rc =   BDecComponentTeletexString (mem_op, b, tagId0, elmtLen0, (&k->a.teletexString), &totalElmtsLen1, DEC_ALLOC_MODE_0 );
00646               if ( rc != LDAP_SUCCESS ) return rc;
00647               (k->a.teletexString)->identifier.bv_val = (k->a.teletexString)->id_buf;
00648               (k->a.teletexString)->identifier.bv_len = strlen("teletexString");
00649               strcpy( (k->a.teletexString)->identifier.bv_val, "teletexString");
00650     break;
00651 
00652        case MAKE_TAG_ID (UNIV, PRIM, PRINTABLESTRING_TAG_CODE):
00653        case MAKE_TAG_ID (UNIV, CONS, PRINTABLESTRING_TAG_CODE):
00654         (k->choiceId) = DIRECTORYSTRING_PRINTABLESTRING;
00655               rc =   BDecComponentPrintableString (mem_op, b, tagId0, elmtLen0, (&k->a.printableString), &totalElmtsLen1, DEC_ALLOC_MODE_0 );
00656               if ( rc != LDAP_SUCCESS ) return rc;
00657               (k->a.printableString)->identifier.bv_val = (k->a.printableString)->id_buf;
00658               (k->a.printableString)->identifier.bv_len = strlen("printableString");
00659               strcpy( (k->a.printableString)->identifier.bv_val, "printableString");
00660     break;
00661 
00662        case MAKE_TAG_ID (UNIV, PRIM, UNIVERSALSTRING_TAG_CODE):
00663        case MAKE_TAG_ID (UNIV, CONS, UNIVERSALSTRING_TAG_CODE):
00664         (k->choiceId) = DIRECTORYSTRING_UNIVERSALSTRING;
00665               rc =   BDecComponentUniversalString (mem_op, b, tagId0, elmtLen0, (&k->a.universalString), &totalElmtsLen1, DEC_ALLOC_MODE_0 );
00666               if ( rc != LDAP_SUCCESS ) return rc;
00667               (k->a.universalString)->identifier.bv_val = (k->a.universalString)->id_buf;
00668               (k->a.universalString)->identifier.bv_len = strlen("universalString");
00669               strcpy( (k->a.universalString)->identifier.bv_val, "universalString");
00670     break;
00671 
00672        case MAKE_TAG_ID (UNIV, PRIM, UTF8STRING_TAG_CODE):
00673        case MAKE_TAG_ID (UNIV, CONS, UTF8STRING_TAG_CODE):
00674         (k->choiceId) = DIRECTORYSTRING_UTF8STRING;
00675               rc =   BDecComponentUTF8String (mem_op, b, tagId0, elmtLen0, (&k->a.utf8String), &totalElmtsLen1, DEC_ALLOC_MODE_0 );
00676               if ( rc != LDAP_SUCCESS ) return rc;
00677               (k->a.utf8String)->identifier.bv_val = (k->a.utf8String)->id_buf;
00678               (k->a.utf8String)->identifier.bv_len = strlen("utf8String");
00679               strcpy( (k->a.utf8String)->identifier.bv_val, "utf8String");
00680     break;
00681 
00682        case MAKE_TAG_ID (UNIV, PRIM, BMPSTRING_TAG_CODE):
00683        case MAKE_TAG_ID (UNIV, CONS, BMPSTRING_TAG_CODE):
00684         (k->choiceId) = DIRECTORYSTRING_BMPSTRING;
00685               rc =   BDecComponentBMPString (mem_op, b, tagId0, elmtLen0, (&k->a.bmpString), &totalElmtsLen1, DEC_ALLOC_MODE_0 );
00686               if ( rc != LDAP_SUCCESS ) return rc;
00687               (k->a.bmpString)->identifier.bv_val = (k->a.bmpString)->id_buf;
00688               (k->a.bmpString)->identifier.bv_len = strlen("bmpString");
00689               strcpy( (k->a.bmpString)->identifier.bv_val, "bmpString");
00690     break;
00691 
00692     default:
00693         Asn1Error ("ERROR - unexpected tag in CHOICE\n");
00694         return -1;
00695         break;
00696     } /* end switch */
00697        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
00698        *v = t = (ComponentDirectoryString*) CompAlloc( mem_op, sizeof(ComponentDirectoryString) );
00699        if ( !t ) return -1;
00700        *t = *k;
00701        }
00702        t->syntax = (Syntax*)NULL;
00703        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
00704        if ( !t->comp_desc ) {
00705               free ( t );
00706               return -1;
00707        }
00708        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentDirectoryString ;
00709        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentDirectoryString ;
00710        t->comp_desc->cd_free = (comp_free_func*)NULL;
00711        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentDirectoryString;
00712        t->comp_desc->cd_type = ASN_COMPOSITE;
00713        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
00714        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentDirectoryString;
00715     (*bytesDecoded) += totalElmtsLen1;
00716        return LDAP_SUCCESS;
00717 }  /* BDecDirectoryStringContent */
00718 
00719 int
00720 GDecComponentDirectoryString PARAMS (( mem_op,b, v, bytesDecoded, mode),
00721 void* mem_op _AND_
00722 GenBuf * b _AND_
00723 ComponentDirectoryString **v _AND_
00724 AsnLen *bytesDecoded _AND_
00725 int mode)
00726 {
00727        char* peek_head,*peek_head2;
00728        int i, strLen,strLen2, rc, old_mode = mode;
00729        ComponentDirectoryString *k,*t, c_temp;
00730 
00731 
00732        if ( !(mode & DEC_ALLOC_MODE_1) ) {
00733               memset(&c_temp,0,sizeof(c_temp));
00734                k = &c_temp;
00735        } else
00736                k = t = *v;
00737        mode = DEC_ALLOC_MODE_2;
00738        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00739               Asn1Error("Error during Reading identifier");
00740               return LDAP_PROTOCOL_ERROR;
00741        }
00742        if( !(strLen2 = LocateNextGSERToken(mem_op,b,&peek_head2,GSER_NO_COPY)) ){
00743               Asn1Error("Error during Reading identifier");
00744               return LDAP_PROTOCOL_ERROR;
00745        }
00746        if(*peek_head2 != ':'){
00747               Asn1Error("Missing : in encoded data");
00748               return LDAP_PROTOCOL_ERROR;
00749        }
00750        if( strncmp("teletexString",peek_head, strlen("teletexString")) == 0){
00751               (k->choiceId) = DIRECTORYSTRING_TELETEXSTRING;
00752               rc =   GDecComponentTeletexString (mem_op, b, (&k->a.teletexString), bytesDecoded, DEC_ALLOC_MODE_0 );
00753               if ( rc != LDAP_SUCCESS ) return rc;
00754               (k->a.teletexString)->identifier.bv_val = peek_head;
00755               (k->a.teletexString)->identifier.bv_len = strLen;
00756        }
00757        else if( strncmp("printableString",peek_head,strlen("printableString")) == 0){
00758               (k->choiceId) = DIRECTORYSTRING_PRINTABLESTRING;
00759               rc =   GDecComponentPrintableString (mem_op, b, (&k->a.printableString), bytesDecoded, DEC_ALLOC_MODE_0 );
00760               if ( rc != LDAP_SUCCESS ) return rc;
00761               (k->a.printableString)->identifier.bv_val = peek_head;
00762               (k->a.printableString)->identifier.bv_len = strLen;
00763        }
00764        else if( strncmp("universalString",peek_head,strlen("universalString")) == 0){
00765               (k->choiceId) = DIRECTORYSTRING_UNIVERSALSTRING;
00766               rc =   GDecComponentUniversalString (mem_op, b, (&k->a.universalString), bytesDecoded, DEC_ALLOC_MODE_0 );
00767               if ( rc != LDAP_SUCCESS ) return rc;
00768               (k->a.universalString)->identifier.bv_val = peek_head;
00769               (k->a.universalString)->identifier.bv_len = strLen;
00770        }
00771        else if( strncmp("utf8String",peek_head,strlen("utf8String")) == 0){
00772               (k->choiceId) = DIRECTORYSTRING_UTF8STRING;
00773               rc =   GDecComponentUTF8String (mem_op, b, (&k->a.utf8String), bytesDecoded, DEC_ALLOC_MODE_0 );
00774               if ( rc != LDAP_SUCCESS ) return rc;
00775               (k->a.utf8String)->identifier.bv_val = peek_head;
00776               (k->a.utf8String)->identifier.bv_len = strLen;
00777        }
00778        else if( strncmp("bmpString",peek_head,strlen("bmpString")) == 0){
00779               (k->choiceId) = DIRECTORYSTRING_BMPSTRING;
00780               rc =   GDecComponentBMPString (mem_op, b, (&k->a.bmpString), bytesDecoded, DEC_ALLOC_MODE_0 );
00781               if ( rc != LDAP_SUCCESS ) return rc;
00782               (k->a.bmpString)->identifier.bv_val = peek_head;
00783               (k->a.bmpString)->identifier.bv_len = strLen;
00784        }
00785        else {
00786               Asn1Error("Undefined Identifier");
00787               return LDAP_PROTOCOL_ERROR;
00788        }
00789        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
00790        *v = t = (ComponentDirectoryString*) CompAlloc( mem_op, sizeof(ComponentDirectoryString) );
00791        if ( !t ) return -1;
00792        *t = *k;
00793        }
00794        t->syntax = (Syntax*)NULL;
00795        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
00796        if ( !t->comp_desc ) {
00797               free ( t );
00798               return -1;
00799        }
00800        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentDirectoryString ;
00801        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentDirectoryString ;
00802        t->comp_desc->cd_free = (comp_free_func*)NULL;
00803        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentDirectoryString;
00804        t->comp_desc->cd_type = ASN_COMPOSITE;
00805        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
00806        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentDirectoryString;
00807        return LDAP_SUCCESS;
00808 }  /* GDecDirectoryStringContent */
00809 
00810 
00811 int
00812 MatchingComponentEDIPartyName ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
00813        int rc;
00814        MatchingRule* mr;
00815 
00816        if ( oid ) {
00817               mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
00818               if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
00819        }
00820 
00821        rc = 1;
00822        if(COMPONENTNOT_NULL( ((ComponentEDIPartyName*)csi_attr)->nameAssigner ) ) {
00823        rc =   MatchingComponentDirectoryString ( oid, (ComponentSyntaxInfo*)((ComponentEDIPartyName*)csi_attr)->nameAssigner, (ComponentSyntaxInfo*)((ComponentEDIPartyName*)csi_assert)->nameAssigner );
00824        if ( rc != LDAP_COMPARE_TRUE )
00825               return rc;
00826        }
00827        rc =   MatchingComponentDirectoryString ( oid, (ComponentSyntaxInfo*)((ComponentEDIPartyName*)csi_attr)->partyName, (ComponentSyntaxInfo*)((ComponentEDIPartyName*)csi_assert)->partyName );
00828        if ( rc != LDAP_COMPARE_TRUE )
00829               return rc;
00830        return LDAP_COMPARE_TRUE;
00831 }  /* BMatchingComponentEDIPartyName */
00832 
00833 void*
00834 ExtractingComponentEDIPartyName ( void* mem_op, ComponentReference* cr, ComponentEDIPartyName *comp )
00835 {
00836 
00837        if ( ( comp->nameAssigner->identifier.bv_val && strncmp(comp->nameAssigner->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->nameAssigner->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
00838               if ( cr->cr_curr->ci_next == NULL )
00839                      return comp->nameAssigner;
00840               else {
00841                      cr->cr_curr = cr->cr_curr->ci_next;
00842                      return        ExtractingComponentDirectoryString ( mem_op, cr, comp->nameAssigner );
00843               }
00844        }
00845        if ( ( comp->partyName->identifier.bv_val && strncmp(comp->partyName->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->partyName->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
00846               if ( cr->cr_curr->ci_next == NULL )
00847                      return comp->partyName;
00848               else {
00849                      cr->cr_curr = cr->cr_curr->ci_next;
00850                      return        ExtractingComponentDirectoryString ( mem_op, cr, comp->partyName );
00851               }
00852        }
00853        return NULL;
00854 }  /* ExtractingComponentEDIPartyName */
00855 
00856 int
00857 BDecComponentEDIPartyName PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
00858 void* mem_op _AND_
00859 GenBuf * b _AND_
00860 AsnTag tagId0 _AND_
00861 AsnLen elmtLen0 _AND_
00862 ComponentEDIPartyName **v _AND_
00863 AsnLen *bytesDecoded _AND_
00864 int mode)
00865 {
00866        int seqDone = FALSE;
00867        AsnLen totalElmtsLen1 = 0;
00868        AsnLen elmtLen1;
00869        AsnTag tagId1;
00870        int mandatoryElmtCount1 = 0;
00871        AsnLen totalElmtsLen2 = 0;
00872        AsnLen elmtLen2;
00873        AsnTag tagId2;
00874        AsnLen totalElmtsLen3 = 0;
00875        AsnLen elmtLen3;
00876        AsnTag tagId3;
00877        int old_mode = mode;
00878        int rc;
00879        ComponentEDIPartyName *k, *t, c_temp;
00880 
00881 
00882        if ( !(mode & DEC_ALLOC_MODE_1) ) {
00883               memset(&c_temp,0,sizeof(c_temp));
00884                k = &c_temp;
00885        } else
00886                k = t = *v;
00887        mode = DEC_ALLOC_MODE_2;
00888     tagId1 = BDecTag (b, &totalElmtsLen1 );
00889 
00890     if (((tagId1 == MAKE_TAG_ID (CNTX, CONS, 0))))
00891     {
00892     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
00893               rc =     tagId2 = BDecTag (b, &totalElmtsLen1 );
00894     elmtLen2 = BDecLen (b, &totalElmtsLen1 );
00895        BDecComponentDirectoryString (mem_op, b, tagId2, elmtLen2, (&k->nameAssigner), &totalElmtsLen1, mode);
00896     if (elmtLen1 == INDEFINITE_LEN)
00897         BDecEoc(b, &totalElmtsLen1 );
00898               if ( rc != LDAP_SUCCESS ) return rc;
00899               (k->nameAssigner)->identifier.bv_val = (k->nameAssigner)->id_buf;
00900               (k->nameAssigner)->identifier.bv_len = strlen("nameAssigner");
00901               strcpy( (k->nameAssigner)->identifier.bv_val, "nameAssigner");
00902        if (elmtLen1 == INDEFINITE_LEN)
00903         BDecEoc (b, &totalElmtsLen1 );
00904     tagId1 = BDecTag (b, &totalElmtsLen1);
00905     }
00906 
00907 
00908     if (((tagId1 == MAKE_TAG_ID (CNTX, CONS, 1))))
00909     {
00910     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
00911               rc =     tagId2 = BDecTag (b, &totalElmtsLen1 );
00912     elmtLen2 = BDecLen (b, &totalElmtsLen1 );
00913        BDecComponentDirectoryString (mem_op, b, tagId2, elmtLen2, (&k->partyName), &totalElmtsLen1, mode);
00914     if (elmtLen1 == INDEFINITE_LEN)
00915         BDecEoc(b, &totalElmtsLen1 );
00916               if ( rc != LDAP_SUCCESS ) return rc;
00917               (k->partyName)->identifier.bv_val = (k->partyName)->id_buf;
00918               (k->partyName)->identifier.bv_len = strlen("partyName");
00919               strcpy( (k->partyName)->identifier.bv_val, "partyName");
00920        if (elmtLen1 == INDEFINITE_LEN)
00921         BDecEoc (b, &totalElmtsLen1 );
00922         seqDone = TRUE;
00923         if (elmtLen0 == INDEFINITE_LEN)
00924             BDecEoc (b, &totalElmtsLen1 );
00925         else if (totalElmtsLen1 != elmtLen0)
00926         return -1;
00927 
00928     }
00929     else
00930         return -1;
00931 
00932 
00933 
00934     if (!seqDone)
00935         return -1;
00936 
00937        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
00938        *v = t = (ComponentEDIPartyName*) CompAlloc( mem_op, sizeof(ComponentEDIPartyName) );
00939        if ( !t ) return -1;
00940        *t = *k;
00941        }
00942        t->syntax = (Syntax*)NULL;
00943        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
00944        if ( !t->comp_desc ) {
00945               free ( t );
00946               return -1;
00947        }
00948        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentEDIPartyName ;
00949        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentEDIPartyName ;
00950        t->comp_desc->cd_free = (comp_free_func*)NULL;
00951        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentEDIPartyName;
00952        t->comp_desc->cd_type = ASN_COMPOSITE;
00953        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
00954        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentEDIPartyName;
00955     (*bytesDecoded) += totalElmtsLen1;
00956        return LDAP_SUCCESS;
00957 }  /* BDecEDIPartyName*/
00958 
00959 int
00960 GDecComponentEDIPartyName PARAMS (( mem_op,b, v, bytesDecoded, mode),
00961 void* mem_op _AND_
00962 GenBuf * b _AND_
00963 ComponentEDIPartyName **v _AND_
00964 AsnLen *bytesDecoded _AND_
00965 int mode)
00966 {
00967        char* peek_head,*peek_head2;
00968        int i, strLen,strLen2, rc, old_mode = mode;
00969        ComponentEDIPartyName *k,*t, c_temp;
00970 
00971 
00972        if ( !(mode & DEC_ALLOC_MODE_1) ) {
00973               memset(&c_temp,0,sizeof(c_temp));
00974                k = &c_temp;
00975        } else
00976                k = t = *v;
00977        mode = DEC_ALLOC_MODE_2;
00978        *bytesDecoded = 0;
00979        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00980               Asn1Error("Error during Reading { in encoded data");
00981               return LDAP_PROTOCOL_ERROR;
00982        }
00983        if(*peek_head != '{'){
00984               Asn1Error("Missing { in encoded data");
00985               return LDAP_PROTOCOL_ERROR;
00986        }
00987 
00988        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00989               Asn1Error("Error during Reading identifier");
00990               return LDAP_PROTOCOL_ERROR;
00991        }
00992        if ( strncmp( peek_head, "nameAssigner", strlen("nameAssigner") ) == 0 ) {
00993               rc =   GDecComponentDirectoryString (mem_op, b, (&k->nameAssigner), bytesDecoded, mode);
00994               if ( rc != LDAP_SUCCESS ) return rc;
00995        ( k->nameAssigner)->identifier.bv_val = peek_head;
00996        ( k->nameAssigner)->identifier.bv_len = strLen;
00997        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
00998               Asn1Error("Error during Reading , ");
00999               return LDAP_PROTOCOL_ERROR;
01000        }
01001        if(*peek_head != ','){
01002               Asn1Error("Missing , in encoding");
01003               return LDAP_PROTOCOL_ERROR;
01004        }
01005        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
01006          Asn1Error("Error during Reading identifier");
01007               return LDAP_PROTOCOL_ERROR;
01008        }
01009        }
01010        if ( strncmp( peek_head, "partyName", strlen("partyName") ) == 0 ) {
01011               rc =   GDecComponentDirectoryString (mem_op, b, (&k->partyName), bytesDecoded, mode);
01012               if ( rc != LDAP_SUCCESS ) return rc;
01013        ( k->partyName)->identifier.bv_val = peek_head;
01014        ( k->partyName)->identifier.bv_len = strLen;
01015        }
01016        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
01017               Asn1Error("Error during Reading } in encoding");
01018               return LDAP_PROTOCOL_ERROR;
01019        }
01020        if(*peek_head != '}'){
01021               Asn1Error("Missing } in encoding");
01022               return LDAP_PROTOCOL_ERROR;
01023        }
01024        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
01025        *v = t = (ComponentEDIPartyName*) CompAlloc( mem_op, sizeof(ComponentEDIPartyName) );
01026        if ( !t ) return -1;
01027        *t = *k;
01028        }
01029        t->syntax = (Syntax*)NULL;
01030        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
01031        if ( !t->comp_desc ) {
01032               free ( t );
01033               return -1;
01034        }
01035        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentEDIPartyName ;
01036        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentEDIPartyName ;
01037        t->comp_desc->cd_free = (comp_free_func*)NULL;
01038        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentEDIPartyName;
01039        t->comp_desc->cd_type = ASN_COMPOSITE;
01040        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
01041        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentEDIPartyName;
01042        return LDAP_SUCCESS;
01043 }  /* GDecEDIPartyName*/
01044 
01045 
01046 
01047 int
01048 MatchingComponentGeneralName ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
01049        int rc;
01050        MatchingRule* mr;
01051        ComponentGeneralName *v1, *v2;
01052 
01053 
01054        v1 = (ComponentGeneralName*)csi_attr;
01055        v2 = (ComponentGeneralName*)csi_assert;
01056        if ( oid ) {
01057               mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
01058               if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
01059        }
01060 
01061        if( (v1->choiceId != v2->choiceId ) )
01062               return LDAP_COMPARE_FALSE;
01063        switch( v1->choiceId )
01064        {
01065           case GENERALNAME_OTHERNAME :
01066               rc =   MatchingComponentOtherName ( oid, (ComponentSyntaxInfo*)(v1->a.otherName), (ComponentSyntaxInfo*)(v2->a.otherName) );
01067               break;
01068           case GENERALNAME_RFC822NAME :
01069               rc =   MatchingComponentIA5String ( oid, (ComponentSyntaxInfo*)(v1->a.rfc822Name), (ComponentSyntaxInfo*)(v2->a.rfc822Name) );
01070               break;
01071           case GENERALNAME_DNSNAME :
01072               rc =   MatchingComponentIA5String ( oid, (ComponentSyntaxInfo*)(v1->a.dNSName), (ComponentSyntaxInfo*)(v2->a.dNSName) );
01073               break;
01074           case GENERALNAME_X400ADDRESS :
01075               rc =   MatchingComponentORAddress ( oid, (ComponentSyntaxInfo*)(v1->a.x400Address), (ComponentSyntaxInfo*)(v2->a.x400Address) );
01076               break;
01077           case GENERALNAME_DIRECTORYNAME :
01078               rc =   MatchingComponentName ( oid, (ComponentSyntaxInfo*)(v1->a.directoryName), (ComponentSyntaxInfo*)(v2->a.directoryName) );
01079               break;
01080           case GENERALNAME_EDIPARTYNAME :
01081               rc =   MatchingComponentEDIPartyName ( oid, (ComponentSyntaxInfo*)(v1->a.ediPartyName), (ComponentSyntaxInfo*)(v2->a.ediPartyName) );
01082               break;
01083           case GENERALNAME_UNIFORMRESOURCEIDENTIFIER :
01084               rc =   MatchingComponentIA5String ( oid, (ComponentSyntaxInfo*)(v1->a.uniformResourceIdentifier), (ComponentSyntaxInfo*)(v2->a.uniformResourceIdentifier) );
01085               break;
01086           case GENERALNAME_IPADDRESS :
01087               rc =   MatchingComponentOcts ( oid, (ComponentSyntaxInfo*)(v1->a.iPAddress), (ComponentSyntaxInfo*)(v2->a.iPAddress) );
01088               break;
01089           case GENERALNAME_REGISTEREDID :
01090               rc =   MatchingComponentOid ( oid, (ComponentSyntaxInfo*)(v1->a.registeredID), (ComponentSyntaxInfo*)(v2->a.registeredID) );
01091               break;
01092        default : 
01093                return LDAP_PROTOCOL_ERROR;
01094        }
01095        return rc;
01096 }  /* BMatchingComponentGeneralNameContent */
01097 
01098 void*
01099 ExtractingComponentGeneralName ( void* mem_op, ComponentReference* cr, ComponentGeneralName *comp )
01100 {
01101 
01102 
01103        if( (comp->choiceId) ==  GENERALNAME_OTHERNAME &&
01104                (( comp->a.otherName->identifier.bv_val && strncmp(comp->a.otherName->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) ||
01105                ( strncmp(comp->a.otherName->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) {
01106               if ( cr->cr_curr->ci_next == NULL )
01107                      return (comp->a.otherName);
01108               else {
01109                      cr->cr_curr = cr->cr_curr->ci_next;
01110                      return        ExtractingComponentOtherName ( mem_op, cr, (comp->a.otherName) );
01111               };
01112        }
01113        if( (comp->choiceId) ==  GENERALNAME_RFC822NAME &&
01114                (( comp->a.rfc822Name->identifier.bv_val && strncmp(comp->a.rfc822Name->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) ||
01115                ( strncmp(comp->a.rfc822Name->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) {
01116               if ( cr->cr_curr->ci_next == NULL )
01117                      return (comp->a.rfc822Name);
01118               else {
01119                      cr->cr_curr = cr->cr_curr->ci_next;
01120                      return        ExtractingComponentIA5String ( mem_op, cr, (comp->a.rfc822Name) );
01121               };
01122        }
01123        if( (comp->choiceId) ==  GENERALNAME_DNSNAME &&
01124                (( comp->a.dNSName->identifier.bv_val && strncmp(comp->a.dNSName->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) ||
01125                ( strncmp(comp->a.dNSName->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) {
01126               if ( cr->cr_curr->ci_next == NULL )
01127                      return (comp->a.dNSName);
01128               else {
01129                      cr->cr_curr = cr->cr_curr->ci_next;
01130                      return        ExtractingComponentIA5String ( mem_op, cr, (comp->a.dNSName) );
01131               };
01132        }
01133        if( (comp->choiceId) ==  GENERALNAME_X400ADDRESS &&
01134                (( comp->a.x400Address->identifier.bv_val && strncmp(comp->a.x400Address->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) ||
01135                ( strncmp(comp->a.x400Address->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) {
01136               if ( cr->cr_curr->ci_next == NULL )
01137                      return (comp->a.x400Address);
01138               else {
01139                      cr->cr_curr = cr->cr_curr->ci_next;
01140                      return        ExtractingComponentORAddress ( mem_op, cr, (comp->a.x400Address) );
01141               };
01142        }
01143        if( (comp->choiceId) ==  GENERALNAME_DIRECTORYNAME &&
01144                (( comp->a.directoryName->identifier.bv_val && strncmp(comp->a.directoryName->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) ||
01145                ( strncmp(comp->a.directoryName->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) {
01146               if ( cr->cr_curr->ci_next == NULL )
01147                      return (comp->a.directoryName);
01148               else {
01149                      cr->cr_curr = cr->cr_curr->ci_next;
01150                      return        ExtractingComponentName ( mem_op, cr, (comp->a.directoryName) );
01151               };
01152        }
01153        if( (comp->choiceId) ==  GENERALNAME_EDIPARTYNAME &&
01154                (( comp->a.ediPartyName->identifier.bv_val && strncmp(comp->a.ediPartyName->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) ||
01155                ( strncmp(comp->a.ediPartyName->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) {
01156               if ( cr->cr_curr->ci_next == NULL )
01157                      return (comp->a.ediPartyName);
01158               else {
01159                      cr->cr_curr = cr->cr_curr->ci_next;
01160                      return        ExtractingComponentEDIPartyName ( mem_op, cr, (comp->a.ediPartyName) );
01161               };
01162        }
01163        if( (comp->choiceId) ==  GENERALNAME_UNIFORMRESOURCEIDENTIFIER &&
01164                (( comp->a.uniformResourceIdentifier->identifier.bv_val && strncmp(comp->a.uniformResourceIdentifier->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) ||
01165                ( strncmp(comp->a.uniformResourceIdentifier->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) {
01166               if ( cr->cr_curr->ci_next == NULL )
01167                      return (comp->a.uniformResourceIdentifier);
01168               else {
01169                      cr->cr_curr = cr->cr_curr->ci_next;
01170                      return        ExtractingComponentIA5String ( mem_op, cr, (comp->a.uniformResourceIdentifier) );
01171               };
01172        }
01173        if( (comp->choiceId) ==  GENERALNAME_IPADDRESS &&
01174                (( comp->a.iPAddress->identifier.bv_val && strncmp(comp->a.iPAddress->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) ||
01175                ( strncmp(comp->a.iPAddress->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) {
01176               if ( cr->cr_curr->ci_next == NULL )
01177                      return (comp->a.iPAddress);
01178               else {
01179                      cr->cr_curr = cr->cr_curr->ci_next;
01180                      return        ExtractingComponentOcts ( mem_op, cr, (comp->a.iPAddress) );
01181               };
01182        }
01183        if( (comp->choiceId) ==  GENERALNAME_REGISTEREDID &&
01184                (( comp->a.registeredID->identifier.bv_val && strncmp(comp->a.registeredID->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) ||
01185                ( strncmp(comp->a.registeredID->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) {
01186               if ( cr->cr_curr->ci_next == NULL )
01187                      return (comp->a.registeredID);
01188               else {
01189                      cr->cr_curr = cr->cr_curr->ci_next;
01190                      return        ExtractingComponentOid ( mem_op, cr, (comp->a.registeredID) );
01191               };
01192        }
01193        return NULL;
01194 }  /* ExtractingComponentGeneralName */
01195 
01196 int
01197 BDecComponentGeneralName PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
01198 void* mem_op _AND_
01199 GenBuf * b _AND_
01200 AsnTag tagId0 _AND_
01201 AsnLen elmtLen0 _AND_
01202 ComponentGeneralName **v _AND_
01203 AsnLen *bytesDecoded _AND_
01204 int mode)
01205 {
01206        int seqDone = FALSE;
01207        AsnLen totalElmtsLen1 = 0;
01208        AsnLen elmtLen1;
01209        AsnTag tagId1;
01210        int mandatoryElmtCount1 = 0;
01211        AsnLen totalElmtsLen2 = 0;
01212        AsnLen elmtLen2;
01213        AsnTag tagId2;
01214        AsnLen totalElmtsLen3 = 0;
01215        AsnLen elmtLen3;
01216        AsnTag tagId3;
01217        int old_mode = mode;
01218        int rc;
01219        ComponentGeneralName *k, *t, c_temp;
01220 
01221 
01222        if ( !(mode & DEC_ALLOC_MODE_1) ) {
01223               memset(&c_temp,0,sizeof(c_temp));
01224                k = &c_temp;
01225        } else
01226                k = t = *v;
01227        mode = DEC_ALLOC_MODE_2;
01228     switch (tagId0)
01229     {
01230        case MAKE_TAG_ID (CNTX, CONS, 0):
01231 if (BDecTag (b, &totalElmtsLen1 ) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
01232     {
01233          Asn1Error ("Unexpected Tag\n");
01234          return -1;
01235     }
01236 
01237     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
01238         (k->choiceId) = GENERALNAME_OTHERNAME;
01239               rc =   BDecComponentOtherName (mem_op, b, tagId1, elmtLen1, (&k->a.otherName), &totalElmtsLen1, mode);
01240               if ( rc != LDAP_SUCCESS ) return rc;
01241               (k->a.otherName)->identifier.bv_val = (k->a.otherName)->id_buf;
01242               (k->a.otherName)->identifier.bv_len = strlen("otherName");
01243               strcpy( (k->a.otherName)->identifier.bv_val, "otherName");
01244        if (elmtLen0 == INDEFINITE_LEN)
01245         BDecEoc (b, &totalElmtsLen1 );
01246     break;
01247 
01248        case MAKE_TAG_ID (CNTX, CONS, 1):
01249     tagId1 = BDecTag (b, &totalElmtsLen1 );
01250 if ((tagId1 != MAKE_TAG_ID (UNIV, PRIM, IA5STRING_TAG_CODE)) &&
01251    (tagId1 != MAKE_TAG_ID (UNIV, CONS, IA5STRING_TAG_CODE)))
01252     {
01253          Asn1Error ("Unexpected Tag\n");
01254          return -1;
01255     }
01256 
01257     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
01258         (k->choiceId) = GENERALNAME_RFC822NAME;
01259               rc =   BDecComponentIA5String (mem_op, b, tagId1, elmtLen1, (&k->a.rfc822Name), &totalElmtsLen1, DEC_ALLOC_MODE_0 );
01260               if ( rc != LDAP_SUCCESS ) return rc;
01261               (k->a.rfc822Name)->identifier.bv_val = (k->a.rfc822Name)->id_buf;
01262               (k->a.rfc822Name)->identifier.bv_len = strlen("rfc822Name");
01263               strcpy( (k->a.rfc822Name)->identifier.bv_val, "rfc822Name");
01264        if (elmtLen0 == INDEFINITE_LEN)
01265         BDecEoc (b, &totalElmtsLen1 );
01266     break;
01267 
01268        case MAKE_TAG_ID (CNTX, CONS, 2):
01269     tagId1 = BDecTag (b, &totalElmtsLen1 );
01270 if ((tagId1 != MAKE_TAG_ID (UNIV, PRIM, IA5STRING_TAG_CODE)) &&
01271    (tagId1 != MAKE_TAG_ID (UNIV, CONS, IA5STRING_TAG_CODE)))
01272     {
01273          Asn1Error ("Unexpected Tag\n");
01274          return -1;
01275     }
01276 
01277     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
01278         (k->choiceId) = GENERALNAME_DNSNAME;
01279               rc =   BDecComponentIA5String (mem_op, b, tagId1, elmtLen1, (&k->a.dNSName), &totalElmtsLen1, DEC_ALLOC_MODE_0 );
01280               if ( rc != LDAP_SUCCESS ) return rc;
01281               (k->a.dNSName)->identifier.bv_val = (k->a.dNSName)->id_buf;
01282               (k->a.dNSName)->identifier.bv_len = strlen("dNSName");
01283               strcpy( (k->a.dNSName)->identifier.bv_val, "dNSName");
01284        if (elmtLen0 == INDEFINITE_LEN)
01285         BDecEoc (b, &totalElmtsLen1 );
01286     break;
01287 
01288        case MAKE_TAG_ID (CNTX, CONS, 3):
01289 if (BDecTag (b, &totalElmtsLen1 ) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
01290     {
01291          Asn1Error ("Unexpected Tag\n");
01292          return -1;
01293     }
01294 
01295     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
01296         (k->choiceId) = GENERALNAME_X400ADDRESS;
01297               rc =   BDecComponentORAddress (mem_op, b, tagId1, elmtLen1, (&k->a.x400Address), &totalElmtsLen1, mode);
01298               if ( rc != LDAP_SUCCESS ) return rc;
01299               (k->a.x400Address)->identifier.bv_val = (k->a.x400Address)->id_buf;
01300               (k->a.x400Address)->identifier.bv_len = strlen("x400Address");
01301               strcpy( (k->a.x400Address)->identifier.bv_val, "x400Address");
01302        if (elmtLen0 == INDEFINITE_LEN)
01303         BDecEoc (b, &totalElmtsLen1 );
01304     break;
01305 
01306        case MAKE_TAG_ID (CNTX, CONS, 4):
01307         (k->choiceId) = GENERALNAME_DIRECTORYNAME;
01308               tagId1 = BDecTag (b, &totalElmtsLen1 );
01309     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
01310        rc = BDecComponentName (mem_op, b, tagId1, elmtLen1, (&k->a.directoryName), &totalElmtsLen1, mode);
01311     if (elmtLen0 == INDEFINITE_LEN)
01312         BDecEoc(b, &totalElmtsLen1 );
01313               if ( rc != LDAP_SUCCESS ) return rc;
01314               (k->a.directoryName)->identifier.bv_val = (k->a.directoryName)->id_buf;
01315               (k->a.directoryName)->identifier.bv_len = strlen("directoryName");
01316               strcpy( (k->a.directoryName)->identifier.bv_val, "directoryName");
01317        if (elmtLen0 == INDEFINITE_LEN)
01318         BDecEoc (b, &totalElmtsLen1 );
01319     break;
01320 
01321        case MAKE_TAG_ID (CNTX, CONS, 5):
01322 if (BDecTag (b, &totalElmtsLen1 ) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
01323     {
01324          Asn1Error ("Unexpected Tag\n");
01325          return -1;
01326     }
01327 
01328     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
01329         (k->choiceId) = GENERALNAME_EDIPARTYNAME;
01330               rc =   BDecComponentEDIPartyName (mem_op, b, tagId1, elmtLen1, (&k->a.ediPartyName), &totalElmtsLen1, mode);
01331               if ( rc != LDAP_SUCCESS ) return rc;
01332               (k->a.ediPartyName)->identifier.bv_val = (k->a.ediPartyName)->id_buf;
01333               (k->a.ediPartyName)->identifier.bv_len = strlen("ediPartyName");
01334               strcpy( (k->a.ediPartyName)->identifier.bv_val, "ediPartyName");
01335        if (elmtLen0 == INDEFINITE_LEN)
01336         BDecEoc (b, &totalElmtsLen1 );
01337     break;
01338 
01339        case MAKE_TAG_ID (CNTX, CONS, 6):
01340     tagId1 = BDecTag (b, &totalElmtsLen1 );
01341 if ((tagId1 != MAKE_TAG_ID (UNIV, PRIM, IA5STRING_TAG_CODE)) &&
01342    (tagId1 != MAKE_TAG_ID (UNIV, CONS, IA5STRING_TAG_CODE)))
01343     {
01344          Asn1Error ("Unexpected Tag\n");
01345          return -1;
01346     }
01347 
01348     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
01349         (k->choiceId) = GENERALNAME_UNIFORMRESOURCEIDENTIFIER;
01350               rc =   BDecComponentIA5String (mem_op, b, tagId1, elmtLen1, (&k->a.uniformResourceIdentifier), &totalElmtsLen1, DEC_ALLOC_MODE_0 );
01351               if ( rc != LDAP_SUCCESS ) return rc;
01352               (k->a.uniformResourceIdentifier)->identifier.bv_val = (k->a.uniformResourceIdentifier)->id_buf;
01353               (k->a.uniformResourceIdentifier)->identifier.bv_len = strlen("uniformResourceIdentifier");
01354               strcpy( (k->a.uniformResourceIdentifier)->identifier.bv_val, "uniformResourceIdentifier");
01355        if (elmtLen0 == INDEFINITE_LEN)
01356         BDecEoc (b, &totalElmtsLen1 );
01357     break;
01358 
01359        case MAKE_TAG_ID (CNTX, CONS, 7):
01360     tagId1 = BDecTag (b, &totalElmtsLen1 );
01361 if ((tagId1 != MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) &&
01362    (tagId1 != MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE)))
01363     {
01364          Asn1Error ("Unexpected Tag\n");
01365          return -1;
01366     }
01367 
01368     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
01369         (k->choiceId) = GENERALNAME_IPADDRESS;
01370               rc =   BDecComponentOcts (mem_op, b, tagId1, elmtLen1, (&k->a.iPAddress), &totalElmtsLen1, DEC_ALLOC_MODE_0 );
01371               if ( rc != LDAP_SUCCESS ) return rc;
01372               (k->a.iPAddress)->identifier.bv_val = (k->a.iPAddress)->id_buf;
01373               (k->a.iPAddress)->identifier.bv_len = strlen("iPAddress");
01374               strcpy( (k->a.iPAddress)->identifier.bv_val, "iPAddress");
01375        if (elmtLen0 == INDEFINITE_LEN)
01376         BDecEoc (b, &totalElmtsLen1 );
01377     break;
01378 
01379        case MAKE_TAG_ID (CNTX, CONS, 8):
01380 if (BDecTag (b, &totalElmtsLen1 ) != MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))
01381     {
01382          Asn1Error ("Unexpected Tag\n");
01383          return -1;
01384     }
01385 
01386     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
01387         (k->choiceId) = GENERALNAME_REGISTEREDID;
01388               rc =   BDecComponentOid (mem_op, b, tagId1, elmtLen1, (&k->a.registeredID), &totalElmtsLen1, DEC_ALLOC_MODE_0 );
01389               if ( rc != LDAP_SUCCESS ) return rc;
01390               (k->a.registeredID)->identifier.bv_val = (k->a.registeredID)->id_buf;
01391               (k->a.registeredID)->identifier.bv_len = strlen("registeredID");
01392               strcpy( (k->a.registeredID)->identifier.bv_val, "registeredID");
01393        if (elmtLen0 == INDEFINITE_LEN)
01394         BDecEoc (b, &totalElmtsLen1 );
01395     break;
01396 
01397     default:
01398         Asn1Error ("ERROR - unexpected tag in CHOICE\n");
01399         return -1;
01400         break;
01401     } /* end switch */
01402        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
01403        *v = t = (ComponentGeneralName*) CompAlloc( mem_op, sizeof(ComponentGeneralName) );
01404        if ( !t ) return -1;
01405        *t = *k;
01406        }
01407        t->syntax = (Syntax*)NULL;
01408        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
01409        if ( !t->comp_desc ) {
01410               free ( t );
01411               return -1;
01412        }
01413        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentGeneralName ;
01414        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentGeneralName ;
01415        t->comp_desc->cd_free = (comp_free_func*)NULL;
01416        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentGeneralName;
01417        t->comp_desc->cd_type = ASN_COMPOSITE;
01418        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
01419        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentGeneralName;
01420     (*bytesDecoded) += totalElmtsLen1;
01421        return LDAP_SUCCESS;
01422 }  /* BDecGeneralNameContent */
01423 
01424 int
01425 GDecComponentGeneralName PARAMS (( mem_op,b, v, bytesDecoded, mode),
01426 void* mem_op _AND_
01427 GenBuf * b _AND_
01428 ComponentGeneralName **v _AND_
01429 AsnLen *bytesDecoded _AND_
01430 int mode)
01431 {
01432        char* peek_head,*peek_head2;
01433        int i, strLen,strLen2, rc, old_mode = mode;
01434        ComponentGeneralName *k,*t, c_temp;
01435 
01436 
01437        if ( !(mode & DEC_ALLOC_MODE_1) ) {
01438               memset(&c_temp,0,sizeof(c_temp));
01439                k = &c_temp;
01440        } else
01441                k = t = *v;
01442        mode = DEC_ALLOC_MODE_2;
01443        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
01444               Asn1Error("Error during Reading identifier");
01445               return LDAP_PROTOCOL_ERROR;
01446        }
01447        if( !(strLen2 = LocateNextGSERToken(mem_op,b,&peek_head2,GSER_NO_COPY)) ){
01448               Asn1Error("Error during Reading identifier");
01449               return LDAP_PROTOCOL_ERROR;
01450        }
01451        if(*peek_head2 != ':'){
01452               Asn1Error("Missing : in encoded data");
01453               return LDAP_PROTOCOL_ERROR;
01454        }
01455        if( strncmp("otherName",peek_head, strlen("otherName")) == 0){
01456               (k->choiceId) = GENERALNAME_OTHERNAME;
01457               rc =   GDecComponentOtherName (mem_op, b, (&k->a.otherName), bytesDecoded, mode);
01458               if ( rc != LDAP_SUCCESS ) return rc;
01459               (k->a.otherName)->identifier.bv_val = peek_head;
01460               (k->a.otherName)->identifier.bv_len = strLen;
01461        }
01462        else if( strncmp("rfc822Name",peek_head,strlen("rfc822Name")) == 0){
01463               (k->choiceId) = GENERALNAME_RFC822NAME;
01464               rc =   GDecComponentIA5String (mem_op, b, (&k->a.rfc822Name), bytesDecoded, DEC_ALLOC_MODE_0 );
01465               if ( rc != LDAP_SUCCESS ) return rc;
01466               (k->a.rfc822Name)->identifier.bv_val = peek_head;
01467               (k->a.rfc822Name)->identifier.bv_len = strLen;
01468        }
01469        else if( strncmp("dNSName",peek_head,strlen("dNSName")) == 0){
01470               (k->choiceId) = GENERALNAME_DNSNAME;
01471               rc =   GDecComponentIA5String (mem_op, b, (&k->a.dNSName), bytesDecoded, DEC_ALLOC_MODE_0 );
01472               if ( rc != LDAP_SUCCESS ) return rc;
01473               (k->a.dNSName)->identifier.bv_val = peek_head;
01474               (k->a.dNSName)->identifier.bv_len = strLen;
01475        }
01476        else if( strncmp("x400Address",peek_head,strlen("x400Address")) == 0){
01477               (k->choiceId) = GENERALNAME_X400ADDRESS;
01478               rc =   GDecComponentORAddress (mem_op, b, (&k->a.x400Address), bytesDecoded, mode);
01479               if ( rc != LDAP_SUCCESS ) return rc;
01480               (k->a.x400Address)->identifier.bv_val = peek_head;
01481               (k->a.x400Address)->identifier.bv_len = strLen;
01482        }
01483        else if( strncmp("directoryName",peek_head,strlen("directoryName")) == 0){
01484               (k->choiceId) = GENERALNAME_DIRECTORYNAME;
01485               rc =   GDecComponentName (mem_op, b, (&k->a.directoryName), bytesDecoded, mode);
01486               if ( rc != LDAP_SUCCESS ) return rc;
01487               (k->a.directoryName)->identifier.bv_val = peek_head;
01488               (k->a.directoryName)->identifier.bv_len = strLen;
01489        }
01490        else if( strncmp("ediPartyName",peek_head,strlen("ediPartyName")) == 0){
01491               (k->choiceId) = GENERALNAME_EDIPARTYNAME;
01492               rc =   GDecComponentEDIPartyName (mem_op, b, (&k->a.ediPartyName), bytesDecoded, mode);
01493               if ( rc != LDAP_SUCCESS ) return rc;
01494               (k->a.ediPartyName)->identifier.bv_val = peek_head;
01495               (k->a.ediPartyName)->identifier.bv_len = strLen;
01496        }
01497        else if( strncmp("uniformResourceIdentifier",peek_head,strlen("uniformResourceIdentifier")) == 0){
01498               (k->choiceId) = GENERALNAME_UNIFORMRESOURCEIDENTIFIER;
01499               rc =   GDecComponentIA5String (mem_op, b, (&k->a.uniformResourceIdentifier), bytesDecoded, DEC_ALLOC_MODE_0 );
01500               if ( rc != LDAP_SUCCESS ) return rc;
01501               (k->a.uniformResourceIdentifier)->identifier.bv_val = peek_head;
01502               (k->a.uniformResourceIdentifier)->identifier.bv_len = strLen;
01503        }
01504        else if( strncmp("iPAddress",peek_head,strlen("iPAddress")) == 0){
01505               (k->choiceId) = GENERALNAME_IPADDRESS;
01506               rc =   GDecComponentOcts (mem_op, b, (&k->a.iPAddress), bytesDecoded, DEC_ALLOC_MODE_0 );
01507               if ( rc != LDAP_SUCCESS ) return rc;
01508               (k->a.iPAddress)->identifier.bv_val = peek_head;
01509               (k->a.iPAddress)->identifier.bv_len = strLen;
01510        }
01511        else if( strncmp("registeredID",peek_head,strlen("registeredID")) == 0){
01512               (k->choiceId) = GENERALNAME_REGISTEREDID;
01513               rc =   GDecComponentOid (mem_op, b, (&k->a.registeredID), bytesDecoded, DEC_ALLOC_MODE_0 );
01514               if ( rc != LDAP_SUCCESS ) return rc;
01515               (k->a.registeredID)->identifier.bv_val = peek_head;
01516               (k->a.registeredID)->identifier.bv_len = strLen;
01517        }
01518        else {
01519               Asn1Error("Undefined Identifier");
01520               return LDAP_PROTOCOL_ERROR;
01521        }
01522        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
01523        *v = t = (ComponentGeneralName*) CompAlloc( mem_op, sizeof(ComponentGeneralName) );
01524        if ( !t ) return -1;
01525        *t = *k;
01526        }
01527        t->syntax = (Syntax*)NULL;
01528        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
01529        if ( !t->comp_desc ) {
01530               free ( t );
01531               return -1;
01532        }
01533        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentGeneralName ;
01534        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentGeneralName ;
01535        t->comp_desc->cd_free = (comp_free_func*)NULL;
01536        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentGeneralName;
01537        t->comp_desc->cd_type = ASN_COMPOSITE;
01538        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
01539        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentGeneralName;
01540        return LDAP_SUCCESS;
01541 }  /* GDecGeneralNameContent */
01542 
01543 
01544 int
01545 MatchingComponentGeneralNames ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
01546        int rc;
01547        MatchingRule* mr;
01548        void* component1, *component2;
01549        AsnList *v1, *v2, t_list;
01550 
01551 
01552        if ( oid ) {
01553               mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
01554               if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
01555        }
01556 
01557        v1 = &((ComponentGeneralNames*)csi_attr)->comp_list;
01558        v2 = &((ComponentGeneralNames*)csi_assert)->comp_list;
01559        FOR_EACH_LIST_PAIR_ELMT(component1, component2, v1, v2)
01560        {
01561               if( MatchingComponentGeneralName(oid, (ComponentSyntaxInfo*)component1, (ComponentSyntaxInfo*)component2) == LDAP_COMPARE_FALSE) {
01562                      return LDAP_COMPARE_FALSE;
01563               }
01564        } /* end of for */
01565 
01566        AsnListFirst( v1 );
01567        AsnListFirst( v2 );
01568        if( (!component1 && component2) || (component1 && !component2))
01569               return LDAP_COMPARE_FALSE;
01570        else
01571               return LDAP_COMPARE_TRUE;
01572 }  /* BMatchingComponentGeneralNamesContent */
01573 
01574 void*
01575 ExtractingComponentGeneralNames ( void* mem_op, ComponentReference* cr, ComponentGeneralNames *comp )
01576 {
01577        int count = 0;
01578        int total;
01579        AsnList *v = &comp->comp_list;
01580        ComponentInt *k;
01581        ComponentGeneralName *component;
01582 
01583 
01584        switch ( cr->cr_curr->ci_type ) {
01585        case LDAP_COMPREF_FROM_BEGINNING :
01586               count = cr->cr_curr->ci_val.ci_from_beginning;
01587               FOR_EACH_LIST_ELMT( component , v ) {
01588                      if( --count == 0 ) {
01589                             if( cr->cr_curr->ci_next == NULL )
01590                                    return component;
01591                             else {
01592                                    cr->cr_curr = cr->cr_curr->ci_next;
01593                                    return        ExtractingComponentGeneralName ( mem_op, cr, component );
01594                             }
01595                      }
01596               }
01597               break;
01598        case LDAP_COMPREF_FROM_END :
01599               total = AsnListCount ( v );
01600               count = cr->cr_curr->ci_val.ci_from_end;
01601               count = total + count +1;
01602               FOR_EACH_LIST_ELMT ( component, v ) {
01603                      if( --count == 0 ) {
01604                             if( cr->cr_curr->ci_next == NULL ) 
01605                                    return component;
01606                             else {
01607                                    cr->cr_curr = cr->cr_curr->ci_next;
01608                                    return        ExtractingComponentGeneralName ( mem_op, cr, component );
01609                             }
01610                      }
01611               }
01612               break;
01613        case LDAP_COMPREF_ALL :
01614               return comp;
01615        case LDAP_COMPREF_COUNT :
01616               k = (ComponentInt*)CompAlloc( mem_op, sizeof(ComponentInt));
01617               k->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
01618               k->comp_desc->cd_tag = (-1);
01619               k->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentInt;
01620               k->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentInt;
01621               k->comp_desc->cd_extract_i = (extract_component_from_id_func*)NULL;
01622               k->comp_desc->cd_type = ASN_BASIC;
01623               k->comp_desc->cd_type_id = BASICTYPE_INTEGER;
01624               k->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentInt;
01625               k->value = AsnListCount(v);
01626               return k;
01627        default :
01628               return NULL;
01629        }
01630 }  /* ExtractingComponentGeneralNames */
01631 
01632 int
01633 BDecComponentGeneralNames PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
01634 void* mem_op _AND_
01635 GenBuf * b _AND_
01636 AsnTag tagId0 _AND_
01637 AsnLen elmtLen0 _AND_
01638 ComponentGeneralNames **v _AND_
01639 AsnLen *bytesDecoded _AND_
01640 int mode)
01641 {
01642        int seqDone = FALSE;
01643        AsnLen totalElmtsLen1 = 0;
01644        AsnLen elmtLen1;
01645        AsnTag tagId1;
01646        int mandatoryElmtCount1 = 0;
01647        int old_mode = mode;
01648        int rc;
01649        ComponentGeneralNames *k, *t, c_temp;
01650 
01651 
01652        if ( !(mode & DEC_ALLOC_MODE_1) ) {
01653               memset(&c_temp,0,sizeof(c_temp));
01654                k = &c_temp;
01655        } else
01656                k = t = *v;
01657        mode = DEC_ALLOC_MODE_2;
01658        AsnListInit(&k->comp_list,sizeof(ComponentGeneralName));
01659     for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);)
01660     {
01661         ComponentGeneralName **tmpVar;
01662     tagId1 = BDecTag (b, &totalElmtsLen1 );
01663 
01664     if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
01665     {
01666         BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
01667         break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/
01668     }
01669         elmtLen1 = BDecLen (b, &totalElmtsLen1);
01670     tmpVar = (ComponentGeneralName**) CompAsnListAppend (mem_op,&k->comp_list);
01671               rc =   BDecComponentGeneralName (mem_op, b, tagId1, elmtLen1, tmpVar, &totalElmtsLen1, mode);
01672               if ( rc != LDAP_SUCCESS ) return rc;
01673     } /* end of for */
01674 
01675        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
01676        *v = t = (ComponentGeneralNames*) CompAlloc( mem_op, sizeof(ComponentGeneralNames) );
01677        if ( !t ) return -1;
01678        *t = *k;
01679        }
01680        t->syntax = (Syntax*)NULL;
01681        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
01682        if ( !t->comp_desc ) {
01683               free ( t );
01684               return -1;
01685        }
01686        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentGeneralNames ;
01687        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentGeneralNames ;
01688        t->comp_desc->cd_free = (comp_free_func*)NULL;
01689        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentGeneralNames;
01690        t->comp_desc->cd_type = ASN_COMPOSITE;
01691        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
01692        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentGeneralNames;
01693     (*bytesDecoded) += totalElmtsLen1;
01694        return LDAP_SUCCESS;
01695 }  /* BDecGeneralNamesContent */
01696 
01697 int
01698 GDecComponentGeneralNames PARAMS (( mem_op,b, v, bytesDecoded, mode),
01699 void* mem_op _AND_
01700 GenBuf * b _AND_
01701 ComponentGeneralNames **v _AND_
01702 AsnLen *bytesDecoded _AND_
01703 int mode)
01704 {
01705        char* peek_head,*peek_head2;
01706        int i, strLen,strLen2, rc, old_mode = mode;
01707        ComponentGeneralNames *k,*t, c_temp;
01708 
01709 
01710        int ElmtsLen1;
01711        if ( !(mode & DEC_ALLOC_MODE_1) ) {
01712               memset(&c_temp,0,sizeof(c_temp));
01713                k = &c_temp;
01714        } else
01715                k = t = *v;
01716        mode = DEC_ALLOC_MODE_2;
01717        AsnListInit( &k->comp_list, sizeof( ComponentGeneralName ) );
01718        *bytesDecoded = 0;
01719        if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_PEEK)) ){
01720               Asn1Error("Error during Reading { in encoding");
01721               return LDAP_PROTOCOL_ERROR;
01722        }
01723        if(*peek_head != '{'){
01724               Asn1Error("Missing { in encoded data");
01725               return LDAP_PROTOCOL_ERROR;
01726        }
01727 
01728        for (ElmtsLen1 = 0; ElmtsLen1 >= INDEFINITE_LEN; ElmtsLen1++)
01729        {
01730               ComponentGeneralName **tmpVar;
01731               if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_NO_COPY)) ){
01732                      Asn1Error("Error during Reading{ in encoding");
01733                      return LDAP_PROTOCOL_ERROR;
01734               }
01735               if(*peek_head == '}') break;
01736               if( !(*peek_head == '{' || *peek_head ==',') ) {
01737                      return LDAP_PROTOCOL_ERROR;
01738               }
01739               tmpVar = (ComponentGeneralName**) CompAsnListAppend (mem_op, &k->comp_list);
01740               if ( tmpVar == NULL ) {
01741                      Asn1Error("Error during Reading{ in encoding");
01742                      return LDAP_PROTOCOL_ERROR;
01743               }
01744               rc =   GDecComponentGeneralName (mem_op, b, tmpVar, bytesDecoded, mode);
01745               if ( rc != LDAP_SUCCESS ) return rc;
01746        } /* end of for */
01747 
01748        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
01749        *v = t = (ComponentGeneralNames*) CompAlloc( mem_op, sizeof(ComponentGeneralNames) );
01750        if ( !t ) return -1;
01751        *t = *k;
01752        }
01753        t->syntax = (Syntax*)NULL;
01754        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
01755        if ( !t->comp_desc ) {
01756               free ( t );
01757               return -1;
01758        }
01759        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentGeneralNames ;
01760        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentGeneralNames ;
01761        t->comp_desc->cd_free = (comp_free_func*)NULL;
01762        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentGeneralNames;
01763        t->comp_desc->cd_type = ASN_COMPOSITE;
01764        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
01765        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentGeneralNames;
01766        return LDAP_SUCCESS;
01767 }  /* GDecGeneralNamesContent */
01768 
01769 
01770 int
01771 MatchingComponentAuthorityKeyIdentifier ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
01772        int rc;
01773        MatchingRule* mr;
01774 
01775        if ( oid ) {
01776               mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
01777               if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
01778        }
01779 
01780        rc = 1;
01781        rc =   MatchingComponentKeyIdentifier ( oid, (ComponentSyntaxInfo*)&((ComponentAuthorityKeyIdentifier*)csi_attr)->keyIdentifier, (ComponentSyntaxInfo*)&((ComponentAuthorityKeyIdentifier*)csi_assert)->keyIdentifier );
01782        if ( rc != LDAP_COMPARE_TRUE )
01783               return rc;
01784        if(COMPONENTNOT_NULL( ((ComponentAuthorityKeyIdentifier*)csi_attr)->authorityCertIssuer ) ) {
01785        rc =   MatchingComponentGeneralNames ( oid, (ComponentSyntaxInfo*)((ComponentAuthorityKeyIdentifier*)csi_attr)->authorityCertIssuer, (ComponentSyntaxInfo*)((ComponentAuthorityKeyIdentifier*)csi_assert)->authorityCertIssuer );
01786        if ( rc != LDAP_COMPARE_TRUE )
01787               return rc;
01788        }
01789        if(COMPONENTNOT_NULL( ((ComponentAuthorityKeyIdentifier*)csi_attr)->authorityCertSerialNumber ) ) {
01790        rc =   MatchingComponentCertificateSerialNumber ( oid, (ComponentSyntaxInfo*)((ComponentAuthorityKeyIdentifier*)csi_attr)->authorityCertSerialNumber, (ComponentSyntaxInfo*)((ComponentAuthorityKeyIdentifier*)csi_assert)->authorityCertSerialNumber );
01791        if ( rc != LDAP_COMPARE_TRUE )
01792               return rc;
01793        }
01794        return LDAP_COMPARE_TRUE;
01795 }  /* BMatchingComponentAuthorityKeyIdentifier */
01796 
01797 void*
01798 ExtractingComponentAuthorityKeyIdentifier ( void* mem_op, ComponentReference* cr, ComponentAuthorityKeyIdentifier *comp )
01799 {
01800 
01801        if ( ( comp->keyIdentifier.identifier.bv_val && strncmp(comp->keyIdentifier.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->keyIdentifier.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
01802               if ( cr->cr_curr->ci_next == NULL )
01803               return &comp->keyIdentifier;
01804               else
01805               return NULL;
01806        }
01807        if ( ( comp->authorityCertIssuer->identifier.bv_val && strncmp(comp->authorityCertIssuer->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->authorityCertIssuer->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
01808               if ( cr->cr_curr->ci_next == NULL )
01809                      return comp->authorityCertIssuer;
01810               else {
01811                      cr->cr_curr = cr->cr_curr->ci_next;
01812                      return        ExtractingComponentGeneralNames ( mem_op, cr, comp->authorityCertIssuer );
01813               }
01814        }
01815        if ( ( comp->authorityCertSerialNumber->identifier.bv_val && strncmp(comp->authorityCertSerialNumber->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->authorityCertSerialNumber->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
01816               if ( cr->cr_curr->ci_next == NULL )
01817                      return comp->authorityCertSerialNumber;
01818               else {
01819                      cr->cr_curr = cr->cr_curr->ci_next;
01820                      return        ExtractingComponentCertificateSerialNumber ( mem_op, cr, comp->authorityCertSerialNumber );
01821               }
01822        }
01823        return NULL;
01824 }  /* ExtractingComponentAuthorityKeyIdentifier */
01825 
01826 int
01827 BDecComponentAuthorityKeyIdentifier PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
01828 void* mem_op _AND_
01829 GenBuf * b _AND_
01830 AsnTag tagId0 _AND_
01831 AsnLen elmtLen0 _AND_
01832 ComponentAuthorityKeyIdentifier **v _AND_
01833 AsnLen *bytesDecoded _AND_
01834 int mode)
01835 {
01836        int seqDone = FALSE;
01837        AsnLen totalElmtsLen1 = 0;
01838        AsnLen elmtLen1;
01839        AsnTag tagId1;
01840        int mandatoryElmtCount1 = 0;
01841        AsnLen totalElmtsLen2 = 0;
01842        AsnLen elmtLen2;
01843        AsnTag tagId2;
01844        int old_mode = mode;
01845        int rc;
01846        ComponentAuthorityKeyIdentifier *k, *t, c_temp;
01847 
01848 
01849        if ( !(mode & DEC_ALLOC_MODE_1) ) {
01850               memset(&c_temp,0,sizeof(c_temp));
01851                k = &c_temp;
01852        } else
01853                k = t = *v;
01854        mode = DEC_ALLOC_MODE_2;
01855     if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0))
01856         seqDone = TRUE;
01857     else
01858     {
01859         tagId1 = BDecTag (b, &totalElmtsLen1 );
01860 
01861          if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID))
01862         {
01863             BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
01864             seqDone = TRUE;
01865         }
01866     }
01867 
01868     if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 0)) ||
01869 (tagId1 == MAKE_TAG_ID (CNTX, CONS, 0))))
01870     {
01871     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
01872                 rc =    BDecComponentKeyIdentifier (mem_op, b, tagId1, elmtLen1, (&k->keyIdentifier), &totalElmtsLen1, mode);
01873                 if ( rc != LDAP_SUCCESS ) return rc;
01874                 (&k->keyIdentifier)->identifier.bv_val = (&k->keyIdentifier)->id_buf;
01875                 (&k->keyIdentifier)->identifier.bv_len = strlen("keyIdentifier");
01876                 strcpy( (&k->keyIdentifier)->identifier.bv_val, "keyIdentifier");
01877     if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0))
01878         seqDone = TRUE;
01879     else
01880     {
01881         tagId1 = BDecTag (b, &totalElmtsLen1 );
01882                                                                                 
01883          if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID))
01884         {
01885             BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
01886             seqDone = TRUE;
01887         }
01888     }
01889     }
01890 
01891     if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, CONS, 1))))
01892     {
01893     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
01894                 rc =    BDecComponentGeneralNames (mem_op, b, tagId1, elmtLen1,
01895 (&k->authorityCertIssuer), &totalElmtsLen1, mode);
01896                 if ( rc != LDAP_SUCCESS ) return rc;
01897                 (k->authorityCertIssuer)->identifier.bv_val = (k->authorityCertIssuer)->id_buf;
01898                 (k->authorityCertIssuer)->identifier.bv_len = strlen("authorityCertIssuer");
01899                 strcpy( (k->authorityCertIssuer)->identifier.bv_val, "authorityCertIssuer");
01900     if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0))
01901         seqDone = TRUE;
01902     else
01903     {
01904         tagId1 = BDecTag (b, &totalElmtsLen1 );
01905                                                                                 
01906          if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID))
01907         {
01908             BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
01909             seqDone = TRUE;
01910         }
01911     }
01912     }
01913 
01914     if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 2))))
01915     {
01916     elmtLen1 = BDecLen (b, &totalElmtsLen1 );
01917                 rc =    BDecComponentCertificateSerialNumber (mem_op, b, tagId1, elmtLen1, (&k->authorityCertSerialNumber), &totalElmtsLen1, DEC_ALLOC_MODE_0 );                if ( rc != LDAP_SUCCESS ) return rc;
01918                 (k->authorityCertSerialNumber)->identifier.bv_val = (k->authorityCertSerialNumber)->id_buf;
01919                 (k->authorityCertSerialNumber)->identifier.bv_len = strlen("authorityCertSerialNumber");
01920                 strcpy( (k->authorityCertSerialNumber)->identifier.bv_val, "authorityCertSerialNumber");
01921         seqDone = TRUE;
01922         if (elmtLen0 == INDEFINITE_LEN)
01923             BDecEoc (b, &totalElmtsLen1 );
01924         else if (totalElmtsLen1 != elmtLen0)
01925         return -1;
01926                                                                                 
01927     }
01928 
01929     if (!seqDone)
01930         return -1;
01931 
01932        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
01933        *v = t = (ComponentAuthorityKeyIdentifier*) CompAlloc( mem_op, sizeof(ComponentAuthorityKeyIdentifier) );
01934        if ( !t ) return -1;
01935        *t = *k;
01936        }
01937        t->syntax = (Syntax*)NULL;
01938        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
01939        if ( !t->comp_desc ) {
01940               free ( t );
01941               return -1;
01942        }
01943        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentAuthorityKeyIdentifier ;
01944        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentAuthorityKeyIdentifier ;
01945        t->comp_desc->cd_free = (comp_free_func*)NULL;
01946        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentAuthorityKeyIdentifier;
01947        t->comp_desc->cd_type = ASN_COMPOSITE;
01948        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
01949        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentAuthorityKeyIdentifier;
01950     (*bytesDecoded) += totalElmtsLen1;
01951        return LDAP_SUCCESS;
01952 }  /* BDecAuthorityKeyIdentifier*/
01953 
01954 int
01955 GDecComponentAuthorityKeyIdentifier PARAMS (( mem_op,b, v, bytesDecoded, mode),
01956 void* mem_op _AND_
01957 GenBuf * b _AND_
01958 ComponentAuthorityKeyIdentifier **v _AND_
01959 AsnLen *bytesDecoded _AND_
01960 int mode)
01961 {
01962        char* peek_head,*peek_head2;
01963        int i, strLen,strLen2, rc, old_mode = mode;
01964        ComponentAuthorityKeyIdentifier *k,*t, c_temp;
01965 
01966 
01967        if ( !(mode & DEC_ALLOC_MODE_1) ) {
01968               memset(&c_temp,0,sizeof(c_temp));
01969                k = &c_temp;
01970        } else
01971                k = t = *v;
01972        mode = DEC_ALLOC_MODE_2;
01973        *bytesDecoded = 0;
01974        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
01975               Asn1Error("Error during Reading { in encoded data");
01976               return LDAP_PROTOCOL_ERROR;
01977        }
01978        if(*peek_head != '{'){
01979               Asn1Error("Missing { in encoded data");
01980               return LDAP_PROTOCOL_ERROR;
01981        }
01982 
01983        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
01984               Asn1Error("Error during Reading identifier");
01985               return LDAP_PROTOCOL_ERROR;
01986        }
01987        if ( strncmp( peek_head, "keyIdentifier", strlen("keyIdentifier") ) == 0 ) {
01988               rc =   GDecComponentKeyIdentifier (mem_op, b, (&k->keyIdentifier), bytesDecoded, mode);
01989               if ( rc != LDAP_SUCCESS ) return rc;
01990        (&k->keyIdentifier)->identifier.bv_val = peek_head;
01991        (&k->keyIdentifier)->identifier.bv_len = strLen;
01992        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
01993               Asn1Error("Error during Reading , ");
01994               return LDAP_PROTOCOL_ERROR;
01995        }
01996        if(*peek_head != ','){
01997               Asn1Error("Missing , in encoding");
01998               return LDAP_PROTOCOL_ERROR;
01999        }
02000        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
02001          Asn1Error("Error during Reading identifier");
02002               return LDAP_PROTOCOL_ERROR;
02003        }
02004        }
02005        if ( strncmp( peek_head, "authorityCertIssuer", strlen("authorityCertIssuer") ) == 0 ) {
02006               rc =   GDecComponentGeneralNames (mem_op, b, (&k->authorityCertIssuer), bytesDecoded, mode);
02007               if ( rc != LDAP_SUCCESS ) return rc;
02008        ( k->authorityCertIssuer)->identifier.bv_val = peek_head;
02009        ( k->authorityCertIssuer)->identifier.bv_len = strLen;
02010        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
02011               Asn1Error("Error during Reading , ");
02012               return LDAP_PROTOCOL_ERROR;
02013        }
02014        if(*peek_head != ','){
02015               Asn1Error("Missing , in encoding");
02016               return LDAP_PROTOCOL_ERROR;
02017        }
02018        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
02019          Asn1Error("Error during Reading identifier");
02020               return LDAP_PROTOCOL_ERROR;
02021        }
02022        }
02023        if ( strncmp( peek_head, "authorityCertSerialNumber", strlen("authorityCertSerialNumber") ) == 0 ) {
02024               rc =   GDecComponentCertificateSerialNumber (mem_op, b, (&k->authorityCertSerialNumber), bytesDecoded, DEC_ALLOC_MODE_0 );
02025               if ( rc != LDAP_SUCCESS ) return rc;
02026        ( k->authorityCertSerialNumber)->identifier.bv_val = peek_head;
02027        ( k->authorityCertSerialNumber)->identifier.bv_len = strLen;
02028        }
02029        if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
02030               Asn1Error("Error during Reading } in encoding");
02031               return LDAP_PROTOCOL_ERROR;
02032        }
02033        if(*peek_head != '}'){
02034               Asn1Error("Missing } in encoding");
02035               return LDAP_PROTOCOL_ERROR;
02036        }
02037        if( !(old_mode & DEC_ALLOC_MODE_1) ) {
02038        *v = t = (ComponentAuthorityKeyIdentifier*) CompAlloc( mem_op, sizeof(ComponentAuthorityKeyIdentifier) );
02039        if ( !t ) return -1;
02040        *t = *k;
02041        }
02042        t->syntax = (Syntax*)NULL;
02043        t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
02044        if ( !t->comp_desc ) {
02045               free ( t );
02046               return -1;
02047        }
02048        t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentAuthorityKeyIdentifier ;
02049        t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentAuthorityKeyIdentifier ;
02050        t->comp_desc->cd_free = (comp_free_func*)NULL;
02051        t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentAuthorityKeyIdentifier;
02052        t->comp_desc->cd_type = ASN_COMPOSITE;
02053        t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
02054        t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentAuthorityKeyIdentifier;
02055        return LDAP_SUCCESS;
02056 }  /* GDecAuthorityKeyIdentifier*/
02057 
02058