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

📄 ckuus4.c

📁 C-Kermit源码。是使用串口/Modem和网络通讯的程序
💻 C
📖 第 1 页 / 共 5 页
字号:
#endif /* KERBANG */#endif /* NOICP */        if (!strcmp(*yargv,"--"))       /* getopt() conformance */          return;#ifdef VMS        else if (**yargv == '/')          continue;#endif /* VMS */        else if (**yargv == '-') {      /* Got an option (begins with dash) */            x = *(*yargv+1);            /* Get option letter */            while (x) {                 /* Allow for bundled options */                debug(F000,"prescan arg","",x);                switch (x) {#ifndef NOICP                  case '+':                  case '-':                    if (doxarg(yargv,1) < 0) {                        fatal("Extended argument error");                    }                    yargv++, yargc--;                    yp = *yargv;                    break;#endif /* NOICP */                  case '7':             /* Undocumented... */                    sstelnet = 1;       /* (because it doesn't work) */                    break;#ifdef IKSD                  case 'A': {                      char * p;                      inserver = 1;     /* Flag that we are doing this */                      srvcdmsg = 2;     /* Preset this */                      /* See inserver section of ckcmai.c for more settings */#ifdef NT                      if (*(yp+1)) {                          fatal("invalid argument bundling after -A");                      }                      /* Support for Pragma Systems Telnet/Terminal Servers */                      p = getenv("PRAGMASYS_INETD_SOCK");                      if (p && atoi(p) != 0) {                          ttname[0] = '$';                          ckstrncpy(&ttname[1],p,TTNAMLEN-1);                          break;                      }                      yargv++, yargc--;                      if (yargc < 1 || **yargv == '-') {                          fatal("-A argument missing");                      } else {                          ttname[0] = '$';                          ckstrncpy(&ttname[1],*yargv,TTNAMLEN-1);                      }#endif /* NT */                      break;                  }#endif /* IKSD */#ifdef OS2                  case 'W':                    if (*(yp+1))                      fatal("invalid argument bundling after -W");                    yargv++, yargc--;                    if (yargc < 1)                      fatal("Window handle missing");#ifdef COMMENT                    if (dummy) {                        yargv++, yargc--;                        break;                    } else {#endif /* COMMENT */                        hwndDialer = (HWND) atol(*yargv);                        StartedFromDialer = 1;                        yargv++, yargc--;                        KermitDialerID = atol(*yargv) ;#ifdef COMMENT                    }#endif /* COMMENT */                    break;                  case '#':             /* K95 initialization options */                    if (*(yp+1)) {                        fatal("invalid argument bundling");                    }                    yargv++, yargc--;                    if (yargc < 1)                      fatal("-# argument missing");                    startflags |= atol(*yargv);                    break;#endif /* OS2 */#ifndef NOSPL                  case 'M':                             /* My User Name */                    if (*(yp+1)) {                        fatal("invalid argument bundling");                    }                    yargv++, yargc--;                    if ((yargc < 1) || (**yargv == '-')) {                        fatal("missing username");                    }                    if ((int)strlen(*yargv) > UIDBUFLEN) {                        fatal("username too long");                    }#ifdef IKSD                    if (!inserver)#endif /* IKSD */                      ckstrncpy(uidbuf,*yargv,UIDBUFLEN);                    break;#endif /* NOSPL */                  case 'R':             /* Remote-only advisory */#ifdef CK_IFRO                    remonly = 1;#endif /* CK_IFRO */                    break;                  case 'S':             /* STAY */                    stayflg = 1;                    break;                  case 'h':                    noinit = 1;#ifdef OS2                    startflags |= 2;    /* No network DLLs */                    startflags |= 4;    /* No TAPI DLLs */                    startflags |= 8;    /* No Security DLLs */                    startflags |= 16;   /* No Zmodem DLLs */#endif /* OS2 */                    break;#ifndef NOICP                  case 'Y':             /* No init file */                    noinit = 1;                    break;#endif /* NOICP */                  case 'd':             /* = SET DEBUG ON */#ifdef DEBUG                    if (!deblog) {                        extern int debtim;                        deblog = debopn("debug.log",0);                        /* debtim = 1; */                    }#endif /* DEBUG */                    break;                  case 'x':             /* Server */                    arg_x = 1;          /* Note in advance */                    break;#ifndef NOICP                  case 'y':             /* Alternative init file */                    yargv++, yargc--;                    if (yargc < 1) fatal("missing name in -y");		    /* Replace init file name */                    ckstrncpy(kermrc,*yargv,KERMRCL);                    rcflag = 1;         /* Flag that this has been done */                    debug(F111,"prescan kermrc",kermrc,rcflag);                    break;#endif /* NOICP */                  case 'z':             /* = SET BACKGROUND OFF */                    bgset = 0;                    break;#ifdef CK_NETBIOS                  case 'N':                    {                        int n ;                        yargv++, yargc--;#ifdef COMMENT                        if (y)                          break;#endif /* COMMENT */                        if (strlen(*yargv) != 1 || (*yargv)[0] == 'X') {                            NetBiosAdapter = -1;                        } else {                            n = atoi(*yargv);                            if (n >= 0 && n <= 9)                              NetBiosAdapter = n;                            else                              NetBiosAdapter = -1;                        }                    }                    break;#endif /* CK_NETBIOS */                  default:                    break;                }                if (!yp)                  break;                x = *++yp;              /* See if options are bundled */            }        }    }#endif /* NOCMDL */}/*  G E T T C S  --  Get Transfer (Intermediate) Character Set  *//*  Given two file character sets, this routine picks out the appropriate  "transfer" character set to use for translating between them.  The transfer character set number is returned.  Translation between two file character sets is done, for example,  by the CONNECT, TRANSMIT, and TRANSLATE commands.  Translation between Kanji character sets is not yet supported.*/intgettcs(cs1,cs2) int cs1, cs2; {#ifdef NOCSETS                          /* No character-set support */    return(0);                          /* so no translation */#else    int tcs = TC_TRANSP;#ifdef KANJI/* Kanji not supported yet */    if (fcsinfo[cs1].alphabet == AL_JAPAN ||        fcsinfo[cs2].alphabet == AL_JAPAN )      tcs = TC_TRANSP;    else#endif /* KANJI */#ifdef CYRILLIC/*  I can't remember why we don't test both sets here, but I think there  must have been a reason...*/      if (fcsinfo[cs2].alphabet == AL_CYRIL)        tcs = TC_CYRILL;      else#endif /* CYRILLIC */#ifdef HEBREW          if (fcsinfo[cs1].alphabet == AL_HEBREW ||              fcsinfo[cs2].alphabet == AL_HEBREW )            tcs = TC_HEBREW;          else#endif /* HEBREW */#ifdef GREEK          if (fcsinfo[cs1].alphabet == AL_GREEK ||              fcsinfo[cs2].alphabet == AL_GREEK )            tcs = TC_GREEK;          else#endif /* GREEK */            /* Roman sets ... */#ifdef LATIN2                           /* East European */        if (cs1 == FC_2LATIN  || cs2 == FC_2LATIN || /* Latin-2 */            cs1 == FC_CP852   || cs2 == FC_CP852  || /* CP852 */            cs1 == FC_CP1250  || cs2 == FC_CP1250 || /* Windows Latin-2 */            cs1 == FC_MAZOVIA || cs2 == FC_MAZOVIA)  /* Polish Mazovia */          tcs = TC_2LATIN;        else#endif /* LATIN2 */                                        /* West European Euro-aware */          if (cs1 == FC_CP858 || cs1 == FC_9LATIN ||              cs2 == FC_CP858 || cs2 == FC_9LATIN)            tcs = TC_9LATIN;          else                          /* Traditional West European */            tcs = TC_1LATIN;    return(tcs);#endif /* NOCSETS */}#ifndef NOLOCAL/*  D O C O N E C T  --  Do the connect command  *//*  q = 0 means issue normal informational message about how to get back, etc.  q != 0 means to skip the message.*/intdoconect(q) int q; {    int x, z;                           /* Return code */    extern int what;#ifdef CK_AUTODL    extern CHAR ksbuf[];#endif /* CK_AUTODL */#ifndef NOKVERBS                        /* Keyboard macro material */    extern int keymac, keymacx;#endif /* NOKVERBS */    extern int justone;    int qsave;                          /* For remembering "quiet" value */#ifdef OS2    extern int term_io;    extern int display_demo;    int term_io_save;#endif /* OS2 */    int is_tn = 0;#ifdef IKSD    if (inserver) {        if (!quiet)          printf("?Sorry, IKSD cannot CONNECT.\r\n");        return(success = 0);    }#endif /* IKSD */    is_tn =#ifdef TNCODE      (local && network && ttnproto == NP_TELNET) || (!local && sstelnet)#else        0#endif /* TNCODE */          ;/*  Saving, changing, and restoring the global "quiet" variable around calls  to conect() to control whether the verbose CONNECT message is printed is  obviously less elegant than passing a parameter to conect(), but we do it  this way to avoid the need to change all of the ck?con.c modules.  NOTE:  it is important to restore the value immediately upon return in case there  is an autodownload or APC.*/    qsave = quiet;                      /* Save it */    if (!quiet && q > -1)      quiet = q;                        /* Use argument temporarily */    conres();                           /* Put console back to normal */    debug(F101,"doconect justone 1","",justone);#ifdef CK_AUTODL    ksbuf[0] = NUL;                     /* Autodownload packet buffer */#endif /* CK_AUTODL */#ifdef OS2    display_demo = 1;                   /* Remember to display demo */#endif /* OS2 */#ifdef IKS_OPTION    if (is_tn && TELOPT_U(TELOPT_KERMIT) && ttchk() >= 0#ifdef OS2       && !viewonly#endif /* OS2 */        ) {        /* If the remote side is in a state of IKS START-SERVER    */        /* we request that the state be changed.  We will detect   */        /* a failure to adhere to the request when we call ttinc() */        if (!iks_wait(KERMIT_REQ_STOP,0) && !tcp_incoming) {            if (!quiet) {                printf("\r\nEnter Client/Server Mode...  Use:\r\n\r\n");                printf(" REMOTE LOGIN <user> <password> to log in to the server if necessary.\r\n");                printf(" SEND and GET for file transfer.\r\n");                printf(" REMOTE commands for file management.\r\n");                printf(" FINISH to terminate Client/Server mode.\r\n");                printf(" BYE to terminate and close connection.\r\n");                printf(" REMOTE HELP for additional information.\r\n\r\n");            }            quiet = qsave;            return(0);      /* Failure */        }    }    /* Let our peer know our state. */#ifdef CK_AUTODL    if (is_tn && TELOPT_ME(TELOPT_KERMIT)#ifdef OS2        && !viewonly#endif /* OS2 */         ) {        if (autodl && !TELOPT_SB(TELOPT_KERMIT).kermit.me_start) {            tn_siks(KERMIT_START);      /* Send Kermit-Server Start */        } else if (!autodl && TELOPT_SB(TELOPT_KERMIT).kermit.me_start) {            tn_siks(KERMIT_STOP);        }    }#else /* CK_AUTODL */    if (TELOPT_SB(TELOPT_KERMIT).kermit.me_start) {        tn_siks(KERMIT_STOP);    }#endif /* CK_AUTODL */#endif /* IKS_OPTION */    debug(F101,"doconect flow","",flow);    x = conect();                       /* Connect the first time */#ifdef IKS_OPTION    if (TELOPT_U(TELOPT_KERMIT) &&        TELOPT_SB(TELOPT_KERMIT).kermit.u_start &&        !tcp_incoming && !quiet && ttchk() >= 0        ) {        printf("\r\nEnter Client/Server Mode...  Use:\r\n\r\n");        printf(" REMOTE LOGIN <user> <password> to log in to the server if necessary.\r\n");        printf(" SEND and GET for file transfer.\r\n");        printf(" REMOTE commands for file management.\r\n");        printf(" FINISH to terminate Client/Server mode.\r\n");        printf(" BYE to terminate and close connection.\r\n");        printf(" REMOTE HELP for additional information.\r\n\r\n");    }#endif /* IKS_OPTION */    quiet = qsave;                      /* Restore "quiet" value */    debug(F101,"doconect justone 2","",justone);#ifdef NETCONN    if (network && tn_exit && ttchk() < 0)      doexit(GOOD_EXIT,xitsta);         /* Exit with good status */#endif /* NETCONN */#ifdef OS2ORUNIX    /* Exit on disconnect if the port is not open or carrier detect */    if (exitonclose && (ttchk() < 0))      doexit(GOOD_EXIT,xitsta);#endif /* OS2ORUNIX */#ifdef CKCONINTB4CB    /* The order makes a difference in HP-UX 8.00. */    /* The other order makes it think it's in the background when it */    /* returns from CONNECT (Apr 1999). */

⌨️ 快捷键说明

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