From: Adam Dickmeiss Date: Tue, 14 Nov 2006 08:48:26 +0000 (+0000) Subject: Added utilities yaz_{set,get}_esn X-Git-Tag: YAZ.2.1.40~3 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=df2adb23954e8ad27dac8e234ee9206c5d980dd9 Added utilities yaz_{set,get}_esn --- diff --git a/src/elementset.c b/src/elementset.c new file mode 100644 index 0000000..173bc0f --- /dev/null +++ b/src/elementset.c @@ -0,0 +1,54 @@ +/* + * Copyright (C) 1995-2006, Index Data ApS + * See the file LICENSE for details. + * + * $Id: elementset.c,v 1.1 2006-11-14 08:48:26 adam Exp $ + */ +/** + * \file tpath.c + * \brief File Path utilities + */ + +#if HAVE_CONFIG_H +#include +#endif + +#include + +const char *yaz_get_esn(Z_RecordComposition *comp) +{ + if (comp && comp->which == Z_RecordComp_complex) + { + if (comp->u.complex->generic + && comp->u.complex->generic->elementSpec + && (comp->u.complex->generic->elementSpec->which == + Z_ElementSpec_elementSetName)) + return comp->u.complex->generic->elementSpec->u.elementSetName; + } + else if (comp && comp->which == Z_RecordComp_simple && + comp->u.simple->which == Z_ElementSetNames_generic) + return comp->u.simple->u.generic; + return 0; +} + +void yaz_set_esn(Z_RecordComposition **comp_p, const char *esn, NMEM nmem) +{ + Z_RecordComposition *comp = nmem_malloc(nmem, sizeof(*comp)); + + comp->which = Z_RecordComp_simple; + comp->u.simple = nmem_malloc(nmem, sizeof(*comp->u.simple)); + comp->u.simple->which = Z_ElementSetNames_generic; + comp->u.simple->u.generic = nmem_strdup(nmem, esn); + *comp_p = comp; +} + + + +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +