wrbuf_puts no longer appends '\0'. Use wrbuf_cstr to get C-string out.
Deprecated functions for yaz_marc-removed.
Changed prototype of yaz_marc_decode_buf: const char for result and size_t
for rsize.
+API changes to WRBUF. wrbuf_free removed; replaced by wrbuf_destroy. And
+wrbuf_puts no longer appends '\0'. Use wrbuf_cstr to get C-string out.
+
+Deprecated functions for yaz_marc-removed.
+
+Changed prototype of yaz_marc_decode_buf: const char for result and size_t
+for rsize.
+
Branch split: YAZ_2_1_55_branch
--- 2.1.54 2007/03/16
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: client.c,v 1.328 2007-03-14 11:46:37 adam Exp $
+ * $Id: client.c,v 1.329 2007-03-19 14:40:06 adam Exp $
*/
/** \file client.c
* \brief yaz-client program
#endif
)
{
- char *result;
- int rlen;
+ const char *result;
+ size_t rlen;
yaz_iconv_t cd = 0;
yaz_marc_t mt = yaz_marc_create();
const char *from = 0;
}
}
- if (yaz_marc_decode_buf(mt, octet_buf,r->u.octet_aligned->len,
+ if (yaz_marc_decode_buf(mt, octet_buf, r->u.octet_aligned->len,
&result, &rlen)> 0)
{
fwrite (result, rlen, 1, stdout);
w = wrbuf_alloc();
yaz_display_grs1(w, r->u.grs1, 0);
puts (wrbuf_buf(w));
- wrbuf_free(w, 1);
+ wrbuf_destroy(w);
}
else if (ent && ent->value == VAL_OPAC)
{
cd = yaz_iconv_open("UTF-8", in_charset);
if (!cd)
{
- wrbuf_free(w, 1);
+ wrbuf_destroy(w);
return odr_strdup(o, q);
}
wrbuf_iconv_write(w, cd, q, strlen(q));
else
res = odr_strdup(o, q);
yaz_iconv_close(cd);
- wrbuf_free(w, 1);
+ wrbuf_destroy(w);
return res;
}
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* $Id: marcdisp.h,v 1.27 2007-01-24 15:13:20 adam Exp $ */
+/* $Id: marcdisp.h,v 1.28 2007-03-19 14:40:06 adam Exp $ */
/**
* \file marcdisp.h
Returns -1 on error, or size of input record (>0) if OK
*/
YAZ_EXPORT int yaz_marc_decode_buf(yaz_marc_t mt, const char *buf, int bsize,
- char **result, int *rsize);
+ const char **result, size_t *rsize);
/** \brief decodes ISO2709/MARC buffer and stores result in WRBUF
\param mt handle
YAZ_EXPORT int yaz_marc_decode_wrbuf(yaz_marc_t mt, const char *buf,
int bsize, WRBUF wrbuf);
-/** \brief depricated */
-YAZ_EXPORT int marc_display(const char *buf, FILE *outf);
-/** \brief depricated */
-YAZ_EXPORT int marc_display_ex(const char *buf, FILE *outf, int debug);
-/** \brief depricated */
-YAZ_EXPORT int marc_display_exl(const char *buf, FILE *outf, int debug,
- int length);
-/** \brief depricated */
-YAZ_EXPORT int marc_display_wrbuf(const char *buf, WRBUF wr, int debug,
- int bsize);
-/** \brief depricated */
-YAZ_EXPORT int yaz_marc_decode(const char *buf, WRBUF wr,
- int debug, int bsize, int xml);
-
YAZ_EXPORT void yaz_marc_subfield_str(yaz_marc_t mt, const char *s);
YAZ_EXPORT void yaz_marc_endline_str(yaz_marc_t mt, const char *s);
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* $Id: wrbuf.h,v 1.24 2007-03-18 12:59:56 adam Exp $ */
+/* $Id: wrbuf.h,v 1.25 2007-03-19 14:40:06 adam Exp $ */
/**
* \file wrbuf.h
typedef struct wrbuf
{
char *buf;
- int pos;
- int size;
+ size_t pos;
+ size_t size;
} wrbuf, *WRBUF;
/** \brief allocate / construct WRBUF */
YAZ_EXPORT WRBUF wrbuf_alloc(void);
-/** \brief free WRBUF and possibly its buffer */
-YAZ_EXPORT void wrbuf_free(WRBUF b, int free_buf);
-
/** \brief destroy WRBUF and its buffer */
YAZ_EXPORT void wrbuf_destroy(WRBUF b);
/* CCL print rpn tree - infix notation
* Europagate, 1995
*
- * $Id: cclptree.c,v 1.6 2005-06-25 15:46:03 adam Exp $
+ * $Id: cclptree.c,v 1.7 2007-03-19 14:40:07 adam Exp $
*
* Old Europagate Log:
*
wrbuf_puts (w, " ");
break;
}
+ wrbuf_cstr(w);
}
/*
* Local variables:
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: marcdisp.c,v 1.47 2007-02-23 10:15:01 adam Exp $
+ * $Id: marcdisp.c,v 1.48 2007-03-19 14:40:07 adam Exp $
*/
/**
if (!mt)
return ;
nmem_destroy(mt->nmem);
- wrbuf_free(mt->m_wr, 1);
+ wrbuf_destroy(mt->m_wr);
xfree(mt->leader_spec);
xfree(mt);
}
wrbuf_write(wr, wrbuf_buf(wr_head), 24);
wrbuf_write(wr, wrbuf_buf(wr_dir), wrbuf_len(wr_dir));
- wrbuf_free(wr_head, 1);
- wrbuf_free(wr_dir, 1);
- wrbuf_free(wr_data_tmp, 1);
+ wrbuf_destroy(wr_head);
+ wrbuf_destroy(wr_dir);
+ wrbuf_destroy(wr_data_tmp);
for (n = mt->nodes; n; n = n->next)
{
}
int yaz_marc_decode_buf (yaz_marc_t mt, const char *buf, int bsize,
- char **result, int *rsize)
+ const char **result, size_t *rsize)
{
int r;
wrbuf_rewind(mt->m_wr);
r = yaz_marc_decode_wrbuf(mt, buf, bsize, mt->m_wr);
if (result)
- *result = wrbuf_buf(mt->m_wr);
+ *result = wrbuf_cstr(mt->m_wr);
if (rsize)
*rsize = wrbuf_len(mt->m_wr);
return r;
}
}
-/* deprecated */
-int yaz_marc_decode(const char *buf, WRBUF wr, int debug, int bsize, int xml)
-{
- yaz_marc_t mt = yaz_marc_create();
- int r;
-
- mt->debug = debug;
- mt->xml = xml;
- r = yaz_marc_decode_wrbuf(mt, buf, bsize, wr);
- yaz_marc_destroy(mt);
- return r;
-}
-
-/* deprecated */
-int marc_display_wrbuf (const char *buf, WRBUF wr, int debug, int bsize)
-{
- return yaz_marc_decode(buf, wr, debug, bsize, 0);
-}
-
-/* deprecated */
-int marc_display_exl (const char *buf, FILE *outf, int debug, int bsize)
-{
- yaz_marc_t mt = yaz_marc_create();
- int r;
-
- mt->debug = debug;
- r = yaz_marc_decode_wrbuf (mt, buf, bsize, mt->m_wr);
- if (!outf)
- outf = stdout;
- if (r > 0)
- fwrite (wrbuf_buf(mt->m_wr), 1, wrbuf_len(mt->m_wr), outf);
- yaz_marc_destroy(mt);
- return r;
-}
-
-/* deprecated */
-int marc_display_ex (const char *buf, FILE *outf, int debug)
-{
- return marc_display_exl (buf, outf, debug, -1);
-}
-
-/* deprecated */
-int marc_display (const char *buf, FILE *outf)
-{
- return marc_display_ex (buf, outf, 0);
-}
-
int yaz_marc_leader_spec(yaz_marc_t mt, const char *leader_spec)
{
xfree(mt->leader_spec);
* Copyright (C) 1995-2007, Index Data ApS
* All rights reserved.
*
- * $Id: querytowrbuf.c,v 1.6 2007-01-03 08:42:15 adam Exp $
+ * $Id: querytowrbuf.c,v 1.7 2007-03-19 14:40:07 adam Exp $
*/
/** \file querytowrbuf.c
void wrbuf_scan_term(WRBUF b, const Z_AttributesPlusTerm *zapt, oid_value ast)
{
yaz_apt_to_wrbuf(b, zapt);
+ wrbuf_cstr(b);
}
/* obsolete */
void wrbuf_put_zquery(WRBUF b, const Z_Query *q)
{
yaz_query_to_wrbuf(b, q);
+ wrbuf_cstr(b);
}
* Copyright (C) 2005-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: record_conv.c,v 1.14 2007-01-03 08:42:15 adam Exp $
+ * $Id: record_conv.c,v 1.15 2007-03-19 14:40:07 adam Exp $
*/
/**
* \file record_conv.c
{
yaz_record_conv_reset(p);
nmem_destroy(p->nmem);
- wrbuf_free(p->wr_error, 1);
+ wrbuf_destroy(p->wr_error);
xfree(p->path);
xfree(p);
}
const char *yaz_record_conv_get_error(yaz_record_conv_t p)
{
- return wrbuf_buf(p->wr_error);
+ return wrbuf_cstr(p->wr_error);
}
void yaz_record_conv_set_path(yaz_record_conv_t p, const char *path)
* Copyright (C) 2005-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: retrieval.c,v 1.16 2007-02-04 02:24:56 quinn Exp $
+ * $Id: retrieval.c,v 1.17 2007-03-19 14:40:07 adam Exp $
*/
/**
* \file retrieval.c
{
yaz_retrieval_reset(p);
odr_destroy(p->odr);
- wrbuf_free(p->wr_error, 1);
+ wrbuf_destroy(p->wr_error);
xfree(p->path);
xfree(p);
}
const char *yaz_retrieval_get_error(yaz_retrieval_t p)
{
- return wrbuf_buf(p->wr_error);
+ return wrbuf_cstr(p->wr_error);
}
void yaz_retrieval_set_path(yaz_retrieval_t p, const char *path)
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: seshigh.c,v 1.111 2007-03-13 09:12:09 adam Exp $
+ * $Id: seshigh.c,v 1.112 2007-03-19 14:40:07 adam Exp $
*/
/**
* \file seshigh.c
rr->record = odr_malloc(rr->stream, rr->len);
memcpy(rr->record, wrbuf_buf(output_record), rr->len);
}
- wrbuf_free(output_record, 1);
+ wrbuf_destroy(output_record);
}
if (match_syntax)
{
srw_res->resultSetId : "-"),
(srw_req->startRecord ? *srw_req->startRecord : 1),
srw_res->num_records);
- yaz_log(log_request, "%s %s: %s", wrbuf_buf(wr), querytype, querystr);
- wrbuf_free(wr, 1);
+ yaz_log(log_request, "%s %s: %s", wrbuf_cstr(wr), querytype, querystr);
+ wrbuf_destroy(wr);
}
}
*srw_req->maximumTerms : 1));
/* there is no step size in SRU/W ??? */
wrbuf_printf(wr, "%s: %s ", querytype, querystr);
- yaz_log(log_request, "%s ", wrbuf_buf(wr) );
- wrbuf_free(wr, 1);
+ yaz_log(log_request, "%s ", wrbuf_cstr(wr) );
+ wrbuf_destroy(wr);
}
}
assoc->init->implementation_name,
odr_prepend(assoc->encode, "GFS", resp->implementationName));
- version = odr_strdup(assoc->encode, "$Revision: 1.111 $");
+ version = odr_strdup(assoc->encode, "$Revision: 1.112 $");
if (strlen(version) > 10) /* check for unexpanded CVS strings */
version[strlen(version)-2] = '\0';
resp->implementationVersion = odr_prepend(assoc->encode,
(req->implementationVersion ?
req->implementationVersion : "-")
);
- yaz_log(log_request, "%s", wrbuf_buf(wr));
- wrbuf_free(wr, 1);
+ yaz_log(log_request, "%s", wrbuf_cstr(wr));
+ wrbuf_destroy(wr);
}
return apdu;
}
req->resultSetName, returnedrecs);
yaz_query_to_wrbuf(wr, req->query);
- yaz_log(log_request, "Search %s", wrbuf_buf(wr));
- wrbuf_free(wr, 1);
+ yaz_log(log_request, "Search %s", wrbuf_cstr(wr));
+ wrbuf_destroy(wr);
}
return apdu;
}
wrbuf_printf(wr, " %s %d+%d ",
req->resultSetId, *req->resultSetStartPoint,
*req->numberOfRecordsRequested);
- yaz_log(log_request, "%s", wrbuf_buf(wr) );
- wrbuf_free(wr, 1);
+ yaz_log(log_request, "%s", wrbuf_cstr(wr) );
+ wrbuf_destroy(wr);
}
if (!resp->records)
return 0;
yaz_scan_to_wrbuf(wr, req->termListAndStartPoint,
bsrr->attributeset);
- yaz_log(log_request, "%s", wrbuf_buf(wr) );
- wrbuf_free(wr, 1);
+ yaz_log(log_request, "%s", wrbuf_cstr(wr) );
+ wrbuf_destroy(wr);
}
return apdu;
}
}
wrbuf_printf(wr, ")->%s ",req->sortedResultSetName);
- yaz_log(log_request, "%s", wrbuf_buf(wr) );
- wrbuf_free(wr, 1);
+ yaz_log(log_request, "%s", wrbuf_cstr(wr) );
+ wrbuf_destroy(wr);
}
return apdu;
}
wrbuf_printf(wr, "OK -");
for (i = 0; i<req->num_resultSetList; i++)
wrbuf_printf(wr, " %s ", req->resultSetList[i]);
- yaz_log(log_request, "%s", wrbuf_buf(wr) );
- wrbuf_free(wr, 1);
+ yaz_log(log_request, "%s", wrbuf_cstr(wr) );
+ wrbuf_destroy(wr);
}
return apdu;
}
{
WRBUF wr = wrbuf_alloc();
wrbuf_diags(wr, resp->num_diagnostics, resp->diagnostics);
- yaz_log(log_request, "EsRequest %s", wrbuf_buf(wr) );
- wrbuf_free(wr, 1);
+ yaz_log(log_request, "EsRequest %s", wrbuf_cstr(wr) );
+ wrbuf_destroy(wr);
}
}
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: wrbuf.c,v 1.17 2007-03-18 12:59:56 adam Exp $
+ * $Id: wrbuf.c,v 1.18 2007-03-19 14:40:07 adam Exp $
*/
/**
return n;
}
-void wrbuf_free(WRBUF b, int free_buf)
-{
- if (free_buf && b->buf)
- xfree(b->buf);
- xfree(b);
-}
-
void wrbuf_destroy(WRBUF b)
{
- wrbuf_free(b, 1);
+ xfree(b->buf);
+ xfree(b);
}
void wrbuf_rewind(WRBUF b)
int wrbuf_puts(WRBUF b, const char *buf)
{
- wrbuf_write(b, buf, strlen(buf)+1); /* '\0'-terminate as well */
- (b->pos)--; /* don't include '\0' in count */
+ wrbuf_write(b, buf, strlen(buf));
return 0;
}
int wrbuf_puts_replace_char(WRBUF b, const char *buf,
const char from, const char to)
{
- while(*buf){
+ while(*buf)
+ {
if (*buf == from)
wrbuf_putc(b, to);
else
wrbuf_putc(b, *buf);
buf++;
}
- wrbuf_putc(b, 0);
- (b->pos)--; /* don't include '\0' in count */
return 0;
}
while (b->pos && b->buf[b->pos-1] == ' ')
{
(b->pos)--;
- b->buf[b->pos] = '\0';
}
}
}
cp++;
}
- wrbuf_putc(b, 0);
- (b->pos)--;
return 0;
}
const char *wrbuf_cstr(WRBUF b)
{
- wrbuf_write(b, "", 1); /* '\0'-terminate as well */
- (b->pos)--; /* don't include '\0' in count */
+ wrbuf_putc(b, '\0'); /* add '\0' */
+ (b->pos)--; /* don't include '\0' in count */
return b->buf;
}
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: yaz-ccl.c,v 1.5 2007-01-03 08:42:15 adam Exp $
+ * $Id: yaz-ccl.c,v 1.6 2007-03-19 14:40:07 adam Exp $
*/
/**
* \file yaz-ccl.c
ccl_pquery(wr, p);
- q = yaz_pqf_parse(parser, o, wrbuf_buf(wr));
+ q = yaz_pqf_parse(parser, o, wrbuf_cstr(wr));
- wrbuf_free(wr, 1);
+ wrbuf_destroy(wr);
yaz_pqf_destroy(parser);
return q;
}
ccl_pquery(wr, p);
- q = yaz_pqf_scan(parser, o, &setp, wrbuf_buf(wr));
+ q = yaz_pqf_scan(parser, o, &setp, wrbuf_cstr(wr));
- wrbuf_free(wr, 1);
+ wrbuf_destroy(wr);
yaz_pqf_destroy(parser);
return q;
}
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: zoom-c.c,v 1.116 2007-03-12 08:27:44 adam Exp $
+ * $Id: zoom-c.c,v 1.117 2007-03-19 14:40:07 adam Exp $
*/
/**
* \file zoom-c.c
WRBUF wr = wrbuf_alloc();
ccl_pquery(wr, rpn);
ccl_rpn_delete(rpn);
- ret = ZOOM_query_prefix(s, wrbuf_buf(wr));
- wrbuf_free(wr, 1);
+ ret = ZOOM_query_prefix(s, wrbuf_cstr(wr));
+ wrbuf_destroy(wr);
}
ccl_qual_rm(&bibset);
return ret;
for (rc = r->record_hash[i]; rc; rc = rc->next)
{
if (rc->rec.wrbuf_marc)
- wrbuf_free(rc->rec.wrbuf_marc, 1);
+ wrbuf_destroy(rc->rec.wrbuf_marc);
if (rc->rec.wrbuf_iconv)
- wrbuf_free(rc->rec.wrbuf_iconv, 1);
+ wrbuf_destroy(rc->rec.wrbuf_iconv);
if (rc->rec.wrbuf_opac)
- wrbuf_free(rc->rec.wrbuf_opac, 1);
+ wrbuf_destroy(rc->rec.wrbuf_opac);
}
r->record_hash[i] = 0;
}
odr_prepend(c->odr_out, "ZOOM-C",
ireq->implementationName));
- version = odr_strdup(c->odr_out, "$Revision: 1.116 $");
+ version = odr_strdup(c->odr_out, "$Revision: 1.117 $");
if (strlen(version) > 10) /* check for unexpanded CVS strings */
version[strlen(version)-2] = '\0';
ireq->implementationVersion =
if (!rec)
return;
if (rec->wrbuf_marc)
- wrbuf_free(rec->wrbuf_marc, 1);
+ wrbuf_destroy(rec->wrbuf_marc);
if (rec->wrbuf_iconv)
- wrbuf_free(rec->wrbuf_iconv, 1);
+ wrbuf_destroy(rec->wrbuf_iconv);
if (rec->wrbuf_opac)
- wrbuf_free(rec->wrbuf_opac, 1);
+ wrbuf_destroy(rec->wrbuf_opac);
odr_destroy(rec->odr);
xfree(rec);
}
yaz_iconv_close(cd);
if (len)
*len = wrbuf_len(rec->wrbuf_marc);
- return wrbuf_buf(rec->wrbuf_marc);
+ return wrbuf_cstr(rec->wrbuf_marc);
}
yaz_marc_destroy(mt);
if (cd)
}
wrbuf_write(rec->wrbuf_iconv, outbuf, outp - outbuf);
}
- wrbuf_puts(rec->wrbuf_iconv, "");
- buf = wrbuf_buf(rec->wrbuf_iconv);
+ buf = wrbuf_cstr(rec->wrbuf_iconv);
sz = wrbuf_len(rec->wrbuf_iconv);
yaz_iconv_close(cd);
}
* Copyright (C) 2005-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: tst_record_conv.c,v 1.13 2007-01-03 08:42:16 adam Exp $
+ * $Id: tst_record_conv.c,v 1.14 2007-03-19 14:40:07 adam Exp $
*
*/
#include <yaz/record_conv.h>
if (!p)
{
- if (expect_error && !strcmp(wrbuf_buf(w), expect_error))
+ if (expect_error && !strcmp(wrbuf_cstr(w), expect_error))
ret = 1;
else
{
ret = 0;
- printf("%.*s\n", wrbuf_len(w), wrbuf_buf(w));
+ printf("%s\n", wrbuf_cstr(w));
}
}
else
if (p)
yaz_record_conv_destroy(p);
- wrbuf_free(w, 1);
+ wrbuf_destroy(w);
return ret;
}
ret = 0;
printf("output_record expect-len=%d got-len=%d\n", expect_len,
wrbuf_len(output_record));
- printf("got-output_record = %.*s\n",
- wrbuf_len(output_record), wrbuf_buf(output_record));
- printf("output_expect_record = %s\n",
- output_expect_record);
+ printf("got-output_record = %s\n", wrbuf_cstr(output_record));
+ printf("output_expect_record = %s\n", output_expect_record);
}
else if (memcmp(output_expect_record, wrbuf_buf(output_record),
strlen(output_expect_record)))
{
ret = 0;
- printf("got-output_record = %.*s\n",
- wrbuf_len(output_record), wrbuf_buf(output_record));
- printf("output_expect_record = %s\n",
- output_expect_record);
+ printf("got-output_record = %s\n", wrbuf_cstr(output_record));
+ printf("output_expect_record = %s\n", output_expect_record);
}
else
{
ret = 1;
}
}
- wrbuf_free(output_record, 1);
+ wrbuf_destroy(output_record);
}
return ret;
}
* Copyright (C) 2005-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: tst_retrieval.c,v 1.9 2007-01-03 08:42:16 adam Exp $
+ * $Id: tst_retrieval.c,v 1.10 2007-03-19 14:40:07 adam Exp $
*
*/
#include <yaz/retrieval.h>
if (!p)
{
- if (expect_error && !strcmp(wrbuf_buf(w), expect_error))
+ if (expect_error && !strcmp(wrbuf_cstr(w), expect_error))
ret = 1;
else
{
ret = 0;
- printf("%.*s\n", wrbuf_len(w), wrbuf_buf(w));
+ printf("%s\n", wrbuf_cstr(w));
}
}
else
ret = 1;
}
}
- wrbuf_free(w, 1);
+ wrbuf_destroy(w);
return ret;
}
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: tstccl.c,v 1.13 2007-01-08 10:48:07 adam Exp $
+ * $Id: tstccl.c,v 1.14 2007-03-19 14:40:07 adam Exp $
*/
/* CCL test */
else
ret = 0;
ccl_rpn_delete(rpn);
- wrbuf_free(wrbuf, 1);
+ wrbuf_destroy(wrbuf);
}
else
{
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: tsticonv.c,v 1.27 2007-03-17 00:10:41 adam Exp $
+ * $Id: tsticonv.c,v 1.28 2007-03-19 14:40:07 adam Exp $
*/
#if HAVE_CONFIG_H
ret = 1;
else
yaz_log(YLOG_LOG, "GOT (%.*s)", wrbuf_len(b), wrbuf_buf(b));
- wrbuf_free(b, 1);
+ wrbuf_destroy(b);
return ret;
}
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: tstpquery.c,v 1.4 2007-01-03 08:42:16 adam Exp $
+ * $Id: tstpquery.c,v 1.5 2007-03-19 14:40:07 adam Exp $
*/
#include <stdlib.h>
{
yaz_rpnquery_to_wrbuf(wrbuf, rpn);
- if (!strcmp(wrbuf_buf(wrbuf), expect_pqf))
+ if (!strcmp(wrbuf_cstr(wrbuf), expect_pqf))
res = 1;
- wrbuf_free(wrbuf, 1);
+ wrbuf_destroy(wrbuf);
}
}
yaz_pqf_destroy(parser);
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: tstwrbuf.c,v 1.6 2007-01-03 08:42:16 adam Exp $
+ * $Id: tstwrbuf.c,v 1.7 2007-03-19 14:40:07 adam Exp $
*/
#include <stdlib.h>
YAZ_CHECK(wr);
- wrbuf_free(wr, 1);
+ wrbuf_destroy(wr);
wr = wrbuf_alloc();
}
wrbuf_rewind(wr);
}
- wrbuf_free(wr, 1);
+ wrbuf_destroy(wr);
}
int main (int argc, char **argv)
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: tstxmlquery.c,v 1.14 2007-01-03 08:42:16 adam Exp $
+ * $Id: tstxmlquery.c,v 1.15 2007-03-19 14:40:07 adam Exp $
*/
#include <stdlib.h>
{
WRBUF w = wrbuf_alloc();
yaz_query_to_wrbuf(w, query2);
- if (!expect_pqf || strcmp(expect_pqf, wrbuf_buf(w)) == 0)
+ if (!expect_pqf || strcmp(expect_pqf, wrbuf_cstr(w)) == 0)
status = XML_MATCH;
else
{
status = XML_NO_MATCH;
printf("Result: %s\n", wrbuf_buf(w));
}
- wrbuf_free(w, 1);
+ wrbuf_destroy(w);
}
odr_destroy(odr2);
}
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: marcdump.c,v 1.50 2007-03-17 09:14:00 adam Exp $
+ * $Id: marcdump.c,v 1.51 2007-03-19 14:40:08 adam Exp $
*/
#define _FILE_OFFSET_BITS 64
{
WRBUF wrbuf = wrbuf_alloc();
yaz_marc_write_mode(mt, wrbuf);
- fputs(wrbuf_buf(wrbuf), stdout);
- wrbuf_free(wrbuf, 1);
+ fputs(wrbuf_cstr(wrbuf), stdout);
+ wrbuf_destroy(wrbuf);
}
fclose(inf);
}
{
yaz_marc_write_mode(mt, wrbuf);
- fputs(wrbuf_buf(wrbuf), stdout);
+ fputs(wrbuf_cstr(wrbuf), stdout);
}
- wrbuf_free(wrbuf, 1);
+ wrbuf_destroy(wrbuf);
}
xmlFreeDoc(doc);
}
fprintf (cfile, "char *marc_records[] = {\n");
for(;; marc_no++)
{
- char *result = 0;
+ const char *result = 0;
size_t len;
size_t rlen;
- int len_result;
+ size_t len_result;
size_t r;
char buf[100001];
fclose(sf);
}
}
- len_result = (int) rlen;
+ len_result = rlen;
r = yaz_marc_decode_buf(mt, buf, -1, &result, &len_result);
if (r > 0 && result)
{
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: yaz-xmlquery.c,v 1.6 2007-01-03 08:42:16 adam Exp $
+ * $Id: yaz-xmlquery.c,v 1.7 2007-03-19 14:40:08 adam Exp $
*/
#include <stdlib.h>
WRBUF w = wrbuf_alloc();
yaz_query_to_wrbuf(w, query);
printf("%s\n", wrbuf_buf(w));
- wrbuf_free(w, 1);
+ wrbuf_destroy(w);
}
odr_destroy(odr);
xmlFreeDoc(doc);
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: read-marc.c,v 1.8 2007-01-03 08:42:18 adam Exp $
+ * $Id: read-marc.c,v 1.9 2007-03-19 14:40:08 adam Exp $
*/
/*
char *dummy_xml_record (int num, ODR odr)
{
yaz_marc_t mt = yaz_marc_create();
- char *result;
- int rlen;
+ const char *result;
+ size_t rlen;
char *rec = dummy_marc_record (num, odr);
int len;
yaz_marc_xml(mt, YAZ_MARC_MARCXML);
len = yaz_marc_decode_buf (mt, rec, -1, &result, &rlen);
if (len > 1)
- rec = (char *) odr_strdup(odr, result);
+ {
+ rec = odr_malloc(odr, rlen+1);
+ memcpy(rec, result, rlen);
+ rec[rlen] = '\0';
+ }
yaz_marc_destroy(mt);
return rec;
}