📄 ckuus4.c
字号:
#endif /* NOSPL */#ifndef NOSPLstruct keytab fnctab[] = { /* Function names */#ifdef OS2 ".oox", FN_OOX, CM_INV, /* ... */#endif /* OS2 */ "basename", FN_BSN, 0, /* Basename */ "break", FN_BRK, 0, /* Break (as in Snobol) */ "capitalize", FN_CAP, 0, /* First Letter -> uppercase */ "caps", FN_CAP, CM_INV, /* ditto */ "character", FN_CHR, 0, /* Character from code */ "checksum", FN_CHK, 0, /* Checksum */ "code", FN_COD, 0, /* Code from character */ "contents", FN_CON, 0, /* Definition (contents) of variable */ "crc16", FN_CRC, 0, /* CRC-16 */#ifdef OS2 "crypt", FN_CRY, CM_INV,#endif /* OS2 */#ifdef ZFCDAT "date", FN_FD, 0, /* File modification/creation date */#endif /* ZFCDAT */ "definition", FN_DEF, 0, /* Return definition of given macro */ "evaluate", FN_EVA, 0, /* Evaluate given arith expression */ "execute", FN_EXE, 0, /* Execute given macro */ "files", FN_FC, 0, /* File count */ "hexify", FN_HEX, 0, /* Hexify */ "index", FN_IND, 0, /* Index (string search) */ "ipaddress", FN_IPA, 0, /* Find and return IP address */ "length", FN_LEN, 0, /* Return length of argument */ "literal", FN_LIT, 0, /* Return argument literally */ "lower", FN_LOW, 0, /* Return lowercased argument */ "lpad", FN_LPA, 0, /* Return left-padded argument */ "ltrim", FN_LTR, 0, /* Left-Trim */ "maximum", FN_MAX, 0, /* Return maximum of two arguments */ "minimim", FN_MIN, 0, /* Return minimum of two arguments */ "modulus", FN_MOD, CM_INV, /* Return modulus of two arguments */ "nextfile", FN_FIL, 0, /* Next file in list */ "pathname", FN_FFN, 0, /* Full file name */ "rep", FN_REP, CM_INV|CM_ABR, "repeat", FN_REP, 0, /* Repeat argument given # of times */ "replace", FN_RPL, 0, /* Replace characters in string */ "reverse", FN_REV, 0, /* Reverse the argument string */ "right", FN_RIG, 0, /* Rightmost n characters of string */ "rindex", FN_RIX, 0, /* Right index */ "rpad", FN_RPA, 0, /* Right-pad the argument */ "size", FN_FS, 0, /* File size */ "span", FN_SPN, 0, /* Span - like Snobol */ "substring", FN_SUB, 0, /* Extract substring from argument */ "tod2secs", FN_TOD, 0, /* Time-of-day-to-secs-since-midnite */ "trim", FN_TRM, 0, /* Trim */ "unhexify", FN_UNH, 0, /* Unhexify */ "upper", FN_UPP, 0, /* Return uppercased argument */ "verify", FN_VER, 0 /* Verify */};int nfuncs = (sizeof(fnctab) / sizeof(struct keytab));#endif /* NOSPL */#ifndef NOSPL /* Buffer for expansion of */#define VVBUFL 256 /* built-in variables. */char vvbuf[VVBUFL+1];#endif /* NOSPL */struct keytab disptb[] = { /* Log file disposition */ "append", 1, 0, "new", 0, 0};/* P R E S C A N -- A quick look through the command-line options for items that must be handled before the initialization file is executed.*/#ifdef NTextern int StartedFromDialer;#endif /* NT */VOIDprescan(y) int y; { int yargc; char **yargv; char x; char *yp; yargc = xargc; yargv = xargv;#ifdef DCMDBUF if (!kermrc) if (!(kermrc = (char *) malloc(KERMRCL+1))) fatal("prescan: no memory for kermrc");#endif /* DCMDBUF */ strcpy(kermrc,KERMRC); /* Default init file name */#ifndef NOCMDL#ifndef NOICP if (yargc > 1 && *yargv[1] != '-') { /* Filename as 1st argument */#ifdef OS2 extern char startupdir[], exedir[], inidir[]; char * scriptenv, * keymapenv;#endif /* OS2 */#ifdef DCMDBUF extern char * cmdbuf;#else extern char cmdbuf[];#endif /* DCMDBUF */ char takepath[1024]; char *s; int x, y; if (!isabsolute(yargv[1])) { /* If not absolute */ /* Set up search path... */#ifdef OS2 #ifdef NT scriptenv = getenv("K95SCRIPTS"); keymapenv = getenv("K95KEYMAPS");#else /* NT */ scriptenv = getenv("K2SCRIPTS"); keymapenv = getenv("K2KEYMAPS");#endif /* NT */ if (!scriptenv) scriptenv = getenv("CK_SCRIPTS"); if (!keymapenv) keymapenv = getenv("CK_KEYMAPS"); sprintf(takepath, /* semicolon-separated path list */ "%s%s%s%s%s;%s%s;%s%s;%s;%s%s;%s%s;%s;%s%s;%s%s", scriptenv?scriptenv:"", (scriptenv && scriptenv[strlen(scriptenv)-1]==';')?"":";", keymapenv?keymapenv:"", (keymapenv && keymapenv[strlen(keymapenv)-1]==';')?"":";", startupdir, startupdir, "SCRIPTS/", startupdir, "KEYMAPS/", inidir, inidir, "SCRIPTS/", inidir, "KEYMAPS/", exedir, exedir, "SCRIPTS/", exedir, "KEYMAPS/" );#else /* not OS2 */#ifndef NOSPL y = 1024; /* Look in home directory */ s = takepath; zzstring("\\v(home)",&s,&y);#else takepath[0] = '\0';#endif /* NOSPL */#endif /* OS2 *//* All the logic for searching the take path is in the command parser. So even though we aren't parsing commands, we initialize and call the parser from here, with the purported filename stuffed into the command buffer, followed by some carriage returns to make the parser return. If the file is not found, or otherwise not accessible, the parser prints an appropriate message, and then we just exit.*/ cmdini(); /* Allocate command buffers etc */ cmini(0); /* Initialize them */ strcpy(cmdbuf,yargv[1]); /* Stuff filename into command buf */ strcat(cmdbuf,"\r\r"); /* And some carriage returns */ if ((y = cmifip("","",&s,&x,0,takepath,xxstring)) < 0) doexit(BAD_EXIT,xitsta); cmres(); } else s = yargv[1]; /* cfilef = 1; */ /* Command file */#ifdef ZFNQFP zfnqfp(s,CKMAXPATH,cmdfil); /* In case of CD in file */#else strncpy(cmdfil,CKMAXPATH,s);#endif /* ZFNQFP */ yargc -= 1; /* Skip past the filename */ yargv += 1; /* Otherwise we'll get an error */ }#endif /* NOICP */ while (--yargc > 0) { /* Go through command-line args */ yargv++; yp = *yargv+1; /* Pointer for bundled args */ if (**yargv == '=') return; /* Same rules as cmdlin()... */#ifdef VMS else if (**yargv == '/') continue;#endif /* VMS */ else if (**yargv == '-') { /* Got an option (begins with dash) */ x = *(*yargv+1); /* Get option letter */ while (x) { /* Allow for bundled options */ debug(F000,"prescan arg","",x); switch (x) {#ifdef OS2 case 'W': if (*(yp+1)) fatal("invalid argument bundling after -W"); yargv++, yargc--; if (yargc < 1) fatal("Window handle missing"); if (y) { yargv++, yargc--; break; } else { hwndDialer = (HWND) atol(*yargv); StartedFromDialer = 1; yargv++, yargc--; KermitDialerID = atol(*yargv) ; } break;#endif /* OS2 */#ifndef NOSPL case 'M': /* My User Name */ if (*(yp+1)) { fatal("invalid argument bundling"); } yargv++, yargc--; if ((yargc < 1) || (**yargv == '-')) { fatal("missing username"); } if ((int)strlen(*yargv) > 63) { fatal("username too long"); } strcpy(uidbuf,*yargv); break;#endif /* NOSPL */ case 'R': /* Remote-only advisory */#ifdef CK_IFRO remonly = 1;#endif /* CK_IFRO */ break; case 'S': /* STAY */ stayflg = 1; break; case 'h': case 'Y': /* No init file */ noinit = 1; break; case 'd': /* = SET DEBUG ON */#ifdef DEBUG if (!deblog) deblog = debopn("debug.log",0);#endif /* DEBUG */ break; case 'y': /* Alternative init file */ yargv++, yargc--; if (yargc < 1) fatal("missing name in -y"); if (!y) break; strcpy(kermrc,*yargv); /* Replace init file name */ rcflag = 1; /* Flag that this has been done */ break; case 'z': /* = SET BACKGROUND OFF */ bgset = 0; break;#ifdef CK_NETBIOS case 'N': { int n ; yargv++, yargc--; if (y) break; if (strlen(*yargv) != 1 || (*yargv)[0] == 'X') { NetBiosAdapter = -1; } else { n = atoi(*yargv); if (n >= 0 && n <= 9) NetBiosAdapter = n; else NetBiosAdapter = -1; } } break;#endif /* CK_NETBIOS */ default: break; } x = *++yp; /* See if options are bundled */ } } }#endif /* NOCMDL */}static int tr_int; /* Flag if TRANSMIT interrupted */#ifndef MACSIGTYP#ifdef CK_ANSICtrtrap(int foo) /* TRANSMIT interrupt trap */#else trtrap(foo) int foo; /* TRANSMIT interrupt trap */#endif /* CK_ANSIC *//* trtrap */ {#ifdef __EMX__ signal(SIGINT, SIG_ACK);#endif tr_int = 1; /* (Need arg for ANSI C) */ SIGRETURN;}#endif /* MAC */#endif /* NOICP *//* G E T T C S -- Get Transfer (Intermediate) Character Set *//* Given two file character sets, this routine picks out the appropriate "transfer" character set to use for translating between them. The transfer character set number is returned. Translation between two file character sets is done, for example, by the CONNECT, TRANSMIT, and TRANSLATE commands. Translation between Kanji character sets is not yet supported.*/intgettcs(cs1,cs2) int cs1, cs2; {#ifdef NOCSETS /* No character-set support */ return(0); /* so no translation */#else int tcs = TC_TRANSP;#ifdef KANJI/* Kanji not supported yet */ if (fcsinfo[cs1].alphabet == AL_JAPAN || fcsinfo[cs2].alphabet == AL_JAPAN ) tcs = TC_TRANSP; else#endif /* KANJI */#ifdef CYRILLIC/* I can't remember why we don't test both sets here, but I think there must have been a reason...*/ if (fcsinfo[cs2].alphabet == AL_CYRIL) tcs = TC_CYRILL; else#endif /* CYRILLIC */#ifdef LATIN2 if (cs1 == FC_2LATIN || cs2 == FC_2LATIN || cs1 == FC_CP852 || cs2 == FC_CP852 ) tcs = TC_2LATIN; else#endif /* LATIN2 */#ifdef HEBREW if (fcsinfo[cs1].alphabet == AL_HEBREW || fcsinfo[cs2].alphabet == AL_HEBREW ) tcs = TC_HEBREW; else#endif /* HEBREW */ tcs = TC_1LATIN; return(tcs);#endif /* NOCSETS */}#ifndef NOLOCAL/* D O C O N E C T -- Do the connect command *//* q = 0 means issue normal informational message about how to get back, etc. q != 0 means to skip the message.*/intdoconect(q) int q; { int x; /* Return code */ extern int what;#ifndef NOKVERBS /* Keyboard macro material */ extern int keymac, keymacx;#endif /* NOKVERBS */ extern int justone; int qsave; /* For remembering "quiet" value *//* Saving, changing, and restoring the global "quiet" variable around calls to conect() to control whether the verbose CONNECT message is printed is obviously less elegant than passing a parameter to conect(), but we do it this way to avoid the need to change all of the ck?con.c modules. NOTE: it is important to restore the value immediately upon return in case there is an autodownload or APC.*/ qsave = quiet; /* Save it */ if (!quiet && q > -1) quiet = q; /* Use argument temporarily */ conres(); /* Put console back to normal */ debug(F101,"doconect justone 1","",justone); x = conect(); /* Connect the first time */ quiet = qsave; /* Restore "quiet" value */ debug(F101,"doconect justone 2","",justone);#ifdef NETCONN if (network && tn_exit && ttyfd == -1) doexit(GOOD_EXIT,xitsta); /* Exit with good status */ #endif /* NETCONN */ concb((char)escape); /* Restore console for commands */#ifdef CK_APC/* If an APC command was received during CONNECT mode, we define it now as a macro, execute the macro, and then return to CONNECT mode. We do this in a WHILE loop in case additional APCs come during subsequent CONNECT sessions.*/ while (apcactive == APC_LOCAL || apcactive == APC_REMOTE && apcstatus != APC_OFF) { debug(F101,"doconect justone 3","",justone); domac("apc_commands",apcbuf,cmdstk[cmdlvl].ccflgs|CF_APC); if (!apcactive) /* In case CLEAR APC was in APC */ break;#ifdef OS2 msleep(250);#endif /* OS2 */ debug(F101,"doconect justone 4","",justone); qsave = quiet; /* Do this again... */ if (!quiet && q > -1) quiet = q; x = conect(); /* Re-CONNECT. */ quiet = qsave; debug(F101,"doconect justone 5","",justone);#ifdef NETCONN if (network && tn_exit && ttyfd == -1) doexit(GOOD_EXIT,xitsta); /* Exit with good status */ #endif /* NETCONN */ concb((char)escape); /* Restore console. */ if (ttyfd == -1) break; } /* Loop back for more. */#endif /* CK_APC */#ifndef NOKVERBS if ((keymac > 0) && (keymacx > -1)) { /* Executing a keyboard macro? */ /* Set up the macro and return */ /* Do not clear the keymac flag */ return(dodo(keymacx,NULL,CF_KMAC|cmdstk[cmdlvl].ccflgs)); }#endif /* NOKVERBS */ what = W_COMMAND; /* Back in command mode. */ return(x); /* Done. */}#endif /* NOLOCAL */#ifndef NOICP #ifdef COMMENT/* It seemed that this was needed for OS/2, in which \v(cmdfile) and other file-oriented variables or functions can return filenames containing backslashes, which are subsequently interpreted as quotes rather than directory separators (e.g. see commented section for VN_CMDF below). But the problem can't be cured at this level. Example: type \v(cmdfile) Without doubling, the filename is parsed correctly, but then when passed to UNIX 'cat' through the shell, the backslash is removed, and then cat can't open the file. With doubling, the filename is not parsed correctly and the TYPE command fails immediately with a "file not found" error.*//* Utility routine to double all backslashes in a string. s1 is pointer to source string, s2 is pointer to destination string, n is length of destination string, both NUL-terminated. Returns 0 if OK, -1 if not OK (destination string too short).*/intdblbs(s1,s2,n) char *s1, *s2; int n; { int i = 0; while (*s1) { if (*s1 == '\\') { if (++i > n) return(-1); *s2++ = '\\'; } if (++i > n) return(-1); *s2++ = *s1++; } *s2 = NUL; return(0);}#endif /* COMMENT */char * gmdmtyp() { /* Get modem type */#ifndef NODIAL
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -