Lines Matching +full:s +full:- +full:mode

1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
32 /* Many bug fixes are from Jim Guyton <guyton@rand-unix> */
35 * TFTP User Program -- Command Interface.
60 #include "tftp-utils.h"
61 #include "tftp-io.h"
62 #include "tftp-options.h"
66 #define TIMEOUT 5 /* secs between rexmt's */
70 static char mode[32]; variable
126 { "mode", modecmd, "set file transfer mode" },
130 { "verbose", setverbose, "toggle verbose mode" },
132 { "binary", setbinary, "set mode to octet" },
133 { "ascii", setascii, "set mode to netascii" },
135 "set per-packet retransmission timeout[-]" },
138 { "trace", setdebug, "enable 'debug packet'[-]" },
173 peer = -1; in main()
174 strcpy(mode, "octet"); in main()
214 * tftpURI = "tftp://" host "/" file [ mode ]
215 * mode = ";" "mode=" ( "netascii" / "octet" )
221 * We are cheating a little bit by allowing any mode as specified in the
223 * mode.
233 char *s; in urihandling() local
240 if ((s = strchr(host, '/')) == NULL) { in urihandling()
245 *s = '\0'; in urihandling()
246 path = s + 1; in urihandling()
248 if ((s = strchr(path, ';')) != NULL) { in urihandling()
249 *s = '\0'; in urihandling()
250 opts = s + 1; in urihandling()
252 if (strncmp(opts, "mode=", 5) == 0) { in urihandling()
261 fprintf(stderr, "Invalid mode: '%s'\n", mode); in urihandling()
272 sprintf(line, "get %s", path); in urihandling()
288 peer = -1; in setpeer0()
301 warnx("%s", gai_strerror(error)); in setpeer0()
305 for (res = res0; res; res = res->ai_next) { in setpeer0()
306 if (res->ai_addrlen > sizeof(peeraddr)) in setpeer0()
308 peer = socket(res->ai_family, res->ai_socktype, in setpeer0()
309 res->ai_protocol); in setpeer0()
316 peer_sock.ss_family = res->ai_family; in setpeer0()
317 peer_sock.ss_len = res->ai_addrlen; in setpeer0()
321 peer = -1; in setpeer0()
329 warn("%s", cause); in setpeer0()
331 /* res->ai_addr <= sizeof(peeraddr) is guaranteed */ in setpeer0()
332 memcpy(&peer_sock, res->ai_addr, res->ai_addrlen); in setpeer0()
333 if (res->ai_canonname) { in setpeer0()
334 (void) strlcpy(hostname, res->ai_canonname, in setpeer0()
352 fgets(&line[strlen(line)], sizeof line - strlen(line), stdin); in setpeer()
358 printf("usage: %s [host [port]]\n", argv[0]); in setpeer()
375 printf("Using %s mode to transfer files.\n", mode); in modecmd()
379 for (p = modes; p->m_name; p++) in modecmd()
380 if (strcmp(argv[1], p->m_name) == 0) in modecmd()
382 if (p->m_name) { in modecmd()
383 settftpmode(p->m_mode); in modecmd()
386 printf("%s: unknown mode\n", argv[1]); in modecmd()
390 printf("usage: %s [", argv[0]); in modecmd()
392 for (p = modes; p->m_name != NULL; p++) { in modecmd()
393 printf("%s%s", sep, p->m_name); in modecmd()
419 strlcpy(mode, newmode, sizeof(mode)); in settftpmode()
421 printf("mode set to %s\n", mode); in settftpmode()
426 * Send file(s).
440 fgets(&line[strlen(line)], sizeof line - strlen(line), stdin); in put()
449 targ = argv[argc - 1]; in put()
450 if (strrchr(argv[argc - 1], ':')) { in put()
453 for (n = 1; n < argc - 1; n++) in put()
458 lcp = argv[argc - 1]; in put()
461 if (lcp[0] == '[' && lcp[strlen(lcp) - 1] == ']') { in put()
462 lcp[strlen(lcp) - 1] = '\0'; in put()
475 warn("%s", cp); in put()
480 warn("%s", cp); in put()
487 printf("putting %s to %s:%s [%s]\n", in put()
488 cp, hostname, targ, mode); in put()
489 if (xmitfile(peer, port, fd, targ, mode)) in put()
496 for (n = 1; n < argc - 1; n++) { in put()
497 if (asprintf(&path, "%s/%s", targ, tail(argv[n])) < 0) in put()
502 warn("%s", argv[n]); in put()
508 warn("%s", argv[n]); in put()
516 printf("putting %s to %s:%s [%s]\n", in put()
517 argv[n], hostname, path, mode); in put()
518 if (xmitfile(peer, port, fd, path, mode) != 0) in put()
527 putusage(char *s) in putusage() argument
530 printf("usage: %s file [remotename]\n", s); in putusage()
531 printf(" %s file host:remotename\n", s); in putusage()
532 printf(" %s file1 file2 ... fileN [[host:]remote-directory]\n", s); in putusage()
536 * Receive file(s).
550 fgets(&line[strlen(line)], sizeof line - strlen(line), stdin); in get()
563 "no host given for file '%s'\n", argv[n]); in get()
577 if (lcp[0] == '[' && lcp[strlen(lcp) - 1] == ']') { in get()
578 lcp[strlen(lcp) - 1] = '\0'; in get()
589 warn("%s", cp); in get()
593 printf("getting from %s:%s to %s [%s]\n", in get()
594 hostname, src, cp, mode); in get()
595 if (recvfile(peer, port, fd, src, mode) != 0) in get()
602 warn("%s", cp); in get()
606 printf("getting from %s:%s to %s [%s]\n", in get()
607 hostname, src, cp, mode); in get()
608 if (recvfile(peer, port, fd, src, mode) != 0) in get()
614 getusage(char *s) in getusage() argument
617 printf("usage: %s file [localname]\n", s); in getusage()
618 printf(" %s [host:]file [localname]\n", s); in getusage()
619 printf(" %s [host1:]file1 [host2:]file2 ... [hostN:]fileN\n", s); in getusage()
631 fgets(&line[strlen(line)], sizeof line - strlen(line), stdin); in settimeoutpacket()
637 printf("usage: %s value\n", argv[0]); in settimeoutpacket()
642 printf("%s: bad value\n", argv[1]); in settimeoutpacket()
658 fgets(&line[strlen(line)], sizeof line - strlen(line), stdin); in settimeoutnetwork()
664 printf("usage: %s value\n", argv[0]); in settimeoutnetwork()
669 printf("%s: bad value\n", argv[1]); in settimeoutnetwork()
680 printf("Remote host: %s\n", in showstatus()
682 printf("RFC2347 Options support: %s\n", in showstatus()
684 printf("Non-RFC defined options support: %s\n", in showstatus()
686 printf("Mode: %s\n", mode); in showstatus()
687 printf("Verbose: %s\n", verbose ? "on" : "off"); in showstatus()
688 printf("Debug: %s\n", debug_show(debug)); in showstatus()
703 longjmp(toplevel, -1); in intr()
709 char *s; in tail() local
712 s = strrchr(filename, '/'); in tail()
713 if (s == NULL) in tail()
715 if (s[1]) in tail()
716 return (s + 1); in tail()
717 *s = '\0'; in tail()
747 line[len - 1] = '\0'; in command()
767 if (c == (struct cmd *)-1) { in command()
775 (*c->handler)(margc, margv); in command()
790 for (c = cmdtab; (p = c->name) != NULL; c++) { in getcmd()
795 if (q - name > longest) { in getcmd()
796 longest = q - name; in getcmd()
799 } else if (q - name == longest) in getcmd()
804 return ((struct cmd *)-1); in getcmd()
820 for (cp = line; margc < MAX_MARGV - 1 && *cp != '\0';) { in makeargv()
853 for (c = cmdtab; c->name; c++) in help()
854 printf("%-*s\t%s\n", (int)HELPINDENT, c->name, c->help); in help()
856 printf("\n[-] : You shouldn't use these ones anymore.\n"); in help()
858 printf("[**] : Non-standard RFC2347 option.\n"); in help()
861 while (--argc > 0) { in help()
865 if (c == (struct cmd *)-1) in help()
866 printf("?Ambiguous help command: %s\n", arg); in help()
868 printf("?Invalid help command: %s\n", arg); in help()
870 printf("%s\n", c->help); in help()
879 printf("Verbose mode %s.\n", verbose ? "on" : "off"); in setverbose()
900 printf("Support for RFC2347 style options are now %s.\n", in setoptions()
902 printf("Support for non-RFC defined options are now %s.\n", in setoptions()
908 "\toptions extra : toggle support for non-RFC defined options\n" in setoptions()
928 printf("Support for the rollover options is %s.\n", in setrollover()
931 printf("Block rollover will be to block %s.\n", in setrollover()
953 printf("The following debugging is enabled: %s\n", debug_show(debug)); in setdebug()
958 printf("\t%s\t%s\n", debugs[i].name, debugs[i].desc); in setdebug()
987 } else if (size > (int)maxdgram - 4) { in setblocksize()
990 maxdgram - 4); in setblocksize()
991 options_set_request(OPT_BLKSIZE, "%ld", maxdgram - 4); in setblocksize()
996 printf("Blocksize is now %s bytes.\n", options[OPT_BLKSIZE].o_request); in setblocksize()
1005 "RFC2347 style or non-RFC defined options are not enabled " in setblocksize2()
1039 } else if (size > (int)maxdgram - 4) { in setblocksize2()
1042 maxdgram - 4); in setblocksize2()
1051 printf("Blocksize2 is now %s bytes.\n", in setblocksize2()
1085 printf("Windowsize is now %s blocks.\n", in setwindowsize()