From owner-freebsd-current Thu Dec 3 11:08:04 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id LAA09263 for freebsd-current-outgoing; Thu, 3 Dec 1998 11:08:04 -0800 (PST) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from cons.org (knight.cons.org [194.233.237.86]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id LAA09172 for ; Thu, 3 Dec 1998 11:08:00 -0800 (PST) (envelope-from cracauer@cons.org) Received: (from cracauer@localhost) by cons.org (8.8.8/8.7.3) id UAA00877 for current@freebsd.org; Thu, 3 Dec 1998 20:07:44 +0100 (CET) Message-ID: <19981203200743.A861@cons.org> Date: Thu, 3 Dec 1998 20:07:43 +0100 From: Martin Cracauer To: current@FreeBSD.ORG Subject: Proposed addition to fetch(1) Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=gBBFr7Ir9EOA20Yy X-Mailer: Mutt 0.93.1i Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --gBBFr7Ir9EOA20Yy Content-Type: text/plain; charset=us-ascii I plan to add this to fetch, unless anyone objects. -s Ask server for size of file in bytes and print it to stdout. Do not actually fetch the file. Actual diff appended. I plan to use it for a `make fetchsize` target for ports, so that you can ask how much traffic you would cause before actually starting the fetch. Martin -- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Martin Cracauer http://www.cons.org/cracauer Tel.: (private) +4940 5221829 Fax.: (private) +4940 5228536 Paper: (private) Waldstrasse 200, 22846 Norderstedt, Germany --gBBFr7Ir9EOA20Yy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="fetch.diff" ? fetch ? fetch.1.gz ? l ? .gdbinit ? ktrace.out ? shc ? README Index: fetch.1 =================================================================== RCS file: /home/CVS-FreeBSD/src/usr.bin/fetch/fetch.1,v retrieving revision 1.25 diff -c -r1.25 fetch.1 *** fetch.1 1998/11/08 23:18:47 1.25 --- fetch.1 1998/12/03 19:04:35 *************** *** 115,120 **** --- 115,123 ---- .Nm fetch from downloading a file that is either incomplete or the wrong version, given the correct size of the file in advance. + .It Fl s + Ask server for size of file in bytes and print it to stdout. Do not + actually fetch the file. .It Fl T Ar seconds Set timeout value to .Ar seconds. Index: fetch.h =================================================================== RCS file: /home/CVS-FreeBSD/src/usr.bin/fetch/fetch.h,v retrieving revision 1.6 diff -c -r1.6 fetch.h *** fetch.h 1998/09/20 00:01:26 1.6 --- fetch.h 1998/12/03 19:04:35 *************** *** 52,57 **** --- 52,58 ---- int fs_linux_bug; /* -b option */ int fs_use_connect; /* -t option */ off_t fs_expectedsize; /* -S option */ + int fs_reportsize; /* -s option */ time_t fs_modtime; void *fs_proto; int (*fs_retrieve)(struct fetch_state *); Index: ftp.c =================================================================== RCS file: /home/CVS-FreeBSD/src/usr.bin/fetch/ftp.c,v retrieving revision 1.10 diff -c -r1.10 ftp.c *** ftp.c 1998/09/20 00:01:26 1.10 --- ftp.c 1998/12/03 19:04:35 *************** *** 375,380 **** --- 375,394 ---- } } size = ftpGetSize(ftp, ftps->ftp_remote_file); + + if (fs->fs_reportsize) { + fclose(ftp); + if (size == -1) { + warnx("%s: size not known\n", fs->fs_outputfile); + printf("Unknown\n"); + return 1; + } + else { + printf("%qd\n", (quad_t)size); + return 0; + } + } + if (size > 0 && fs->fs_expectedsize != -1 && size != fs->fs_expectedsize) { warnx("%s: size mismatch, expected=%lu / actual=%lu", ftps->ftp_remote_path, Index: http.c =================================================================== RCS file: /home/CVS-FreeBSD/src/usr.bin/fetch/http.c,v retrieving revision 1.21 diff -c -r1.21 http.c *** http.c 1998/10/26 02:39:21 1.21 --- http.c 1998/12/03 19:04:35 *************** *** 945,950 **** --- 945,967 ---- fs->fs_status = "retrieving file from HTTP/1.x server"; + if (fs->fs_reportsize) { + if (total_length == -1) { + warnx("%s: size not known\n", + fs->fs_outputfile); + printf("Unknown\n"); + status = 1; + } + else { + printf("%qd\n", (quad_t)total_length); + status = 0; + } + fclose(remote); + unsetup_sigalrm(); + return status; + } + + /* * OK, if we got here, then we have finished parsing the header * and have read the `\r\n' line which denotes the end of same. Index: main.c =================================================================== RCS file: /home/CVS-FreeBSD/src/usr.bin/fetch/main.c,v retrieving revision 1.48 diff -c -r1.48 main.c *** main.c 1998/11/08 23:18:48 1.48 --- main.c 1998/12/03 19:04:36 *************** *** 71,80 **** init_schemes(); fs = clean_fetch_state; fs.fs_verbose = 1; fs.fs_expectedsize = -1; change_to_dir = file_to_get = hostname = 0; ! while ((c = getopt(argc, argv, "abc:D:f:h:HIlLmMnNo:pPqRrS:tT:vV:")) != -1) { switch (c) { case 'D': case 'H': case 'I': case 'L': case 'N': case 'V': break; /* ncftp compatibility */ --- 71,81 ---- init_schemes(); fs = clean_fetch_state; fs.fs_verbose = 1; + fs.fs_reportsize = 0; fs.fs_expectedsize = -1; change_to_dir = file_to_get = hostname = 0; ! while ((c = getopt(argc, argv, "abc:D:f:h:HIlLmMnNo:pPqRrSs:tT:vV:")) != -1) { switch (c) { case 'D': case 'H': case 'I': case 'L': case 'N': case 'V': break; /* ncftp compatibility */ *************** *** 133,138 **** --- 134,143 ---- case 't': fs.fs_use_connect = 1; + break; + + case 's': + fs.fs_reportsize = 1; break; case 'S': --gBBFr7Ir9EOA20Yy-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message