YAZ 5.35.1
otherinfo.c
Go to the documentation of this file.
1/* This file is part of the YAZ toolkit.
2 * Copyright (C) Index Data
3 * See the file LICENSE for details.
4 */
9#if HAVE_CONFIG_H
10#include <config.h>
11#endif
12
13#include <stdio.h>
14#include <string.h>
15
16#include <yaz/otherinfo.h>
17
19{
20 switch (apdu->which)
21 {
23 *oip = &apdu->u.initRequest->otherInfo;
24 break;
26 *oip = &apdu->u.searchRequest->otherInfo;
27 break;
29 *oip = &apdu->u.presentRequest->otherInfo;
30 break;
32 *oip = &apdu->u.sortRequest->otherInfo;
33 break;
35 *oip = &apdu->u.scanRequest->otherInfo;
36 break;
38 *oip = &apdu->u.extendedServicesRequest->otherInfo;
39 break;
41 *oip = &apdu->u.deleteResultSetRequest->otherInfo;
42 break;
44 *oip = &apdu->u.initResponse->otherInfo;
45 break;
47 *oip = &apdu->u.searchResponse->otherInfo;
48 break;
50 *oip = &apdu->u.presentResponse->otherInfo;
51 break;
53 *oip = &apdu->u.sortResponse->otherInfo;
54 break;
56 *oip = &apdu->u.scanResponse->otherInfo;
57 break;
60 break;
62 *oip = &apdu->u.deleteResultSetResponse->otherInfo;
63 break;
66 break;
69 break;
70 default:
71 *oip = 0;
72 break;
73 }
74}
75
77 Z_OtherInformation **otherInformationP, ODR odr,
78 const Odr_oid *oid, int categoryValue, int delete_flag)
79{
80 int i;
81 Z_OtherInformation *otherInformation;
82
83 if (!otherInformationP)
84 return 0;
85 otherInformation = *otherInformationP;
86 if (!otherInformation)
87 {
88 if (!odr)
89 return 0;
90 otherInformation = *otherInformationP = (Z_OtherInformation *)
91 odr_malloc (odr, sizeof(*otherInformation));
92 otherInformation->num_elements = 0;
93 otherInformation->list = 0;
94 }
95 for (i = 0; i<otherInformation->num_elements; i++)
96 {
97 if (!oid)
98 {
99 /* DS: Want does this do? Returns the first element without a category */
100 if (!otherInformation->list[i]->category)
101 return otherInformation->list[i];
102 }
103 else
104 {
105 if (otherInformation->list[i]->category &&
106 categoryValue ==
107 *otherInformation->list[i]->category->categoryValue &&
108 !oid_oidcmp (oid, otherInformation->list[i]->category->
109 categoryTypeId))
110 {
111 Z_OtherInformationUnit *this_list = otherInformation->list[i];
112
113 if (delete_flag)
114 {
115 (otherInformation->num_elements)--;
116 while (i < otherInformation->num_elements)
117 {
118 otherInformation->list[i] =
119 otherInformation->list[i+1];
120 i++;
121 }
122 }
123 return this_list;
124 }
125 }
126 }
127 if (!odr)
128 return 0;
129 else
130 {
132 odr_malloc(odr, (otherInformation->num_elements+1) *
133 sizeof(*newlist));
134 for (i = 0; i<otherInformation->num_elements; i++)
135 newlist[i] = otherInformation->list[i];
136 otherInformation->list = newlist;
137
138 otherInformation->list[i] = (Z_OtherInformationUnit*)
140 if (oid)
141 {
142 otherInformation->list[i]->category = (Z_InfoCategory*)
143 odr_malloc (odr, sizeof(Z_InfoCategory));
144 otherInformation->list[i]->category->categoryTypeId = (Odr_oid*)
145 odr_oiddup (odr, oid);
146 otherInformation->list[i]->category->categoryValue =
147 odr_intdup(odr, categoryValue);
148 }
149 else
150 otherInformation->list[i]->category = 0;
151 otherInformation->list[i]->which = Z_OtherInfo_characterInfo;
152 otherInformation->list[i]->information.characterInfo = 0;
153
154 otherInformation->num_elements = i+1;
155 return otherInformation->list[i];
156 }
157}
158
160 Z_OtherInformation **otherInformation, ODR odr,
161 const Odr_oid *oid, int categoryValue,
162 const char *str)
163{
165 yaz_oi_update(otherInformation, odr, oid, categoryValue, 0);
166 if (!oi)
167 return;
170}
171
173 Z_OtherInformation **otherInformation,
174 const Odr_oid *oid, int categoryValue, int delete_flag)
175{
177
178 if ((oi = yaz_oi_update(otherInformation, 0, oid, categoryValue,
179 delete_flag)) &&
181 return oi->information.characterInfo;
182 return 0;
183}
184
185
186/*
187 * Local variables:
188 * c-basic-offset: 4
189 * c-file-style: "Stroustrup"
190 * indent-tabs-mode: nil
191 * End:
192 * vim: shiftwidth=4 tabstop=8 expandtab
193 */
194
Odr_int * odr_intdup(ODR o, Odr_int v)
Definition odr_mem.c:51
void * odr_malloc(ODR o, size_t size)
Definition odr_mem.c:31
char * odr_strdup(ODR o, const char *str)
Definition odr_mem.c:36
Odr_oid * odr_oiddup(ODR odr, const Odr_oid *o)
Definition odr_util.c:60
int oid_oidcmp(const Odr_oid *o1, const Odr_oid *o2)
compares OIDs
Definition oid_util.c:34
short Odr_oid
Definition oid_util.h:42
void yaz_oi_APDU(Z_APDU *apdu, Z_OtherInformation ***oip)
Definition otherinfo.c:18
void yaz_oi_set_string_oid(Z_OtherInformation **otherInformation, ODR odr, const Odr_oid *oid, int categoryValue, const char *str)
Definition otherinfo.c:159
Z_OtherInformationUnit * yaz_oi_update(Z_OtherInformation **otherInformationP, ODR odr, const Odr_oid *oid, int categoryValue, int delete_flag)
Definition otherinfo.c:76
char * yaz_oi_get_string_oid(Z_OtherInformation **otherInformation, const Odr_oid *oid, int categoryValue, int delete_flag)
Definition otherinfo.c:172
Header for Z39.50 OtherInfo utilities.
int which
Definition z-core.h:322
Z_InitRequest * initRequest
Definition z-core.h:324
Z_DeleteResultSetRequest * deleteResultSetRequest
Definition z-core.h:330
Z_ScanResponse * scanResponse
Definition z-core.h:340
Z_DuplicateDetectionResponse * duplicateDetectionResponse
Definition z-core.h:348
Z_DeleteResultSetResponse * deleteResultSetResponse
Definition z-core.h:331
Z_InitResponse * initResponse
Definition z-core.h:325
Z_DuplicateDetectionRequest * duplicateDetectionRequest
Definition z-core.h:347
Z_ExtendedServicesResponse * extendedServicesResponse
Definition z-core.h:345
Z_ScanRequest * scanRequest
Definition z-core.h:339
Z_SearchResponse * searchResponse
Definition z-core.h:327
union Z_APDU::@43 u
Z_PresentResponse * presentResponse
Definition z-core.h:329
Z_ExtendedServicesRequest * extendedServicesRequest
Definition z-core.h:344
Z_SortRequest * sortRequest
Definition z-core.h:341
Z_SearchRequest * searchRequest
Definition z-core.h:326
Z_SortResponse * sortResponse
Definition z-core.h:342
Z_PresentRequest * presentRequest
Definition z-core.h:328
Z_OtherInformation * otherInfo
Definition z-core.h:827
Z_OtherInformation * otherInfo
Definition z-core.h:837
Z_OtherInformation * otherInfo
Definition z-core.h:1202
Z_OtherInformation * otherInfo
Definition z-core.h:1266
Z_OtherInformation * otherInfo
Definition z-core.h:1138
Z_OtherInformation * otherInfo
Definition z-core.h:1150
Odr_oid * categoryTypeId
Definition z-core.h:1300
Odr_int * categoryValue
Definition z-core.h:1301
Z_OtherInformation * otherInfo
Definition z-core.h:388
Z_OtherInformation * otherInfo
Definition z-core.h:422
Z_InternationalString * characterInfo
Definition z-core.h:1283
Z_InfoCategory * category
Definition z-core.h:1280
union Z_OtherInformationUnit::@71 information
Z_OtherInformationUnit ** list
Definition z-core.h:1296
Z_OtherInformation * otherInfo
Definition z-core.h:662
Z_OtherInformation * otherInfo
Definition z-core.h:679
Z_OtherInformation * otherInfo
Definition z-core.h:953
Z_OtherInformation * otherInfo
Definition z-core.h:971
Z_OtherInformation * otherInfo
Definition z-core.h:465
Z_OtherInformation * otherInfo
Definition z-core.h:637
Z_OtherInformation * otherInfo
Definition z-core.h:1041
Z_OtherInformation * otherInfo
Definition z-core.h:1058
Definition odr.h:125
#define Z_APDU_initRequest
Definition z-core.h:349
#define Z_APDU_scanRequest
Definition z-core.h:364
#define Z_APDU_presentResponse
Definition z-core.h:354
#define Z_APDU_sortResponse
Definition z-core.h:367
#define Z_APDU_presentRequest
Definition z-core.h:353
#define Z_APDU_duplicateDetectionResponse
Definition z-core.h:373
#define Z_APDU_extendedServicesResponse
Definition z-core.h:370
#define Z_APDU_searchRequest
Definition z-core.h:351
#define Z_APDU_deleteResultSetResponse
Definition z-core.h:356
#define Z_APDU_initResponse
Definition z-core.h:350
#define Z_APDU_duplicateDetectionRequest
Definition z-core.h:372
#define Z_OtherInfo_characterInfo
Definition z-core.h:1287
#define Z_APDU_scanResponse
Definition z-core.h:365
#define Z_APDU_sortRequest
Definition z-core.h:366
#define Z_APDU_deleteResultSetRequest
Definition z-core.h:355
#define Z_APDU_searchResponse
Definition z-core.h:352
#define Z_APDU_extendedServicesRequest
Definition z-core.h:369