#ifndef MIRC
#define MIRC
#include <windows.h>
#include <stdio.h>
#ifdef HAVE_SSL
#include <openssl/ssl.h>
#endif
//#include "hash.h"
#define WM_MCOMMAND (WM_USER+200)
#define WM_MEVALUATE (WM_USER+201)
#define WGET_THREAD_ID wget_get_thread_by_id(GetCurrentThreadId())
#define WGET_THREAD thread[WGET_THREAD_ID]
#define WGET_OPTIONS WGET_THREAD->opt
#define WGET_GLOBAL_DOWNLOAD_COUNT WGET_THREAD->global_download_count
#define WGET_LIMIT_DATA WGET_THREAD->limit_data
#define WGET_TOTAL_BYTES WGET_THREAD->total_downloaded_bytes
#define WGET_HTML_LIST WGET_THREAD->downloaded_html_list
#define WGET_HTML_SET WGET_THREAD->downloaded_html_set
#define WGET_FILE_URL_MAP WGET_THREAD->dl_file_url_map
#define WGET_URL_FILE_MAP WGET_THREAD->dl_url_file_map
#define WGET_ACTIVE_P WGET_THREAD->socket.pc_active_p
#define WGET_LAST_HOST_IP WGET_THREAD->socket.pc_last_host_ip
#define WGET_LAST_PORT WGET_THREAD->socket.pc_last_port
#define WGET_LAST_FD WGET_THREAD->socket.pc_last_fd
#ifdef HAVE_SSL
#define WGET_ACTIVE_SSL WGET_THREAD->socket.pc_active_ssl
#define WGET_LAST_SSL WGET_THREAD->socket.pc_last_ssl
#endif /* HAVE_SSL */
#define SIGNAL_INIT(restval,url,file) SendCommand(mIRC_window, "/.signal WGET_INIT %d %d %s %s", WGET_THREAD_ID+1,restval,url,file)
#define SIGNAL_PROGRESS(size,speed,percent,total) SendCommand(mIRC_window, "/.signal WGET_PROGRESS %d %d %s %3d %d", WGET_THREAD_ID+1,size,speed,percent,total)
#define SIGNAL_END(result) SendCommand(mIRC_window, "/.signal WGET_END %d %s %d %d", WGET_THREAD_ID+1, uerr_to_string(result), WGET_THREAD->download_info.size, WGET_THREAD->download_info.total)
#define SIGNAL_LOG(log) SendCommand(mIRC_window, "/.signal WGET_LOG %d %s", WGET_THREAD_ID+1,log)
typedef struct s_thread_t {
HANDLE handle;
int status;
int id;
int thread_id;
long tlsIndex;
struct options *opt;
long total_downloaded_bytes;
char ftp_last_respline[128];
int result;
struct {
double rate;
long size;
long total;
int percent;
double last_timer_value;
} download_info;
struct {
long chunk_bytes;
double chunk_start;
double sleep_adjust;
} limit_data;
struct {
int cookies_loaded_p;
struct cookie_jar *wget_cookie_jar;
} cookies;
int global_download_count;
struct slist *downloaded_html_list;
struct hash_table *downloaded_html_set;
struct hash_table *dl_file_url_map;
struct hash_table *dl_url_file_map;
FILE *file_handle;
int sock_fd;
char *filename;
/* Whether a persistent connection is active. */
struct {
int pc_active_p;
/* Host and port of currently active persistent connection. */
struct address_list *pc_last_host_ip;
unsigned short pc_last_port;
/* File descriptor of the currently active persistent connection. */
int pc_last_fd;
#ifdef HAVE_SSL
/* Whether a ssl handshake has occoured on this connection */
int pc_active_ssl;
/* SSL connection of the currently active persistent connection. */
SSL *pc_last_ssl;
#endif /* HAVE_SSL */
} socket;
} thread_t, *pthread_t;
typedef struct s_param_info { pthread_t thread; char *data; } param_info;
thread_t **thread;
enum status_t {
STATUS_CLEANUP = -1,
STATUS_CLOSED,
STATUS_LOADING,
STATUS_LOADED,
STATUS_DOWNLOAD
};
BOOL SendCommand(HWND hwnd, char *fmt, ...);
BOOL vSendCommand(HWND hwnd, char *fmt, va_list args);
int wget_get_thread_by_id(long thread_id);
extern int sprintf(char *, const char *, ...);
extern int vsprintf(char *, const char *, va_list);
HWND mIRC_window;
#endif Powered by
GeSHi Syntax Highlighting software.
Author of all (other) material unless otherwise specified:
Loren Segal. Copyright 2005.