📄 ckcmai.c
字号:
dblchar = -1; /* Character to double when sending *//* Variables passed from command parser to protocol module */#ifndef NOSPL_PROTOTYP( int parser, (int) ); /* The parser itself */char *clcmds = NULL; /* Pointer to command-line commands */#endif /* NOSPL */CHAR sstate = (CHAR) 0; /* Starting state for automaton */CHAR zstate = (CHAR) 0; /* For remembering sstate */char *cmarg = ""; /* Pointer to command data */char *cmarg2 = ""; /* Pointer to 2nd command data */char **cmlist; /* Pointer to file list in argv *//* Flags for the ENABLE and DISABLE commands */int en_cwd = 1; /* CD/CWD */int en_del = 1; /* DELETE */int en_dir = 1; /* DIRECTORY */int en_fin = 1; /* FINISH/BYE */int en_get = 1; /* GET */#ifndef NOPUSHint en_hos = 1; /* HOST enabled */#elseint en_hos = 0; /* HOST disabled */#endif /* NOPUSH */int en_sen = 1; /* SEND */int en_set = 1; /* SET */int en_spa = 1; /* SPACE */int en_typ = 1; /* TYPE */int en_who = 1; /* WHO */#ifdef datageneral/* Data General AOS/VS can't do this */int en_bye = 0; /* BYE */#elseint en_bye = 1; /* BYE */#endif /* datageneral *//* Miscellaneous */char **xargv; /* Global copies of argv */int xargc; /* and argc */int xargs; /* an immutable copy of argc */char *xarg0; /* and of argv[0] */extern char *dftty; /* Default tty name from ck?tio.c */extern int dfloc; /* Default location: remote/local */extern int dfprty; /* Default parity */extern int dfflow; /* Default flow control *//* Buffered file input and output buffers. See getpkt() in ckcfns.c and zoutdump() in the system-dependent file i/o module (usually ck?fio.c).*/#ifndef DYNAMIC/* Now we allocate them dynamically, see getiobs() below. */char zinbuffer[INBUFSIZE], zoutbuffer[OBUFSIZE];#endifchar *zinptr, *zoutptr;int zincnt, zoutcnt;_PROTOTYP( int getiobs, (void) );/* M A I N -- C-Kermit main program */#ifndef NOCCTRAP#include <setjmp.h>extern jmp_buf cmjbuf;#ifdef GEMDOS /* Special for Atari ST */ cc_clean();#endif /* GEMDOS */#endif /* NOCCTRAP */#ifdef aegis/* On the Apollo, intercept main to insert a cleanup handler */intckcmai(argc,argv) int argc; char **argv;#else#ifdef MACint main (void)#elseintmain(argc,argv) int argc; char **argv;#endif /* MAC */#endif /* aegis */{#ifdef datageneralshort *pfha = 016000000036; /* Get around LANG_RT problem -- */*pfha = (short) 0; /* No user protection fault handler */#endif /* datageneral */ /* Do some initialization */ if (sysinit() < 0) /* System-dependent initialization. */ fatal("Can't initialize!"); connoi(); /* Console interrupts off */#ifndef MAC xargc = xargs = argc; /* Make global copies of argc */ xargv = argv; /* ...and argv. */ xarg0 = argv[0];#endif /* MAC */ sstate = 0; /* No default start state. */#ifdef DYNAMIC if (getiobs() < 0) fatal("Can't allocate i/o buffers!");#endif /* DYNAMIC */ ckhost(myhost,MYHOSTL); /* Name of local host */ strcpy(ttname,dftty); /* Set up default tty name. */ local = dfloc; /* And whether it's local or remote. */ parity = dfprty; /* Set initial parity, */ flow = dfflow; /* and flow control. */ if (local) if (ttopen(ttname,&local,0,0) < 0) { /* If default tty line */ printf("%s: Can't open device\n",ttname); /* is external, open it */ local = 0; /* now... */ strcpy(ttname,CTTNAM); } speed = ttgspd(); /* Get transmission speed. */#ifdef SUNX25 initpad(); /* Initialize X.25 PAD */#endif /* SUNX25 */ if (inibufs(SBSIZ,RBSIZ) < 0) /* Allocate packet buffers */ fatal("Can't allocate packet buffers!");#ifndef NOICP#ifdef MAC cmdini();#else /* Not MAC *//* Attempt to take ini file before doing command line */ *cmdfil = '\0'; /* Assume no command file. */ prescan(); /* But first check for -y option */#ifndef NOCCTRAP setint(); /* Set up interrupts */ if (setjmp(cmjbuf)) { /* Control-C trap returns to here. */#ifdef GEMDOS cc_clean(); /* Atari: Clean up after ^C-trap. */#endif /* GEMDOS */ doexit(GOOD_EXIT,-1); /* Exit with good status. */ } else {#endif /* NOCCTRAP */ cmdini(); /* Sets tlevel */ while (tlevel > -1) { /* Execute init file. */ sstate = parser(0); /* Loop getting commands. */ if (sstate) proto(); /* Enter protocol if requested. */ }#ifndef NOCCTRAP }#endif /* NOCCTRAP *//* In UNIX there are two ways to invoke Kermit with a cmdfile: (1) From the kermit command line, e.g. "kermit cmdfile [ options... ]" argv[0] = "kermit" argv[1] = "cmdfile" (2) By executing a cmdfile whose first line is like "#!/path/kermit" argv[0] = "/path/kermit" (sometimes just "kermit") argv[1] = "/path/cmdfile"*/ if (argc > 1) { if (*argv[1] != '-') { if (zchki(argv[1]) > 0) { strcpy(cmdfil,argv[1]); } } } if (*cmdfil) { /* If we got one, */ dotake(cmdfil); /* execute it */ while (tlevel > -1) { /* until it runs out. */ sstate = parser(1); /* Loop getting commands. */ if (sstate) proto(); /* Enter protocol if requested. */ } } *cmdfil = '\0'; /* Done, nullify the file name */#endif /* MAC */#endif /* NOICP */#ifndef NOCMDL/* Look for a UNIX-style command line... */ if (argc > 1) { /* Command line arguments? */ sstate = cmdlin(); /* Yes, parse. */ zstate = sstate; /* Remember sstate around protocol */ if (cflg) conect(); /* Connect first if requested */ if (sstate) { if (displa) concb((char)escape); /* (for console "interrupts") */#ifndef NOCCTRAP setint(); /* Set up interrupts */ if (setjmp(cmjbuf)) { /* Control-C trap returns to here. */#ifdef GEMDOS cc_clean();#endif /* GEMDOS */ if (cnflg) conect(); /* connect again if requested, */ } else {#endif /* NOCCTRAP */ proto(); /* Take any requested action, then */ if (!quiet) /* put cursor back at left margin, */ conoll(""); if (cnflg) conect(); /* connect if requested, */#ifndef NOCCTRAP }#endif /* NOCCTRAP */ }/* If interactive commands were given on the command line (using the -C "command, command, ..." option), assign them to a macro called "cl_commands", then execute the macro and leave it defined for subsequent re-execution if desired.*/#ifndef NOSPL if (clcmds) { /* Check for -C commands */ int x; x = addmac("cl_commands",clcmds); /* Put macro in table */ if (x > -1) { /* If successful, */ dodo(x,NULL); /* set up for macro execution */ while (maclvl > -1) { /* Loop getting macro commands. */ sstate = parser(1); if (sstate) proto(); /* Enter protocol if requested. */ } } }#endif /* NOSPL */#ifndef NOICP/* If a command-line action argument was given and -S ("stay") was not given, exit now.*/ if ((cflg || cnflg || zstate) && !stayflg)#endif /* NOICP */ doexit(GOOD_EXIT,xitsta); /* exit with good status */ }#endif /* NOCMDL */#ifdef NOICP /* No interactive command parser */ else {#ifndef NOCMDL usage(); /* Command-line-only version */ doexit(BAD_EXIT,-1);#else /* Neither one! */ doexit(BAD_EXIT,-1);#endif /* NOCMDL */ }#else /* not NOICP *//* If no action requested on command line, or if -S ("stay") was included, enter the interactive command parser.*/ herald(); /* Display program herald. */#ifndef NOCCTRAP /* If not no Control-C trap */ccagain: if (setjmp(cmjbuf)) { /* Control-C trap returns to here. */#ifdef GEMDOS cc_clean();#endif /* GEMDOS */ fixcmd(); /* Pop command stacks, etc. */ debug(F100,"ckcmai got interrupt","",0); goto ccagain; /* set up trap again. */ } else { debug(F100,"ckcmai setting interrupt trap","",0); setint(); /* Set up command interrupt traps */ }#else /* NOCCTRAP */ setint(); /* Set up command interrupt traps */#endif /* NOCCTRAP */#ifdef MAC while (1) { extern char *lfiles; /* fake pointer cast */ if (connected) { debug(F100, "main: calling macparser", "", 0); sstate = newparser(1, 1, 0L); /* ignore null command state */ if (sstate == 'n') sstate = '\0'; if (sstate) proto(); } else { /* * process take files the finder gave us. */ if ((tlevel == -1) && lfiles) startlfile(); debug(F100, "main: calling parser", "", 0); sstate = parser(0); if (sstate == 'c') /* if MAC connect */ sstate = 0; if (sstate) proto(); } }#else /* Not MAC *//* Running from an application file, or a command filename was specified on the command line.*/ if (*cmdfil) dotake(cmdfil); /* Command file spec'd on cmd line */ while(1) { /* Loop getting commands. */ sstate = parser(0); if (sstate) proto(); /* Enter protocol if requested. */ }#endif /* MAC */#endif /* NOICP */}#ifdef DYNAMIC/* Allocate file i/o buffers */char *zinbuffer, *zoutbuffer;intgetiobs() { zinbuffer = (char *)malloc(INBUFSIZE); if (!zinbuffer) return(-1); zoutbuffer = (char *)malloc(OBUFSIZE); if (!zoutbuffer) return(-1); debug(F100,"getiobs ok","",0); return(0);}#endif /* DYNAMIC */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -