X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Fsiconvtst.c;h=9f7038ece3b62d255e79c8ebf4be86812068a17b;hb=9241daf8b3104b67b2801872d0e07d6762f78b47;hp=baded669971b1e14cd25dc4f042a769abe133ec9;hpb=4d5043a735f072b648a7550b8f460726721b9f14;p=yaz-moved-to-github.git diff --git a/util/siconvtst.c b/util/siconvtst.c index baded66..9f7038e 100644 --- a/util/siconvtst.c +++ b/util/siconvtst.c @@ -1,8 +1,8 @@ /* - * Copyright (c) 1997-2002, Index Data + * Copyright (c) 1997-2003, Index Data * See the file LICENSE for details. * - * $Id: siconvtst.c,v 1.5 2002-12-10 10:23:21 adam Exp $ + * $Id: siconvtst.c,v 1.8 2003-01-06 08:20:28 adam Exp $ */ #if HAVE_CONFIG_H @@ -18,7 +18,7 @@ #define CHUNK_IN 64 #define CHUNK_OUT 64 -void convert (FILE *inf, yaz_iconv_t cd) +void convert (FILE *inf, yaz_iconv_t cd, int verbose) { char inbuf0[CHUNK_IN], *inbuf = inbuf0; char outbuf0[CHUNK_OUT], *outbuf = outbuf0; @@ -48,6 +48,12 @@ void convert (FILE *inf, yaz_iconv_t cd) inbytesleft = r; } } + if (verbose > 1) + { + fprintf (stderr, "yaz_iconv: inbytesleft=%d outbytesleft=%d\n", + inbytesleft, outbytesleft); + + } r = yaz_iconv (cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); if (r == (size_t)(-1)) { @@ -111,13 +117,14 @@ void convert (FILE *inf, yaz_iconv_t cd) int main (int argc, char **argv) { int ret; + int verbose = 0; char *from = 0; char *to = 0; char *arg; yaz_iconv_t cd; FILE *inf = stdin; - while ((ret = options ("f:t:", argv, argc, &arg)) != -2) + while ((ret = options ("vf:t:", argv, argc, &arg)) != -2) { switch (ret) { @@ -135,9 +142,12 @@ int main (int argc, char **argv) case 't': to = arg; break; + case 'v': + verbose++; + break; default: fprintf (stderr, "yaziconv: Usage\n" - "siconv -f encoding -t encoding [file]\n"); + "siconv -f encoding -t encoding [-v] [file]\n"); exit(1); } } @@ -157,8 +167,15 @@ int main (int argc, char **argv) fprintf (stderr, "yaziconv: unsupported encoding\n"); exit (5); } - - convert (inf, cd); + else + { + if (verbose) + { + fprintf (stderr, "yaziconv: using %s\n", + yaz_iconv_isbuiltin(cd) ? "YAZ" : "iconv"); + } + } + convert (inf, cd, verbose); yaz_iconv_close (cd); return 0; }