home *** CD-ROM | disk | FTP | other *** search
- #include "Terminal.h"
- #include "pathent.h"
-
- #define CTLZ 26 /* EOF for CP/M systems */
-
- extern char userfile[]; /* List of user names and permissions */
-
- #define MAXPATH 16 /* Maximum number of path/permission pairs */
-
- /* Per-session control block */
- struct ftp {
- struct ftp *prev; /* Linked list pointers */
- struct ftp *next;
- struct tcb *control; /* TCP control connection */
- /*
- * The transfer state have been changed to *1 and *2.
- * *1 state is where a transfer is in progress
- * *2 state is when either the data connection has finished, or a 226
- * completed message has been received.
- * The states prgress as follows: COMMAND -> *1 -> *2 -> COMMAND
- *
- * This change allows scripts to work properly.
- * Note - this only applies to the client. The server only uses the *1 state.
- */
- int state;
- int last_state;
- #define COMMAND_STATE 0 /* Awaiting user command */
- #define STARTUP_STATE 1 /* Starting up autologin */
- #define USER_STATE 2 /* Waiting for the user name */
- #define PASS_STATE 3 /* Waiting for the password */
- #define CONTINUATION_STATE 4 /* Multiple comment lines */
- #define SENDING_FILE_STATE1 5 /* Sending file data to user */
- #define SENDING_DATA_STATE1 6 /* Sending memory data to user */
- #define RECEIVING_STATE1 7 /* Storing data from user */
- #define SENDING_FILE_STATE2 8 /* Sending file data to user */
- #define SENDING_DATA_STATE2 9 /* Sending memory data to user */
- #define RECEIVING_STATE2 10 /* Storing data from user */
-
- int continue_val;
- int replycount;
- int type; /* Transfer type */
- #define IMAGE_TYPE 0
- #define ASCII_TYPE 1
- #define IMAGE_PENDING 2
-
- FILE *fp; /* File descriptor being transferred */
- char *p; /* Data in memory being transferred */
- char *cp; /* Data in memory current position */
- struct socket port; /* Remote port for data connection */
- struct tcb *data; /* Data connection */
- char *cd; /* Current directory name was server only, now used by client */
- char *username; /* Arg to USER command */
- char *password; /* Arg to PASS command - used by client */
-
- /* The following are used only by the server */
- char *path[MAXPATH]; /* Allowable path prefix */
- char perms[MAXPATH]; /* Permission flag bits */
- #define FTP_READ 1 /* Read files */
- #define FTP_CREATE 2 /* Create new files */
- #define FTP_WRITE 4 /* Overwrite or delete existing files */
- long restart;
- char *buf; /* Input command buffer */
- int cnt; /* Length of input buffer */
-
- /* And this is used only by the client */
- struct session *session;
- Terminal *window;
- int start_time; /* Start of transfer */
- long expected_size;
- int filetype; /* File type to stamp receive file with */
- int filename; /* File name of file being retreived */
-
- pathent_str *pathopts; /* Path processing options for get */
-
- int prompt; /* Current prompt type */
- int trace; /* Trace state */
- int flags; /* Supression/trap control flags */
- #define FTP_TRAP_257 0x01 /* Capture CSD information */
- #define FTP_TRAP_213 0x02 /* Capture file size or time information */
- #define FTP_SUPP_257 0x04 /* Suppress CSD information */
- #define FTP_SUPP_213 0x08 /* Suppress file size or time information */
- #define FTP_SHOW_200 0x10 /* Enable display of general info */
- #define FTP_SUPP_250 0x20 /* Suppress command OK - used when waiting for 257 */
-
- FILE *batch; /* Batch file being processed */
- char *nextsource; /* Batch file queued for execution */
- int mpstate; /* State machine for mget/mput proessing */
- #define FTPM_IDLE 0
- #define FTPM_LISTING 1
- #define FTPM_GETFILES 2
- char **margv; /* Arg list and pointer */
- int margp; /* for mput/mget processing */
- char *mtemp; /* File name of temp file */
- FILE *mfp; /* File handle of temp file */
- int32 hash;
- int32 last;
- };
-
- #define NULLFTP (struct ftp *)0
-
- /* In FTP */
- void ftpdr(struct tcb *, int16);
- void ftpdt(struct tcb *, int16);
- struct ftp *ftp_create(unsigned int);
- void ftp_delete(struct ftp *);
-
- /* In FTPCLI */
- int doftp(int, char **);
- int doaftp(int, char **); /* auto-login anon ftp */
- void ftpparse(struct session *, char *, int16);
- int doabort(int, char **);
- void ftpccr(struct tcb *, int16);
-
- /* In FTPSERV */
- int ftp1(int, char **);
- int ftp0(void);
- void ftpsds(struct tcb *, char, char);
- int permcheck(struct ftp *, int, char *);
-