home *** CD-ROM | disk | FTP | other *** search
/ ftp.ncftp.com / ftp.ncftp.com.zip / ftp.ncftp.com / ncftp / older_versions / ncftp-3.2.2-src.tar.bz2 / ncftp-3.2.2-src.tar / ncftp-3.2.2 / libncftp / u_rebuildci.c < prev    next >
C/C++ Source or Header  |  2008-07-13  |  2KB  |  79 lines

  1. /* u_rebuildci.c
  2.  *
  3.  * Copyright (c) 1996-2005 Mike Gleason, NcFTP Software.
  4.  * All rights reserved.
  5.  *
  6.  */
  7.  
  8. #include "syshdrs.h"
  9. #ifdef PRAGMA_HDRSTOP
  10. #    pragma hdrstop
  11. #endif
  12.  
  13. int
  14. FTPRebuildConnectionInfo(const FTPLIPtr lip, const FTPCIPtr cip)
  15. {
  16.     char *buf;
  17.  
  18.     cip->lip = lip;
  19.     cip->debugLog = NULL;
  20.     cip->errLog = NULL;
  21.     cip->debugLogProc = NULL;
  22.     cip->errLogProc = NULL;
  23.     cip->buf = NULL;
  24.     cip->cin = NULL;
  25.     cip->cout = NULL;
  26.     cip->errNo = 0;
  27.     cip->progress = NULL;
  28.     cip->rname = NULL;
  29.     cip->lname = NULL;
  30.     cip->onConnectMsgProc = NULL;
  31.     cip->redialStatusProc = NULL;
  32.     cip->printResponseProc = NULL;
  33.     cip->onLoginMsgProc = NULL;
  34.     cip->passphraseProc = NULL;
  35.     cip->startingWorkingDirectory = NULL;
  36.     cip->asciiFilenameExtensions = NULL;
  37.     cip->dataTimedOut = 0;
  38.  
  39.     (void) memset(&cip->lastFTPCmdResultLL, 0, sizeof(FTPLineList));
  40.  
  41.     /* Allocate a new buffer. */
  42.     buf = (char *) calloc((size_t) 1, cip->bufSize);
  43.     if (buf == NULL) {
  44.         cip->errNo = kErrMallocFailed;
  45.         return (kErrMallocFailed);
  46.     }
  47.     cip->buf = buf;
  48.  
  49.     /* Reattach the FILE pointers for use with the Std I/O library
  50.      * routines.
  51.      */
  52.     if ((cip->cin = fdopen(cip->ctrlSocketR, "r")) == NULL) {
  53.         cip->errNo = kErrFdopenR;
  54.         cip->ctrlSocketR = kClosedFileDescriptor;
  55.         cip->ctrlSocketW = kClosedFileDescriptor;
  56.         return (kErrFdopenR);
  57.     }
  58.  
  59.     if ((cip->cout = fdopen(cip->ctrlSocketW, "w")) == NULL) {
  60.         CloseFile(&cip->cin);
  61.         cip->errNo = kErrFdopenW;
  62.         cip->ctrlSocketR = kClosedFileDescriptor;
  63.         cip->ctrlSocketW = kClosedFileDescriptor;
  64.         return (kErrFdopenW);
  65.     }
  66.  
  67. #if USE_SIO
  68.     if (InitSReadlineInfo(&cip->ctrlSrl, cip->ctrlSocketR, cip->srlBuf, sizeof(cip->srlBuf), (int) cip->ctrlTimeout, 1) < 0) {
  69.         cip->errNo = kErrFdopenW;
  70.         CloseFile(&cip->cin);
  71.         cip->errNo = kErrFdopenW;
  72.         cip->ctrlSocketR = kClosedFileDescriptor;
  73.         cip->ctrlSocketW = kClosedFileDescriptor;
  74.         return (kErrFdopenW);
  75.     }
  76. #endif
  77.     return (kNoErr);
  78. }    /* FTPRebuildConnectionInfo */
  79.