/* Main network program - provides both client and server functions */ #define HOSTNAMELEN 32 /* changed from 16 by Bdale 860812 */ extern char startup[]; /* File to read startup commands from */ #include #include "config.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" #include "ax25.h" #include "remote.h" #include "netrom.h" #include "ftp.h" #include "telnet.h" #include "session.h" #include "cmdparse.h" #ifdef UNIX /* BSD or SYS5 */ #include "unix.h" #endif #ifdef AMIGA #include "amiga.h" #endif #ifdef MAC #include "mac.h" #endif #ifdef MSDOS #include "pc.h" #endif #ifdef ATARI_ST #include "st.h" #endif #ifdef LATTICE extern long _MNEED; /* reserve memory for child process (shell) */ long _MNEED = 100000; /* plucked out of thin air */ extern long _32K; long _32K = 0x8000; /* keep GST Linker happy */ #endif #ifdef MWC long _stksize cmdmode(); } continue; } #endif #ifdef SYS5 if(c == escape && escape != 0){ if(mode != CMD_MODE){ printf("\r\n"); cmdmode(); } continue; } #endif /* SYS5 */ /* ----------------------------(DG2KK)------------------------------- */ #ifndef FLOW if((cnt = ttydriv(c,&ttybuf)) == 0) continue; #else cnt = ttydriv(c,&ttybuf); if (cnt == 0) { /* should be != 0 */ ttyflow = 0; /* stop output to screen */ } else { ttyflow = 1; /* restart output */ if(mode != CMD_MODE) go(); /* display pending chars */ } if (cnt == 0) continue; #endif FLOW /* ------------------------------------------------------------------ */ switch(mode){ case CMD_MODE: (void)cmdparse(cmds,ttybuf); fflush(stdout); break; case CONV_MODE: #if (!MSDOS && !ATARI_ST) if(ttybuf[0] == escape && escape != 0){ printf("\n"); cmdmode(); } else #endif if(current->parse != NULLFP) (*current->parse)(ttybuf,cnt); break; } if(mode == CMD_MODE){ printf(prompt); fflush(stdout); } } keep_things_going(); } } /* Standard commands called from main */ /* Enter command mode */ int cmdmode() { if(mode != CMD_MODE){ mode = CMD_MODE; cooked(); printf(prompt); fflush(stdout); echo(); } return 0; } static doexit() { if(logfp != NULLFILE) fclose(logfp); iostop(); exit(0); } static dohostname(argc,argv) int argc; char *argv[]; { char *strncpy(); if(argc < 2) printf("%s\n",hostname); else strncpy(hostname,argv[1],HOSTNAMELEN); return 0; } static int dolog(argc,argv) int argc; char *argv[]; { char *strncpy(); static char logname[15]; if(argc < 2){ if(logfp) printf("Logging to %s\n",logname); else printf("Logging off\n"); return 0; } if(logfp){ fclose(logfp); logfp = NULLFILE; } if(strcmp(argv[1],"stop") != 0){ strncpy(logname,argv[1],15); logfp = fopen(logname,"a+"); } return 0; } static int dohelp() { register struct cmds *cmdp; int i,j; printf("Main commands:\n"); for(i=0,cmdp = cmds;cmdp->name != NULL;cmdp++,i++){ printf("%s",cmdp->name); if((i % 4) == 3) printf("\n"); else { for(j=strlen(cmdp->name);j < 16; j++) putchar(' '); } } if((i % 4) != 0) printf("\n"); return 0; } doecho(argc,argv) int argc; char *argv[]; { extern int refuse_echo; if(argc < 2){ if(refuse_echo) printf("Refuse\n"); else printf("Accept\n"); } else { if(argv[1][0] == 'r') refuse_echo = 1; else if(argv[1][0] == 'a') refuse_echo = 0; else return -1; } return 0; } /* set for unix end of line for remote echo mode telnet */ doeol(argc,argv) int argc; char *argv[]; { extern int unix_line_mode; if(argc < 2){ if(unix_line_mode) printf("Unix\n"); else printf("Standard\n"); } else { if(strcmp(argv[1],"unix") == 0) unix_line_mode = 1; else if(strcmp(argv[1],"standard") == 0) unix_line_mode = 0; else { return -1; } } return 0; } /* Attach an interface * Syntax: attach