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 / c_modtime.c < prev    next >
C/C++ Source or Header  |  2005-01-01  |  2KB  |  67 lines

  1. /* c_modtime.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. FTPFileModificationTime(const FTPCIPtr cip, const char *const file, time_t *const mdtm)
  15. {
  16.     int result;
  17.     ResponsePtr rp;
  18.  
  19.     if (cip == NULL)
  20.         return (kErrBadParameter);
  21.     if (strcmp(cip->magic, kLibraryMagic))
  22.         return (kErrBadMagic);
  23.  
  24.     if ((mdtm == NULL) || (file == NULL))
  25.         return (kErrBadParameter);
  26.     *mdtm = kModTimeUnknown;
  27.  
  28.     if (cip->hasMDTM == kCommandNotAvailable) {
  29.         cip->errNo = kErrMDTMNotAvailable;
  30.         result = kErrMDTMNotAvailable;
  31.     } else {
  32.         rp = InitResponse();
  33.         if (rp == NULL) {
  34.             result = kErrMallocFailed;
  35.             cip->errNo = kErrMallocFailed;
  36.             FTPLogError(cip, kDontPerror, "Malloc failed.\n");
  37.         } else {
  38.             result = RCmd(cip, rp, "MDTM %s", file);
  39.             if (result < 0) {
  40.                 DoneWithResponse(cip, rp);
  41.                 return (result);
  42.             }
  43.             if (result == 2) {
  44.                 if (strncmp(rp->msg.first->line, "1910", 4) == 0) {
  45.                     /* Year was printed as "19100" rather than
  46.                      * "2000" ...
  47.                      */
  48.                     FTPLogError(cip, kDontPerror, "Warning: Server has Y2K Bug in \"MDTM\" command.\n");
  49.                 }
  50.                 *mdtm = UnMDTMDate(rp->msg.first->line);
  51.                 cip->hasMDTM = kCommandAvailable;
  52.                 result = kNoErr;
  53.             } else if (FTP_UNIMPLEMENTED_CMD(rp->code)) {
  54.                 cip->hasMDTM = kCommandNotAvailable;
  55.                 cip->hasMDTM_set = kCommandNotAvailable;
  56.                 cip->errNo = kErrMDTMNotAvailable;
  57.                 result = kErrMDTMNotAvailable;
  58.             } else {
  59.                 cip->errNo = kErrMDTMFailed;
  60.                 result = kErrMDTMFailed;
  61.             }
  62.             DoneWithResponse(cip, rp);
  63.         }
  64.     }
  65.     return (result);
  66. }    /* FTPFileModificationTime */
  67.