Deleted Added
full compact
main.c (223926) main.c (229403)
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. 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

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

35
36#if 0
37#ifndef lint
38static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
39#endif
40#endif
41
42#include <sys/cdefs.h>
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. 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

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

35
36#if 0
37#ifndef lint
38static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
39#endif
40#endif
41
42#include <sys/cdefs.h>
43__FBSDID("$FreeBSD: head/usr.bin/tftp/main.c 223926 2011-07-11 05:57:49Z delphij $");
43__FBSDID("$FreeBSD: head/usr.bin/tftp/main.c 229403 2012-01-03 18:51:58Z ed $");
44
45/* Many bug fixes are from Jim Guyton <guyton@rand-unix> */
46
47/*
48 * TFTP User Program -- Command Interface.
49 */
50#include <sys/param.h>
51#include <sys/types.h>

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

432 argc = margc;
433 argv = margv;
434 }
435 if (argc < 2) {
436 putusage(argv[0]);
437 return;
438 }
439 targ = argv[argc - 1];
44
45/* Many bug fixes are from Jim Guyton <guyton@rand-unix> */
46
47/*
48 * TFTP User Program -- Command Interface.
49 */
50#include <sys/param.h>
51#include <sys/types.h>

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

432 argc = margc;
433 argv = margv;
434 }
435 if (argc < 2) {
436 putusage(argv[0]);
437 return;
438 }
439 targ = argv[argc - 1];
440 if (rindex(argv[argc - 1], ':')) {
440 if (strrchr(argv[argc - 1], ':')) {
441 char *lcp;
442
443 for (n = 1; n < argc - 1; n++)
441 char *lcp;
442
443 for (n = 1; n < argc - 1; n++)
444 if (index(argv[n], ':')) {
444 if (strchr(argv[n], ':')) {
445 putusage(argv[0]);
446 return;
447 }
448 lcp = argv[argc - 1];
445 putusage(argv[0]);
446 return;
447 }
448 lcp = argv[argc - 1];
449 targ = rindex(lcp, ':');
449 targ = strrchr(lcp, ':');
450 *targ++ = 0;
451 if (lcp[0] == '[' && lcp[strlen(lcp) - 1] == ']') {
452 lcp[strlen(lcp) - 1] = '\0';
453 lcp++;
454 }
455 setpeer0(lcp, NULL);
456 }
457 if (!connected) {

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

472 if (verbose)
473 printf("putting %s to %s:%s [%s]\n",
474 cp, hostname, targ, mode);
475 xmitfile(peer, port, fd, targ, mode);
476 return;
477 }
478 /* this assumes the target is a directory */
479 /* on a remote unix system. hmmmm. */
450 *targ++ = 0;
451 if (lcp[0] == '[' && lcp[strlen(lcp) - 1] == ']') {
452 lcp[strlen(lcp) - 1] = '\0';
453 lcp++;
454 }
455 setpeer0(lcp, NULL);
456 }
457 if (!connected) {

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

472 if (verbose)
473 printf("putting %s to %s:%s [%s]\n",
474 cp, hostname, targ, mode);
475 xmitfile(peer, port, fd, targ, mode);
476 return;
477 }
478 /* this assumes the target is a directory */
479 /* on a remote unix system. hmmmm. */
480 cp = index(targ, '\0');
480 cp = strchr(targ, '\0');
481 *cp++ = '/';
482 for (n = 1; n < argc - 1; n++) {
483 strcpy(cp, tail(argv[n]));
484 fd = open(argv[n], O_RDONLY);
485 if (fd < 0) {
486 warn("%s", argv[n]);
487 continue;
488 }

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

527 argv = margv;
528 }
529 if (argc < 2) {
530 getusage(argv[0]);
531 return;
532 }
533 if (!connected) {
534 for (n = 1; n < argc ; n++)
481 *cp++ = '/';
482 for (n = 1; n < argc - 1; n++) {
483 strcpy(cp, tail(argv[n]));
484 fd = open(argv[n], O_RDONLY);
485 if (fd < 0) {
486 warn("%s", argv[n]);
487 continue;
488 }

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

527 argv = margv;
528 }
529 if (argc < 2) {
530 getusage(argv[0]);
531 return;
532 }
533 if (!connected) {
534 for (n = 1; n < argc ; n++)
535 if (rindex(argv[n], ':') == 0) {
535 if (strrchr(argv[n], ':') == 0) {
536 printf("No remote host specified and "
537 "no host given for file '%s'\n", argv[n]);
538 getusage(argv[0]);
539 return;
540 }
541 }
542 for (n = 1; n < argc ; n++) {
536 printf("No remote host specified and "
537 "no host given for file '%s'\n", argv[n]);
538 getusage(argv[0]);
539 return;
540 }
541 }
542 for (n = 1; n < argc ; n++) {
543 src = rindex(argv[n], ':');
543 src = strrchr(argv[n], ':');
544 if (src == NULL)
545 src = argv[n];
546 else {
547 char *lcp;
548
549 *src++ = 0;
550 lcp = argv[n];
551 if (lcp[0] == '[' && lcp[strlen(lcp) - 1] == ']') {

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

676}
677
678static char *
679tail(char *filename)
680{
681 char *s;
682
683 while (*filename) {
544 if (src == NULL)
545 src = argv[n];
546 else {
547 char *lcp;
548
549 *src++ = 0;
550 lcp = argv[n];
551 if (lcp[0] == '[' && lcp[strlen(lcp) - 1] == ']') {

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

676}
677
678static char *
679tail(char *filename)
680{
681 char *s;
682
683 while (*filename) {
684 s = rindex(filename, '/');
684 s = strrchr(filename, '/');
685 if (s == NULL)
686 break;
687 if (s[1])
688 return (s + 1);
689 *s = '\0';
690 }
691 return (filename);
692}

--- 362 unchanged lines hidden ---
685 if (s == NULL)
686 break;
687 if (s[1])
688 return (s + 1);
689 *s = '\0';
690 }
691 return (filename);
692}

--- 362 unchanged lines hidden ---