X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=zutil%2Fotherinfo.c;h=9ee855068a9c2b4d8e37d893287f44e630c9dead;hb=c39a893dfdae5f792139177132e7e7a70e010aa7;hp=29aa036c1349b52a2a58a885473cd9f9b439a6ce;hpb=161ec45b40a3ab08e08946c9654ab6fea4604760;p=yaz-moved-to-github.git diff --git a/zutil/otherinfo.c b/zutil/otherinfo.c index 29aa036..9ee8550 100644 --- a/zutil/otherinfo.c +++ b/zutil/otherinfo.c @@ -1,21 +1,15 @@ /* - * Copyright (c) 1999, Index Data + * Copyright (c) 1999-2003, Index Data * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * - * $Log: otherinfo.c,v $ - * Revision 1.1 1999-06-08 10:10:16 adam - * New sub directory zutil. Moved YAZ Compiler to be part of YAZ tree. - * - * Revision 1.1 1999/04/26 07:25:25 adam - * Implemented OtherInfo utility. - * + * $Id: otherinfo.c,v 1.7 2003-01-06 08:20:29 adam Exp $ */ #include #include -#include +#include void yaz_oi_APDU(Z_APDU *apdu, Z_OtherInformation ***oip) { @@ -36,6 +30,12 @@ void yaz_oi_APDU(Z_APDU *apdu, Z_OtherInformation ***oip) case Z_APDU_scanRequest: *oip = &apdu->u.scanRequest->otherInfo; break; + case Z_APDU_extendedServicesRequest: + *oip = &apdu->u.extendedServicesRequest->otherInfo; + break; + case Z_APDU_deleteResultSetRequest: + *oip = &apdu->u.deleteResultSetRequest->otherInfo; + break; case Z_APDU_initResponse: *oip = &apdu->u.initResponse->otherInfo; break; @@ -51,6 +51,18 @@ void yaz_oi_APDU(Z_APDU *apdu, Z_OtherInformation ***oip) case Z_APDU_scanResponse: *oip = &apdu->u.scanResponse->otherInfo; break; + case Z_APDU_extendedServicesResponse: + *oip = &apdu->u.extendedServicesResponse->otherInfo; + break; + case Z_APDU_deleteResultSetResponse: + *oip = &apdu->u.deleteResultSetResponse->otherInfo; + break; + case Z_APDU_duplicateDetectionRequest: + *oip = &apdu->u.duplicateDetectionRequest->otherInfo; + break; + case Z_APDU_duplicateDetectionResponse: + *oip = &apdu->u.duplicateDetectionResponse->otherInfo; + break; default: *oip = 0; break; @@ -59,10 +71,14 @@ void yaz_oi_APDU(Z_APDU *apdu, Z_OtherInformation ***oip) Z_OtherInformationUnit *yaz_oi_update ( Z_OtherInformation **otherInformationP, ODR odr, - int *oid, int categoryValue) + int *oid, int categoryValue, int delete_flag) { int i; - Z_OtherInformation *otherInformation = *otherInformationP; + Z_OtherInformation *otherInformation; + + if (!otherInformationP) + return 0; + otherInformation = *otherInformationP; if (!otherInformation) { if (!odr) @@ -86,7 +102,21 @@ Z_OtherInformationUnit *yaz_oi_update ( *otherInformation->list[i]->category->categoryValue && !oid_oidcmp (oid, otherInformation->list[i]->category-> categoryTypeId)) - return otherInformation->list[i]; + { + 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 (!odr) @@ -94,7 +124,7 @@ Z_OtherInformationUnit *yaz_oi_update ( else { Z_OtherInformationUnit **newlist = (Z_OtherInformationUnit**) - odr_malloc(odr, otherInformation->num_elements+1 * + odr_malloc(odr, (otherInformation->num_elements+1) * sizeof(*newlist)); for (i = 0; inum_elements; i++) newlist[i] = otherInformation->list[i]; @@ -129,7 +159,7 @@ void yaz_oi_set_string_oid ( const char *str) { Z_OtherInformationUnit *oi = - yaz_oi_update(otherInformation, odr, oid, categoryValue); + yaz_oi_update(otherInformation, odr, oid, categoryValue, 0); if (!oi) return; oi->which = Z_OtherInfo_characterInfo; @@ -154,18 +184,18 @@ void yaz_oi_set_string_oidval ( char *yaz_oi_get_string_oid ( Z_OtherInformation **otherInformation, - int *oid, int categoryValue) + int *oid, int categoryValue, int delete_flag) { Z_OtherInformationUnit *oi; - if ((oi = yaz_oi_update(otherInformation, 0, oid, 1)) && + if ((oi = yaz_oi_update(otherInformation, 0, oid, 1, delete_flag)) && 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 oidval, int categoryValue, int delete_flag) { int oid[OID_SIZE]; struct oident ent; @@ -175,6 +205,7 @@ char *yaz_oi_get_string_oidval(Z_OtherInformation **otherInformation, if (!oid_ent_to_oid (&ent, oid)) return 0; - return yaz_oi_get_string_oid (otherInformation, oid, categoryValue); + return yaz_oi_get_string_oid (otherInformation, oid, categoryValue, + delete_flag); }