Deleted Added
full compact
fetch.c (131615) fetch.c (132695)
1/*-
2 * Copyright (c) 2000 Dag-Erling Co�dan Sm�rgrav
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2000 Dag-Erling Co�dan Sm�rgrav
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/usr.bin/fetch/fetch.c 131615 2004-07-05 11:21:50Z des $");
30__FBSDID("$FreeBSD: head/usr.bin/fetch/fetch.c 132695 2004-07-27 11:30:35Z des $");
31
32#include <sys/param.h>
33#include <sys/socket.h>
34#include <sys/stat.h>
35#include <sys/time.h>
36
37#include <ctype.h>
38#include <err.h>

--- 225 unchanged lines hidden (view full) ---

264 */
265static int
266query_auth(struct url *URL)
267{
268 struct termios tios;
269 tcflag_t saved_flags;
270 int i, nopwd;
271
31
32#include <sys/param.h>
33#include <sys/socket.h>
34#include <sys/stat.h>
35#include <sys/time.h>
36
37#include <ctype.h>
38#include <err.h>

--- 225 unchanged lines hidden (view full) ---

264 */
265static int
266query_auth(struct url *URL)
267{
268 struct termios tios;
269 tcflag_t saved_flags;
270 int i, nopwd;
271
272
273 fprintf(stderr, "Authentication required for <%s://%s:%d/>!\n",
274 URL->scheme, URL->host, URL->port);
275
276 fprintf(stderr, "Login: ");
277 if (fgets(URL->user, sizeof URL->user, stdin) == NULL)
272 fprintf(stderr, "Authentication required for <%s://%s:%d/>!\n",
273 URL->scheme, URL->host, URL->port);
274
275 fprintf(stderr, "Login: ");
276 if (fgets(URL->user, sizeof URL->user, stdin) == NULL)
278 return -1;
277 return (-1);
279 for (i = 0; URL->user[i]; ++i)
280 if (isspace(URL->user[i]))
281 URL->user[i] = '\0';
282
283 fprintf(stderr, "Password: ");
284 if (tcgetattr(STDIN_FILENO, &tios) == 0) {
285 saved_flags = tios.c_lflag;
286 tios.c_lflag &= ~ECHO;
287 tios.c_lflag |= ECHONL|ICANON;
288 tcsetattr(STDIN_FILENO, TCSAFLUSH|TCSASOFT, &tios);
289 nopwd = (fgets(URL->pwd, sizeof URL->pwd, stdin) == NULL);
290 tios.c_lflag = saved_flags;
291 tcsetattr(STDIN_FILENO, TCSANOW|TCSASOFT, &tios);
292 } else {
293 nopwd = (fgets(URL->pwd, sizeof URL->pwd, stdin) == NULL);
294 }
295 if (nopwd)
278 for (i = 0; URL->user[i]; ++i)
279 if (isspace(URL->user[i]))
280 URL->user[i] = '\0';
281
282 fprintf(stderr, "Password: ");
283 if (tcgetattr(STDIN_FILENO, &tios) == 0) {
284 saved_flags = tios.c_lflag;
285 tios.c_lflag &= ~ECHO;
286 tios.c_lflag |= ECHONL|ICANON;
287 tcsetattr(STDIN_FILENO, TCSAFLUSH|TCSASOFT, &tios);
288 nopwd = (fgets(URL->pwd, sizeof URL->pwd, stdin) == NULL);
289 tios.c_lflag = saved_flags;
290 tcsetattr(STDIN_FILENO, TCSANOW|TCSASOFT, &tios);
291 } else {
292 nopwd = (fgets(URL->pwd, sizeof URL->pwd, stdin) == NULL);
293 }
294 if (nopwd)
296 return -1;
295 return (-1);
297
298 for (i = 0; URL->pwd[i]; ++i)
299 if (isspace(URL->pwd[i]))
300 URL->pwd[i] = '\0';
296
297 for (i = 0; URL->pwd[i]; ++i)
298 if (isspace(URL->pwd[i]))
299 URL->pwd[i] = '\0';
301 return 0;
300 return (0);
302}
303
304/*
305 * Fetch a file
306 */
307static int
308fetch(char *URL, const char *path)
309{

--- 372 unchanged lines hidden (view full) ---

682 if (f)
683 fclose(f);
684 if (of && of != stdout)
685 fclose(of);
686 if (url)
687 fetchFreeURL(url);
688 if (tmppath != NULL)
689 free(tmppath);
301}
302
303/*
304 * Fetch a file
305 */
306static int
307fetch(char *URL, const char *path)
308{

--- 372 unchanged lines hidden (view full) ---

681 if (f)
682 fclose(f);
683 if (of && of != stdout)
684 fclose(of);
685 if (url)
686 fetchFreeURL(url);
687 if (tmppath != NULL)
688 free(tmppath);
690 return r;
689 return (r);
691}
692
693static void
694usage(void)
695{
696 fprintf(stderr, "%s\n%s\n%s\n",
697 "usage: fetch [-146AFMPRUadlmnpqrsv] [-N netrc] [-o outputfile]",
698 " [-S bytes] [-B bytes] [-T seconds] [-w seconds]",

--- 270 unchanged lines hidden ---
690}
691
692static void
693usage(void)
694{
695 fprintf(stderr, "%s\n%s\n%s\n",
696 "usage: fetch [-146AFMPRUadlmnpqrsv] [-N netrc] [-o outputfile]",
697 " [-S bytes] [-B bytes] [-T seconds] [-w seconds]",

--- 270 unchanged lines hidden ---