projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update RPM requires
[yaz-moved-to-github.git]
/
util
/
yaz-url.c
diff --git
a/util/yaz-url.c
b/util/yaz-url.c
index
a94f809
..
7a78e67
100644
(file)
--- a/
util/yaz-url.c
+++ b/
util/yaz-url.c
@@
-1,10
+1,10
@@
/* This file is part of the YAZ toolkit.
/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2011 Index Data
+ * Copyright (C) Index Data
* See the file LICENSE for details.
*/
#if HAVE_CONFIG_H
* See the file LICENSE for details.
*/
#if HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
#endif
#include <string.h>
#endif
#include <string.h>
@@
-21,7
+21,9
@@
static void usage(void)
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(" -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(" -R num Set maximum number of HTTP redirects\n");
printf(" -u user/password Sets Basic HTTP auth\n");
printf(" -u user/password Sets Basic HTTP auth\n");
+ printf(" -v Verbose\n");
printf(" -x proxy Sets HTTP proxy\n");
exit(1);
}
printf(" -x proxy Sets HTTP proxy\n");
exit(1);
}
@@
-43,9
+45,15
@@
static char *get_file(const char *fname, size_t *len)
*len = ftell(inf);
if (*len) /* zero length not considered an error */
{
*len = ftell(inf);
if (*len) /* zero length not considered an error */
{
+ size_t r;
buf = xmalloc(*len);
fseek(inf, 0L, SEEK_SET);
buf = xmalloc(*len);
fseek(inf, 0L, SEEK_SET);
- (void) 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;
}
fclose(inf);
return buf;
@@
-66,7
+74,7
@@
int main(int argc, char **argv)
int no_urls = 0;
const char *outfname = 0;
int no_urls = 0;
const char *outfname = 0;
- while ((ret = options("hH:m:O:p:u:x:", argv, argc, &arg))
+ while ((ret = options("h{help}H:m:O:p:R{max-redirs}:u:vx:", argv, argc, &arg))
!= YAZ_OPTIONS_EOF)
{
switch (ret)
!= YAZ_OPTIONS_EOF)
{
switch (ret)
@@
-103,6
+111,9
@@
int main(int argc, char **argv)
post_buf = get_file(arg, &post_len);
method = "POST";
break;
post_buf = get_file(arg, &post_len);
method = "POST";
break;
+ case 'R':
+ yaz_url_set_max_redirects(p, atoi(arg));
+ break;
case 'u':
if (strchr(arg, '/'))
{
case 'u':
if (strchr(arg, '/'))
{
@@
-117,6
+128,9
@@
int main(int argc, char **argv)
else
z_HTTP_header_add_basic_auth(odr, &http_headers, arg, 0);
break;
else
z_HTTP_header_add_basic_auth(odr, &http_headers, arg, 0);
break;
+ case 'v':
+ yaz_url_set_verbose(p, 1);
+ break;
case 'x':
yaz_url_set_proxy(p, arg);
break;
case 'x':
yaz_url_set_proxy(p, arg);
break;