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

📄 ckcnet.c

📁 KERMIT工具 这在办公室下载不了,很多人都没有载不到.
💻 C
📖 第 1 页 / 共 5 页
字号:
          case KRB_A_IN:                /* INIT */            rc |= !(ck_krb5_initTGT(&krb_op,&krb5_init,                                     krb5_init.getk4 ? &krb4_init : 0) < 0);            break;          case KRB_A_DE:                /* DESTROY */            rc |= !(ck_krb5_destroy(&krb_op) < 0);            break;          case KRB_A_LC:                /* LIST-CREDENTIALS */            if (krb_op.version == 0)              printf("\n");            rc |= !(ck_krb5_list_creds(&krb_op,&krb5_lc) < 0);            break;        }    }#else#ifndef NOICP#ifndef NOSHOW    rc = sho_auth(0);                   /* Show all */#endif /* NOSHOW */#endif /* NOICP */#endif /* CK_AUTHENTICATION */    return(rc);}#endif /* CK_KERBEROS */#ifdef TCPSOCKET#ifndef OS2#ifndef NOLISTEN                        /* For incoming connections */#ifndef INADDR_ANY#define INADDR_ANY 0#endif /* INADDR_ANY */_PROTOTYP( int ttbufr, ( VOID ) );_PROTOTYP( int tcpsrv_open, (char *, int *, int, int ) );static unsigned short tcpsrv_port = 0;#endif /* NOLISTEN */#endif /* OS2 */static char svcbuf[80];                 /* TCP service string */static int svcnum = 0;                  /* TCP port number */#endif /* TCPSOCKET *//*  TCPIPLIB means use separate socket calls for i/o, while on UNIX the  normal file system calls are used for TCP/IP sockets too.  Means "DEC_TCPIP or MULTINET or WINTCP or OS2 or BEBOX" (see ckcnet.h),*/#ifdef TCPIPLIB/* For buffered network reads... *//*  If the buffering code is written right, it shouldn't matter  how long this buffer is.*/#ifdef OS2#ifdef NT#define TTIBUFL 64240                   /* 44 * 1460 (MSS) */#else#define TTIBUFL 32120                   /* 22 * 1460 (MSS) */#endif /* NT */#else /* OS2 */#define TTIBUFL 8191                    /* Let's use 8K. */#endif /* OS2 */CHAR ttibuf[TTIBUFL+1];/*  select() is used in preference to alarm()/signal(), but different systems  use different forms of select()...*/#ifndef NOSELECT         /* Option to override BSDSELECT */#ifdef BELLV10/*  Note: Although BELLV10 does have TCP/IP support, and does use the unique  form of select() that is evident in this module (and in ckutio.c), it does  not have a sockets library and so we can't build Kermit TCP/IP support for  it.  For this, somebody would have to write TCP/IP streams code.*/#define BELLSELECT#ifndef FD_SETSIZE#define FD_SETSIZE 128#endif /* FD_SETSIZE */#else#ifdef WINTCP                           /* VMS with Wollongong WIN/TCP */#ifndef OLD_TWG                         /* TWG 3.2 has only select(read) */#define BSDSELECT#endif /* OLD_TWG */#else#ifdef CMU_TCPIP                        /* LIBCMU can do select */#define BSDSELECT#else#ifdef DEC_TCPIP#define BSDSELECT#else#ifdef OS2                              /* OS/2 with TCP/IP */#ifdef NT#define BSDSELECT#else /* NT */#define IBMSELECT#endif /* NT */#endif /* OS2 */#endif /* DEC_TCPIP */#endif /* CMU_TCPIP */#endif /* WINTCP */#endif /* BELLV10 */#endif /* NOSELECT *//*  Others (TGV, TCPware, ...) use alarm()/signal().  The BSDSELECT case does not  compile at all; the IBMSELECT case compiles and links but crashes at runtime.  NOTE: If any of these can be converted to select(), they should be for two  reasons: (1) It's a lot faster; (2) certain sockets libraries do not like  their socket_read() calls to be interrupted; subsequent socket_read()'s tend  to fail with EBUSY.  This happened in the UCX case before it was converted  to use select().*/#ifndef OS2#ifndef VMSstatic                                  /* These are used in CKVTIO.C */#endif /* VMS */                        /* And in CKONET.C            */#endif /* OS2 */int  ttibp = 0,  ttibn = 0;/*  Read bytes from network into internal buffer ttibuf[].  To be called when input buffer is empty, i.e. when ttibn == 0.  Other network reading routines, like ttinc, ttinl, ttxin, should check the  internal buffer first, and call this routine for a refill if necessary.  Returns -1 on error, 0 if nothing happens.  When data is read successfully,  returns number of bytes read, and sets global ttibn to that number and  ttibp (the buffer pointer) to zero.*/_PROTOTYP( int ttbufr, ( VOID ) );intttbufr() {                              /* TT Buffer Read */    int count;    if (ttnet != NET_TCPB)              /* First make sure current net is */      return(-1);                       /* TCP/IP; if not, do nothing. */#ifdef OS2    RequestTCPIPMutex(SEM_INDEFINITE_WAIT);#endif /* OS2 */    if (ttibn > 0) {                    /* Our internal buffer is not empty, */#ifdef OS2        ReleaseTCPIPMutex();#endif /* OS2 */        return(ttibn);                  /* so keep using it. */    }    if (ttyfd == -1) {                  /* No connection, error */#ifdef OS2        ReleaseTCPIPMutex();#endif /* OS2 */        return(-2);    }    ttibp = 0;                          /* Else reset pointer to beginning */#ifdef WINTCP    count = 512;                        /* This works for WIN/TCP */#else#ifdef DEC_TCPIP    count = 512;                        /* UCX */#else#ifdef OS2    count = TTIBUFL;#else                                   /* Multinet, etc. */    count = ttchk();                    /* Check network input buffer, */    if (ttibn > 0) {                    /* which can put a char there! */        debug(F111,"ttbufr","ttchk() returns",count);#ifdef OS2        ReleaseTCPIPMutex();#endif /* OS2 */        return(ttibn);    }    if (count < 0) {                     /* Read error - connection closed */#ifdef OS2        ReleaseTCPIPMutex();#endif /* OS2 */        return(-2);    }    else if (count > TTIBUFL)           /* Too many to read */      count = TTIBUFL;    else if (count == 0)                /* None, so force blocking read */      count = 1;#endif /* OS2 */#endif /* DEC_TCPIP */#endif /* WINTCP */    debug(F101,"ttbufr count 1","",count);#ifdef CK_SSL    if (ssl_active_flag || tls_active_flag) {        int error;      ssl_read:        if (ssl_active_flag)          count = SSL_read(ssl_con, ttibuf, count);        else          count = SSL_read(tls_con, ttibuf, count);        error = SSL_get_error(ssl_active_flag?ssl_con:tls_con,count);        switch (error) {          case SSL_ERROR_NONE:            debug(F111,"ttbufr SSL_ERROR_NONE","count",count);            if (count > 0) {                ttibp = 0;              /* Reset buffer pointer. */                ttibn = count;#ifdef OS2                ReleaseTCPIPMutex();#endif /* OS2 */                return(ttibn);          /* Return buffer count. */            } else if (count < 0) {#ifdef OS2                ReleaseTCPIPMutex();#endif /* OS2 */                return(-1);            } else {                netclos();#ifdef OS2                ReleaseTCPIPMutex();#endif /* OS2 */                return(-2);            }          case SSL_ERROR_WANT_WRITE:            debug(F100,"ttbufr SSL_ERROR_WANT_WRITE","",0);#ifdef OS2              ReleaseTCPIPMutex();#endif /* OS2 */            return(-1);          case SSL_ERROR_WANT_READ:            debug(F100,"ttbufr SSL_ERROR_WANT_READ","",0);#ifdef OS2            ReleaseTCPIPMutex();#endif /* OS2 */            return(-1);          case SSL_ERROR_SYSCALL:              if ( count == 0 ) { /* EOF */                  netclos();#ifdef OS2                  ReleaseTCPIPMutex();#endif /* OS2 */                  return(-2);              } else {                  int rc = -1;#ifdef NT                  int gle = GetLastError();                  debug(F111,"ttbufr SSL_ERROR_SYSCALL",                         "GetLastError()",gle);                  rc = os2socketerror(gle);                  if (rc == -1)                      rc = -2;                  else if ( rc == -2 )                      rc = -1;#endif /* NT */#ifdef OS2                  ReleaseTCPIPMutex();#endif /* OS2 */                  return(rc);              }          case SSL_ERROR_WANT_X509_LOOKUP:            debug(F100,"ttbufr SSL_ERROR_WANT_X509_LOOKUP","",0);            netclos();#ifdef OS2              ReleaseTCPIPMutex();#endif /* OS2 */            return(-2);          case SSL_ERROR_SSL:              if (bio_err!=NULL) {                  int len;                  extern char ssl_err[];                  BIO_printf(bio_err,"ttbufr SSL_ERROR_SSL\n");                  ERR_print_errors(bio_err);                  len = BIO_read(bio_err,ssl_err,SSL_ERR_BFSZ);                  ssl_err[len < SSL_ERR_BFSZ ? len : SSL_ERR_BFSZ] = '\0';                  debug(F110,"ttbufr SSL_ERROR_SSL",ssl_err,0);                  if (ssl_debug_flag)                                        printf(ssl_err);              } else if (ssl_debug_flag) {                  debug(F100,"ttbufr SSL_ERROR_SSL","",0);                  fflush(stderr);                  fprintf(stderr,"ttbufr SSL_ERROR_SSL\n");                  ERR_print_errors_fp(stderr);              }#ifdef COMMENT	      netclos();#endif /* COMMENT */#ifdef OS2              ReleaseTCPIPMutex();#endif /* OS2 */            return(-2);          case SSL_ERROR_ZERO_RETURN:            debug(F100,"ttbufr SSL_ERROR_ZERO_RETURN","",0);            netclos();#ifdef OS2              ReleaseTCPIPMutex();#endif /* OS2 */            return(-2);          default:              debug(F100,"ttbufr SSL_ERROR_?????","",0);              netclos();#ifdef OS2              ReleaseTCPIPMutex();#endif /* OS2 */              return(-2);          }    }#endif /* CK_SSL */#ifdef COMMENT/* This is for nonblocking reads, which we don't do any more.  This code didn't work anyway, in the sense that a broken connection was never sensed.*/    if ((count = socket_read(ttyfd,&ttibuf[ttibp+ttibn],count)) < 1) {        if (count == -1 && socket_errno == EWOULDBLOCK) {            debug(F100,"ttbufr finds nothing","",0);#ifdef OS2            ReleaseTCPIPMutex();#endif /* OS2 */            return(0);        } else {            debug(F101,"ttbufr socket_read error","",socket_errno);#ifdef OS2            ReleaseTCPIPMutex();#endif /* OS2 */            return(-1);        }    } else if (count == 0) {        debug(F100,"ttbufr socket eof","",0);#ifdef OS2        ReleaseTCPIPMutex();#endif /* OS2 */        return(-1);    }#else /* COMMENT *//* This is for blocking reads */#ifndef VMS#ifdef SO_OOBINLINE    {        int outofband = 0;#ifdef BELLSELECT        if (select(128, NULL, NULL, efds, 0) > 0 && FD_ISSET(ttyfd, efds))          outofband = 1;#else#ifdef BSDSELECT        fd_set efds;        struct timeval tv;        FD_ZERO(&efds);        FD_SET(ttyfd, &efds);        tv.tv_sec  = tv.tv_usec = 0L;        debug(F100,"Out-of-Band BSDSELECT","",0);#ifdef NT        WSASafeToCancel = 1;#endif /* NT */        if (select(FD_SETSIZE, NULL, NULL, &efds, &tv) > 0 &&            FD_ISSET(ttyfd, &efds))          outofband = 1;#ifdef NT        WSASafeToCancel = 0;#endif /* NT */#else /* !BSDSELECT */#ifdef IBMSELECT/* Is used by OS/2 ... *//* ... and it came in handy!  For our TCP/IP layer, it avoids all the fd_set *//* and timeval stuff since this is the only place where it is used. */        int socket = ttyfd;        debug(F100,"Out-of-Band IBMSELECT","",0);        if ((select(&socket, 0, 0, 1, 0L) == 1) && (socket == ttyfd))          outofband = 1;#else /* !IBMSELECT *//*  If we can't use select(), then we use the regular alarm()/signal()  timeout mechanism.*/      debug(F101,"Out-of-Band data not supported","",0);      outofband = 0;#endif /* IBMSELECT */#endif /* BSDSELECT */#endif /* BELLSELECT */      if (outofband) {         /* Get the Urgent Data */         /* if OOBINLINE is disabled this should be only a single byte      */         /* MS Winsock has a bug in Windows 95.  Extra bytes are delivered  */         /* That were never sent.                                           */#ifdef OS2          RequestTCPIPMutex(SEM_INDEFINITE_WAIT);#endif /* OS2 */          count = socket_recv(ttyfd,&ttibuf[ttibp+ttibn],count,MSG_OOB);#ifdef OS2          ReleaseTCPIPMutex();#endif /* OS2 */          if (count <= 0) {              int s_errno = socket_errno;              debug(F101, "ttbufr socket_recv MSG_OOB","",count);              debug(F101, "ttbufr socket_errno","",s_errno);#ifdef OS2ONLY              if (count < 0 && (s_errno == 0 || s_errno == 23)) {                  /* These appear in OS/2 - don't know why   */                  /* ignore it and read as normal data       */                  /* and break, then we will attempt to read */                  /* the port using normal read() techniques */                  debug(F100,"ttbufr handing as in-band data","",0);                  count = 1;              } else {                  netclos();                    /* *** *** */#ifdef OS2                  ReleaseTCPIPMutex();#endif /* OS2 */                  return(-2);              }#else /* OS2ONLY */              netclos();                        /* *** *** */#ifdef OS2              ReleaseTCPIPMutex();#endif /* OS2 */

⌨️ 快捷键说明

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