ckuus5.c

来自「KERMIT工具 这在办公室下载不了,很多人都没有载不到.」· C语言 代码 · 共 2,159 行 · 第 1/5 页

C
2,159
字号
            } else if (j < 0 &&                       (!strcmp(xargv[i],"+") ||                        !strncmp(xargv[i],"+ ",2) ||                        !strncmp(xargv[i],"+\t",2))                        ) {                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) {                    char c, * p;                    int flag = 0;                    p = xargv[i];                    makestr(&(toparg[j]),p);                    while ((c = *p++)) { if (c == SP) { flag++; break; } }                    if (flag)                      ckstrncat(tmpbuf,"\"",TMPBUFSIZ);                    ckstrncat(tmpbuf,xargv[i],TMPBUFSIZ);                    if (flag)                      ckstrncat(tmpbuf,"\"",TMPBUFSIZ);                    ckstrncat(tmpbuf," ",TMPBUFSIZ);                }            }        }        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;#ifdef COMMENT            /* This needs work */            if (!cfilef)              makestr(&topline,tmpbuf);#endif /* COMMENT */        } else {            topargc = 0;            topxarg = NULL;        }        a_dim[0] = topargc - 1;        a_ptr[0] = topxarg;	debug(F111,"a_dim[0]","A",a_dim[0]);    }    *vnambuf = NUL;#endif /* NOSPL */    luinit();                           /* Initialize lookup() cache *//* Get our home directory now.  This needed in lots of places. */    cmdinited = 1;}#ifdef NT_PROTOTYP(char * GetAppData,(int));#endif /* NT */VOIDdoinit() {#ifdef CKROOTextern int ckrooterr;#endif /* CKROOT */    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.*/#ifdef CK_LOGIN    debug(F101,"doinit inserver","",inserver);    debug(F101,"doinit isguest","",isguest);    debug(F110,"doinit anonfile",anonfile,0);    if (isguest && anonfile) {      ckstrncpy(line, anonfile, LINBUFSIZ+1);    } else#endif /* CK_LOGIN */      if (rcflag) {          ckstrncpy(line,kermrc,LINBUFSIZ+1);#ifdef CK_LOGIN      } else if (inserver) {          char * appdata = NULL;#ifdef NT          appdata = GetAppData(1);          if ( appdata ) {              ckmakmsg(line,LINBUFSIZ+1,appdata,                        "Kermit 95/k95.ini",NULL,NULL);              if ( zchki(line) < 0 )                  line[0] = '\0';          }          if (line[0] == 0) {              appdata = GetAppData(0);              if ( appdata ) {                  ckmakmsg(line,LINBUFSIZ+1,appdata,                            "Kermit 95/k95.ini",NULL,NULL);                  if ( zchki(line) < 0 )                      line[0] = '\0';              }          }#endif /* NT */          if (line[0] == 0) {              appdata = zhome();              if ( appdata ) {                  ckmakmsg(line,LINBUFSIZ+1,appdata,#ifdef NT                          "k95.ini",#else /* NT */                          "k2.ini",#endif /* NT */                           NULL,NULL);                  if ( zchki(line) < 0 )                      line[0] = '\0';              }          }          debug(F110,"doinit inserver inifile",line,0);#endif /* CK_LOGIN */    } 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';        debug(F110,"doinit env",env,0);        if (env)          ckstrncpy(line,env,LINBUFSIZ+1);#ifdef NT        if (line[0] == 0) {            env = GetAppData(1);            if ( env ) {                ckmakmsg(line,LINBUFSIZ+1,env,"Kermit 95/k95.ini",NULL,NULL);                if ( zchki(line) < 0 )                    line[0] = '\0';            }        }        if (line[0] == 0) {            env = GetAppData(0);            if ( env ) {                ckmakmsg(line,LINBUFSIZ+1,env,"Kermit 95/k95.ini",NULL,NULL);                if ( zchki(line) < 0 )                    line[0] = '\0';            }        }#endif /* NT */        if (line[0] == 0) {            env = zhome();            if ( env ) {                ckmakmsg(line,LINBUFSIZ+1,env,#ifdef NT                          "k95.ini",#else /* NT */                          "k2.ini",#endif /* NT */                          NULL,NULL);                if ( zchki(line) < 0 )                    line[0] = '\0';            }        }        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");                    }                }            }        }    }#ifdef CKROOT    if (!zinroot(line)) {        debug(F110,"doinit setroot violation",line,0);        return;    }#endif /* CKROOT */    debug(F110,"doinit fopen()",line,0);    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);   /* safe */#ifndef NOSPL        cmdlvl++;        xcmdsrc = CMD_TF;        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    {	int x;	x = zkermini(line,LINBUFSIZ,kermrc);	debug(F111,"CUSTOM zkermini",line,x);	if (x == 0)	  line[0] = NUL;    }#else /* not VMS */#ifdef CK_LOGIN    debug(F101,"doinit isguest","",isguest);    if (isguest)      ckstrncpy(lp, anonfile ? anonfile : kermrc, LINBUFSIZ);    else#endif /* CK_LOGIN */      if (rcflag) {                     /* If init file name from cmd line */          ckstrncpy(lp,kermrc,LINBUFSIZ); /* 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 */              char * homdir;              char * env = 0;              line[0] = NUL;              /* Add support for environment variable */              env = getenv("CKERMIT.INI");              if (!env)                env = getenv("CKERMIT_INI");              if (env)                ckstrncpy(lp,env,KERMRCL);              if (lp[0] == 0) {                  homdir = zhome();                  if (homdir) {         /* Home directory for init file. */                      ckstrncpy(lp,homdir,KERMRCL);#ifdef STRATUS                      ckstrncat(lp,">",KERMRCL);/* VOS dirsep */#else                      if (lp[0] == '/') ckstrncat(lp,"/",KERMRCL);#endif /* STRATUS */                  }                  ckstrncat(lp,kermrc,KERMRCL);/* Append 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 */#ifdef USE_CUSTOM    /* If no init file was found, execute the customization file */    debug(F110,"CUSTOM 1",line,0);    if (!line[0] || zchki(line) < 0) {	int x;#ifdef OS2	x = ckmakestr(line,LINBUFSIZ,GetAppData(1),"/","K95CUSTOM.INI",NULL);	debug(F111,"CUSTOM 2",line,x);	if (zchki(line) < 0) {	    x = ckmakestr(line,LINBUFSIZ,GetAppData(0),"/","K95USER.INI",NULL);	    debug(F111,"CUSTOM 3",line,x);	}#else  /* OS2 */	x = ckstrncpy(line,zhome(),LINBUFSIZ);#ifndef VMS	/* VMS zhome() returns "SYS$LOGIN:" */	if (line[x-1] != DIRSEP) {	    line[x++] = DIRSEP;	    line[x] = NUL;	}#endif /* VMS */	x = ckstrncat(line,MYCUSTOM,LINBUFSIZ);	debug(F111,"CUSTOM 4",line,x);#endif /* OS2 */    }    debug(F110,"CUSTOM 5",line,0);#endif /* USE_CUSTOM */#ifdef CKROOT    if (!zinroot(line)) {        debug(F110,"doinit setroot violation",line,0);        return;    }#endif /* CKROOT */    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);   /* safe */        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);        xcmdsrc = CMD_TF;        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)) {        ckstrncpy(lp,kermrc,LINBUFSIZ);        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); /* safe */#ifndef NOSPL            cmdlvl++;            xcmdsrc = CMD_TF;            cmdstk[cmdlvl].src = CMD_TF;            cmdstk[cmdlvl].lvl = tlevel;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?