📄 ftplib.h
字号:
#ifndef _FTPLIB_H
#define _FTPLIB_H
///////////libftp.h
#include <sys/cdefs.h> /* get definition (prototypes) */
#include <stdio.h>
#include <netdb.h>
#include <string.h>
#define BINARY 1
#define ASCII 2
#define TENEX 3
#define EBCDIC 4
#define NORMAL 0
#define ABNORMAL 1
#define ON 1
#define OFF 0
#define ALTPORT 190
#ifndef __CONST
#define __CONST const /* 自定义__CONST */
#endif
typedef struct
{
long size_bytes; /* total bytes transferred */
float seconds; /* time taken to transfer */
float kbs; /* kilobytes per second */
} SPEED;
typedef struct
{
FILE *filedes; /* data file descriptor */
char transf_type; /* type of transfer (bin/ascii) */
char *ftp_msg; /* error status of function or reply
string from server */
int transf_calc; /* flag to turn on xfer rate calc */
SPEED speed; /* xfer rate information */
int sockfd; /* CNTRL connection socket id */
int datasd; /* DATA connection socket id */
int reply; /* return value of function or reply
code from server */
int debug; /* flag to turn on debugging */
int linger; /* flag to turn on socket linger opt */
int connected; /* flag to indicate the existance of
a control connection for the
session under question */
struct servent *ftp_sp; /* specific service entry */
} FTPINFO;
/*
Description of data base entry for a single service.
struct servent
{
char *s_name; Official service name.
char **s_aliases; Alias list.
int s_port; Port number.
char *s_proto; Protocol to use.
};
*/
int ftp_accnt(FTPINFO *, __CONST char *);//d end
int ftp_ascii(FTPINFO *);//d end
int ftp_binary(FTPINFO *);//d end
int ftp_bye(FTPINFO *);//d end
int ftp_chdir(FTPINFO *, __CONST char *);//d end
int ftp_command(FTPINFO *, __CONST char *, __CONST char *); //d end
int ftp_dataconn(FTPINFO *, __CONST char *, __CONST char *, __CONST char *);
int ftp_del(FTPINFO *, __CONST char *);//d end
int ftp_dir(FTPINFO *, __CONST char *, __CONST char *);//d end
int ftp_ebcdic(FTPINFO *);
int ftp_getfile(FTPINFO *, __CONST char *, __CONST char *);
int ftp_idle(FTPINFO *, __CONST char *);
int ftp_initconn(FTPINFO *);
int ftp_login(FTPINFO *, __CONST char *, __CONST char *, __CONST char *, __CONST char *);//d end
int ftp_mkdir(FTPINFO *, __CONST char *);//d end
int ftp_passwd(FTPINFO *, __CONST char *);//d end
int ftp_setport( in_port_t );//d end
int ftp_prconnect(FTPINFO *, __CONST char *);//d end
int ftp_putfile(FTPINFO *, __CONST char *, __CONST char *);//d end
int ftp_appfile(FTPINFO *, __CONST char *, __CONST char *);
int ftp_pwd(FTPINFO *);//d end
int ftp_rmdir(FTPINFO *, __CONST char *);//d end
int ftp_settype(FTPINFO *, int);//d end
int ftp_site(FTPINFO *, __CONST char *);//d end
int ftp_tenex(FTPINFO *);
int ftp_user(FTPINFO *, __CONST char *);//d end
/////end of libftp.h
///////////tcpbase.h
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <sys/types.h> /* basic system data types */
#include <sys/socket.h> /* basic socket definitions */
#include <sys/time.h> /* timeval{} for select() */
#include <time.h> /* timespec{} for pselect() */
#include <netinet/in.h> /* sockaddr_in{} and other Internet defns */
#include <arpa/inet.h> /* inet(3) functions */
#include <errno.h>
#include <fcntl.h> /* for nonblocking */
#include <netdb.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h> /* for S_xxx file mode constants */
#include <sys/uio.h> /* for iovec{} and readv/writev */
#include <unistd.h>
#include <sys/wait.h>
#include <sys/un.h> /* for Unix domain sockets */
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h> /* for convenience */
#endif
#ifdef HAVE_POLL_H
#include <poll.h> /* for convenience */
#endif
#ifdef HAVE_STRINGS_H
#include <strings.h> /* for convenience */
#endif
/* Three headers are normally needed for socket/file ioctl's:
* <sys/ioctl.h>, <sys/filio.h>, and <sys/sockio.h>.
*/
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#ifdef HAVE_SYS_FILIO_H
#include <sys/filio.h>
#endif
#ifdef HAVE_SYS_SOCKIO_H
#include <sys/sockio.h>
#endif
#ifdef HAVE_PTHREAD_H
#include <pthread.h>
#endif
#define MAXLINE 256
int tcp_connect_server(int *, char *, int);
void debug_print(const char *, ...);
void message_print(const char *, ...);
void signal_alarm(int);
ssize_t tcp_read_line(int, void *, size_t);
ssize_t tcp_read(int, char *);
ssize_t tcp_write(int, void *, size_t);
ssize_t tcp_readn(int, void *, size_t);
ssize_t file_read_line(FILE *, char *, int);
/////end of tcpbase.h
///////////ftpbase.h
#include <ctype.h>
#define FTP_MESSAGE_LEN 1024
int ftp_response(FTPINFO *);
void ftp_set_timeout(FTPINFO *, int);
int ftp_check_response(FTPINFO *, char);
int ftp_pasv(FTPINFO *, char *, int *);
int ftp_get_data_sock(FTPINFO *);
/////end of ftpbase.h
void usage(char *progname);
//void check_n_close ( FTPINFO *ftpinfo, int status );
int check_n_close ( FTPINFO *ftpinfo, int status );
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -