X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fotherinfo.c;h=4cf95c864f82bf574a3ea9af220429553b99178b;hp=580c610d8ed099a1d3b3f6b45841172d0e9ff6ee;hb=fb6d99a0c7e07d9cc4a315c447deaf6564a85505;hpb=67002f49611adb64993391b0cbf6c235f18080a4 diff --git a/src/otherinfo.c b/src/otherinfo.c index 580c610..4cf95c8 100644 --- a/src/otherinfo.c +++ b/src/otherinfo.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: otherinfo.c,v 1.3 2005-01-15 19:47:14 adam Exp $ + * $Id: otherinfo.c,v 1.4 2005-06-25 15:46:04 adam Exp $ */ /** * \file otherinfo.c @@ -18,56 +18,56 @@ void yaz_oi_APDU(Z_APDU *apdu, Z_OtherInformation ***oip) switch (apdu->which) { case Z_APDU_initRequest: - *oip = &apdu->u.initRequest->otherInfo; - break; + *oip = &apdu->u.initRequest->otherInfo; + break; case Z_APDU_searchRequest: - *oip = &apdu->u.searchRequest->otherInfo; - break; + *oip = &apdu->u.searchRequest->otherInfo; + break; case Z_APDU_presentRequest: - *oip = &apdu->u.presentRequest->otherInfo; - break; + *oip = &apdu->u.presentRequest->otherInfo; + break; case Z_APDU_sortRequest: - *oip = &apdu->u.sortRequest->otherInfo; - break; + *oip = &apdu->u.sortRequest->otherInfo; + break; case Z_APDU_scanRequest: - *oip = &apdu->u.scanRequest->otherInfo; - break; + *oip = &apdu->u.scanRequest->otherInfo; + break; case Z_APDU_extendedServicesRequest: - *oip = &apdu->u.extendedServicesRequest->otherInfo; - break; + *oip = &apdu->u.extendedServicesRequest->otherInfo; + break; case Z_APDU_deleteResultSetRequest: - *oip = &apdu->u.deleteResultSetRequest->otherInfo; - break; + *oip = &apdu->u.deleteResultSetRequest->otherInfo; + break; case Z_APDU_initResponse: - *oip = &apdu->u.initResponse->otherInfo; - break; + *oip = &apdu->u.initResponse->otherInfo; + break; case Z_APDU_searchResponse: - *oip = &apdu->u.searchResponse->otherInfo; - break; + *oip = &apdu->u.searchResponse->otherInfo; + break; case Z_APDU_presentResponse: - *oip = &apdu->u.presentResponse->otherInfo; - break; + *oip = &apdu->u.presentResponse->otherInfo; + break; case Z_APDU_sortResponse: - *oip = &apdu->u.sortResponse->otherInfo; - break; + *oip = &apdu->u.sortResponse->otherInfo; + break; case Z_APDU_scanResponse: - *oip = &apdu->u.scanResponse->otherInfo; - break; + *oip = &apdu->u.scanResponse->otherInfo; + break; case Z_APDU_extendedServicesResponse: - *oip = &apdu->u.extendedServicesResponse->otherInfo; - break; + *oip = &apdu->u.extendedServicesResponse->otherInfo; + break; case Z_APDU_deleteResultSetResponse: - *oip = &apdu->u.deleteResultSetResponse->otherInfo; - break; + *oip = &apdu->u.deleteResultSetResponse->otherInfo; + break; case Z_APDU_duplicateDetectionRequest: - *oip = &apdu->u.duplicateDetectionRequest->otherInfo; - break; + *oip = &apdu->u.duplicateDetectionRequest->otherInfo; + break; case Z_APDU_duplicateDetectionResponse: - *oip = &apdu->u.duplicateDetectionResponse->otherInfo; - break; + *oip = &apdu->u.duplicateDetectionResponse->otherInfo; + break; default: - *oip = 0; - break; + *oip = 0; + break; } } @@ -83,75 +83,75 @@ Z_OtherInformationUnit *yaz_oi_update ( otherInformation = *otherInformationP; if (!otherInformation) { - if (!odr) - return 0; - otherInformation = *otherInformationP = (Z_OtherInformation *) - odr_malloc (odr, sizeof(*otherInformation)); - otherInformation->num_elements = 0; - otherInformation->list = 0; + if (!odr) + return 0; + otherInformation = *otherInformationP = (Z_OtherInformation *) + odr_malloc (odr, sizeof(*otherInformation)); + otherInformation->num_elements = 0; + otherInformation->list = 0; } for (i = 0; inum_elements; i++) { - if (!oid) - { - if (!otherInformation->list[i]->category) - return otherInformation->list[i]; - } - else - { - if (otherInformation->list[i]->category && - categoryValue == - *otherInformation->list[i]->category->categoryValue && - !oid_oidcmp (oid, otherInformation->list[i]->category-> - categoryTypeId)) - { - Z_OtherInformationUnit *this_list = otherInformation->list[i]; + if (!oid) + { + if (!otherInformation->list[i]->category) + return otherInformation->list[i]; + } + else + { + if (otherInformation->list[i]->category && + categoryValue == + *otherInformation->list[i]->category->categoryValue && + !oid_oidcmp (oid, otherInformation->list[i]->category-> + categoryTypeId)) + { + Z_OtherInformationUnit *this_list = otherInformation->list[i]; - if (delete_flag) - { - (otherInformation->num_elements)--; - while (i < otherInformation->num_elements) - { - otherInformation->list[i] = - otherInformation->list[i+1]; - i++; - } - } - return this_list; - } - } + if (delete_flag) + { + (otherInformation->num_elements)--; + while (i < otherInformation->num_elements) + { + otherInformation->list[i] = + otherInformation->list[i+1]; + i++; + } + } + return this_list; + } + } } if (!odr) - return 0; + return 0; else { - Z_OtherInformationUnit **newlist = (Z_OtherInformationUnit**) - odr_malloc(odr, (otherInformation->num_elements+1) * - sizeof(*newlist)); - for (i = 0; inum_elements; i++) - newlist[i] = otherInformation->list[i]; - otherInformation->list = newlist; - - otherInformation->list[i] = (Z_OtherInformationUnit*) - odr_malloc (odr, sizeof(Z_OtherInformationUnit)); - if (oid) - { - otherInformation->list[i]->category = (Z_InfoCategory*) - odr_malloc (odr, sizeof(Z_InfoCategory)); - otherInformation->list[i]->category->categoryTypeId = (int*) - odr_oiddup (odr, oid); - otherInformation->list[i]->category->categoryValue = (int*) - odr_malloc (odr, sizeof(int)); - *otherInformation->list[i]->category->categoryValue = - categoryValue; - } - else - otherInformation->list[i]->category = 0; - otherInformation->list[i]->which = Z_OtherInfo_characterInfo; - otherInformation->list[i]->information.characterInfo = 0; - - otherInformation->num_elements = i+1; - return otherInformation->list[i]; + Z_OtherInformationUnit **newlist = (Z_OtherInformationUnit**) + odr_malloc(odr, (otherInformation->num_elements+1) * + sizeof(*newlist)); + for (i = 0; inum_elements; i++) + newlist[i] = otherInformation->list[i]; + otherInformation->list = newlist; + + otherInformation->list[i] = (Z_OtherInformationUnit*) + odr_malloc (odr, sizeof(Z_OtherInformationUnit)); + if (oid) + { + otherInformation->list[i]->category = (Z_InfoCategory*) + odr_malloc (odr, sizeof(Z_InfoCategory)); + otherInformation->list[i]->category->categoryTypeId = (int*) + odr_oiddup (odr, oid); + otherInformation->list[i]->category->categoryValue = (int*) + odr_malloc (odr, sizeof(int)); + *otherInformation->list[i]->category->categoryValue = + categoryValue; + } + else + otherInformation->list[i]->category = 0; + otherInformation->list[i]->which = Z_OtherInfo_characterInfo; + otherInformation->list[i]->information.characterInfo = 0; + + otherInformation->num_elements = i+1; + return otherInformation->list[i]; } } @@ -161,9 +161,9 @@ void yaz_oi_set_string_oid ( const char *str) { Z_OtherInformationUnit *oi = - yaz_oi_update(otherInformation, odr, oid, categoryValue, 0); + yaz_oi_update(otherInformation, odr, oid, categoryValue, 0); if (!oi) - return; + return; oi->which = Z_OtherInfo_characterInfo; oi->information.characterInfo = odr_strdup (odr, str); } @@ -179,9 +179,9 @@ void yaz_oi_set_string_oidval ( ent.oclass = CLASS_USERINFO; ent.value = (oid_value) oidval; if (!oid_ent_to_oid (&ent, oid)) - return ; + return ; yaz_oi_set_string_oid(otherInformation, - odr, oid, categoryValue, str); + odr, oid, categoryValue, str); } char *yaz_oi_get_string_oid ( @@ -191,13 +191,13 @@ char *yaz_oi_get_string_oid ( Z_OtherInformationUnit *oi; if ((oi = yaz_oi_update(otherInformation, 0, oid, 1, delete_flag)) && - oi->which == Z_OtherInfo_characterInfo) - return oi->information.characterInfo; + oi->which == Z_OtherInfo_characterInfo) + return oi->information.characterInfo; return 0; } char *yaz_oi_get_string_oidval(Z_OtherInformation **otherInformation, - int oidval, int categoryValue, int delete_flag) + int oidval, int categoryValue, int delete_flag) { int oid[OID_SIZE]; struct oident ent; @@ -206,8 +206,16 @@ char *yaz_oi_get_string_oidval(Z_OtherInformation **otherInformation, ent.value = (oid_value) oidval; if (!oid_ent_to_oid (&ent, oid)) - return 0; + return 0; return yaz_oi_get_string_oid (otherInformation, oid, categoryValue, - delete_flag); + delete_flag); } +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +