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

📄 ckctel.c

📁 KERMIT工具 这在办公室下载不了,很多人都没有载不到.
💻 C
📖 第 1 页 / 共 5 页
字号:
        memcpy(&buf[4],data,len);    }    buf[4+len] = (CHAR) IAC;    buf[5+len] = (CHAR) SE;#ifdef DEBUG    if (tn_deb || debses || deblog) {        if (opt == TELOPT_START_TLS && sub == 1)          ckmakmsg(tn_msg_out,TN_MSG_LEN,"TELNET SENT SB ",                    TELOPT(opt)," FOLLOWS IAC SE",NULL);        else if (opt == TELOPT_TTYPE && sub == 1)          ckmakmsg(tn_msg_out,TN_MSG_LEN,"TELNET SENT SB ", TELOPT(opt),                    " SEND IAC SE",NULL);        else if (opt == TELOPT_TTYPE && sub == 0)          ckmakxmsg(tn_msg_out,TN_MSG_LEN,"TELNET SENT SB ",TELOPT(opt)," IS ",                    (char *)data," IAC SE",NULL,NULL,NULL,NULL,NULL,NULL,NULL);        else if (opt == TELOPT_NEWENVIRON) {            int i, quote;            ckmakmsg(tn_msg_out,TN_MSG_LEN,"TELNET SENT SB ",                     TELOPT(TELOPT_NEWENVIRON)," ",                     sub == TELQUAL_SEND ? "SEND" :                     sub == TELQUAL_IS ? "IS" :                     sub == TELQUAL_INFO ?"INFO" : "UNKNOWN" );            for (i = 0, quote = 0; i < len; i++) {                if (quote) {                    sprintf(hexbuf,"%02x",data[i]); /* safe but ugly */                    ckstrncat(tn_msg_out,hexbuf,TN_MSG_LEN);                    quote = 0;                } else {                    switch (data[i]) {                      case TEL_ENV_USERVAR:                        ckstrncat(tn_msg_out," USERVAR ",TN_MSG_LEN);                        break;                      case TEL_ENV_VAR:                        ckstrncat(tn_msg_out," VAR ",TN_MSG_LEN);                        break;                      case TEL_ENV_VALUE:                        ckstrncat(tn_msg_out," VALUE ",TN_MSG_LEN);                        break;                      case TEL_ENV_ESC:                        ckstrncat(tn_msg_out," ESC ",TN_MSG_LEN);                        quote = 1;                        break;                      case IAC:                        ckstrncat(tn_msg_out," IAC ",TN_MSG_LEN);                        break;                      default:                        sprintf(hexbuf,"%c",data[i]); /* safe but ugly */                        ckstrncat(tn_msg_out,hexbuf,TN_MSG_LEN);                    }                }            }            ckstrncat(tn_msg_out," IAC SE",TN_MSG_LEN);        } else {            sprintf(hexbuf,"%02x",sub);             /* safe but ugly */            ckmakxmsg(tn_msg_out,TN_MSG_LEN,                      "TELNET SENT SB ",TELOPT(opt),                      " ",                      hexbuf,                      " <data> IAC SE",                       NULL,NULL,NULL,NULL,NULL,NULL,NULL                      );        }    }#endif /* DEBUG */#ifdef OS2    RequestTelnetMutex( SEM_INDEFINITE_WAIT );#endif /* OS2 */#ifdef DEBUG    debug(F101,tn_msg_out,"",opt);    if (tn_deb || debses)      tn_debug(tn_msg_out);#endif /* DEBUG */    rc = (ttol(buf,6+len) < 6+len);#ifdef OS2    ReleaseTelnetMutex();#endif    if (rc)      return(-1);    return(1);}/*  tn_flui() -- Processes all waiting data for Telnet commands.  All non-Telnet data is to be stored into the Telnet Wait Buffer.  Returns 1 on success.*/inttn_flui() {    extern int ckxech;    int x = 0;    /* Wait up to 5 sec for responses to outstanding telnet negotiations */    while (x >= 0 && ttchk() > 0  && tn_wait_idx < TN_WAIT_BUF_SZ) {        x = ttinc(1);        switch (x) {          case IAC:            x = tn_doop((CHAR)(x & 0xff),inserver?ckxech:duplex,ttinc);            debug(F101,"tn_flui tn_doop","",x);            switch (x) {              case 1:                   /* Turn on echoing */                duplex = 1;                if (inserver)                  ckxech = 1;                break;              case 2:                   /* Turn off echoing */                duplex = 0;                if (inserver)                  ckxech = 0;                break;              case 3:                tn_wait_buf[tn_wait_idx++] = IAC;                break;              case 4:                   /* IKS event */              case 6:                   /* Logout */                break;            }            break;          default:            if (x >= 0)              tn_wait_buf[tn_wait_idx++] = x;        }    }    return(1);}unsigned char *tn_get_display(){    char * disp = NULL;    static char tmploc[256];    /* Must compute the DISPLAY string we are going to send to the host */    /* If one is not assigned, do not send a string unless the user has */    /* explicitedly requested we try to send one via X-Display Location */    /* But do not send a string at all if FORWARD_X is in use.          */    debug(F110,"tn_get_display() myipaddr",myipaddr,0);#ifdef CK_ENVIRONMENT    debug(F110,"tn_get_display() tn_env_disp",tn_env_disp,0);    if (tn_env_disp[0]) {        int colon = ckindex(":",tn_env_disp,0,0,1);        if ( !colon ) {            ckmakmsg(tmploc,256,myipaddr,":",tn_env_disp,NULL);            disp = tmploc;        } else if ( ckindex("localhost:",tn_env_disp,0,0,0) ||                    ckindex("unix:",tn_env_disp,0,0,0) ||                    ckindex("127.0.0.1:",tn_env_disp,0,0,0) ||                    !ckstrcmp("0:",tn_env_disp,2,1) ||                    tn_env_disp[0] == ':' ) {            ckmakmsg(tmploc,256,myipaddr,":",&tn_env_disp[colon],NULL);            disp = tmploc;        } else            disp = tn_env_disp;    }    else#endif /* CK_ENVIRONMENT */        if (TELOPT_ME(TELOPT_XDISPLOC) ||              TELOPT_U(TELOPT_FORWARD_X)) {        ckmakmsg(tmploc,256,myipaddr,":0.0",NULL,NULL);        disp = tmploc;    }    debug(F110,"tn_get_display() returns",disp,0);    return((CHAR *)disp);}#ifdef CK_FORWARD_Xstatic Xauth fake_xauth = {0,0,NULL,0,NULL,0,NULL,0,NULL};static Xauth *real_xauth=NULL;/* * Author:  Jim Fulton, MIT X Consortium * * fwdx_parse_displayname - * display a display string up into its component parts */#ifdef UNIX#define UNIX_CONNECTION "unix"#define UNIX_CONNECTION_LENGTH 4#endif/* * private utility routines */static int#ifdef CK_ANSICXmuGetHostname (char *buf, int maxlen)#elseXmuGetHostname (buf, maxlen)    char *buf;    int maxlen;#endif /* CK_ANSIC */{    int len;#ifdef NEED_UTSNAME    /*     * same host name crock as in server and xinit.     */    struct utsname name;    uname (&name);    len = strlen (name.nodename);    if (len >= maxlen) len = maxlen - 1;    strncpy (buf, name.nodename, len);    buf[len] = '\0';#else    buf[0] = '\0';    (void) gethostname (buf, maxlen);    buf [maxlen - 1] = '\0';    len = strlen(buf);#endif /* hpux */    return len;}static char *#ifdef CK_ANSICcopystring (char *src, int len)#elsecopystring (src, len)    char *src;    int len;#endif /* CK_ANSIC */{    char *cp;    if (!src && len != 0) return NULL;    cp = malloc (len + 1);    if (cp) {        if (src) strncpy (cp, src, len);        cp[len] = '\0';    }    return cp;}static char *#ifdef CK_ANSICget_local_hostname (char *buf, int maxlen)#elseget_local_hostname (buf, maxlen)    char *buf;    int maxlen;#endif{    buf[0] = '\0';    (void) XmuGetHostname (buf, maxlen);    return (buf[0] ? buf : NULL);}#ifndef UNIXstatic char *copyhostname (){    char buf[256];    return (get_local_hostname (buf, sizeof buf) ?            copystring (buf, strlen (buf)) : NULL);}#endifint#ifdef CK_ANSICfwdx_parse_displayname (char *displayname, int *familyp, char **hostp,                        int *dpynump, int *scrnump, char **restp)#elsefwdx_parse_displayname (displayname, familyp, hostp, dpynump, scrnump, restp)    char *displayname;    int *familyp;                       /* return */    char **hostp;                       /* return */    int *dpynump, *scrnump;             /* return */    char **restp;                       /* return */#endif /* CK_ANSIC */{    char *ptr;                          /* work variables */    int len;                            /* work variable */    int family = -1;                    /* value to be returned */    char *host = NULL;                  /* must free if set and error return */    int dpynum = -1;                    /* value to be returned */    int scrnum = 0;                     /* value to be returned */    char *rest = NULL;                  /* must free if set and error return */    int dnet = 0;                       /* if 1 then using DECnet */                                        /* check the name */    if (!displayname || !displayname[0])        return 0;                                        /* must have at least :number */    ptr = (char *)strchr(displayname, ':');    if (!ptr || !ptr[1]) return 0;    if (ptr[1] == ':') {        if (ptr[2] == '\0') return 0;        dnet = 1;    }    /*     * get the host string; if none is given, use the most effiecient path     */    len = (ptr - displayname);  /* length of host name */    if (len == 0) {                     /* choose most efficient path */#ifdef UNIX        host = copystring (UNIX_CONNECTION, UNIX_CONNECTION_LENGTH);        family = FamilyLocal;#else        if (dnet) {            host = copystring ("0", 1);            family = FamilyDECnet;        } else {            host = copyhostname ();            family = FamilyInternet;        }#endif    } else {        host = copystring (displayname, len);        if (dnet) {            family = dnet;        } else {#ifdef UNIX            if (host && strcmp (host, UNIX_CONNECTION) == 0)              family = FamilyLocal;            else#endif              family = FamilyInternet;        }    }    if (!host) return 0;    /*     * get the display number; we know that there is something after the     * colon (or colons) from above.  note that host is now set and must     * be freed if there is an error.     */    if (dnet) ptr++;                    /* skip the extra DECnet colon */    ptr++;                              /* move to start of display num */    {        register char *cp;        for (cp = ptr; *cp && isascii(*cp) && isdigit(*cp); cp++) ;        len = (cp - ptr);                                        /* check present and valid follow */        if (len == 0 || (*cp && *cp != '.')) {            free (host);            return 0;        }        dpynum = atoi (ptr);            /* it will handle num. as well */        ptr = cp;    }    /*     * now get screen number if given; ptr may point to nul at this point     */    if (ptr[0] == '.') {        register char *cp;        ptr++;        for (cp = ptr; *cp && isascii(*cp) && isdigit(*cp); cp++) ;        len = (cp - ptr);        if (len == 0 || (*cp && *cp != '.')) {  /* all prop name */            free (host);            return 0;        }        scrnum = atoi (ptr);            /* it will handle num. as well */        ptr = cp;    }    /*     * and finally, get any additional stuff that might be following the     * the screen number; ptr must point to a period if there is anything     */    if (ptr[0] == '.') {        ptr++;        len = strlen (ptr);        if (len > 0) {            rest = copystring (ptr, len);            if (!rest) {                free (host);                return 1;            }        }    }    /*     * and we are done!     */    if ( familyp )        *familyp = family;    if ( hostp )        *hostp = host;    else        free(host);    if ( dpynump )        *dpynump = dpynum;    if ( scrnump )        *scrnump = scrnum;    if ( restp )        *restp = rest;    else        free(rest);    return 1;}int#ifdef CK_ANSIC

⌨️ 快捷键说明

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