File: fgftpcon.h

package info (click to toggle)
ftpgrab 0.1.2r-8
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 376 kB
  • ctags: 335
  • sloc: cpp: 2,790; makefile: 26
file content (84 lines) | stat: -rw-r--r-- 1,909 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef _FGFTPCON_H
#define _FGFTPCON_H

// fgftpcon.h
//
// FTPGrabFTPConnection
//
// Class implementing getting of files over FTP protocol

#ifndef _FGCONI_H
#include "fgconi.h"
#endif

// Fun and games!!
struct _IO_FILE;
typedef struct _IO_FILE FILE;

class FGFTPCon : public FGConnectionInterface {
public:
  // Default constructor
  FGFTPCon();

  // Destructor
  ~FGFTPCon();

  // Interface methods from base class
  virtual void Connect(const FGString& host);
  virtual void ChangeDir(const FGString& dir);
  virtual FGDirListing GetDirListing(void);
  virtual int GetFile(const FGString& file);
  virtual void PostFileTransfer(void);
  virtual void Disconnect(void);

private:
  // Banned!
  FGFTPCon(const FGFTPCon& other);
  FGFTPCon& operator=(const FGFTPCon& other);

  // Implementation details

  bool mConnected;

  // File descriptor of connected command stream
  int mCommandFD;

  // Stream version of the above
  FILE* mpCommandStream;

  // Buffer for storing/parsing the FTP server replies
  char mBuf[1024];

  // Value of FTP server's reply
  int mResponse;

  // Details for remote data connection
  int mDataFD;
  int mRemotePort;
  FILE* mpDirStream;
  unsigned long mRemoteAddr;

  // Internal constants
  static const int msFTPPort;

  static const int msRespPassRequired;
  static const int msRespBadLogin;
  static const int msRespLoginOK;
  static const int msRespNotFound;
  static const int msRespTransferDone;
  static const int msRespChangeDirOK;
  static const int msRespCommandOK;
  static const int msRespGoodbye;
  static const int msRespPleaseLogin;
  static const int msRespPassiveOK;
  static const int msRespTransferOpen;

  // Internal functions
  void GetResponse(void);
  void GetLine(void);
  void SendCommand(const FGString& cmd) const;
  void SetupPassivePort(void);
  void InternalConnect(int* pDestFD, int port, void* pInetAddr);
};

#endif // _FGFTPCON_H