usrFtp.c
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:2k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* usrFtp.c - Support for FTP client */
  2. /* Copyright 2002 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01b,23may02,elr  ftpLibDebugLevelSet (FTP_DEBUG_LEVEL) is now
  7.                  ftpLibDebugOptionsSet (FTP_DEBUG_OPTIONS)
  8. 01a,20dec06,elr  created
  9. */
  10. /*
  11. DESCRIPTION
  12. This file is used to include support for the ftp client.
  13. NOMANUAL
  14. */
  15. IMPORT UINT32 ftplTransientMaxRetryCount;
  16. IMPORT UINT32 ftplTransientRetryInterval;
  17. IMPORT STATUS ftpTransientFatalInstall();
  18. IMPORT STATUS ftplDebugOptionsSet();
  19. /*******************************************************************************
  20. *
  21. * ftpTransientFatal - example applette to terminate FTP transient host responses
  22. *
  23. * ftpXfer will normally retry a command if the host responds with a 4xx
  24. *     reply.   If this applette is installed,  it can immediately terminate
  25. *     the retry sequence.
  26. *
  27. *
  28. * RETURNS : TRUE - Terminate retry attempts
  29. *           FALSE - Continue retry attempts
  30. *
  31. *
  32. * SEE ALSO : ftpTransientFatalInstall(), ftpTransientConfigSet()
  33. *
  34. */
  35. LOCAL BOOL ftpTransientFatal 
  36.     (
  37.     UINT32 reply /* Three digit code defined in RFC #640 */
  38.     )
  39.     {
  40.     switch (reply)
  41.         {
  42.         case (421): /* Service not available */
  43.         case (450): /* File unavailable */
  44.         case (451): /* error in processing */
  45.         case (452): /* insufficient storage */
  46.             { 
  47.             /* yes, these are actually non-recoverable replies */
  48.             return (TRUE); 
  49.             break;
  50.             }
  51.             /* attempt to retry the last command */
  52.         default:
  53.         return (FALSE); 
  54.         }
  55.     }
  56. /******************************************************************************
  57. *
  58. * usrFtpInit - initialize FTP parameters
  59. *
  60. * This routine configures ftp client parameters.
  61. * defined by the user via the project facility.
  62. *
  63. * RETURNS: OK or ERROR
  64. *
  65. * NOMANUAL
  66. */
  67. STATUS usrFtpInit (void)
  68.     {
  69.     ftplTransientMaxRetryCount = FTP_TRANSIENT_MAX_RETRY_COUNT;
  70.     ftplTransientRetryInterval = FTP_TRANSIENT_RETRY_INTERVAL;
  71.     ftpTransientFatalInstall ( FTP_TRANSIENT_FATAL );
  72.     ftpLibDebugOptionsSet ( FTP_DEBUG_OPTIONS );
  73.     return OK;
  74.     }