00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef _FTPLIB_H
00013 #define _FTPLIB_H
00014
00015 #ifndef EXPRT
00016 #define EXPRT
00017 #endif
00018
00019 #define FTP_MAX_ANSWERS 10
00020 #define FTP_QUIT 0
00021 #define FTP_Ctrl(x) ((x) - '@')
00022 #define FTP_FREE(x) memset ( &x , '\0' , sizeof x )
00023 #define FTP_CUT(x) ((x)&0xff)
00024
00025 typedef struct {
00026 int sock;
00027 int data;
00028 int err_no;
00029 } FTP_CON;
00030
00031 #define ftp_account(ftp,acc) ftp_command(ftp,"ACCT %s",acc,230,EOF)
00032 #define ftp_user(ftp,user) ftp_command(ftp,"USER %s",user,230,331,332,EOF)
00033 #define ftp_password(ftp,pas) ftp_command(ftp,"PASS %s",pas,230,332,EOF)
00034 #define ftp_type(ftp,type) ftp_command(ftp,"TYPE %s",type,200,EOF)
00035 #define ftp_chdir(ftp,dir) ftp_command(ftp,"CWD %s",dir,200,250,EOF)
00036 #define ftp_mkdir(ftp,dir) ftp_command(ftp,"XMKD %s",dir,200,257,EOF)
00037 #define ftp_rm(ftp,dir) ftp_command(ftp,"DELE %s",dir,200,250,EOF)
00038 #define ftp_ascii(ftp) ftp_type(ftp,"A")
00039 #define ftp_binary(ftp) ftp_type(ftp,"I")
00040 #define ftp_open_read(ftp,file) ftp_data(ftp,"RETR %s",file)
00041 #define ftp_open_write(ftp,file) ftp_data(ftp,"STOR %s",file)
00042 #define ftp_open_append(ftp,file) ftp_data(ftp,"APPE %s",file)
00043
00044
00045 #ifdef __cplusplus
00046 extern "C" {
00047 #endif
00048
00049 int EXPRT ftp_bye(FTP_CON * con);
00050 int EXPRT ftp_close(FTP_CON * con);
00051 int EXPRT ftp_connect(FTP_CON ** con, const char *host_name, unsigned short port);
00052 int EXPRT ftp_login(FTP_CON ** con, const char *host, unsigned short port, const char *user,
00053 const char *pass, const char *acct);
00054 int EXPRT ftp_move(FTP_CON * con, const char *old_name, const char *new_name);
00055 int EXPRT ftp_data(FTP_CON * con, const char *command, const char *param);
00056 int EXPRT ftp_port(FTP_CON * con, int, int, int, int, int, int);
00057 int EXPRT ftp_get(FTP_CON * con, const char *local_name, const char *remote_name);
00058 int EXPRT ftp_put(FTP_CON * con, const char *local_name, const char *remote_name);
00059 int EXPRT ftp_send(int sock, char *buffer, int n_bytes);
00060 int EXPRT ftp_receive(int sock, char *buffer, int bsize);
00061 int EXPRT ftp_send_message(FTP_CON * con, char *message);
00062 int EXPRT ftp_get_message(FTP_CON * con, char *message);
00063 BOOL EXPRT ftp_good(int number, ...);
00064 int EXPRT ftp_command(FTP_CON * con, const char *command, const char *param, ...);
00065 int EXPRT ftp_dir(FTP_CON * con, const char *file);
00066 char EXPRT *ftp_pwd(FTP_CON * con);
00067 void EXPRT ftp_debug(int (*debug_func) (char *message),
00068 int (*error_func) (char *message));
00069
00070 #ifdef __cplusplus
00071 }
00072 #endif
00073
00074 #endif // _FTPLIB_H