X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Fyaz-url.c;h=498e2f8e6ce056af075203fa174795d326e12db9;hb=2598d7948bb30770da2bcb729a4b2bf2a626a23f;hp=98bf594a542a631cd23a01b9aa57a25e561216f4;hpb=bef3628f699c3d747292bd6c87a733818e618e6c;p=yaz-moved-to-github.git diff --git a/util/yaz-url.c b/util/yaz-url.c index 98bf594..498e2f8 100644 --- a/util/yaz-url.c +++ b/util/yaz-url.c @@ -1,10 +1,10 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2011 Index Data + * Copyright (C) 1995-2013 Index Data * See the file LICENSE for details. */ #if HAVE_CONFIG_H -#include "config.h" +#include #endif #include @@ -17,12 +17,12 @@ static void usage(void) { printf("yaz-icu [options] url ..\n"); - printf(" -H name:value Set HTTP header (repeat if necessary)\n"); - printf(" -m method HTTP method\n"); - printf(" -O file Write to file, instead of stdout\n"); - printf(" -p file POSTs file at following url\n"); - printf(" -u user/password Basic HTTP auth\n"); - printf(" -x proxy HTTP proxy\n"); + printf(" -H name:value Sets HTTP header (repeat if necessary)\n"); + printf(" -m method Sets HTTP method\n"); + printf(" -O fname Writes HTTP content to file\n"); + printf(" -p fname POSTs file at following url\n"); + printf(" -u user/password Sets Basic HTTP auth\n"); + printf(" -x proxy Sets HTTP proxy\n"); exit(1); } @@ -43,9 +43,15 @@ static char *get_file(const char *fname, size_t *len) *len = ftell(inf); if (*len) /* zero length not considered an error */ { + size_t r; buf = xmalloc(*len); fseek(inf, 0L, SEEK_SET); - fread(buf, 1, *len, inf); + r = fread(buf, 1, *len, inf); + if (r != *len) + { + yaz_log(YLOG_FATAL|YLOG_ERRNO, "short fread of %s", fname); + exit(1); + } } fclose(inf); return buf;