www.pudn.com > tftp.rar > MAIN.C
/* ** This product contains: ** "Restricted Materials of IBM" ** (c) Copyright IBM Corp. 1987 ** All Rights Reserved ** Licensed Materials-Property of IBM ** ** See Copyright Instructions, G120-2083 ** */ #include#include #include #include "tftpdefs.h" struct tftpcon conn; main (argc,argv) int argc; char *argv[]; { enum commands cmd; char cmdline[COMMANDLEN]; initialize(argv); do { cmd = getcmd(cmdline); switch (cmd) { case c_serve: /* be a tftp server */ server( S_NOSPOOL ); break; case c_spool: /* be a spooling server */ server( S_SPOOL ); break; case c_connect: /* connect to a foreign host */ connect (cmdline); break; case c_mode: /* change or display the transfer mode */ chmode (cmdline); break; case c_put: /* send a file to a foreign host */ transfer (D_PUT,cmdline); break; case c_get: /* grab a file from the foreign host */ transfer (D_GET,cmdline); break; case c_quit: /* we be done */ break; case c_verbose: /* toggle the vebosity */ conn.flags = conn.flags ^ F_VERBOSE; printf ("Verbose %s\n",(conn.flags & F_VERBOSE) ? "On" : "Off"); break; case c_trace: /* toggle the tracing of packets */ conn.flags = conn.flags ^ F_TRACE; printf ("Trace %s\n",(conn.flags & F_TRACE) ? "On" : "Off"); if (conn.flags & F_TRACE) break; case c_clobber: /* toggle clobbering files without asking */ conn.flags = conn.flags ^ F_CLOBBER; printf ("Clobber %s\n",(conn.flags & F_CLOBBER) ? "On" : "Off"); break; case c_eofmark: /* toggle write ^Z at end of local file */ conn.flags = conn.flags ^ F_EOFMARK; printf ("Write End of File character %s\n", (conn.flags & F_EOFMARK) ? "On" : "Off"); break; case c_status: /* display the status */ showstats(); break; case c_binary: /* short for mode binary */ chmode ("binary"); break; case c_ascii: /* short for mode ascii */ chmode ("ascii"); break; case c_help: /* feed me some help */ help(); break; case c_shell: /* spawn a new shell */ system (cmdline); break; case c_rexmt: case c_timeout: case unsupported: #if false printf ("Sorry, I don't support that function yet\n"); break; #endif case c_error: /* try to cheat will ya?? */ printf ("Unknown command -- %s\n",cmdline); break; default: /* shut're down Clancy, she's a-pumping mud */ message ("main: Impossible state!\n",INT_ERR,NULL); } } while (cmd != c_quit); exit (0); }