📄 ckuus4.c
字号:
"fpcosine", FN_FPCOS, 0, /* FP cosine */ "fpdivide", FN_FPDIV, 0, /* FP divide */ "fpexp", FN_FPEXP, 0, /* FP e to the x */ "fpint", FN_FPINT, 0, /* FP to integer */ "fplog10", FN_FPLOG, 0, /* FP base-10 logarithm */ "fplogn", FN_FPLN, 0, /* FP natural logarithm */ "fpmaximum", FN_FPMAX, 0, /* FP maxinum */ "fpminimum", FN_FPMIN, 0, /* FP mininum */ "fpmodulus", FN_FPMOD, 0, /* FP modulus */ "fpmultiply", FN_FPMUL, 0, /* FP multiply */ "fpraise", FN_FPPOW, 0, /* FP raise to a power */ "fpround", FN_FPROU, 0, /* FP round */ "fpsine", FN_FPSIN, 0, /* FP sine */ "fpsqrt", FN_FPSQR, 0, /* FP square root */ "fpsubtract", FN_FPSUB, 0, /* FP subtract */ "fptangent", FN_FPTAN, 0, /* FP tangent */#endif /* FNFLOAT */ "hex2ip", FN_HEX2IP,0, /* Hex to IP address */ "hex2n", FN_HEX2N, CM_INV, /* Hex to decimal number */ "hexify", FN_HEX, 0, /* Hexify (string) */ "index", FN_IND, 0, /* Index (string search) */ "ip2hex", FN_IP2HEX,0, /* IP address to hex */ "ipaddress", FN_IPA, 0, /* Find and return IP address */ "jdate", FN_JDATE, CM_INV, /* Date to Day of Year */#ifdef CK_KERBEROS "krbflags", FN_KRB_FG, 0, /* Kerberos functions */ "krbisvalid", FN_KRB_IV, 0, "krbnextticket", FN_KRB_NX, 0, "krbtickets", FN_KRB_TK, 0, "krbtimeleft", FN_KRB_TT, 0,#endif /* CK_KERBEROS */ "left", FN_LEF, 0, /* Leftmost n characters of string */ "length", FN_LEN, 0, /* Return length of argument */ "literal", FN_LIT, 0, /* Return argument literally */ "lop", FN_STL, 0, /* Lop */ "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 */ "mjd", FN_MJD, 0, /* Date to Modified Julian Date */ "mjd2date", FN_MJD2, 0, /* MJD to Date */ "modulus", FN_MOD, CM_INV, /* Return modulus of two arguments */ "n2hex", FN_2HEX, CM_INV, /* Number to hex */ "n2octal", FN_2OCT, CM_INV, /* Number to octal */ "n2time", FN_N2TIM,0, /* Number to hh:mm:ss */ "nday", FN_NDAY, 0, /* Numeric day of week */ "nextfile", FN_FIL, 0, /* Next file in list */ "ntime", FN_NTIM, 0, /* Time to seconds since midnight */ "oct2n", FN_OCT2N,CM_INV, /* Octal to decimal number */ "pathname", FN_FFN, 0, /* Full file name */ "pattern", FN_PATTERN, 0, /* Pattern (for INPUT) */#ifdef CK_PERMS "permissions",FN_PERM, 0, /* Permissions of file */#else "permissions",FN_PERM, CM_INV, /* Permissions of file */#endif /* CK_PERMS */ "radix", FN_RADIX,0, /* Radix conversion */#ifndef NORANDOM "random", FN_RAND, 0, /* Random number */#endif /* NORANDOM */#ifndef NOPUSH "rawcommand", FN_RAW, 0, /* Output from a command (raw) */#endif /* NOPUSH */#ifdef RECURSIVE "rdirectories", FN_RDIR, 0, /* Recursive directory list */ "rfiles", FN_RFIL, 0, /* Recursive file list */#endif /* RECURSIVE */ "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 */ "rsearch", FN_RSEARCH, 0, /* R-L Search for pattern in string */#ifdef OS2 "scrncurx", FN_SCRN_CX, 0, /* Screen Cursor X Pos */ "scrncury", FN_SCRN_CY, 0, /* Screen Cursor Y Pos */ "scrnstr", FN_SCRN_STR, 0, /* Screen String */#endif /* OS2 */ "search", FN_SEARCH, 0, /* L-R Search for pattern in string */ "size", FN_FS, 0, /* File size */ "span", FN_SPN, 0, /* Span - like Snobol */ "split", FN_SPLIT,0, /* Split string into words */ "stripb", FN_STB, 0, /* Strip enclosing braces/brackets */ "stripn", FN_STN, 0, /* Strip n chars */ "stripx", FN_STX, 0, /* Strip "extension" */ "substring", FN_SUB, 0, /* Extract substring from argument */ "tablelook", FN_TLOOK,0, /* Table lookup */ "time", FN_TIME, 0, /* Free-format time to hh:mm:ss */ "tod2secs", FN_NTIM, CM_INV, /* 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 */ "word", FN_WORD, 0, /* Extract a word */ "", 0, 0};int nfuncs = (sizeof(fnctab) / sizeof(struct keytab)) - 1;#endif /* NOSPL */#ifndef NOSPL /* Buffer for expansion of */#ifdef BIGBUFOK /* built-in variables. */#define VVBUFL 1024#else#define VVBUFL 256#endif /* BIGBUFOK */char vvbuf[VVBUFL+1];#endif /* NOSPL */struct keytab disptb[] = { /* Log file disposition */ "append", 1, 0, "new", 0, 0};#ifdef FNFLOAT/* I N I T F L O A T -- Deduce floating-point precision by inspection */int fp_rounding = 0; /* Nonzero if printf("%f") rounds */int fp_digits = 0; /* Digits of floating point precision */#ifdef COMMENT/* For looking at internal floating-point representations */static char fp_xbuf[128];static char *tohex(s, n) CHAR * s; int n; { int x; char * p = fp_xbuf; while (n-- > 0) { x = (*s >> 4) & 0x0f; *p++ = hexdigits[x]; x = *s++ & 0x0f; *p++ = hexdigits[x]; } *p = NUL; return((char *)fp_xbuf);}#endif /* COMMENT */VOIDinitfloat() { char buf[256]; int i, x, y;#ifdef COMMENT /* For looking at internal floating-point representations */ double a[] = { 0.0, 0.5, 0.05, 0.005, 0.0005, 0.00005, 0.5e-20, 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 }; int n = sizeof(a) / sizeof(double); union blah { CHAR xbuf[32]; double f; } u;#endif /* COMMENT */ sprintf(buf,"%0.250f",(10.0 / 3.0)); for (i = 2; i < 250 && buf[i] == '3'; i++) ; x = i - 1; debug(F111,"initfloat 10.0/3.0",buf,x); sprintf(buf,"%0.250f",(4.0 / 9.0)); for (i = 2; i < 250 && buf[i] == '4'; i++) ; y = i - 1; debug(F111,"initfloat 4.0/9.0",buf,y); fp_digits = (x < y) ? x : y; sprintf(buf,"%0.6f",(7.0 / 9.0)); if (buf[7] == '8') fp_rounding = 1; debug(F111,"initfloat 7.0/9.0",buf,fp_rounding); debug(F101,"initfloat precision","",fp_digits);#ifdef COMMENT for (i = 0; i < n; i++) { memset(u.xbuf,0,32); u.f = a[i]; sprintf(buf,"initfloat %f", u.f); debug(F110,buf,tohex(u.xbuf,8),0); }#endif /* COMMENT */}#endif /* FNFLOAT *//* 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 */#ifdef OS2extern int k95stdio;unsigned long startflags = 0L;#endif /* OS2 */static char *findinpath(arg) char * arg; {#ifdef OS2 extern char startupdir[], exedir[], inidir[]; char * scriptenv, * keymapenv; int len;#endif /* OS2 */#ifdef DCMDBUF extern char * cmdbuf;#else extern char cmdbuf[];#endif /* DCMDBUF */ char takepath[4096]; char * s; int x, z; /* 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 (!scriptenv) scriptenv = ""; if (!keymapenv) keymapenv = getenv("CK_KEYMAPS"); if (!keymapenv) keymapenv = ""; debug(F110,"startupdir",startupdir,0); debug(F110,"inidir",inidir,0); debug(F110,"exedir",exedir,0); len = strlen(scriptenv) + strlen(keymapenv) + 3*strlen(startupdir) + 3*strlen(inidir) + 3*strlen(zhome()) + 3*strlen(exedir) + 4*strlen("SCRIPTS/") + 4*strlen("KEYMAPS/") + 16; if (len >= 4096) { takepath[0] = '\0'; debug(F111,"findinpath error - path length too long","len",len); } else 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[0] && scriptenv[strlen(scriptenv)-1]==';')?"":";", keymapenv, (keymapenv[0] && keymapenv[strlen(keymapenv)-1]==';')?"":";", startupdir, startupdir, "SCRIPTS/", startupdir, "KEYMAPS/", inidir, inidir, "SCRIPTS/", inidir, "KEYMAPS/", zhome(), zhome(), "SCRIPTS/", zhome(), "KEYMAPS/", exedir, exedir, "SCRIPTS/", exedir, "KEYMAPS/" );#else /* not OS2 */#ifndef NOSPL z = 1024; /* Look in home directory */ s = takepath; zzstring("\\v(home)",&s,&z);#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 */ /* Stuff filename into command buf with braces in case of spaces */ sprintf(cmdbuf,"{%s}",arg); debug(F110,"prescan cmdbuf",cmdbuf,0); strcat(cmdbuf,"\r\r"); /* And some carriage returns */ if (cmifip("","",&s,&x,0,takepath,xxstring) < 0) return(NULL); cmres(); return(s);}static int tr_int; /* Flag if TRANSMIT interrupted */#ifndef MACSIGTYP#ifdef CK_ANSICtrtrap(int foo) /* TRANSMIT interrupt trap */#elsetrtrap(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 */int arg_x = 0;static int x_prescan = 0;/* The argument y once meant something but I can't imagine what so now it's ignored. (Prior to 22 Aug 98, prescan() was called twice by main(), and the arg differentiated the two calls. But this caused all sorts of problems & confusion, so I commented out the second call. This issue might need to be revisited.)*/VOIDprescan(dummy) int dummy; { /* Arg is ignored. */ extern int howcalled; int yargc; char **yargv; char x; char *yp; int z; if (x_prescan) /* Only run once */ return; x_prescan = 1; yargc = xargc; /* Make copy of arg vector */ yargv = xargv;#ifndef NOICP#ifdef DCMDBUF if (!kermrc) if (!(kermrc = (char *) malloc(KERMRCL+1))) fatal("prescan: no memory for kermrc");#endif /* DCMDBUF */ ckstrncpy(kermrc,KERMRC,KERMRCL); /* Default init file name */#endif /* NOICP */#ifdef IKSD if (howcalled == I_AM_IKSD) /* Internet Kermit Service daemon */ inserver = 1; /* (See inserver section of ckcmai) */ else#endif /* IKSD */ if (howcalled != I_AM_KERMIT) /* I'm called "telnet" or... */ return;/* Command line options for Kermit */#ifndef NOCMDL#ifndef NOICP if (yargc > 1 && *yargv[1] != '-' && strcmp(yargv[1],"=")#ifdef KERBANG && strcmp(yargv[1],"+")#endif /* KERBANG */ ) { /* Filename as 1st argument */ char *s; int x, y; x = isabsolute(yargv[1]); if (!x) /* If not absolute */ s = findinpath(yargv[1]); else s = yargv[1]; if (!s) doexit(BAD_EXIT,xitsta); zfnqfp(s,CKMAXPATH,cmdfil); /* In case of CD in file */ 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 == '=') /* Same rules as cmdlin()... */ return; debug(F110,"prescan *yargv",*yargv,0);#ifndef NOICP#ifdef KERBANG if (!strcmp(*yargv,"+")) { char * s; yargv++; noinit = 1; if (!*yargv) return; cfilef = 1; s = findinpath(*yargv); if (s) { zfnqfp(s,CKMAXPATH,cmdfil); return; } else doexit(BAD_EXIT,xitsta); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -