/* Main metwork program - provides both client and server functions * See readme.src for modification notes - K5JB * #define CPUSTAT to measure loop performance - adds 768 bytes */ #define HOSTNAMELEN 64 #include #include #include "options.h" #include "config.h" #include "sokname.h" #include "global.h" #include "mbuf.h" #include "netuser.h" #include "timer.h" #include "icmp.h" #include "iface.h" #include "ip.h" #include "tcp.h" #ifdef AX25 #include "ax25.h" #include "lapb.h" #endif #ifdef NETROM #include "netrom.h" #include "nr4.h" #endif #include "ftp.h" #include "telnet.h" #include "remote.h" #ifdef _FINGER #include "finger.h" #endif #include "session.h" #include "cmdparse.h" #if defined(MSDOS) || defined(ASY) #include "asy.h" #endif #ifdef ASY #include "slip.h" #endif #ifdef NRS #include "nrs.h" #endif #ifdef UNIX /* BSD or SYS5 */ #include "unix.h" #include "unixopt.h" #endif #ifdef TRACE #include "trace.h" /* Dummy structure for loopback tracing */ extern struct interface loopback; extern char howtotrace[]; #endif #if defined(MSDOS) && defined(CUTE_VIDEO) unsigned int saved_attrib; unsigned int ourcute = OUR_CUTE; /* we select default from options.h */ int doattrib(); unsigned int get_attr(); void putca(),putsa(); #endif #ifdef AX25 extern int16 paclen; #endif extern struct interface *ifaces; extern void version(),fileinit(); extern struct mbuf *loopq; extern FILE *trfp; extern char trname[]; int mode,atoi(),exitval; /* used by doexit() */ extern char *homedir,*mailspool,*startup; char badhost[] = "Unknown host %s\n"; char hostname[HOSTNAMELEN]; unsigned nsessions = NSESSIONS; int32 resolve(); char *strncpy(),*make_path(); int16 lport = 1024; char prompt[] = "NET> "; char nospace[] = "No space!!\n"; /* Generic malloc fail message */ #ifdef SYS5 #include #ifdef USE_QUIT int backgrd = 0; /* backgrd is controlled by SIGQUIT */ #endif #ifdef FORKSHELL extern int shellpid; #endif int background = 0; /* background is detected on startup */ int io_active = 0; #endif /* PC uses F-10 key always */ #if !defined(MSDOS) char escape = 0x1d; /* default escape character is ^] */ #endif /* Enter command mode */ int cmdmode() { void cooked(); extern void echo(); #if defined(SYS5) && defined(FORKSHELL) if(shellpid) return 0; #endif if(mode != CMD_MODE){ mode = CMD_MODE; cooked(); #ifdef CUTE_FTP echo(); /* one in a million chance... */ #endif } printf(prompt); /* note change to always print a prompt */ fflush(stdout); return 0; } int /* removed static to make this the only sane exit from program */ doexit() /* left declaration as int to match cmd list */ { void iostop(),exit(); #ifdef TRACE if (trfp != stdout) fclose(trfp); #endif #ifdef SYS5 if (!background) iostop(); /* this function will exit() */ #else /* it is also a signal handler */ iostop(); #endif exit(exitval); /* only rational exit in NET */ } static dohostname(argc,argv) int argc; char *argv[]; { if(argc < 2) printf("%s\n",hostname); else strncpy(hostname,argv[1],HOSTNAMELEN); return 0; } static int dohelp() { extern struct cmds cmds[]; register struct cmds *cmdp; int i; printf("Main commands:"); /* first command is "" and will do \n */ for(i=0,cmdp = cmds;cmdp->name != NULLCHAR;cmdp++,i++){ printf("%-15s",cmdp->name); if(!(i % 5)) printf("\n"); } printf("\n"); return 0; } int subcmd(); /* Attach an interface * Syntax: attach