Bump copyright year
[yaz-moved-to-github.git] / src / elementset.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 1995-2010 Index Data
3  * See the file LICENSE for details.
4  */
5 /**
6  * \file elementset.c
7  * \brief Z39.50 element set utilities
8  */
9
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 ==
23                 Z_ElementSpec_elementSetName))
24             return comp->u.complex->generic->elementSpec->u.elementSetName;
25     }
26     else if (comp && comp->which == Z_RecordComp_simple &&
27              comp->u.simple->which == Z_ElementSetNames_generic)
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 {
34     Z_RecordComposition *comp = (Z_RecordComposition *)
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));
40     comp->u.simple->which = Z_ElementSetNames_generic;
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