home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / internet / tcpip / src205 / TCPIP_Src / h / ftp < prev    next >
Encoding:
Text File  |  1995-04-18  |  4.9 KB  |  119 lines

  1. #include "Terminal.h"
  2. #include "pathent.h"
  3.  
  4. #define CTLZ    26              /* EOF for CP/M systems */
  5.  
  6. extern char userfile[]; /* List of user names and permissions */
  7.  
  8. #define MAXPATH 16              /* Maximum number of path/permission pairs */
  9.  
  10. /* Per-session control block */
  11. struct ftp {
  12.         struct ftp *prev;       /* Linked list pointers */
  13.         struct ftp *next;
  14.         struct tcb *control;    /* TCP control connection */
  15. /*
  16.  * The transfer state have been changed to *1 and *2.
  17.  * *1 state is where a transfer is in progress
  18.  * *2 state is when either the data connection has finished, or a 226
  19.  *    completed message has been received.
  20.  * The states prgress as follows: COMMAND -> *1 -> *2 -> COMMAND
  21.  *
  22.  * This change allows scripts to work properly.
  23.  * Note - this only applies to the client. The server only uses the *1 state.
  24.  */
  25.         int state;
  26.         int last_state;
  27. #define COMMAND_STATE           0       /* Awaiting user command */
  28. #define STARTUP_STATE           1       /* Starting up autologin */
  29. #define USER_STATE              2       /* Waiting for the user name */
  30. #define PASS_STATE              3       /* Waiting for the password */
  31. #define CONTINUATION_STATE      4       /* Multiple comment lines */
  32. #define SENDING_FILE_STATE1     5       /* Sending file data to user */
  33. #define SENDING_DATA_STATE1     6       /* Sending memory data to user */
  34. #define RECEIVING_STATE1        7       /* Storing data from user */
  35. #define SENDING_FILE_STATE2     8       /* Sending file data to user */
  36. #define SENDING_DATA_STATE2     9       /* Sending memory data to user */
  37. #define RECEIVING_STATE2        10      /* Storing data from user */
  38.  
  39.         int continue_val;
  40.         int replycount;
  41.         int type;              /* Transfer type */
  42. #define IMAGE_TYPE      0
  43. #define ASCII_TYPE      1
  44. #define IMAGE_PENDING   2
  45.  
  46.         FILE *fp;               /* File descriptor being transferred */
  47.         char *p;                /* Data in memory being transferred */
  48.         char *cp;               /* Data in memory current position */
  49.         struct socket port;     /* Remote port for data connection */
  50.         struct tcb *data;       /* Data connection */
  51.         char *cd;               /* Current directory name was server only, now used by client */
  52.         char *username;         /* Arg to USER command */
  53.         char *password;         /* Arg to PASS command - used by client */
  54.  
  55.         /* The following are used only by the server */
  56.         char *path[MAXPATH];    /* Allowable path prefix */
  57.         char perms[MAXPATH];    /* Permission flag bits */
  58. #define FTP_READ        1       /* Read files */
  59. #define FTP_CREATE      2       /* Create new files */
  60. #define FTP_WRITE       4       /* Overwrite or delete existing files */
  61.         long restart;
  62.         char *buf;              /* Input command buffer */
  63.         int cnt;                /* Length of input buffer */
  64.  
  65.         /* And this is used only by the client */
  66.         struct session *session;
  67.         Terminal       *window;
  68.         int  start_time;       /* Start of transfer */
  69.         long expected_size;
  70.         int filetype;           /* File type to stamp receive file with */
  71.         int filename;           /* File name of file being retreived */
  72.  
  73.         pathent_str *pathopts;  /* Path processing options for get */
  74.  
  75.         int  prompt;            /* Current prompt type */
  76.         int  trace;             /* Trace state */
  77.         int  flags;             /* Supression/trap control flags */
  78. #define FTP_TRAP_257  0x01      /* Capture CSD information */
  79. #define FTP_TRAP_213  0x02      /* Capture file size or time information */
  80. #define FTP_SUPP_257  0x04      /* Suppress CSD information */
  81. #define FTP_SUPP_213  0x08      /* Suppress file size or time information */
  82. #define FTP_SHOW_200  0x10      /* Enable display of general info */
  83. #define FTP_SUPP_250  0x20      /* Suppress command OK - used when waiting for 257 */
  84.  
  85.         FILE *batch;            /* Batch file being processed */
  86.         char *nextsource;       /* Batch file queued for execution */
  87.         int mpstate;            /* State machine for mget/mput proessing */
  88. #define FTPM_IDLE 0
  89. #define FTPM_LISTING 1
  90. #define FTPM_GETFILES 2
  91.         char **margv;           /* Arg list and pointer */
  92.         int margp;              /* for mput/mget processing */
  93.         char *mtemp;            /* File name of temp file */
  94.         FILE *mfp;              /* File handle of temp file */
  95.         int32 hash;
  96.         int32 last;
  97. };
  98.  
  99. #define NULLFTP (struct ftp *)0
  100.  
  101. /* In FTP */
  102. void   ftpdr(struct tcb *, int16);
  103. void   ftpdt(struct tcb *, int16);
  104. struct ftp *ftp_create(unsigned int);
  105. void   ftp_delete(struct ftp *);
  106.  
  107. /* In FTPCLI */
  108. int  doftp(int, char **);
  109. int  doaftp(int, char **);  /* auto-login anon ftp */
  110. void ftpparse(struct session *, char *, int16);
  111. int  doabort(int, char **);
  112. void ftpccr(struct tcb *, int16);
  113.  
  114. /* In FTPSERV */
  115. int  ftp1(int, char **);
  116. int  ftp0(void);
  117. void ftpsds(struct tcb *, char, char);
  118. int  permcheck(struct ftp *, int, char *);
  119.