📄 ckuus4.c
字号:
struct keytab disptb[] = { /* Log file disposition */ { "append", 1, 0}, { "new", 0, 0}};#ifdef CKFLOAT/* 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 */char math_pi[] = "3.1415926535897932384626433832795";char math_e[] = "2.7182818284590452353602874713527";VOIDinitfloat() { char * buf = NULL; int i, x, y;/* We malloc a big temporary buffer for sprintf() to minimize likelihood of (and damage from) sprintf buffer overflows. In any case, the only way this could happen would be if sprintf() itself had bugs, since the format descriptor says to cut it off at 250 decimal places.*/ if ((buf = (char *)malloc(4096))) { 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; if (fp_digits < sizeof(math_pi) - 1) { math_pi[fp_digits+1] = NUL; math_e[fp_digits+1] = NUL; } 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); free(buf); }}#endif /* CKFLOAT *//* 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 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 char * appdata0 = NULL, *appdata1 = NULL;#ifdef NT scriptenv = getenv("K95SCRIPTS"); keymapenv = getenv("K95KEYMAPS"); makestr(&appdata0,(char *)GetAppData(0)); makestr(&appdata1,(char *)GetAppData(1));#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,"common appdata directory",appdata1,0); debug(F110,"appdata directory",appdata0,0); debug(F110,"inidir",inidir,0); debug(F110,"home",zhome(),0); debug(F110,"exedir",exedir,0); len = strlen(scriptenv) + strlen(keymapenv) + 3*strlen(startupdir) + 3*strlen(inidir) + 3*strlen(zhome()) + 3*strlen(exedir) + (appdata0 ? 3*strlen(appdata0) : 0) + (appdata1 ? 3*strlen(appdata1) : 0) + 6*strlen("SCRIPTS/") + 6*strlen("KEYMAPS/") + 16; if (len >= 4096) { /* SAFE (length is checked) */ 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%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/", appdata1 ? appdata1 : "", appdata1 ? "Kermit 95;" : "", appdata1 ? appdata1 : "", appdata1 ? "Kermit 95/SCRIPTS/;" : "", appdata1 ? appdata1 : "", appdata1 ? "Kermit 95/KEYMAPS/;" : "", appdata0 ? appdata0 : "", appdata0 ? "Kermit 95;" : "", appdata0 ? appdata0 : "", appdata0 ? "Kermit 95/SCRIPTS/;" : "", appdata0 ? appdata0 : "", appdata0 ? "Kermit 95/KEYMAPS/;" : "", inidir, inidir, "SCRIPTS/", inidir, "KEYMAPS/", zhome(), zhome(), "SCRIPTS/", zhome(), "KEYMAPS/", exedir, exedir, "SCRIPTS/", exedir, "KEYMAPS/" ); debug(F110,"findinpath takepath",takepath,0);#ifdef NT makestr(&appdata0,NULL); makestr(&appdata1,NULL);#endif /* NT */#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 */ ckmakmsg(cmdbuf,CMDBL,"{",arg,"}",NULL); debug(F110,"findinpath cmdbuf",cmdbuf,0); ckstrncat(cmdbuf,"\r\r",CMDBL); /* 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 */#ifdef UNIXVOIDgetexedir() { extern char * xarg0; long xx; /* Unix provides no standard service for this. We look in argv[0], and if we're lucky there's a full pathname. If not we do a PATH search. */ if (ckstrchr(xarg0,'/')) { /* Global copy of argv[0] */ int i, k; char * p = NULL; if ((k = ckstrncpy(tmpbuf,xarg0,TMPBUFSIZ-2)) > 0) { p = tmpbuf; /* Convert to fully qualified pathname */ if (tmpbuf[0]) if (tmpbuf[0] != '/') { line[0] = NUL; zfnqfp(tmpbuf,LINBUFSIZ-2,(char *)line); if (line[0]) p = line; } xx = zchki(p); if (xx > -1) { /* Is the result an existing file? */ k = strlen(p); for (i = k-1; i > 0; i--) { /* Yes, strip name part */ if (p[i] == '/') { if (i < k-1) p[i+1] = NUL; break; } } } makestr(&exedir,p); /* Save the result */ } } if (!exedir && xarg0) { /* Not found? */ char * p; p = getenv("PATH"); /* Search the PATH */ if (p) { /* If there is one... */ char * q, * PATH = NULL; int k; makestr(&PATH,p); /* Pokeable copy of PATH string */ if (PATH) { /* If malloc succeeded... */ p = PATH; while (p && *p) { /* Loop through segments */ q = ckstrchr(p,':'); /* End of this segment */ if (q == p) { /* Null PATH segment */ p++; /* Skip over colon */ continue; } if (q) /* If not at end of PATH string */ *q++ = NUL; /* zero out the colon */ if ((k = ckstrncpy(tmpbuf,p,TMPBUFSIZ)) > 0) { if (tmpbuf[k-1] != '/') { /* Copy this PATH segment */ tmpbuf[k++] = '/'; /* Append '/' if needed */ tmpbuf[k] = NUL; } /* Append the argv[0] value */ if (ckstrncpy(&tmpbuf[k],xarg0,TMPBUFSIZ) > 0) { if (zchki(tmpbuf) > -1) { /* File exists? */ tmpbuf[k] = NUL; /* Yes, we're done */ zfnqfp(tmpbuf,LINBUFSIZ,(char *)line); makestr(&exedir,line); break; } } else break; } else break; p = q; /* Not found, go to next segment */ } /* while */ free(PATH); /* Free PATH copy */ } } if (!exedir) { /* Still nothing? */ if (zchki(xarg0) > -1) { /* Maybe it's in the current dir */ zfnqfp(zgtdir(),LINBUFSIZ,(char *)line); makestr(&exedir,line); } } } if (!exedir) { /* Still nothing? */ makestr(&exedir,"/"); /* Fake it with with root. */ }}#endif /* UNIX */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, *yy;#ifdef DEBUG int debcount = 0;#endif /* DEBUG */ 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) */#endif /* IKSD *//* Command line options for Kermit */#ifndef NOCMDL if (yargc > 1 && *yargv[1] != '-' && (yargv[1][0] != '=')#ifdef KERBANG && (yargv[1][0] != '+')#endif /* KERBANG */#ifdef IKSD && (howcalled != I_AM_IKSD)#endif /* IKSD */ ) { /* Filename as 1st argument */#ifndef NOICP char *s;#endif /* NOICP */#ifndef NOURL extern int haveurl; extern struct urldata g_url; if (urlparse(yargv[1],&g_url)) { if (!ckstrcmp(g_url.svc,"ftp",-1,0) || !ckstrcmp(g_url.svc,"ftps",-1,0)) { haveurl = 1; howcalled = I_AM_FTP; } else if (!ckstrcmp(g_url.svc,"telnet",-1,0) || !ckstrcmp(g_url.svc,"telnets",-1,0)) { haveurl = 1; howcalled = I_AM_TELNET; } else if (!ckstrcmp(g_url.svc,"ssh",-1,0)) { haveurl = 1; howcalled = I_AM_SSH; } else if (!ckstrcmp(g_url.svc,"iksd",-1,0) || !ckstrcmp(g_url.svc,"kermit",-1,0)) { haveurl = 1; howcalled = I_AM_KERMIT; } else if (!ckstrcmp(g_url.svc,"http",-1,0) ||
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -