Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## This file is part of the YAZ toolkit.
## Copyright (C) Index Data

YAZ_VERSION_INFO=6:1:1
YAZ_VERSION_INFO=7:0:2

bin_SCRIPTS = yaz-asncomp yaz-config

Expand Down Expand Up @@ -113,7 +113,7 @@ libyaz_la_SOURCES= $(GEN_FILES) \
marc_read_json.c marc_read_xml.c marc_read_iso2709.c marc_read_line.c \
marc_read_sax.c \
wrbuf.c wrbuf_sha1.c malloc_info.c oid_db.c errno.c \
nmemsdup.c xmalloc.c readconf.c tpath.c nmem.c matchstr.c atoin.c \
nmemsdup.c nmem_xml.c xmalloc.c readconf.c tpath.c nmem.c matchstr.c atoin.c \
siconv.c iconv-p.h utf8.c ucs4.c iso5428.c advancegreek.c \
odr_bool.c ber_bool.c ber_len.c ber_tag.c odr_util.c facet.c \
odr_null.c ber_null.c odr_int.c ber_int.c odr_tag.c odr_cons.c \
Expand Down Expand Up @@ -153,7 +153,7 @@ libyaz_la_SOURCES= $(GEN_FILES) \
libyaz_la_LDFLAGS=-version-info $(YAZ_VERSION_INFO)

libyaz_server_la_SOURCES = statserv.c seshigh.c eventl.c \
requestq.c eventl.h session.h
requestq.c eventl.h session.h

libyaz_server_la_LDFLAGS=-version-info $(YAZ_VERSION_INFO)

Expand Down
53 changes: 53 additions & 0 deletions src/nmem_xml.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* This file is part of the YAZ toolkit.
* Copyright (C) Index Data
* See the file LICENSE for details.
*/

/**
* \file nmem_xml.c
* \brief Implements NMEM XML utilities
*/

#if HAVE_CONFIG_H
#include <config.h>
#endif

#include <string.h>
#include <yaz/nmem_xml.h>

#if YAZ_HAVE_XML2
char *nmem_text_node_cdata(const xmlNode *ptr_cdata, NMEM nmem)
{
char *cdata;
int len = 0;
const xmlNode *ptr;

for (ptr = ptr_cdata; ptr; ptr = ptr->next)
if (ptr->type == XML_TEXT_NODE)
len += xmlStrlen(ptr->content);
cdata = (char *) nmem_malloc(nmem, len+1);
*cdata = '\0';
for (ptr = ptr_cdata; ptr; ptr = ptr->next)
if (ptr->type == XML_TEXT_NODE)
strcat(cdata, (const char *) ptr->content);
return cdata;
}

char *nmem_from_xml_buffer(NMEM nmem, const xmlBufferPtr buf, int *ret_len)
{
int len = xmlBufferLength(buf);
if (ret_len)
*ret_len = len;
return nmem_strdupn(nmem, (const char *) xmlBufferContent(buf), len);
}
#endif

/*
* Local variables:
* c-basic-offset: 4
* c-file-style: "Stroustrup"
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab
*/

21 changes: 1 addition & 20 deletions src/nmemsdup.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#endif

#include <string.h>
#include <yaz/nmem_xml.h>
#include <yaz/nmem.h>

char *nmem_strdup(NMEM mem, const char *src)
{
Expand Down Expand Up @@ -141,25 +141,6 @@ void nmem_strsplit_escape2(NMEM nmem, const char *delim, const char *dstr,
}
}

#if YAZ_HAVE_XML2
char *nmem_text_node_cdata(const xmlNode *ptr_cdata, NMEM nmem)
{
char *cdata;
int len = 0;
const xmlNode *ptr;

for (ptr = ptr_cdata; ptr; ptr = ptr->next)
if (ptr->type == XML_TEXT_NODE)
len += xmlStrlen(ptr->content);
cdata = (char *) nmem_malloc(nmem, len+1);
*cdata = '\0';
for (ptr = ptr_cdata; ptr; ptr = ptr->next)
if (ptr->type == XML_TEXT_NODE)
strcat(cdata, (const char *) ptr->content);
return cdata;
}
#endif

/*
* Local variables:
* c-basic-offset: 4
Expand Down
4 changes: 1 addition & 3 deletions src/solr.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ static void yaz_solr_decode_result_docs(ODR o, xmlNodePtr ptr,

record->recordSchema = 0;
record->recordPacking = Z_SRW_recordPacking_XML;
record->recordData_len = xmlBufferLength(buf);
record->recordData_buf =
odr_strdupn(o, (const char *) xmlBufferContent(buf), xmlBufferLength(buf));
record->recordData_buf = nmem_from_xml_buffer(odr_getmem(o), buf, &record->recordData_len);
record->recordPosition = odr_intdup(o, start + offset + 1);

xmlBufferFree(buf);
Expand Down
6 changes: 2 additions & 4 deletions src/xml_match.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include <yaz/srw.h>
#if YAZ_HAVE_XML2
#include <yaz/nmem_xml.h>
#include "sru-p.h"

int yaz_match_xsd_element(xmlNodePtr ptr, const char *elem)
Expand Down Expand Up @@ -108,10 +109,7 @@ int yaz_match_xsd_XML_n2(xmlNodePtr ptr, const char *elem, ODR o,
xmlBufferAddHead(buf, (const xmlChar *) "<yaz_record>", -1);
xmlBufferAdd(buf, (const xmlChar *) "</yaz_record>", -1);
}
*val = odr_strdupn(o, (const char *) xmlBufferContent(buf), xmlBufferLength(buf));
if (len)
*len = xmlBufferLength(buf);

*val = nmem_from_xml_buffer(odr_getmem(o), buf, len);
xmlBufferFree(buf);

return 1;
Expand Down
4 changes: 4 additions & 0 deletions src/yaz/nmem_xml.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ YAZ_BEGIN_CDECL
#if YAZ_HAVE_XML2
/** \brief copies TEXT Libxml2 node data to NMEM */
YAZ_EXPORT char *nmem_text_node_cdata(const xmlNode *ptr, NMEM nmem);

/** \brief copies xmlBuffer data to NMEM */
YAZ_EXPORT char *nmem_from_xml_buffer(NMEM nmem, const xmlBufferPtr buf, int *len);

#endif

YAZ_END_CDECL
Expand Down
1 change: 1 addition & 0 deletions win/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ MISC_OBJS= \
$(OBJDIR)\marc_read_line.obj \
$(OBJDIR)\nmem.obj \
$(OBJDIR)\nmemsdup.obj \
$(OBJDIR)\nmem_xml.obj \
$(OBJDIR)\oid_db.obj \
$(OBJDIR)\oid_util.obj \
$(OBJDIR)\options.obj \
Expand Down