📄 ckcmai.c
字号:
} else { /* * process take files the finder gave us. */ if ((tlevel == -1) && lfiles) startlfile(); debug(F100, "main: calling parser", "", 0); sstate = (CHAR) parser(0); if (sstate == 'c') /* if MAC connect */ sstate = 0; if (sstate) proto();#ifdef NTSIG ck_ih();#endif /* NTSIG */ } }#else /* Not MAC */#ifndef NOSPL/* 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.*/ 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,CF_CMDL); /* set up for macro execution */ while (maclvl > -1) { /* Loop getting macro commands. */ sstate = (CHAR) parser(1); if (sstate) proto(); /* Enter protocol if requested. */#ifdef NTSIG ck_ih();#endif /* NTSIG */ } } herald(); }#endif /* NOSPL *//* Running from an application file, or a command filename was specified on the command line.*/ debug(F101,"main cfilef","",cfilef); if (*cmdfil) { cfilef = 1; /* Remember we did this, */ dotake(cmdfil); /* Command file spec'd on cmd line */ } while(1) { /* Loop getting commands. */ sstate = (CHAR) parser(0); if (sstate) proto(); /* Enter protocol if requested. */#ifdef NTSIG ck_ih();#endif /* NTSIG */ }#ifdef NTSIG ckThreadEnd(threadinfo);#endif /* NTSIG */ /* return ; */ /* If this routine is void there should be no return */#endif /* MAC */}VOID #ifdef CK_ANSICfailicp(void * threadinfo)#else /* CK_ANSIC */failicp(threadinfo) VOID * threadinfo; #endif /* CK_ANSIC */{#ifdef GEMDOS cc_clean();#endif /* GEMDOS */ fixcmd(); /* Pop command stacks, etc. */ clcmds = NULL; debug(F100,"ckcmai got interrupt","",0);}#endif /* NOICP */#ifndef NOICPVOID #ifdef CK_ANSICdocmdfile(void * threadinfo) /* Execute application file */#else /* CK_ANSIC */docmdfile(threadinfo) VOID * threadinfo;#endif /* CK_ANSIC */{#ifdef NTSIG if (threadinfo) { /* Thread local storage... */ TlsSetValue(TlsIndex,threadinfo); debug( F100, "docmdfile called with threadinfo block","", 0 ) ; } else debug( F100, "docmdfile - threadinfo is NULL", "", 0 ) ;#endif /* NTSIG */ debug(F110,"main cmdfil",cmdfil,0); dotake(cmdfil); /* execute it */ while (tlevel > -1) { /* until it runs out. */ sstate = parser(1); /* Loop getting commands. */ if (sstate) proto(); /* Enter protocol if requested. */#ifdef NTSIG ck_ih();#endif /* NTSIG */ } cfilef = 1; /* Remember we did this */#ifdef NTSIG ckThreadEnd(threadinfo);#endif /* NTSIG */ return;}VOID #ifdef CK_ANSICfailcmdfile(void * threadinfo) #else /* CK_ANSIC */failcmdfile(threadinfo) VOID * threadinfo; #endif /* CK_ANSIC */{#ifdef GEMDOS cc_clean(); /* Atari: Clean up after ^C-trap. */#endif /* GEMDOS */ conoll("Interrupt during initialization or command-line processing."); conoll("C-Kermit quitting..."); doexit(BAD_EXIT,-1); /* Exit with bad status. */}#endif /* NOICP */VOIDsetprefix(z) int z; { /* Initial control-char prefixing */#ifdef CK_SPEED int i, val; prefixing = z; ptab[protocol].prefix = prefixing; switch(z) { case PX_ALL: /* All or None */ case PX_NON: val = (z == PX_ALL) ? 1 : 0; for (i = 1; i < 32; i++) ctlp[i] = val; for (i = 127; i < 160; i++) ctlp[i] = val; ctlp[255] = val; break; case PX_CAU: /* Cautious or Minimal */ case PX_WIL: for (i = 1; i < 32; i++) ctlp[i] = 0; for (i = 127; i < 160; i++) ctlp[i] = 0; ctlp[mystch] = ctlp[mystch+128] = 1; /* Kermit start of packet */ if (seol != 13) ctlp[seol] = ctlp[seol+128] = 1; /* Kermit end */ ctlp[13] = ctlp[141] = 1; /* In case of TELNET */ ctlp[(unsigned)255] = 1; /* Ditto */ ctlp[17] = ctlp[19] = 1; ctlp[145] = ctlp[147] = 1; if (prefixing == PX_CAU) { /* Cautious - add some more */ ctlp[3] = ctlp[13] = ctlp[16] = 1; ctlp[28] = ctlp[29] = ctlp[30] = 1; ctlp[131] = ctlp[141] = ctlp[144] = 1; ctlp[(unsigned)255] = ctlp[156] = ctlp[157] = ctlp[158] = 1; } break; }#endif /* CK_SPEED */}#ifdef aegis/* On the Apollo, intercept main to insert a cleanup handler */intckcmai(argc,argv) int argc; char **argv;#else#ifdef MAC /* Macintosh */intmain (void)#else#ifdef VMSGCC /* (Open)VMS with GCC compiler */intmain(argc,argv) int argc; char **argv;#else#ifdef __DECC /* DEC Alpha with DEC C compiler */#ifdef __ALPHAintmain(argc,argv) int argc; char **argv;#else /* DEC C compiler, not Alpha */VOIDmain(argc,argv) int argc; char **argv;#endif /* __ALPHA */#else#ifdef STRATUS /* Stratus VOS *//* ANSI main returns int, and VOS compiler complains if not so. */intmain(argc,argv) int argc; char **argv;#else /* All others */#ifdef NT#ifdef CK_WINvoidMain( int argc, char ** argv ) #elseVOIDmain(argc,argv) int argc; char **argv;#endif /* CK_TAPI */#elseVOIDmain(argc,argv) int argc; char **argv;#endif /* NT */#endif /* STRATUS */#endif /* __DECC */#endif /* VMSGCC */#endif /* MAC */#endif /* aegis *//* main */ {#ifdef datageneral short *pfha = 016000000036; /* Get around LANG_RT problem -- */ *pfha = (short) 0; /* No user protection fault handler */#endif /* datageneral *//* Do some initialization */#ifndef MAC xargc = xargs = argc; /* Make global copies of argc */ xargv = argv; /* ...and argv. */ xarg0 = argv[0];#ifndef NOICP#ifdef NT setOSVer();#endif /* NT */ prescan(0); /* Check for debugging */#endif /* NOICP */#endif /* MAC */ if (sysinit() < 0) /* System-dependent initialization. */ fatal("Can't initialize!");#ifdef CK_CURSES#ifndef OS2#ifndef COHERENT fxdinit(); /* Init fullscreen package */#endif /* COHERENT */#endif /* OS2 */#endif /* CK_CURSES */#ifdef TCPSOCKET#ifdef CK_SOCKS SOCKSinit(argv[0]); /* Internet relay package... */#endif /* CK_SOCKS */#endif /* TCPSOCKET */#ifdef CK_XYZ /* Initialize protocols... */#ifdef XYZ_INTERNAL /* XYZMODEM are internal ... */ initproto(PROTO_X, "rx %s","rx %s", NULL, NULL, NULL, NULL); initproto(PROTO_Y, "rb","rb", NULL, NULL, NULL, NULL); initproto(PROTO_G, "rb","rb", NULL, NULL, NULL, NULL); initproto(PROTO_Z, "rz","rz", NULL, NULL, NULL, NULL); initproto(PROTO_K, "kermit -ir","kermit -r", NULL, NULL, NULL, NULL); /* Kermit Must be last */#else /* XYZMODEM are external protocols ... */ /* s1 s2 s3 s4 s5 s6 */ initproto(PROTO_X, "rx %s","rx %s", "sx %s", "sx -a %s", "rx %s", "rx %s"); initproto(PROTO_Y, "rb", "rb", "sb %s", "sb -a %s", "rb", "rb" ); initproto(PROTO_G, "rb", "rb", "sb %s", "sb -a %s", "rb", "rb" ); initproto(PROTO_Z, "rz", "rz", "sz %s", "sz -a %s", "rz", "rz" ); initproto(PROTO_K, "kermit -ir", "kermit -r", NULL, NULL, NULL, NULL); /* Kermit must be last */#endif /* XYZ_INTERNAL */#else /* No XYZMODEM support */ initproto(PROTO_K, "kermit -ir","kermit -r", NULL, NULL, NULL, NULL);#endif /* CK_XYZ */ connoi(); /* Console interrupts off */ 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. */ myindex = getsysix(cksysid); if (local) if (ttopen(ttname,&local,0,0) < 0) { /* If default tty line */#ifndef OS2 conol("Can't open device: "); conoll(ttname);#endif /* OS2 */ local = 0; strcpy(ttname,CTTNAM); } speed = ttgspd(); /* Get transmission speed. */#ifdef ANYX25 initpad(); /* Initialize X.25 PAD */#endif /* ANYX25 */ if (inibufs(SBSIZ,RBSIZ) < 0) /* Allocate packet buffers */ fatal("Can't allocate packet buffers!");#ifndef NOCKSPEED setprefix(prefixing); /* Set up control char prefixing */#endif /* NOCKSPEED */#ifndef NOICP#ifdef MAC cmdini();#else /* Not MAC *//* Attempt to take ini file before doing command line */ *cmdfil = '\0'; /* Assume no command file. */ prescan(1); /* But first check for -y option */ debug(F101,"main argc after prescan()","",argc);/* Now process any relevant environment variables */#ifndef NODIAL getdialenv(); /* Dialing */#ifdef NETCONN ndinit(); /* Initialize network directory info */ getnetenv(); /* Network directories */#endif /* NETCONN */#endif /* NODIAL */#ifdef NOCCTRAP dotakeini(0);#else /* NOCCTRAP */ setint(); cc_execute( ckjaddr(cmjbuf), dotakeini, failtakeini );#endif /* NOCCTRAP */ debug(F101,"main 2 cfilef","",cfilef); if (*cmdfil) { /* If we got one (see prescan())... */#ifdef NOCCTRAP docmdfile(0); /* execute it. */#else /* NOCCTRAP */ setint(); cc_execute( ckjaddr(cmjbuf), docmdfile, failcmdfile );#endif /* NOCCTRAP */ } *cmdfil = '\0'; /* Done, nullify the file name */#endif /* MAC */#endif /* NOICP */#ifndef NOCMDL/* Look for a UNIX-style command line... */ what = W_NOTHING; debug(F101,"main argc","",argc); if (argc > 1) { /* Command line arguments? */ sstate = (CHAR) cmdlin(); /* Yes, parse. */ zstate = sstate; /* Remember sstate around protocol */#ifndef NOLOCAL if (cflg) /* Connect first if requested */ doconect(0);#endif /* NOLOCAL */ if (sstate) {#ifndef NOLOCAL if (displa) concb((char)escape); /* (for console "interrupts") */#endif /* NOLOCAL */#ifdef NOCCTRAP docmdline(1);#else /* NOCCTRAP */ setint(); cc_execute( ckjaddr(cmjbuf), docmdline, failcmdline );#endif /* NOCCTRAP */ }#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 */#ifndef NOICP#ifdef NETCONN if ((cflg || cnflg) && tn_exit && ttyfd == -1) doexit(GOOD_EXIT,xitsta); /* Exit with good status */#endif /* NETCONN */#endif /* NOICP */ }#endif /* NOCMDL */#ifdef NOICP /* No interactive command parser */ else {#ifndef NOCMDL /* Command-line-only version */ fatal("no command-line options given, type 'kermit -h' for help");#else /* Neither one! */ sstate = 'x'; proto(); /* So go into server mode */ doexit(GOOD_EXIT,xitsta); /* exit with good status */#endif /* NOCMDL */ }#else /* not NOICP *//* If no action requested on command line, or if -S ("stay") was included, enter the interactive command parser.*/ if (!clcmds) herald(); /* Display program herald. */#ifdef NOCCTRAP debug(F100,"ckcmai s
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -