📄 prozilla.h
字号:
/****************************************************************************** libprozilla - a download accelerator library Copyright (C) 2001 Kalum Somaratna This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA******************************************************************************//* Main include-file. *//* $Id: prozilla.h,v 1.57 2001/10/27 11:24:40 kalum Exp $ */#ifndef PROZILLA_H#define PROZILLA_H#include <stdio.h>#include <pthread.h>#include <sys/time.h>#include "netrc.h"#ifdef __cplusplusextern "C" {#endif typedef enum { /*Connect establishment related values */ NOCONERROR, HOSTERR, CONSOCKERR, CONERROR, CONREFUSED, ACCEPTERR, ACCEPTOK, BINDERR, BINDOK, LISTENERR, LISTENOK, SERVERCLOSECONERR, CONPORTERR, /* URL handling related value */ URLOK, URLHTTP, URLFTP, URLFILE, URLUNKNOWN, URLBADPORT, URLBADHOST, URLBADPATTERN, /* HTTP related values */ NEWLOCATION, HOK, HEOF, HERR, HAUTHREQ, HAUTHFAIL, HTTPNSFOD, /*FTP related value */ FTPOK, FTPLOGINC, FTPLOGREFUSED, FTPPORTERR, FTPNSFOD, FTPRETROK, FTPUNKNOWNTYPE, FTPUNKNOWNCMD, FTPSIZEFAIL, FTPERR, FTPRESTFAIL, FTPACCDENIED, FTPPWDERR, FTPINVPASV, FTPNOPASV, FTPCONREFUSED, FTPCWDFAIL, FTPPWDFAIL, FTPSERVCLOSEDATLOGIN, /*Error values that can happen due to failed proxie request */ GATEWAYTIMEOUT, SERVICEUNAVAIL, BADGATEWAY, INTERNALSERVERR, UNKNOWNREQ, /*File handling related return values. */ FOPENERR, FWRITEERR, RETROK, /*Download related retrn values. */ DLINPROGRESS, DLABORTED, DLDONE, CANTRESUME, DLLOCALFATAL, DLREMOTEFATAL, /*FTPSEARCH+ping related return values. */ FTPSINPROGRESS, MASSPINGINPROGRESS, FTPSFAIL, MASSPINGDONE, /*PING related values */ PINGOK, PINGTIMEOUT, /*Misc Value */ RETRFINISHED, READERR, PROXERR, WRITEERR, FILEISDIR, MIRINFOK, MIRPARSEOK, MIRPARSEFAIL, FILEGETOK, /*Related to file joining */ JOININPROGRESS, JOINDONE, JOINERR } uerr_t;#define FTP_BUFFER_SIZE 2048#define HTTP_BUFFER_SIZE 2048#define MAX_MSG_SIZE 2048#define DEFAULT_FTP_PORT 21#define DEFAULT_HTTP_PORT 80/* This is used when no password is found or specified. */#define DEFAULT_FTP_USER "anonymous"#define DEFAULT_FTP_PASSWD "billg@hotmail.com"/* The D/L ed fragments will be saved to files with this extension. * E.g.: gnu.jpg.prz0, gnu.jpg.prz1 etc... */#define DEFAULT_FILE_EXT ".prz"/* The extension for the log file created. */#define DEFAULT_LOG_EXT ".log"#define DEFAULT_USER_AGENT "Prozilla" typedef char longstring[1024];/* Callback message function. */ typedef void (*message_proc) (const char *msg, void *cb_data);/* Structure containing info on a URL. */ typedef struct _urlinfo { char *url; /* Unchanged URL. */ uerr_t proto; /* URL protocol. */ char *host; /* Extracted hostname. */ unsigned short port; char ftp_type; char *path, *dir, *file; /* Path, dir and file (properly decoded). */ char *user, *passwd; /* For FTP. */ char *referer; /* The source from which the request URI was obtained. */ } urlinfo; typedef enum { USERatSITE, USERatPROXYUSERatSITE, USERatSITE_PROXYUSER, PROXYUSERatSITE, LOGINthenUSERatSITE, OPENSITE, SITESITE, HTTPPROXY, FTPGATE, WINGATE } proxy_type; typedef enum { IDLE = 0, CONNECTING, LOGGININ, DOWNLOADING, COMPLETED, LOGINFAIL, CONREJECT, REMOTEFATAL, LOCALFATAL, TIMEDOUT, MAXTRYS } dl_status; typedef enum { NOT_FOUND, REGULAR_FILE, DIRECTORY, SYMBOLIC_LINK, UNKNOWN } file_type_t; typedef struct { long len; /* Received length. */ long contlen; /* Expected length. */ int res; /* The result of last read. */ /* -1 = Accept ranges not found. 0 = Accepts range is none. 1 = Accepts ranges. */ int accept_ranges; char *newloc; /* New location (redirection). */ char *remote_time; /* Remote time-stamp string. */ char *error; /* Textual HTTP error. */ int statcode; /* Status code. */ } http_stat_t; typedef struct { urlinfo proxy_url; char *username; char *passwd; proxy_type type; boolean use_proxy; } proxy_info; typedef struct libprozinfo { int argc; char **argv; boolean debug_mode; /* For netrc. */ netrc_entry *netrc_list; boolean use_netrc; char *home_dir; char *ftp_default_user; char *ftp_default_passwd; char *dl_dir; char *output_dir; char *log_dir; boolean ftp_use_pasv; proxy_info *ftp_proxy; proxy_info *http_proxy; boolean http_no_cache; /* the default timeout for all the connection types (ctrl, data etc) */ struct timeval conn_timeout; struct timeval conn_retry_delay; int max_attempts; long max_bps_per_dl; } libprozinfo; extern libprozinfo libprozrtinfo; typedef struct response_line { char *line; struct response_line *next; } response_line; typedef struct connection_t { /* struct which contains the parsed url info. It includes the remote file, path,protocol etc. */ urlinfo u; /* The error status of the connection. */ uerr_t err; /* Proxy specific info. */ proxy_info *ftp_proxy; proxy_info *http_proxy; /* Netrc. */ boolean use_netrc; /* FTP specific info. */ boolean ftp_use_pasv; struct timeval xfer_timeout; struct timeval conn_timeout; struct timeval ctrl_timeout; unsigned char pasv_addr[6]; int ctrl_sock; int data_sock; int listen_sock; /* Additional info about what this URL is. */ /* FIXME Should this be in the url_info struct? */ file_type_t file_type; /* The lines that the server returned. */ response_line *serv_ret_lines; /* Does the server support resume? */ boolean resume_support; /* The file name to save the data to locally. */ char *localfile; /* Pointer to file that we will be saving the data to locally. */ FILE *fp; /* Tells whether to open the file for appending or for writing etc. Used for adding resume support. */ char *file_mode; /* FIXME Add an enum here to say whether run mode is resume or normal etc. and remove the file mode. */ long remote_startpos; long orig_remote_startpos; long remote_endpos; long remote_bytes_received; long main_file_size; /* The permanent base offset from the beginning of the file, put in anticipation of making the threads download to a single file. */ long local_base_offset; /* Indicates the startpos of the localfile. It is always 0 in normal mode and can be any positive value in resume mode. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -