X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=util%2Fsrwtst.c;h=cd10a513ee38bc562e0601658aaa8a83e0311209;hp=35e60b4f123a93e4c90b3e1719d6a57c838207a1;hb=0c46d2e66bdeea1600e700124a81a5d0a65d349e;hpb=fc6d778b923000b5c6ad8e108b0b184178a9d33f diff --git a/util/srwtst.c b/util/srwtst.c index 35e60b4..cd10a51 100644 --- a/util/srwtst.c +++ b/util/srwtst.c @@ -1,9 +1,10 @@ -/* - * Copyright (C) 1995-2005, Index Data ApS +/* This file is part of the YAZ toolkit. + * Copyright (C) 1995-2013 Index Data * See the file LICENSE for details. - * - * $Id: srwtst.c,v 1.5 2006-07-06 10:17:55 adam Exp $ */ +#if HAVE_CONFIG_H +#include +#endif #include #include @@ -19,13 +20,11 @@ int main(int argc, char **argv) char buf[163840]; char *content_buf = buf; int content_len; - int ret; size_t no; Z_SOAP *soap_package = 0; ODR decode, encode; int debug = 0; - nmem_init(); if (argc == 2 && !strcmp(argv[1], "debug")) debug = 1; no = fread(buf, 1, sizeof(buf), stdin); @@ -37,8 +36,8 @@ int main(int argc, char **argv) decode = odr_createmem(ODR_DECODE); encode = odr_createmem(ODR_ENCODE); content_len = no; - ret = z_soap_codec(decode, &soap_package, - &content_buf, &content_len, h); + z_soap_codec(decode, &soap_package, + &content_buf, &content_len, h); if (!soap_package) { fprintf(stderr, "Decoding seriously failed\n"); @@ -50,9 +49,9 @@ int main(int argc, char **argv) if (soap_package->which == Z_SOAP_generic && soap_package->u.generic->no == 0) { - Z_SRW_PDU *sr = soap_package->u.generic->p; + Z_SRW_PDU *sr = (Z_SRW_PDU *) soap_package->u.generic->p; if (sr->which == Z_SRW_searchRetrieve_request) - { + { Z_SRW_searchRetrieveRequest *req = sr->u.request; switch(req->query_type) { @@ -77,18 +76,22 @@ int main(int argc, char **argv) { fprintf (stderr, "%d\n", i); if (res->records[i].recordData_buf) - fwrite(res->records[i].recordData_buf, 1, - res->records[i].recordData_len, stderr); + { + fprintf(stderr, "%.*s", + res->records[i].recordData_len, + res->records[i].recordData_buf); + } } } } } } - ret = z_soap_codec(encode, &soap_package, - &content_buf, &content_len, h); + z_soap_codec(encode, &soap_package, &content_buf, &content_len, h); if (content_buf && content_len) - fwrite (content_buf, content_len, 1, stdout); + { + printf("%.*s", content_len, content_buf); + } else { fprintf(stderr, "No output!\n"); @@ -96,7 +99,6 @@ int main(int argc, char **argv) } odr_destroy(decode); odr_destroy(encode); - nmem_exit(); exit(0); } #else @@ -109,6 +111,7 @@ int main(int argc, char **argv) /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab