YAZ  5.23.1
elementset.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  */
10 #if HAVE_CONFIG_H
11 #include <config.h>
12 #endif
13 
14 #include <yaz/proto.h>
15 
16 const char *yaz_get_esn(Z_RecordComposition *comp)
17 {
18  if (comp && comp->which == Z_RecordComp_complex)
19  {
20  if (comp->u.complex->generic
21  && comp->u.complex->generic->elementSpec
22  && (comp->u.complex->generic->elementSpec->which ==
24  return comp->u.complex->generic->elementSpec->u.elementSetName;
25  }
26  else if (comp && comp->which == Z_RecordComp_simple &&
28  return comp->u.simple->u.generic;
29  return 0;
30 }
31 
32 void yaz_set_esn(Z_RecordComposition **comp_p, const char *esn, NMEM nmem)
33 {
35  nmem_malloc(nmem, sizeof(*comp));
36 
37  comp->which = Z_RecordComp_simple;
38  comp->u.simple = (Z_ElementSetNames *)
39  nmem_malloc(nmem, sizeof(*comp->u.simple));
41  comp->u.simple->u.generic = nmem_strdup(nmem, esn);
42  *comp_p = comp;
43 }
44 
45 
46 
47 /*
48  * Local variables:
49  * c-basic-offset: 4
50  * c-file-style: "Stroustrup"
51  * indent-tabs-mode: nil
52  * End:
53  * vim: shiftwidth=4 tabstop=8 expandtab
54  */
55 
union Z_ElementSetNames::@61 u
Z_InternationalString * generic
Definition: z-core.h:771
#define Z_ElementSetNames_generic
Definition: z-core.h:773
const char * yaz_get_esn(Z_RecordComposition *comp)
get element set name from RecordComposition
Definition: elementset.c:16
void * nmem_malloc(NMEM n, size_t size)
allocates memory block on NMEM handle
Definition: nmem.c:145
Z_ElementSpec * elementSpec
Definition: z-core.h:817
#define Z_RecordComp_simple
Definition: z-core.h:645
#define Z_RecordComp_complex
Definition: z-core.h:646
Z_Specification * generic
Definition: z-core.h:792
Header for Z39.50 Protocol.
char * nmem_strdup(NMEM mem, const char *src)
allocates string on NMEM handle (similar strdup)
Definition: nmemsdup.c:18
#define Z_ElementSpec_elementSetName
Definition: z-core.h:804
Z_ElementSetNames * simple
Definition: z-core.h:643
void yaz_set_esn(Z_RecordComposition **comp_p, const char *esn, NMEM nmem)
set element set name in RecordComposition struct
Definition: elementset.c:32
union Z_ElementSpec::@62 u
Z_InternationalString * elementSetName
Definition: z-core.h:802
union Z_RecordComposition::@55 u
Z_CompSpec * complex
Definition: z-core.h:644