From: Adam Dickmeiss Date: Tue, 20 Mar 2007 07:54:11 +0000 (+0000) Subject: WRBUF updates X-Git-Tag: YAZPP.1.0.3~9 X-Git-Url: http://git.indexdata.com/?p=yazpp-moved-to-github.git;a=commitdiff_plain;h=b68803f07a763804a784806082f484cb0c8b531a WRBUF updates --- diff --git a/configure.ac b/configure.ac index f27b206..763a245 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ dnl YAZ++ Toolkit, Index Data 1994-2006 dnl See the file LICENSE for details. -dnl $Id: configure.ac,v 1.13 2007-01-25 18:36:48 adam Exp $ +dnl $Id: configure.ac,v 1.14 2007-03-20 07:54:11 adam Exp $ AC_PREREQ(2.59) AC_INIT([yazpp],[1.0.2],[adam@indexdata.dk]) AC_CONFIG_SRCDIR(configure.ac) @@ -13,7 +13,7 @@ AC_PROG_CXX AC_HEADER_STDC AM_PROG_LIBTOOL -YAZ_INIT(threads,2.1.23) +YAZ_INIT(threads,2.1.50) if test -z "$YAZLIB"; then AC_MSG_ERROR([YAZ development libraries missing]) fi diff --git a/include/yazpp/query.h b/include/yazpp/query.h index 695d007..8d4298c 100644 --- a/include/yazpp/query.h +++ b/include/yazpp/query.h @@ -2,12 +2,13 @@ * Copyright (c) 1998-2005, Index Data. * See the file LICENSE for details. * - * $Id: query.h,v 1.1 2006-03-29 13:14:15 adam Exp $ + * $Id: query.h,v 1.2 2007-03-20 07:54:11 adam Exp $ */ #ifndef YAZ_PP_QUERY_H #define YAZ_PP_QUERY_H +#include #include namespace yazpp_1 { @@ -17,7 +18,7 @@ namespace yazpp_1 { class YAZ_EXPORT Yaz_Query { public: /// Print query in buffer described by str and len - virtual void print (char *str, int len) = 0; + virtual void print (char *str, size_t len) = 0; virtual ~Yaz_Query(); }; }; diff --git a/include/yazpp/z-query.h b/include/yazpp/z-query.h index 3e792a6..a2490b4 100644 --- a/include/yazpp/z-query.h +++ b/include/yazpp/z-query.h @@ -2,7 +2,7 @@ * Copyright (c) 1998-2005, Index Data. * See the file LICENSE for details. * - * $Id: z-query.h,v 1.2 2006-06-19 13:12:06 adam Exp $ + * $Id: z-query.h,v 1.3 2007-03-20 07:54:11 adam Exp $ */ #ifndef YAZPP_Z_QUERY_INCLUDED @@ -30,7 +30,7 @@ class YAZ_EXPORT Yaz_Z_Query : public Yaz_Query { /// Get Z Query Z_Query *get_Z_Query (); /// print query - void print(char *str, int len); + void print(char *str, size_t len); /// match query int match(const Yaz_Z_Query *other); /// Copy @@ -43,7 +43,6 @@ class YAZ_EXPORT Yaz_Z_Query : public Yaz_Query { ODR odr_decode; ODR odr_encode; ODR odr_print; - WRBUF zquery2pquery(Z_Query *q); }; }; #endif diff --git a/src/yaz-cql2rpn.cpp b/src/yaz-cql2rpn.cpp index 777c818..2354b8b 100644 --- a/src/yaz-cql2rpn.cpp +++ b/src/yaz-cql2rpn.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2004, Index Data. * See the file LICENSE for details. * - * $Id: yaz-cql2rpn.cpp,v 1.13 2007-01-16 11:54:55 adam Exp $ + * $Id: yaz-cql2rpn.cpp,v 1.14 2007-03-20 07:54:11 adam Exp $ */ #include @@ -65,7 +65,7 @@ int Yaz_cql2rpn::query_transform(const char *cql_query, { size_t off; const char *pqf_msg; - int code = yaz_pqf_error(pp, &pqf_msg, &off); + yaz_pqf_error(pp, &pqf_msg, &off); r = -1; } yaz_pqf_destroy(pp); diff --git a/src/yaz-my-client.cpp b/src/yaz-my-client.cpp index 3336587..b21442a 100644 --- a/src/yaz-my-client.cpp +++ b/src/yaz-my-client.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2004, Index Data. * See the file LICENSE for details. * - * $Id: yaz-my-client.cpp,v 1.24 2006-10-10 13:31:49 adam Exp $ + * $Id: yaz-my-client.cpp,v 1.25 2007-03-20 07:54:11 adam Exp $ */ #include @@ -327,6 +327,7 @@ void MyClient::recv_record(Z_DatabaseRecord *record, int offset, } if (r->which == Z_External_octet && record->u.octet_aligned->len) { + yaz_marc_t mt = yaz_marc_create(); switch (ent->value) { case VAL_ISO2709: @@ -351,13 +352,20 @@ void MyClient::recv_record(Z_DatabaseRecord *record, int offset, case VAL_SIGLEMARC: case VAL_ISDSMARC: case VAL_RUSMARC: - marc_display((char*) record->u.octet_aligned->buf,0); + const char *result_buf; + size_t result_size; + yaz_marc_decode_buf(mt, (const char *) + record->u.octet_aligned->buf, + record->u.octet_aligned->len, + &result_buf, &result_size); + fwrite(result_buf, 1, result_size, stdout); break; default: recv_textRecord((int) ent->value, (const char *) record->u.octet_aligned->buf, (size_t) record->u.octet_aligned->len); } + yaz_marc_destroy(mt); } else if (ent && ent->value == VAL_SUTRS && r->which == Z_External_sutrs) recv_textRecord((int) VAL_SUTRS, (const char *) r->u.sutrs->buf, diff --git a/src/yaz-z-query.cpp b/src/yaz-z-query.cpp index f149b38..85d496a 100644 --- a/src/yaz-z-query.cpp +++ b/src/yaz-z-query.cpp @@ -1,11 +1,11 @@ /* - * Copyright (c) 1998-2005, Index Data. + * Copyright (c) 1998-2007, Index Data. * See the file LICENSE for details. * - * $Id: yaz-z-query.cpp,v 1.20 2006-06-19 13:12:07 adam Exp $ + * $Id: yaz-z-query.cpp,v 1.21 2007-03-20 07:54:11 adam Exp $ */ -#include +#include #include #include #include @@ -101,7 +101,7 @@ Z_Query *Yaz_Z_Query::get_Z_Query() return query; } -void Yaz_Z_Query::print(char *str, int len) +void Yaz_Z_Query::print(char *str, size_t len) { Z_Query *query; *str = 0; @@ -110,18 +110,16 @@ void Yaz_Z_Query::print(char *str, int len) odr_setbuf(odr_decode, m_buf, m_len, 0); if (!z_Query(odr_decode, &query, 0, 0)) return; - WRBUF wbuf = zquery2pquery(query); - if (wbuf) + WRBUF wbuf = wrbuf_alloc(); + yaz_query_to_wrbuf(wbuf, query); + if (wrbuf_len(wbuf) > len-1) { - if (wrbuf_len(wbuf) > len-1) - { - memcpy(str, wrbuf_buf(wbuf), len-1); - str[len-1] = '\0'; - } - else - strcpy(str, wrbuf_buf(wbuf)); - wrbuf_free(wbuf,1); + memcpy(str, wrbuf_buf(wbuf), len-1); + str[len-1] = '\0'; } + else + strcpy(str, wrbuf_cstr(wbuf)); + wrbuf_destroy(wbuf); odr_reset(odr_decode); } @@ -136,13 +134,6 @@ int Yaz_Z_Query::match(const Yaz_Z_Query *other) return 1; } -WRBUF Yaz_Z_Query::zquery2pquery(Z_Query *q) -{ - WRBUF w = wrbuf_alloc(); - wrbuf_put_zquery(w, q); - return w; -} - /* * Local variables: * c-basic-offset: 4