📄 ftp.h
字号:
/************************************************************************* Copyright (c) 1993-2001 by NETsilicon Inc.** This software is copyrighted by and is the sole property of* NETsilicon. All rights, title, ownership, or other interests* in the software remain the property of NETsilicon. This* software may only be used in accordance with the corresponding* license agreement. Any unauthorized use, duplication, transmission,* distribution, or disclosure of this software is expressly forbidden.** This Copyright notice may not be removed or modified without prior* written consent of NETsilicon.** NETsilicon, reserves the right to modify this software* without notice.** NETsilicon* 411 Waverley Oaks Road USA 781.647.1234* Suite 227 http://www.netsilicon.com* Waltham, MA 02452 AmericaSales@netsilicon.com*************************************************************************** $Name: Fusion 6.52 Fusion 6.51 $* $Date: 2002/01/16 08:38:18 $* $Source: M:/psisrc/ftp/incl/rcs/ftp.h $* $Revision: 1.13 $************************************************************************** - Revision Log - ** Who When Why** FND 11/30/01 Add os_printf() prototype so FTP_DEBUGx works.***************************************************************************** File Name : ftp.h** Description:* Declarations which are used by all portions of FTP:* server-DTP (libftp.a)* server-FTP process (ftpd)* server-PI (libftp.a, spi.h)* user-DTP (libdtp.a)* user-FTP process (ftp)* user-PI (libftp.a, cpi.h)*************************************************************************/#ifndef _FTP_#define _FTP_#include "fnssock.h"#include "tnbuf.h"#ifdef FTP_DEBUG#ifndef os_printfimport void os_printf(char * msg,...);#endif #define FTP_DEBUG0(s) os_printf(s) #define FTP_DEBUG1(s,x) os_printf(s,x) #define FTP_DEBUG2(s,x,y) os_printf(s,x,y) #define FTP_DEBUG3(s,x,y,z) os_printf(s,x,y,z) #define FTP_DEBUG4(s,w,x,y,z) os_printf(s,w,x,y,z) #define FTP_DEBUG5(s,v,w,x,y,z) os_printf(s,v,w,x,y,z) #define FTP_DEBUG6(s,u,v,w,x,y,z) os_printf(s,u,v,w,x,y,z)#else #define FTP_DEBUG0(s) #define FTP_DEBUG1(s,x) #define FTP_DEBUG2(s,x,y) #define FTP_DEBUG3(s,x,y,z) #define FTP_DEBUG4(s,w,x,y,z) #define FTP_DEBUG5(s,v,w,x,y,z) #define FTP_DEBUG6(s,u,v,w,x,y,z)#endif#define cdc_nilpfi ((int(*)(struct cdc_s *datafunc)) 0)#define nserror(cdcp) err_to_string(cdcp->c_errno)#define USER_LEN 25#define FFTP_MAX_PATH_LEN 256/* * 'fd_t' is the handle for a file. Most file systems * implement it as "FILE *" which indicates the address * of a data structure. Other operating sytems may * require it to be a structure. */typedef int fd_t; /* file descriptor type *//* Transfer modes */typedef u8 ftp_mode_t; /* see below */#define MODE_STREAM 1 /* stream mode (default) */#define MODE_BLOCK 2 /* block mode */#define MODE_COMPRESSED 3 /* compressed mode */#define MODE_LAST 3 /* total number of modes *//* Repesentation types *//* t_type */#define TYPE_ASCII 1 /* ASCII type (default); field 't_form' contains the form */#define TYPE_BYTE 2 /* logical bytes; field 't_form' contains the byte size */#define TYPE_EBCDIC 3 /* EBCDIC type; field 't_form' contains the form */#define TYPE_IMAGE 4 /* image type; field 't_form' is unused */#define TYPE_LAST 4 /* total number of types *//* t_form */#define FORM_NONPRINT 1 /* non-print format (default) */#define FORM_TELNET 2 /* telnet format */#define FORM_ASA 3 /* ASA carriage control format */#define FORM_LAST 3 /* total number of forms */typedef struct type_s { u8 t_type; /* see above */ u8 t_form; /* see above */ } type_t;/* File structures */typedef u8 stru_t; /* see below */#define STRU_FILE 1 /* file structure (default) */#define STRU_RECORD 2 /* record structure */#define STRU_PAGE 3 /* page structure */#define STRU_LAST 3 /* total number of file structures *//* * Structure to represent an operating system's "best" settings * for mode, structure, and type. */typedef struct os_s { char * os_name; /* operating system name (see Assigned Numbers) */ ftp_mode_t os_mode; /* best transfer mode for the data connection */ stru_t os_cstru; /* best file structure for the client to use */ stru_t os_sstru; /* server's natural file structure */ type_t os_ctype; /* best representation type for the client to use */ type_t os_stype; /* server's natural representation type */ } os_t;/* Telnet buffer structure definitions * This has a bigger buffer than the tnbuf structure used for telnet. */#define TN_FTP_BUF_SIZE 2 * 1024typedef struct tnftpbuf { int tn_fd; /* file descriptor */ u16 tn_flags; /* see below */ int (*tn_func)(struct tnio * tniop); u8 * tn_nxt; /* next character pointer */ u8 * tn_lst; /* last character pointer */ u8 tn_buf[TN_FTP_BUF_SIZE]; /* da goods */ } tnftpbuf;/* c_flags */#define C_PASSIVE 0x2 /* server is in passive mode */#define C_XRATED 0x4 /* server understands eXperimental commands */#define C_TRANSFER 0x8 /* transfer in progress over data connection, field 'c_transfer' contains the transfer type */#define C_ABORTED 0x10 /* transfer aborted by SIGINT (client), or 'ABOR' (server) */#define C_USER 0x20 /* user logged in to server (client only) */#define C_FNS 0x40 /* server system is FNS (determined by the 'SITE' command) (client only) */#define C_REPLY 0x100 /* reply received (client only, locks this transaction) */#define C_COMMAND 0x200 /* command received (server only) */#define C_VERBOSE 0x400 /* print additional information */#define C_TRACE 0x1000 /* trace FTP transactions */#define C_PRESERVE 0x2000 /* preserve file modes if possible */#define C_QUIET 0x4000 /* run in quiet mode */#define C_FORCE 0x8000 /* delete file before overwriting */#define C_HASH 0x20000 /* print hash marks during transfers */#define C_TIMEOUT 0x40000 /* timeout has occurred */#define C_ANONYMOUS 0x80000 /* anonymous login */#define C_APPEND 0x100000 /* performing append */#define C_LISTENING 0x400000 /* listening flag for synchronous nselect */#define C_ACTIVE 0x800000 /* active host */#define C_PORT 0x1000000 /* send port command for data transfers */#define C_GLOB 0x2000000 /* enable filename expansion */#define C_STATS 0x8000000 /* Print transfer statistics *//* * Control and data connection structure. * This structure is the focus of all activity in FTP. */typedef struct cdc_s { tnio c_telnet; /* buffers to implement Telnet protocol over the control conection */ tnftpbuf * c_rbuf; /* special buffer where the final reply resides */ ftp_mode_t c_mode; /* transfer mode of data connection */ stru_t c_structure; /* file structure of connected host */ type_t c_type; /* representation type of connected host */ type_t c_clienttype; /* client representation type*/ struct in_sockaddr c_ctladdress; /* address of connected host control connection */ char c_cwd[FFTP_MAX_PATH_LEN]; /* Current working dir */ u32 c_flags; /* 32-bit mask to indicate various states */ int c_lsd; /* listening socket */ char c_transfer[4]; /* transfer taking place if C_TRANSFER is set ("APPE", "RETR", ...) */ u16 c_reply; /* reply received (client only) */ char * c_user; /* name of user logged in */ os_t * c_system; /* operating system if known (obtained by 'SYST' command) (client only) */ struct in_sockaddr c_dataaddress; /* data connection server address */ struct in_sockaddr c_passiveaddress; /* data connection PASSIVE server address */ struct cdc_s * c_activehost; /* pointer to the active party */ /* transfer command to perform active part of transfer */ int (*c_actcmd)(struct cdc_s * c_activehost, char * c_actfile); int (*c_datacmd)(struct cdc_s *datafunc); int status; char * c_actfile; /* file the active transfer operates on */ fd_t c_fd; /* file descriptor of file being accessed */ int c_datasocket; /* data connection socket */ u8 c_descriptor; /* block mode transfer descriptor code */ u16 c_length; /* number of bytes in the buffer */ char * c_bufstart; /* points to beginning of user buffer */ char * c_bufptr; /* points to next available char in the user buffer */ char * c_bufend; /* Points to the end of buffer in use */ boolean c_enobuf; /* true if user buffer can't hold all of the data received */ int c_errno; /* Holds errno (for what it's worth) */ char * c_clientfile; /* client file name */ char * c_serverfile; /* server file name */ } cdc_t;/* * Interface to O/S and file-system */extern int os_access (cdc_t *cdcp, char *file, int mode);extern int os_append (cdc_t *cdcp, char *path);extern int os_chdir (cdc_t *cdcp, char *path);extern int os_close(cdc_t * cdcp);extern int os_create (cdc_t *cdcp, char *path);extern int os_delete (cdc_t *cdcp, char *path);extern int os_initcwd (cdc_t *cdcp);extern int os_list (cdc_t * cdcp, char *path);extern int os_mkdir (cdc_t *cdcp, char *path, unsigned mode);extern int os_nlst (cdc_t *cdcp, char *arg);extern int os_open (cdc_t *cdcp, char *path);extern int os_pwd (cdc_t *cdcp);extern int os_rename (cdc_t *cdcp, char *oldf, char *newf);extern int os_rmdir (cdc_t *cdcp, char *dir);extern int os_set_user(char * name);extern int os_tempfile(cdc_t * cdcp);extern int os_write_to_file (cdc_t *cdcp, char *data_ptr, int amount);extern int os_read_from_file (cdc_t *cdcp, char *out_buffer, int buf_size);extern char *os_mktemp(char * path);extern boolean os_isdir(char * path);extern boolean os_privileged(void);extern void os_logout(void);extern char * os_system(void);/* * Support functions */extern int flush(tnio * tniop);extern void ftp_close_data_socket (cdc_t *cdcp);extern int store(cdc_t * cdcp);extern int retrieve(cdc_t * cdcp);extern char *ftp_strasn (const char *s);extern char * mode_name(ftp_mode_t mode);extern char * str_format(char * string, int length);extern char * stru_name(stru_t stru);extern char * type_name(type_t * tp);extern void cdc_quit (cdc_t * cdcp);/* * Demo functions */extern void do_ftpsingle (void);extern void get_cwd (cdc_t * cdcp);#endif /* _FTP_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -