⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ckuus5.c

📁 KERMIT工具 这在办公室下载不了,很多人都没有载不到.
💻 C
📖 第 1 页 / 共 5 页
字号:
            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 {        ckstrncpy(inidir, kermrc, CCHMAXPATH);        x = strlen(inidir);        if (x > 0) {            int i;            for (i = x - 1; i > 0; i-- ) {                if (ISDIRSEP(inidir[i])) {                    inidir[i+1] = NUL;                    break;                }            }        }#ifdef NT        GetShortPathName(inidir,inidir,CCHMAXPATH);#endif /* NT */    }}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), "\\");                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;#ifdef OS2        if (tfnam[tlevel] = malloc(strlen(line)+1))          strcpy(tfnam[tlevel],line);#else /* OS2 */        if ((tfnam[tlevel] = malloc(strlen(iksdconf)+1)))          strcpy(tfnam[tlevel],iksdconf);#endif /* OS2 */#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,"doiksdinit file ok",tfnam[tlevel],0);    } else {        debug(F110,"doiksdinit open failed",tfnam[tlevel],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 = 0;				/* Character counter */    int quote = 0;    int kp = 0;				/* Brace up-down counter */    int pp = 0;				/* Parenthesis up-down counter */#ifndef NODQMACRO    int dq = 0;				/* Doublequote counter */#endif /* NODQMACRO */    char *s2;                           /* Copy of destination pointer */    s2 = s;                             /* Initialize string pointers */    *s = NUL;                           /* and destination buffer */    /* debug(F010,"getncm entry",macp[maclvl],0); */    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 */#ifndef COMMENT/*  This is to allow quoting of parentheses, commas, etc, in function  arguments, but it breaks just about everything else.  DON'T REMOVE THIS  COMMENT!  (Otherwise you'll wind up adding the same code again and breaking  everything again.)  <-- The preceding warning should be obsolete since the  statements below have been fixed, but in case of fire, remove the "n" from  the <#>ifndef above.  NEW WARNING: code added 12 Apr 2002 to exempt the  opening brace in \{nnn} from being treated as a quoted brace.*/        if (!quote && *s == CMDQ) {            quote = 1;            continue;        }        if (quote) {	    int notquote = 0;            quote = 0;	    if (*s == '{') {		/* Check for \{nnn} (8.0.203) */		char c, * p;		p = macp[maclvl] + 1;		while ((c = *p++)) {		    if (isdigit(c))		      continue;		    else if (c == '}') {			notquote++;			break;		    } else {			break;		    }		}	    }	    if (notquote == 0)	      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.  19 Oct 2001: Similar treatment was added for doublequotes, so     define foo { echo "one, two, three" }  would work as expected.  This doesn't seem to have broken anything but  if something comes up later, rebuild with NODQMACRO defined.*/        if (*s == '{') kp++;            /* Count braces */        if (*s == '}' && kp > 0) kp--;        if (*s == '(') pp++;            /* Count parentheses. */        if (*s == ')' && pp > 0) pp--;#ifndef NODQMACRO#ifndef COMMENT	/* Too many false positives */	/* No, not really -- this is indeed the best we can do */	/* Reverted to this method Sun May 11 18:43:45 2003 */	if (*s == '"') dq = 1 - dq;     /* Account for doublequotes */#else  /* Fri Apr  4 13:21:29 2003 */	/* The code below breaks the SWITCH statement */	/* There is no way to make this work -- it would require */	/* building in all the knowledge of command parser. */        if (dblquo && (*s == '"')) {    /* Have doublequote */            if (dq == 1) {		/* Close quote only if... */                if ((*(macp[maclvl]+1) == SP) || /* followed by space or... */		    (!*(macp[maclvl]+1)) ||      /* at end or ... */		    /* Next char is command separator... */		    /* Sun May 11 17:24:12 2003 */		    (kp < 1 && pp < 1 && (*(macp[maclvl]+1) == ','))		    )		                       dq = 0;		/* Close the quote */            } else if (dq == 0) {                /* Open quote only if at beginning or preceded by space */                if (s > s2) {                    if (*(s-1) == SP)                      dq = 1;                } else if (s == s2) {                      dq = 1;                }            }        }#endif /* COMMENT */#endif /* NODQMACRO */        if (*s == ',' && pp <= 0 && kp <= 0#ifndef NODQMACRO            && dq == 0#endif /* NODQMACRO */            ) {            macp[maclvl]++;             /* Comma not in {} or () */            /* debug(F110,"next cmd",s,0); */            kp = pp = 0;                /* so we have the next command */            break;        }    }                                   /* Reached end. */#ifdef COMMENT    /* DON'T DO THIS - IT BREAKS EVERYTHING */    *s = NUL;#endif /* COMMENT */    if (*s2 == NUL) {                   /* If nothing was copied, */        /* debug(F100,"XXX getncm eom","",0); */        popclvl();                      /* pop command level. */        return(-1);    } else {                            /* otherwise, tack CR onto end */        *s++ = CR;        *s = '\0';        /* debug(F110,"XXX getncm OK",s,0); */        if (mecho && pflag)             /* If MACRO ECHO ON, echo the cmd */          printf("%s\n",s2);    }    return(0);}/*  D O M A C  --  Define and then execute a macro */intdomac(name, def, flags) char *name, *def; int flags; {    int x, m;#ifndef NOLOCAL#ifdef OS2    extern int term_io;    int term_io_sav = term_io;    term_io = 0;                        /* Disable Terminal Emulator I/O */#endif /* OS2 */#endif /* NOLOCAL */    m = maclvl;                         /* Current macro stack level */    x = addmac(name, def);              /* Define a new macro */    if (x > -1) {                       /* If successful, */        dodo(x,NULL,flags);             /* start it (increments maclvl). */        while (maclvl > m) {            /* Keep going till done with it, */            debug(F101,"domac loop maclvl 1","",maclvl);            sstate = (CHAR) parser(1);  /* parsing & executing each command, */            debug(F101,"domac loop maclvl 2","",maclvl);            if (sstate) proto();        /* including protocol commands. */        }        debug(F101,"domac loop exit maclvl","",maclvl);    }#ifndef NOLOCAL#ifdef OS2    term_io = term_io_sav;#endif /* OS2 */#endif /* NOLOCAL */    return(success);}#endif /* NOSPL *//*  G E T N C T  Get next command from TAKE (command) file.  Call with:   s     Pointer to buffer to read into   n     Length of buffer   f     File descriptor of file to read from   flag  0 == keep line terminator on and allow continuation         1 == discard line terminator and don't allow continuation  Call with flag == 0 to read a command from a TAKE file;  Call with flag != 0 to read a line from a dialing or network directory.  In both cases, trailing comments and/or trailing whitespace is/are stripped.  If flag == 0, continued lines are combined into one line.  A continued line  is one that ends in hypen, or any line in a "block", which starts with "{"  at the end of a line and ends with a matching "}" at the beginning of a  subsequent line; blocks may be nested.  Returns:   0 if a string was copied,  -1 on EOF,  -2 on malloc failure  -3 if line is not properly terminated  -4 if (possibly continued) line is too long.*/static int lpxlen = 0;intgetnct(s,n,f,flag) char *s; int n; FILE *f; int flag; {    int i = 0, len = 0, buflen = 0;    char c = NUL, cc = NUL, ccl = NUL, ccx = NUL, *s2 = NULL;    char *lp = NULL, *lpx = NULL, *lp2 = NULL, *lp3 = NULL, *lastcomma = NULL;    char * prev = NULL;    int bc = 0;                         /* Block counter */    s2 = s;                             /* Remember original pointer */    prev = s2;    buflen = n;                         /* Remember original buffer length */    if (n < 0)      return(-2);    /* Allocate a line buffer only if we don't have one that's big enough */    debug(F111,"getnct",ckitoa(lpxlen),n);    if (lpx && (n > lpxlen)) {          /* Have one already */        debug(F101,"getnct new buffer","",lpxlen);        free(lpx);                      /* But it's not big enough */        lpx = NULL;                     /* Free current one */        lpxlen = 0;    }    if (!lpx) {                         /* Get new one */        if (!(lpx = (char *) malloc(n))) {            debug(F101,"getnct malloc failure","",0);            printf("?Memory allocation failure [getnct]\n");            return(-2);        }        lpxlen = n;    }    lp2 = lpx;#ifdef KLUDGE    /* NOTE: No longer used as of 14 Aug 2000 */    lp2++;#endif /* KLUDGE */    while (1) {                         /* Loop to read lines from file */        debug(F101,"getnct while (1)","",n);        if (fgets(lp2,n,f) == NULL) {   /* Read a line into lp2 */            debug(F110,"getnct EOF",s2,0); /* EOF */            free(lpx);                  /* Free temporary storage */            lpx = NULL;            *s = NUL;                   /* Make destination be empty */            return(-1);                 /* Return failure code */        }#ifndef NODIAL        if (flag)                       /* Count this line */          dirline++;        else#endif /* NODIAL */          tfline[tlevel]++;        len = strlen(lp2) - 1;          /* Position of line terminator */        if (len == 0 && lp2[0] != '\n') { /* Last line in file has one char */            lp2[++len] = '\n';          /* that is not a newline */            lp2[len] = NUL;        }        debug(F010,"getnct",lp2,0);        if (len < 0)          len = 0;        if (techo && pflag)             /* If TAKE ECHO ON, */          printf("%3d. %s",             /* echo it this line. */#ifndef NODIAL                 flag ? dirline :#endif /* NODIAL */                 tfline[tlevel],                 lp2                 );        lp3 = lp2;                      /* Working pointer */        i = len;                        /* Get first nonwhitespace character */        while (i > 0 && (*lp3 == SP || *lp3 == HT)) {            i--;            lp3++;        }        if (i == 0 && bc > 0)           /* Blank line in {...} block */          continue;        /* Isolate, remove, and check terminator */        c = lp2[len];                   /* Value of line terminator */        /* debug(F101,"getnct terminator","",c); */        if (c < LF || c > CR) {         /* It's not a terminator */            /* debug(F111,"getnct bad line",lp2,c); */            if (feof(f) && len > 0 && len < n) {                /* Kludge Alert... */                if (!quiet)                  printf("WARNING: Last line of %s lacks terminator\n",                         s2 == cmdbuf ? "command file" : "directory file");                c = lp2[++len] = '\n';  /* No big deal - supply one. */            } else {                    /* Something's wrong, fail. */                free(lpx);                lpx = NULL;                return(-3);            }        }        /* Trim trailing whitespace */        for (i = len - 1; i > -1 && lp2[i] <= SP; i--) /* Trim */          ;        /* debug(F101,"getnct i","",i); */        lp2[i+1] = NUL;                 /* Terminate the string */        /* debug(F110,"getnct lp2",lp2,0); */        lp = lp2;                       /* Make a working pointer */        /* Remove trailing or full-line comment */        while ((cc = *lp)) {            if (cc == ';' || cc == '#') { /* Comment introducer? */                if (lp == lp2) {        /* First char on line */                   

⌨️ 快捷键说明

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