ReactOS  0.4.13-dev-259-g5ca9c9c
ncftp.h File Reference
#include <stdio.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include "ncftp_errno.h"
Include dependency graph for ncftp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Line
 
struct  LineList
 
struct  Response
 
struct  SReadlineInfo
 
struct  FTPLibraryInfo
 
struct  FTPConnectionInfo
 
struct  FileInfo
 
struct  FileInfoList
 
struct  MLstItem
 

Macros

#define kLibraryVersion   "@(#) LibNcFTP 3.0.6 (April 14, 2001)"
 
#define USE_SIO   1
 
#define NO_SIGNALS   1
 
#define kLibraryMagic   "LibNcFTP 3.0.6"
 
#define longest_int   long long
 
#define longest_uint   unsigned long long
 
#define forever   for ( ; ; )
 
#define _SReadlineInfo_   1
 
#define kPrInitMsg   1
 
#define kPrUpdateMsg   2
 
#define kPrEndMsg   3
 
#define kSendPortMode   0
 
#define kPassiveMode   1
 
#define kFallBackToSendPortMode   2
 
#define kAcceptForWriting   00100
 
#define kAcceptForReading   00101
 
#define kNetWriting   kAcceptForWriting
 
#define kNetReading   kAcceptForReading
 
#define kResponseNoPrint   00001
 
#define kResponseNoSave   00002
 
#define kResponseNoProc   00002
 
#define kDefaultFTPPort   21
 
#define kDefaultFTPBufSize   32768
 
#define kDefaultXferTimeout   600
 
#define kDefaultConnTimeout   30
 
#define kDefaultCtrlTimeout   135
 
#define kDefaultAbortTimeout   10
 
#define kSuggestedDefaultXferTimeout   (0) /* No timeout on data blocks. */
 
#define kSuggestedDefaultConnTimeout   30
 
#define kSuggestedDefaultCtrlTimeout   135 /* 2*MSL, + slop */
 
#define kSuggestedAbortTimeout   10
 
#define kDefaultMaxDials   3
 
#define kDefaultRedialDelay   20 /* seconds */
 
#define kDefaultDataPortMode   kSendPortMode
 
#define kRedialStatusDialing   0
 
#define kRedialStatusSleeping   1
 
#define INADDR_NONE   (0xffffffff) /* <netinet/in.h> should have it. */
 
#define kTypeAscii   'A'
 
#define kTypeBinary   'I'
 
#define kTypeEbcdic   'E'
 
#define kGlobChars   "[*?"
 
#define GLOBCHARSINSTR(a)   (strpbrk(a, kGlobChars) != NULL)
 
#define kGlobYes   1
 
#define kGlobNo   0
 
#define kRecursiveYes   1
 
#define kRecursiveNo   0
 
#define kAppendYes   1
 
#define kAppendNo   0
 
#define kResumeYes   1
 
#define kResumeNo   0
 
#define kDeleteYes   1
 
#define kDeleteNo   0
 
#define kTarYes   1
 
#define kTarNo   0
 
#define UNIMPLEMENTED_CMD(a)   ((a == 500) || (a == 502) || (a == 504))
 
#define kSizeUnknown   ((longest_int) (-1))
 
#define kModTimeUnknown   ((time_t) (-1))
 
#define kCommandAvailabilityUnknown   (-1)
 
#define kCommandAvailable   1
 
#define kCommandNotAvailable   0
 
#define kNotURL   (-1)
 
#define kMalformedURL   (-2)
 
#define kFirewallNotInUse   0
 
#define kFirewallUserAtSite   1
 
#define kFirewallLoginThenUserAtSite   2
 
#define kFirewallSiteSite   3
 
#define kFirewallOpenSite   4
 
#define kFirewallUserAtUserPassAtPass   5
 
#define kFirewallFwuAtSiteFwpUserPass   6
 
#define kFirewallUserAtSiteFwuPassFwp   7
 
#define kFirewallLastType   kFirewallUserAtSiteFwuPassFwp
 
#define kPreferredMlsOpts   (kMlsOptType | kMlsOptSize | kMlsOptModify | kMlsOptUNIXmode | kMlsOptUNIXowner | kMlsOptUNIXgroup | kMlsOptUNIXuid | kMlsOptUNIXgid | kMlsOptPerm)
 
#define kMlsOptType   00001
 
#define kMlsOptSize   00002
 
#define kMlsOptModify   00004
 
#define kMlsOptUNIXmode   00010
 
#define kMlsOptUNIXowner   00020
 
#define kMlsOptUNIXgroup   00040
 
#define kMlsOptPerm   00100
 
#define kMlsOptUNIXuid   00200
 
#define kMlsOptUNIXgid   00400
 
#define kMlsOptUnique   01000
 
#define kFtwFile   0
 
#define kFtwDir   1
 
#define kChdirOnly   00000
 
#define kChdirAndMkdir   00001
 
#define kChdirAndGetCWD   00002
 
#define kChdirOneSubdirAtATime   00004
 
#define kConfirmResumeProcNotUsed   0
 
#define kConfirmResumeProcSaidSkip   1
 
#define kConfirmResumeProcSaidResume   2
 
#define kConfirmResumeProcSaidOverwrite   3
 
#define kConfirmResumeProcSaidAppend   4
 
#define kConfirmResumeProcSaidBestGuess   5
 
#define kConfirmResumeProcSaidCancel   6
 
#define NoConfirmResumeDownloadProc   ((ConfirmResumeDownloadProc) 0)
 
#define NoConfirmResumeUploadProc   ((ConfirmResumeUploadProc) 0)
 
#define NoGetPassphraseProc   ((FTPGetPassphraseProc) 0)
 
#define kServerTypeUnknown   0
 
#define kServerTypeWuFTPd   1
 
#define kServerTypeNcFTPd   2
 
#define kServerTypeProFTPD   3
 
#define kServerTypeMicrosoftFTP   4
 
#define kServerTypeWarFTPd   5
 
#define kServerTypeServ_U   6
 
#define kServerTypeWFTPD   7
 
#define kServerTypeVFTPD   8
 
#define kServerTypeFTP_Max   9
 
#define kServerTypeRoxen   10
 
#define kServerTypeNetWareFTP   11
 
#define kServerTypeWS_FTP   12
 
#define closesocket   close
 
#define ioctlsocket   ioctl
 
#define LOCAL_PATH_DELIM   '/'
 
#define LOCAL_PATH_DELIM_STR   "/"
 
#define StrFindLocalPathDelim(a)   strchr(a, LOCAL_PATH_DELIM)
 
#define StrRFindLocalPathDelim(a)   strrchr(a, LOCAL_PATH_DELIM)
 
#define StrRemoveTrailingLocalPathDelim   StrRemoveTrailingSlashes
 
#define IsLocalPathDelim(c)   (c == LOCAL_PATH_DELIM)
 
#define TVFSPathToLocalPath(s)
 
#define LocalPathToTVFSPath(s)
 
#define LIBNCFTP_USE_VAR(a)   gLibNcFTP_Uses_Me_To_Quiet_Variable_Unused_Warnings = (a == 0)
 
#define UNUSED(a)   a
 
#define NcSignal   signal
 

Typedefs

typedef void(* FTPSigProc) (int)
 
typedef struct LineLinePtr
 
typedef struct Line Line
 
typedef struct LineList LineList
 
typedef struct LineListLineListPtr
 
typedef struct Response Response
 
typedef struct ResponseResponsePtr
 
typedef struct SReadlineInfo SReadlineInfo
 
typedef struct FTPLibraryInfo FTPLibraryInfo
 
typedef struct FTPLibraryInfoFTPLIPtr
 
typedef struct FTPConnectionInfoFTPCIPtr
 
typedef void(* FTPProgressMeterProc) (const FTPCIPtr, int)
 
typedef void(* FTPLogProc) (const FTPCIPtr, char *)
 
typedef void(* FTPConnectMessageProc) (const FTPCIPtr, ResponsePtr)
 
typedef void(* FTPLoginMessageProc) (const FTPCIPtr, ResponsePtr)
 
typedef void(* FTPRedialStatusProc) (const FTPCIPtr, int, int)
 
typedef void(* FTPPrintResponseProc) (const FTPCIPtr, ResponsePtr)
 
typedef int(* FTPFtwProc) (const FTPCIPtr cip, const char *fn, int flag)
 
typedef void(* FTPGetPassphraseProc) (const FTPCIPtr, LineListPtr pwPrompt, char *pass, size_t dsize)
 
typedef struct FTPConnectionInfo FTPConnectionInfo
 
typedef struct FileInfoFileInfoPtr
 
typedef struct FileInfo ** FileInfoVec
 
typedef struct FileInfo FileInfo
 
typedef struct FileInfoList FileInfoList
 
typedef struct FileInfoListFileInfoListPtr
 
typedef struct MLstItem MLstItem
 
typedef struct MLstItemMLstItemPtr
 
typedef int(* ConfirmResumeDownloadProc) (const char *volatile *localpath, volatile longest_int localsize, volatile time_t localmtime, const char *volatile remotepath, volatile longest_int remotesize, volatile time_t remotetime, volatile longest_int *volatile startPoint)
 
typedef int(* ConfirmResumeUploadProc) (const char *volatile localpath, volatile longest_int localsize, volatile time_t localmtime, const char *volatile *remotepath, volatile longest_int remotesize, volatile time_t remotetime, volatile longest_int *volatile startPoint)
 

Functions

void FTPAbortDataTransfer (const FTPCIPtr cip)
 
int FTPChdir (const FTPCIPtr cip, const char *const cdCwd)
 
int FTPChdirAndGetCWD (const FTPCIPtr cip, const char *const cdCwd, char *const newCwd, const size_t newCwdSize)
 
int FTPChdir3 (FTPCIPtr cip, const char *const cdCwd, char *const newCwd, const size_t newCwdSize, int flags)
 
int FTPChmod (const FTPCIPtr cip, const char *const pattern, const char *const mode, const int doGlob)
 
int FTPCloseHost (const FTPCIPtr cip)
 
int FTPCmd (const FTPCIPtr cip, const char *const cmdspec,...)
 
int FTPDecodeURL (const FTPCIPtr cip, char *const url, LineListPtr cdlist, char *const fn, const size_t fnsize, int *const xtype, int *const wantnlst)
 
int FTPDelete (const FTPCIPtr cip, const char *const pattern, const int recurse, const int doGlob)
 
int FTPFileExists (const FTPCIPtr cip, const char *const file)
 
int FTPFileModificationTime (const FTPCIPtr cip, const char *const file, time_t *const mdtm)
 
int FTPFileSize (const FTPCIPtr cip, const char *const file, longest_int *const size, const int type)
 
int FTPFileSizeAndModificationTime (const FTPCIPtr cip, const char *const file, longest_int *const size, const int type, time_t *const mdtm)
 
int FTPFileType (const FTPCIPtr cip, const char *const file, int *const ftype)
 
int FTPGetCWD (const FTPCIPtr cip, char *const newCwd, const size_t newCwdSize)
 
int FTPGetFiles3 (const FTPCIPtr cip, const char *pattern, const char *const dstdir, const int recurse, int doGlob, const int xtype, const int resumeflag, int appendflag, const int deleteflag, const int tarflag, const ConfirmResumeDownloadProc resumeProc, int reserved)
 
int FTPGetOneFile3 (const FTPCIPtr cip, const char *const file, const char *const dstfile, const int xtype, const int fdtouse, const int resumeflag, const int appendflag, const int deleteflag, const ConfirmResumeDownloadProc resumeProc, int reserved)
 
int FTPInitConnectionInfo (const FTPLIPtr lip, const FTPCIPtr cip, size_t bufsize)
 
int FTPInitLibrary (const FTPLIPtr lip)
 
int FTPIsDir (const FTPCIPtr cip, const char *const dir)
 
int FTPIsRegularFile (const FTPCIPtr cip, const char *const file)
 
int FTPList (const FTPCIPtr cip, const int outfd, const int longMode, const char *const lsflag)
 
int FTPListToMemory (const FTPCIPtr cip, const char *const pattern, const LineListPtr llines, const char *const lsflags)
 
int FTPLocalGlob (FTPCIPtr cip, LineListPtr fileList, const char *pattern, int doGlob)
 
int FTPLoginHost (const FTPCIPtr cip)
 
int FTPMkdir (const FTPCIPtr cip, const char *const newDir, const int recurse)
 
int FTPMkdir2 (const FTPCIPtr cip, const char *const newDir, const int recurse, const char *const curDir)
 
int FTPOpenHost (const FTPCIPtr cip)
 
int FTPOpenHostNoLogin (const FTPCIPtr cip)
 
void FTPPerror (const FTPCIPtr cip, const int err, const int eerr, const char *const s1, const char *const s2)
 
int FTPPutOneFile3 (const FTPCIPtr cip, const char *const file, const char *const dstfile, const int xtype, const int fdtouse, const int appendflag, const char *const tmppfx, const char *const tmpsfx, const int resumeflag, const int deleteflag, const ConfirmResumeUploadProc resumeProc, int reserved)
 
int FTPPutFiles3 (const FTPCIPtr cip, const char *const pattern, const char *const dstdir, const int recurse, const int doGlob, const int xtype, int appendflag, const char *const tmppfx, const char *const tmpsfx, const int resumeflag, const int deleteflag, const ConfirmResumeUploadProc resumeProc, int reserved)
 
int FTPRemoteGlob (FTPCIPtr cip, LineListPtr fileList, const char *pattern, int doGlob)
 
int FTPRename (const FTPCIPtr cip, const char *const oldname, const char *const newname)
 
int FTPRmdir (const FTPCIPtr cip, const char *const pattern, const int recurse, const int doGlob)
 
void FTPShutdownHost (const FTPCIPtr cip)
 
const charFTPStrError (int e)
 
int FTPSymlink (const FTPCIPtr cip, const char *const lfrom, const char *const lto)
 
int FTPUmask (const FTPCIPtr cip, const char *const umsk)
 
int FTPUtime (const FTPCIPtr cip, const char *const file, time_t actime, time_t modtime, time_t crtime)
 
int CopyLineList (LineListPtr, LineListPtr)
 
void DisposeLineListContents (LineListPtr)
 
void InitLineList (LineListPtr)
 
LinePtr RemoveLine (LineListPtr, LinePtr)
 
LinePtr AddLine (LineListPtr, const char *)
 
charStrDup (const char *)
 
charFGets (char *, size_t, FILE *)
 
void GetHomeDir (char *, size_t)
 
void GetUsrName (char *, size_t)
 
void Scramble (unsigned char *dst, size_t dsize, unsigned char *src, char *key)
 
time_t UnMDTMDate (char *)
 
int MkDirs (const char *const, int mode1)
 
charGetPass (const char *const prompt)
 
int FilenameExtensionIndicatesASCII (const char *const pathName, const char *const extnList)
 
void StrRemoveTrailingSlashes (char *dst)
 
int FTPGetOneFile (const FTPCIPtr cip, const char *const file, const char *const dstfile)
 
int FTPGetOneFile2 (const FTPCIPtr cip, const char *const file, const char *const dstfile, const int xtype, const int fdtouse, const int resumeflag, const int appendflag)
 
int FTPGetFiles (const FTPCIPtr cip, const char *const pattern, const char *const dstdir, const int recurse, const int doGlob)
 
int FTPGetFiles2 (const FTPCIPtr cip, const char *const pattern, const char *const dstdir, const int recurse, const int doGlob, const int xtype, const int resumeflag, const int appendflag)
 
int FTPGetOneFileAscii (const FTPCIPtr cip, const char *const file, const char *const dstfile)
 
int FTPGetFilesAscii (const FTPCIPtr cip, const char *const pattern, const char *const dstdir, const int recurse, const int doGlob)
 
int FTPPutOneFile (const FTPCIPtr cip, const char *const file, const char *const dstfile)
 
int FTPPutOneFile2 (const FTPCIPtr cip, const char *const file, const char *const dstfile, const int xtype, const int fdtouse, const int appendflag, const char *const tmppfx, const char *const tmpsfx)
 
int FTPPutFiles (const FTPCIPtr cip, const char *const pattern, const char *const dstdir, const int recurse, const int doGlob)
 
int FTPPutFiles2 (const FTPCIPtr cip, const char *const pattern, const char *const dstdir, const int recurse, const int doGlob, const int xtype, const int appendflag, const char *const tmppfx, const char *const tmpsfx)
 
int FTPPutOneFileAscii (const FTPCIPtr cip, const char *const file, const char *const dstfile)
 
int FTPPutFilesAscii (const FTPCIPtr cip, const char *const pattern, const char *const dstdir, const int recurse, const int doGlob)
 
charFTPGetLocalCWD (char *buf, size_t size)
 
int FTPQueryFeatures (const FTPCIPtr)
 
int FTPMListOneFile (const FTPCIPtr cip, const char *const file, const MLstItemPtr mlip)
 
void FTPInitializeOurHostName (const FTPLIPtr)
 
void FTPInitializeAnonPassword (const FTPLIPtr)
 
int FTPListToMemory2 (const FTPCIPtr cip, const char *const pattern, const LineListPtr llines, const char *const lsflags, const int blanklines, int *const tryMLSD)
 
void FTPInitIOTimer (const FTPCIPtr)
 
int FTPStartDataCmd (const FTPCIPtr, int, int, longest_int, const char *,...)
 
void FTPStartIOTimer (const FTPCIPtr)
 
void FTPStopIOTimer (const FTPCIPtr)
 
void FTPUpdateIOTimer (const FTPCIPtr)
 
int FTPSetTransferType (const FTPCIPtr, int)
 
int FTPEndDataCmd (const FTPCIPtr, int)
 
int FTPRemoteHelp (const FTPCIPtr, const char *const, const LineListPtr)
 
int FTPCmdNoResponse (const FTPCIPtr, const char *const cmdspec,...)
 
int WaitResponse (const FTPCIPtr, unsigned int)
 
int FTPLocalRecursiveFileList (FTPCIPtr, LineListPtr, FileInfoListPtr)
 
int FTPLocalRecursiveFileList2 (FTPCIPtr cip, LineListPtr fileList, FileInfoListPtr files, int erelative)
 
int FTPRemoteRecursiveFileList (FTPCIPtr, LineListPtr, FileInfoListPtr)
 
int FTPRemoteRecursiveFileList1 (FTPCIPtr, char *const, FileInfoListPtr)
 
int FTPRebuildConnectionInfo (const FTPLIPtr lip, const FTPCIPtr cip)
 
int FTPFileExistsStat (const FTPCIPtr cip, const char *const file)
 
int FTPFileExistsNlst (const FTPCIPtr cip, const char *const file)
 
int FTPFileExists2 (const FTPCIPtr cip, const char *const file, const int tryMDTM, const int trySIZE, const int tryMLST, const int trySTAT, const int tryNLST)
 
int FTPFtw (const FTPCIPtr cip, const char *const dir, FTPFtwProc proc, int maxdepth)
 
int BufferGets (char *, size_t, int, char *, char **, char **, size_t)
 
void DisposeFileInfoListContents (FileInfoListPtr)
 
void InitFileInfoList (FileInfoListPtr)
 
void InitFileInfo (FileInfoPtr)
 
FileInfoPtr RemoveFileInfo (FileInfoListPtr, FileInfoPtr)
 
FileInfoPtr AddFileInfo (FileInfoListPtr, FileInfoPtr)
 
void SortFileInfoList (FileInfoListPtr, int, int)
 
void VectorizeFileInfoList (FileInfoListPtr)
 
void UnvectorizeFileInfoList (FileInfoListPtr)
 
int ComputeRNames (FileInfoListPtr, const char *, int, int)
 
int ComputeLNames (FileInfoListPtr, const char *, const char *, int)
 
int ConcatFileInfoList (FileInfoListPtr, FileInfoListPtr)
 
int ConcatFileToFileInfoList (FileInfoListPtr, char *)
 
int LineListToFileInfoList (LineListPtr, FileInfoListPtr)
 
int LineToFileInfoList (LinePtr, FileInfoListPtr)
 
void URLCopyToken (char *, size_t, const char *, size_t)
 
int UnMlsT (const char *const, const MLstItemPtr)
 
int UnMlsD (FileInfoListPtr, LineListPtr)
 
int UnLslR (FileInfoListPtr, LineListPtr, int)
 
void TraceResponse (const FTPCIPtr, ResponsePtr)
 
void PrintResponse (const FTPCIPtr, LineListPtr)
 
void DoneWithResponse (const FTPCIPtr, ResponsePtr)
 
ResponsePtr InitResponse (void)
 
void ReInitResponse (const FTPCIPtr, ResponsePtr)
 
int GetTelnetString (const FTPCIPtr, char *, size_t, FILE *, FILE *)
 
int GetResponse (const FTPCIPtr, ResponsePtr)
 
int RCmd (const FTPCIPtr, ResponsePtr, const char *,...)
 

Variables

char gLibNcFTPVersion [64]
 
int gLibNcFTP_Uses_Me_To_Quiet_Variable_Unused_Warnings
 

Macro Definition Documentation

◆ _SReadlineInfo_

#define _SReadlineInfo_   1

Definition at line 99 of file ncftp.h.

◆ closesocket

#define closesocket   close

Definition at line 477 of file ncftp.h.

◆ forever

#define forever   for ( ; ; )

Definition at line 73 of file ncftp.h.

◆ GLOBCHARSINSTR

#define GLOBCHARSINSTR (   a)    (strpbrk(a, kGlobChars) != NULL)

Definition at line 358 of file ncftp.h.

◆ INADDR_NONE

#define INADDR_NONE   (0xffffffff) /* <netinet/in.h> should have it. */

Definition at line 350 of file ncftp.h.

◆ ioctlsocket

#define ioctlsocket   ioctl

Definition at line 481 of file ncftp.h.

◆ IsLocalPathDelim

#define IsLocalPathDelim (   c)    (c == LOCAL_PATH_DELIM)

Definition at line 497 of file ncftp.h.

◆ kAcceptForReading

#define kAcceptForReading   00101

Definition at line 301 of file ncftp.h.

◆ kAcceptForWriting

#define kAcceptForWriting   00100

Definition at line 300 of file ncftp.h.

◆ kAppendNo

#define kAppendNo   0

Definition at line 365 of file ncftp.h.

◆ kAppendYes

#define kAppendYes   1

Definition at line 364 of file ncftp.h.

◆ kChdirAndGetCWD

#define kChdirAndGetCWD   00002

Definition at line 419 of file ncftp.h.

◆ kChdirAndMkdir

#define kChdirAndMkdir   00001

Definition at line 418 of file ncftp.h.

◆ kChdirOneSubdirAtATime

#define kChdirOneSubdirAtATime   00004

Definition at line 420 of file ncftp.h.

◆ kChdirOnly

#define kChdirOnly   00000

Definition at line 417 of file ncftp.h.

◆ kCommandAvailabilityUnknown

#define kCommandAvailabilityUnknown   (-1)

Definition at line 379 of file ncftp.h.

◆ kCommandAvailable

#define kCommandAvailable   1

Definition at line 380 of file ncftp.h.

◆ kCommandNotAvailable

#define kCommandNotAvailable   0

Definition at line 381 of file ncftp.h.

◆ kConfirmResumeProcNotUsed

#define kConfirmResumeProcNotUsed   0

Definition at line 423 of file ncftp.h.

◆ kConfirmResumeProcSaidAppend

#define kConfirmResumeProcSaidAppend   4

Definition at line 427 of file ncftp.h.

◆ kConfirmResumeProcSaidBestGuess

#define kConfirmResumeProcSaidBestGuess   5

Definition at line 428 of file ncftp.h.

◆ kConfirmResumeProcSaidCancel

#define kConfirmResumeProcSaidCancel   6

Definition at line 429 of file ncftp.h.

◆ kConfirmResumeProcSaidOverwrite

#define kConfirmResumeProcSaidOverwrite   3

Definition at line 426 of file ncftp.h.

◆ kConfirmResumeProcSaidResume

#define kConfirmResumeProcSaidResume   2

Definition at line 425 of file ncftp.h.

◆ kConfirmResumeProcSaidSkip

#define kConfirmResumeProcSaidSkip   1

Definition at line 424 of file ncftp.h.

◆ kDefaultAbortTimeout

#define kDefaultAbortTimeout   10

Definition at line 323 of file ncftp.h.

◆ kDefaultConnTimeout

#define kDefaultConnTimeout   30

Definition at line 321 of file ncftp.h.

◆ kDefaultCtrlTimeout

#define kDefaultCtrlTimeout   135

Definition at line 322 of file ncftp.h.

◆ kDefaultDataPortMode

#define kDefaultDataPortMode   kSendPortMode

Definition at line 344 of file ncftp.h.

◆ kDefaultFTPBufSize

#define kDefaultFTPBufSize   32768

Definition at line 314 of file ncftp.h.

◆ kDefaultFTPPort

#define kDefaultFTPPort   21

Definition at line 312 of file ncftp.h.

◆ kDefaultMaxDials

#define kDefaultMaxDials   3

Definition at line 341 of file ncftp.h.

◆ kDefaultRedialDelay

#define kDefaultRedialDelay   20 /* seconds */

Definition at line 342 of file ncftp.h.

◆ kDefaultXferTimeout

#define kDefaultXferTimeout   600

Definition at line 320 of file ncftp.h.

◆ kDeleteNo

#define kDeleteNo   0

Definition at line 369 of file ncftp.h.

◆ kDeleteYes

#define kDeleteYes   1

Definition at line 368 of file ncftp.h.

◆ kFallBackToSendPortMode

#define kFallBackToSendPortMode   2

Definition at line 297 of file ncftp.h.

◆ kFirewallFwuAtSiteFwpUserPass

#define kFirewallFwuAtSiteFwpUserPass   6

Definition at line 394 of file ncftp.h.

◆ kFirewallLastType

#define kFirewallLastType   kFirewallUserAtSiteFwuPassFwp

Definition at line 396 of file ncftp.h.

◆ kFirewallLoginThenUserAtSite

#define kFirewallLoginThenUserAtSite   2

Definition at line 390 of file ncftp.h.

◆ kFirewallNotInUse

#define kFirewallNotInUse   0

Definition at line 388 of file ncftp.h.

◆ kFirewallOpenSite

#define kFirewallOpenSite   4

Definition at line 392 of file ncftp.h.

◆ kFirewallSiteSite

#define kFirewallSiteSite   3

Definition at line 391 of file ncftp.h.

◆ kFirewallUserAtSite

#define kFirewallUserAtSite   1

Definition at line 389 of file ncftp.h.

◆ kFirewallUserAtSiteFwuPassFwp

#define kFirewallUserAtSiteFwuPassFwp   7

Definition at line 395 of file ncftp.h.

◆ kFirewallUserAtUserPassAtPass

#define kFirewallUserAtUserPassAtPass   5

Definition at line 393 of file ncftp.h.

◆ kFtwDir

#define kFtwDir   1

Definition at line 414 of file ncftp.h.

◆ kFtwFile

#define kFtwFile   0

Definition at line 413 of file ncftp.h.

◆ kGlobChars

#define kGlobChars   "[*?"

Definition at line 357 of file ncftp.h.

◆ kGlobNo

#define kGlobNo   0

Definition at line 361 of file ncftp.h.

◆ kGlobYes

#define kGlobYes   1

Definition at line 360 of file ncftp.h.

◆ kLibraryMagic

#define kLibraryMagic   "LibNcFTP 3.0.6"

Definition at line 65 of file ncftp.h.

◆ kLibraryVersion

#define kLibraryVersion   "@(#) LibNcFTP 3.0.6 (April 14, 2001)"

Definition at line 11 of file ncftp.h.

◆ kMalformedURL

#define kMalformedURL   (-2)

Definition at line 385 of file ncftp.h.

◆ kMlsOptModify

#define kMlsOptModify   00004

Definition at line 403 of file ncftp.h.

◆ kMlsOptPerm

#define kMlsOptPerm   00100

Definition at line 407 of file ncftp.h.

◆ kMlsOptSize

#define kMlsOptSize   00002

Definition at line 402 of file ncftp.h.

◆ kMlsOptType

#define kMlsOptType   00001

Definition at line 401 of file ncftp.h.

◆ kMlsOptUnique

#define kMlsOptUnique   01000

Definition at line 410 of file ncftp.h.

◆ kMlsOptUNIXgid

#define kMlsOptUNIXgid   00400

Definition at line 409 of file ncftp.h.

◆ kMlsOptUNIXgroup

#define kMlsOptUNIXgroup   00040

Definition at line 406 of file ncftp.h.

◆ kMlsOptUNIXmode

#define kMlsOptUNIXmode   00010

Definition at line 404 of file ncftp.h.

◆ kMlsOptUNIXowner

#define kMlsOptUNIXowner   00020

Definition at line 405 of file ncftp.h.

◆ kMlsOptUNIXuid

#define kMlsOptUNIXuid   00200

Definition at line 408 of file ncftp.h.

◆ kModTimeUnknown

#define kModTimeUnknown   ((time_t) (-1))

Definition at line 377 of file ncftp.h.

◆ kNetReading

#define kNetReading   kAcceptForReading

Definition at line 303 of file ncftp.h.

◆ kNetWriting

#define kNetWriting   kAcceptForWriting

Definition at line 302 of file ncftp.h.

◆ kNotURL

#define kNotURL   (-1)

Definition at line 384 of file ncftp.h.

◆ kPassiveMode

#define kPassiveMode   1

Definition at line 296 of file ncftp.h.

◆ kPreferredMlsOpts

◆ kPrEndMsg

#define kPrEndMsg   3

Definition at line 292 of file ncftp.h.

◆ kPrInitMsg

#define kPrInitMsg   1

Definition at line 290 of file ncftp.h.

◆ kPrUpdateMsg

#define kPrUpdateMsg   2

Definition at line 291 of file ncftp.h.

◆ kRecursiveNo

#define kRecursiveNo   0

Definition at line 363 of file ncftp.h.

◆ kRecursiveYes

#define kRecursiveYes   1

Definition at line 362 of file ncftp.h.

◆ kRedialStatusDialing

#define kRedialStatusDialing   0

Definition at line 346 of file ncftp.h.

◆ kRedialStatusSleeping

#define kRedialStatusSleeping   1

Definition at line 347 of file ncftp.h.

◆ kResponseNoPrint

#define kResponseNoPrint   00001

Definition at line 308 of file ncftp.h.

◆ kResponseNoProc

#define kResponseNoProc   00002

Definition at line 310 of file ncftp.h.

◆ kResponseNoSave

#define kResponseNoSave   00002

Definition at line 309 of file ncftp.h.

◆ kResumeNo

#define kResumeNo   0

Definition at line 367 of file ncftp.h.

◆ kResumeYes

#define kResumeYes   1

Definition at line 366 of file ncftp.h.

◆ kSendPortMode

#define kSendPortMode   0

Definition at line 295 of file ncftp.h.

◆ kServerTypeFTP_Max

#define kServerTypeFTP_Max   9

Definition at line 470 of file ncftp.h.

◆ kServerTypeMicrosoftFTP

#define kServerTypeMicrosoftFTP   4

Definition at line 465 of file ncftp.h.

◆ kServerTypeNcFTPd

#define kServerTypeNcFTPd   2

Definition at line 463 of file ncftp.h.

◆ kServerTypeNetWareFTP

#define kServerTypeNetWareFTP   11

Definition at line 472 of file ncftp.h.

◆ kServerTypeProFTPD

#define kServerTypeProFTPD   3

Definition at line 464 of file ncftp.h.

◆ kServerTypeRoxen

#define kServerTypeRoxen   10

Definition at line 471 of file ncftp.h.

◆ kServerTypeServ_U

#define kServerTypeServ_U   6

Definition at line 467 of file ncftp.h.

◆ kServerTypeUnknown

#define kServerTypeUnknown   0

Definition at line 461 of file ncftp.h.

◆ kServerTypeVFTPD

#define kServerTypeVFTPD   8

Definition at line 469 of file ncftp.h.

◆ kServerTypeWarFTPd

#define kServerTypeWarFTPd   5

Definition at line 466 of file ncftp.h.

◆ kServerTypeWFTPD

#define kServerTypeWFTPD   7

Definition at line 468 of file ncftp.h.

◆ kServerTypeWS_FTP

#define kServerTypeWS_FTP   12

Definition at line 473 of file ncftp.h.

◆ kServerTypeWuFTPd

#define kServerTypeWuFTPd   1

Definition at line 462 of file ncftp.h.

◆ kSizeUnknown

#define kSizeUnknown   ((longest_int) (-1))

Definition at line 376 of file ncftp.h.

◆ kSuggestedAbortTimeout

#define kSuggestedAbortTimeout   10

Definition at line 339 of file ncftp.h.

◆ kSuggestedDefaultConnTimeout

#define kSuggestedDefaultConnTimeout   30

Definition at line 337 of file ncftp.h.

◆ kSuggestedDefaultCtrlTimeout

#define kSuggestedDefaultCtrlTimeout   135 /* 2*MSL, + slop */

Definition at line 338 of file ncftp.h.

◆ kSuggestedDefaultXferTimeout

#define kSuggestedDefaultXferTimeout   (0) /* No timeout on data blocks. */

Definition at line 336 of file ncftp.h.

◆ kTarNo

#define kTarNo   0

Definition at line 371 of file ncftp.h.

◆ kTarYes

#define kTarYes   1

Definition at line 370 of file ncftp.h.

◆ kTypeAscii

#define kTypeAscii   'A'

Definition at line 353 of file ncftp.h.

◆ kTypeBinary

#define kTypeBinary   'I'

Definition at line 354 of file ncftp.h.

◆ kTypeEbcdic

#define kTypeEbcdic   'E'

Definition at line 355 of file ncftp.h.

◆ LIBNCFTP_USE_VAR

#define LIBNCFTP_USE_VAR (   a)    gLibNcFTP_Uses_Me_To_Quiet_Variable_Unused_Warnings = (a == 0)

Definition at line 521 of file ncftp.h.

◆ LOCAL_PATH_DELIM

#define LOCAL_PATH_DELIM   '/'

Definition at line 492 of file ncftp.h.

◆ LOCAL_PATH_DELIM_STR

#define LOCAL_PATH_DELIM_STR   "/"

Definition at line 493 of file ncftp.h.

◆ LocalPathToTVFSPath

#define LocalPathToTVFSPath (   s)

Definition at line 499 of file ncftp.h.

◆ longest_int

#define longest_int   long long

Definition at line 68 of file ncftp.h.

◆ longest_uint

#define longest_uint   unsigned long long

Definition at line 69 of file ncftp.h.

◆ NcSignal

#define NcSignal   signal

Definition at line 604 of file ncftp.h.

◆ NO_SIGNALS

#define NO_SIGNALS   1

Definition at line 49 of file ncftp.h.

◆ NoConfirmResumeDownloadProc

#define NoConfirmResumeDownloadProc   ((ConfirmResumeDownloadProc) 0)

Definition at line 451 of file ncftp.h.

◆ NoConfirmResumeUploadProc

#define NoConfirmResumeUploadProc   ((ConfirmResumeUploadProc) 0)

Definition at line 452 of file ncftp.h.

◆ NoGetPassphraseProc

#define NoGetPassphraseProc   ((FTPGetPassphraseProc) 0)

Definition at line 453 of file ncftp.h.

◆ StrFindLocalPathDelim

#define StrFindLocalPathDelim (   a)    strchr(a, LOCAL_PATH_DELIM)

Definition at line 494 of file ncftp.h.

◆ StrRemoveTrailingLocalPathDelim

#define StrRemoveTrailingLocalPathDelim   StrRemoveTrailingSlashes

Definition at line 496 of file ncftp.h.

◆ StrRFindLocalPathDelim

#define StrRFindLocalPathDelim (   a)    strrchr(a, LOCAL_PATH_DELIM)

Definition at line 495 of file ncftp.h.

◆ TVFSPathToLocalPath

#define TVFSPathToLocalPath (   s)

Definition at line 498 of file ncftp.h.

◆ UNIMPLEMENTED_CMD

#define UNIMPLEMENTED_CMD (   a)    ((a == 500) || (a == 502) || (a == 504))

Definition at line 373 of file ncftp.h.

◆ UNUSED

#define UNUSED (   a)    a

Definition at line 523 of file ncftp.h.

◆ USE_SIO

#define USE_SIO   1

Definition at line 46 of file ncftp.h.

Typedef Documentation

◆ ConfirmResumeDownloadProc

typedef int(* ConfirmResumeDownloadProc) (const char *volatile *localpath, volatile longest_int localsize, volatile time_t localmtime, const char *volatile remotepath, volatile longest_int remotesize, volatile time_t remotetime, volatile longest_int *volatile startPoint)

Definition at line 431 of file ncftp.h.

◆ ConfirmResumeUploadProc

typedef int(* ConfirmResumeUploadProc) (const char *volatile localpath, volatile longest_int localsize, volatile time_t localmtime, const char *volatile *remotepath, volatile longest_int remotesize, volatile time_t remotetime, volatile longest_int *volatile startPoint)

Definition at line 441 of file ncftp.h.

◆ FileInfo

◆ FileInfoList

◆ FileInfoListPtr

◆ FileInfoPtr

Definition at line 250 of file ncftp.h.

◆ FileInfoVec

Definition at line 250 of file ncftp.h.

◆ FTPCIPtr

Definition at line 124 of file ncftp.h.

◆ FTPConnectionInfo

◆ FTPConnectMessageProc

typedef void(* FTPConnectMessageProc) (const FTPCIPtr, ResponsePtr)

Definition at line 127 of file ncftp.h.

◆ FTPFtwProc

typedef int(* FTPFtwProc) (const FTPCIPtr cip, const char *fn, int flag)

Definition at line 131 of file ncftp.h.

◆ FTPGetPassphraseProc

typedef void(* FTPGetPassphraseProc) (const FTPCIPtr, LineListPtr pwPrompt, char *pass, size_t dsize)

Definition at line 132 of file ncftp.h.

◆ FTPLibraryInfo

◆ FTPLIPtr

◆ FTPLoginMessageProc

typedef void(* FTPLoginMessageProc) (const FTPCIPtr, ResponsePtr)

Definition at line 128 of file ncftp.h.

◆ FTPLogProc

typedef void(* FTPLogProc) (const FTPCIPtr, char *)

Definition at line 126 of file ncftp.h.

◆ FTPPrintResponseProc

typedef void(* FTPPrintResponseProc) (const FTPCIPtr, ResponsePtr)

Definition at line 130 of file ncftp.h.

◆ FTPProgressMeterProc

typedef void(* FTPProgressMeterProc) (const FTPCIPtr, int)

Definition at line 125 of file ncftp.h.

◆ FTPRedialStatusProc

typedef void(* FTPRedialStatusProc) (const FTPCIPtr, int, int)

Definition at line 129 of file ncftp.h.

◆ FTPSigProc

typedef void(* FTPSigProc) (int)

Definition at line 76 of file ncftp.h.

◆ Line

typedef struct Line Line

◆ LineList

◆ LineListPtr

◆ LinePtr

typedef struct Line* LinePtr

Definition at line 78 of file ncftp.h.

◆ MLstItem

◆ MLstItemPtr

◆ Response

◆ ResponsePtr

◆ SReadlineInfo

Function Documentation

◆ AddFileInfo()

FileInfoPtr AddFileInfo ( FileInfoListPtr  ,
FileInfoPtr   
)

Definition at line 530 of file linelist.c.

531 {
532  FileInfoPtr lp;
533 
534  lp = (FileInfoPtr) malloc(sizeof(FileInfo));
535  if (lp != NULL) {
536  (void) memcpy(lp, src, sizeof(FileInfo));
537  lp->next = NULL;
538  if (list->first == NULL) {
539  list->first = list->last = lp;
540  lp->prev = NULL;
541  list->nFileInfos = 1;
542  } else {
543  lp->prev = list->last;
544  list->last->next = lp;
545  list->last = lp;
546  list->nFileInfos++;
547  }
548  }
549  return lp;
550 } /* AddFileInfo */
FileInfoPtr prev
Definition: ncftp.h:252
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
struct FileInfo * FileInfoPtr
Definition: ncftp.h:250
smooth NULL
Definition: ftsmooth.c:416
struct list * next
Definition: list.h:38
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: _list.h:228
GLenum src
Definition: glext.h:6340
#define malloc
Definition: debug_ros.c:4
FileInfoPtr next
Definition: ncftp.h:252

Referenced by ConcatFileInfoList(), ConcatFileToFileInfoList(), FTPLocalRecursiveFileList2(), Traverse(), UnLslR(), and UnMlsD().

◆ AddLine()

LinePtr AddLine ( LineListPtr  ,
const char  
)

Definition at line 94 of file linelist.c.

95 {
96  LinePtr lp;
97  char *buf;
98 
99  lp = (LinePtr) malloc(sizeof(Line));
100  if (lp != NULL) {
101  buf = StrDup(buf1);
102  if (buf == NULL) {
103  free(lp);
104  lp = NULL;
105  } else {
106  lp->line = buf;
107  lp->next = NULL;
108  if (list->first == NULL) {
109  list->first = list->last = lp;
110  lp->prev = NULL;
111  list->nLines = 1;
112  } else {
113  lp->prev = list->last;
114  list->last->next = lp;
115  list->last = lp;
116  list->nLines++;
117  }
118  }
119  }
120  return lp;
121 } /* AddLine */
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define free
Definition: debug_ros.c:5
LinePtr next
Definition: ncftp.h:80
struct Line * LinePtr
Definition: ncftp.h:78
smooth NULL
Definition: ftsmooth.c:416
LinePtr prev
Definition: ncftp.h:80
struct list * next
Definition: list.h:38
Definition: ncftp.h:79
Definition: _list.h:228
char * StrDup(const char *buf)
Definition: linelist.c:12
#define malloc
Definition: debug_ros.c:4
char * line
Definition: ncftp.h:81

Referenced by CopyLineList(), FTPDecodeURL(), FTPListToMemory2(), FTPLocalGlob(), FTPRemoteGlob(), GetResponse(), and LazyUnixLocalGlob().

◆ BufferGets()

int BufferGets ( char ,
size_t  ,
int  ,
char ,
char **  ,
char **  ,
size_t   
)

Definition at line 978 of file rcmd.c.

979 {
980  int err;
981  char *src;
982  char *dst;
983  char *dstlim;
984  int len;
985  int nr;
986  int haveEof = 0;
987 
988  err = 0;
989  dst = buf;
990  dstlim = dst + bufsize - 1; /* Leave room for NUL. */
991  src = (*secBufPtr);
992  for ( ; dst < dstlim; ) {
993  if (src >= (*secBufLimit)) {
994  /* Fill the buffer. */
995 
996 /* Don't need to poll it here. The routines that use BufferGets don't
997  * need any special processing during timeouts (i.e. progress reports),
998  * so go ahead and just let it block until there is data to read.
999  */
1000  nr = (int) read(inStream, secondaryBuf, secBufSize);
1001  if (nr == 0) {
1002  /* EOF. */
1003  haveEof = 1;
1004  goto done;
1005  } else if (nr < 0) {
1006  /* Error. */
1007  err = -1;
1008  goto done;
1009  }
1010  (*secBufPtr) = secondaryBuf;
1011  (*secBufLimit) = secondaryBuf + nr;
1012  src = (*secBufPtr);
1013  if (nr < (int) secBufSize)
1014  src[nr] = '\0';
1015  }
1016  if (*src == '\r') {
1017  ++src;
1018  } else {
1019  if (*src == '\n') {
1020  /* *dst++ = *src++; */ ++src;
1021  goto done;
1022  }
1023  *dst++ = *src++;
1024  }
1025  }
1026 
1027 done:
1028  (*secBufPtr) = src;
1029  *dst = '\0';
1030  len = (int) (dst - buf);
1031  if (err < 0)
1032  return (err);
1033  if ((len == 0) && (haveEof == 1))
1034  return (-1);
1035  return (len); /* May be zero, if a blank line. */
1036 } /* BufferGets */
ULONG nr
Definition: thread.c:7
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLuint GLsizei bufsize
Definition: glext.h:7473
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
#define err(...)
GLenum GLenum dst
Definition: glext.h:6340
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by FTPList(), and FTPListToMemory2().

◆ ComputeLNames()

int ComputeLNames ( FileInfoListPtr  ,
const char ,
const char ,
int   
)

Definition at line 663 of file linelist.c.

664 {
665  FileInfoPtr lp, lp2;
666  char *buf;
667  char *cp;
668 
669  if (srcdir != NULL) {
670  cp = strrchr(srcdir, '/');
671  if (cp == NULL)
672  cp = strrchr(srcdir, '\\');
673  if (cp != NULL)
674  srcdir = cp + 1;
675  }
676  if (dstdir == NULL)
677  dstdir = ".";
678 
679  for (lp = dst->first; lp != NULL; lp = lp2) {
680  lp2 = lp->next;
681 
682  buf = NULL;
683  if (nochop != 0) {
684  if ((dstdir[0] != '\0') && (strcmp(dstdir, "."))) {
685  if (Dynscat(&buf, dstdir, "/", 0) == NULL)
686  goto memerr;
687  }
688  if (lp->lname != NULL) {
689  if (Dynscat(&buf, lp->lname, "/", 0) == NULL)
690  goto memerr;
691  } else if (srcdir != NULL) {
692  if (Dynscat(&buf, srcdir, "/", 0) == NULL)
693  goto memerr;
694  }
695  if (Dynscat(&buf, lp->relname, 0) == NULL)
696  goto memerr;
697  } else {
698  if ((dstdir[0] != '\0') && (strcmp(dstdir, "."))) {
699  cp = strrchr(lp->relname, '/');
700  if (cp == NULL)
701  cp = strrchr(lp->relname, '\\');
702  if (cp == NULL) {
703  cp = lp->relname;
704  } else {
705  cp++;
706  }
707  if (Dynscat(&buf, dstdir, "/", cp, 0) == NULL)
708  goto memerr;
709  } else {
710  cp = strrchr(lp->relname, '/');
711  if (cp == NULL)
712  cp = strrchr(lp->relname, '\\');
713  if (cp == NULL) {
714  cp = lp->relname;
715  } else {
716  cp++;
717  }
718  if (Dynscat(&buf, cp, 0) == NULL)
719  goto memerr;
720  }
721  }
722  if (buf == NULL) {
723 memerr:
724  return (-1);
725  }
726  if (lp->lname != NULL) {
727  free(lp->lname);
728  lp->lname = NULL;
729  }
730  lp->lname = buf;
732  }
733  return (0);
734 } /* ComputeLNames */
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define free
Definition: debug_ros.c:5
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
char * lname
Definition: ncftp.h:256
smooth NULL
Definition: ftsmooth.c:416
char * relname
Definition: ncftp.h:253
char * Dynscat(char **dst,...)
Definition: Dynscat.c:9
GLenum GLenum dst
Definition: glext.h:6340
POINT cp
Definition: magnifier.c:61
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define TVFSPathToLocalPath(s)
Definition: ncftp.h:498
FileInfoPtr next
Definition: ncftp.h:252

Referenced by FTPGetFiles3(), and FTPPutFiles3().

◆ ComputeRNames()

int ComputeRNames ( FileInfoListPtr  ,
const char ,
int  ,
int   
)

Definition at line 579 of file linelist.c.

580 {
581  FileInfoPtr lp, lp2;
582  char *buf;
583  char *cp;
584 
585  if (dstdir == NULL)
586  dstdir = ".";
587 
588  for (lp = dst->first; lp != NULL; lp = lp2) {
589  lp2 = lp->next;
590 
591  buf = NULL;
592  if (nochop != 0) {
593  if ((dstdir[0] != '\0') && (strcmp(dstdir, "."))) {
594  if (Dynscat(&buf, dstdir, "/", lp->relname, 0) == NULL)
595  goto memerr;
596 
597  if (pflag != 0) {
598  /* Init lname to parent dir name of remote dir */
599  cp = strrchr(dstdir, '/');
600  if (cp == NULL)
601  cp = strrchr(dstdir, '\\');
602  if (cp != NULL) {
603  if (Dynscat(&lp->lname, cp + 1, 0) == NULL)
604  goto memerr;
606  }
607  }
608  } else {
609  if (Dynscat(&buf, lp->relname, 0) == NULL)
610  goto memerr;
611  }
612  } else {
613  if ((dstdir[0] != '\0') && (strcmp(dstdir, "."))) {
614  cp = strrchr(lp->relname, '/');
615  if (cp == NULL)
616  cp = strrchr(lp->relname, '\\');
617  if (cp != NULL) {
618  cp++;
619  } else {
620  cp = lp->relname;
621  }
622  if (Dynscat(&buf, dstdir, "/", cp, 0) == NULL)
623  goto memerr;
624 
625  if (pflag != 0) {
626  /* Init lname to parent dir name of remote dir */
627  cp = strrchr(dstdir, '/');
628  if (cp == NULL)
629  cp = strrchr(dstdir, '\\');
630  if (cp != NULL) {
631  if (Dynscat(&lp->lname, cp + 1, 0) == NULL)
632  goto memerr;
634  }
635  }
636  } else {
637  cp = strrchr(lp->relname, '/');
638  if (cp == NULL)
639  cp = strrchr(lp->relname, '\\');
640  if (cp != NULL) {
641  cp++;
642  } else {
643  cp = lp->relname;
644  }
645  if (Dynscat(&buf, cp, 0) == NULL)
646  goto memerr;
647  }
648  }
649  lp->rname = buf;
650  if (lp->rname == NULL) {
651 memerr:
652  return (-1);
653  }
655  }
656  return (0);
657 } /* ComputeRNames */
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define LocalPathToTVFSPath(s)
Definition: ncftp.h:499
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
char * lname
Definition: ncftp.h:256
char * rname
Definition: ncftp.h:254
smooth NULL
Definition: ftsmooth.c:416
char * relname
Definition: ncftp.h:253
char * Dynscat(char **dst,...)
Definition: Dynscat.c:9
GLenum GLenum dst
Definition: glext.h:6340
POINT cp
Definition: magnifier.c:61
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define TVFSPathToLocalPath(s)
Definition: ncftp.h:498
FileInfoPtr next
Definition: ncftp.h:252

Referenced by FTPGetFiles3(), FTPPutFiles3(), FTPRemoteRecursiveFileList(), and FTPRemoteRecursiveFileList1().

◆ ConcatFileInfoList()

int ConcatFileInfoList ( FileInfoListPtr  ,
FileInfoListPtr   
)

Definition at line 556 of file linelist.c.

557 {
558  FileInfoPtr lp, lp2;
559  FileInfo newfi;
560 
561  for (lp = src->first; lp != NULL; lp = lp2) {
562  lp2 = lp->next;
563  newfi = *lp;
564  newfi.relname = StrDup(lp->relname);
565  newfi.lname = StrDup(lp->lname);
566  newfi.rname = StrDup(lp->rname);
567  newfi.rlinkto = StrDup(lp->rlinkto);
568  newfi.plug = StrDup(lp->plug);
569  if (AddFileInfo(dst, &newfi) == NULL)
570  return (-1);
571  }
572  return (0);
573 } /* ConcatFileInfoList */
char * lname
Definition: ncftp.h:256
char * rname
Definition: ncftp.h:254
char * plug
Definition: ncftp.h:257
smooth NULL
Definition: ftsmooth.c:416
FileInfoPtr AddFileInfo(FileInfoListPtr list, FileInfoPtr src)
Definition: linelist.c:530
char * rlinkto
Definition: ncftp.h:255
char * relname
Definition: ncftp.h:253
GLenum src
Definition: glext.h:6340
char * StrDup(const char *buf)
Definition: linelist.c:12
GLenum GLenum dst
Definition: glext.h:6340
FileInfoPtr next
Definition: ncftp.h:252

Referenced by FTPRemoteRecursiveFileList(), and FTPRemoteRecursiveFileList1().

◆ ConcatFileToFileInfoList()

int ConcatFileToFileInfoList ( FileInfoListPtr  ,
char  
)

Definition at line 740 of file linelist.c.

741 {
742  FileInfo newfi;
743 
744  InitFileInfo(&newfi); /* Use defaults. */
745  newfi.relname = StrDup(rfile);
746  newfi.rname = NULL;
747  newfi.lname = NULL;
748 
749  if (AddFileInfo(dst, &newfi) == NULL)
750  return (-1);
751  return (0);
752 } /* ConcatFileToFileInfoList */
void InitFileInfo(FileInfoPtr fip)
Definition: linelist.c:471
char * lname
Definition: ncftp.h:256
char * rname
Definition: ncftp.h:254
smooth NULL
Definition: ftsmooth.c:416
FileInfoPtr AddFileInfo(FileInfoListPtr list, FileInfoPtr src)
Definition: linelist.c:530
char * relname
Definition: ncftp.h:253
char * StrDup(const char *buf)
Definition: linelist.c:12
GLenum GLenum dst
Definition: glext.h:6340

Referenced by FTPRemoteRecursiveFileList(), FTPRemoteRecursiveFileList1(), LineListToFileInfoList(), and LineToFileInfoList().

◆ CopyLineList()

int CopyLineList ( LineListPtr  ,
LineListPtr   
)

Definition at line 127 of file linelist.c.

128 {
129  LinePtr lp, lp2;
130 
131  InitLineList(dst);
132  for (lp = src->first; lp != NULL; ) {
133  lp2 = lp;
134  lp = lp->next;
135  if (lp2->line != NULL) {
136  if (AddLine(dst, lp2->line) == NULL) {
138  return (-1);
139  }
140  }
141  }
142  return (0);
143 } /* CopyLineList */
LinePtr next
Definition: ncftp.h:80
smooth NULL
Definition: ftsmooth.c:416
LinePtr AddLine(LineListPtr list, const char *buf1)
Definition: linelist.c:94
Definition: ncftp.h:79
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
void InitLineList(LineListPtr list)
Definition: linelist.c:54
void DisposeLineListContents(LineListPtr list)
Definition: linelist.c:33
char * line
Definition: ncftp.h:81

Referenced by FTPRemoteHelp().

◆ DisposeFileInfoListContents()

void DisposeFileInfoListContents ( FileInfoListPtr  )

Definition at line 152 of file linelist.c.

153 {
154  FileInfoPtr lp, lp2;
155 
156  for (lp = list->first; lp != NULL; ) {
157  lp2 = lp;
158  lp = lp->next;
159  if (lp2->relname != NULL) {
160  lp2->relname[0] = '\0';
161  free(lp2->relname);
162  }
163  if (lp2->lname != NULL) {
164  lp2->lname[0] = '\0';
165  free(lp2->lname);
166  }
167  if (lp2->rname != NULL) {
168  lp2->rname[0] = '\0';
169  free(lp2->rname);
170  }
171  if (lp2->rlinkto != NULL) {
172  lp2->rlinkto[0] = '\0';
173  free(lp2->rlinkto);
174  }
175  if (lp2->plug != NULL) {
176  lp2->plug[0] = '\0';
177  free(lp2->plug);
178  }
179  free(lp2);
180  }
181 
182  if (list->vec != NULL)
183  free(list->vec);
184 
185  /* Same as InitFileInfoList. */
186  (void) memset(list, 0, sizeof(FileInfoList));
187 } /* DisposeFileInfoListContents */
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define free
Definition: debug_ros.c:5
char * lname
Definition: ncftp.h:256
char * rname
Definition: ncftp.h:254
char * plug
Definition: ncftp.h:257
smooth NULL
Definition: ftsmooth.c:416
char * rlinkto
Definition: ncftp.h:255
char * relname
Definition: ncftp.h:253
Definition: _list.h:228
#define memset(x, y, z)
Definition: compat.h:39
FileInfoPtr next
Definition: ncftp.h:252

Referenced by FlushLsCacheItem(), FTPGetFiles3(), FTPPutFiles3(), FTPRemoteRecursiveFileList(), and FTPRemoteRecursiveFileList1().

◆ DisposeLineListContents()

void DisposeLineListContents ( LineListPtr  )

Definition at line 33 of file linelist.c.

34 {
35  LinePtr lp, lp2;
36 
37  for (lp = list->first; lp != NULL; ) {
38  lp2 = lp;
39  lp = lp->next;
40  if (lp2->line != NULL) {
41  lp2->line[0] = '\0';
42  free(lp2->line);
43  }
44  free(lp2);
45  }
46  /* Same as InitLineList. */
47  (void) memset(list, 0, sizeof(LineList));
48 } /* DisposeLineListContents */
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define free
Definition: debug_ros.c:5
LinePtr next
Definition: ncftp.h:80
smooth NULL
Definition: ftsmooth.c:416
Definition: ncftp.h:79
Definition: ncftp.h:84
Definition: _list.h:228
#define memset(x, y, z)
Definition: compat.h:39
char * line
Definition: ncftp.h:81

Referenced by ChdirCmd(), CopyLineList(), DoneWithResponse(), EchoCmd(), FTPChmod(), FTPDeallocateHost(), FTPDelete(), FTPFileExistsNlst(), FTPFileExistsStat(), FTPFtwL2(), FTPGetFiles3(), FTPPutFiles3(), FTPRemoteRecursiveFileList(), FTPRemoteRecursiveFileList1(), FTPRmdir(), FTPRmdirRecursiveL2(), LocalRmCmd(), LocalRmdirCmd(), Ls(), OpenCmd(), ReInitResponse(), RGlobCmd(), RmtHelpCmd(), SaveLastResponse(), SpoolGetCmd(), and SpoolPutCmd().

◆ DoneWithResponse()

void DoneWithResponse ( const  FTPCIPtr,
ResponsePtr   
)

Definition at line 114 of file rcmd.c.

115 {
116  /* Dispose space taken up by the Response, and clear it out
117  * again. For some reason, I like to return memory to zeroed
118  * when not in use.
119  */
120  if (rp != NULL) {
121  TraceResponse(cip, rp);
122  if (cip->printResponseProc != 0) {
123  if ((rp->printMode & kResponseNoProc) == 0)
124  (*cip->printResponseProc)(cip, rp);
125  }
126  if ((rp->printMode & kResponseNoSave) == 0)
127  SaveLastResponse(cip, rp);
128  else
129  DisposeLineListContents(&rp->msg);
130  (void) memset(rp, 0, sizeof(Response));
131  free(rp);
132  }
133 } /* DoneWithResponse */
#define kResponseNoProc
Definition: ncftp.h:310
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define kResponseNoSave
Definition: ncftp.h:309
#define free
Definition: debug_ros.c:5
static void SaveLastResponse(const FTPCIPtr cip, ResponsePtr rp)
Definition: rcmd.c:89
smooth NULL
Definition: ftsmooth.c:416
void TraceResponse(const FTPCIPtr cip, ResponsePtr rp)
Definition: rcmd.c:55
Definition: ncftp.h:89
void DisposeLineListContents(LineListPtr list)
Definition: linelist.c:33
#define memset(x, y, z)
Definition: compat.h:39

Referenced by FTPAbortDataTransfer(), FTPChdirAndGetCWD(), FTPCloseHost(), FTPCmd(), FTPEndDataCmd(), FTPFileExistsStat(), FTPFileModificationTime(), FTPFileSize(), FTPGetCWD(), FTPLoginHost(), FTPMListOneFile(), FTPQueryFeatures(), FTPRemoteHelp(), FTPStartDataCmd(), FTPUtime(), nFTPChdirAndGetCWD(), OpenControlConnection(), Passive(), SendPort(), and SetStartOffset().

◆ FGets()

char* FGets ( char ,
size_t  ,
FILE  
)

Definition at line 111 of file util.c.

112 {
113  char *cp, *nlptr;
114 
115  cp = fgets(str, ((int) size) - 1, fp);
116  if (cp != NULL) {
117  cp[((int) size) - 1] = '\0'; /* ensure terminator */
118  nlptr = cp + strlen(cp) - 1;
119  if (*nlptr == '\n')
120  *nlptr = '\0';
121  } else {
122  memset(str, 0, size);
123  }
124  return cp;
125 } /* FGets */
static int
Definition: util.c:37
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
POINT cp
Definition: magnifier.c:61
#define memset(x, y, z)
Definition: compat.h:39

Referenced by GetBookmark(), GetNextBookmark(), LazyUnixLocalGlob(), OpenBookmarkFile(), PromptForBookmarkName(), PutBookmark(), and RunBookmarkEditor().

◆ FilenameExtensionIndicatesASCII()

int FilenameExtensionIndicatesASCII ( const char *const  pathName,
const char *const  extnList 
)

Definition at line 963 of file util.c.

964 {
965  const char *extn;
966  char *cp;
967  int c;
968  char extnPattern[16];
969 
970  extn = pathName + strlen(pathName) - 1;
971  forever {
972  if (extn <= pathName)
973  return (0); /* End of pathname, no extension. */
974  c = (int) *--extn;
975  if (IsLocalPathDelim(c))
976  return (0); /* End of filename, no extension. */
977  if (c == '.') {
978  extn += 1;
979  break;
980  }
981  }
982  if (strlen(extn) > (sizeof(extnPattern) - 2 - 1 - 1)) {
983  return (0);
984  }
985 #ifdef HAVE_SNPRINTF
986  snprintf(extnPattern, sizeof(extnPattern),
987 #else
988  sprintf(extnPattern,
989 #endif
990  "|.%s|",
991  extn
992  );
993 
994  cp = extnPattern;
995  forever {
996  c = *cp;
997  if (c == '\0')
998  break;
999  if (isupper(c)) {
1000  c = tolower(c);
1001  *cp++ = (char) c;
1002  } else {
1003  cp++;
1004  }
1005  }
1006 
1007  /* Extension list is specially formatted, like this:
1008  *
1009  * |ext1|ext2|ext3|...|extN|
1010  *
1011  * I.e, each filename extension is delimited with
1012  * a pipe, and we always begin and end the string
1013  * with a pipe.
1014  */
1015  if (strstr(extnList, extnPattern) != NULL) {
1016  return (1);
1017  }
1018  return (0);
1019 } /* FilenameExtensionIndicatesASCII */
static int
Definition: util.c:37
#define IsLocalPathDelim(c)
Definition: ncftp.h:497
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
#define snprintf
Definition: wintirpc.h:48
#define sprintf(buf, format,...)
Definition: sprintf.c:55
smooth NULL
Definition: ftsmooth.c:416
unsigned char
Definition: typeof.h:29
#define isupper(c)
Definition: acclib.h:71
const GLubyte * c
Definition: glext.h:8905
#define forever
Definition: ncftp.h:73
POINT cp
Definition: magnifier.c:61
#define c
Definition: ke_i.h:80
int tolower(int c)
Definition: utclib.c:902

Referenced by AutomaticallyUseASCIIModeDependingOnExtension().

◆ FTPAbortDataTransfer()

void FTPAbortDataTransfer ( const FTPCIPtr  cip)

Definition at line 870 of file rcmd.c.

871 {
872  ResponsePtr rp;
873  int result;
874 
875  if (cip->dataSocket != kClosedFileDescriptor) {
876  PrintF(cip, "Starting abort sequence.\n");
877  SendTelnetInterrupt(cip); /* Probably could get by w/o doing this. */
878 
879  result = FTPCmdNoResponse(cip, "ABOR");
880  if (result != kNoErr) {
881  /* Linger could cause close to block, so unset it. */
882  (void) SetLinger(cip, cip->dataSocket, 0);
883  CloseDataConnection(cip);
884  PrintF(cip, "Could not send abort command.\n");
885  return;
886  }
887 
888  if (cip->abortTimeout > 0) {
889  result = WaitResponse(cip, (unsigned int) cip->abortTimeout);
890  if (result <= 0) {
891  /* Error or no response received to ABOR in time. */
892  (void) SetLinger(cip, cip->dataSocket, 0);
893  CloseDataConnection(cip);
894  PrintF(cip, "No response received to abort request.\n");
895  return;
896  }
897  }
898 
899  rp = InitResponse();
900  if (rp == NULL) {
901  Error(cip, kDontPerror, "Malloc failed.\n");
902  cip->errNo = kErrMallocFailed;
903  result = cip->errNo;
904  return;
905  }
906 
907  result = GetResponse(cip, rp);
908  if (result < 0) {
909  /* Shouldn't happen, and doesn't matter if it does. */
910  (void) SetLinger(cip, cip->dataSocket, 0);
911  CloseDataConnection(cip);
912  PrintF(cip, "Invalid response to abort request.\n");
913  DoneWithResponse(cip, rp);
914  return;
915  }
916  DoneWithResponse(cip, rp);
917 
918  /* A response to the abort request has been received.
919  * Now the only thing left to do is close the data
920  * connection, making sure to turn off linger mode
921  * since we don't care about straggling data bits.
922  */
923  (void) SetLinger(cip, cip->dataSocket, 0);
924  CloseDataConnection(cip); /* Must close (by protocol). */
925  PrintF(cip, "End abort.\n");
926  }
927 } /* FTPAbortDataTransfer */
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
void CloseDataConnection(const FTPCIPtr cip)
Definition: ftp.c:831
int GetResponse(const FTPCIPtr cip, ResponsePtr rp)
Definition: rcmd.c:287
int FTPCmdNoResponse(const FTPCIPtr cip, const char *const cmdspec,...)
Definition: rcmd.c:656
void SendTelnetInterrupt(const FTPCIPtr cip)
Definition: ftp.c:1328
#define kErrMallocFailed
Definition: ncftp_errno.h:40
void DoneWithResponse(const FTPCIPtr cip, ResponsePtr rp)
Definition: rcmd.c:114
smooth NULL
Definition: ftsmooth.c:416
BOOL Error
Definition: chkdsk.c:66
Definition: ncftp.h:89
#define kClosedFileDescriptor
Definition: util.h:47
#define kDontPerror
Definition: util.h:45
void PrintF(const FTPCIPtr cip, const char *const fmt,...)
Definition: util.c:340
ResponsePtr InitResponse(void)
Definition: rcmd.c:38
int SetLinger(const FTPCIPtr cip, int sockfd, int onoff)
Definition: ftp.c:262
#define kNoErr
Definition: ncftp_errno.h:9
unsigned int abortTimeout
Definition: ncftp.h:144
int WaitResponse(const FTPCIPtr cip, unsigned int sec)
Definition: rcmd.c:684
GLuint64EXT * result
Definition: glext.h:11304

Referenced by FTPCloseHost(), FTPGetOneF(), and FTPPutOneF().

◆ FTPChdir()

int FTPChdir ( const FTPCIPtr  cip,
const char *const  cdCwd 
)

Definition at line 11 of file cmds.c.

12 {
13  int result;
14 
15  if (cip == NULL)
16  return (kErrBadParameter);
17  if (strcmp(cip->magic, kLibraryMagic))
18  return (kErrBadMagic);
19 
20  if (cdCwd == NULL) {
23  } else {
24  if (cdCwd[0] == '\0') /* But allow FTPChdir(cip, ".") to go through. */
25  result = 2;
26  else if (strcmp(cdCwd, "..") == 0)
27  result = FTPCmd(cip, "CDUP");
28  else
29  result = FTPCmd(cip, "CWD %s", cdCwd);
30  if (result >= 0) {
31  if (result == 2) {
32  result = kNoErr;
33  } else {
35  cip->errNo = kErrCWDFailed;
36  }
37  }
38  }
39  return (result);
40 } /* FTPChdir */
#define kErrInvalidDirParam
Definition: ncftp_errno.h:39
#define kErrBadParameter
Definition: ncftp_errno.h:56
char magic[16]
Definition: ncftp.h:135
int FTPCmd(const FTPCIPtr cip, const char *const cmdspec,...)
Definition: rcmd.c:603
smooth NULL
Definition: ftsmooth.c:416
#define kErrBadMagic
Definition: ncftp_errno.h:55
#define kLibraryMagic
Definition: ncftp.h:65
#define kNoErr
Definition: ncftp_errno.h:9
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
GLuint64EXT * result
Definition: glext.h:11304
#define kErrCWDFailed
Definition: ncftp_errno.h:42

Referenced by FTPChdir3(), FTPFileExistsNlst(), FTPFileExistsStat(), FTPFileType(), FTPFtw(), FTPFtwL2(), FTPMkdir2(), FTPRemoteRecursiveFileList(), FTPRemoteRecursiveFileList1(), FTPRmdirRecursive(), FTPRmdirRecursiveL2(), OpenCmd(), and OpenURL().

◆ FTPChdir3()

int FTPChdir3 ( FTPCIPtr  cip,
const char *const  cdCwd,
char *const  newCwd,
const size_t  newCwdSize,
int  flags 
)

Definition at line 376 of file cmds.c.

377 {
378  char *cp, *startcp;
379  int result;
380  int lastSubDir;
381  int mkd, pwd;
382 
383  if (cip == NULL)
384  return (kErrBadParameter);
385  if (strcmp(cip->magic, kLibraryMagic))
386  return (kErrBadMagic);
387 
388  if (cdCwd == NULL) {
390  cip->errNo = kErrInvalidDirParam;
391  return result;
392  }
393 
394  if (flags == kChdirOnly)
395  return (FTPChdir(cip, cdCwd));
396  if (flags == kChdirAndGetCWD) {
397  return (FTPChdirAndGetCWD(cip, cdCwd, newCwd, newCwdSize));
398  } else if (flags == kChdirAndMkdir) {
399  result = FTPMkdir(cip, cdCwd, kRecursiveYes);
400  if (result == kNoErr)
401  result = FTPChdir(cip, cdCwd);
402  return result;
403  } else if (flags == (kChdirAndMkdir|kChdirAndGetCWD)) {
404  result = FTPMkdir(cip, cdCwd, kRecursiveYes);
405  if (result == kNoErr)
406  result = FTPChdirAndGetCWD(cip, cdCwd, newCwd, newCwdSize);
407  return result;
408  }
409 
410  /* else: (flags | kChdirOneSubdirAtATime) == true */
411 
412  cp = cip->buf;
413  cp[cip->bufSize - 1] = '\0';
414  (void) Strncpy(cip->buf, cdCwd, cip->bufSize);
415  if (cp[cip->bufSize - 1] != '\0')
416  return (kErrBadParameter);
417 
418  mkd = (flags & kChdirAndMkdir);
419  pwd = (flags & kChdirAndGetCWD);
420 
421  if ((cdCwd[0] == '\0') || (strcmp(cdCwd, ".") == 0)) {
422  result = 0;
423  if (flags == kChdirAndGetCWD)
424  result = FTPGetCWD(cip, newCwd, newCwdSize);
425  return (result);
426  }
427 
428  lastSubDir = 0;
429  do {
430  startcp = cp;
432  if (cp != NULL) {
433  /* If this is the first slash in an absolute
434  * path, then startcp will be empty. We will
435  * use this below to treat this as the root
436  * directory.
437  */
438  *cp++ = '\0';
439  } else {
440  lastSubDir = 1;
441  }
442  if (strcmp(startcp, ".") == 0) {
443  result = 0;
444  if ((lastSubDir != 0) && (pwd != 0))
445  result = FTPGetCWD(cip, newCwd, newCwdSize);
446  } else if ((lastSubDir != 0) && (pwd != 0)) {
447  result = FTPChdirAndGetCWD(cip, (*startcp != '\0') ? startcp : "/", newCwd, newCwdSize);
448  } else {
449  result = FTPChdir(cip, (*startcp != '\0') ? startcp : "/");
450  }
451  if (result < 0) {
452  if ((mkd != 0) && (*startcp != '\0')) {
453  if (FTPCmd(cip, "MKD %s", startcp) == 2) {
454  result = FTPChdir(cip, startcp);
455  } else {
456  /* couldn't change nor create */
457  cip->errNo = result;
458  }
459  } else {
460  cip->errNo = result;
461  }
462  }
463  } while ((!lastSubDir) && (result == 0));
464 
465  return (result);
466 } /* FTPChdir3 */
#define kErrInvalidDirParam
Definition: ncftp_errno.h:39
#define kErrBadParameter
Definition: ncftp_errno.h:56
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
char * buf
Definition: ncftp.h:186
int FTPMkdir(const FTPCIPtr cip, const char *const newDir, const int recurse)
Definition: cmds.c:641
char magic[16]
Definition: ncftp.h:135
int FTPCmd(const FTPCIPtr cip, const char *const cmdspec,...)
Definition: rcmd.c:603
void pwd(int argc, const char *argv[])
Definition: cmds.c:1401
smooth NULL
Definition: ftsmooth.c:416
#define kRecursiveYes
Definition: ncftp.h:362
#define kChdirOnly
Definition: ncftp.h:417
#define kChdirAndGetCWD
Definition: ncftp.h:419
#define kErrBadMagic
Definition: ncftp_errno.h:55
GLbitfield flags
Definition: glext.h:7161
int FTPChdir(const FTPCIPtr cip, const char *const cdCwd)
Definition: cmds.c:11
int FTPChdirAndGetCWD(const FTPCIPtr cip, const char *const cdCwd, char *const newCwd, const size_t newCwdSize)
Definition: cmds.c:313
#define kChdirAndMkdir
Definition: ncftp.h:418
char * Strncpy(char *const, const char *const, const size_t)
Definition: Strncpy.c:11
int FTPGetCWD(const FTPCIPtr cip, char *const newCwd, const size_t newCwdSize)
Definition: cmds.c:254
size_t bufSize
Definition: ncftp.h:187
POINT cp
Definition: magnifier.c:61
#define kLibraryMagic
Definition: ncftp.h:65
#define kNoErr
Definition: ncftp_errno.h:9
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
GLuint64EXT * result
Definition: glext.h:11304
#define StrFindLocalPathDelim(a)
Definition: ncftp.h:494

◆ FTPChdirAndGetCWD()

int FTPChdirAndGetCWD ( const FTPCIPtr  cip,
const char *const  cdCwd,
char *const  newCwd,
const size_t  newCwdSize 
)

Definition at line 313 of file cmds.c.

314 {
315  ResponsePtr rp;
316  char *l, *r;
317  int result;
318 
319  if (cip == NULL)
320  return (kErrBadParameter);
321  if (strcmp(cip->magic, kLibraryMagic))
322  return (kErrBadMagic);
323 
324  if ((newCwd == NULL) || (cdCwd == NULL)) {
326  cip->errNo = kErrInvalidDirParam;
327  } else {
328  if (cdCwd[0] == '\0') { /* But allow FTPChdir(cip, ".") to go through. */
329  result = FTPGetCWD(cip, newCwd, newCwdSize);
330  return (result);
331  }
332  rp = InitResponse();
333  if (rp == NULL) {
335  cip->errNo = kErrMallocFailed;
336  Error(cip, kDontPerror, "Malloc failed.\n");
337  } else {
338  if (strcmp(cdCwd, "..") == 0)
339  result = RCmd(cip, rp, "CDUP");
340  else
341  result = RCmd(cip, rp, "CWD %s", cdCwd);
342  if (result == 2) {
343  l = strchr(rp->msg.first->line, '"');
344  if ((l == rp->msg.first->line) && ((r = strrchr(rp->msg.first->line, '"')) != NULL) && (l != r)) {
345  /* "xxxx" is current directory.
346  * Strip out just the xxxx to copy into the remote cwd.
347  *
348  * This is nice because we didn't have to do a PWD.
349  */
350  *r = '\0';
351  ++l;
352  (void) Strncpy(newCwd, l, newCwdSize);
353  *r = '"'; /* Restore, so response prints correctly. */
354  DoneWithResponse(cip, rp);
355  result = kNoErr;
356  } else {
357  DoneWithResponse(cip, rp);
358  result = FTPGetCWD(cip, newCwd, newCwdSize);
359  }
360  } else if (result > 0) {
362  cip->errNo = kErrCWDFailed;
363  DoneWithResponse(cip, rp);
364  } else {
365  DoneWithResponse(cip, rp);
366  }
367  }
368  }
369  return (result);
370 } /* FTPChdirAndGetCWD */
#define kErrInvalidDirParam
Definition: ncftp_errno.h:39
#define kErrBadParameter
Definition: ncftp_errno.h:56
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
int RCmd(const FTPCIPtr, ResponsePtr, const char *,...)
Definition: rcmd.c:718
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
void DoneWithResponse(const FTPCIPtr, ResponsePtr)
Definition: rcmd.c:114
#define kErrMallocFailed
Definition: ncftp_errno.h:40
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
char magic[16]
Definition: ncftp.h:135
smooth NULL
Definition: ftsmooth.c:416
r l[0]
Definition: byte_order.h:167
#define kErrBadMagic
Definition: ncftp_errno.h:55
BOOL Error
Definition: chkdsk.c:66
Definition: ncftp.h:89
#define kDontPerror
Definition: util.h:45
LinePtr first
Definition: ncftp.h:85
LineList msg
Definition: ncftp.h:90
char * Strncpy(char *const, const char *const, const size_t)
Definition: Strncpy.c:11
int FTPGetCWD(const FTPCIPtr cip, char *const newCwd, const size_t newCwdSize)
Definition: cmds.c:254
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define kLibraryMagic
Definition: ncftp.h:65
#define kNoErr
Definition: ncftp_errno.h:9
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ResponsePtr InitResponse(void)
Definition: rcmd.c:38
GLuint64EXT * result
Definition: glext.h:11304
char * line
Definition: ncftp.h:81
#define kErrCWDFailed
Definition: ncftp_errno.h:42

Referenced by FTPChdir3().

◆ FTPChmod()

int FTPChmod ( const FTPCIPtr  cip,
const char *const  pattern,
const char *const  mode,
const int  doGlob 
)

Definition at line 46 of file cmds.c.

47 {
48  LineList fileList;
49  LinePtr filePtr;
50  char *file;
51  int onceResult, batchResult;
52 
53  if (cip == NULL)
54  return (kErrBadParameter);
55  if (strcmp(cip->magic, kLibraryMagic))
56  return (kErrBadMagic);
57 
58  batchResult = FTPRemoteGlob(cip, &fileList, pattern, doGlob);
59  if (batchResult != kNoErr)
60  return (batchResult);
61 
62  for (batchResult = kNoErr, filePtr = fileList.first;
63  filePtr != NULL;
64  filePtr = filePtr->next)
65  {
66  file = filePtr->line;
67  if (file == NULL) {
68  batchResult = kErrBadLineList;
69  cip->errNo = kErrBadLineList;
70  break;
71  }
72  onceResult = FTPCmd(cip, "SITE CHMOD %s %s", mode, file);
73  if (onceResult < 0) {
74  batchResult = onceResult;
75  break;
76  }
77  if (onceResult != 2) {
78  batchResult = kErrChmodFailed;
79  cip->errNo = kErrChmodFailed;
80  }
81  }
82  DisposeLineListContents(&fileList);
83  return (batchResult);
84 } /* FTPChmod */
#define kErrBadParameter
Definition: ncftp_errno.h:56
LinePtr next
Definition: ncftp.h:80
char magic[16]
Definition: ncftp.h:135
int FTPCmd(const FTPCIPtr cip, const char *const cmdspec,...)
Definition: rcmd.c:603
smooth NULL
Definition: ftsmooth.c:416
#define kErrBadMagic
Definition: ncftp_errno.h:55
const char file[]
Definition: icontest.c:11
#define kErrChmodFailed
Definition: ncftp_errno.h:59
Definition: ncftp.h:79
Definition: ncftp.h:84
LinePtr first
Definition: ncftp.h:85
GLenum mode
Definition: glext.h:6217
int FTPRemoteGlob(FTPCIPtr cip, LineListPtr fileList, const char *pattern, int doGlob)
Definition: glob.c:1335
#define kErrBadLineList
Definition: ncftp_errno.h:44
#define kLibraryMagic
Definition: ncftp.h:65
#define kNoErr
Definition: ncftp_errno.h:9
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
void DisposeLineListContents(LineListPtr list)
Definition: linelist.c:33
char * line
Definition: ncftp.h:81
GLubyte * pattern
Definition: glext.h:7787
Definition: fci.c:126

Referenced by ChmodCmd().

◆ FTPCloseHost()

int FTPCloseHost ( const FTPCIPtr  cip)

Definition at line 523 of file open.c.

524 {
525  ResponsePtr rp;
526  int result;
527 
528  if (cip == NULL)
529  return (kErrBadParameter);
530  if (strcmp(cip->magic, kLibraryMagic))
531  return (kErrBadMagic);
532 
533  /* Data connection shouldn't be open normally. */
534  if (cip->dataSocket != kClosedFileDescriptor)
536 
537  result = kNoErr;
538  if (cip->connected != 0) {
539  rp = InitResponse();
540  if (rp == NULL) {
541  cip->errNo = kErrMallocFailed;
542  result = cip->errNo;
543  } else {
544  rp->eofOkay = 1; /* We are expecting EOF after this cmd. */
545  cip->eofOkay = 1;
546  (void) RCmd(cip, rp, "QUIT");
547  DoneWithResponse(cip, rp);
548  }
549  }
550 
552 
553  /* Dispose dynamic data structures, so you won't leak
554  * if you OpenHost with this again.
555  */
556  FTPDeallocateHost(cip);
557  return (result);
558 } /* FTPCloseHost */
void FTPAbortDataTransfer(const FTPCIPtr cip)
Definition: rcmd.c:870
#define kErrBadParameter
Definition: ncftp_errno.h:56
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
int RCmd(const FTPCIPtr, ResponsePtr, const char *,...)
Definition: rcmd.c:718
void CloseControlConnection(const FTPCIPtr cip)
Definition: ftp.c:197
void DoneWithResponse(const FTPCIPtr, ResponsePtr)
Definition: rcmd.c:114
#define kErrMallocFailed
Definition: ncftp_errno.h:40
char magic[16]
Definition: ncftp.h:135
smooth NULL
Definition: ftsmooth.c:416
#define kErrBadMagic
Definition: ncftp_errno.h:55
Definition: ncftp.h:89
#define kClosedFileDescriptor
Definition: util.h:47
static void FTPDeallocateHost(const FTPCIPtr cip)
Definition: open.c:11
#define kLibraryMagic
Definition: ncftp.h:65
#define kNoErr
Definition: ncftp_errno.h:9
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ResponsePtr InitResponse(void)
Definition: rcmd.c:38
GLuint64EXT * result
Definition: glext.h:11304
int eofOkay
Definition: ncftp.h:94

Referenced by CloseHost(), and FTPOpenHost().

◆ FTPCmd()

int FTPCmd ( const FTPCIPtr  cip,
const char *const  cmdspec,
  ... 
)

Definition at line 603 of file rcmd.c.

604 {
605  va_list ap;
606  int result;
607  ResponsePtr rp;
608 
609  if (cip == NULL)
610  return (kErrBadParameter);
611  if (strcmp(cip->magic, kLibraryMagic))
612  return (kErrBadMagic);
613 
614  rp = InitResponse();
615  if (rp == NULL) {
617  cip->errNo = kErrMallocFailed;
618  Error(cip, kDontPerror, "Malloc failed.\n");
619  return (cip->errNo);
620  }
621 
622  va_start(ap, cmdspec);
623 #ifndef NO_SIGNALS
624  if (cip->ctrlTimeout > 0)
625  (void) alarm(cip->ctrlTimeout);
626 #endif /* NO_SIGNALS */
627  result = SendCommand(cip, cmdspec, ap);
628  va_end(ap);
629  if (result < 0) {
630 #ifndef NO_SIGNALS
631  if (cip->ctrlTimeout > 0)
632  (void) alarm(0);
633 #endif /* NO_SIGNALS */
634  return (result);
635  }
636 
637  /* Get the response to the command we sent. */
638  result = GetResponse(cip, rp);
639 #ifndef NO_SIGNALS
640  if (cip->ctrlTimeout > 0)
641  (void) alarm(0);
642 #endif /* NO_SIGNALS */
643 
644  if (result == kNoErr)
645  result = rp->codeType;
646  DoneWithResponse(cip, rp);
647  return (result);
648 } /* FTPCmd */
unsigned int ctrlTimeout
Definition: ncftp.h:143
#define kErrBadParameter
Definition: ncftp_errno.h:56
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
int GetResponse(const FTPCIPtr cip, ResponsePtr rp)
Definition: rcmd.c:287
#define kErrMallocFailed
Definition: ncftp_errno.h:40
void DoneWithResponse(const FTPCIPtr cip, ResponsePtr rp)
Definition: rcmd.c:114
char magic[16]
Definition: ncftp.h:135
#define va_end(ap)
Definition: acmsvcex.h:90
smooth NULL
Definition: ftsmooth.c:416
char * va_list
Definition: acmsvcex.h:78
#define kErrBadMagic
Definition: ncftp_errno.h:55
BOOL Error
Definition: chkdsk.c:66
int codeType
Definition: ncftp.h:91
Definition: ncftp.h:89
#define kDontPerror
Definition: util.h:45
ResponsePtr InitResponse(void)
Definition: rcmd.c:38
#define va_start(ap, A)
Definition: acmsvcex.h:91
static int SendCommand(const FTPCIPtr cip, const char *cmdspec, va_list ap)
Definition: rcmd.c:496
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
#define kLibraryMagic
Definition: ncftp.h:65
#define kNoErr
Definition: ncftp_errno.h:9
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
GLuint64EXT * result
Definition: glext.h:11304

Referenced by DoOpen(), FTPChdir(), FTPChdir3(), FTPChmod(), FTPDelete(), FTPGetOneF(), FTPMkdir2(), FTPPutOneF(), FTPRename(), FTPRequestMlsOptions(), FTPRmdir(), FTPSetTransferType(), FTPSymlink(), FTPUmask(), QuoteCmd(), and SiteCmd().

◆ FTPCmdNoResponse()

int FTPCmdNoResponse ( const  FTPCIPtr,
const char *const  cmdspec,
  ... 
)

Definition at line 656 of file rcmd.c.

657 {
658  va_list ap;
659 
660  if (cip == NULL)
661  return (kErrBadParameter);
662  if (strcmp(cip->magic, kLibraryMagic))
663  return (kErrBadMagic);
664 
665  va_start(ap, cmdspec);
666 #ifndef NO_SIGNALS
667  if (cip->ctrlTimeout > 0)
668  (void) alarm(cip->ctrlTimeout);
669 #endif /* NO_SIGNALS */
670  (void) SendCommand(cip, cmdspec, ap);
671 #ifndef NO_SIGNALS
672  if (cip->ctrlTimeout > 0)
673  (void) alarm(0);
674 #endif /* NO_SIGNALS */
675  va_end(ap);
676 
677  return (kNoErr);
678 } /* FTPCmdNoResponse */
#define kErrBadParameter
Definition: ncftp_errno.h:56
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define va_end(ap)
Definition: acmsvcex.h:90
smooth NULL
Definition: ftsmooth.c:416
char * va_list
Definition: acmsvcex.h:78
#define kErrBadMagic
Definition: ncftp_errno.h:55
#define va_start(ap, A)
Definition: acmsvcex.h:91
static int SendCommand(const FTPCIPtr cip, const char *cmdspec, va_list ap)
Definition: rcmd.c:496
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
#define kLibraryMagic
Definition: ncftp.h:65
#define kNoErr
Definition: ncftp_errno.h:9
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by FTPAbortDataTransfer().

◆ FTPDecodeURL()

int FTPDecodeURL ( const FTPCIPtr  cip,
char *const  url,
LineListPtr  cdlist,
char *const  fn,
const size_t  fnsize,
int *const  xtype,
int *const  wantnlst 
)

Definition at line 639 of file open.c.

648 {
649  char *cp;
650  char *hstart, *hend;
651  char *h2start;
652  char *at1;
653  char portstr[32];
654  int port;
655  int sc;
656  char *lastslash;
657  char *parsestr;
658  char *tok;
659  char subdir[128];
660  char *semi;
661 
662  InitLineList(cdlist);
663  *fn = '\0';
664  if (wantnlst != NULL)
665  *wantnlst = 0;
666  if (xtype != NULL)
667  *xtype = kTypeBinary;
668 
669  cp = NULL; /* shut up warnings */
670 #ifdef HAVE_STRCASECMP
671  if (strncasecmp(url, "<URL:ftp://", 11) == 0) {
672  cp = url + strlen(url) - 1;
673  if (*cp != '>')
674  return (kMalformedURL); /* missing closing > */
675  *cp = '\0';
676  cp = url + 11;
677  } else if (strncasecmp(url, "ftp://", 6) == 0) {
678  cp = url + 6;
679  } else {
680  return (-1); /* not a RFC 1738 URL */
681  }
682 #else /* HAVE_STRCASECMP */
683  if (strncmp(url, "<URL:ftp://", 11) == 0) {
684  cp = url + strlen(url) - 1;
685  if (*cp != '>')
686  return (kMalformedURL); /* missing closing > */
687  *cp = '\0';
688  cp = url + 11;
689  } else if (strncmp(url, "ftp://", 6) == 0) {
690  cp = url + 6;
691  } else {
692  return (-1); /* not a RFC 1738 URL */
693  }
694 #endif /* HAVE_STRCASECMP */
695 
696  /* //<user>:<password>@<host>:<port>/<url-path> */
697 
698  at1 = NULL;
699  for (hstart = cp; ; cp++) {
700  if (*cp == '@') {
701  if (at1 == NULL)
702  at1 = cp;
703  else
704  return (kMalformedURL);
705  } else if ((*cp == '\0') || (*cp == '/')) {
706  hend = cp;
707  break;
708  }
709  }
710 
711  sc = *hend;
712  *hend = '\0';
713  if (at1 == NULL) {
714  /* no user or password */
715  h2start = hstart;
716  } else {
717  *at1 = '\0';
718  cp = strchr(hstart, ':');
719  if (cp == NULL) {
720  /* whole thing is the user name then */
721  URLCopyToken(cip->user, sizeof(cip->user), hstart, (size_t) (at1 - hstart));
722  } else if (strchr(cp + 1, ':') != NULL) {
723  /* Too many colons */
724  return (kMalformedURL);
725  } else {
726  URLCopyToken(cip->user, sizeof(cip->user), hstart, (size_t) (cp - hstart));
727  URLCopyToken(cip->pass, sizeof(cip->pass), cp + 1, (size_t) (at1 - (cp + 1)));
728  }
729  *at1 = '@';
730  h2start = at1 + 1;
731  }
732 
733  cp = strchr(h2start, ':');
734  if (cp == NULL) {
735  /* whole thing is the host then */
736  URLCopyToken(cip->host, sizeof(cip->host), h2start, (size_t) (hend - h2start));
737  } else if (strchr(cp + 1, ':') != NULL) {
738  /* Too many colons */
739  return (kMalformedURL);
740  } else {
741  URLCopyToken(cip->host, sizeof(cip->host), h2start, (size_t) (cp - h2start));
742  URLCopyToken(portstr, sizeof(portstr), cp + 1, (size_t) (hend - (cp + 1)));
743  port = atoi(portstr);
744  if (port > 0)
745  cip->port = port;
746  }
747 
748  *hend = (char) sc;
749  if ((*hend == '\0') || ((*hend == '/') && (hend[1] == '\0'))) {
750  /* no path, okay */
751  return (0);
752  }
753 
754  lastslash = strrchr(hend, '/');
755  if (lastslash == NULL) {
756  /* no path, okay */
757  return (0);
758  }
759  *lastslash = '\0';
760 
761  if ((semi = strchr(lastslash + 1, ';')) != NULL) {
762  *semi++ = '\0';
763 #ifdef HAVE_STRCASECMP
764  if (strcasecmp(semi, "type=i") == 0) {
765  if (xtype != NULL)
766  *xtype = kTypeBinary;
767  } else if (strcasecmp(semi, "type=a") == 0) {
768  if (xtype != NULL)
769  *xtype = kTypeAscii;
770  } else if (strcasecmp(semi, "type=b") == 0) {
771  if (xtype != NULL)
772  *xtype = kTypeBinary;
773  } else if (strcasecmp(semi, "type=d") == 0) {
774  if (wantnlst != NULL) {
775  *wantnlst = 1;
776  if (xtype != NULL)
777  *xtype = kTypeAscii;
778  } else {
779  /* You didn't want these. */
780  return (kMalformedURL);
781  }
782  }
783 #else /* HAVE_STRCASECMP */
784  if (strcmp(semi, "type=i") == 0) {
785  if (xtype != NULL)
786  *xtype = kTypeBinary;
787  } else if (strcmp(semi, "type=a") == 0) {
788  if (xtype != NULL)
789  *xtype = kTypeAscii;
790  } else if (strcmp(semi, "type=b") == 0) {
791  if (xtype != NULL)
792  *xtype = kTypeBinary;
793  } else if (strcmp(semi, "type=d") == 0) {
794  if (wantnlst != NULL) {
795  *wantnlst = 1;
796  if (xtype != NULL)
797  *xtype = kTypeAscii;
798  } else {
799  /* You didn't want these. */
800  return (kMalformedURL);
801  }
802  }
803 #endif /* HAVE_STRCASECMP */
804  }
805  URLCopyToken(fn, fnsize, lastslash + 1, strlen(lastslash + 1));
806  for (parsestr = hend; (tok = strtok(parsestr, "/")) != NULL; parsestr = NULL) {
807  URLCopyToken(subdir, sizeof(subdir), tok, strlen(tok));
808  (void) AddLine(cdlist, subdir);
809  }
810  *lastslash = '/';
811  return (kNoErr);
812 } /* FTPDecodeURL */
unsigned int port
Definition: ncftp.h:140
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define strcasecmp
Definition: fake.h:9
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
char pass[64]
Definition: ncftp.h:138
char user[64]
Definition: ncftp.h:137
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
char host[64]
Definition: ncftp.h:136
#define kMalformedURL
Definition: ncftp.h:385
#define strncasecmp
Definition: fake.h:10
smooth NULL
Definition: ftsmooth.c:416
unsigned char
Definition: typeof.h:29
static const WCHAR url[]
Definition: encode.c:1432
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
LinePtr AddLine(LineListPtr list, const char *buf1)
Definition: linelist.c:94
#define kTypeBinary
Definition: ncftp.h:354
#define kTypeAscii
Definition: ncftp.h:353
void InitLineList(LineListPtr list)
Definition: linelist.c:54
char * strtok(char *String, const char *Delimiters)
Definition: utclib.c:338
char * strchr(const char *String, int ch)
Definition: utclib.c:501
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
POINT cp
Definition: magnifier.c:61
void URLCopyToken(char *dst, size_t dsize, const char *src, size_t howmuch)
Definition: open.c:598
#define kNoErr
Definition: ncftp_errno.h:9
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
USHORT port
Definition: uri.c:227

Referenced by DecodeDirectoryURL().

◆ FTPDelete()

int FTPDelete ( const FTPCIPtr  cip,
const char *const  pattern,
const int  recurse,
const int  doGlob 
)

Definition at line 195 of file cmds.c.

196 {
197  LineList fileList;
198  LinePtr filePtr;
199  char *file;
200  int onceResult, batchResult;
201 
202  if (cip == NULL)
203  return (kErrBadParameter);
204  if (strcmp(cip->magic, kLibraryMagic))
205  return (kErrBadMagic);
206 
207  batchResult = FTPRemoteGlob(cip, &fileList, pattern, doGlob);
208  if (batchResult != kNoErr)
209  return (batchResult);
210 
211  for (batchResult = kNoErr, filePtr = fileList.first;
212  filePtr != NULL;
213  filePtr = filePtr->next)
214  {
215  file = filePtr->line;
216  if (file == NULL) {
217  batchResult = kErrBadLineList;
218  cip->errNo = kErrBadLineList;
219  break;
220  }
221  onceResult = FTPCmd(cip, "DELE %s", file);
222  if (onceResult < 0) {
223  batchResult = onceResult;
224  break;
225  }
226  if (onceResult != 2) {
227  if (recurse != kRecursiveYes) {
228  batchResult = kErrDELEFailed;
229  cip->errNo = kErrDELEFailed;
230  } else {
231  onceResult = FTPCmd(cip, "RMD %s", file);
232  if (onceResult < 0) {
233  batchResult = onceResult;
234  break;
235  }
236  if (onceResult != 2) {
237  onceResult = FTPRmdirRecursive(cip, file);
238  if (onceResult < 0) {
239  batchResult = kErrRMDFailed;
240  cip->errNo = kErrRMDFailed;
241  }
242  }
243  }
244  }
245  }
246  DisposeLineListContents(&fileList);
247  return (batchResult);
248 } /* FTPDelete */
#define kErrRMDFailed
Definition: ncftp_errno.h:43
#define kErrBadParameter
Definition: ncftp_errno.h:56
LinePtr next
Definition: ncftp.h:80
char magic[16]
Definition: ncftp.h:135
int FTPCmd(const FTPCIPtr cip, const char *const cmdspec,...)
Definition: rcmd.c:603
static int FTPRmdirRecursive(const FTPCIPtr cip, const char *const dir)
Definition: cmds.c:158
smooth NULL
Definition: ftsmooth.c:416
#define kRecursiveYes
Definition: ncftp.h:362
#define kErrBadMagic
Definition: ncftp_errno.h:55
const char file[]
Definition: icontest.c:11
Definition: ncftp.h:79
Definition: ncftp.h:84
LinePtr first
Definition: ncftp.h:85
int FTPRemoteGlob(FTPCIPtr cip, LineListPtr fileList, const char *pattern, int doGlob)
Definition: glob.c:1335
#define kErrBadLineList
Definition: ncftp_errno.h:44
#define kLibraryMagic
Definition: ncftp.h:65
#define kNoErr
Definition: ncftp_errno.h:9
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define kErrDELEFailed
Definition: ncftp_errno.h:61
void DisposeLineListContents(LineListPtr list)
Definition: linelist.c:33
char * line
Definition: ncftp.h:81
GLubyte * pattern
Definition: glext.h:7787
Definition: fci.c:126

Referenced by DeleteCmd(), FTPGetOneF(), FTPPutOneF(), and FTPRmdirRecursiveL2().

◆ FTPEndDataCmd()

int FTPEndDataCmd ( const  FTPCIPtr,
int   
)

Definition at line 933 of file rcmd.c.

934 {
935  int result;
936  int respCode;
937  ResponsePtr rp;
938 
939  if (cip == NULL)
940  return (kErrBadParameter);
941  if (strcmp(cip->magic, kLibraryMagic))
942  return (kErrBadMagic);
943 
944  CloseDataConnection(cip);
945  result = kNoErr;
946  if (didXfer) {
947  /* Get the response to the data transferred. Most likely a message
948  * saying that the transfer completed succesfully. However, if
949  * we tried to abort the transfer using ABOR, we will have a response
950  * to that command instead.
951  */
952  rp = InitResponse();
953  if (rp == NULL) {
954  Error(cip, kDontPerror, "Malloc failed.\n");
955  cip->errNo = kErrMallocFailed;
956  result = cip->errNo;
957  return (result);
958  }
959  result = GetResponse(cip, rp);
960  if (result < 0)
961  return (result);
962  respCode = rp->codeType;
963  DoneWithResponse(cip, rp);
964  if (respCode != 2) {
965  cip->errNo = kErrDataTransferFailed;
966  result = cip->errNo;
967  } else {
968  result = kNoErr;
969  }
970  }
971  return (result);
972 } /* FTPEndDataCmd */
#define kErrBadParameter
Definition: ncftp_errno.h:56
void CloseDataConnection(const FTPCIPtr cip)
Definition: ftp.c:831
int GetResponse(const FTPCIPtr cip, ResponsePtr rp)
Definition: rcmd.c:287
#define kErrDataTransferFailed
Definition: ncftp_errno.h:78
#define kErrMallocFailed
Definition: ncftp_errno.h:40
void DoneWithResponse(const FTPCIPtr cip, ResponsePtr rp)
Definition: rcmd.c:114
smooth NULL
Definition: ftsmooth.c:416
#define kErrBadMagic
Definition: ncftp_errno.h:55
BOOL Error
Definition: chkdsk.c:66
int codeType
Definition: ncftp.h:91
Definition: ncftp.h:89
#define kDontPerror
Definition: util.h:45
ResponsePtr InitResponse(void)
Definition: rcmd.c:38
#define kLibraryMagic
Definition: ncftp.h:65
#define kNoErr
Definition: ncftp_errno.h:9
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
GLuint64EXT * result
Definition: glext.h:11304

Referenced by FTPGetOneF(), FTPList(), FTPListToMemory2(), FTPPutOneF(), and FTPStartDataCmd().

◆ FTPFileExists()

int FTPFileExists ( const FTPCIPtr  cip,
const char *const  file 
)

Definition at line 1423 of file cmds.c.

1424 {
1425  return (FTPFileExists2(cip, file, 1, 1, 1, 1, 1));
1426 } /* FTPFileExists */
int FTPFileExists2(const FTPCIPtr cip, const char *const file, const int tryMDTM, const int trySIZE, const int tryMLST, const int trySTAT, const int tryNLST)
Definition: cmds.c:1350
Definition: fci.c:126

◆ FTPFileExists2()

int FTPFileExists2 ( const FTPCIPtr  cip,
const char *const  file,
const int  tryMDTM,
const int  trySIZE,
const int  tryMLST,
const int  trySTAT,
const int  tryNLST 
)

Definition at line 1350 of file cmds.c.

1351 {
1352  int result;
1353  time_t mdtm;
1354  longest_int size;
1355  MLstItem mlsInfo;
1356 
1357  if (tryMDTM != 0) {
1358  result = FTPFileModificationTime(cip, file, &mdtm);
1359  if (result == kNoErr)
1360  return (kNoErr);
1361  if (result == kErrMDTMFailed) {
1363  return (kErrNoSuchFileOrDirectory);
1364  }
1365  /* else keep going */
1366  }
1367 
1368  if (trySIZE != 0) {
1369  result = FTPFileSize(cip, file, &size, kTypeBinary);
1370  if (result == kNoErr)
1371  return (kNoErr);
1372  /* SIZE could fail if the server does
1373  * not support it for directories.
1374  *
1375  * if (result == kErrSIZEFailed)
1376  * return (kErrNoSuchFileOrDirectory);
1377  */
1378  /* else keep going */
1379  }
1380 
1381 
1382  if (tryMLST != 0) {
1383  result = FTPMListOneFile(cip, file, &mlsInfo);
1384  if (result == kNoErr)
1385  return (kNoErr);
1386  if (result == kErrMLSTFailed) {
1388  return (kErrNoSuchFileOrDirectory);
1389  }
1390  /* else keep going */
1391  }
1392 
1393  if (trySTAT != 0) {
1394  result = FTPFileExistsStat(cip, file);
1395  if (result == kNoErr)
1396  return (kNoErr);
1397  if (result == kErrSTATFailed) {
1399  return (kErrNoSuchFileOrDirectory);
1400  }
1401  /* else keep going */
1402  }
1403 
1404  if (tryNLST != 0) {
1405  result = FTPFileExistsNlst(cip, file);
1406  if (result == kNoErr)
1407  return (kNoErr);
1408  if (result == kErrNLSTFailed) {
1410  return (kErrNoSuchFileOrDirectory);
1411  }
1412  /* else keep going */
1413  }
1414 
1416  return (kErrCantTellIfFileExists);
1417 } /* FTPFileExists2 */
#define kErrNoSuchFileOrDirectory
Definition: ncftp_errno.h:105
int FTPFileModificationTime(const FTPCIPtr cip, const char *const file, time_t *const mdtm)
Definition: cmds.c:649
#define kErrNLSTFailed
Definition: ncftp_errno.h:103
int FTPFileExistsNlst(const FTPCIPtr cip, const char *const file)
Definition: cmds.c:1209
int FTPFileExistsStat(const FTPCIPtr cip, const char *const file)
Definition: cmds.c:1008
#define kErrCantTellIfFileExists
Definition: ncftp_errno.h:106
#define kErrMLSTFailed
Definition: ncftp_errno.h:97
GLsizeiptr size
Definition: glext.h:5919
#define longest_int
Definition: ncftp.h:68
#define kTypeBinary
Definition: ncftp.h:354
#define kErrMDTMFailed
Definition: ncftp_errno.h:63
__kernel_time_t time_t
Definition: linux.h:252
int FTPFileSize(const FTPCIPtr cip, const char *const file, longest_int *const size, const int type)
Definition: cmds.c:887
#define kErrSTATFailed
Definition: ncftp_errno.h:101
#define kNoErr
Definition: ncftp_errno.h:9
GLuint64EXT * result
Definition: glext.h:11304
int FTPMListOneFile(const FTPCIPtr cip, const char *const file, const MLstItemPtr mlip)
Definition: cmds.c:947
Definition: fci.c:126

Referenced by FTPFileExists(), FTPFileType(), and FTPPutOneF().

◆ FTPFileExistsNlst()

int FTPFileExistsNlst ( const FTPCIPtr  cip,
const char *const  file 
)

Definition at line 1209 of file cmds.c.

1210 {
1211  int result;
1212  LineList fileList, rootFileList;
1213  char savedCwd[512];
1214 
1215  if (cip == NULL)
1216  return (kErrBadParameter);
1217  if (strcmp(cip->magic, kLibraryMagic))
1218  return (kErrBadMagic);
1219 
1220  if (file == NULL)
1221  return (kErrBadParameter);
1222 
1225  return (result);
1226  }
1227 
1229  /* First, make sure that when we NLST a pathname
1230  * that does not exist, that we get an error back.
1231  *
1232  * We also assume that a valid NLST response has
1233  * at least 3 lines of response text, typically
1234  * a "start" line, intermediate data, and then
1235  * a trailing line.
1236  *
1237  * We also can see a one-line case.
1238  */
1239  if (
1240  ((FTPListToMemory2(cip, "NoSuchFile", &fileList, "", 0, (int *) 0)) == kNoErr) &&
1241  (fileList.nLines >= 1) &&
1242  (strstr(fileList.last->line, "o such file") == NULL) &&
1243  (strstr(fileList.last->line, "ot found") == NULL) &&
1244  (strstr(fileList.last->line, "o Such File") == NULL) &&
1245  (strstr(fileList.last->line, "ot Found") == NULL)
1246 
1247  ) {
1250  DisposeLineListContents(&fileList);
1251  return (result);
1252  }
1253  DisposeLineListContents(&fileList);
1254 
1255  /* We can't assume that we can simply say NLST rootdir/firstfile,
1256  * since the remote host may not be using / as a directory
1257  * delimiter. So we have to change to the root directory
1258  * and then do the NLST on that file.
1259  */
1260  if (
1261  (FTPGetCWD(cip, savedCwd, sizeof(savedCwd)) != kNoErr) ||
1262  (FTPChdir(cip, cip->startingWorkingDirectory) != kNoErr)
1263  ) {
1264  return (cip->errNo);
1265  }
1266 
1267  /* OK, we get an error when we list
1268  * a non-existant file, but now we need to
1269  * see if we get a positive reply when
1270  * we stat a file that does exist.
1271  *
1272  * To do this, we list the root directory,
1273  * which we assume has one or more items.
1274  * If it doesn't, the user can't do anything
1275  * anyway. Then we do the first item
1276  * we found to see if NLST says it exists.
1277  */
1278  if (
1279  ((result = FTPListToMemory2(cip, "", &rootFileList, "", 0, (int *) 0)) < 0) ||
1280  (rootFileList.last == NULL) ||
1281  (rootFileList.last->line == NULL)
1282  ) {
1283  /* Hmmm... well, in any case we can't use NLST. */
1286  DisposeLineListContents(&rootFileList);
1287  (void) FTPChdir(cip, savedCwd);
1288  return (result);
1289  }
1290 
1291  if (
1292  ((FTPListToMemory2(cip, rootFileList.last->line, &fileList, "", 0, (int *) 0)) == kNoErr) &&
1293  (fileList.nLines >= 1) &&
1294  (strstr(fileList.last->line, "o such file") == NULL) &&
1295  (strstr(fileList.last->line, "ot found") == NULL) &&
1296  (strstr(fileList.last->line, "o Such File") == NULL) &&
1297  (strstr(fileList.last->line, "ot Found") == NULL)
1298 
1299  ) {
1300  /* Good. We listed the item. */
1301  DisposeLineListContents(&fileList);
1302  DisposeLineListContents(&rootFileList);
1304 
1305  /* Don't forget to change back to the original directory. */
1306  (void) FTPChdir(cip, savedCwd);
1307  } else {
1310  DisposeLineListContents(&fileList);
1311  DisposeLineListContents(&rootFileList);
1312  (void) FTPChdir(cip, savedCwd);
1313  return (result);
1314  }
1315  }
1316 
1317  /* Check the requested item. */
1318  InitLineList(&fileList);
1319  if (
1320  ((FTPListToMemory2(cip, file, &fileList, "", 0, (int *) 0)) == kNoErr) &&
1321  (fileList.nLines >= 1) &&
1322  (strstr(fileList.last->line, "o such file") == NULL) &&
1323  (strstr(fileList.last->line, "ot found") == NULL) &&
1324  (strstr(fileList.last->line, "o Such File") == NULL) &&
1325  (strstr(fileList.last->line, "ot Found") == NULL)
1326 
1327  ) {
1328  /* The item existed. */
1329  result = kNoErr;
1330  } else {
1331  cip->errNo = kErrNLSTFailed;
1333  }
1334 
1335  DisposeLineListContents(&fileList);
1336  return (result);
1337 } /* FTPFileExistsNlst*/
LinePtr last
Definition: ncftp.h:85
#define kErrBadParameter
Definition: ncftp_errno.h:56
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define kCommandAvailable
Definition: ncftp.h:380
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
#define kCommandAvailabilityUnknown
Definition: ncftp.h:379
int NLSTfileParamWorks
Definition: ncftp.h:180
char magic[16]
Definition: ncftp.h:135
#define kErrNLSTFailed
Definition: ncftp_errno.h:103
#define kErrNLSTwithFileNotAvailable
Definition: ncftp_errno.h:104
smooth NULL
Definition: ftsmooth.c:416
char * startingWorkingDirectory
Definition: ncftp.h:158
int nLines
Definition: ncftp.h:86
#define kErrBadMagic
Definition: ncftp_errno.h:55
Definition: ncftp.h:84
int FTPListToMemory2(const FTPCIPtr cip, const char *const pattern, const LineListPtr llines, const char *const lsflags, const int blankLines, int *const tryMLSD)
Definition: io.c:366
#define kCommandNotAvailable
Definition: ncftp.h:381
int FTPChdir(const FTPCIPtr cip, const char *const cdCwd)
Definition: cmds.c:11
void InitLineList(LineListPtr list)
Definition: linelist.c:54
int FTPGetCWD(const FTPCIPtr cip, char *const newCwd, const size_t newCwdSize)
Definition: cmds.c:254
#define kLibraryMagic
Definition: ncftp.h:65
#define kNoErr
Definition: ncftp_errno.h:9
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
void DisposeLineListContents(LineListPtr list)
Definition: linelist.c:33
GLuint64EXT * result
Definition: glext.h:11304
char * line
Definition: ncftp.h:81
Definition: fci.c:126

Referenced by FTPFileExists2().

◆ FTPFileExistsStat()

int FTPFileExistsStat ( const FTPCIPtr  cip,
const char *const  file 
)

Definition at line 1008 of file cmds.c.

1009 {
1010  int result;
1011  ResponsePtr rp;
1012  LineList fileList;
1013  char savedCwd[512];
1014 
1015  if (cip == NULL)
1016  return (kErrBadParameter);
1017  if (strcmp(cip->magic, kLibraryMagic))
1018  return (kErrBadMagic);
1019 
1020  if (file == NULL)
1021  return (kErrBadParameter);
1022 
1025  return (result);
1026  }
1027 
1029  rp = InitResponse();
1030  if (rp == NULL) {
1032  cip->errNo = kErrMallocFailed;
1033  Error(cip, kDontPerror, "Malloc failed.\n");
1034  return (result);
1035 
1036  }
1037 
1038  /* First, make sure that when we STAT a pathname
1039  * that does not exist, that we get an error back.
1040  *
1041  * We also assume that a valid STAT response has
1042  * at least 3 lines of response text, typically
1043  * a "start" line, intermediate data, and then
1044  * a trailing line.
1045  *
1046  * We also can see a one-line case.
1047  */
1048  result = RCmd(cip, rp, "STAT %s", "NoSuchFile");
1049  if ((result == 2) && ((rp->msg.nLines >= 3) || (rp->msg.nLines == 1))) {
1050  /* Hmmm.... it gave back a positive
1051  * response. So STAT <file> does not
1052  * work correctly.
1053  */
1054  if (
1055  (rp->msg.first->next != NULL) &&
1056  (rp->msg.first->next->line != NULL) &&
1057  (
1058  (strstr(rp->msg.first->next->line, "o such file") != NULL) ||
1059  (strstr(rp->msg.first->next->line, "ot found") != NULL)
1060  )
1061  ) {
1062  /* OK, while we didn't want a 200
1063  * level response, some servers,
1064  * like wu-ftpd print an error
1065  * message "No such file or
1066  * directory" which we can special
1067  * case.
1068  */
1069  result = kNoErr;
1070  } else {
1073  DoneWithResponse(cip, rp);
1074  return (result);
1075  }
1076  }
1077  DoneWithResponse(cip, rp);
1078 
1079  /* We can't assume that we can simply say STAT rootdir/firstfile,
1080  * since the remote host may not be using / as a directory
1081  * delimiter. So we have to change to the root directory
1082  * and then do the STAT on that file.
1083  */
1084  if (
1085  (FTPGetCWD(cip, savedCwd, sizeof(savedCwd)) != kNoErr) ||
1086  (FTPChdir(cip, cip->startingWorkingDirectory) != kNoErr)
1087  ) {
1088  return (cip->errNo);
1089  }
1090 
1091  /* OK, we get an error when we stat
1092  * a non-existant file, but now we need to
1093  * see if we get a positive reply when
1094  * we stat a file that does exist.
1095  *
1096  * To do this, we list the root directory,
1097  * which we assume has one or more items.
1098  * If it doesn't, the user can't do anything
1099  * anyway. Then we stat the first item
1100  * we found to see if STAT says it exists.
1101  */
1102  if (
1103  ((result = FTPListToMemory2(cip, "", &fileList, "", 0, (int *) 0)) < 0) ||
1104  (fileList.last == NULL) ||
1105  (fileList.last->line == NULL)
1106  ) {
1107  /* Hmmm... well, in any case we can't use STAT. */
1110  DisposeLineListContents(&fileList);
1111  (void) FTPChdir(cip, savedCwd);
1112  return (result);
1113  }
1114 
1115  rp = InitResponse();
1116  if (rp == NULL) {
1118  cip->errNo = kErrMallocFailed;
1119  Error(cip, kDontPerror, "Malloc failed.\n");
1120  DisposeLineListContents(&fileList);
1121  (void) FTPChdir(cip, savedCwd);
1122  return (result);
1123 
1124  }
1125 
1126  result = RCmd(cip, rp, "STAT %s", fileList.last->line);
1127  DisposeLineListContents(&fileList);
1128 
1129  if ((result != 2) || (rp->msg.nLines == 2)) {
1130  /* Hmmm.... it gave back a negative
1131  * response. So STAT <file> does not
1132  * work correctly.
1133  */
1136  DoneWithResponse(cip, rp);
1137  (void) FTPChdir(cip, savedCwd);
1138  return (result);
1139  } else if (
1140  (rp->msg.first->next != NULL) &&
1141  (rp->msg.first->next->line != NULL) &&
1142  (
1143  (strstr(rp->msg.first->next->line, "o such file") != NULL) ||
1144  (strstr(rp->msg.first->next->line, "ot found") != NULL)
1145  )
1146  ) {
1147  /* Same special-case of the second line of STAT response. */
1150  DoneWithResponse(cip, rp);
1151  (void) FTPChdir(cip, savedCwd);
1152  return (result);
1153  }
1154  DoneWithResponse(cip, rp);
1156 
1157  /* Don't forget to change back to the original directory. */
1158  (void) FTPChdir(cip, savedCwd);
1159  }
1160 
1161  rp = InitResponse();
1162  if (rp == NULL) {
1164  cip->errNo = kErrMallocFailed;
1165  Error(cip, kDontPerror, "Malloc failed.\n");
1166  return (result);
1167  }
1168 
1169  result = RCmd(cip, rp, "STAT %s", file);
1170  if (result == 2) {
1171  result = kNoErr;
1172  if (((rp->msg.nLines >= 3) || (rp->msg.nLines == 1))) {
1173  if (
1174  (rp->msg.first->next != NULL) &&
1175  (rp->msg.first->next->line != NULL) &&
1176  (
1177  (strstr(rp->msg.first->next->line, "o such file") != NULL) ||
1178  (strstr(rp->msg.first->next->line, "ot found") != NULL)
1179  )
1180  ) {
1181  cip->errNo = kErrSTATFailed;
1183  } else {
1184  result = kNoErr;
1185  }
1186  } else if (rp->msg.nLines == 2) {
1187  cip->errNo = kErrSTATFailed;
1189  } else {
1190  result = kNoErr;
1191  }
1192  } else {
1193  cip->errNo = kErrSTATFailed;
1195  }
1196  DoneWithResponse(cip, rp);
1197  return (result);
1198 } /* FTPFileExistsStat */
LinePtr last
Definition: ncftp.h:85
#define kErrBadParameter
Definition: ncftp_errno.h:56
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define kCommandAvailable
Definition: ncftp.h:380
int STATfileParamWorks
Definition: ncftp.h:179
int RCmd(const FTPCIPtr, ResponsePtr, const char *,...)
Definition: rcmd.c:718
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
#define kCommandAvailabilityUnknown
Definition: ncftp.h:379
void DoneWithResponse(const FTPCIPtr, ResponsePtr)
Definition: rcmd.c:114
LinePtr next
Definition: ncftp.h:80
#define kErrMallocFailed
Definition: ncftp_errno.h:40
char magic[16]
Definition: ncftp.h:135
smooth NULL
Definition: ftsmooth.c:416
char * startingWorkingDirectory
Definition: ncftp.h:158
int nLines
Definition: ncftp.h:86
#define kErrBadMagic
Definition: ncftp_errno.h:55
BOOL Error
Definition: chkdsk.c:66
#define kErrSTATwithFileNotAvailable
Definition: ncftp_errno.h:102
Definition: ncftp.h:89
Definition: ncftp.h:84
#define kDontPerror
Definition: util.h:45
LinePtr first
Definition: ncftp.h:85
int FTPListToMemory2(const FTPCIPtr cip, const char *const pattern, const LineListPtr llines, const char *const lsflags, const int blankLines, int *const tryMLSD)
Definition: io.c:366
#define kCommandNotAvailable
Definition: ncftp.h:381
int FTPChdir(const FTPCIPtr cip, const char *const cdCwd)
Definition: cmds.c:11
LineList msg
Definition: ncftp.h:90
int FTPGetCWD(const FTPCIPtr cip, char *const newCwd, const size_t newCwdSize)
Definition: cmds.c:254
#define kErrSTATFailed
Definition: ncftp_errno.h:101
#define kLibraryMagic
Definition: ncftp.h:65
#define kNoErr
Definition: ncftp_errno.h:9
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
void DisposeLineListContents(LineListPtr list)
Definition: linelist.c:33
ResponsePtr InitResponse(void)
Definition: rcmd.c:38
GLuint64EXT * result
Definition: glext.h:11304
char * line
Definition: ncftp.h:81
Definition: fci.c:126

Referenced by FTPFileExists2().

◆ FTPFileModificationTime()

int FTPFileModificationTime ( const FTPCIPtr  cip,
const char *const  file,
time_t *const  mdtm 
)

Definition at line 649 of file cmds.c.

650 {
651  int result;
652  ResponsePtr rp;
653 
654  if (cip == NULL)
655  return (kErrBadParameter);
656  if (strcmp(cip->magic, kLibraryMagic))
657  return (kErrBadMagic);
658 
659  if ((mdtm == NULL) || (file == NULL))
660  return (kErrBadParameter);
661  *mdtm = kModTimeUnknown;
662 
663  if (cip->hasMDTM == kCommandNotAvailable) {
666  } else {
667  rp = InitResponse();
668  if (rp == NULL) {
670  cip->errNo = kErrMallocFailed;
671  Error(cip, kDontPerror, "Malloc failed.\n");
672  } else {
673  result = RCmd(cip, rp, "MDTM %s", file);
674  if (result < 0) {
675  DoneWithResponse(cip, rp);
676  return (result);
677  } else if (strncmp(rp->msg.first->line, "19100", 5) == 0) {
678  Error(cip, kDontPerror, "Warning: Server has Y2K Bug in \"MDTM\" command.\n");
679  cip->errNo = kErrMDTMFailed;
681  } else if (result == 2) {
682  *mdtm = UnMDTMDate(rp->msg.first->line);
683  cip->hasMDTM = kCommandAvailable;
684  result = kNoErr;
685  } else if (UNIMPLEMENTED_CMD(rp->code)) {
689  } else {
690  cip->errNo = kErrMDTMFailed;
692  }
693  DoneWithResponse(cip, rp);
694  }
695  }
696  return (result);
697 } /* FTPFileModificationTime */
#define kErrMDTMNotAvailable
Definition: ncftp_errno.h:66
#define kErrBadParameter
Definition: ncftp_errno.h:56
#define kCommandAvailable
Definition: ncftp.h:380
int RCmd(const FTPCIPtr, ResponsePtr, const char *,...)
Definition: rcmd.c:718
void DoneWithResponse(const FTPCIPtr, ResponsePtr)
Definition: rcmd.c:114
time_t UnMDTMDate(char *)
Definition: util.c:486
#define kErrMallocFailed
Definition: ncftp_errno.h:40
char magic[16]
Definition: ncftp.h:135
#define UNIMPLEMENTED_CMD(a)
Definition: ncftp.h:373
smooth NULL
Definition: ftsmooth.c:416
int code
Definition: ncftp.h:92
#define kErrBadMagic
Definition: ncftp_errno.h:55
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
#define kErrMDTMFailed
Definition: ncftp_errno.h:63
BOOL Error
Definition: chkdsk.c:66
Definition: ncftp.h:89
#define kDontPerror
Definition: util.h:45
LinePtr first
Definition: ncftp.h:85
#define kCommandNotAvailable
Definition: ncftp.h:381
LineList msg
Definition: ncftp.h:90
#define kModTimeUnknown
Definition: ncftp.h:377
#define kLibraryMagic
Definition: ncftp.h:65
#define kNoErr
Definition: ncftp_errno.h:9
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ResponsePtr InitResponse(void)
Definition: rcmd.c:38
GLuint64EXT * result
Definition: glext.h:11304
char * line
Definition: ncftp.h:81
Definition: fci.c:126

Referenced by FTPFileExists2(), FTPFileSizeAndModificationTime(), and FTPGetOneF().

◆ FTPFileSize()

int FTPFileSize ( const FTPCIPtr  cip,
const char *const  file,
longest_int *const  size,
const int  type 
)

Definition at line 887 of file cmds.c.

888 {
889  int result;
890  ResponsePtr rp;
891 
892  if (cip == NULL)
893  return (kErrBadParameter);
894  if (strcmp(cip->magic, kLibraryMagic))
895  return (kErrBadMagic);
896 
897  if ((size == NULL) || (file == NULL))
898  return (kErrBadParameter);
899  *size = kSizeUnknown;
900 
902  if (result < 0)
903  return (result);
904 
905  if (cip->hasSIZE == kCommandNotAvailable) {
908  } else {
909  rp = InitResponse();
910  if (rp == NULL) {
912  cip->errNo = kErrMallocFailed;
913  Error(cip, kDontPerror, "Malloc failed.\n");
914  } else {
915  result = RCmd(cip, rp, "SIZE %s", file);
916  if (result < 0) {
917  DoneWithResponse(cip, rp);
918  return (result);
919  } else if (result == 2) {
920 #if defined(HAVE_LONG_LONG) && defined(SCANF_LONG_LONG)
922 #elif defined(HAVE_LONG_LONG) && defined(HAVE_STRTOQ)
923  *size = (longest_int) strtoq(rp->msg.first->line, NULL, 0);
924 #else
925  (void) sscanf(rp->msg.first->line, "%ld", size);
926 #endif
927  cip->hasSIZE = kCommandAvailable;
928  result = kNoErr;
929  } else if (UNIMPLEMENTED_CMD(rp->code)) {
933  } else {
934  cip->errNo = kErrSIZEFailed;
936  }
937  DoneWithResponse(cip, rp);
938  }
939  }
940  return (result);
941 } /* FTPFileSize */
#define kErrBadParameter
Definition: ncftp_errno.h:56
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define kCommandAvailable
Definition: ncftp.h:380
int RCmd(const FTPCIPtr, ResponsePtr, const char *,...)
Definition: rcmd.c:718
void DoneWithResponse(const FTPCIPtr, ResponsePtr)
Definition: rcmd.c:114
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
int FTPSetTransferType(const FTPCIPtr cip, int type)
Definition: cmds.c:836
#define kErrMallocFailed
Definition: ncftp_errno.h:40
char magic[16]
Definition: ncftp.h:135
#define UNIMPLEMENTED_CMD(a)
Definition: ncftp.h:373
smooth NULL
Definition: ftsmooth.c:416
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
#define SCANF_LONG_LONG
Definition: wincfg.h:30
int code
Definition: ncftp.h:92
GLsizeiptr size
Definition: glext.h:5919
#define longest_int
Definition: ncftp.h:68
#define kErrBadMagic
Definition: ncftp_errno.h:55
#define kErrSIZEFailed
Definition: ncftp_errno.h:62
#define kErrSIZENotAvailable
Definition: ncftp_errno.h:65
BOOL Error
Definition: chkdsk.c:66
Definition: ncftp.h:89
#define kDontPerror
Definition: util.h:45
LinePtr first
Definition: ncftp.h:85
#define kCommandNotAvailable
Definition: ncftp.h:381
LineList msg
Definition: ncftp.h:90
#define kSizeUnknown
Definition: ncftp.h:376
#define kLibraryMagic
Definition: ncftp.h:65
#define kNoErr
Definition: ncftp_errno.h:9
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ResponsePtr InitResponse(void)
Definition: rcmd.c:38
GLuint64EXT * result
Definition: glext.h:11304
char * line
Definition: ncftp.h:81
Definition: fci.c:126

Referenced by FTPFileExists2(), and FTPFileSizeAndModificationTime().

◆ FTPFileSizeAndModificationTime()

int FTPFileSizeAndModificationTime ( const FTPCIPtr  cip,
const char *const  file,
longest_int *const  size,
const int  type,
time_t *const  mdtm 
)

Definition at line 1433 of file cmds.c.

1434 {
1435  MLstItem mlsInfo;
1436  int result;
1437 
1438  if (cip == NULL)
1439  return (kErrBadParameter);
1440  if (strcmp(cip->magic, kLibraryMagic))
1441  return (kErrBadMagic);
1442 
1443  if ((mdtm == NULL) || (size == NULL) || (file == NULL))
1444  return (kErrBadParameter);
1445 
1446  *mdtm = kModTimeUnknown;
1447  *size = kSizeUnknown;
1448 
1449  result = FTPSetTransferType(cip, type);
1450  if (result < 0)
1451  return (result);
1452 
1453  result = FTPMListOneFile(cip, file, &mlsInfo);
1454  if (result < 0) {
1455  /* Do it the regular way, where
1456  * we do a SIZE and then a MDTM.
1457  */
1458  result = FTPFileSize(cip, file, size, type);
1459  if (result < 0)
1460  return (result);
1461  result = FTPFileModificationTime(cip, file, mdtm);
1462  return (result);
1463  } else {
1464  *mdtm = mlsInfo.ftime;
1465  *size = mlsInfo.fsize;
1466  }
1467 
1468  return (result);
1469 } /* FTPFileSizeAndModificationTime */
#define kErrBadParameter
Definition: ncftp_errno.h:56
int FTPFileModificationTime(const FTPCIPtr cip, const char *const file, time_t *const mdtm)
Definition: cmds.c:649
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
longest_int fsize
Definition: ncftp.h:279
int FTPSetTransferType(const FTPCIPtr cip, int type)
Definition: cmds.c:836
char magic[16]
Definition: ncftp.h:135
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
#define kErrBadMagic
Definition: ncftp_errno.h:55
time_t ftime
Definition: ncftp.h:280
int FTPFileSize(const FTPCIPtr cip, const char *const file, longest_int *const size, const int type)
Definition: cmds.c:887
#define kModTimeUnknown
Definition: ncftp.h:377
#define kSizeUnknown
Definition: ncftp.h:376
#define kLibraryMagic
Definition: ncftp.h:65
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
GLuint64EXT * result
Definition: glext.h:11304
int FTPMListOneFile(const FTPCIPtr cip, const char *const file, const MLstItemPtr mlip)
Definition: cmds.c:947
Definition: fci.c:126

Referenced by FTPGetOneF(), and FTPPutOneF().

◆ FTPFileType()

int FTPFileType ( const FTPCIPtr  cip,
const char *const  file,
int *const  ftype 
)

Definition at line 1475 of file cmds.c.

1476 {
1477  int result;
1478  MLstItem mlsInfo;
1479 
1480  if (cip == NULL)
1481  return (kErrBadParameter);
1482  if (strcmp(cip->magic, kLibraryMagic))
1483  return (kErrBadMagic);
1484 
1485  if ((file == NULL) || (file[0] == '\0')) {
1486  cip->errNo = kErrBadParameter;
1487  return (kErrBadParameter);
1488  }
1489 
1490  if (ftype == NULL) {
1491  cip->errNo = kErrBadParameter;
1492  return (kErrBadParameter);
1493  }
1494 
1495  *ftype = 0;
1496  result = FTPMListOneFile(cip, file, &mlsInfo);
1497  if (result == kNoErr) {
1498  *ftype = mlsInfo.ftype;
1499  return (kNoErr);
1500  }
1501 
1502  /* Preserve old working directory. */
1503  (void) FTPGetCWD(cip, cip->buf, cip->bufSize);
1504 
1505  result = FTPChdir(cip, file);
1506  if (result == kNoErr) {
1507  *ftype = 'd';
1508  /* Yes it was a directory, now go back to
1509  * where we were.
1510  */
1511  (void) FTPChdir(cip, cip->buf);
1512 
1513  /* Note: This improperly assumes that we
1514  * will be able to chdir back, which is
1515  * not guaranteed.
1516  */
1517  return (kNoErr);
1518  }
1519 
1520  result = FTPFileExists2(cip, file, 1, 1, 0, 1, 1);
1523 
1524  return (result);
1525 } /* FTPFileType */
#define kErrBadParameter
Definition: ncftp_errno.h:56
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define kErrNoSuchFileOrDirectory
Definition: ncftp_errno.h:105
char * buf
Definition: ncftp.h:186
char magic[16]
Definition: ncftp.h:135
int FTPFileExists2(const FTPCIPtr cip, const char *const file, const int tryMDTM, const int trySIZE, const int tryMLST, const int trySTAT, const int tryNLST)
Definition: cmds.c:1350
smooth NULL
Definition: ftsmooth.c:416
#define kErrBadMagic
Definition: ncftp_errno.h:55
int ftype
Definition: ncftp.h:278
int FTPChdir(const FTPCIPtr cip, const char *const cdCwd)
Definition: cmds.c:11
int FTPGetCWD(const FTPCIPtr cip, char *const newCwd, const size_t newCwdSize)
Definition: cmds.c:254
#define kErrFileExistsButCannotDetermineType
Definition: ncftp_errno.h:107
size_t bufSize
Definition: ncftp.h:187
#define kLibraryMagic
Definition: ncftp.h:65
#define kNoErr
Definition: ncftp_errno.h:9
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
GLuint64EXT * result
Definition: glext.h:11304
int FTPMListOneFile(const FTPCIPtr cip, const char *const file, const MLstItemPtr mlip)
Definition: cmds.c:947
Definition: fci.c:126

Referenced by FTPIsDir(), and FTPIsRegularFile().

◆ FTPFtw()

int FTPFtw ( const FTPCIPtr  cip,
const char *const  dir,
FTPFtwProc  proc,
int  maxdepth 
)

Definition at line 1700 of file glob.c.

1701 {
1702  int result, result2;
1703  char *cp;
1704  char savedcwd[1024];
1705  char curcwd[2048];
1706 
1707  result = FTPIsDir(cip, dir);
1708  if (result < 0) {
1709  /* error */
1710  return result;
1711  } else if (result == 0) {
1712  result = cip->errNo = kErrNotADirectory;
1713  return (result);
1714  }
1715 
1716  /* Preserve old working directory. */
1717  (void) FTPGetCWD(cip, savedcwd, sizeof(savedcwd));
1718 
1719  result = FTPChdir(cip, dir);
1720  if (result != kNoErr) {
1721  return (result);
1722  }
1723 
1724  /* Get full working directory we just changed to. */
1725  result = FTPGetCWD(cip, curcwd, sizeof(curcwd) - 3);
1726  if (result != kNoErr) {
1727  if (FTPChdir(cip, savedcwd) != kNoErr) {
1730  }
1731  return (result);
1732  }
1733 
1734  result2 = (*proc)(cip, curcwd, kFtwDir);
1735  if (result2 == kNoErr) {
1736  cp = curcwd + strlen(curcwd);
1737 
1738  if ((strchr(curcwd, '/') == NULL) && (strrchr(curcwd, '\\') != NULL))
1739  *cp++ = '\\';
1740  else
1741  *cp++ = '/';
1742  *cp = '\0';
1743  result = FTPFtwL2(cip, curcwd, cp, sizeof(curcwd), proc, maxdepth - 1);
1744  }
1745 
1746 
1747  if (FTPChdir(cip, savedcwd) != kNoErr) {
1748  /* Could not cd back to the original user directory -- bad. */
1750  cip->errNo = kErrCannotGoToPrevDir;
1751  return (result);
1752  }
1753 
1754  if ((result2 != kNoErr) && (result == kNoErr))
1755  result = result2;
1756 
1757  return (result);
1758 } /* FTPFtw */
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static HANDLE proc()
Definition: pdb.c:32
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
#define kFtwDir
Definition: ncftp.h:414
#define kErrNotADirectory
Definition: ncftp_errno.h:108
#define kErrCannotGoToPrevDir
Definition: ncftp_errno.h:58
int FTPChdir(const FTPCIPtr cip, const char *const cdCwd)
Definition: cmds.c:11
int FTPGetCWD(const FTPCIPtr cip, char *const newCwd, const size_t newCwdSize)
Definition: cmds.c:254
int FTPIsDir(const FTPCIPtr cip, const char *const dir)
Definition: cmds.c:1531
char * strchr(const char *String, int ch)
Definition: utclib.c:501
POINT cp
Definition: magnifier.c:61
#define kNoErr
Definition: ncftp_errno.h:9
static int FTPFtwL2(const FTPCIPtr cip, char *dir, char *end, size_t dirsize, FTPFtwProc proc, int maxdepth)
Definition: glob.c:1618
GLuint64EXT * result
Definition: glext.h:11304

◆ FTPGetCWD()

int FTPGetCWD ( const FTPCIPtr  cip,
char *const  newCwd,
const size_t  newCwdSize 
)

Definition at line 254 of file cmds.c.

255 {
256  ResponsePtr rp;
257  char *l, *r;
258  int result;
259 
260  if (cip == NULL)
261  return (kErrBadParameter);
262  if (strcmp(cip->magic, kLibraryMagic))
263  return (kErrBadMagic);
264 
265  if ((newCwd == NULL) || (newCwdSize == 0)) {
267  cip->errNo = kErrInvalidDirParam;
268  } else {
269  rp = InitResponse();
270  if (rp == NULL) {
272  cip->errNo = kErrMallocFailed;
273  Error(cip, kDontPerror, "Malloc failed.\n");
274  } else {
275  result = RCmd(cip, rp, "PWD");
276  if (result == 2) {
277  if ((r = strrchr(rp->msg.first->line, '"')) != NULL) {
278  /* "xxxx" is current directory.
279  * Strip out just the xxxx to copy into the remote cwd.