📄 ckuus5.c
字号:
if (x > -1) mactab[x].flgs = CM_INV; x = addmmac("_switx",sw_def); /* SWITCH macro */ if (x > -1) mactab[x].flgs = CM_INV;/* Fill in command-line argument vector */ sprintf(vnambuf,"\\&@[%d]",xargs); /* Command line argument vector */ if (inserver) { /* (except in IKSD) */ y = -1; xargs = 0; } else y = arraynam(vnambuf,&x,&z); /* goes in array \&@[] */ if (y > -1) { int j = -1; int yy = 0; dclarray((char)x,z); /* Declare the array */#ifndef NOTAKEARGS sprintf(vnambuf,"\\&_[%d]",z); /* Macro argument vector */ yy = arraynam(vnambuf,&x,&z); /* goes in array \&_[] */ if (yy > -1) /* Name is OK */ dclarray((char)x,z); /* Declare the array */#endif /* NOTAKEARGS */ skip = 0; for (i = 0; i < xargs; i++) { /* Fill the arrays */ sprintf(vnambuf,"\\&@[%d]",i); addmac(vnambuf,xargv[i]); if (cfilef && i == 0) continue;#ifdef KERBANG if (skip) { j = 0; skip = 0; continue; }#endif /* KERBANG */ if (j < 0 && /* Assign items after "=" or "--"*/ (!strcmp(xargv[i],"=") || !strcmp(xargv[i],"--")) ) { j = 0; /* to \%1..\%9 */#ifdef KERBANG } else if (j < 0 && !strcmp(xargv[i],"+")) { skip = 1; continue;#endif /* KERBANG */ } else if (j > -1) { j++; if (j <= 9) { vnambuf[0] = '\\'; vnambuf[1] = '%'; vnambuf[2] = (char)(j+'0'); vnambuf[3] = NUL; addmac(vnambuf,xargv[i]); } if (yy > -1) makestr(&(toparg[j]),xargv[i]); } } if (cfilef) { addmac("\\%0",cmdfil); if (yy > -1) makestr(&(toparg[0]),cmdfil); } else { addmac("\\%0",xargv[0]); if (yy > -1) makestr(&(toparg[0]),xargv[0]); } if (yy > -1) { topargc = (j < 0) ? 1 : j + 1; topxarg = toparg; } else { topargc = 0; topxarg = NULL; } a_dim[0] = topargc - 1; a_ptr[0] = topxarg; } *vnambuf = NUL;#endif /* NOSPL *//* Get our home directory now. This needed in lots of places. */ homdir = zhome(); cmdinited = 1;}VOIDdoinit() { int x = 0, ok = 0;#ifdef OS2 char * ptr = 0;#endif /* OS2 */ if (!cmdinited) cmdini();#ifdef MAC return; /* Mac Kermit has no init file */#else /* !MAC *//* If skipping init file ('-Y' on Kermit command line), return now. */ if (noinit) { kermrc[0] = '\0'; inidir[0] = '\0';/* But returning from here results in inidir[] never being set to anything. Instead it should be set to wherever the init file *would* have been executed from. So this bit of code should be removed, and then we should sprinkle "if (noinit)" tests throughout the following code until we have set inidir[], and then return without actually taking the init file.*/ return; }#ifdef OS2/* The -y init file must be fully specified or in the current directory. KERMRC is looked for via INIT, DPATH and PATH in that order. Finally, our own executable file path is taken and the .EXE suffix is replaced by .INI and this is tried as the initialization file.*/ if (rcflag) { ckstrncpy(line,kermrc,LINBUFSIZ+1); } else { char * env = 0;#ifdef NT env = getenv("K95.KSC");#else env = getenv("K2.KSC");#endif /* NT */ if (!env) {#ifdef NT env = getenv("K95.INI");#else env = getenv("K2.INI");#endif /* NT */ } if (!env) env = getenv("CKERMIT.INI"); if (!env) env = getenv("CKERMIT_INI"); line[0] = '\0'; if (env) ckstrncpy(line,env,LINBUFSIZ+1); if (line[0] == 0) _searchenv(kermrc,"INIT",line); if (line[0] == 0) _searchenv(kermrc,"DPATH",line); if (line[0] == 0) _searchenv(kermrc,"PATH",line); if (line[0] == 0) { char *pgmptr = GetLoadPath(); if (pgmptr && strlen(pgmptr) < LINBUFSIZ-8) { lp = strrchr(pgmptr, '\\'); if (lp) { strncpy(line, pgmptr, lp - pgmptr);#ifdef NT strcpy(line + (lp - pgmptr), "\\k95.ini");#else /* NT */ strcpy(line + (lp - pgmptr), "\\k2.ini");#endif /* NT */ } else { lp = strrchr(pgmptr, '.'); if (lp) { strncpy(line, pgmptr, lp - pgmptr); strcpy(line + (lp - pgmptr), ".ini"); } } } } } if ((tfile[0] = fopen(line,"r")) != NULL) { ok = 1; tlevel = 0; tfline[tlevel] = 0; if (tfnam[tlevel] = malloc(strlen(line)+1)) strcpy(tfnam[tlevel],line);#ifndef NOSPL cmdlvl++; cmdstk[cmdlvl].src = CMD_TF; cmdstk[cmdlvl].lvl = tlevel; cmdstk[cmdlvl].ccflgs = 0; ifcmd[cmdlvl] = 0; iftest[cmdlvl] = 0; count[cmdlvl] = count[cmdlvl-1]; /* Inherit from previous level */ intime[cmdlvl] = intime[cmdlvl-1]; inpcas[cmdlvl] = inpcas[cmdlvl-1]; takerr[cmdlvl] = takerr[cmdlvl-1]; merror[cmdlvl] = merror[cmdlvl-1]; xquiet[cmdlvl] = quiet;#endif /* NOSPL */ debug(F110,"doinit init file",line,0); } else { debug(F100,"doinit no init file","",0); } ckstrncpy(kermrc,line,KERMRCL); for (ptr = kermrc; *ptr; ptr++) /* Convert backslashes to slashes */ if (*ptr == '\\') *ptr = '/';#else /* not OS2 */ lp = line; lp[0] = '\0'; debug(F101,"doinit rcflag","",rcflag);#ifdef GEMDOS zkermini(line, rcflag, kermrc);#else#ifdef VMS zkermini(line,LINBUFSIZ,kermrc);#else /* not VMS */#ifdef CK_LOGIN debug(F101,"doinit isguest","",isguest); if (isguest) strcpy(lp, anonfile ? anonfile : kermrc); else#endif /* CK_LOGIN */ if (rcflag) { /* If init file name from cmd line */ strcpy(lp,kermrc); /* use it, */ } else { /* otherwise... */#ifdef CK_INI_A /* If we've a system-wide init file */ /* And it takes precedence over the user's... */ ckstrncpy(lp,CK_SYSINI,KERMRCL); /* Use it */ if (zchki(lp) < 0) { /* (if it exists...) */#endif /* CK_INI_A */ line[0] = NUL; if (homdir) { /* Home directory for init file. */ strcpy(lp,homdir);#ifdef STRATUS strcat(lp,">"); /* VOS separates dirs with >'s */#else if (lp[0] == '/') strcat(lp,"/");#endif /* STRATUS */ } strcat(lp,kermrc); /* Append the default file name */#ifdef CK_INI_A }#endif /* CK_INI_A */ }#ifdef CK_INI_B /* System-wide init defined? */ /* But user's ini file takes precedence */ if (zchki(lp) < 0) /* If user doesn't have her own, */ ckstrncpy(lp,CK_SYSINI,KERMRCL); /* use system-wide one. */#endif /* CK_INI_B */#endif /* VMS */#endif /* GEMDOS */#ifdef AMIGA reqoff(); /* Disable requestors */#endif /* AMIGA */ debug(F110,"doinit ini file is",line,0); if ((tfile[0] = fopen(line,"r")) != NULL) { /* Try to open init file. */ ok = 1; tlevel = 0; tfline[tlevel] = 0; if (tfnam[tlevel] = malloc(strlen(line)+1)) strcpy(tfnam[tlevel],line); ckstrncpy(kermrc,line,KERMRCL);#ifndef NOSPL cmdlvl++; ifcmd[cmdlvl] = 0; iftest[cmdlvl] = 0; count[cmdlvl] = count[cmdlvl-1]; /* Inherit from previous level */ intime[cmdlvl] = intime[cmdlvl-1]; inpcas[cmdlvl] = inpcas[cmdlvl-1]; takerr[cmdlvl] = takerr[cmdlvl-1]; merror[cmdlvl] = merror[cmdlvl-1]; xquiet[cmdlvl] = quiet; debug(F101,"doinit open ok","",cmdlvl); cmdstk[cmdlvl].src = CMD_TF; cmdstk[cmdlvl].lvl = tlevel; cmdstk[cmdlvl].ccflgs = 0;#endif /* NOSPL */ } else if (rcflag) { /* Print an error message only if a specific file was asked for. */ printf("?%s - %s\n", ck_errstr(), line); }#ifdef datageneral/* If CKERMIT.INI not found in home directory, look in searchlist */ if (homdir && (tlevel < 0)) { strcpy(lp,kermrc); if ((tfile[0] = fopen(line,"r")) != NULL) { ok = 1; tlevel = 0; tfline[tlevel] = 0; if (tfnam[tlevel] = malloc(strlen(line)+1)) strcpy(tfnam[tlevel],line);#ifndef NOSPL cmdlvl++; cmdstk[cmdlvl].src = CMD_TF; cmdstk[cmdlvl].lvl = tlevel; cmdstk[cmdlvl].ccflgs = 0; ifcmd[cmdlvl] = 0; iftest[cmdlvl] = 0; count[cmdlvl] = count[cmdlvl-1]; /* Inherit from previous level */ intime[cmdlvl] = intime[cmdlvl-1]; inpcas[cmdlvl] = inpcas[cmdlvl-1]; takerr[cmdlvl] = takerr[cmdlvl-1]; merror[cmdlvl] = merror[cmdlvl-1]; xquiet[cmdlvl] = quiet;#endif /* NOSPL */ } }#endif /* datageneral */#ifdef AMIGA /* Amiga... */ reqpop(); /* Restore requestors */#endif /* AMIGA */#endif /* OS2 */#endif /* MAC */ /* Assign value to inidir */ if (!ok) { inidir[0] = NUL; } else { strcpy(inidir, kermrc); x = strlen(inidir); if (x > 0) { int i; for (i = x - 1; i > 0; i-- ) { if (inidir[i] ==#ifdef MAC ':'#else#ifdef UNIX '/'#else#ifdef OSK '/'#else#ifdef STRATUS '>'#else#ifdef VMS ']' || inidir[i] == ':'#else#ifdef datageneral ':'#else#ifdef OS2 '/' || inidir[i+1] == '\\'#else#ifdef AMIGA '/' || inidir[i+1] == ':'#endif /* AMIGA */#endif /* OS2 */#endif /* datageneral */#endif /* VMS */#endif /* STRATUS */#endif /* OSK */#endif /* UNIX */#endif /* MAC */ ) { inidir[i+1] = NUL; break; } } } }}VOIDdoiksdinit() {#ifdef CK_SSL /* IKSD doesn't request client certs */ ssl_verify_flag = SSL_VERIFY_NONE;#endif /* CK_SSL */ if (!cmdinited) cmdini();#ifdef IKSDCONF#ifdef OS2 line[0] = '\0'; _searchenv(iksdconf,"INIT",line); if (line[0] == 0) _searchenv(iksdconf,"DPATH",line); if (line[0] == 0) _searchenv(iksdconf,"PATH",line); if (line[0] == 0) { char *pgmptr = GetLoadPath(); if (pgmptr && strlen(pgmptr) < LINBUFSIZ-8) { lp = strrchr(pgmptr, '\\'); if (lp) { strncpy(line, pgmptr, lp - pgmptr); strcpy(line + (lp - pgmptr + 1), "\\"); strcpy(line + (lp - pgmptr + 1), iksdconf); } else { lp = strrchr(pgmptr, '.'); if (lp) { strncpy(line, pgmptr, lp - pgmptr); strcpy(line + (lp - pgmptr), ".ksc"); } } } } debug(F110,"doiksdinit() line",line,0); tfile[0] = fopen(line,"r");#else /* OS2 */ tfile[0] = fopen(iksdconf,"r");#endif /* OS2 */ if (tfile[0] != NULL) { tlevel = 0; tfline[tlevel] = 0; if (tfnam[tlevel] = malloc(strlen(line)+1)) strcpy(tfnam[tlevel],iksdconf);#ifndef NOSPL cmdlvl++; cmdstk[cmdlvl].src = CMD_TF; cmdstk[cmdlvl].lvl = tlevel; cmdstk[cmdlvl].ccflgs = 0; ifcmd[cmdlvl] = 0; iftest[cmdlvl] = 0; count[cmdlvl] = count[cmdlvl-1]; /* Inherit from previous level */ intime[cmdlvl] = intime[cmdlvl-1]; inpcas[cmdlvl] = inpcas[cmdlvl-1]; takerr[cmdlvl] = takerr[cmdlvl-1]; merror[cmdlvl] = merror[cmdlvl-1]; xquiet[cmdlvl] = quiet;#endif /* NOSPL */ debug(F110,"doiksdinit file ok",iksdconf,0); } else { debug(F110,"doiksdinit open failed",iksdconf,0); }#endif /* IKSDCONF */}#ifndef NOSPL/* G E T N C M Get next command from current macro definition. Command is copied into string pointed to by argument s, max length n. Returns: 0 if a string was copied; -1 if there was no string to copy.*/intgetncm(s,n) char *s; int n; { int y, /* Character counter */#ifdef COMMENT quote = 0,#endif /* COMMENT */ kp = 0, /* Brace up-down counter */ pp = 0; /* Parenthesis up-down counter */ char *s2; /* Copy of destination pointer */ s2 = s; /* Initialize string pointers */ *s = NUL; /* and destination buffer */ debug(F101,"getncm dest length","",n); for (y = 0; /* Loop for n bytes max */ macp[maclvl] && *macp[maclvl] && y < n; y++, s++, macp[maclvl]++) { *s = *macp[maclvl]; /* Get next char from macro def */ /* debug(F000,"char","",*s); */#ifdef COMMENT/* The intention here was to allow quoting of commas, braces, etc, in macro definitions, e.g. "define rows mode co80\,\%1". And it works, but it breaks just about everything else.*/ if (*s == CMDQ && quote == 0) { /* Allow for quoting of */ quote = 1; /* braces, commas, etc. */ continue; }#endif /* COMMENT *//* Allow braces around macro definition to prevent commas from being turned to end-of-lines and also treat any commas within parens as text so that multiple-argument functions won't cause the command to break prematurely.*/#ifdef COMMENT if (!quote) {#endif /* COMMENT */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -