X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fcharneg.c;h=8d6774e2478e74d893ff7f5df6e241fd8b4b534e;hb=58e7306c9f23189e136c52b21e39692392824ea7;hp=ebd10fc53f429ae6cfea6bff39fb90be8dd9b7a5;hpb=c6e47cbbff56f39f6d81b079ebaeac41d793d4d9;p=yaz-moved-to-github.git diff --git a/src/charneg.c b/src/charneg.c index ebd10fc..8d6774e 100644 --- a/src/charneg.c +++ b/src/charneg.c @@ -1,8 +1,16 @@ -/* - $ $Id: charneg.c,v 1.1 2003-10-27 12:21:30 adam Exp $ - * Helper functions for Character Set and Language Negotiation - 3 +/* + * Copyright (C) 1995-2005, Index Data ApS + * See the file LICENSE for details. + * + * $Id: charneg.c,v 1.4 2005-05-18 12:38:40 adam Exp $ */ +/** + * \file charneg.c + * \brief Implements Z39.50 Charset negotiation utilities + * + * Helper functions for Character Set and Language Negotiation - 3 + */ #include #include #include @@ -252,22 +260,22 @@ Z_External *yaz_set_response_charneg(ODR o, const char *charset, /* Get negotiation from OtherInformation. Client&Server side */ Z_CharSetandLanguageNegotiation *yaz_get_charneg_record(Z_OtherInformation *p) { - Z_External *pext; int i; - if(!p) + if (!p) return 0; - for (i=0; inum_elements; i++) { - + for (i = 0; i < p->num_elements; i++) { + Z_External *pext; if ((p->list[i]->which == Z_OtherInfo_externallyDefinedInfo) && (pext = p->list[i]->information.externallyDefinedInfo)) { - + oident *ent = oid_getentbyoid(pext->direct_reference); - - if (ent && ent->value == VAL_CHARNEG3 && ent->oclass == CLASS_NEGOT && - pext->which == Z_External_charSetandLanguageNegotiation) { - + + if (ent && ent->value == VAL_CHARNEG3 + && ent->oclass == CLASS_NEGOT + && pext->which == Z_External_charSetandLanguageNegotiation) + { return pext->u.charNeg3; } } @@ -275,6 +283,41 @@ Z_CharSetandLanguageNegotiation *yaz_get_charneg_record(Z_OtherInformation *p) return 0; } +/* Delete negotiation from OtherInformation. Client&Server side */ +int yaz_del_charneg_record(Z_OtherInformation **p) +{ + int i; + + if (!*p) + return 0; + + for (i = 0; i < (*p)->num_elements; i++) { + Z_External *pext; + if (((*p)->list[i]->which == Z_OtherInfo_externallyDefinedInfo) && + (pext = (*p)->list[i]->information.externallyDefinedInfo)) { + + oident *ent = oid_getentbyoid(pext->direct_reference); + + if (ent && ent->value == VAL_CHARNEG3 + && ent->oclass == CLASS_NEGOT + && pext->which == Z_External_charSetandLanguageNegotiation) + { + --((*p)->num_elements); + if ((*p)->num_elements == 0) + *p = 0; + else + { + for(; i < (*p)->num_elements; i++) + (*p)->list[i] = (*p)->list[i+1]; + } + return 1; + } + } + } + return 0; +} + + /* Get charsets, langs, selected from negotiation.. Server side */ void yaz_get_proposal_charneg(NMEM mem, Z_CharSetandLanguageNegotiation *p, char ***charsets, int *num_charsets,