X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fcharneg.c;h=9701cdac545103db123d78b3338541325777e878;hp=d6a2398c3a4f1a622e709bd8b456e2e6a3bb9ca1;hb=43a9d38d20c1b1bcd1a03b2445a501d27526bd35;hpb=7a4064cd15f6c6b34c1180e1bc51f0d0e90da320 diff --git a/src/charneg.c b/src/charneg.c index d6a2398..9701cda 100644 --- a/src/charneg.c +++ b/src/charneg.c @@ -1,16 +1,17 @@ -/* - * Copyright (C) 1995-2007, Index Data ApS +/* This file is part of the YAZ toolkit. + * Copyright (C) 1995-2011 Index Data * See the file LICENSE for details. - * - * $Id: charneg.c,v 1.8 2007-04-12 13:52:57 adam Exp $ */ - /** * \file charneg.c * \brief Implements Z39.50 Charset negotiation utilities * * Helper functions for Character Set and Language Negotiation - 3 */ +#if HAVE_CONFIG_H +#include +#endif + #include #include #include @@ -28,10 +29,7 @@ static Z_External* z_ext_record2(ODR o, const char *buf) p->descriptor = 0; p->indirect_reference = 0; - p->direct_reference = yaz_string_to_oid_odr(yaz_oid_std(), - CLASS_NEGOT, - OID_STR_ID_CHARSET, - o); + p->direct_reference = odr_oiddup(o, yaz_oid_negot_charset_id); p->which = Z_External_octet; if (!(p->u.octet_aligned = (Odr_oct *)odr_malloc(o, sizeof(Odr_oct)))) { @@ -175,10 +173,7 @@ Z_External *yaz_set_proposal_charneg(ODR o, p->descriptor = 0; p->indirect_reference = 0; - p->direct_reference = yaz_string_to_oid_odr(yaz_oid_std(), - CLASS_NEGOT, - OID_STR_CHARNEG_3, - o); + p->direct_reference = odr_oiddup(o, yaz_oid_negot_charset_3); p->which = Z_External_charSetandLanguageNegotiation; p->u.charNeg3 = z_get_CharSetandLanguageNegotiation(o); @@ -266,10 +261,7 @@ Z_External *yaz_set_response_charneg(ODR o, const char *charset, p->descriptor = 0; p->indirect_reference = 0; - p->direct_reference = yaz_string_to_oid_odr(yaz_oid_std(), - CLASS_NEGOT, - OID_STR_CHARNEG_3, - o); + p->direct_reference = odr_oiddup(o, yaz_oid_negot_charset_3); p->which = Z_External_charSetandLanguageNegotiation; p->u.charNeg3 = z_get_CharSetandLanguageNegotiation(o); @@ -291,14 +283,8 @@ Z_CharSetandLanguageNegotiation *yaz_get_charneg_record(Z_OtherInformation *p) Z_External *pext; if ((p->list[i]->which == Z_OtherInfo_externallyDefinedInfo) && (pext = p->list[i]->information.externallyDefinedInfo)) { - - int oclass; - const char *name = yaz_oid_to_string(yaz_oid_std(), - pext->direct_reference, - &oclass); - - if (oclass == CLASS_NEGOT - && name && !strcmp(name, OID_STR_CHARNEG_3) + + if (!oid_oidcmp(pext->direct_reference, yaz_oid_negot_charset_3) && pext->which == Z_External_charSetandLanguageNegotiation) { return pext->u.charNeg3; @@ -321,13 +307,7 @@ int yaz_del_charneg_record(Z_OtherInformation **p) if (((*p)->list[i]->which == Z_OtherInfo_externallyDefinedInfo) && (pext = (*p)->list[i]->information.externallyDefinedInfo)) { - int oclass; - const char *name = yaz_oid_to_string(yaz_oid_std(), - pext->direct_reference, - &oclass); - - if (oclass == CLASS_NEGOT - && name && !strcmp(name, OID_STR_CHARNEG_3) + if (!oid_oidcmp(pext->direct_reference, yaz_oid_negot_charset_3) && pext->which == Z_External_charSetandLanguageNegotiation) { if ((*p)->num_elements <= 1) @@ -448,6 +428,7 @@ void yaz_get_response_charneg(NMEM mem, Z_CharSetandLanguageNegotiation *p, /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab